2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to handling incoming events.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "atoms.h"
|
2013-02-26 07:45:44 +00:00
|
|
|
#include "cursor.h"
|
2012-11-20 16:26:50 +00:00
|
|
|
#include "focuschain.h"
|
2013-04-26 08:41:24 +00:00
|
|
|
#include "netinfo.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "workspace.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "x11client.h"
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "tabbox.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "effects.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "group.h"
|
|
|
|
#include "rules.h"
|
2021-12-27 11:30:02 +00:00
|
|
|
#include "screenedge.h"
|
2013-04-03 10:19:27 +00:00
|
|
|
#include "screens.h"
|
2022-03-23 10:13:38 +00:00
|
|
|
#include "unmanaged.h"
|
|
|
|
#include "useractions.h"
|
2022-01-13 13:54:03 +00:00
|
|
|
#include "utils/xcbutils.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-07-22 11:11:19 +00:00
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
2013-09-10 11:18:55 +00:00
|
|
|
#include <QApplication>
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2014-12-02 12:50:26 +00:00
|
|
|
#include <QHoverEvent>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QMouseEvent>
|
2014-11-28 13:50:21 +00:00
|
|
|
#include <QStyleHints>
|
2014-12-02 12:50:26 +00:00
|
|
|
#include <QWheelEvent>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <kkeyserver.h>
|
|
|
|
|
2021-08-12 17:57:17 +00:00
|
|
|
#include <xcb/damage.h>
|
2013-07-26 10:00:14 +00:00
|
|
|
#include <xcb/sync.h>
|
2022-02-28 19:12:30 +00:00
|
|
|
#if XCB_ICCCM_FOUND
|
2013-08-07 07:53:08 +00:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2014-06-11 05:51:07 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-08-21 19:50:23 +00:00
|
|
|
#include "composite.h"
|
2014-09-02 16:46:07 +00:00
|
|
|
#include "x11eventfilter.h"
|
2011-08-21 19:50:23 +00:00
|
|
|
|
2015-04-02 07:49:39 +00:00
|
|
|
#include "wayland_server.h"
|
2020-04-29 15:18:41 +00:00
|
|
|
#include <KWaylandServer/surface_interface.h>
|
2015-02-09 15:08:53 +00:00
|
|
|
|
2014-09-19 08:04:00 +00:00
|
|
|
#ifndef XCB_GE_GENERIC
|
|
|
|
#define XCB_GE_GENERIC 35
|
2022-03-23 10:13:38 +00:00
|
|
|
typedef struct xcb_ge_generic_event_t
|
|
|
|
{
|
|
|
|
uint8_t response_type; /**< */
|
|
|
|
uint8_t extension; /**< */
|
2014-09-19 08:04:00 +00:00
|
|
|
uint16_t sequence; /**< */
|
|
|
|
uint32_t length; /**< */
|
|
|
|
uint16_t event_type; /**< */
|
2022-03-23 10:13:38 +00:00
|
|
|
uint8_t pad0[22]; /**< */
|
2014-09-19 08:04:00 +00:00
|
|
|
uint32_t full_sequence; /**< */
|
|
|
|
} xcb_ge_generic_event_t;
|
|
|
|
#endif
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Workspace
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 14:19:05 +00:00
|
|
|
static xcb_window_t findEventWindow(xcb_generic_event_t *event)
|
|
|
|
{
|
|
|
|
const uint8_t eventType = event->response_type & ~0x80;
|
2022-03-23 10:13:38 +00:00
|
|
|
switch (eventType) {
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_KEY_PRESS:
|
|
|
|
case XCB_KEY_RELEASE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_key_press_event_t *>(event)->event;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_BUTTON_PRESS:
|
|
|
|
case XCB_BUTTON_RELEASE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_button_press_event_t *>(event)->event;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_MOTION_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_motion_notify_event_t *>(event)->event;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_ENTER_NOTIFY:
|
|
|
|
case XCB_LEAVE_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_enter_notify_event_t *>(event)->event;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_FOCUS_IN:
|
|
|
|
case XCB_FOCUS_OUT:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_focus_in_event_t *>(event)->event;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_EXPOSE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_expose_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_GRAPHICS_EXPOSURE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_graphics_exposure_event_t *>(event)->drawable;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_NO_EXPOSURE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_no_exposure_event_t *>(event)->drawable;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_VISIBILITY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_visibility_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_CREATE_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_create_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_destroy_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_UNMAP_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_unmap_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_MAP_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_map_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_MAP_REQUEST:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_map_request_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_REPARENT_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_reparent_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_configure_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_CONFIGURE_REQUEST:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_configure_request_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_GRAVITY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_gravity_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_RESIZE_REQUEST:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_resize_request_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_CIRCULATE_NOTIFY:
|
|
|
|
case XCB_CIRCULATE_REQUEST:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_circulate_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_property_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_COLORMAP_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_colormap_notify_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_client_message_event_t *>(event)->window;
|
2013-07-26 14:19:05 +00:00
|
|
|
default:
|
|
|
|
// extension handling
|
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_shape_notify_event_t *>(event)->affected_window;
|
2013-07-26 14:19:05 +00:00
|
|
|
}
|
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return reinterpret_cast<xcb_damage_notify_event_t *>(event)->drawable;
|
2013-07-26 14:19:05 +00:00
|
|
|
}
|
|
|
|
return XCB_WINDOW_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles workspace specific XCB event
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-26 05:52:56 +00:00
|
|
|
bool Workspace::workspaceEvent(xcb_generic_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 06:01:16 +00:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
2022-03-23 10:13:38 +00:00
|
|
|
if (effects && static_cast<EffectsHandlerImpl *>(effects)->hasKeyboardGrab()
|
2022-03-25 12:20:32 +00:00
|
|
|
&& (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return false; // let Qt process it, it'll be intercepted again in eventFilter()
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// events that should be handled before Clients can get them
|
2013-07-26 06:46:31 +00:00
|
|
|
switch (eventType) {
|
2013-07-26 08:10:49 +00:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
2022-03-25 12:20:32 +00:00
|
|
|
if (reinterpret_cast<xcb_configure_notify_event_t *>(e)->event == kwinApp()->x11RootWindow()) {
|
2017-06-21 04:56:53 +00:00
|
|
|
markXStackingOrderAsDirty();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
2013-07-26 14:19:05 +00:00
|
|
|
const xcb_window_t eventWindow = findEventWindow(e);
|
2013-08-30 11:34:29 +00:00
|
|
|
if (eventWindow != XCB_WINDOW_NONE) {
|
2019-09-24 08:48:08 +00:00
|
|
|
if (X11Client *c = findClient(Predicate::WindowMatch, eventWindow)) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->windowEvent(e)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
} else if (X11Client *c = findClient(Predicate::WrapperIdMatch, eventWindow)) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->windowEvent(e)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
} else if (X11Client *c = findClient(Predicate::FrameIdMatch, eventWindow)) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->windowEvent(e)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
} else if (X11Client *c = findClient(Predicate::InputIdMatch, eventWindow)) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->windowEvent(e)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
} else if (Unmanaged *c = findUnmanaged(eventWindow)) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c->windowEvent(e)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 08:51:54 +00:00
|
|
|
switch (eventType) {
|
|
|
|
case XCB_CREATE_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_create_notify_event_t *>(e);
|
|
|
|
if (event->parent == kwinApp()->x11RootWindow() && !QWidget::find(event->window) && !event->override_redirect) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// see comments for allowClientActivation()
|
2014-11-27 22:24:05 +00:00
|
|
|
updateXTime();
|
2013-07-26 08:51:54 +00:00
|
|
|
const xcb_timestamp_t t = xTime();
|
2022-02-08 22:22:38 +00:00
|
|
|
xcb_change_property(kwinApp()->x11Connection(), XCB_PROP_MODE_REPLACE, event->window, atoms->kde_net_wm_user_creation_time, XCB_ATOM_CARDINAL, 32, 1, &t);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
2013-07-26 08:51:54 +00:00
|
|
|
}
|
2013-07-26 08:56:43 +00:00
|
|
|
case XCB_UNMAP_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_unmap_notify_event_t *>(e);
|
|
|
|
return (event->event != event->window); // hide wm typical event from Qt
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-07-26 08:56:43 +00:00
|
|
|
case XCB_REPARENT_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
// do not confuse Qt with these events. After all, _we_ are the
|
|
|
|
// window manager who does the reparenting.
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-07-26 09:02:44 +00:00
|
|
|
case XCB_MAP_REQUEST: {
|
2011-01-30 14:34:42 +00:00
|
|
|
updateXTime();
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_map_request_event_t *>(e);
|
2019-09-24 08:48:08 +00:00
|
|
|
if (X11Client *c = findClient(Predicate::WindowMatch, event->window)) {
|
2012-02-03 22:31:13 +00:00
|
|
|
// e->xmaprequest.window is different from e->xany.window
|
|
|
|
// TODO this shouldn't be necessary now
|
2011-01-30 14:34:42 +00:00
|
|
|
c->windowEvent(e);
|
2012-11-20 16:26:50 +00:00
|
|
|
FocusChain::self()->update(c, FocusChain::Update);
|
2022-03-23 10:13:38 +00:00
|
|
|
} else if (true /*|| e->xmaprequest.parent != root */) {
|
2012-02-03 22:31:13 +00:00
|
|
|
// NOTICE don't check for the parent being the root window, this breaks when some app unmaps
|
|
|
|
// a window, changes something and immediately maps it back, without giving KWin
|
|
|
|
// a chance to reparent it back to root
|
|
|
|
// since KWin can get MapRequest only for root window children and
|
|
|
|
// children of WindowWrapper (=clients), the check is AFAIK useless anyway
|
2019-09-24 08:48:08 +00:00
|
|
|
// NOTICE: The save-set support in X11Client::mapRequestEvent() actually requires that
|
2012-02-03 22:31:13 +00:00
|
|
|
// this code doesn't check the parent to be root.
|
2013-07-26 09:02:44 +00:00
|
|
|
if (!createClient(event->window, false)) {
|
2022-02-08 22:22:38 +00:00
|
|
|
xcb_map_window(kwinApp()->x11Connection(), event->window);
|
2022-03-23 10:13:38 +00:00
|
|
|
const uint32_t values[] = {XCB_STACK_MODE_ABOVE};
|
2022-02-08 22:22:38 +00:00
|
|
|
xcb_configure_window(kwinApp()->x11Connection(), event->window, XCB_CONFIG_WINDOW_STACK_MODE, values);
|
2013-07-26 09:02:44 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-02-03 22:31:13 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-07-26 09:16:50 +00:00
|
|
|
case XCB_MAP_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_map_notify_event_t *>(e);
|
2013-07-26 09:16:50 +00:00
|
|
|
if (event->override_redirect) {
|
2022-03-23 10:13:38 +00:00
|
|
|
Unmanaged *c = findUnmanaged(event->window);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c == nullptr) {
|
2013-07-26 09:16:50 +00:00
|
|
|
c = createUnmanaged(event->window);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-10-24 10:00:16 +00:00
|
|
|
if (c) {
|
2020-11-27 19:57:24 +00:00
|
|
|
// if hasScheduledRelease is true, it means a unamp and map sequence has occurred.
|
2019-10-24 10:00:16 +00:00
|
|
|
// since release is scheduled after map notify, this old Unmanaged will get released
|
|
|
|
// before KWIN has chance to remanage it again. so release it right now.
|
|
|
|
if (c->hasScheduledRelease()) {
|
|
|
|
c->release();
|
|
|
|
c = createUnmanaged(event->window);
|
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c) {
|
2019-10-24 10:00:16 +00:00
|
|
|
return c->windowEvent(e);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-10-24 10:00:16 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
return (event->event != event->window); // hide wm typical event from Qt
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 09:31:24 +00:00
|
|
|
case XCB_CONFIGURE_REQUEST: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_configure_request_event_t *>(e);
|
2022-02-08 22:28:03 +00:00
|
|
|
if (event->parent == kwinApp()->x11RootWindow()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
uint32_t values[5] = {0, 0, 0, 0, 0};
|
2014-04-25 12:42:20 +00:00
|
|
|
const uint32_t value_mask = event->value_mask
|
2022-03-23 10:13:38 +00:00
|
|
|
& (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH);
|
2014-04-25 12:42:20 +00:00
|
|
|
int i = 0;
|
|
|
|
if (value_mask & XCB_CONFIG_WINDOW_X) {
|
|
|
|
values[i++] = event->x;
|
|
|
|
}
|
|
|
|
if (value_mask & XCB_CONFIG_WINDOW_Y) {
|
|
|
|
values[i++] = event->y;
|
|
|
|
}
|
|
|
|
if (value_mask & XCB_CONFIG_WINDOW_WIDTH) {
|
|
|
|
values[i++] = event->width;
|
|
|
|
}
|
|
|
|
if (value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
|
|
|
|
values[i++] = event->height;
|
|
|
|
}
|
|
|
|
if (value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
|
|
|
|
values[i++] = event->border_width;
|
|
|
|
}
|
2022-02-08 22:22:38 +00:00
|
|
|
xcb_configure_window(kwinApp()->x11Connection(), event->window, value_mask, values);
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 09:37:57 +00:00
|
|
|
case XCB_FOCUS_IN: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_focus_in_event_t *>(e);
|
2022-02-08 22:28:03 +00:00
|
|
|
if (event->event == kwinApp()->x11RootWindow()
|
2022-03-23 10:13:38 +00:00
|
|
|
&& (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT || event->detail == XCB_NOTIFY_DETAIL_INFERIOR)) {
|
2013-09-10 09:37:40 +00:00
|
|
|
Xcb::CurrentInput currentInput;
|
2011-01-30 14:34:42 +00:00
|
|
|
updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp)
|
2015-11-10 22:59:17 +00:00
|
|
|
// it seems we can "loose" focus reversions when the closing client hold a grab
|
|
|
|
// => catch the typical pattern (though we don't want the focus on the root anyway) #348935
|
2022-02-08 22:28:03 +00:00
|
|
|
const bool lostFocusPointerToRoot = currentInput->focus == kwinApp()->x11RootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR;
|
2015-11-10 22:59:17 +00:00
|
|
|
if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) {
|
2022-03-23 10:13:38 +00:00
|
|
|
// kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
|
2015-03-12 10:56:55 +00:00
|
|
|
AbstractClient *c = mostRecentlyActivatedClient();
|
2022-03-25 12:20:32 +00:00
|
|
|
if (c != nullptr) {
|
2011-01-30 14:34:42 +00:00
|
|
|
requestFocus(c, true);
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (activateNextClient(nullptr)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
; // ok, activated
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2011-01-30 14:34:42 +00:00
|
|
|
focusToNull();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-07-26 09:37:57 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
// fall through
|
2013-07-26 09:37:57 +00:00
|
|
|
case XCB_FOCUS_OUT:
|
2011-01-30 14:34:42 +00:00
|
|
|
return true; // always eat these, they would tell Qt that KWin is the active app
|
|
|
|
default:
|
|
|
|
break;
|
2013-07-26 08:51:54 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Used only to filter events that need to be processed by Qt first
|
|
|
|
// (e.g. keyboard input to be composed), otherwise events are
|
|
|
|
// handle by the XEvent filter above
|
2022-03-23 10:13:38 +00:00
|
|
|
bool Workspace::workspaceEvent(QEvent *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if ((e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease || e->type() == QEvent::ShortcutOverride)
|
2022-03-23 10:13:38 +00:00
|
|
|
&& effects && static_cast<EffectsHandlerImpl *>(effects)->hasKeyboardGrab()) {
|
|
|
|
static_cast<EffectsHandlerImpl *>(effects)->grabbedKeyboardEvent(static_cast<QKeyEvent *>(e));
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Client
|
|
|
|
// ****************************************
|
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* General handler for XEvents concerning the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::windowEvent(xcb_generic_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-08-02 11:53:21 +00:00
|
|
|
if (findEventWindow(e) == window()) { // avoid doing stuff on frame or wrapper
|
2014-03-17 09:22:20 +00:00
|
|
|
NET::Properties dirtyProperties;
|
|
|
|
NET::Properties2 dirtyProperties2;
|
2022-03-23 10:13:38 +00:00
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if ((dirtyProperties & NET::WMName) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
fetchName();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if ((dirtyProperties & NET::WMIconName) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
fetchIconicName();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties & NET::WMStrut) != 0
|
2022-03-23 10:13:38 +00:00
|
|
|
|| (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
workspace()->updateClientArea();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if ((dirtyProperties & NET::WMIcon) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
getIcons();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// Note there's a difference between userTime() and info->userTime()
|
|
|
|
// info->userTime() is the value of the property, userTime() also includes
|
|
|
|
// updates of the time done by KWin (ButtonPress on windowrapper etc.).
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties2 & NET::WM2UserTime) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
workspace()->setWasUserInteraction();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateUserTime(info->userTime());
|
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if ((dirtyProperties2 & NET::WM2StartupId) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
startupIdChanged();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2014-03-17 09:22:20 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2021-06-14 09:44:36 +00:00
|
|
|
if (Compositor::compositing()) {
|
2021-02-05 22:18:45 +00:00
|
|
|
setOpacity(info->opacityF());
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
// forward to the frame if there's possibly another compositing manager running
|
2022-02-08 22:28:03 +00:00
|
|
|
NETWinInfo i(kwinApp()->x11Connection(), frameId(), kwinApp()->x11RootWindow(), NET::Properties(), NET::Properties2());
|
2011-01-30 14:34:42 +00:00
|
|
|
i.setOpacity(info->opacity());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2014-04-10 09:12:48 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowRoleChanged();
|
2014-04-10 09:12:48 +00:00
|
|
|
}
|
2014-04-11 06:06:26 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
|
|
|
getResourceClass();
|
|
|
|
}
|
2014-04-14 13:32:45 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2BlockCompositing)) {
|
|
|
|
setBlockingCompositing(info->isBlockingCompositing());
|
|
|
|
}
|
2014-09-12 11:56:34 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2GroupLeader)) {
|
|
|
|
checkGroup();
|
|
|
|
updateAllowedActions(); // Group affects isMinimizable()
|
|
|
|
}
|
|
|
|
if (dirtyProperties2.testFlag(NET::WM2Urgency)) {
|
|
|
|
updateUrgency();
|
|
|
|
}
|
2015-01-22 14:46:12 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2OpaqueRegion) {
|
|
|
|
getWmOpaqueRegion();
|
|
|
|
}
|
2016-10-27 13:59:08 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2DesktopFileName) {
|
|
|
|
setDesktopFileName(QByteArray(info->desktopFileName()));
|
|
|
|
}
|
[x11] Add support for _GTK_FRAME_EXTENTS
Summary:
KDE is known for having a strong view on the client-side decorations vs
server-side decorations issue. The main argument raised against CSD is
that desktop will look less consistent when clients start drawing window
decorations by themselves, which is somewhat true. It all ties to how
well each toolkit is integrated with the desktop environment.
KDE doesn't control the desktop market on Linux. Another big "player"
is GNOME. Both KDE and GNOME have very polarized views on in which
direction desktop should move forward. The KDE community is pushing more
toward server-side decorations while the GNOME community is pushing
more toward client-side decorations. Both communities have developed
great applications and it's not rare to see a GNOME application being
used in KDE Plasma. The only problem is that these different views are
not left behind the curtain and our users pay the price. Resizing GTK
clients in Plasma became practically impossible due to resize borders
having small hit area.
When a client draws its window decoration, it's more likely that it also
draws the drop-shadow around the decoration. The compositor must know
the extents of the shadow so things like snapping and so on work as
expected. And here lies the problem... While the xdg-shell protocol has
a way to specify such things, the NetWM spec doesn't have anything like
that. There's _GTK_FRAME_EXTENTS in the wild, however the problem with
it is that it's a proprietary atom, which is specific only to GTK apps.
Due to that, _GTK_FRAME_EXTENTS wasn't implemented because implementing
anything like that would require major changes in how we think about
geometry.
Recent xdg-shell window geometry patches adjusted geometry abstractions
in kwin to such a degree that it's very easy to add support for client
side decorated clients on X11. We just have to make sure that the
X11Client class provides correct buffer geometry and frame geometry when
the gtk frame extents are set.
Even though the X11 code is feature frozen, I still think it's worth
to have _GTK_FRAME_EXTENTS support in kwin because it will fix the resize
issues. Also, because KWin/Wayland is unfortunately far from becoming
default, it will help us with testing some implementation bits of the
window geometry from xdg-shell.
BUG: 390550
FIXED-IN: 5.18.0
Test Plan:
Things like quick tiling, maximizing, tiling scripts and so on work as
expected with GTK clients.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: cblack, trmdi, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D24660
2019-10-08 08:46:59 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2GTKFrameExtents) {
|
|
|
|
setClientFrameExtents(info->gtkFrameExtents());
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 11:17:23 +00:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
2022-03-23 10:13:38 +00:00
|
|
|
switch (eventType) {
|
2013-07-26 11:34:54 +00:00
|
|
|
case XCB_UNMAP_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
unmapNotifyEvent(reinterpret_cast<xcb_unmap_notify_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 11:40:43 +00:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
destroyNotifyEvent(reinterpret_cast<xcb_destroy_notify_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 11:46:06 +00:00
|
|
|
case XCB_MAP_REQUEST:
|
2011-01-30 14:34:42 +00:00
|
|
|
// this one may pass the event to workspace
|
2022-03-23 10:13:38 +00:00
|
|
|
return mapRequestEvent(reinterpret_cast<xcb_map_request_event_t *>(e));
|
2013-07-26 11:56:16 +00:00
|
|
|
case XCB_CONFIGURE_REQUEST:
|
2022-03-23 10:13:38 +00:00
|
|
|
configureRequestEvent(reinterpret_cast<xcb_configure_request_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
propertyNotifyEvent(reinterpret_cast<xcb_property_notify_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
case XCB_KEY_PRESS:
|
2022-03-23 10:13:38 +00:00
|
|
|
updateUserTime(reinterpret_cast<xcb_key_press_event_t *>(e)->time);
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
case XCB_BUTTON_PRESS: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_button_press_event_t *>(e);
|
2014-06-01 15:57:51 +00:00
|
|
|
updateUserTime(event->time);
|
2013-07-26 12:03:14 +00:00
|
|
|
buttonPressEvent(event->event, event->detail, event->state,
|
2014-06-01 15:57:51 +00:00
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y, event->time);
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
}
|
|
|
|
case XCB_KEY_RELEASE:
|
2011-01-30 14:34:42 +00:00
|
|
|
// don't update user time on releases
|
|
|
|
// e.g. if the user presses Alt+F2, the Alt release
|
|
|
|
// would appear as user input to the currently active window
|
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
case XCB_BUTTON_RELEASE: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_button_release_event_t *>(e);
|
2011-01-30 14:34:42 +00:00
|
|
|
// don't update user time on releases
|
|
|
|
// e.g. if the user presses Alt+F2, the Alt release
|
|
|
|
// would appear as user input to the currently active window
|
2013-07-26 12:03:14 +00:00
|
|
|
buttonReleaseEvent(event->event, event->detail, event->state,
|
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y);
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
}
|
|
|
|
case XCB_MOTION_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_motion_notify_event_t *>(e);
|
2013-07-26 12:03:14 +00:00
|
|
|
motionNotifyEvent(event->event, event->state,
|
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y);
|
|
|
|
workspace()->updateFocusMousePosition(QPoint(event->root_x, event->root_y));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
}
|
2013-07-26 12:22:43 +00:00
|
|
|
case XCB_ENTER_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
auto *event = reinterpret_cast<xcb_enter_notify_event_t *>(e);
|
2013-07-26 12:22:43 +00:00
|
|
|
enterNotifyEvent(event);
|
2011-01-30 14:34:42 +00:00
|
|
|
// MotionNotify is guaranteed to be generated only if the mouse
|
|
|
|
// move start and ends in the window; for cases when it only
|
|
|
|
// starts or only ends there, Enter/LeaveNotify are generated.
|
|
|
|
// Fake a MotionEvent in such cases to make handle of mouse
|
|
|
|
// events simpler (Qt does that too).
|
2013-07-26 12:22:43 +00:00
|
|
|
motionNotifyEvent(event->event, event->state,
|
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y);
|
|
|
|
workspace()->updateFocusMousePosition(QPoint(event->root_x, event->root_y));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:22:43 +00:00
|
|
|
}
|
2013-07-26 12:29:47 +00:00
|
|
|
case XCB_LEAVE_NOTIFY: {
|
2022-03-23 10:13:38 +00:00
|
|
|
auto *event = reinterpret_cast<xcb_leave_notify_event_t *>(e);
|
2013-07-26 12:29:47 +00:00
|
|
|
motionNotifyEvent(event->event, event->state,
|
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y);
|
|
|
|
leaveNotifyEvent(event);
|
2011-01-30 14:34:42 +00:00
|
|
|
// not here, it'd break following enter notify handling
|
|
|
|
// workspace()->updateFocusMousePosition( QPoint( e->xcrossing.x_root, e->xcrossing.y_root ));
|
|
|
|
break;
|
2013-07-26 12:29:47 +00:00
|
|
|
}
|
2013-07-26 12:35:28 +00:00
|
|
|
case XCB_FOCUS_IN:
|
2022-03-23 10:13:38 +00:00
|
|
|
focusInEvent(reinterpret_cast<xcb_focus_in_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 12:51:56 +00:00
|
|
|
case XCB_FOCUS_OUT:
|
2022-03-23 10:13:38 +00:00
|
|
|
focusOutEvent(reinterpret_cast<xcb_focus_out_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 13:02:59 +00:00
|
|
|
case XCB_REPARENT_NOTIFY:
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 13:02:59 +00:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
2022-03-23 10:13:38 +00:00
|
|
|
clientMessageEvent(reinterpret_cast<xcb_client_message_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2014-07-22 11:11:19 +00:00
|
|
|
case XCB_EXPOSE: {
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_expose_event_t *event = reinterpret_cast<xcb_expose_event_t *>(e);
|
2014-07-22 11:11:19 +00:00
|
|
|
if (event->window == frameId() && !Compositor::self()->isActive()) {
|
|
|
|
// TODO: only repaint required areas
|
|
|
|
triggerDecorationRepaint();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
default:
|
2022-03-23 10:13:38 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent() && reinterpret_cast<xcb_shape_notify_event_t *>(e)->affected_window == window()) {
|
|
|
|
detectShape(window()); // workaround for #19644
|
2013-07-26 13:05:55 +00:00
|
|
|
updateShape();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast<xcb_damage_notify_event_t *>(e)->drawable == frameId()) {
|
2013-07-26 13:05:55 +00:00
|
|
|
damageNotifyEvent();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true; // eat all events
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles map requests of the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::mapRequestEvent(xcb_map_request_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// Special support for the save-set feature, which is a bit broken.
|
|
|
|
// If there's a window from one client embedded in another one,
|
2009-02-07 01:12:28 +00:00
|
|
|
// e.g. using XEMBED, and the embedder suddenly loses its X connection,
|
2007-04-29 17:35:43 +00:00
|
|
|
// save-set will reparent the embedded window to its closest ancestor
|
|
|
|
// that will remains. Unfortunately, with reparenting window managers,
|
|
|
|
// this is not the root window, but the frame (or in KWin's case,
|
|
|
|
// it's the wrapper for the client window). In this case,
|
|
|
|
// the wrapper will get ReparentNotify for a window it won't know,
|
|
|
|
// which will be ignored, and then it gets MapRequest, as save-set
|
|
|
|
// always maps. Returning true here means that Workspace::workspaceEvent()
|
|
|
|
// will handle this MapRequest and manage this window (i.e. act as if
|
|
|
|
// it was reparented to root window).
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->parent == wrapperId()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return true; // no messing with frame etc.
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-12 11:02:58 +00:00
|
|
|
// also copied in clientMessage()
|
2022-03-25 12:20:32 +00:00
|
|
|
if (isMinimized()) {
|
2008-08-12 11:02:58 +00:00
|
|
|
unminimize();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (isShade()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
setShade(ShadeNone);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isOnCurrentDesktop()) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (workspace()->allowClientActivation(this)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->activateClient(this);
|
2022-03-25 12:20:32 +00:00
|
|
|
} else {
|
2008-08-12 11:02:58 +00:00
|
|
|
demandAttention();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles unmap notify events of the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (e->event != wrapperId()) {
|
|
|
|
// most probably event from root window when initially reparenting
|
2007-04-29 17:35:43 +00:00
|
|
|
bool ignore = true;
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->event == kwinApp()->x11RootWindow() && (e->response_type & 0x80)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
ignore = false; // XWithdrawWindow()
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (ignore) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-03-05 17:04:30 +00:00
|
|
|
|
|
|
|
// check whether this is result of an XReparentWindow - client then won't be parented by wrapper
|
|
|
|
// in this case do not release the client (causes reparent to root, removal from saveSet and what not)
|
|
|
|
// but just destroy the client
|
2013-05-02 16:43:49 +00:00
|
|
|
Xcb::Tree tree(m_client);
|
2013-03-05 17:04:30 +00:00
|
|
|
xcb_window_t daddy = tree.parent();
|
2013-05-02 16:26:05 +00:00
|
|
|
if (daddy == m_wrapper) {
|
2013-03-05 17:04:30 +00:00
|
|
|
releaseWindow(); // unmapped from a regular client state
|
|
|
|
} else {
|
|
|
|
destroyClient(); // the client was moved to some other parent
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
destroyClient();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles client messages for the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::clientMessageEvent(xcb_client_message_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-01-09 10:16:57 +00:00
|
|
|
Toplevel::clientMessageEvent(e);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// WM_STATE
|
2014-05-20 13:58:15 +00:00
|
|
|
if (e->type == atoms->wm_change_state) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) {
|
2007-04-29 17:35:43 +00:00
|
|
|
minimize();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles configure requests of the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::configureRequestEvent(xcb_configure_request_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (isInteractiveResize() || isInteractiveMove()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we have better things to do right now
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-01-10 12:16:01 +00:00
|
|
|
if (m_fullscreenMode == FullScreenNormal) { // refuse resizing of fullscreen windows
|
2011-01-30 14:34:42 +00:00
|
|
|
// but allow resizing fullscreen hacks in order to let them cancel fullscreen mode
|
2007-04-29 17:35:43 +00:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
if (isSplash()) { // no manipulations with splashscreens either
|
2007-04-29 17:35:43 +00:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 11:56:16 +00:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// first, get rid of a window border
|
2013-09-10 07:51:31 +00:00
|
|
|
m_client.setBorderWidth(0);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->value_mask & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_WIDTH)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
configureRequest(e->value_mask, e->x, e->y, e->width, e->height, 0, false);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
|
2013-07-26 11:56:16 +00:00
|
|
|
restackWindow(e->sibling, e->stack_mode, NET::FromApplication, userTime(), false);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-07-19 16:38:46 +00:00
|
|
|
// Sending a synthetic configure notify always is fine, even in cases where
|
2007-04-29 17:35:43 +00:00
|
|
|
// the ICCCM doesn't require this - it can be though of as 'the WM decided to move
|
|
|
|
// the window later'. The client should not cause that many configure request,
|
|
|
|
// so this should not have any significant impact. With user moving/resizing
|
Rework async geometry updates
Window management features were written with synchronous geometry
updates in mind. Currently, this poses a big problem on Wayland because
geometry updates are done in asynchronous fashion there.
At the moment, geometry is updated in a so called pseudo-asynchronous
fashion, meaning that the frame geometry will be reset to the old value
once geometry updates are unblocked. The main drawback of this approach
is that it is too error prone, the data flow is hard to comprehend, etc.
It is worth noting that there is already a machinery to perform async
geometry which is used during interactive move/resize operations.
This change extends the move/resize geometry usage beyond interactive
move/resize to make asynchronous geometry updates less error prone and
easier to comprehend.
With the proposed solution, all geometry updates must be done on the
move/resize geometry first. After that, the new geometry is passed on to
the Client-specific implementation of moveResizeInternal().
To be more specific, the frameGeometry() returns the current frame
geometry, it is primarily useful only to the scene. If you want to move
or resize a window, you need to use moveResizeGeometry() because it
corresponds to the last requested frame geometry.
It is worth noting that the moveResizeGeometry() returns the desired
bounding geometry. The client may commit the xdg_toplevel surface with a
slightly smaller window geometry, for example to enforce a specific
aspect ratio. The client is not allowed to resize beyond the size as
indicated in moveResizeGeometry().
The data flow is very simple: moveResize() updates the move/resize
geometry and calls the client-specific implementation of the
moveResizeInternal() method. Based on whether a configure event is
needed, moveResizeInternal() will update the frameGeometry() either
immediately or after the client commits a new buffer.
Unfortunately, both the compositor and xdg-shell clients try to update
the window geometry. It means that it's possible to have conflicts
between the two. With this change, the compositor's move resize geometry
will be synced only if there are no pending configure events, meaning
that the user doesn't try to resize the window.
2021-04-30 18:26:09 +00:00
|
|
|
// the it should be optimized though (see also X11Client::setGeometry()/resize()/move()).
|
2007-04-29 17:35:43 +00:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
|
|
|
|
// SELI TODO accept configure requests for isDesktop windows (because kdesktop
|
|
|
|
// may get XRANDR resize event before kwin), but check it's still at the bottom?
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Handles property changes of the client window
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
Toplevel::propertyNotifyEvent(e);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
switch (e->atom) {
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_ATOM_WM_NORMAL_HINTS:
|
2011-01-30 14:34:42 +00:00
|
|
|
getWmNormalHints();
|
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_ATOM_WM_NAME:
|
2011-01-30 14:34:42 +00:00
|
|
|
fetchName();
|
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_ATOM_WM_ICON_NAME:
|
2011-01-30 14:34:42 +00:00
|
|
|
fetchIconicName();
|
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_ATOM_WM_TRANSIENT_FOR:
|
2011-01-30 14:34:42 +00:00
|
|
|
readTransient();
|
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_ATOM_WM_HINTS:
|
2011-01-30 14:34:42 +00:00
|
|
|
getIcons(); // because KWin::icon() uses WMHints as fallback
|
|
|
|
break;
|
|
|
|
default:
|
2015-02-02 13:56:21 +00:00
|
|
|
if (e->atom == atoms->motif_wm_hints) {
|
2011-01-30 14:34:42 +00:00
|
|
|
getMotifHints();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->net_wm_sync_request_counter) {
|
2011-01-30 14:34:42 +00:00
|
|
|
getSyncCounter();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->activities) {
|
2011-01-30 14:34:42 +00:00
|
|
|
checkActivities();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_first_in_window_list) {
|
2011-12-01 12:15:11 +00:00
|
|
|
updateFirstInTabBox();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_color_sheme) {
|
2013-10-14 05:17:07 +00:00
|
|
|
updateColorScheme();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_screen_edge_show) {
|
2014-02-20 11:39:23 +00:00
|
|
|
updateShowOnScreenEdge();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_net_wm_appmenu_service_name) {
|
2017-01-11 09:21:03 +00:00
|
|
|
checkApplicationMenuServiceName();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_net_wm_appmenu_object_path) {
|
2017-01-11 09:21:03 +00:00
|
|
|
checkApplicationMenuObjectPath();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::enterNotifyEvent(xcb_enter_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return;
|
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->event != frameId()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // care only about entering the whole frame
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2012-03-17 14:34:32 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || (options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse()))
|
2013-07-26 12:22:43 +00:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && MOUSE_DRIVEN_FOCUS)) {
|
2012-03-17 14:34:32 +00:00
|
|
|
#undef MOUSE_DRIVEN_FOCUS
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2021-11-29 16:59:06 +00:00
|
|
|
pointerEnterEvent(QPoint(e->root_x, e->root_y));
|
2011-01-30 14:34:42 +00:00
|
|
|
return;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return;
|
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->event != frameId()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // care only about leaving the whole frame
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2013-07-26 12:29:47 +00:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
|
2021-04-30 18:06:58 +00:00
|
|
|
if (!isInteractiveMoveResizePointerButtonDown()) {
|
2021-12-24 12:05:41 +00:00
|
|
|
setInteractiveMoveResizeGravity(Gravity::None);
|
2007-05-22 15:46:42 +00:00
|
|
|
updateCursor();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-07-26 12:29:47 +00:00
|
|
|
bool lostMouse = !rect().contains(QPoint(e->event_x, e->event_y));
|
2007-04-29 17:35:43 +00:00
|
|
|
// 'lostMouse' wouldn't work with e.g. B2 or Keramik, which have non-rectangular decorations
|
|
|
|
// (i.e. the LeaveNotify event comes before leaving the rect and no LeaveNotify event
|
|
|
|
// comes after leaving the rect) - so lets check if the pointer is really outside the window
|
|
|
|
|
|
|
|
// TODO this still sucks if a window appears above this one - it should lose the mouse
|
|
|
|
// if this window is another client, but not if it's a popup ... maybe after KDE3.1 :(
|
|
|
|
// (repeat after me 'AARGHL!')
|
2013-07-26 12:29:47 +00:00
|
|
|
if (!lostMouse && e->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
|
2014-04-25 09:18:49 +00:00
|
|
|
Xcb::Pointer pointer(frameId());
|
|
|
|
if (!pointer || !pointer->same_screen || pointer->child == XCB_WINDOW_NONE) {
|
|
|
|
// really lost the mouse
|
|
|
|
lostMouse = true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (lostMouse) {
|
2021-11-29 16:59:06 +00:00
|
|
|
pointerLeaveEvent();
|
2015-12-03 12:24:44 +00:00
|
|
|
if (isDecorated()) {
|
2015-08-31 08:28:03 +00:00
|
|
|
// sending a move instead of a leave. With leave we need to send proper coords, with move it's handled internally
|
|
|
|
QHoverEvent leaveEvent(QEvent::HoverMove, QPointF(-1, -1), QPointF(-1, -1), Qt::NoModifier);
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::sendEvent(decoration(), &leaveEvent);
|
2015-08-31 08:28:03 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2012-02-20 09:25:13 +00:00
|
|
|
if (options->focusPolicy() == Options::FocusStrictlyUnderMouse && isActive() && lostMouse) {
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
workspace()->requestDelayFocus(nullptr);
|
2011-11-13 17:23:49 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-07-16 11:01:08 +00:00
|
|
|
static uint16_t x11CommandAllModifier()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-07-16 11:01:08 +00:00
|
|
|
switch (options->commandAllModifier()) {
|
2020-06-23 16:26:36 +00:00
|
|
|
case Qt::MetaModifier:
|
2020-07-16 11:01:08 +00:00
|
|
|
return KKeyServer::modXMeta();
|
2020-06-23 16:26:36 +00:00
|
|
|
case Qt::AltModifier:
|
2020-07-16 11:01:08 +00:00
|
|
|
return KKeyServer::modXAlt();
|
2020-06-23 16:26:36 +00:00
|
|
|
default:
|
2020-07-16 11:01:08 +00:00
|
|
|
return 0;
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
2020-07-16 11:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define XCapL KKeyServer::modXLock()
|
|
|
|
#define XNumL KKeyServer::modXNumLock()
|
|
|
|
#define XScrL KKeyServer::modXScrollLock()
|
|
|
|
void X11Client::establishCommandWindowGrab(uint8_t button)
|
|
|
|
{
|
|
|
|
// Unfortunately there are a lot of possible modifier combinations that we need to take into
|
|
|
|
// account. We tackle that problem in a kind of smart way. First, we grab the button with all
|
|
|
|
// possible modifiers, then we ungrab the ones that are relevant only to commandAllx().
|
|
|
|
|
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_MOD_MASK_ANY, button);
|
|
|
|
|
|
|
|
uint16_t x11Modifier = x11CommandAllModifier();
|
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
unsigned int mods[8] = {
|
2020-07-16 11:01:08 +00:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
2022-03-23 10:13:38 +00:00
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL};
|
2022-03-25 12:20:32 +00:00
|
|
|
for (int i = 0; i < 8; ++i) {
|
2022-03-23 10:13:38 +00:00
|
|
|
m_wrapper.ungrabButton(x11Modifier | mods[i], button);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2020-07-16 11:01:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void X11Client::establishCommandAllGrab(uint8_t button)
|
|
|
|
{
|
|
|
|
uint16_t x11Modifier = x11CommandAllModifier();
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
unsigned int mods[8] = {
|
2007-04-29 17:35:43 +00:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
2022-03-23 10:13:38 +00:00
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL};
|
2022-03-25 12:20:32 +00:00
|
|
|
for (int i = 0; i < 8; ++i) {
|
2022-03-23 10:13:38 +00:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, x11Modifier | mods[i], button);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
#undef XCapL
|
|
|
|
#undef XNumL
|
|
|
|
#undef XScrL
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::updateMouseGrab()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-08 22:22:38 +00:00
|
|
|
xcb_ungrab_button(kwinApp()->x11Connection(), XCB_BUTTON_INDEX_ANY, m_wrapper, XCB_MOD_MASK_ANY);
|
2020-06-23 16:26:36 +00:00
|
|
|
|
2022-02-28 18:58:35 +00:00
|
|
|
#if KWIN_BUILD_TABBOX
|
2020-06-23 16:26:36 +00:00
|
|
|
if (TabBox::TabBox::self()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
|
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
2007-08-23 15:08:39 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-02-11 15:24:32 +00:00
|
|
|
#endif
|
2020-06-23 16:26:36 +00:00
|
|
|
|
|
|
|
// When a passive grab is activated or deactivated, the X server will generate crossing
|
|
|
|
// events as if the pointer were suddenly to warp from its current position to some position
|
|
|
|
// in the grab window. Some /broken/ X11 clients do get confused by such EnterNotify and
|
|
|
|
// LeaveNotify events so we release the passive grab for the active window.
|
|
|
|
//
|
|
|
|
// The passive grab below is established so the window can be raised or activated when it
|
|
|
|
// is clicked.
|
2022-03-23 10:13:38 +00:00
|
|
|
if ((options->focusPolicyIsReasonable() && !isActive()) || (options->isClickRaise() && !isMostRecentlyRaised())) {
|
2020-06-23 16:26:36 +00:00
|
|
|
if (options->commandWindow1() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandWindowGrab(XCB_BUTTON_INDEX_1);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandWindow2() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandWindowGrab(XCB_BUTTON_INDEX_2);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandWindow3() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandWindowGrab(XCB_BUTTON_INDEX_3);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandWindowWheel() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandWindowGrab(XCB_BUTTON_INDEX_4);
|
|
|
|
establishCommandWindowGrab(XCB_BUTTON_INDEX_5);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We want to grab <command modifier> + buttons no matter what state the window is in. The
|
|
|
|
// client will receive funky EnterNotify and LeaveNotify events, but there is nothing that
|
|
|
|
// we can do about it, unfortunately.
|
|
|
|
|
|
|
|
if (!workspace()->globalShortcutsDisabled()) {
|
|
|
|
if (options->commandAll1() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandAllGrab(XCB_BUTTON_INDEX_1);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandAll2() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandAllGrab(XCB_BUTTON_INDEX_2);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandAll3() != Options::MouseNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandAllGrab(XCB_BUTTON_INDEX_3);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
|
|
|
if (options->commandAllWheel() != Options::MouseWheelNothing) {
|
2020-07-16 11:01:08 +00:00
|
|
|
establishCommandAllGrab(XCB_BUTTON_INDEX_4);
|
|
|
|
establishCommandAllGrab(XCB_BUTTON_INDEX_5);
|
2020-06-23 16:26:36 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-23 10:13:38 +00:00
|
|
|
static bool modKeyDown(int state)
|
|
|
|
{
|
|
|
|
const uint keyModX = (options->keyCmdAllModKey() == Qt::Key_Meta) ? KKeyServer::modXMeta() : KKeyServer::modXAlt();
|
|
|
|
return keyModX && (state & KKeyServer::accelModMaskX()) == keyModX;
|
2012-05-18 20:38:04 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// return value matters only when filtering events before decoration gets them
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::buttonPressEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root, xcb_timestamp_t time)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return true;
|
|
|
|
}
|
2021-04-30 18:06:58 +00:00
|
|
|
if (isInteractiveMoveResizePointerButtonDown()) {
|
2022-03-25 12:20:32 +00:00
|
|
|
if (w == wrapperId()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-07-22 11:11:19 +00:00
|
|
|
if (w == wrapperId() || w == frameId() || w == inputId()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// FRAME neco s tohohle by se melo zpracovat, nez to dostane dekorace
|
2014-06-01 15:57:51 +00:00
|
|
|
updateUserTime(time);
|
2012-05-18 20:38:04 +00:00
|
|
|
const bool bModKeyHeld = modKeyDown(state);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
if (isSplash()
|
2022-03-23 10:13:38 +00:00
|
|
|
&& button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// hide splashwindow if the user clicks on it
|
2021-11-03 09:40:31 +00:00
|
|
|
hideClient();
|
2022-03-25 12:20:32 +00:00
|
|
|
if (w == wrapperId()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
bool was_action = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (bModKeyHeld) {
|
2007-04-29 17:35:43 +00:00
|
|
|
was_action = true;
|
2022-03-23 10:13:38 +00:00
|
|
|
switch (button) {
|
2013-09-13 07:12:26 +00:00
|
|
|
case XCB_BUTTON_INDEX_1:
|
2011-01-30 14:34:42 +00:00
|
|
|
com = options->commandAll1();
|
|
|
|
break;
|
2013-09-13 07:12:26 +00:00
|
|
|
case XCB_BUTTON_INDEX_2:
|
2011-01-30 14:34:42 +00:00
|
|
|
com = options->commandAll2();
|
|
|
|
break;
|
2013-09-13 07:12:26 +00:00
|
|
|
case XCB_BUTTON_INDEX_3:
|
2011-01-30 14:34:42 +00:00
|
|
|
com = options->commandAll3();
|
|
|
|
break;
|
2013-09-13 07:12:26 +00:00
|
|
|
case XCB_BUTTON_INDEX_4:
|
|
|
|
case XCB_BUTTON_INDEX_5:
|
|
|
|
com = options->operationWindowMouseWheel(button == XCB_BUTTON_INDEX_4 ? 120 : -120);
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2015-07-09 14:11:51 +00:00
|
|
|
if (w == wrapperId()) {
|
|
|
|
if (button < 4) {
|
|
|
|
com = getMouseCommand(x11ToQtMouseButton(button), &was_action);
|
|
|
|
} else if (button < 6) {
|
|
|
|
com = getWheelCommand(Qt::Vertical, &was_action);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (was_action) {
|
2014-03-20 12:39:00 +00:00
|
|
|
bool replay = performMouseCommand(com, QPoint(x_root, y_root));
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if (isSpecialWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
replay = true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2022-03-25 12:20:32 +00:00
|
|
|
if (w == wrapperId()) { // these can come only from a grab
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_allow_events(kwinApp()->x11Connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w == wrapperId()) { // these can come only from a grab
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-10-03 17:00:56 +00:00
|
|
|
if (w == inputId()) {
|
2019-09-27 10:01:10 +00:00
|
|
|
x = x_root - frameGeometry().x();
|
|
|
|
y = y_root - frameGeometry().y();
|
2012-10-03 17:00:56 +00:00
|
|
|
// New API processes core events FIRST and only passes unused ones to the decoration
|
2015-12-03 15:40:27 +00:00
|
|
|
QMouseEvent ev(QMouseEvent::MouseButtonPress, QPoint(x, y), QPoint(x_root, y_root),
|
|
|
|
x11ToQtMouseButton(button), x11ToQtMouseButtons(state), Qt::KeyboardModifiers());
|
|
|
|
return processDecorationButtonPress(&ev, true);
|
2012-10-03 17:00:56 +00:00
|
|
|
}
|
2015-12-03 12:24:44 +00:00
|
|
|
if (w == frameId() && isDecorated()) {
|
2014-07-25 06:05:47 +00:00
|
|
|
if (button >= 4 && button <= 7) {
|
|
|
|
const Qt::KeyboardModifiers modifiers = x11ToQtKeyboardModifiers(state);
|
|
|
|
// Logic borrowed from qapplication_x11.cpp
|
|
|
|
const int delta = 120 * ((button == 4 || button == 6) ? 1 : -1);
|
|
|
|
const bool hor = (((button == 4 || button == 5) && (modifiers & Qt::AltModifier))
|
2022-03-23 10:13:38 +00:00
|
|
|
|| (button == 6 || button == 7));
|
2014-07-25 06:05:47 +00:00
|
|
|
|
|
|
|
const QPoint angle = hor ? QPoint(delta, 0) : QPoint(0, delta);
|
|
|
|
QWheelEvent event(QPointF(x, y),
|
|
|
|
QPointF(x_root, y_root),
|
|
|
|
QPoint(),
|
|
|
|
angle,
|
|
|
|
x11ToQtMouseButtons(state),
|
2022-03-13 10:36:23 +00:00
|
|
|
modifiers,
|
|
|
|
Qt::NoScrollPhase,
|
|
|
|
false);
|
2014-11-28 13:08:13 +00:00
|
|
|
event.setAccepted(false);
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::sendEvent(decoration(), &event);
|
2014-11-28 13:08:13 +00:00
|
|
|
if (!event.isAccepted() && !hor) {
|
2016-05-12 08:28:40 +00:00
|
|
|
if (titlebarPositionUnderMouse()) {
|
2014-11-28 13:08:13 +00:00
|
|
|
performMouseCommand(options->operationTitlebarMouseWheel(delta), QPoint(x_root, y_root));
|
|
|
|
}
|
|
|
|
}
|
2014-07-25 06:05:47 +00:00
|
|
|
} else {
|
|
|
|
QMouseEvent event(QEvent::MouseButtonPress, QPointF(x, y), QPointF(x_root, y_root),
|
2022-03-23 10:13:38 +00:00
|
|
|
x11ToQtMouseButton(button), x11ToQtMouseButtons(state), x11ToQtKeyboardModifiers(state));
|
2022-01-30 17:28:39 +00:00
|
|
|
event.setTimestamp(time);
|
2014-07-25 06:05:47 +00:00
|
|
|
event.setAccepted(false);
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::sendEvent(decoration(), &event);
|
2014-07-25 06:05:47 +00:00
|
|
|
if (!event.isAccepted()) {
|
2015-12-03 15:40:27 +00:00
|
|
|
processDecorationButtonPress(&event);
|
2014-07-25 06:05:47 +00:00
|
|
|
}
|
2014-07-22 11:11:19 +00:00
|
|
|
}
|
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// return value matters only when filtering events before decoration gets them
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::buttonReleaseEvent(xcb_window_t w, int button, int state, int x, int y, int x_root, int y_root)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-12-03 12:24:44 +00:00
|
|
|
if (w == frameId() && isDecorated()) {
|
2014-07-25 06:05:47 +00:00
|
|
|
// wheel handled on buttonPress
|
|
|
|
if (button < 4 || button > 7) {
|
|
|
|
QMouseEvent event(QEvent::MouseButtonRelease,
|
|
|
|
QPointF(x, y),
|
|
|
|
QPointF(x_root, y_root),
|
|
|
|
x11ToQtMouseButton(button),
|
2014-10-23 14:49:21 +00:00
|
|
|
x11ToQtMouseButtons(state) & ~x11ToQtMouseButton(button),
|
2014-07-25 06:05:47 +00:00
|
|
|
x11ToQtKeyboardModifiers(state));
|
2014-11-28 13:50:21 +00:00
|
|
|
event.setAccepted(false);
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::sendEvent(decoration(), &event);
|
2016-05-12 08:28:40 +00:00
|
|
|
if (event.isAccepted() || !titlebarPositionUnderMouse()) {
|
2016-01-05 10:43:12 +00:00
|
|
|
invalidateDecorationDoubleClickTimer(); // click was for the deco and shall not init a doubleclick
|
2014-11-28 13:50:21 +00:00
|
|
|
}
|
2014-07-25 06:05:47 +00:00
|
|
|
}
|
2014-07-22 11:11:19 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w == wrapperId()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
xcb_allow_events(kwinApp()->x11Connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); // xTime());
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2015-09-22 12:44:25 +00:00
|
|
|
if (w == frameId() && workspace()->userActionsMenu() && workspace()->userActionsMenu()->isShown()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
const_cast<UserActionsMenu *>(workspace()->userActionsMenu())->grabInput();
|
2015-09-22 12:44:25 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
2013-10-20 20:30:44 +00:00
|
|
|
|
|
|
|
// Check whether other buttons are still left pressed
|
|
|
|
int buttonMask = XCB_BUTTON_MASK_1 | XCB_BUTTON_MASK_2 | XCB_BUTTON_MASK_3;
|
2022-03-25 12:20:32 +00:00
|
|
|
if (button == XCB_BUTTON_INDEX_1) {
|
2013-10-20 20:30:44 +00:00
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_1;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (button == XCB_BUTTON_INDEX_2) {
|
2013-10-20 20:30:44 +00:00
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_2;
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (button == XCB_BUTTON_INDEX_3) {
|
2013-10-20 20:30:44 +00:00
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_3;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2013-10-20 20:30:44 +00:00
|
|
|
|
|
|
|
if ((state & buttonMask) == 0) {
|
2021-04-30 18:06:58 +00:00
|
|
|
endInteractiveMoveResize();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// return value matters only when filtering events before decoration gets them
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-11-27 22:55:57 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
return true;
|
|
|
|
}
|
2015-12-03 12:24:44 +00:00
|
|
|
if (w == frameId() && isDecorated() && !isMinimized()) {
|
2014-07-22 11:11:19 +00:00
|
|
|
// TODO Mouse move event dependent on state
|
|
|
|
QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y));
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::instance()->sendEvent(decoration(), &event);
|
2014-07-22 11:11:19 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return true; // care only about the whole frame
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2021-04-30 18:06:58 +00:00
|
|
|
if (!isInteractiveMoveResizePointerButtonDown()) {
|
2011-11-09 19:39:13 +00:00
|
|
|
if (w == inputId()) {
|
2022-03-23 10:13:38 +00:00
|
|
|
int x = x_root - frameGeometry().x(); // + padding_left;
|
|
|
|
int y = y_root - frameGeometry().y(); // + padding_top;
|
2014-12-16 14:29:04 +00:00
|
|
|
|
2015-12-03 12:24:44 +00:00
|
|
|
if (isDecorated()) {
|
2014-12-16 14:29:04 +00:00
|
|
|
QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y));
|
2015-12-03 12:24:44 +00:00
|
|
|
QCoreApplication::instance()->sendEvent(decoration(), &event);
|
2014-12-16 14:29:04 +00:00
|
|
|
}
|
2011-11-09 19:39:13 +00:00
|
|
|
}
|
2021-12-24 12:05:41 +00:00
|
|
|
Gravity newGravity = modKeyDown(state) ? Gravity::None : mouseGravity();
|
|
|
|
if (newGravity != interactiveMoveResizeGravity()) {
|
|
|
|
setInteractiveMoveResizeGravity(newGravity);
|
2007-05-22 15:46:42 +00:00
|
|
|
updateCursor();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (w == moveResizeGrabWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
|
|
|
}
|
2014-02-01 08:34:40 +00:00
|
|
|
|
2021-04-30 18:06:58 +00:00
|
|
|
handleInteractiveMoveResize(QPoint(x, y), QPoint(x_root, y_root));
|
2021-12-27 11:30:02 +00:00
|
|
|
if (isInteractiveMove()) {
|
|
|
|
ScreenEdges::self()->check(QPoint(x_root, y_root), QDateTime::fromMSecsSinceEpoch(xTime(), Qt::UTC));
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::focusInEvent(xcb_focus_in_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->event != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // only window gets focus
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (e->mode == XCB_NOTIFY_MODE_UNGRAB) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we don't care
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (e->detail == XCB_NOTIFY_DETAIL_POINTER) {
|
2022-03-23 10:13:38 +00:00
|
|
|
return; // we don't care
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (isShade() || !isShown() || !isOnCurrentDesktop()) { // we unmapped it, but it got focus meanwhile ->
|
2022-03-23 10:13:38 +00:00
|
|
|
return; // activateNextClient() already transferred focus elsewhere
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
workspace()->forEachClient([](X11Client *client) {
|
2013-08-05 07:48:14 +00:00
|
|
|
client->cancelFocusOutTimer();
|
|
|
|
});
|
2007-04-29 17:35:43 +00:00
|
|
|
// check if this client is in should_get_focus list or if activation is allowed
|
2022-03-23 10:13:38 +00:00
|
|
|
bool activate = workspace()->allowClientActivation(this, -1U, true);
|
|
|
|
workspace()->gotFocusIn(this); // remove from should_get_focus list
|
2020-07-22 11:00:11 +00:00
|
|
|
if (activate) {
|
2011-01-30 14:34:42 +00:00
|
|
|
setActive(true);
|
2020-07-22 11:00:11 +00:00
|
|
|
} else {
|
|
|
|
if (workspace()->restoreFocus()) {
|
|
|
|
demandAttention();
|
|
|
|
} else {
|
2020-11-04 15:49:10 +00:00
|
|
|
qCWarning(KWIN_CORE, "Failed to restore focus. Activating 0x%x", window());
|
2020-07-22 11:00:11 +00:00
|
|
|
setActive(true);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::focusOutEvent(xcb_focus_out_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->event != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // only window gets focus
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (e->mode == XCB_NOTIFY_MODE_GRAB) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we don't care
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (isShade()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // here neither
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2013-07-26 12:51:56 +00:00
|
|
|
if (e->detail != XCB_NOTIFY_DETAIL_NONLINEAR
|
2022-03-25 12:20:32 +00:00
|
|
|
&& e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL) {
|
2007-04-29 17:35:43 +00:00
|
|
|
// SELI check all this
|
|
|
|
return; // hack for motif apps like netscape
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (QApplication::activePopupWidget()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2013-08-05 07:48:14 +00:00
|
|
|
|
|
|
|
// When a client loses focus, FocusOut events are usually immediatelly
|
|
|
|
// followed by FocusIn events for another client that gains the focus
|
|
|
|
// (unless the focus goes to another screen, or to the nofocus widget).
|
|
|
|
// Without this check, the former focused client would have to be
|
|
|
|
// deactivated, and after that, the new one would be activated, with
|
|
|
|
// a short time when there would be no active client. This can cause
|
|
|
|
// flicker sometimes, e.g. when a fullscreen is shown, and focus is transferred
|
|
|
|
// from it to its transient, the fullscreen would be kept in the Active layer
|
|
|
|
// at the beginning and at the end, but not in the middle, when the active
|
2019-09-24 08:48:08 +00:00
|
|
|
// client would be temporarily none (see X11Client::belongToLayer() ).
|
2013-08-05 07:48:14 +00:00
|
|
|
// Therefore the setActive(false) call is moved to the end of the current
|
|
|
|
// event queue. If there is a matching FocusIn event in the current queue
|
|
|
|
// this will be processed before the setActive(false) call and the activation
|
|
|
|
// of the Client which gained FocusIn will automatically deactivate the
|
|
|
|
// previously active client.
|
|
|
|
if (!m_focusOutTimer) {
|
|
|
|
m_focusOutTimer = new QTimer(this);
|
|
|
|
m_focusOutTimer->setSingleShot(true);
|
|
|
|
m_focusOutTimer->setInterval(0);
|
2021-08-22 12:51:36 +00:00
|
|
|
connect(m_focusOutTimer, &QTimer::timeout, this, [this]() {
|
2013-08-05 07:48:14 +00:00
|
|
|
setActive(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
m_focusOutTimer->start();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// performs _NET_WM_MOVERESIZE
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2016-04-15 14:07:39 +00:00
|
|
|
if (direction == NET::Move) {
|
|
|
|
// move cursor to the provided position to prevent the window jumping there on first movement
|
|
|
|
// the expectation is that the cursor is already at the provided position,
|
|
|
|
// thus it's more a safety measurement
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->setPos(QPoint(x_root, y_root));
|
2011-01-30 14:34:42 +00:00
|
|
|
performMouseCommand(Options::MouseMove, QPoint(x_root, y_root));
|
2021-04-30 18:06:58 +00:00
|
|
|
} else if (isInteractiveMoveResize() && direction == NET::MoveResizeCancel) {
|
|
|
|
finishInteractiveMoveResize(true);
|
|
|
|
setInteractiveMoveResizePointerButtonDown(false);
|
2007-05-22 15:46:42 +00:00
|
|
|
updateCursor();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (direction >= NET::TopLeft && direction <= NET::Left) {
|
2021-12-24 12:05:41 +00:00
|
|
|
static const Gravity convert[] = {
|
|
|
|
Gravity::TopLeft,
|
|
|
|
Gravity::Top,
|
|
|
|
Gravity::TopRight,
|
|
|
|
Gravity::Right,
|
|
|
|
Gravity::BottomRight,
|
|
|
|
Gravity::Bottom,
|
|
|
|
Gravity::BottomLeft,
|
2022-03-23 10:13:38 +00:00
|
|
|
Gravity::Left};
|
2022-03-25 12:20:32 +00:00
|
|
|
if (!isResizable() || isShade()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
|
|
|
if (isInteractiveMoveResize()) {
|
2021-04-30 18:06:58 +00:00
|
|
|
finishInteractiveMoveResize(false);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2021-04-30 18:06:58 +00:00
|
|
|
setInteractiveMoveResizePointerButtonDown(true);
|
2022-03-23 10:13:38 +00:00
|
|
|
setInteractiveMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global
|
2021-04-30 18:06:58 +00:00
|
|
|
setInvertedInteractiveMoveOffset(rect().bottomRight() - interactiveMoveOffset());
|
|
|
|
setUnrestrictedInteractiveMoveResize(false);
|
2021-12-24 12:05:41 +00:00
|
|
|
setInteractiveMoveResizeGravity(convert[direction]);
|
2022-03-25 12:20:32 +00:00
|
|
|
if (!startInteractiveMoveResize()) {
|
2021-04-30 18:06:58 +00:00
|
|
|
setInteractiveMoveResizePointerButtonDown(false);
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2007-05-22 15:46:42 +00:00
|
|
|
updateCursor();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (direction == NET::KeyboardMove) {
|
|
|
|
// ignore mouse coordinates given in the message, mouse position is used by the moving algorithm
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->setPos(frameGeometry().center());
|
2019-09-27 10:01:10 +00:00
|
|
|
performMouseCommand(Options::MouseUnrestrictedMove, frameGeometry().center());
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (direction == NET::KeyboardSize) {
|
|
|
|
// ignore mouse coordinates given in the message, mouse position is used by the resizing algorithm
|
2020-04-02 16:18:01 +00:00
|
|
|
Cursors::self()->mouse()->setPos(frameGeometry().bottomRight());
|
2019-09-27 10:01:10 +00:00
|
|
|
performMouseCommand(Options::MouseUnrestrictedResize, frameGeometry().bottomRight());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::keyPressEvent(uint key_code, xcb_timestamp_t time)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-06-01 15:57:51 +00:00
|
|
|
updateUserTime(time);
|
2015-10-23 13:32:10 +00:00
|
|
|
AbstractClient::keyPressEvent(key_code);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Unmanaged
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 09:16:50 +00:00
|
|
|
bool Unmanaged::windowEvent(xcb_generic_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-03-17 09:22:20 +00:00
|
|
|
NET::Properties dirtyProperties;
|
|
|
|
NET::Properties2 dirtyProperties2;
|
2022-03-23 10:13:38 +00:00
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
2014-03-17 09:22:20 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2021-06-14 09:44:36 +00:00
|
|
|
if (Compositor::compositing()) {
|
2021-02-05 22:18:45 +00:00
|
|
|
setOpacity(info->opacityF());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-22 14:46:12 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2OpaqueRegion) {
|
|
|
|
getWmOpaqueRegion();
|
|
|
|
}
|
2014-04-10 09:12:48 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT windowRoleChanged();
|
2014-04-10 09:12:48 +00:00
|
|
|
}
|
2014-04-11 06:06:26 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
|
|
|
getResourceClass();
|
|
|
|
}
|
2013-07-26 11:00:51 +00:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
|
|
|
switch (eventType) {
|
2014-04-07 14:23:17 +00:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
release(ReleaseReason::Destroyed);
|
|
|
|
break;
|
2022-03-23 10:13:38 +00:00
|
|
|
case XCB_UNMAP_NOTIFY: {
|
2020-04-02 16:18:01 +00:00
|
|
|
workspace()->updateFocusMousePosition(Cursors::self()->mouse()->pos()); // may cause leave event
|
2014-04-07 14:23:17 +00:00
|
|
|
|
|
|
|
// unmap notify might have been emitted due to a destroy notify
|
|
|
|
// but unmap notify gets emitted before the destroy notify, nevertheless at this
|
|
|
|
// point the window is already destroyed. This means any XCB request with the window
|
|
|
|
// will cause an error.
|
|
|
|
// To not run into these errors we try to wait for the destroy notify. For this we
|
|
|
|
// generate a round trip to the X server and wait a very short time span before
|
|
|
|
// handling the release.
|
|
|
|
updateXTime();
|
|
|
|
// using 1 msec to not just move it at the end of the event loop but add an very short
|
|
|
|
// timespan to cover cases like unmap() followed by destroy(). The only other way to
|
|
|
|
// ensure that the window is not destroyed when we do the release handling is to grab
|
|
|
|
// the XServer which we do not want to do for an Unmanaged. The timespan of 1 msec is
|
|
|
|
// short enough to not cause problems in the close window animations.
|
|
|
|
// It's of course still possible that we miss the destroy in which case non-fatal
|
|
|
|
// X errors are reported to the event loop and logged by Qt.
|
2019-10-24 10:00:16 +00:00
|
|
|
m_scheduledRelease = true;
|
2022-03-23 10:13:38 +00:00
|
|
|
QTimer::singleShot(1, this, [this]() {
|
|
|
|
release();
|
|
|
|
});
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2014-04-07 14:23:17 +00:00
|
|
|
}
|
2013-07-26 11:04:12 +00:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
configureNotifyEvent(reinterpret_cast<xcb_configure_notify_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 11:17:23 +00:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
2022-03-23 10:13:38 +00:00
|
|
|
propertyNotifyEvent(reinterpret_cast<xcb_property_notify_event_t *>(e));
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2015-01-09 10:16:57 +00:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
2022-03-23 10:13:38 +00:00
|
|
|
clientMessageEvent(reinterpret_cast<xcb_client_message_event_t *>(e));
|
2015-01-09 10:16:57 +00:00
|
|
|
break;
|
2011-01-30 14:34:42 +00:00
|
|
|
default: {
|
2013-07-26 11:05:23 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
detectShape(window());
|
|
|
|
addRepaintFull();
|
2022-03-23 10:13:38 +00:00
|
|
|
addWorkspaceRepaint(frameGeometry()); // in case shape change removes part of this window
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT geometryShapeChanged(this, frameGeometry());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2022-03-25 12:20:32 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) {
|
2013-04-26 09:00:08 +00:00
|
|
|
damageNotifyEvent();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-07-26 11:00:51 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return false; // don't eat events, even our own unmanaged widgets are tracked
|
|
|
|
}
|
|
|
|
|
2013-07-26 11:04:12 +00:00
|
|
|
void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (effects) {
|
2022-03-23 10:13:38 +00:00
|
|
|
static_cast<EffectsHandlerImpl *>(effects)->checkInputWindowStacking(); // keep them on top
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect newgeom(e->x, e->y, e->width, e->height);
|
2019-12-04 13:18:34 +00:00
|
|
|
if (newgeom != m_frameGeometry) {
|
|
|
|
QRect old = m_frameGeometry;
|
2020-06-01 10:43:49 +00:00
|
|
|
m_clientGeometry = newgeom;
|
2019-12-04 13:18:34 +00:00
|
|
|
m_frameGeometry = newgeom;
|
2021-05-15 10:56:35 +00:00
|
|
|
m_bufferGeometry = newgeom;
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT bufferGeometryChanged(this, old);
|
|
|
|
Q_EMIT clientGeometryChanged(this, old);
|
|
|
|
Q_EMIT frameGeometryChanged(this, old);
|
|
|
|
Q_EMIT geometryShapeChanged(this, old);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Toplevel
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 11:17:23 +00:00
|
|
|
void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->window != window()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2022-03-23 10:13:38 +00:00
|
|
|
switch (e->atom) {
|
2011-01-30 14:34:42 +00:00
|
|
|
default:
|
2022-03-25 12:20:32 +00:00
|
|
|
if (e->atom == atoms->wm_client_leader) {
|
2011-01-30 14:34:42 +00:00
|
|
|
getWmClientLeader();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_net_wm_shadow) {
|
2019-09-29 11:26:04 +00:00
|
|
|
updateShadow();
|
2022-03-25 12:20:32 +00:00
|
|
|
} else if (e->atom == atoms->kde_skip_close_animation) {
|
2014-01-24 11:34:16 +00:00
|
|
|
getSkipCloseAnimation();
|
2022-03-25 12:20:32 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-01-09 10:16:57 +00:00
|
|
|
void Toplevel::clientMessageEvent(xcb_client_message_event_t *e)
|
|
|
|
{
|
|
|
|
if (e->type == atoms->wl_surface_id) {
|
2021-09-29 08:28:47 +00:00
|
|
|
m_pendingSurfaceId = e->data.data32[0];
|
2015-04-02 07:49:39 +00:00
|
|
|
if (auto w = waylandServer()) {
|
2021-09-29 08:28:47 +00:00
|
|
|
if (auto s = KWaylandServer::SurfaceInterface::get(m_pendingSurfaceId, w->xWaylandConnection())) {
|
2016-06-10 14:15:56 +00:00
|
|
|
setSurface(s);
|
|
|
|
}
|
2015-04-02 07:49:39 +00:00
|
|
|
}
|
2015-01-09 10:16:57 +00:00
|
|
|
}
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|