Skip to content

Commit

Permalink
Fix broken modSuperIsCtrlAlt for issue #791.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Feb 23, 2025
1 parent f154124 commit 26751c7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
11 changes: 6 additions & 5 deletions src/wmcontainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,15 @@ void YClientContainer::handleButton(const XButtonEvent &button) {
}
return ;
}
else if (gMouseWinRaise == button
&& (gMouseWinRaise != gMouseWinLower || getFrame()->canRaise()))
{
else if (gMouseWinRaise == button) {
XAllowEvents(xapp->display(), AsyncPointer, CurrentTime);
getFrame()->wmRaise();
if (getFrame()->canRaise())
getFrame()->wmRaise();
else if (gMouseWinRaise == gMouseWinLower)
getFrame()->wmLower();
return ;
}
else if (gMouseWinLower == button) {
else if (gMouseWinLower != gMouseWinRaise && gMouseWinLower == button) {
XAllowEvents(xapp->display(), AsyncPointer, CurrentTime);
getFrame()->wmLower();
return ;
Expand Down
30 changes: 23 additions & 7 deletions src/wmkey.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void WMKey::grab(int handle) {
else
ok = false;
}
if (modSuperIsCtrlAlt && xapp->WinMask && hasbits(mod, kfAlt | kfCtrl)) {
supered = true;
}
if (km && ok) {
xm[0] = xm[1] = km;
} else {
Expand All @@ -91,8 +94,7 @@ void WMKey::grab(int handle) {
if (IS_POINTER(key)) {
int button = key - XK_Pointer_Button1 + Button1;
if (inrange(button, Button1, Button3)) {
if (hasbits(mod, kfAlt | kfCtrl) &&
modSuperIsCtrlAlt && xapp->WinMask) {
if (supered) {
xm[1] = xapp->WinMask | (xm[0] & ~(ControlMask | xapp->AltMask));
}
unsigned short mods[8];
Expand Down Expand Up @@ -149,7 +151,7 @@ void WMKey::grab(int handle) {
mods[count++] = xm[k] | xapp->NumLockMask;
mods[count++] = xm[k] | LockMask | xapp->NumLockMask;
}
if (hasbits(mod, kfAlt | kfCtrl) && modSuperIsCtrlAlt && xapp->WinMask) {
if (supered) {
unsigned short wmod = xm[k];
wmod &= ~(ControlMask | xapp->AltMask);
wmod |= xapp->WinMask;
Expand All @@ -168,12 +170,26 @@ void WMKey::grab(int handle) {
}

bool WMKey::operator==(const XKeyEvent& x) const {
return (x.keycode == kc[0] && KEY_MODMASK(x.state) == xm[0])
|| (x.keycode == kc[1] && KEY_MODMASK(x.state) == xm[1]);
for (int i = 0; i < 2; ++i) {
if (x.keycode == kc[i]) {
const unsigned km = KEY_MODMASK(x.state);
if (km == xm[i])
return true;
if (supered && hasbit(km, xapp->WinMask)) {
if (((km & ~xapp->WinMask) | ControlMask | xapp->AltMask) == xm[i])
return true;
}
}
}
return false;
}

bool WMKey::operator==(const XButtonEvent& b) const {
return (key == b.button - Button1 + XK_Pointer_Button1
&& mod == desktop->VMod(KEY_MODMASK(b.state)));
if (key == b.button - Button1 + XK_Pointer_Button1) {
const unsigned km = KEY_MODMASK(b.state);
if (km == xm[0] || km == xm[1])
return true;
}
return false;
}

7 changes: 4 additions & 3 deletions src/wmkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ struct WMKey {
unsigned short mod, xm[2];
unsigned char kc[2];
bool initial;
bool supered;

WMKey() : name(""), key(0), mod(0), initial(true) {
WMKey() : name(""), key(0), mod(0), initial(true), supered(false) {
xm[0] = xm[1] = kc[0] = kc[1] = 0;
}
WMKey(char* s) : name(s), key(0), mod(0), initial(false) {
WMKey(char* s) : name(s), key(0), mod(0), initial(false), supered(false) {
xm[0] = xm[1] = kc[0] = kc[1] = 0;
parse();
}
WMKey(unsigned k, unsigned short m, const char* s) :
name(s), key(k), mod(m), initial(true) {
name(s), key(k), mod(m), initial(true), supered(false) {
xm[0] = xm[1] = kc[0] = kc[1] = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wmprog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class MenuProgSwitchItems: public ISwitchItems {
virtual bool isKey(const XKeyEvent& key) override {
KeySym k = xapp->keyCodeToKeySym(key.keycode);
unsigned m = KEY_MODMASK(key.state);
unsigned mod = desktop->VMod(m);
unsigned mod = YWindow::VMod(m);
return k == this->key && mod == this->mod;
}
unsigned modifiers() override {
Expand Down
2 changes: 1 addition & 1 deletion src/ywindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class YWindow : protected YWindowList, private YWindowNode {
void setPointer(Cursor pointer);
void grabKeyM(unsigned key, unsigned modifiers);
void grabKey(unsigned key, unsigned modifiers);
unsigned VMod(unsigned modifiers);
static unsigned VMod(unsigned modifiers);
void grabButtonM(int button, unsigned modifiers);
void grabButton(int button, unsigned modifiers);

Expand Down

0 comments on commit 26751c7

Please sign in to comment.