Commit e10cf2a6 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

x11: Make X11Client not grab pointer when starting interactive move or resize

X11Client can grab pointer when starting interactive move or resize so
all pointer events go to it and kwin can update the move resize geometry
based on the current interactive move-resize mode.

However, on Wayland, X11Client::motionNotifyEvent() is disabled and
pointer events go through a code path that requires no X11 pointer grab.
parent f2d3c528
Pipeline #126665 passed with stage
in 15 minutes and 2 seconds
......@@ -4515,28 +4515,31 @@ QRect X11Client::fullscreenMonitorsArea(NETFullscreenMonitors requestedTopology)
bool X11Client::doStartInteractiveMoveResize()
{
bool has_grab = false;
// This reportedly improves smoothness of the moveresize operation,
// something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug*
// (https://lists.kde.org/?t=107302193400001&r=1&w=2)
QRect r = workspace()->clientArea(FullArea, this);
m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, nullptr, rootWindow());
m_moveResizeGrabWindow.map();
m_moveResizeGrabWindow.raise();
updateXTime();
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursors::self()->mouse()->x11Cursor(cursor()), xTime());
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(connection(), cookie, nullptr));
if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) {
has_grab = true;
}
if (!has_grab && grabXKeyboard(frameId()))
has_grab = move_resize_has_keyboard_grab = true;
if (!has_grab) { // at least one grab is necessary in order to be able to finish move/resize
m_moveResizeGrabWindow.reset();
return false;
if (kwinApp()->operationMode() == Application::OperationModeX11) {
bool has_grab = false;
// This reportedly improves smoothness of the moveresize operation,
// something with Enter/LeaveNotify events, looks like XFree performance problem or something *shrug*
// (https://lists.kde.org/?t=107302193400001&r=1&w=2)
QRect r = workspace()->clientArea(FullArea, this);
m_moveResizeGrabWindow.create(r, XCB_WINDOW_CLASS_INPUT_ONLY, 0, nullptr, rootWindow());
m_moveResizeGrabWindow.map();
m_moveResizeGrabWindow.raise();
updateXTime();
const xcb_grab_pointer_cookie_t cookie = xcb_grab_pointer_unchecked(connection(), false, m_moveResizeGrabWindow,
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_POINTER_MOTION |
XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, m_moveResizeGrabWindow, Cursors::self()->mouse()->x11Cursor(cursor()), xTime());
ScopedCPointer<xcb_grab_pointer_reply_t> pointerGrab(xcb_grab_pointer_reply(connection(), cookie, nullptr));
if (!pointerGrab.isNull() && pointerGrab->status == XCB_GRAB_STATUS_SUCCESS) {
has_grab = true;
}
if (!has_grab && grabXKeyboard(frameId())) {
has_grab = move_resize_has_keyboard_grab = true;
}
if (!has_grab) { // at least one grab is necessary in order to be able to finish move/resize
m_moveResizeGrabWindow.reset();
return false;
}
}
return true;
}
......@@ -4550,11 +4553,14 @@ void X11Client::leaveInteractiveMoveResize()
}
if (!isInteractiveResize())
sendSyntheticConfigureNotify(); // tell the client about it's new final position
if (move_resize_has_keyboard_grab)
ungrabXKeyboard();
move_resize_has_keyboard_grab = false;
xcb_ungrab_pointer(connection(), xTime());
m_moveResizeGrabWindow.reset();
if (kwinApp()->operationMode() == Application::OperationModeX11) {
if (move_resize_has_keyboard_grab) {
ungrabXKeyboard();
}
move_resize_has_keyboard_grab = false;
xcb_ungrab_pointer(connection(), xTime());
m_moveResizeGrabWindow.reset();
}
AbstractClient::leaveInteractiveMoveResize();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment