2007-11-27 22:40:25 +03:00
|
|
|
/********************************************************************
|
2007-04-29 21:35:43 +04: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 22:40:25 +03: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 21:35:43 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to handling incoming events.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "client.h"
|
2013-02-26 11:45:44 +04:00
|
|
|
#include "cursor.h"
|
2012-11-20 20:26:50 +04:00
|
|
|
#include "focuschain.h"
|
2013-04-26 12:41:24 +04:00
|
|
|
#include "netinfo.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "atoms.h"
|
2011-06-30 15:02:30 +04:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "tabbox.h"
|
2011-06-30 15:02:30 +04:00
|
|
|
#endif
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "group.h"
|
2011-07-06 13:58:23 +04:00
|
|
|
#include "overlaywindow.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "rules.h"
|
|
|
|
#include "unmanaged.h"
|
2012-08-19 14:00:53 +04:00
|
|
|
#include "useractions.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "effects.h"
|
2013-01-21 12:04:06 +04:00
|
|
|
#include "screenedge.h"
|
2013-04-03 14:19:27 +04:00
|
|
|
#include "screens.h"
|
2012-12-21 18:11:31 +04:00
|
|
|
#include "xcbutils.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2014-07-22 15:11:19 +04:00
|
|
|
#include <KDecoration2/Decoration>
|
|
|
|
|
2013-09-10 15:18:55 +04:00
|
|
|
#include <QApplication>
|
2013-09-02 15:14:39 +04:00
|
|
|
#include <QDebug>
|
2014-12-02 15:50:26 +03:00
|
|
|
#include <QHoverEvent>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QMouseEvent>
|
2014-11-28 16:50:21 +03:00
|
|
|
#include <QStyleHints>
|
2007-04-29 21:35:43 +04:00
|
|
|
#include <QWhatsThis>
|
2014-12-02 15:50:26 +03:00
|
|
|
#include <QWheelEvent>
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
#include <kkeyserver.h>
|
|
|
|
|
2013-07-26 14:00:14 +04:00
|
|
|
#include <xcb/sync.h>
|
2014-06-11 09:51:07 +04:00
|
|
|
#ifdef XCB_ICCCM_FOUND
|
2013-08-07 11:53:08 +04:00
|
|
|
#include <xcb/xcb_icccm.h>
|
2014-06-11 09:51:07 +04:00
|
|
|
#endif
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-08-21 23:50:23 +04:00
|
|
|
#include "composite.h"
|
2012-12-27 17:26:46 +04:00
|
|
|
#include "killwindow.h"
|
2014-09-02 20:46:07 +04:00
|
|
|
#include "x11eventfilter.h"
|
2011-08-21 23:50:23 +04:00
|
|
|
|
2015-04-02 10:49:39 +03:00
|
|
|
#include "wayland_server.h"
|
2015-02-09 18:08:53 +03:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
|
2014-09-19 12:04:00 +04: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 21:35:43 +04:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2010-11-27 18:27:54 +03:00
|
|
|
extern int currentRefreshRate();
|
2011-01-30 17:34:42 +03:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// ****************************************
|
|
|
|
// Workspace
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 18:19:05 +04: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 17:05:41 +04: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 20:46:07 +04: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 21:35:43 +04:00
|
|
|
/*!
|
2013-07-26 09:52:56 +04:00
|
|
|
Handles workspace specific XCB event
|
2007-04-29 21:35:43 +04:00
|
|
|
*/
|
2013-07-26 09:52:56 +04:00
|
|
|
bool Workspace::workspaceEvent(xcb_generic_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-26 10:01:16 +04:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
2014-04-07 17:05:41 +04: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 13:42:15 +03:00
|
|
|
qCWarning(KWIN_CORE, "XCB error: %d (%s), sequence: %d, resource id: %d, major code: %d (%s), minor code: %d (%s)",
|
2014-04-07 17:05:41 +04: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 20:46:07 +04: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) {
|
|
|
|
if (filter->extension() == ge->extension && filter->genericEventType() == ge->event_type && filter->event(e)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foreach (X11EventFilter *filter, m_eventFilters) {
|
|
|
|
if (filter->eventType() == eventType && filter->event(e)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()
|
2013-07-26 10:01:16 +04:00
|
|
|
&& (eventType == XCB_KEY_PRESS || eventType == XCB_KEY_RELEASE))
|
2007-04-29 21:35:43 +04:00
|
|
|
return false; // let Qt process it, it'll be intercepted again in eventFilter()
|
|
|
|
|
2013-07-26 10:02:54 +04:00
|
|
|
if (!m_windowKiller.isNull() && m_windowKiller->isActive() && m_windowKiller->isResponsibleForEvent(eventType)) {
|
2012-12-27 17:26:46 +04:00
|
|
|
m_windowKiller->processEvent(e);
|
|
|
|
// filter out the event
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-26 10:06:36 +04:00
|
|
|
if (eventType == XCB_PROPERTY_NOTIFY || eventType == XCB_CLIENT_MESSAGE) {
|
2014-03-17 13:22:20 +04:00
|
|
|
NET::Properties dirtyProtocols;
|
|
|
|
NET::Properties2 dirtyProtocols2;
|
|
|
|
rootInfo()->event(e, &dirtyProtocols, &dirtyProtocols2);
|
|
|
|
if (dirtyProtocols & NET::DesktopNames)
|
2012-11-16 11:23:47 +04:00
|
|
|
VirtualDesktopManager::self()->save();
|
2014-03-17 13:22:20 +04:00
|
|
|
if (dirtyProtocols2 & NET::WM2DesktopLayout)
|
2012-11-16 11:23:47 +04:00
|
|
|
VirtualDesktopManager::self()->updateLayout();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// events that should be handled before Clients can get them
|
2013-07-26 10:46:31 +04:00
|
|
|
switch (eventType) {
|
|
|
|
case XCB_BUTTON_PRESS:
|
|
|
|
case XCB_BUTTON_RELEASE: {
|
2011-01-30 17:34:42 +03:00
|
|
|
was_user_interaction = true;
|
2013-07-26 10:46:31 +04: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: {
|
|
|
|
auto *mouseEvent = reinterpret_cast<xcb_motion_notify_event_t*>(e);
|
|
|
|
const QPoint rootPos(mouseEvent->root_x, mouseEvent->root_y);
|
2011-06-30 15:02:30 +04:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 11:41:18 +04:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
2013-07-26 10:46:31 +04:00
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime()), true);
|
|
|
|
return TabBox::TabBox::self()->handleMouseEvent(mouseEvent);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-06-30 15:02:30 +04:00
|
|
|
#endif
|
2013-07-26 10:46:31 +04:00
|
|
|
if (effects && static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowEvent(mouseEvent)) {
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
2013-03-08 23:17:55 +04:00
|
|
|
}
|
|
|
|
if (QWidget::mouseGrabber()) {
|
2013-07-26 10:46:31 +04:00
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(xTime()), true);
|
2014-02-01 13:03:49 +04:00
|
|
|
} else {
|
|
|
|
ScreenEdges::self()->check(rootPos, QDateTime::fromMSecsSinceEpoch(mouseEvent->time));
|
2013-03-08 23:17:55 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 10:46:31 +04:00
|
|
|
}
|
2013-07-26 12:04:53 +04:00
|
|
|
case XCB_KEY_PRESS: {
|
2011-01-30 17:34:42 +03:00
|
|
|
was_user_interaction = true;
|
|
|
|
int keyQt;
|
2014-06-01 19:57:51 +04:00
|
|
|
xcb_key_press_event_t *event = reinterpret_cast<xcb_key_press_event_t*>(e);
|
|
|
|
KKeyServer::xcbKeyPressEventToQt(event, &keyQt);
|
2013-11-01 15:29:05 +04:00
|
|
|
// qDebug() << "Workspace::keyPress( " << keyQt << " )";
|
2015-03-06 14:38:07 +03:00
|
|
|
if (Client *c = dynamic_cast<Client*>(movingClient)) {
|
|
|
|
c->keyPressEvent(keyQt, event->time);
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 15:02:30 +04:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 11:41:18 +04:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
|
|
|
TabBox::TabBox::self()->keyPress(keyQt);
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 15:02:30 +04:00
|
|
|
#endif
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
|
|
|
}
|
2013-07-26 12:04:53 +04:00
|
|
|
case XCB_KEY_RELEASE:
|
2011-01-30 17:34:42 +03:00
|
|
|
was_user_interaction = true;
|
2011-06-30 15:02:30 +04:00
|
|
|
#ifdef KWIN_BUILD_TABBOX
|
2013-04-04 11:41:18 +04:00
|
|
|
if (TabBox::TabBox::self()->isGrabbed()) {
|
2013-07-26 12:04:53 +04:00
|
|
|
TabBox::TabBox::self()->keyRelease(reinterpret_cast<xcb_key_release_event_t*>(e));
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-30 15:02:30 +04:00
|
|
|
#endif
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 12:10:49 +04:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
|
|
|
if (reinterpret_cast<xcb_configure_notify_event_t*>(e)->event == rootWindow())
|
2011-01-30 17:34:42 +03:00
|
|
|
x_stacking_dirty = true;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
2013-07-26 18:19:05 +04:00
|
|
|
const xcb_window_t eventWindow = findEventWindow(e);
|
2013-08-30 15:34:29 +04:00
|
|
|
if (eventWindow != XCB_WINDOW_NONE) {
|
2014-03-20 12:19:53 +04:00
|
|
|
if (Client* c = findClient(Predicate::WindowMatch, eventWindow)) {
|
2013-08-30 15:34:29 +04:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 12:19:53 +04:00
|
|
|
} else if (Client* c = findClient(Predicate::WrapperIdMatch, eventWindow)) {
|
2013-08-30 15:34:29 +04:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 12:19:53 +04:00
|
|
|
} else if (Client* c = findClient(Predicate::FrameIdMatch, eventWindow)) {
|
2013-08-30 15:34:29 +04:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 12:19:53 +04:00
|
|
|
} else if (Client *c = findClient(Predicate::InputIdMatch, eventWindow)) {
|
2013-08-30 15:34:29 +04:00
|
|
|
if (c->windowEvent(e))
|
|
|
|
return true;
|
2014-03-20 10:52:18 +04:00
|
|
|
} else if (Unmanaged* c = findUnmanaged(eventWindow)) {
|
2013-08-30 15:34:29 +04: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 18:19:05 +04:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2015-03-06 14:38:07 +03:00
|
|
|
if (Client *c = dynamic_cast<Client*>(movingClient)) {
|
2014-07-22 15:11:19 +04:00
|
|
|
if (eventType == XCB_BUTTON_PRESS || eventType == XCB_BUTTON_RELEASE || eventType == XCB_MOTION_NOTIFY) {
|
2015-03-06 14:38:07 +03:00
|
|
|
if (c->moveResizeGrabWindow() == reinterpret_cast<xcb_button_press_event_t*>(e)->event && c->windowEvent(e)) {
|
2013-07-26 12:32:48 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 12:51:54 +04: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 17:34:42 +03:00
|
|
|
// see comments for allowClientActivation()
|
2014-11-28 01:24:05 +03:00
|
|
|
updateXTime();
|
2013-07-26 12:51:54 +04: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 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
break;
|
2013-07-26 12:51:54 +04:00
|
|
|
}
|
2013-07-26 12:56:43 +04: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 17:34:42 +03:00
|
|
|
}
|
2013-07-26 12:56:43 +04:00
|
|
|
case XCB_REPARENT_NOTIFY: {
|
2007-04-29 21:35:43 +04:00
|
|
|
//do not confuse Qt with these events. After all, _we_ are the
|
|
|
|
//window manager who does the reparenting.
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
2013-07-26 12:56:43 +04:00
|
|
|
case XCB_DESTROY_NOTIFY: {
|
2011-01-30 17:34:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
2013-07-26 13:02:44 +04:00
|
|
|
case XCB_MAP_REQUEST: {
|
2011-01-30 17:34:42 +03:00
|
|
|
updateXTime();
|
|
|
|
|
2013-07-26 13:02:44 +04:00
|
|
|
const auto *event = reinterpret_cast<xcb_map_request_event_t*>(e);
|
2014-03-20 12:19:53 +04:00
|
|
|
if (Client* c = findClient(Predicate::WindowMatch, event->window)) {
|
2012-02-04 02:31:13 +04:00
|
|
|
// e->xmaprequest.window is different from e->xany.window
|
|
|
|
// TODO this shouldn't be necessary now
|
2011-01-30 17:34:42 +03:00
|
|
|
c->windowEvent(e);
|
2012-11-20 20:26:50 +04:00
|
|
|
FocusChain::self()->update(c, FocusChain::Update);
|
2012-02-04 02:31:13 +04: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 13:02:44 +04: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 17:34:42 +03:00
|
|
|
}
|
2012-02-04 02:31:13 +04:00
|
|
|
return true;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2013-07-26 13:16:50 +04:00
|
|
|
case XCB_MAP_NOTIFY: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_map_notify_event_t*>(e);
|
|
|
|
if (event->override_redirect) {
|
2014-03-20 10:52:18 +04:00
|
|
|
Unmanaged* c = findUnmanaged(event->window);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (c == NULL)
|
2013-07-26 13:16:50 +04:00
|
|
|
c = createUnmanaged(event->window);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (c)
|
|
|
|
return c->windowEvent(e);
|
|
|
|
}
|
2013-07-26 13:16:50 +04:00
|
|
|
return (event->event != event->window); // hide wm typical event from Qt
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 13:24:19 +04:00
|
|
|
case XCB_ENTER_NOTIFY: {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (QWhatsThis::inWhatsThisMode()) {
|
2013-07-26 13:24:19 +04:00
|
|
|
QWidget* w = QWidget::find(reinterpret_cast<xcb_enter_notify_event_t*>(e)->event);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (w)
|
2007-04-29 21:35:43 +04:00
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2013-08-01 13:36:38 +04:00
|
|
|
if (ScreenEdges::self()->isEntered(reinterpret_cast<xcb_enter_notify_event_t*>(e)))
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 13:24:19 +04:00
|
|
|
case XCB_LEAVE_NOTIFY: {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!QWhatsThis::inWhatsThisMode())
|
2007-04-29 21:35:43 +04:00
|
|
|
break;
|
2011-01-30 17:34:42 +03:00
|
|
|
// TODO is this cliente ever found, given that client events are searched above?
|
2013-07-26 13:24:19 +04:00
|
|
|
const auto *event = reinterpret_cast<xcb_leave_notify_event_t*>(e);
|
2014-03-20 12:19:53 +04:00
|
|
|
Client* c = findClient(Predicate::FrameIdMatch, event->event);
|
2013-07-26 13:24:19 +04:00
|
|
|
if (c && event->detail != XCB_NOTIFY_DETAIL_INFERIOR)
|
2011-01-30 17:34:42 +03:00
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 13:31:24 +04:00
|
|
|
case XCB_CONFIGURE_REQUEST: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_configure_request_event_t*>(e);
|
|
|
|
if (event->parent == rootWindow()) {
|
2014-04-25 16:42:20 +04: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 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2013-07-26 13:37:57 +04:00
|
|
|
case XCB_FOCUS_IN: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_focus_in_event_t*>(e);
|
|
|
|
if (event->event == rootWindow()
|
|
|
|
&& (event->detail == XCB_NOTIFY_DETAIL_NONE || event->detail == XCB_NOTIFY_DETAIL_POINTER_ROOT)) {
|
2013-09-10 13:37:40 +04:00
|
|
|
Xcb::CurrentInput currentInput;
|
2011-01-30 17:34:42 +03:00
|
|
|
updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp)
|
2013-09-13 11:11:10 +04:00
|
|
|
if (!currentInput.isNull() && (currentInput->focus == XCB_WINDOW_NONE || currentInput->focus == XCB_INPUT_FOCUS_POINTER_ROOT)) {
|
2011-01-30 17:34:42 +03:00
|
|
|
//kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" ;
|
2015-03-12 13:56:55 +03:00
|
|
|
AbstractClient *c = mostRecentlyActivatedClient();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (c != NULL)
|
|
|
|
requestFocus(c, true);
|
|
|
|
else if (activateNextClient(NULL))
|
|
|
|
; // ok, activated
|
|
|
|
else
|
|
|
|
focusToNull();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2013-07-26 13:37:57 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
// fall through
|
2013-07-26 13:37:57 +04:00
|
|
|
case XCB_FOCUS_OUT:
|
2011-01-30 17:34:42 +03:00
|
|
|
return true; // always eat these, they would tell Qt that KWin is the active app
|
2013-07-26 13:41:44 +04:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
2013-08-01 13:36:38 +04:00
|
|
|
if (ScreenEdges::self()->isEntered(reinterpret_cast<xcb_client_message_event_t*>(e)))
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
break;
|
2013-07-26 13:44:00 +04:00
|
|
|
case XCB_EXPOSE: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_expose_event_t*>(e);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (compositing()
|
2013-07-26 13:44:00 +04: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 17:34:42 +03:00
|
|
|
}
|
|
|
|
break;
|
2013-07-26 13:44:00 +04:00
|
|
|
}
|
2013-07-26 13:46:00 +04: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 23:19:54 +04:00
|
|
|
bool was_visible = m_compositor->isOverlayWindowVisible();
|
2013-07-26 13:46:00 +04:00
|
|
|
m_compositor->setOverlayWindowVisibility((event->state != XCB_VISIBILITY_FULLY_OBSCURED));
|
2012-08-16 23:19:54 +04:00
|
|
|
if (!was_visible && m_compositor->isOverlayWindowVisible()) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// hack for #154825
|
2012-08-28 21:43:33 +04:00
|
|
|
m_compositor->addRepaintFull();
|
|
|
|
QTimer::singleShot(2000, m_compositor, SLOT(addRepaintFull()));
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2012-08-28 21:43:33 +04:00
|
|
|
m_compositor->scheduleRepaint();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
break;
|
2013-07-26 13:46:00 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
default:
|
2013-07-26 14:00:14 +04:00
|
|
|
if (eventType == Xcb::Extensions::self()->randrNotifyEvent() && Xcb::Extensions::self()->isRandrAvailable()) {
|
2013-08-30 16:30:14 +04: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 21:43:33 +04:00
|
|
|
if (compositing()) {
|
2011-01-30 17:34:42 +03: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 23:50:23 +04:00
|
|
|
if (m_compositor->xrrRefreshRate() != currentRefreshRate())
|
|
|
|
m_compositor->setCompositeResetTimer(0);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2010-11-27 18:27:54 +03:00
|
|
|
|
2013-07-26 14:00:14 +04: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 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 12:51:54 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 21:35:43 +04: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 17:34:42 +03: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 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Client
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
/*!
|
|
|
|
General handler for XEvents concerning the client window
|
|
|
|
*/
|
2013-07-26 12:32:48 +04:00
|
|
|
bool Client::windowEvent(xcb_generic_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-08-02 15:53:21 +04:00
|
|
|
if (findEventWindow(e) == window()) { // avoid doing stuff on frame or wrapper
|
2014-03-17 13:22:20 +04:00
|
|
|
NET::Properties dirtyProperties;
|
|
|
|
NET::Properties2 dirtyProperties2;
|
2007-04-29 21:35:43 +04:00
|
|
|
double old_opacity = opacity();
|
2014-03-17 13:22:20 +04:00
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2014-03-17 13:22:20 +04:00
|
|
|
if ((dirtyProperties & NET::WMName) != 0)
|
2007-04-29 21:35:43 +04:00
|
|
|
fetchName();
|
2014-03-17 13:22:20 +04:00
|
|
|
if ((dirtyProperties & NET::WMIconName) != 0)
|
2007-04-29 21:35:43 +04:00
|
|
|
fetchIconicName();
|
2014-03-17 13:22:20 +04:00
|
|
|
if ((dirtyProperties & NET::WMStrut) != 0
|
|
|
|
|| (dirtyProperties2 & NET::WM2ExtendedStrut) != 0) {
|
2007-04-29 21:35:43 +04:00
|
|
|
workspace()->updateClientArea();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2014-03-17 13:22:20 +04:00
|
|
|
if ((dirtyProperties & NET::WMIcon) != 0)
|
2007-04-29 21:35:43 +04: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 13:22:20 +04:00
|
|
|
if ((dirtyProperties2 & NET::WM2UserTime) != 0) {
|
2007-04-29 21:35:43 +04:00
|
|
|
workspace()->setWasUserInteraction();
|
2011-01-30 17:34:42 +03:00
|
|
|
updateUserTime(info->userTime());
|
|
|
|
}
|
2014-03-17 13:22:20 +04:00
|
|
|
if ((dirtyProperties2 & NET::WM2StartupId) != 0)
|
2007-04-29 21:35:43 +04:00
|
|
|
startupIdChanged();
|
2014-03-17 13:22:20 +04:00
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (compositing()) {
|
2007-04-29 21:35:43 +04:00
|
|
|
addRepaintFull();
|
2011-03-06 12:30:23 +03:00
|
|
|
emit opacityChanged(this, old_opacity);
|
2011-01-30 17:34:42 +03:00
|
|
|
} else {
|
|
|
|
// forward to the frame if there's possibly another compositing manager running
|
2014-03-17 13:22:20 +04:00
|
|
|
NETWinInfo i(connection(), frameId(), rootWindow(), 0, 0);
|
2011-01-30 17:34:42 +03:00
|
|
|
i.setOpacity(info->opacity());
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2014-03-17 13:22:20 +04:00
|
|
|
if (dirtyProperties2 & NET::WM2FrameOverlap) {
|
2009-11-26 02:32:35 +03:00
|
|
|
// ### Inform the decoration
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2014-04-10 13:12:48 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
|
|
|
emit windowRoleChanged();
|
|
|
|
}
|
2014-04-11 10:06:26 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
|
|
|
getResourceClass();
|
|
|
|
}
|
2014-04-14 17:32:45 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2BlockCompositing)) {
|
|
|
|
setBlockingCompositing(info->isBlockingCompositing());
|
|
|
|
}
|
2014-09-12 15:56:34 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2GroupLeader)) {
|
|
|
|
checkGroup();
|
|
|
|
updateAllowedActions(); // Group affects isMinimizable()
|
|
|
|
}
|
|
|
|
if (dirtyProperties2.testFlag(NET::WM2Urgency)) {
|
|
|
|
updateUrgency();
|
|
|
|
}
|
2015-01-22 17:46:12 +03:00
|
|
|
if (dirtyProperties2 & NET::WM2OpaqueRegion) {
|
|
|
|
getWmOpaqueRegion();
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 15:17:23 +04:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
|
|
|
switch(eventType) {
|
2013-07-26 15:34:54 +04:00
|
|
|
case XCB_UNMAP_NOTIFY:
|
|
|
|
unmapNotifyEvent(reinterpret_cast<xcb_unmap_notify_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 15:40:43 +04:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
destroyNotifyEvent(reinterpret_cast<xcb_destroy_notify_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 15:46:06 +04:00
|
|
|
case XCB_MAP_REQUEST:
|
2011-01-30 17:34:42 +03:00
|
|
|
// this one may pass the event to workspace
|
2013-07-26 15:46:06 +04:00
|
|
|
return mapRequestEvent(reinterpret_cast<xcb_map_request_event_t*>(e));
|
2013-07-26 15:56:16 +04:00
|
|
|
case XCB_CONFIGURE_REQUEST:
|
|
|
|
configureRequestEvent(reinterpret_cast<xcb_configure_request_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
|
|
|
propertyNotifyEvent(reinterpret_cast<xcb_property_notify_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:03:14 +04:00
|
|
|
case XCB_KEY_PRESS:
|
2014-06-01 19:57:51 +04:00
|
|
|
updateUserTime(reinterpret_cast<xcb_key_press_event_t*>(e)->time);
|
2011-01-30 17:34:42 +03:00
|
|
|
workspace()->setWasUserInteraction();
|
|
|
|
break;
|
2013-07-26 16:03:14 +04:00
|
|
|
case XCB_BUTTON_PRESS: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_button_press_event_t*>(e);
|
2014-06-01 19:57:51 +04:00
|
|
|
updateUserTime(event->time);
|
2011-01-30 17:34:42 +03:00
|
|
|
workspace()->setWasUserInteraction();
|
2013-07-26 16:03:14 +04:00
|
|
|
buttonPressEvent(event->event, event->detail, event->state,
|
2014-06-01 19:57:51 +04:00
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y, event->time);
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:03:14 +04:00
|
|
|
}
|
|
|
|
case XCB_KEY_RELEASE:
|
2011-01-30 17:34:42 +03: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 16:03:14 +04:00
|
|
|
case XCB_BUTTON_RELEASE: {
|
|
|
|
const auto *event = reinterpret_cast<xcb_button_release_event_t*>(e);
|
2011-01-30 17:34:42 +03: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 16:03:14 +04:00
|
|
|
buttonReleaseEvent(event->event, event->detail, event->state,
|
|
|
|
event->event_x, event->event_y, event->root_x, event->root_y);
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:03:14 +04: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 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:03:14 +04:00
|
|
|
}
|
2013-07-26 16:22:43 +04:00
|
|
|
case XCB_ENTER_NOTIFY: {
|
|
|
|
auto *event = reinterpret_cast<xcb_enter_notify_event_t*>(e);
|
|
|
|
enterNotifyEvent(event);
|
2011-01-30 17:34:42 +03: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 16:22:43 +04: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 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:22:43 +04:00
|
|
|
}
|
2013-07-26 16:29:47 +04: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 17:34:42 +03: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 16:29:47 +04:00
|
|
|
}
|
2013-07-26 16:35:28 +04:00
|
|
|
case XCB_FOCUS_IN:
|
|
|
|
focusInEvent(reinterpret_cast<xcb_focus_in_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 16:51:56 +04:00
|
|
|
case XCB_FOCUS_OUT:
|
|
|
|
focusOutEvent(reinterpret_cast<xcb_focus_out_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 17:02:59 +04:00
|
|
|
case XCB_REPARENT_NOTIFY:
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 17:02:59 +04:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
|
|
|
clientMessageEvent(reinterpret_cast<xcb_client_message_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2014-07-22 15:11:19 +04: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 17:34:42 +03:00
|
|
|
default:
|
2013-07-26 17:05:55 +04: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 21:35:43 +04:00
|
|
|
}
|
2013-07-26 17:05:55 +04:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent() && reinterpret_cast<xcb_damage_notify_event_t*>(e)->drawable == frameId())
|
|
|
|
damageNotifyEvent();
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return true; // eat all events
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles map requests of the client window
|
|
|
|
*/
|
2013-07-26 15:46:06 +04:00
|
|
|
bool Client::mapRequestEvent(xcb_map_request_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (e->window != window()) {
|
2007-04-29 21:35:43 +04: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 04:12:28 +03:00
|
|
|
// e.g. using XEMBED, and the embedder suddenly loses its X connection,
|
2007-04-29 21:35:43 +04: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 17:34:42 +03:00
|
|
|
if (e->parent == wrapperId())
|
2007-04-29 21:35:43 +04:00
|
|
|
return false;
|
|
|
|
return true; // no messing with frame etc.
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2008-08-12 15:02:58 +04:00
|
|
|
// also copied in clientMessage()
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isMinimized())
|
2008-08-12 15:02:58 +04:00
|
|
|
unminimize();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isShade())
|
|
|
|
setShade(ShadeNone);
|
|
|
|
if (!isOnCurrentDesktop()) {
|
|
|
|
if (workspace()->allowClientActivation(this))
|
|
|
|
workspace()->activateClient(this);
|
2008-08-12 15:02:58 +04:00
|
|
|
else
|
|
|
|
demandAttention();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles unmap notify events of the client window
|
|
|
|
*/
|
2013-07-26 15:34:54 +04:00
|
|
|
void Client::unmapNotifyEvent(xcb_unmap_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
if (e->event != wrapperId()) {
|
|
|
|
// most probably event from root window when initially reparenting
|
2007-04-29 21:35:43 +04:00
|
|
|
bool ignore = true;
|
2013-08-02 12:24:20 +04:00
|
|
|
if (e->event == rootWindow() && (e->response_type & 0x80))
|
2007-04-29 21:35:43 +04:00
|
|
|
ignore = false; // XWithdrawWindow()
|
2011-01-30 17:34:42 +03:00
|
|
|
if (ignore)
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-03-05 21:04:30 +04: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 20:43:49 +04:00
|
|
|
Xcb::Tree tree(m_client);
|
2013-03-05 21:04:30 +04:00
|
|
|
xcb_window_t daddy = tree.parent();
|
2013-05-02 20:26:05 +04:00
|
|
|
if (daddy == m_wrapper) {
|
2013-03-05 21:04:30 +04:00
|
|
|
releaseWindow(); // unmapped from a regular client state
|
|
|
|
} else {
|
|
|
|
destroyClient(); // the client was moved to some other parent
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 15:40:43 +04:00
|
|
|
void Client::destroyNotifyEvent(xcb_destroy_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
|
|
|
destroyClient();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
/*!
|
|
|
|
Handles client messages for the client window
|
|
|
|
*/
|
2013-07-26 17:02:59 +04:00
|
|
|
void Client::clientMessageEvent(xcb_client_message_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2015-01-09 13:16:57 +03:00
|
|
|
Toplevel::clientMessageEvent(e);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // ignore frame/wrapper
|
|
|
|
// WM_STATE
|
2014-05-20 17:58:15 +04:00
|
|
|
if (e->type == atoms->wm_change_state) {
|
2013-07-26 17:02:59 +04:00
|
|
|
if (e->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)
|
2007-04-29 21:35:43 +04:00
|
|
|
minimize();
|
|
|
|
return;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles configure requests of the client window
|
|
|
|
*/
|
2013-07-26 15:56:16 +04:00
|
|
|
void Client::configureRequestEvent(xcb_configure_request_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isResize() || isMove())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // we have better things to do right now
|
|
|
|
|
2011-01-30 17:34:42 +03: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 21:35:43 +04:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2011-06-24 14:19:47 +04:00
|
|
|
if (isSplash()) { // no manipulations with splashscreens either
|
2007-04-29 21:35:43 +04:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 15:56:16 +04:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
|
2007-04-29 21:35:43 +04:00
|
|
|
// first, get rid of a window border
|
2013-09-10 11:51:31 +04:00
|
|
|
m_client.setBorderWidth(0);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 15:56:16 +04:00
|
|
|
if (e->value_mask & (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_WIDTH))
|
2011-01-30 17:34:42 +03:00
|
|
|
configureRequest(e->value_mask, e->x, e->y, e->width, e->height, 0, false);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 15:56:16 +04:00
|
|
|
if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE)
|
|
|
|
restackWindow(e->sibling, e->stack_mode, NET::FromApplication, userTime(), false);
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2007-07-19 20:38:46 +04:00
|
|
|
// Sending a synthetic configure notify always is fine, even in cases where
|
2007-04-29 21:35:43 +04: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 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles property changes of the client window
|
|
|
|
*/
|
2013-07-26 15:17:23 +04:00
|
|
|
void Client::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
Toplevel::propertyNotifyEvent(e);
|
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 17:34:42 +03:00
|
|
|
switch(e->atom) {
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_ATOM_WM_NORMAL_HINTS:
|
2011-01-30 17:34:42 +03:00
|
|
|
getWmNormalHints();
|
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_ATOM_WM_NAME:
|
2011-01-30 17:34:42 +03:00
|
|
|
fetchName();
|
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_ATOM_WM_ICON_NAME:
|
2011-01-30 17:34:42 +03:00
|
|
|
fetchIconicName();
|
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_ATOM_WM_TRANSIENT_FOR:
|
2011-01-30 17:34:42 +03:00
|
|
|
readTransient();
|
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_ATOM_WM_HINTS:
|
2011-01-30 17:34:42 +03:00
|
|
|
getIcons(); // because KWin::icon() uses WMHints as fallback
|
|
|
|
break;
|
|
|
|
default:
|
2015-02-02 16:56:21 +03:00
|
|
|
if (e->atom == atoms->motif_wm_hints) {
|
2011-01-30 17:34:42 +03:00
|
|
|
getMotifHints();
|
2015-02-02 16:56:21 +03:00
|
|
|
} else if (e->atom == atoms->net_wm_sync_request_counter)
|
2011-01-30 17:34:42 +03:00
|
|
|
getSyncCounter();
|
|
|
|
else if (e->atom == atoms->activities)
|
|
|
|
checkActivities();
|
2011-12-01 16:15:11 +04:00
|
|
|
else if (e->atom == atoms->kde_first_in_window_list)
|
|
|
|
updateFirstInTabBox();
|
2013-10-14 09:17:07 +04:00
|
|
|
else if (e->atom == atoms->kde_color_sheme)
|
|
|
|
updateColorScheme();
|
2014-02-20 15:39:23 +04:00
|
|
|
else if (e->atom == atoms->kde_screen_edge_show)
|
|
|
|
updateShowOnScreenEdge();
|
2014-07-01 17:44:02 +04:00
|
|
|
else if (e->atom == atoms->gtk_frame_extents)
|
|
|
|
detectGtkFrameExtents();
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
2013-07-26 16:22:43 +04:00
|
|
|
void Client::enterNotifyEvent(xcb_enter_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-26 16:22:43 +04:00
|
|
|
if (e->event != frameId())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // care only about entering the whole frame
|
2012-03-17 18:34:32 +04:00
|
|
|
|
|
|
|
#define MOUSE_DRIVEN_FOCUS (!options->focusPolicyIsReasonable() || \
|
|
|
|
(options->focusPolicy() == Options::FocusFollowsMouse && options->isNextFocusPrefersMouse()))
|
2013-07-26 16:22:43 +04:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_NORMAL || (e->mode == XCB_NOTIFY_MODE_UNGRAB && MOUSE_DRIVEN_FOCUS)) {
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-02-20 13:25:13 +04:00
|
|
|
if (options->isShadeHover()) {
|
2008-12-15 11:27:17 +03:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isShade()) {
|
|
|
|
shadeHoverTimer = new QTimer(this);
|
|
|
|
connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeHover()));
|
|
|
|
shadeHoverTimer->setSingleShot(true);
|
2012-02-20 13:25:13 +04:00
|
|
|
shadeHoverTimer->start(options->shadeHoverInterval());
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2012-03-17 18:34:32 +04:00
|
|
|
#undef MOUSE_DRIVEN_FOCUS
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-08-19 14:00:53 +04:00
|
|
|
if (options->focusPolicy() == Options::ClickToFocus || workspace()->userActionsMenu()->isShown())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
|
|
|
|
2013-07-26 16:22:43 +04:00
|
|
|
QPoint currentPos(e->root_x, e->root_y);
|
2012-02-20 13:25:13 +04:00
|
|
|
if (options->isAutoRaise() && !isDesktop() &&
|
2011-06-24 14:19:47 +04:00
|
|
|
!isDock() && workspace()->focusChangeEnabled() &&
|
2012-09-05 01:36:39 +04:00
|
|
|
currentPos != workspace()->focusMousePosition() &&
|
2012-11-16 11:23:47 +04:00
|
|
|
workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(),
|
2012-02-20 13:25:13 +04:00
|
|
|
options->isSeparateScreenFocus() ? screen() : -1) != this) {
|
2015-03-13 12:26:10 +03:00
|
|
|
startAutoRaise();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-11-13 21:23:49 +04:00
|
|
|
if (isDesktop() || isDock())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2007-08-24 13:46:56 +04:00
|
|
|
// for FocusFollowsMouse, change focus only if the mouse has actually been moved, not if the focus
|
|
|
|
// change came because of window changes (e.g. closing a window) - #92290
|
2012-02-20 13:25:13 +04:00
|
|
|
if (options->focusPolicy() != Options::FocusFollowsMouse
|
2011-01-30 17:34:42 +03:00
|
|
|
|| currentPos != workspace()->focusMousePosition()) {
|
|
|
|
workspace()->requestDelayFocus(this);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 16:29:47 +04:00
|
|
|
void Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-26 16:29:47 +04:00
|
|
|
if (e->event != frameId())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // care only about leaving the whole frame
|
2013-07-26 16:29:47 +04:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_NORMAL) {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!buttonDown) {
|
2007-04-29 21:35:43 +04:00
|
|
|
mode = PositionCenter;
|
2007-05-22 19:46:42 +04:00
|
|
|
updateCursor();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2013-07-26 16:29:47 +04:00
|
|
|
bool lostMouse = !rect().contains(QPoint(e->event_x, e->event_y));
|
2007-04-29 21:35:43 +04: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 16:29:47 +04:00
|
|
|
if (!lostMouse && e->detail != XCB_NOTIFY_DETAIL_INFERIOR) {
|
2014-04-25 13:18:49 +04:00
|
|
|
Xcb::Pointer pointer(frameId());
|
|
|
|
if (!pointer || !pointer->same_screen || pointer->child == XCB_WINDOW_NONE) {
|
|
|
|
// really lost the mouse
|
|
|
|
lostMouse = true;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
if (lostMouse) {
|
2007-04-29 21:35:43 +04:00
|
|
|
cancelAutoRaise();
|
|
|
|
workspace()->cancelDelayFocus();
|
2008-12-15 11:27:17 +03:00
|
|
|
cancelShadeHoverTimer();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (shade_mode == ShadeHover && !moveResizeMode && !buttonDown) {
|
|
|
|
shadeHoverTimer = new QTimer(this);
|
|
|
|
connect(shadeHoverTimer, SIGNAL(timeout()), this, SLOT(shadeUnhover()));
|
|
|
|
shadeHoverTimer->setSingleShot(true);
|
2012-02-20 13:25:13 +04:00
|
|
|
shadeHoverTimer->start(options->shadeHoverInterval());
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2015-08-31 11:28:03 +03:00
|
|
|
if (m_decoration) {
|
|
|
|
// 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);
|
|
|
|
QCoreApplication::sendEvent(m_decoration, &leaveEvent);
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2012-02-20 13:25:13 +04:00
|
|
|
if (options->focusPolicy() == Options::FocusStrictlyUnderMouse && isActive() && lostMouse) {
|
2011-11-13 21:23:49 +04:00
|
|
|
workspace()->requestDelayFocus(0);
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
#define XCapL KKeyServer::modXLock()
|
|
|
|
#define XNumL KKeyServer::modXNumLock()
|
|
|
|
#define XScrL KKeyServer::modXScrollLock()
|
2011-01-30 17:34:42 +03:00
|
|
|
void Client::grabButton(int modifier)
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] = {
|
2007-04-29 21:35:43 +04:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
2011-01-30 17:34:42 +03:00
|
|
|
};
|
|
|
|
for (int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i)
|
2013-09-10 12:28:11 +04:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, modifier | mods[ i ]);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void Client::ungrabButton(int modifier)
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] = {
|
2007-04-29 21:35:43 +04:00
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
2011-01-30 17:34:42 +03:00
|
|
|
};
|
|
|
|
for (int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i)
|
2013-09-10 12:03:37 +04:00
|
|
|
m_wrapper.ungrabButton(modifier | mods[ i ]);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04: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 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (workspace()->globalShortcutsDisabled()) {
|
2013-09-10 12:03:37 +04:00
|
|
|
m_wrapper.ungrabButton();
|
2007-08-23 19:08:39 +04:00
|
|
|
// keep grab for the simple click without modifiers if needed (see below)
|
2012-11-16 11:23:47 +04:00
|
|
|
bool not_obscured = workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(), -1, true, false) == this;
|
2012-02-20 13:25:13 +04:00
|
|
|
if (!(!options->isClickRaise() || not_obscured))
|
2014-05-22 17:31:55 +04:00
|
|
|
grabButton(XCB_NONE);
|
2007-08-23 19:08:39 +04:00
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2014-05-22 17:28:29 +04:00
|
|
|
if (isActive() && !TabBox::TabBox::self()->forcedGlobalMouseGrab()) { // see TabBox::establishTabBoxGrab()
|
2007-08-23 19:12:25 +04:00
|
|
|
// first grab all modifier combinations
|
2013-09-10 12:28:11 +04:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
2007-04-29 21:35:43 +04:00
|
|
|
// remove the grab for no modifiers only if the window
|
|
|
|
// is unobscured or if the user doesn't want click raise
|
2007-04-30 02:37:19 +04: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 11:23:47 +04:00
|
|
|
bool not_obscured = workspace()->topClientOnDesktop(VirtualDesktopManager::self()->current(), -1, true, false) == this;
|
2012-02-20 13:25:13 +04:00
|
|
|
if (!options->isClickRaise() || not_obscured)
|
2014-05-22 17:31:55 +04:00
|
|
|
ungrabButton(XCB_NONE);
|
2007-04-29 21:35:43 +04:00
|
|
|
else
|
2014-05-22 17:31:55 +04: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 17:34:42 +03:00
|
|
|
} else {
|
2013-09-10 12:03:37 +04:00
|
|
|
m_wrapper.ungrabButton();
|
2007-04-29 21:35:43 +04:00
|
|
|
// simply grab all modifier combinations
|
2013-09-10 12:28:11 +04:00
|
|
|
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-05-19 00:38:04 +04: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 21:35:43 +04:00
|
|
|
// return value matters only when filtering events before decoration gets them
|
2014-06-01 19:57:51 +04: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 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (buttonDown) {
|
|
|
|
if (w == wrapperId())
|
2013-09-10 12:55:14 +04:00
|
|
|
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2014-07-22 15:11:19 +04:00
|
|
|
if (w == wrapperId() || w == frameId() || w == inputId()) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// FRAME neco s tohohle by se melo zpracovat, nez to dostane dekorace
|
2014-06-01 19:57:51 +04:00
|
|
|
updateUserTime(time);
|
2007-04-29 21:35:43 +04:00
|
|
|
workspace()->setWasUserInteraction();
|
2012-05-19 00:38:04 +04:00
|
|
|
const bool bModKeyHeld = modKeyDown(state);
|
2011-01-30 17:34:42 +03:00
|
|
|
|
|
|
|
if (isSplash()
|
2013-09-13 11:12:26 +04:00
|
|
|
&& button == XCB_BUTTON_INDEX_1 && !bModKeyHeld) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// hide splashwindow if the user clicks on it
|
|
|
|
hideClient(true);
|
|
|
|
if (w == wrapperId())
|
2013-09-10 12:55:14 +04:00
|
|
|
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
bool was_action = false;
|
2011-01-30 17:34:42 +03:00
|
|
|
if (bModKeyHeld) {
|
2007-04-29 21:35:43 +04:00
|
|
|
was_action = true;
|
2011-01-30 17:34:42 +03:00
|
|
|
switch(button) {
|
2013-09-13 11:12:26 +04:00
|
|
|
case XCB_BUTTON_INDEX_1:
|
2011-01-30 17:34:42 +03:00
|
|
|
com = options->commandAll1();
|
|
|
|
break;
|
2013-09-13 11:12:26 +04:00
|
|
|
case XCB_BUTTON_INDEX_2:
|
2011-01-30 17:34:42 +03:00
|
|
|
com = options->commandAll2();
|
|
|
|
break;
|
2013-09-13 11:12:26 +04:00
|
|
|
case XCB_BUTTON_INDEX_3:
|
2011-01-30 17:34:42 +03:00
|
|
|
com = options->commandAll3();
|
|
|
|
break;
|
2013-09-13 11:12:26 +04:00
|
|
|
case XCB_BUTTON_INDEX_4:
|
|
|
|
case XCB_BUTTON_INDEX_5:
|
|
|
|
com = options->operationWindowMouseWheel(button == XCB_BUTTON_INDEX_4 ? 120 : -120);
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2015-07-09 17:11:51 +03: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 21:35:43 +04:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
if (was_action) {
|
2014-03-20 16:39:00 +04:00
|
|
|
bool replay = performMouseCommand(com, QPoint(x_root, y_root));
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isSpecialWindow())
|
2007-04-29 21:35:43 +04:00
|
|
|
replay = true;
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (w == wrapperId()) // these can come only from a grab
|
2013-09-10 12:55:14 +04:00
|
|
|
xcb_allow_events(connection(), replay ? XCB_ALLOW_REPLAY_POINTER : XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
if (w == wrapperId()) { // these can come only from a grab
|
2013-09-10 12:55:14 +04:00
|
|
|
xcb_allow_events(connection(), XCB_ALLOW_REPLAY_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2012-10-03 21:00:56 +04:00
|
|
|
if (w == inputId()) {
|
2014-07-22 15:11:19 +04:00
|
|
|
x = x_root - geometry().x();
|
|
|
|
y = y_root - geometry().y();
|
2012-10-03 21:00:56 +04:00
|
|
|
// New API processes core events FIRST and only passes unused ones to the decoration
|
|
|
|
return processDecorationButtonPress(button, state, x, y, x_root, y_root, true);
|
|
|
|
}
|
2014-07-22 15:11:19 +04:00
|
|
|
if (w == frameId() && m_decoration) {
|
2014-07-25 10:05:47 +04: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 16:08:13 +03:00
|
|
|
event.setAccepted(false);
|
2014-07-25 10:05:47 +04:00
|
|
|
QCoreApplication::sendEvent(m_decoration, &event);
|
2014-11-28 16:08:13 +03:00
|
|
|
if (!event.isAccepted() && !hor) {
|
|
|
|
if (m_decoration->titleBar().contains(x, y)) {
|
|
|
|
performMouseCommand(options->operationTitlebarMouseWheel(delta), QPoint(x_root, y_root));
|
|
|
|
}
|
|
|
|
}
|
2014-07-25 10:05:47 +04:00
|
|
|
} else {
|
|
|
|
QMouseEvent event(QEvent::MouseButtonPress, QPointF(x, y), QPointF(x_root, y_root),
|
|
|
|
x11ToQtMouseButton(button), x11ToQtMouseButtons(state), x11ToQtKeyboardModifiers(state));
|
|
|
|
event.setAccepted(false);
|
|
|
|
QCoreApplication::sendEvent(m_decoration, &event);
|
|
|
|
if (!event.isAccepted()) {
|
|
|
|
processDecorationButtonPress(button, state, x, y, x_root, y_root);
|
|
|
|
}
|
2014-07-22 15:11:19 +04:00
|
|
|
}
|
|
|
|
return true;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
// this function processes button press events only after decoration decides not to handle them,
|
|
|
|
// unlike buttonPressEvent(), which (when the window is decoration) filters events before decoration gets them
|
2011-01-30 17:34:42 +03:00
|
|
|
bool Client::processDecorationButtonPress(int button, int /*state*/, int x, int y, int x_root, int y_root,
|
|
|
|
bool ignoreMenu)
|
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
bool active = isActive();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!wantsInput()) // we cannot be active, use it anyway
|
2007-04-29 21:35:43 +04:00
|
|
|
active = true;
|
|
|
|
|
2014-11-28 16:50:21 +03:00
|
|
|
// check whether it is a double click
|
|
|
|
if (button == XCB_BUTTON_INDEX_1) {
|
|
|
|
if (m_decorationDoubleClickTimer.isValid() &&
|
|
|
|
m_decoration->titleBar().contains(x, y) &&
|
|
|
|
!m_decorationDoubleClickTimer.hasExpired(QGuiApplication::styleHints()->mouseDoubleClickInterval())) {
|
|
|
|
Workspace::self()->performWindowOperation(this, options->operationTitlebarDblClick());
|
|
|
|
dontMoveResize();
|
|
|
|
m_decorationDoubleClickTimer.invalidate();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
m_decorationDoubleClickTimer.invalidate();
|
|
|
|
}
|
|
|
|
|
2013-09-13 11:12:26 +04:00
|
|
|
if (button == XCB_BUTTON_INDEX_1)
|
2007-04-29 21:35:43 +04:00
|
|
|
com = active ? options->commandActiveTitlebar1() : options->commandInactiveTitlebar1();
|
2013-09-13 11:12:26 +04:00
|
|
|
else if (button == XCB_BUTTON_INDEX_2)
|
2007-04-29 21:35:43 +04:00
|
|
|
com = active ? options->commandActiveTitlebar2() : options->commandInactiveTitlebar2();
|
2013-09-13 11:12:26 +04:00
|
|
|
else if (button == XCB_BUTTON_INDEX_3)
|
2007-04-29 21:35:43 +04:00
|
|
|
com = active ? options->commandActiveTitlebar3() : options->commandInactiveTitlebar3();
|
2013-09-13 11:12:26 +04:00
|
|
|
if (button == XCB_BUTTON_INDEX_1
|
2011-01-30 17:34:42 +03:00
|
|
|
&& com != Options::MouseOperationsMenu // actions where it's not possible to get the matching
|
|
|
|
&& com != Options::MouseMinimize // mouse release event
|
2012-01-12 10:42:55 +04:00
|
|
|
&& com != Options::MouseDragTab) {
|
2015-06-04 20:26:35 +03:00
|
|
|
mode = mousePosition();
|
2007-04-29 21:35:43 +04:00
|
|
|
buttonDown = true;
|
2014-07-22 15:11:19 +04:00
|
|
|
moveOffset = QPoint(x/* - padding_left*/, y/* - padding_top*/);
|
2007-04-29 21:35:43 +04:00
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = false;
|
2007-05-22 19:46:42 +04:00
|
|
|
startDelayedMoveResize();
|
|
|
|
updateCursor();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-11-17 10:17:49 +03:00
|
|
|
// In the new API the decoration may process the menu action to display an inactive tab's menu.
|
|
|
|
// If the event is unhandled then the core will create one for the active window in the group.
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!ignoreMenu || com != Options::MouseOperationsMenu)
|
|
|
|
performMouseCommand(com, QPoint(x_root, y_root));
|
2009-11-17 10:17:49 +03:00
|
|
|
return !( // Return events that should be passed to the decoration in the new API
|
2011-01-30 17:34:42 +03:00
|
|
|
com == Options::MouseRaise ||
|
|
|
|
com == Options::MouseOperationsMenu ||
|
|
|
|
com == Options::MouseActivateAndRaise ||
|
|
|
|
com == Options::MouseActivate ||
|
|
|
|
com == Options::MouseActivateRaiseAndPassClick ||
|
|
|
|
com == Options::MouseActivateAndPassClick ||
|
2012-01-12 10:42:55 +04:00
|
|
|
com == Options::MouseDragTab ||
|
2011-01-30 17:34:42 +03:00
|
|
|
com == Options::MouseNothing);
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// return value matters only when filtering events before decoration gets them
|
2013-10-21 00:30:44 +04: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 17:34:42 +03:00
|
|
|
{
|
2014-07-22 15:11:19 +04:00
|
|
|
if (w == frameId() && m_decoration) {
|
2014-07-25 10:05:47 +04: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 18:49:21 +04:00
|
|
|
x11ToQtMouseButtons(state) & ~x11ToQtMouseButton(button),
|
2014-07-25 10:05:47 +04:00
|
|
|
x11ToQtKeyboardModifiers(state));
|
2014-11-28 16:50:21 +03:00
|
|
|
event.setAccepted(false);
|
2014-07-25 10:05:47 +04:00
|
|
|
QCoreApplication::sendEvent(m_decoration, &event);
|
2014-11-28 16:50:21 +03:00
|
|
|
if (!event.isAccepted() && m_decoration->titleBar().contains(x, y) && button == XCB_BUTTON_INDEX_1) {
|
|
|
|
m_decorationDoubleClickTimer.start();
|
|
|
|
}
|
2014-07-25 10:05:47 +04:00
|
|
|
}
|
2014-07-22 15:11:19 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
if (w == wrapperId()) {
|
2013-09-10 12:55:14 +04:00
|
|
|
xcb_allow_events(connection(), XCB_ALLOW_SYNC_POINTER, XCB_TIME_CURRENT_TIME); //xTime());
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2014-07-22 15:11:19 +04:00
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
|
2007-04-29 21:35:43 +04:00
|
|
|
return true;
|
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
2013-10-21 00:30:44 +04: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) {
|
2007-04-29 21:35:43 +04:00
|
|
|
buttonDown = false;
|
2007-05-22 19:46:42 +04:00
|
|
|
stopDelayedMoveResize();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (moveResizeMode) {
|
|
|
|
finishMoveResize(false);
|
2015-06-04 20:26:35 +03:00
|
|
|
mode = mousePosition();
|
2014-07-22 15:11:19 +04:00
|
|
|
}
|
2007-05-22 19:46:42 +04:00
|
|
|
updateCursor();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2010-01-09 12:49:52 +03:00
|
|
|
// Checks if the mouse cursor is near the edge of the screen and if so activates quick tiling or maximization
|
2011-01-30 17:34:42 +03:00
|
|
|
void Client::checkQuickTilingMaximizationZones(int xroot, int yroot)
|
|
|
|
{
|
2011-03-08 00:31:44 +03:00
|
|
|
|
|
|
|
QuickTileMode mode = QuickTileNone;
|
2015-09-01 20:49:04 +03:00
|
|
|
bool innerBorder = false;
|
|
|
|
for (int i=0; i < screens()->count(); ++i) {
|
2011-03-08 00:31:44 +03:00
|
|
|
|
2013-07-17 23:23:24 +04:00
|
|
|
if (!screens()->geometry(i).contains(QPoint(xroot, yroot)))
|
2011-03-08 00:31:44 +03:00
|
|
|
continue;
|
|
|
|
|
2015-09-16 00:59:08 +03:00
|
|
|
auto isInScreen = [i](const QPoint &pt) {
|
|
|
|
for (int j = 0; j < screens()->count(); ++j) {
|
|
|
|
if (j == i)
|
|
|
|
continue;
|
|
|
|
if (screens()->geometry(j).contains(pt)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
2013-07-17 23:23:24 +04:00
|
|
|
QRect area = workspace()->clientArea(MaximizeArea, QPoint(xroot, yroot), desktop());
|
2011-03-08 00:31:44 +03:00
|
|
|
if (options->electricBorderTiling()) {
|
2015-09-01 20:49:04 +03:00
|
|
|
if (xroot <= area.x() + 20) {
|
|
|
|
mode |= QuickTileLeft;
|
2015-09-16 00:59:08 +03:00
|
|
|
innerBorder = isInScreen(QPoint(area.x() - 1, yroot));
|
2015-09-01 20:49:04 +03:00
|
|
|
} else if (xroot >= area.x() + area.width() - 20) {
|
|
|
|
mode |= QuickTileRight;
|
2015-09-16 00:59:08 +03:00
|
|
|
innerBorder = isInScreen(QPoint(area.right() + 1, yroot));
|
2015-09-01 20:49:04 +03:00
|
|
|
}
|
2010-01-09 12:49:52 +03:00
|
|
|
}
|
2011-03-08 00:31:44 +03:00
|
|
|
|
|
|
|
if (mode != QuickTileNone) {
|
2012-09-20 00:48:52 +04:00
|
|
|
if (yroot <= area.y() + area.height() * options->electricBorderCornerRatio())
|
2011-03-08 00:31:44 +03:00
|
|
|
mode |= QuickTileTop;
|
2012-09-20 00:48:52 +04:00
|
|
|
else if (yroot >= area.y() + area.height() - area.height() * options->electricBorderCornerRatio())
|
2011-03-08 00:31:44 +03:00
|
|
|
mode |= QuickTileBottom;
|
2015-09-01 20:49:04 +03:00
|
|
|
} else if (options->electricBorderMaximize() && yroot <= area.y() + 5 && isMaximizable()) {
|
2011-03-08 00:31:44 +03:00
|
|
|
mode = QuickTileMaximize;
|
2015-09-16 00:59:08 +03:00
|
|
|
innerBorder = isInScreen(QPoint(xroot, area.y() - 1));
|
2015-09-01 20:49:04 +03:00
|
|
|
}
|
2011-03-08 00:31:44 +03:00
|
|
|
break; // no point in checking other screens to contain this... "point"...
|
2010-01-09 12:49:52 +03:00
|
|
|
}
|
2015-10-12 10:56:54 +03:00
|
|
|
if (mode != electricBorderMode()) {
|
2015-09-01 20:49:04 +03:00
|
|
|
setElectricBorderMode(mode);
|
|
|
|
if (innerBorder) {
|
|
|
|
if (!m_electricMaximizingDelay) {
|
|
|
|
m_electricMaximizingDelay = new QTimer(this);
|
|
|
|
m_electricMaximizingDelay->setInterval(250);
|
|
|
|
m_electricMaximizingDelay->setSingleShot(true);
|
|
|
|
connect(m_electricMaximizingDelay, &QTimer::timeout, [this]() {
|
2015-09-16 00:59:08 +03:00
|
|
|
if (isMove())
|
2015-10-12 10:56:54 +03:00
|
|
|
setElectricBorderMaximizing(electricBorderMode() != QuickTileNone);
|
2015-09-01 20:49:04 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
m_electricMaximizingDelay->start();
|
|
|
|
} else {
|
|
|
|
setElectricBorderMaximizing(mode != QuickTileNone);
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2010-01-09 12:49:52 +03:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// return value matters only when filtering events before decoration gets them
|
2013-05-03 12:32:18 +04:00
|
|
|
bool Client::motionNotifyEvent(xcb_window_t w, int state, int x, int y, int x_root, int y_root)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2015-08-31 11:28:03 +03:00
|
|
|
if (w == frameId() && m_decoration && !isMinimized()) {
|
2014-07-22 15:11:19 +04:00
|
|
|
// TODO Mouse move event dependent on state
|
|
|
|
QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y));
|
|
|
|
QCoreApplication::instance()->sendEvent(m_decoration, &event);
|
|
|
|
}
|
|
|
|
if (w != frameId() && w != inputId() && w != moveResizeGrabWindow())
|
2007-04-29 21:35:43 +04:00
|
|
|
return true; // care only about the whole frame
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!buttonDown) {
|
2011-11-09 23:39:13 +04:00
|
|
|
if (w == inputId()) {
|
2014-07-22 15:11:19 +04:00
|
|
|
int x = x_root - geometry().x();// + padding_left;
|
|
|
|
int y = y_root - geometry().y();// + padding_top;
|
2014-12-16 17:29:04 +03:00
|
|
|
|
|
|
|
if (m_decoration) {
|
|
|
|
QHoverEvent event(QEvent::HoverMove, QPointF(x, y), QPointF(x, y));
|
|
|
|
QCoreApplication::instance()->sendEvent(m_decoration, &event);
|
|
|
|
}
|
2011-11-09 23:39:13 +04:00
|
|
|
}
|
2015-06-04 20:26:35 +03:00
|
|
|
Position newmode = modKeyDown(state) ? PositionCenter : mousePosition();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (newmode != mode) {
|
2007-05-22 19:46:42 +04:00
|
|
|
mode = newmode;
|
|
|
|
updateCursor();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
return false;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
if (w == moveResizeGrabWindow()) {
|
2007-04-29 21:35:43 +04:00
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
|
|
|
}
|
2014-02-01 12:34:40 +04:00
|
|
|
|
2015-06-05 06:06:20 +03:00
|
|
|
handleMoveResize(QPoint(x, y), QPoint(x_root, y_root));
|
2011-01-30 17:34:42 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-07-26 16:35:28 +04:00
|
|
|
void Client::focusInEvent(xcb_focus_in_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-26 16:35:28 +04:00
|
|
|
if (e->event != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // only window gets focus
|
2013-07-26 16:35:28 +04:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_UNGRAB)
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // we don't care
|
2013-07-26 16:35:28 +04:00
|
|
|
if (e->detail == XCB_NOTIFY_DETAIL_POINTER)
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // we don't care
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!isShown(false) || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile ->
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // activateNextClient() already transferred focus elsewhere
|
2013-08-05 11:48:14 +04:00
|
|
|
workspace()->forEachClient([](Client *client) {
|
|
|
|
client->cancelFocusOutTimer();
|
|
|
|
});
|
2007-04-29 21:35:43 +04:00
|
|
|
// check if this client is in should_get_focus list or if activation is allowed
|
2011-01-30 17:34:42 +03: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 21:35:43 +04:00
|
|
|
workspace()->restoreFocus();
|
|
|
|
demandAttention();
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 16:51:56 +04:00
|
|
|
void Client::focusOutEvent(xcb_focus_out_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-26 16:51:56 +04:00
|
|
|
if (e->event != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // only window gets focus
|
2013-07-26 16:51:56 +04:00
|
|
|
if (e->mode == XCB_NOTIFY_MODE_GRAB)
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // we don't care
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isShade())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // here neither
|
2013-07-26 16:51:56 +04:00
|
|
|
if (e->detail != XCB_NOTIFY_DETAIL_NONLINEAR
|
|
|
|
&& e->detail != XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL)
|
2007-04-29 21:35:43 +04:00
|
|
|
// SELI check all this
|
|
|
|
return; // hack for motif apps like netscape
|
2011-01-30 17:34:42 +03:00
|
|
|
if (QApplication::activePopupWidget())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2013-08-05 11:48:14 +04: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 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// performs _NET_WM_MOVERESIZE
|
2011-01-30 17:34:42 +03:00
|
|
|
void Client::NETMoveResize(int x_root, int y_root, NET::Direction direction)
|
|
|
|
{
|
|
|
|
if (direction == NET::Move)
|
|
|
|
performMouseCommand(Options::MouseMove, QPoint(x_root, y_root));
|
|
|
|
else if (moveResizeMode && direction == NET::MoveResizeCancel) {
|
|
|
|
finishMoveResize(true);
|
2007-04-29 21:35:43 +04:00
|
|
|
buttonDown = false;
|
2007-05-22 19:46:42 +04:00
|
|
|
updateCursor();
|
2011-01-30 17:34:42 +03:00
|
|
|
} else if (direction >= NET::TopLeft && direction <= NET::Left) {
|
|
|
|
static const Position convert[] = {
|
2007-04-29 21:35:43 +04:00
|
|
|
PositionTopLeft,
|
|
|
|
PositionTop,
|
|
|
|
PositionTopRight,
|
|
|
|
PositionRight,
|
|
|
|
PositionBottomRight,
|
|
|
|
PositionBottom,
|
|
|
|
PositionBottomLeft,
|
|
|
|
PositionLeft
|
2011-01-30 17:34:42 +03:00
|
|
|
};
|
|
|
|
if (!isResizable() || isShade())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
if (moveResizeMode)
|
|
|
|
finishMoveResize(false);
|
2007-04-29 21:35:43 +04:00
|
|
|
buttonDown = true;
|
2011-01-30 17:34:42 +03:00
|
|
|
moveOffset = QPoint(x_root - x(), y_root - y()); // map from global
|
2007-04-29 21:35:43 +04:00
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = false;
|
|
|
|
mode = convert[ direction ];
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!startMoveResize())
|
2007-04-29 21:35:43 +04:00
|
|
|
buttonDown = false;
|
2007-05-22 19:46:42 +04:00
|
|
|
updateCursor();
|
2011-01-30 17:34:42 +03:00
|
|
|
} else if (direction == NET::KeyboardMove) {
|
|
|
|
// ignore mouse coordinates given in the message, mouse position is used by the moving algorithm
|
2013-02-26 11:45:44 +04:00
|
|
|
Cursor::setPos(geometry().center());
|
2011-01-30 17:34:42 +03: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 11:45:44 +04:00
|
|
|
Cursor::setPos(geometry().bottomRight());
|
2011-01-30 17:34:42 +03:00
|
|
|
performMouseCommand(Options::MouseUnrestrictedResize, geometry().bottomRight());
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2014-06-01 19:57:51 +04:00
|
|
|
void Client::keyPressEvent(uint key_code, xcb_timestamp_t time)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2014-06-01 19:57:51 +04:00
|
|
|
updateUserTime(time);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (!isMove() && !isResize())
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
|
|
|
bool is_control = key_code & Qt::CTRL;
|
|
|
|
bool is_alt = key_code & Qt::ALT;
|
|
|
|
key_code = key_code & ~Qt::KeyboardModifierMask;
|
2011-01-30 17:34:42 +03:00
|
|
|
int delta = is_control ? 1 : is_alt ? 32 : 8;
|
2014-03-19 17:45:27 +04:00
|
|
|
QPoint pos = Cursor::pos();
|
2011-01-30 17:34:42 +03:00
|
|
|
switch(key_code) {
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Left:
|
2011-01-30 17:34:42 +03:00
|
|
|
pos.rx() -= delta;
|
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Right:
|
2011-01-30 17:34:42 +03:00
|
|
|
pos.rx() += delta;
|
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Up:
|
2011-01-30 17:34:42 +03:00
|
|
|
pos.ry() -= delta;
|
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Down:
|
2011-01-30 17:34:42 +03:00
|
|
|
pos.ry() += delta;
|
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Space:
|
|
|
|
case Qt::Key_Return:
|
|
|
|
case Qt::Key_Enter:
|
2011-01-30 17:34:42 +03:00
|
|
|
finishMoveResize(false);
|
|
|
|
buttonDown = false;
|
|
|
|
updateCursor();
|
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
case Qt::Key_Escape:
|
2011-01-30 17:34:42 +03:00
|
|
|
finishMoveResize(true);
|
|
|
|
buttonDown = false;
|
|
|
|
updateCursor();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2013-02-26 11:45:44 +04:00
|
|
|
Cursor::setPos(pos);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2013-07-26 14:00:14 +04:00
|
|
|
void Client::syncEvent(xcb_sync_alarm_notify_event_t* e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-07-31 12:11:39 +04:00
|
|
|
if (e->alarm == syncRequest.alarm && e->counter_value.hi == syncRequest.value.hi && e->counter_value.lo == syncRequest.value.lo) {
|
2012-01-24 20:00:40 +04:00
|
|
|
setReadyForPainting();
|
2015-07-09 10:10:33 +03:00
|
|
|
setupWindowManagementInterface();
|
2011-08-13 18:39:58 +04:00
|
|
|
syncRequest.isPending = false;
|
|
|
|
if (syncRequest.failsafeTimeout)
|
|
|
|
syncRequest.failsafeTimeout->stop();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (isResize()) {
|
2011-08-13 18:39:58 +04:00
|
|
|
if (syncRequest.timeout)
|
|
|
|
syncRequest.timeout->stop();
|
|
|
|
performMoveResize();
|
2012-01-24 20:00:40 +04:00
|
|
|
} else // setReadyForPainting does as well, but there's a small chance for resize syncs after the resize ended
|
2011-08-13 18:39:58 +04:00
|
|
|
addRepaintFull();
|
2007-06-25 12:51:44 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-06-25 12:51:44 +04:00
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
// ****************************************
|
|
|
|
// Unmanaged
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 13:16:50 +04:00
|
|
|
bool Unmanaged::windowEvent(xcb_generic_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
double old_opacity = opacity();
|
2014-03-17 13:22:20 +04:00
|
|
|
NET::Properties dirtyProperties;
|
|
|
|
NET::Properties2 dirtyProperties2;
|
|
|
|
info->event(e, &dirtyProperties, &dirtyProperties2); // pass through the NET stuff
|
|
|
|
if (dirtyProperties2 & NET::WM2Opacity) {
|
2011-01-30 17:34:42 +03:00
|
|
|
if (compositing()) {
|
2007-04-29 21:35:43 +04:00
|
|
|
addRepaintFull();
|
2011-03-06 12:30:23 +03:00
|
|
|
emit opacityChanged(this, old_opacity);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
|
|
|
}
|
2015-01-22 17:46:12 +03:00
|
|
|
if (dirtyProperties2 & NET::WM2OpaqueRegion) {
|
|
|
|
getWmOpaqueRegion();
|
|
|
|
}
|
2014-04-10 13:12:48 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowRole)) {
|
|
|
|
emit windowRoleChanged();
|
|
|
|
}
|
2014-04-11 10:06:26 +04:00
|
|
|
if (dirtyProperties2.testFlag(NET::WM2WindowClass)) {
|
|
|
|
getResourceClass();
|
|
|
|
}
|
2013-07-26 15:00:51 +04:00
|
|
|
const uint8_t eventType = e->response_type & ~0x80;
|
|
|
|
switch (eventType) {
|
2014-04-07 18:23:17 +04:00
|
|
|
case XCB_DESTROY_NOTIFY:
|
|
|
|
release(ReleaseReason::Destroyed);
|
|
|
|
break;
|
|
|
|
case XCB_UNMAP_NOTIFY:{
|
2015-01-29 02:14:47 +03:00
|
|
|
workspace()->updateFocusMousePosition(Cursor::pos()); // may cause leave event
|
2014-04-07 18:23:17 +04: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 17:34:42 +03:00
|
|
|
break;
|
2014-04-07 18:23:17 +04:00
|
|
|
}
|
2013-07-26 15:04:12 +04:00
|
|
|
case XCB_CONFIGURE_NOTIFY:
|
|
|
|
configureNotifyEvent(reinterpret_cast<xcb_configure_notify_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2013-07-26 15:17:23 +04:00
|
|
|
case XCB_PROPERTY_NOTIFY:
|
|
|
|
propertyNotifyEvent(reinterpret_cast<xcb_property_notify_event_t*>(e));
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2015-01-09 13:16:57 +03:00
|
|
|
case XCB_CLIENT_MESSAGE:
|
|
|
|
clientMessageEvent(reinterpret_cast<xcb_client_message_event_t*>(e));
|
|
|
|
break;
|
2011-01-30 17:34:42 +03:00
|
|
|
default: {
|
2013-07-26 15:05:23 +04:00
|
|
|
if (eventType == Xcb::Extensions::self()->shapeNotifyEvent()) {
|
2011-01-30 17:34:42 +03:00
|
|
|
detectShape(window());
|
|
|
|
addRepaintFull();
|
|
|
|
addWorkspaceRepaint(geometry()); // in case shape change removes part of this window
|
2011-06-20 00:07:19 +04:00
|
|
|
emit geometryShapeChanged(this, geometry());
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2013-07-26 15:05:23 +04:00
|
|
|
if (eventType == Xcb::Extensions::self()->damageNotifyEvent())
|
2013-04-26 13:00:08 +04:00
|
|
|
damageNotifyEvent();
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2013-07-26 15:00:51 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
return false; // don't eat events, even our own unmanaged widgets are tracked
|
|
|
|
}
|
|
|
|
|
2013-07-26 15:04:12 +04:00
|
|
|
void Unmanaged::configureNotifyEvent(xcb_configure_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (effects)
|
2007-04-29 21:35:43 +04:00
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking(); // keep them on top
|
2011-01-30 17:34:42 +03:00
|
|
|
QRect newgeom(e->x, e->y, e->width, e->height);
|
|
|
|
if (newgeom != geom) {
|
2011-04-04 20:50:30 +04:00
|
|
|
addWorkspaceRepaint(visibleRect()); // damage old area
|
2007-05-23 20:22:59 +04:00
|
|
|
QRect old = geom;
|
|
|
|
geom = newgeom;
|
2013-09-12 01:27:30 +04:00
|
|
|
emit geometryChanged(); // update shadow region
|
2008-10-01 16:49:52 +04:00
|
|
|
addRepaintFull();
|
2011-01-30 17:34:42 +03:00
|
|
|
if (old.size() != geom.size())
|
2008-03-20 12:58:46 +03:00
|
|
|
discardWindowPixmap();
|
2011-06-20 00:07:19 +04:00
|
|
|
emit geometryShapeChanged(this, old);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Toplevel
|
|
|
|
// ****************************************
|
|
|
|
|
2013-07-26 15:17:23 +04:00
|
|
|
void Toplevel::propertyNotifyEvent(xcb_property_notify_event_t *e)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (e->window != window())
|
2007-04-29 21:35:43 +04:00
|
|
|
return; // ignore frame/wrapper
|
2011-01-30 17:34:42 +03:00
|
|
|
switch(e->atom) {
|
|
|
|
default:
|
|
|
|
if (e->atom == atoms->wm_client_leader)
|
|
|
|
getWmClientLeader();
|
2011-03-27 14:33:07 +04:00
|
|
|
else if (e->atom == atoms->kde_net_wm_shadow)
|
|
|
|
getShadow();
|
2014-01-24 15:34:16 +04:00
|
|
|
else if (e->atom == atoms->kde_skip_close_animation)
|
|
|
|
getSkipCloseAnimation();
|
2011-01-30 17:34:42 +03:00
|
|
|
break;
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-03-12 21:18:19 +03:00
|
|
|
emit propertyNotify(this, e->atom);
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2015-01-09 13:16:57 +03: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 10:49:39 +03:00
|
|
|
if (auto w = waylandServer()) {
|
|
|
|
m_surface = KWayland::Server::SurfaceInterface::get(m_surfaceId, w->xWaylandConnection());
|
|
|
|
}
|
2015-01-09 13:16:57 +03:00
|
|
|
emit surfaceIdChanged(m_surfaceId);
|
|
|
|
}
|
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
} // namespace
|