File kglobalaccel-5.32.0-Make-sure-ungrab-keyboard-request.patch of Package kglobalaccel
Subject: [PATCH] Make sure ungrab keyboard request is processed before
emitting shortcut
From: Sontol Bonggol <sonbonggol@gmail.com>
Date: Fri, 25 May 2018 20:46:06 -0700
References: kde#394689, boo#1094931
In some rare cases, the ungrab keyboard request is processed later than
the action of the key shortcut. This can make the application that try
to grab the keyboard (e.g. in kwin) fail to do so. The solution is to
use ungrab_keyboard_checked() and xcb_request_check() before emitting
the shortcut signal.
---
src/runtime/plugins/xcb/kglobalaccel_x11.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Index: kglobalaccel-5.32.0/src/runtime/plugins/xcb/kglobalaccel_x11.cpp
===================================================================
--- kglobalaccel-5.32.0.orig/src/runtime/plugins/xcb/kglobalaccel_x11.cpp
+++ kglobalaccel-5.32.0/src/runtime/plugins/xcb/kglobalaccel_x11.cpp
@@ -240,8 +240,12 @@ bool KGlobalAccelImpl::x11KeyPress(xcb_k
// Keyboard needs to be ungrabed after XGrabKey() activates the grab,
// otherwise it becomes frozen.
xcb_connection_t *c = QX11Info::connection();
- xcb_ungrab_keyboard(c, XCB_TIME_CURRENT_TIME);
+ xcb_void_cookie_t cookie = xcb_ungrab_keyboard_checked(c, XCB_TIME_CURRENT_TIME);
xcb_flush(c);
+ // xcb_flush() only makes sure that the ungrab keyboard request has been
+ // sent, but is not enough to make sure that request has been fulfilled. Use
+ // xcb_request_check() to make sure that the request has been processed.
+ xcb_request_check(c, cookie);
xcb_keycode_t keyCodeX = pEvent->detail;
uint16_t keyModX = pEvent->state & (g_keyModMaskXAccel | KKeyServer::MODE_SWITCH);