Skip to content

Commit

Permalink
When a key event is handled, don't propagate it further.
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsbers committed Jul 2, 2024
1 parent e4a32f3 commit cdbdbab
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions src/wmwinlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,46 +188,34 @@ void WindowListBox::actionPerformed(YAction action, unsigned int modifiers) {
}

bool WindowListBox::handleKey(const XKeyEvent &key) {
const KeySym k = keyCodeToKeySym(key.keycode);
const int m = KEY_MODMASK(key.state);

if (key.type == KeyPress) {
KeySym k = keyCodeToKeySym(key.keycode);
int m = KEY_MODMASK(key.state);
fKeyPressed = k;

switch (k) {
case XK_F10:
case XK_Menu:
if (k != XK_F10 || m == ShiftMask) {
if (hasSelection()) {
YMenu* windowListPopup = windowList->getWindowListPopup();
enableCommands(windowListPopup);
windowListPopup->popup(nullptr, nullptr, nullptr,
key.x_root, key.y_root,
YPopupWindow::pfCanFlipVertical |
YPopupWindow::pfCanFlipHorizontal |
YPopupWindow::pfPopupMenu);
} else {
YMenu* windowListAllPopup = windowList->getWindowListAllPopup();
windowListAllPopup->popup(nullptr, nullptr, nullptr,
key.x_root, key.y_root,
YPopupWindow::pfCanFlipVertical |
YPopupWindow::pfCanFlipHorizontal |
YPopupWindow::pfPopupMenu);
}
}
break;
case XK_Delete:
{
if (m & ShiftMask)
actionPerformed(actionKill, key.state);
else
actionPerformed(actionClose, key.state);
if (k == XK_Menu || (k == XK_F10 && m == ShiftMask)) {
YMenu* menu;
if (hasSelection()) {
menu = windowList->getWindowListPopup();
enableCommands(menu);
} else {
menu = windowList->getWindowListAllPopup();
}
break;
menu->popup(nullptr, nullptr, nullptr, key.x_root, key.y_root,
YPopupWindow::pfCanFlipVertical |
YPopupWindow::pfCanFlipHorizontal |
YPopupWindow::pfPopupMenu);
return true;
}
else if (k == XK_Delete) {
if (m & ShiftMask)
actionPerformed(actionKill, key.state);
else
actionPerformed(actionClose, key.state);
return true;
}
}
else if (key.type == KeyRelease) {
KeySym k = keyCodeToKeySym(key.keycode);
int m = KEY_MODMASK(key.state);
if (k == XK_Escape && k == fKeyPressed && m == 0) {
windowList->handleClose();
return true;
Expand Down

0 comments on commit cdbdbab

Please sign in to comment.