2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to handling incoming events.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "client.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"
|
|
|
|
#include "atoms.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "tabbox.h"
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "group.h"
|
2011-07-06 09:58:23 +00:00
|
|
|
#include "overlaywindow.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "rules.h"
|
|
|
|
#include "unmanaged.h"
|
2012-08-19 10:00:53 +00:00
|
|
|
#include "useractions.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "effects.h"
|
2013-01-21 08:04:06 +00:00
|
|
|
#include "screenedge.h"
|
2013-04-03 10:19:27 +00:00
|
|
|
#include "screens.h"
|
2012-12-21 14:11:31 +00:00
|
|
|
#include "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>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QWhatsThis>
|
2014-12-02 12:50:26 +00:00
|
|
|
#include <QWheelEvent>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <kkeyserver.h>
|
|
|
|
|
2013-07-26 10:00:14 +00:00
|
|
|
#include <xcb/sync.h>
|
2014-06-11 05:51:07 +00:00
|
|
|
#ifdef 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"
|
2012-12-27 13:26:46 +00:00
|
|
|
#include "killwindow.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"
|
2015-02-09 15:08:53 +00:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
|
2014-09-19 08:04:00 +00:00
|
|
|
#ifndef XCB_GE_GENERIC
|
|
|
|
#define XCB_GE_GENERIC 35
|
|
|
|
typedef struct xcb_ge_generic_event_t {
|
|
|
|
uint8_t response_type; /**< */
|
|
|
|
uint8_t extension; /**< */
|
|
|
|
uint16_t sequence; /**< */
|
|
|
|
uint32_t length; /**< */
|
|
|
|
uint16_t event_type; /**< */
|
|
|
|
uint8_t pad0[22]; /**< */
|
|
|
|
uint32_t full_sequence; /**< */
|
|
|
|
} xcb_ge_generic_event_t;
|
|
|
|
#endif
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2010-11-27 15:27:54 +00:00
|
|
|
extern int currentRefreshRate();
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// ****************************************
|
|
|
|
// 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;
|
|
|
|
switch(eventType) {
|
|
|
|
case XCB_KEY_PRESS:
|
|
|
|
case XCB_KEY_RELEASE:
|
|
|
|
return reinterpret_cast<xcb_key_press_event_t*>(event)->event;
|
|
|
|
case XCB_BUTTON_PRESS:
|
|
|
|
case XCB_BUTTON_RELEASE:
|
|
|
|
return reinterpret_cast<xcb_button_press_event_t*>(event)->event;
|
|
|
|
case XCB_MOTION_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_motion_notify_event_t*>(event)->event;
|
|
|
|
case XCB_ENTER_NOTIFY:
|
|
|
|
case XCB_LEAVE_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_enter_notify_event_t*>(event)->event;
|
|
|
|
case XCB_FOCUS_IN:
|
|
|
|
case XCB_FOCUS_OUT:
|
|
|
|
return reinterpret_cast<xcb_focus_in_event_t*>(event)->event;
|
|
|
|
case XCB_EXPOSE:
|
|
|
|
return reinterpret_cast<xcb_expose_event_t*>(event)->window;
|
|
|
|
case XCB_GRAPHICS_EXPOSURE:
|
|
|
|
return reinterpret_cast<xcb_graphics_exposure_event_t*>(event)->drawable;
|
|
|
|
case XCB_NO_EXPOSURE:
|
|
|
|
return reinterpret_cast<xcb_no_exposure_event_t*>(event)->drawable;
|
|
|
|
case XCB_VISIBILITY_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_visibility_notify_event_t*>(event)->window;
|
|
|
|
case XCB_CREATE_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_create_notify_event_t*>(event)->window;
|
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_destroy_notify_event_t*>(event)->window;
|
|
|
|
case XCB_UNMAP_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_unmap_notify_event_t*>(event)->window;
|
|
|
|
case XCB_MAP_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_map_notify_event_t*>(event)->window;
|
|
|
|
case XCB_MAP_REQUEST:
|
|
|
|
return reinterpret_cast<xcb_map_request_event_t*>(event)->window;
|
|
|
|
case XCB_REPARENT_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_reparent_notify_event_t*>(event)->window;
|
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_configure_notify_event_t*>(event)->window;
|
|
|
|
case XCB_CONFIGURE_REQUEST:
|
|
|
|
return reinterpret_cast<xcb_configure_request_event_t*>(event)->window;
|
|
|
|
case XCB_GRAVITY_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_gravity_notify_event_t*>(event)->window;
|
|
|
|
case XCB_RESIZE_REQUEST:
|
|
|
|
return reinterpret_cast<xcb_resize_request_event_t*>(event)->window;
|
|
|
|
case XCB_CIRCULATE_NOTIFY:
|
|
|
|
case XCB_CIRCULATE_REQUEST:
|
|
|
|
return reinterpret_cast<xcb_circulate_notify_event_t*>(event)->window;
|
|
|
|
case XCB_PROPERTY_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_property_notify_event_t*>(event)->window;
|
|
|
|
case XCB_COLORMAP_NOTIFY:
|
|
|
|
return reinterpret_cast<xcb_colormap_notify_event_t*>(event)->window;
|
|
|
|
case XCB_CLIENT_MESSAGE:
|
|
|
|
return reinterpret_cast<xcb_client_message_event_t*>(event)->window;
|
|
|
|
default:
|
|
|
|
// extension handling
|
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) {
|
|
|
|
return reinterpret_cast<xcb_shape_notify_event_t*>(event)->affected_window;
|
|
|
|
}
|
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent()) {
|
|
|
|
return reinterpret_cast<xcb_damage_notify_event_t*>(event)->drawable;
|
|
|
|
}
|
|
|
|
return XCB_WINDOW_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-07 13:05:41 +00:00
|
|
|
QVector<QByteArray> s_xcbEerrors({
|
|
|
|
QByteArrayLiteral("Success"),
|
|
|
|
QByteArrayLiteral("BadRequest"),
|
|
|
|
QByteArrayLiteral("BadValue"),
|
|
|
|
QByteArrayLiteral("BadWindow"),
|
|
|
|
QByteArrayLiteral("BadPixmap"),
|
|
|
|
QByteArrayLiteral("BadAtom"),
|
|
|
|
QByteArrayLiteral("BadCursor"),
|
|
|
|
QByteArrayLiteral("BadFont"),
|
|
|
|
QByteArrayLiteral("BadMatch"),
|
|
|
|
QByteArrayLiteral("BadDrawable"),
|
|
|
|
QByteArrayLiteral("BadAccess"),
|
|
|
|
QByteArrayLiteral("BadAlloc"),
|
|
|
|
QByteArrayLiteral("BadColor"),
|
|
|
|
QByteArrayLiteral("BadGC"),
|
|
|
|
QByteArrayLiteral("BadIDChoice"),
|
|
|
|
QByteArrayLiteral("BadName"),
|
|
|
|
QByteArrayLiteral("BadLength"),
|
|
|
|
QByteArrayLiteral("BadImplementation"),
|
|
|
|
QByteArrayLiteral("Unknown")});
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
void Workspace::registerEventFilter(X11EventFilter *filter)
|
|
|
|
{
|
|
|
|
if (filter->eventType() == XCB_GE_GENERIC)
|
|
|
|
m_genericEventFilters.append(filter);
|
|
|
|
else
|
|
|
|
m_eventFilters.append(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::unregisterEventFilter(X11EventFilter *filter)
|
|
|
|
{
|
|
|
|
if (filter->eventType() == XCB_GE_GENERIC)
|
|
|
|
m_genericEventFilters.removeOne(filter);
|
|
|
|
else
|
|
|
|
m_eventFilters.removeOne(filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
/*!
|
2013-07-26 05:52:56 +00:00
|
|
|
Handles workspace specific XCB event
|
2007-04-29 17:35:43 +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;
|
2014-04-07 13:05:41 +00:00
|
|
|
if (!eventType) {
|
|
|
|
// let's check whether it's an error from one of the extensions KWin uses
|
|
|
|
xcb_generic_error_t *error = reinterpret_cast<xcb_generic_error_t*>(e);
|
|
|
|
const QVector<Xcb::ExtensionData> extensions = Xcb::Extensions::self()->extensions();
|
|
|
|
for (const auto &extension : extensions) {
|
|
|
|
if (error->major_code == extension.majorOpcode) {
|
|
|
|
QByteArray errorName;
|
|
|
|
if (error->error_code < s_xcbEerrors.size()) {
|
|
|
|
errorName = s_xcbEerrors.at(error->error_code);
|
|
|
|
} else if (error->error_code >= extension.errorBase) {
|
|
|
|
const int index = error->error_code - extension.errorBase;
|
|
|
|
if (index >= 0 && index < extension.errorCodes.size()) {
|
|
|
|
errorName = extension.errorCodes.at(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errorName.isEmpty()) {
|
|
|
|
errorName = QByteArrayLiteral("Unknown");
|
|
|
|
}
|
2014-12-05 10:42:15 +00:00
|
|
|
qCWarning(KWIN_CORE, "XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d (%s)",
|
2014-04-07 13:05:41 +00:00
|
|
|
int(error->error_code), errorName.constData(),
|
|
|
|
int(error->sequence), int(error->resource_id),
|
|
|
|
int(error->major_code), extension.name.constData(),
|
|
|
|
int(error->minor_code),
|
|
|
|
extension.opCodes.size() > error->minor_code ? extension.opCodes.at(error->minor_code).constData() : "Unknown");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2014-09-02 16:46:07 +00:00
|
|
|
|
|
|
|
if (eventType == XCB_GE_GENERIC) {
|
|
|
|
xcb_ge_generic_event_t *ge = reinterpret_cast<xcb_ge_generic_event_t *>(e);
|
|
|
|
|
|
|
|
foreach (X11EventFilter *filter, m_genericEventFilters) {
|
2016-08-11 10:55:25 +00:00
|
|
|
if (filter->extension() == ge->extension && filter->genericEventTypes().contains(ge->event_type) && filter->event(e)) {
|
2014-09-02 16:46:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (X11EventFilter *filter, m_eventFilters) {
|
|
|
|
if (filter->eventType() == eventType && filter->event(e)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()
|
2013-07-26 06:01:16 +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()
|
|
|
|
|
2013-07-26 06:02:54 +00:00
|
|
|
if (!m_windowKiller.isNull() && m_windowKiller->isActive() && m_windowKiller->isResponsibleForEvent(eventType)) {
|
2012-12-27 13:26:46 +00:00
|
|
|
m_windowKiller->processEvent(e);
|
|
|
|
// filter out the event
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-26 06:06:36 +00:00
|
|
|
if (eventType == XCB_PROPERTY_NOTIFY || eventType == XCB_CLIENT_MESSAGE) {
|
2014-03-17 09:22:20 +00:00
|
|
|
NET::Properties dirtyProtocols;
|
|
|
|
NET::Properties2 dirtyProtocols2;
|
|
|
|
rootInfo()->event(e, &dirtyProtocols, &dirtyProtocols2);
|
|
|
|
if (dirtyProtocols & NET::DesktopNames)
|
2012-11-16 07:23:47 +00:00
|
|
|
VirtualDesktopManager::self()->save();
|
2014-03-17 09:22:20 +00:00
|
|
|
if (dirtyProtocols2 & NET::WM2DesktopLayout)
|
2012-11-16 07:23:47 +00:00
|
|
|
VirtualDesktopManager::self()->updateLayout();
|
2011-01-30 14:34:42 +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) {
|
|
|
|
case XCB_BUTTON_PRESS:
|
|
|
|
case XCB_BUTTON_RELEASE: {
|
2011-01-30 14:34:42 +00:00
|
|
|
was_user_interaction = true;
|
2013-07-26 06:46:31 +00:00
|
|
|
auto *mouseEvent = reinterpret_cast<xcb_button_press_event_t*>(e);
|
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
|
|
|
return TabBox::TabBox::self()->handleMouseEvent(mouseEvent);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (effects && static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(mouseEvent)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case XCB_MOTION_NOTIFY: {
|
2016-08-22 17:20:57 +00:00
|
|
|
if (kwinApp()->operationMode() != Application::OperationModeX11) {
|
|
|
|
// ignore X11 pointer events generated on X windows if we are not on X
|
|
|
|
return true;
|
|
|
|
}
|
2013-07-26 06:46:31 +00:00
|
|
|
auto *mouseEvent = reinterpret_cast<xcb_motion_notify_event_t*>(e);
|
|
|
|
const QPoint rootPos(mouseEvent->root_x, mouseEvent->root_y);
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
2013-07-26 06:46:31 +00:00
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime()), true);
|
|
|
|
return TabBox::TabBox::self()->handleMouseEvent(mouseEvent);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2013-07-26 06:46:31 +00:00
|
|
|
if (effects && static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(mouseEvent)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
2013-03-08 19:17:55 +00:00
|
|
|
}
|
|
|
|
if (QWidget::mouseGrabber()) {
|
2013-07-26 06:46:31 +00:00
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime()), true);
|
2014-02-01 09:03:49 +00:00
|
|
|
} else {
|
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(mouseEvent->time));
|
2013-03-08 19:17:55 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 06:46:31 +00:00
|
|
|
}
|
2013-07-26 08:04:53 +00:00
|
|
|
case XCB_KEY_PRESS: {
|
2011-01-30 14:34:42 +00:00
|
|
|
was_user_interaction = true;
|
|
|
|
int keyQt;
|
2014-06-01 15:57:51 +00:00
|
|
|
xcb_key_press_event_t *event = reinterpret_cast<xcb_key_press_event_t*>(e);
|
|
|
|
KKeyServer::xcbKeyPressEventToQt(event, &keyQt);
|
2013-11-01 11:29:05 +00:00
|
|
|
// qDebug() << "Workspace::keyPress( " << keyQt << " )";
|
2015-03-06 11:38:07 +00:00
|
|
|
if (Client *c = dynamic_cast<Client*>(movingClient)) {
|
|
|
|
c->keyPressEvent(keyQt, event->time);
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
|
|
|
TabBox::TabBox::self()->keyPress(keyQt);
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-07-26 08:04:53 +00:00
|
|
|
case XCB_KEY_RELEASE:
|
2011-01-30 14:34:42 +00:00
|
|
|
was_user_interaction = true;
|
2011-06-30 11:02:30 +00:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 07:41:18 +00:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
2013-07-26 08:04:53 +00:00
|
|
|
TabBox::TabBox::self()->keyRelease(reinterpret_cast<xcb_key_release_event_t*>(e));
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 11:02:30 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2013-07-26 08:10:49 +00:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
|
|
|
if (reinterpret_cast<xcb_configure_notify_event_t*>(e)->event == rootWindow())
|
2011-01-30 14:34:42 +00:00
|
|
|
x_stacking_dirty = true;
|
|
|
|
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) {
|
2014-03-20 08:19:53 +00:00
|
|
|
if (Client* c = findClient(Predicate::WindowMatch, eventWindow)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 08:19:53 +00:00
|
|
|
} else if (Client* c = findClient(Predicate::WrapperIdMatch, eventWindow)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 08:19:53 +00:00
|
|
|
} else if (Client* c = findClient(Predicate::FrameIdMatch, eventWindow)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 08:19:53 +00:00
|
|
|
} else if (Client *c = findClient(Predicate::InputIdMatch, eventWindow)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 06:52:18 +00:00
|
|
|
} else if (Unmanaged* c = findUnmanaged(eventWindow)) {
|
2013-08-30 11:34:29 +00:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// We want to pass root window property events to effects
|
|
|
|
if (eventType == XCB_PROPERTY_NOTIFY) {
|
|
|
|
auto *event = reinterpret_cast<xcb_property_notify_event_t*>(e);
|
|
|
|
if (event->window == rootWindow()) {
|
|
|
|
emit propertyNotify(event->atom);
|
|
|
|
}
|
2013-07-26 14:19:05 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2015-03-06 11:38:07 +00:00
|
|
|
if (Client *c = dynamic_cast<Client*>(movingClient)) {
|
2014-07-22 11:11:19 +00:00
|
|
|
if (eventType == XCB_BUTTON_PRESS || eventType == XCB_BUTTON_RELEASE || eventType == XCB_MOTION_NOTIFY) {
|
2015-03-06 11:38:07 +00:00
|
|
|
if (c->moveResizeGrabWindow() == reinterpret_cast<xcb_button_press_event_t*>(e)->event && c->windowEvent(e)) {
|
2013-07-26 08:32:48 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
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: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_create_notify_event_t*>(e);
|
|
|
|
if (event->parent == rootWindow() &&
|
|
|
|
!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();
|
|
|
|
xcb_change_property(connection(), 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: {
|
|
|
|
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: {
|
2007-04-29 17:35:43 +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 08:56:43 +00:00
|
|
|
case XCB_DESTROY_NOTIFY: {
|
2011-01-30 14:34:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-26 09:02:44 +00:00
|
|
|
case XCB_MAP_REQUEST: {
|
2011-01-30 14:34:42 +00:00
|
|
|
updateXTime();
|
|
|
|
|
2013-07-26 09:02:44 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_map_request_event_t*>(e);
|
2014-03-20 08:19:53 +00:00
|
|
|
if (Client* 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);
|
2012-02-03 22:31:13 +00:00
|
|
|
} else if ( true /*|| e->xmaprequest.parent != root */ ) {
|
|
|
|
// 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
|
|
|
|
// NOTICE: The save-set support in Client::mapRequestEvent() actually requires that
|
|
|
|
// this code doesn't check the parent to be root.
|
2013-07-26 09:02:44 +00:00
|
|
|
if (!createClient(event->window, false)) {
|
|
|
|
xcb_map_window(connection(), event->window);
|
|
|
|
const uint32_t values[] = { XCB_STACK_MODE_ABOVE };
|
|
|
|
xcb_configure_window(connection(), event->window, XCB_CONFIG_WINDOW_STACK_MODE, values);
|
|
|
|
}
|
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: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_map_notify_event_t*>(e);
|
|
|
|
if (event->override_redirect) {
|
2014-03-20 06:52:18 +00:00
|
|
|
Unmanaged* c = findUnmanaged(event->window);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c == NULL)
|
2013-07-26 09:16:50 +00:00
|
|
|
c = createUnmanaged(event->window);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c)
|
|
|
|
return c->windowEvent(e);
|
|
|
|
}
|
2013-07-26 09:16:50 +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:24:19 +00:00
|
|
|
case XCB_ENTER_NOTIFY: {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (QWhatsThis::inWhatsThisMode()) {
|
2013-07-26 09:24:19 +00:00
|
|
|
QWidget* w = QWidget::find(reinterpret_cast<xcb_enter_notify_event_t*>(e)->event);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w)
|
2007-04-29 17:35:43 +00:00
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-08-01 09:36:38 +00:00
|
|
|
if (ScreenEdges::self()->isEntered(reinterpret_cast<xcb_enter_notify_event_t*>(e)))
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 09:24:19 +00:00
|
|
|
case XCB_LEAVE_NOTIFY: {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!QWhatsThis::inWhatsThisMode())
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
2011-01-30 14:34:42 +00:00
|
|
|
// TODO is this cliente ever found, given that client events are searched above?
|
2013-07-26 09:24:19 +00:00
|
|
|
const auto *event = reinterpret_cast<xcb_leave_notify_event_t*>(e);
|
2014-03-20 08:19:53 +00:00
|
|
|
Client* c = findClient(Predicate::FrameIdMatch, event->event);
|
2013-07-26 09:24:19 +00:00
|
|
|
if (c && event->detail != XCB_NOTIFY_DETAIL_INFERIOR)
|
2011-01-30 14:34:42 +00:00
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 09:31:24 +00:00
|
|
|
case XCB_CONFIGURE_REQUEST: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_configure_request_event_t*>(e);
|
|
|
|
if (event->parent == rootWindow()) {
|
2014-04-25 12:42:20 +00:00
|
|
|
uint32_t values[5] = { 0, 0, 0, 0, 0};
|
|
|
|
const uint32_t value_mask = event->value_mask
|
|
|
|
& (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
xcb_configure_window(connection(), 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: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_focus_in_event_t*>(e);
|
|
|
|
if (event->event == rootWindow()
|
2015-11-10 22:59:17 +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
|
|
|
|
const bool lostFocusPointerToRoot = currentInput->focus == rootWindow() && event->detail == XCB_NOTIFY_DETAIL_INFERIOR;
|
|
|
|
if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT || lostFocusPointerToRoot)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
//kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
|
2015-03-12 10:56:55 +00:00
|
|
|
AbstractClient *c = mostRecentlyActivatedClient();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c != NULL)
|
|
|
|
requestFocus(c, true);
|
|
|
|
else if (activateNextClient(NULL))
|
|
|
|
; // ok, activated
|
|
|
|
else
|
|
|
|
focusToNull();
|
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
|
2013-07-26 09:41:44 +00:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
2013-08-01 09:36:38 +00:00
|
|
|
if (ScreenEdges::self()->isEntered(reinterpret_cast<xcb_client_message_event_t*>(e)))
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
break;
|
2013-07-26 09:44:00 +00:00
|
|
|
case XCB_EXPOSE: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_expose_event_t*>(e);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing()
|
2013-07-26 09:44:00 +00:00
|
|
|
&& (event->window == rootWindow() // root window needs repainting
|
|
|
|
|| (m_compositor->overlayWindow() != XCB_WINDOW_NONE && event->window == m_compositor->overlayWindow()))) { // overlay needs repainting
|
|
|
|
m_compositor->addRepaint(event->x, event->y, event->width, event->height);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-26 09:44:00 +00:00
|
|
|
}
|
2013-07-26 09:46:00 +00:00
|
|
|
case XCB_VISIBILITY_NOTIFY: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_visibility_notify_event_t*>(e);
|
|
|
|
if (compositing() && m_compositor->overlayWindow() != XCB_WINDOW_NONE && event->window == m_compositor->overlayWindow()) {
|
2012-08-16 19:19:54 +00:00
|
|
|
bool was_visible = m_compositor->isOverlayWindowVisible();
|
2013-07-26 09:46:00 +00:00
|
|
|
m_compositor->setOverlayWindowVisibility((event->state != XCB_VISIBILITY_FULLY_OBSCURED));
|
2012-08-16 19:19:54 +00:00
|
|
|
if (!was_visible && m_compositor->isOverlayWindowVisible()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// hack for #154825
|
2012-08-28 17:43:33 +00:00
|
|
|
m_compositor->addRepaintFull();
|
|
|
|
QTimer::singleShot(2000, m_compositor, SLOT(addRepaintFull()));
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2012-08-28 17:43:33 +00:00
|
|
|
m_compositor->scheduleRepaint();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-26 09:46:00 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
default:
|
2013-07-26 10:00:14 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->randrNotifyEvent() && Xcb::Extensions::self()->isRandrAvailable()) {
|
2013-08-30 12:30:14 +00:00
|
|
|
auto *event = reinterpret_cast<xcb_randr_screen_change_notify_event_t*>(e);
|
|
|
|
xcb_screen_t *screen = defaultScreen();
|
|
|
|
if (event->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) {
|
|
|
|
screen->width_in_pixels = event->height;
|
|
|
|
screen->height_in_pixels = event->width;
|
|
|
|
screen->width_in_millimeters = event->mheight;
|
|
|
|
screen->height_in_millimeters = event->mwidth;
|
|
|
|
} else {
|
|
|
|
screen->width_in_pixels = event->width;
|
|
|
|
screen->height_in_pixels = event->height;
|
|
|
|
screen->width_in_millimeters = event->mwidth;
|
|
|
|
screen->height_in_millimeters = event->mheight;
|
|
|
|
}
|
2012-08-28 17:43:33 +00:00
|
|
|
if (compositing()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// desktopResized() should take care of when the size or
|
|
|
|
// shape of the desktop has changed, but we also want to
|
|
|
|
// catch refresh rate changes
|
2011-08-21 19:50:23 +00:00
|
|
|
if (m_compositor->xrrRefreshRate() != currentRefreshRate())
|
|
|
|
m_compositor->setCompositeResetTimer(0);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2010-11-27 15:27:54 +00:00
|
|
|
|
2013-07-26 10:00:14 +00:00
|
|
|
} else if (eventType == Xcb::Extensions::self()->syncAlarmNotifyEvent() && Xcb::Extensions::self()->isSyncAvailable()) {
|
|
|
|
for (Client *c : clients)
|
|
|
|
c->syncEvent(reinterpret_cast< xcb_sync_alarm_notify_event_t* >(e));
|
|
|
|
for (Client *c : desktops)
|
|
|
|
c->syncEvent(reinterpret_cast< xcb_sync_alarm_notify_event_t* >(e));
|
|
|
|
} else if (eventType == Xcb::Extensions::self()->fixesCursorNotifyEvent() && Xcb::Extensions::self()->isFixesAvailable()) {
|
|
|
|
Cursor::self()->notifyCursorChanged(reinterpret_cast<xcb_xfixes_cursor_notify_event_t*>(e)->cursor_serial);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
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
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Workspace::workspaceEvent(QEvent* e)
|
|
|
|
{
|
|
|
|
if ((e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease || e->type() == QEvent::ShortcutOverride)
|
|
|
|
&& 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
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
/*!
|
|
|
|
General handler for XEvents concerning the client window
|
|
|
|
*/
|
2013-07-26 08:32:48 +00:00
|
|
|
bool Client::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;
|
2007-04-29 17:35:43 +00:00
|
|
|
double old_opacity = opacity();
|
2014-03-17 09:22:20 +00:00
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties & NET::WMName) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
fetchName();
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties & NET::WMIconName) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
fetchIconicName();
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties & NET::WMStrut) != 0
|
|
|
|
|| (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) {
|
2007-04-29 17:35:43 +00:00
|
|
|
workspace()->updateClientArea();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties & NET::WMIcon) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
getIcons();
|
|
|
|
// 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());
|
|
|
|
}
|
2014-03-17 09:22:20 +00:00
|
|
|
if ((dirtyProperties2 & NET::WM2StartupId) != 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
startupIdChanged();
|
2014-03-17 09:22:20 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
addRepaintFull();
|
2011-03-06 09:30:23 +00:00
|
|
|
emit opacityChanged(this, old_opacity);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
|
|
|
// forward to the frame if there's possibly another compositing manager running
|
2014-03-17 09:22:20 +00:00
|
|
|
NETWinInfo i(connection(), frameId(), rootWindow(), 0, 0);
|
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-03-17 09:22:20 +00:00
|
|
|
if (dirtyProperties2 & NET::WM2FrameOverlap) {
|
2009-11-25 23:32:35 +00:00
|
|
|
// ### Inform the decoration
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2014-04-10 09:12:48 +00:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
|
|
|
emit windowRoleChanged();
|
|
|
|
}
|
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();
|
|
|
|
}
|
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;
|
|
|
|
switch(eventType) {
|
2013-07-26 11:34:54 +00:00
|
|
|
case XCB_UNMAP_NOTIFY:
|
|
|
|
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:
|
|
|
|
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
|
2013-07-26 11:46:06 +00:00
|
|
|
return mapRequestEvent(reinterpret_cast<xcb_map_request_event_t*>(e));
|
2013-07-26 11:56:16 +00:00
|
|
|
case XCB_CONFIGURE_REQUEST:
|
|
|
|
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:
|
|
|
|
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:
|
2014-06-01 15:57:51 +00:00
|
|
|
updateUserTime(reinterpret_cast<xcb_key_press_event_t*>(e)->time);
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->setWasUserInteraction();
|
|
|
|
break;
|
2013-07-26 12:03:14 +00:00
|
|
|
case XCB_BUTTON_PRESS: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_button_press_event_t*>(e);
|
2014-06-01 15:57:51 +00:00
|
|
|
updateUserTime(event->time);
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->setWasUserInteraction();
|
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: {
|
|
|
|
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: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_motion_notify_event_t*>(e);
|
|
|
|
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: {
|
|
|
|
auto *event = reinterpret_cast<xcb_enter_notify_event_t*>(e);
|
|
|
|
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: {
|
|
|
|
auto *event = reinterpret_cast<xcb_leave_notify_event_t*>(e);
|
|
|
|
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:
|
|
|
|
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:
|
|
|
|
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:
|
|
|
|
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: {
|
|
|
|
xcb_expose_event_t *event = reinterpret_cast<xcb_expose_event_t*>(e);
|
|
|
|
if (event->window == frameId() && !Compositor::self()->isActive()) {
|
|
|
|
// TODO: only repaint required areas
|
|
|
|
triggerDecorationRepaint();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
default:
|
2013-07-26 13:05:55 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent() && reinterpret_cast<xcb_shape_notify_event_t*>(e)->affected_window == window()) {
|
|
|
|
detectShape(window()); // workaround for #19644
|
|
|
|
updateShape();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-07-26 13:05:55 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast<xcb_damage_notify_event_t*>(e)->drawable == frameId())
|
|
|
|
damageNotifyEvent();
|
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
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles map requests of the client window
|
|
|
|
*/
|
2013-07-26 11:46:06 +00:00
|
|
|
bool Client::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).
|
2011-01-30 14:34:42 +00:00
|
|
|
if (e->parent == wrapperId())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
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()
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isMinimized())
|
2008-08-12 11:02:58 +00:00
|
|
|
unminimize();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShade())
|
|
|
|
setShade(ShadeNone);
|
|
|
|
if (!isOnCurrentDesktop()) {
|
|
|
|
if (workspace()->allowClientActivation(this))
|
|
|
|
workspace()->activateClient(this);
|
2008-08-12 11:02:58 +00:00
|
|
|
else
|
|
|
|
demandAttention();
|
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
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles unmap notify events of the client window
|
|
|
|
*/
|
2013-07-26 11:34:54 +00:00
|
|
|
void Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
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;
|
2013-08-02 08:24:20 +00:00
|
|
|
if (e->event == rootWindow() && (e->response_type & 0x80))
|
2007-04-29 17:35:43 +00:00
|
|
|
ignore = false; // XWithdrawWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
if (ignore)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
2013-07-26 11:40:43 +00:00
|
|
|
void Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
destroyClient();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
/*!
|
|
|
|
Handles client messages for the client window
|
|
|
|
*/
|
2013-07-26 13:02:59 +00:00
|
|
|
void Client::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);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
|
|
|
// WM_STATE
|
2014-05-20 13:58:15 +00:00
|
|
|
if (e->type == atoms->wm_change_state) {
|
2013-07-26 13:02:59 +00:00
|
|
|
if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)
|
2007-04-29 17:35:43 +00:00
|
|
|
minimize();
|
|
|
|
return;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles configure requests of the client window
|
|
|
|
*/
|
2013-07-26 11:56:16 +00:00
|
|
|
void Client::configureRequestEvent(xcb_configure_request_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isResize() || isMove())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we have better things to do right now
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (fullscreen_mode == FullScreenNormal) { // refuse resizing of fullscreen windows
|
|
|
|
// 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
|
|
|
}
|
2011-06-24 10:19:47 +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
|
|
|
|
2013-07-26 11:56:16 +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);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 11:56:16 +00:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
|
|
|
|
restackWindow(e->sibling, e->stack_mode, NET::FromApplication, userTime(), false);
|
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
|
|
|
|
// the it should be optimized though (see also Client::setGeometry()/plainResize()/move()).
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles property changes of the client window
|
|
|
|
*/
|
2013-07-26 11:17:23 +00:00
|
|
|
void Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
Toplevel::propertyNotifyEvent(e);
|
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 14:34:42 +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();
|
2015-02-02 13:56:21 +00:00
|
|
|
} else if (e->atom == atoms->net_wm_sync_request_counter)
|
2011-01-30 14:34:42 +00:00
|
|
|
getSyncCounter();
|
|
|
|
else if (e->atom == atoms->activities)
|
|
|
|
checkActivities();
|
2011-12-01 12:15:11 +00:00
|
|
|
else if (e->atom == atoms->kde_first_in_window_list)
|
|
|
|
updateFirstInTabBox();
|
2013-10-14 05:17:07 +00:00
|
|
|
else if (e->atom == atoms->kde_color_sheme)
|
|
|
|
updateColorScheme();
|
2014-02-20 11:39:23 +00:00
|
|
|
else if (e->atom == atoms->kde_screen_edge_show)
|
|
|
|
updateShowOnScreenEdge();
|
2014-07-01 13:44:02 +00:00
|
|
|
else if (e->atom == atoms->gtk_frame_extents)
|
|
|
|
detectGtkFrameExtents();
|
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
|
|
|
|
|
|
|
|
2013-07-26 12:22:43 +00:00
|
|
|
void Client::enterNotifyEvent(xcb_enter_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 12:22:43 +00:00
|
|
|
if (e->event != frameId())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // care only about entering the whole frame
|
2012-03-17 14:34:32 +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)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-02-20 09:25:13 +00:00
|
|
|
if (options->isShadeHover()) {
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShade()) {
|
|
|
|
shadeHoverTimer = new QTimer(this);
|
|
|
|
connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeHover()));
|
|
|
|
shadeHoverTimer->setSingleShot(true);
|
2012-02-20 09:25:13 +00:00
|
|
|
shadeHoverTimer->start(options->shadeHoverInterval());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-03-17 14:34:32 +00:00
|
|
|
#undef MOUSE_DRIVEN_FOCUS
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2016-02-18 10:30:52 +00:00
|
|
|
enterEvent(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
|
|
|
|
2013-07-26 12:29:47 +00:00
|
|
|
void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 12:29:47 +00:00
|
|
|
if (e->event != frameId())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // care only about leaving the whole frame
|
2013-07-26 12:29:47 +00:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
|
2015-10-16 12:58:43 +00:00
|
|
|
if (!isMoveResizePointerButtonDown()) {
|
2015-10-16 11:10:55 +00:00
|
|
|
setMoveResizePointerMode(PositionCenter);
|
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) {
|
2016-02-18 12:00:50 +00:00
|
|
|
leaveEvent();
|
2008-12-15 08:27:17 +00:00
|
|
|
cancelShadeHoverTimer();
|
2015-10-16 12:58:43 +00:00
|
|
|
if (shade_mode == ShadeHover && !isMoveResize() && !isMoveResizePointerButtonDown()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
shadeHoverTimer = new QTimer(this);
|
|
|
|
connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeUnhover()));
|
|
|
|
shadeHoverTimer->setSingleShot(true);
|
2012-02-20 09:25:13 +00:00
|
|
|
shadeHoverTimer->start(options->shadeHoverInterval());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
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) {
|
2011-11-13 17:23:49 +00:00
|
|
|
workspace()->requestDelayFocus(0);
|
|
|
|
}
|
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
|
|
|
|
|
|
|
#define XCapL KKeyServer::modXLock()
|
|
|
|
#define XNumL KKeyServer::modXNumLock()
|
|
|
|
#define XScrL KKeyServer::modXScrollLock()
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::grabButton(int modifier)
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] = {
|
2007-04-29 17:35:43 +00:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
|
|
|
for (int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i)
|
2013-09-10 08:28:11 +00:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, modifier | mods[ i ]);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::ungrabButton(int modifier)
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] = {
|
2007-04-29 17:35:43 +00:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
|
|
|
for (int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i)
|
2013-09-10 08:03:37 +00:00
|
|
|
m_wrapper.ungrabButton(modifier | mods[ i ]);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
#undef XCapL
|
|
|
|
#undef XNumL
|
|
|
|
#undef XScrL
|
|
|
|
|
|
|
|
/*
|
|
|
|
Releases the passive grab for some modifier combinations when a
|
|
|
|
window becomes active. This helps broken X programs that
|
|
|
|
missinterpret LeaveNotify events in grab mode to work properly
|
|
|
|
(Motif, AWT, Tk, ...)
|
|
|
|
*/
|
|
|
|
void Client::updateMouseGrab()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (workspace()->globalShortcutsDisabled()) {
|
2013-09-10 08:03:37 +00:00
|
|
|
m_wrapper.ungrabButton();
|
2007-08-23 15:08:39 +00:00
|
|
|
// keep grab for the simple click without modifiers if needed (see below)
|
2012-11-16 07:23:47 +00:00
|
|
|
bool not_obscured = workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(), -1, true, false) == this;
|
2012-02-20 09:25:13 +00:00
|
|
|
if (!(!options->isClickRaise() || not_obscured))
|
2014-05-22 13:31:55 +00:00
|
|
|
grabButton(XCB_NONE);
|
2007-08-23 15:08:39 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2014-05-22 13:28:29 +00:00
|
|
|
if (isActive() && !TabBox::TabBox::self()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
|
2007-08-23 15:12:25 +00:00
|
|
|
// first grab all modifier combinations
|
2013-09-10 08:28:11 +00:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
2007-04-29 17:35:43 +00:00
|
|
|
// remove the grab for no modifiers only if the window
|
|
|
|
// is unobscured or if the user doesn't want click raise
|
2007-04-29 22:37:19 +00:00
|
|
|
// (it is unobscured if it the topmost in the unconstrained stacking order, i.e. it is
|
|
|
|
// the most recently raised window)
|
2012-11-16 07:23:47 +00:00
|
|
|
bool not_obscured = workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(), -1, true, false) == this;
|
2012-02-20 09:25:13 +00:00
|
|
|
if (!options->isClickRaise() || not_obscured)
|
2014-05-22 13:31:55 +00:00
|
|
|
ungrabButton(XCB_NONE);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2014-05-22 13:31:55 +00:00
|
|
|
grabButton(XCB_NONE);
|
|
|
|
ungrabButton(XCB_MOD_MASK_SHIFT);
|
|
|
|
ungrabButton(XCB_MOD_MASK_CONTROL);
|
|
|
|
ungrabButton(XCB_MOD_MASK_CONTROL | XCB_MOD_MASK_SHIFT);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2013-09-10 08:03:37 +00:00
|
|
|
m_wrapper.ungrabButton();
|
2007-04-29 17:35:43 +00:00
|
|
|
// simply grab all modifier combinations
|
2013-09-10 08:28:11 +00:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-05-18 20:38:04 +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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// return value matters only when filtering events before decoration gets them
|
2014-06-01 15:57:51 +00:00
|
|
|
bool Client::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
|
|
|
{
|
2015-10-16 12:58:43 +00:00
|
|
|
if (isMoveResizePointerButtonDown()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w == wrapperId())
|
2013-09-10 08:55:14 +00:00
|
|
|
xcb_allow_events(connection(), 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
|
|
|
}
|
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);
|
2007-04-29 17:35:43 +00:00
|
|
|
workspace()->setWasUserInteraction();
|
2012-05-18 20:38:04 +00:00
|
|
|
const bool bModKeyHeld = modKeyDown(state);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
|
|
|
if (isSplash()
|
2013-09-13 07:12:26 +00:00
|
|
|
&& button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// hide splashwindow if the user clicks on it
|
|
|
|
hideClient(true);
|
|
|
|
if (w == wrapperId())
|
2013-09-10 08:55:14 +00:00
|
|
|
xcb_allow_events(connection(), 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
|
|
|
}
|
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;
|
2011-01-30 14:34:42 +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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isSpecialWindow())
|
2007-04-29 17:35:43 +00:00
|
|
|
replay = true;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (w == wrapperId()) // these can come only from a grab
|
2013-09-10 08:55:14 +00:00
|
|
|
xcb_allow_events(connection(), replay ? XCB_ALLOW_REPLAY_POINTER : 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
|
|
|
}
|
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
|
2013-09-10 08:55:14 +00:00
|
|
|
xcb_allow_events(connection(), 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()) {
|
2014-07-22 11:11:19 +00:00
|
|
|
x = x_root - geometry().x();
|
|
|
|
y = y_root - geometry().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))
|
|
|
|
|| (button == 6 || button == 7));
|
|
|
|
|
|
|
|
const QPoint angle = hor ? QPoint(delta, 0) : QPoint(0, delta);
|
|
|
|
QWheelEvent event(QPointF(x, y),
|
|
|
|
QPointF(x_root, y_root),
|
|
|
|
QPoint(),
|
|
|
|
angle,
|
|
|
|
delta,
|
|
|
|
hor ? Qt::Horizontal : Qt::Vertical,
|
|
|
|
x11ToQtMouseButtons(state),
|
|
|
|
modifiers);
|
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),
|
|
|
|
x11ToQtMouseButton(button), x11ToQtMouseButtons(state), x11ToQtKeyboardModifiers(state));
|
|
|
|
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
|
2013-10-20 20:30:44 +00:00
|
|
|
bool Client::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
|
|
|
{
|
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()) {
|
2013-09-10 08:55:14 +00:00
|
|
|
xcb_allow_events(connection(), 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
|
|
|
}
|
2014-07-22 11:11:19 +00:00
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2015-09-22 12:44:25 +00:00
|
|
|
if (w == frameId() && workspace()->userActionsMenu() && workspace()->userActionsMenu()->isShown()) {
|
|
|
|
const_cast<UserActionsMenu*>(workspace()->userActionsMenu())->grabInput();
|
|
|
|
}
|
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;
|
|
|
|
if (button == XCB_BUTTON_INDEX_1)
|
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_1;
|
|
|
|
else if (button == XCB_BUTTON_INDEX_2)
|
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_2;
|
|
|
|
else if (button == XCB_BUTTON_INDEX_3)
|
|
|
|
buttonMask &= ~XCB_BUTTON_MASK_3;
|
|
|
|
|
|
|
|
if ((state & buttonMask) == 0) {
|
2015-10-28 09:43:49 +00:00
|
|
|
endMoveResize();
|
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
|
2013-05-03 08:32:18 +00:00
|
|
|
bool Client::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
|
|
|
{
|
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
|
|
|
}
|
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
|
2007-04-29 17:35:43 +00:00
|
|
|
return true; // care only about the whole frame
|
2015-10-16 12:58:43 +00:00
|
|
|
if (!isMoveResizePointerButtonDown()) {
|
2011-11-09 19:39:13 +00:00
|
|
|
if (w == inputId()) {
|
2014-07-22 11:11:19 +00:00
|
|
|
int x = x_root - geometry().x();// + padding_left;
|
|
|
|
int y = y_root - geometry().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
|
|
|
}
|
2015-06-04 17:26:35 +00:00
|
|
|
Position newmode = modKeyDown(state) ? PositionCenter : mousePosition();
|
2015-10-16 11:10:55 +00:00
|
|
|
if (newmode != moveResizePointerMode()) {
|
|
|
|
setMoveResizePointerMode(newmode);
|
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
|
|
|
|
2015-06-05 03:06:20 +00:00
|
|
|
handleMoveResize(QPoint(x, y), QPoint(x_root, y_root));
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-26 12:35:28 +00:00
|
|
|
void Client::focusInEvent(xcb_focus_in_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 12:35:28 +00:00
|
|
|
if (e->event != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // only window gets focus
|
2013-07-26 12:35:28 +00:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_UNGRAB)
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we don't care
|
2013-07-26 12:35:28 +00:00
|
|
|
if (e->detail == XCB_NOTIFY_DETAIL_POINTER)
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we don't care
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!isShown(false) || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile ->
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // activateNextClient() already transferred focus elsewhere
|
2013-08-05 07:48:14 +00:00
|
|
|
workspace()->forEachClient([](Client *client) {
|
|
|
|
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
|
2011-01-30 14:34:42 +00:00
|
|
|
bool activate = workspace()->allowClientActivation(this, -1U, true);
|
|
|
|
workspace()->gotFocusIn(this); // remove from should_get_focus list
|
|
|
|
if (activate)
|
|
|
|
setActive(true);
|
|
|
|
else {
|
2007-04-29 17:35:43 +00:00
|
|
|
workspace()->restoreFocus();
|
|
|
|
demandAttention();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-07-26 12:51:56 +00:00
|
|
|
void Client::focusOutEvent(xcb_focus_out_event_t *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-26 12:51:56 +00:00
|
|
|
if (e->event != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // only window gets focus
|
2013-07-26 12:51:56 +00:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_GRAB)
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // we don't care
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isShade())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // here neither
|
2013-07-26 12:51:56 +00:00
|
|
|
if (e->detail != XCB_NOTIFY_DETAIL_NONLINEAR
|
|
|
|
&& 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
|
2011-01-30 14:34:42 +00:00
|
|
|
if (QApplication::activePopupWidget())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
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
|
|
|
|
// client would be temporarily none (see Client::belongToLayer() ).
|
|
|
|
// 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);
|
|
|
|
connect(m_focusOutTimer, &QTimer::timeout, [this]() {
|
|
|
|
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
|
2011-01-30 14:34:42 +00:00
|
|
|
void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
|
|
|
|
{
|
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
|
|
|
|
Cursor::setPos(QPoint(x_root, y_root));
|
2011-01-30 14:34:42 +00:00
|
|
|
performMouseCommand(Options::MouseMove, QPoint(x_root, y_root));
|
2016-04-15 14:07:39 +00:00
|
|
|
} else if (isMoveResize() && direction == NET::MoveResizeCancel) {
|
2011-01-30 14:34:42 +00:00
|
|
|
finishMoveResize(true);
|
2015-10-16 12:58:43 +00:00
|
|
|
setMoveResizePointerButtonDown(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) {
|
|
|
|
static const Position convert[] = {
|
2007-04-29 17:35:43 +00:00
|
|
|
PositionTopLeft,
|
|
|
|
PositionTop,
|
|
|
|
PositionTopRight,
|
|
|
|
PositionRight,
|
|
|
|
PositionBottomRight,
|
|
|
|
PositionBottom,
|
|
|
|
PositionBottomLeft,
|
|
|
|
PositionLeft
|
2011-01-30 14:34:42 +00:00
|
|
|
};
|
|
|
|
if (!isResizable() || isShade())
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2015-10-16 07:08:02 +00:00
|
|
|
if (isMoveResize())
|
2011-01-30 14:34:42 +00:00
|
|
|
finishMoveResize(false);
|
2015-10-16 12:58:43 +00:00
|
|
|
setMoveResizePointerButtonDown(true);
|
2015-10-16 07:46:33 +00:00
|
|
|
setMoveOffset(QPoint(x_root - x(), y_root - y())); // map from global
|
|
|
|
setInvertedMoveOffset(rect().bottomRight() - moveOffset());
|
2015-10-16 07:23:46 +00:00
|
|
|
setUnrestrictedMoveResize(false);
|
2015-10-16 11:10:55 +00:00
|
|
|
setMoveResizePointerMode(convert[ direction ]);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!startMoveResize())
|
2015-10-16 12:58:43 +00:00
|
|
|
setMoveResizePointerButtonDown(false);
|
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
|
2013-02-26 07:45:44 +00:00
|
|
|
Cursor::setPos(geometry().center());
|
2011-01-30 14:34:42 +00:00
|
|
|
performMouseCommand(Options::MouseUnrestrictedMove, geometry().center());
|
|
|
|
} else if (direction == NET::KeyboardSize) {
|
|
|
|
// ignore mouse coordinates given in the message, mouse position is used by the resizing algorithm
|
2013-02-26 07:45:44 +00:00
|
|
|
Cursor::setPos(geometry().bottomRight());
|
2011-01-30 14:34:42 +00:00
|
|
|
performMouseCommand(Options::MouseUnrestrictedResize, geometry().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
|
|
|
|
2014-06-01 15:57:51 +00:00
|
|
|
void Client::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
|
|
|
|
2013-07-26 10:00:14 +00:00
|
|
|
void Client::syncEvent(xcb_sync_alarm_notify_event_t* e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-07-31 08:11:39 +00:00
|
|
|
if (e->alarm == syncRequest.alarm && e->counter_value.hi == syncRequest.value.hi && e->counter_value.lo == syncRequest.value.lo) {
|
2012-01-24 16:00:40 +00:00
|
|
|
setReadyForPainting();
|
2015-07-09 07:10:33 +00:00
|
|
|
setupWindowManagementInterface();
|
2011-08-13 14:39:58 +00:00
|
|
|
syncRequest.isPending = false;
|
|
|
|
if (syncRequest.failsafeTimeout)
|
|
|
|
syncRequest.failsafeTimeout->stop();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isResize()) {
|
2011-08-13 14:39:58 +00:00
|
|
|
if (syncRequest.timeout)
|
|
|
|
syncRequest.timeout->stop();
|
|
|
|
performMoveResize();
|
2012-01-24 16:00:40 +00:00
|
|
|
} else // setReadyForPainting does as well, but there's a small chance for resize syncs after the resize ended
|
2011-08-13 14:39:58 +00:00
|
|
|
addRepaintFull();
|
2007-06-25 08:51:44 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-06-25 08:51:44 +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
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
double old_opacity = opacity();
|
2014-03-17 09:22:20 +00:00
|
|
|
NET::Properties dirtyProperties;
|
|
|
|
NET::Properties2 dirtyProperties2;
|
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (compositing()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
addRepaintFull();
|
2011-03-06 09:30:23 +00:00
|
|
|
emit opacityChanged(this, old_opacity);
|
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)) {
|
|
|
|
emit windowRoleChanged();
|
|
|
|
}
|
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;
|
|
|
|
case XCB_UNMAP_NOTIFY:{
|
2015-01-28 23:14:47 +00:00
|
|
|
workspace()->updateFocusMousePosition(Cursor::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.
|
|
|
|
QTimer::singleShot(1, this, SLOT(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:
|
|
|
|
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:
|
|
|
|
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:
|
|
|
|
clientMessageEvent(reinterpret_cast<xcb_client_message_event_t*>(e));
|
|
|
|
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();
|
|
|
|
addWorkspaceRepaint(geometry()); // in case shape change removes part of this window
|
2011-06-19 20:07:19 +00:00
|
|
|
emit geometryShapeChanged(this, geometry());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-07-26 11:05:23 +00:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent())
|
2013-04-26 09:00:08 +00:00
|
|
|
damageNotifyEvent();
|
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
|
|
|
{
|
|
|
|
if (effects)
|
2007-04-29 17:35:43 +00:00
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking(); // keep them on top
|
2011-01-30 14:34:42 +00:00
|
|
|
QRect newgeom(e->x, e->y, e->width, e->height);
|
|
|
|
if (newgeom != geom) {
|
2011-04-04 16:50:30 +00:00
|
|
|
addWorkspaceRepaint(visibleRect()); // damage old area
|
2007-05-23 16:22:59 +00:00
|
|
|
QRect old = geom;
|
|
|
|
geom = newgeom;
|
2013-09-11 21:27:30 +00:00
|
|
|
emit geometryChanged(); // update shadow region
|
2008-10-01 12:49:52 +00:00
|
|
|
addRepaintFull();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (old.size() != geom.size())
|
2008-03-20 09:58:46 +00:00
|
|
|
discardWindowPixmap();
|
2011-06-19 20:07:19 +00:00
|
|
|
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
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 14:34:42 +00:00
|
|
|
switch(e->atom) {
|
|
|
|
default:
|
|
|
|
if (e->atom == atoms->wm_client_leader)
|
|
|
|
getWmClientLeader();
|
2011-03-27 10:33:07 +00:00
|
|
|
else if (e->atom == atoms->kde_net_wm_shadow)
|
|
|
|
getShadow();
|
2014-01-24 11:34:16 +00:00
|
|
|
else if (e->atom == atoms->kde_skip_close_animation)
|
|
|
|
getSkipCloseAnimation();
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-03-12 18:18:19 +00:00
|
|
|
emit propertyNotify(this, e->atom);
|
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) {
|
|
|
|
m_surfaceId = e->data.data32[0];
|
2015-04-02 07:49:39 +00:00
|
|
|
if (auto w = waylandServer()) {
|
2016-06-10 14:15:56 +00:00
|
|
|
if (auto s = KWayland::Server::SurfaceInterface::get(m_surfaceId, w->xWaylandConnection())) {
|
|
|
|
setSurface(s);
|
|
|
|
}
|
2015-04-02 07:49:39 +00:00
|
|
|
}
|
2015-01-09 10:16:57 +00:00
|
|
|
emit surfaceIdChanged(m_surfaceId);
|
|
|
|
}
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|