This repository has been archived by the owner on Apr 29, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Move X11 movingClient handling into a dedicated X11EventFilter
Summary: Splits out the X11 specific window movement handling so that it's not used in the Wayland case at runtime. As a nice side effect it un-spaghetties the X11 event handler. Test Plan: Run nested KWin on Xephyr and nested KWin/Wayland to verify that move/resize of X11 windows is still working Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D7374
- Loading branch information
1 parent
b57a525
commit bd5f5e0
Showing
6 changed files
with
104 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************** | ||
KWin - the KDE window manager | ||
This file is part of the KDE project. | ||
Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org> | ||
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/>. | ||
*********************************************************************/ | ||
#include "moving_client_x11_filter.h" | ||
#include "client.h" | ||
#include "workspace.h" | ||
#include <KKeyServer> | ||
#include <xcb/xcb.h> | ||
|
||
namespace KWin | ||
{ | ||
|
||
MovingClientX11Filter::MovingClientX11Filter() | ||
: X11EventFilter(QVector<int>{XCB_KEY_PRESS, XCB_MOTION_NOTIFY, XCB_BUTTON_PRESS, XCB_BUTTON_RELEASE}) | ||
{ | ||
} | ||
|
||
bool MovingClientX11Filter::event(xcb_generic_event_t *event) | ||
{ | ||
auto client = dynamic_cast<Client*>(workspace()->getMovingClient()); | ||
if (!client) { | ||
return false; | ||
} | ||
auto testWindow = [client, event] (xcb_window_t window) { | ||
return client->moveResizeGrabWindow() == window && client->windowEvent(event); | ||
}; | ||
|
||
const uint8_t eventType = event->response_type & ~0x80; | ||
switch (eventType) { | ||
case XCB_KEY_PRESS: { | ||
int keyQt; | ||
xcb_key_press_event_t *keyEvent = reinterpret_cast<xcb_key_press_event_t*>(event); | ||
KKeyServer::xcbKeyPressEventToQt(keyEvent, &keyQt); | ||
client->keyPressEvent(keyQt, keyEvent->time); | ||
return true; | ||
} | ||
case XCB_BUTTON_PRESS: | ||
case XCB_BUTTON_RELEASE: | ||
return testWindow(reinterpret_cast<xcb_button_press_event_t*>(event)->event); | ||
case XCB_MOTION_NOTIFY: | ||
return testWindow(reinterpret_cast<xcb_motion_notify_event_t*>(event)->event); | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************** | ||
KWin - the KDE window manager | ||
This file is part of the KDE project. | ||
Copyright (C) 2017 Martin Flöser <mgraesslin@kde.org> | ||
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/>. | ||
*********************************************************************/ | ||
#ifndef KWIN_MOVING_CLIENT_X11_FILTER_H | ||
#define KWIN_MOVING_CLIENT_X11_FILTER_H | ||
#include "x11eventfilter.h" | ||
|
||
namespace KWin | ||
{ | ||
|
||
class MovingClientX11Filter : public X11EventFilter | ||
{ | ||
public: | ||
explicit MovingClientX11Filter(); | ||
|
||
bool event(xcb_generic_event_t *event) override; | ||
}; | ||
|
||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters