Commit 4921acf4 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii Committed by Vlad Zahorodnii
Browse files

Grab all possible keyboard modifiers for window commands

BUG: 424272
FIXED-IN: 5.19.4
parent 3609a029
......@@ -820,24 +820,45 @@ void X11Client::leaveNotifyEvent(xcb_leave_notify_event_t *e)
}
}
#define XCapL KKeyServer::modXLock()
#define XNumL KKeyServer::modXNumLock()
#define XScrL KKeyServer::modXScrollLock()
void X11Client::grabButton(Qt::KeyboardModifier modifier, uint8_t button)
static uint16_t x11CommandAllModifier()
{
uint16_t x11Modifier;
switch (modifier) {
switch (options->commandAllModifier()) {
case Qt::MetaModifier:
x11Modifier = KKeyServer::modXMeta();
break;
return KKeyServer::modXMeta();
case Qt::AltModifier:
x11Modifier = KKeyServer::modXAlt();
break;
return KKeyServer::modXAlt();
default:
x11Modifier = 0;
break;
return 0;
}
}
#define XCapL KKeyServer::modXLock()
#define XNumL KKeyServer::modXNumLock()
#define XScrL KKeyServer::modXScrollLock()
void X11Client::establishCommandWindowGrab(uint8_t button)
{
// Unfortunately there are a lot of possible modifier combinations that we need to take into
// account. We tackle that problem in a kind of smart way. First, we grab the button with all
// possible modifiers, then we ungrab the ones that are relevant only to commandAllx().
m_wrapper.grabButton(XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_MOD_MASK_ANY, button);
uint16_t x11Modifier = x11CommandAllModifier();
unsigned int mods[ 8 ] = {
0, XCapL, XNumL, XNumL | XCapL,
XScrL, XScrL | XCapL,
XScrL | XNumL, XScrL | XNumL | XCapL
};
for (int i = 0;
i < 8;
++i)
m_wrapper.ungrabButton(x11Modifier | mods[ i ], button);
}
void X11Client::establishCommandAllGrab(uint8_t button)
{
uint16_t x11Modifier = x11CommandAllModifier();
unsigned int mods[ 8 ] = {
0, XCapL, XNumL, XNumL | XCapL,
......@@ -872,17 +893,17 @@ void X11Client::updateMouseGrab()
if ((options->focusPolicyIsReasonable() && !isActive()) ||
(options->isClickRaise() && !isMostRecentlyRaised())) {
if (options->commandWindow1() != Options::MouseNothing) {
grabButton(Qt::NoModifier, XCB_BUTTON_INDEX_1);
establishCommandWindowGrab(XCB_BUTTON_INDEX_1);
}
if (options->commandWindow2() != Options::MouseNothing) {
grabButton(Qt::NoModifier, XCB_BUTTON_INDEX_2);
establishCommandWindowGrab(XCB_BUTTON_INDEX_2);
}
if (options->commandWindow3() != Options::MouseNothing) {
grabButton(Qt::NoModifier, XCB_BUTTON_INDEX_3);
establishCommandWindowGrab(XCB_BUTTON_INDEX_3);
}
if (options->commandWindowWheel() != Options::MouseNothing) {
grabButton(Qt::NoModifier, XCB_BUTTON_INDEX_4);
grabButton(Qt::NoModifier, XCB_BUTTON_INDEX_5);
establishCommandWindowGrab(XCB_BUTTON_INDEX_4);
establishCommandWindowGrab(XCB_BUTTON_INDEX_5);
}
}
......@@ -892,17 +913,17 @@ void X11Client::updateMouseGrab()
if (!workspace()->globalShortcutsDisabled()) {
if (options->commandAll1() != Options::MouseNothing) {
grabButton(options->commandAllModifier(), XCB_BUTTON_INDEX_1);
establishCommandAllGrab(XCB_BUTTON_INDEX_1);
}
if (options->commandAll2() != Options::MouseNothing) {
grabButton(options->commandAllModifier(), XCB_BUTTON_INDEX_2);
establishCommandAllGrab(XCB_BUTTON_INDEX_2);
}
if (options->commandAll3() != Options::MouseNothing) {
grabButton(options->commandAllModifier(), XCB_BUTTON_INDEX_3);
establishCommandAllGrab(XCB_BUTTON_INDEX_3);
}
if (options->commandAllWheel() != Options::MouseWheelNothing) {
grabButton(options->commandAllModifier(), XCB_BUTTON_INDEX_4);
grabButton(options->commandAllModifier(), XCB_BUTTON_INDEX_5);
establishCommandAllGrab(XCB_BUTTON_INDEX_4);
establishCommandAllGrab(XCB_BUTTON_INDEX_5);
}
}
}
......
......@@ -416,7 +416,8 @@ private:
void sendSyncRequest();
void leaveMoveResize() override;
void positionGeometryTip() override;
void grabButton(Qt::KeyboardModifier modifier, uint8_t button);
void establishCommandWindowGrab(uint8_t button);
void establishCommandAllGrab(uint8_t button);
void resizeDecoration();
void createDecoration(const QRect &oldgeom) override;
......
Markdown is supported
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