diff --git a/tabbox/tabbox.cpp b/tabbox/tabbox.cpp --- a/tabbox/tabbox.cpp +++ b/tabbox/tabbox.cpp @@ -54,14 +54,6 @@ #include #include #include -#include -// X11 -#include -#include -// xcb -#include - -// specify externals before namespace namespace KWin { @@ -910,100 +902,11 @@ m_tabBox->grabbedKeyEvent(event); } -struct KeySymbolsDeleter +static bool areModKeysDepressed(const QKeySequence &seq) { - static inline void cleanup(xcb_key_symbols_t *symbols) - { - xcb_key_symbols_free(symbols); - } -}; - -/** - * Handles alt-tab / control-tab - **/ -static bool areKeySymXsDepressed(bool bAll, const uint keySyms[], int nKeySyms) { - - qCDebug(KWIN_TABBOX) << "areKeySymXsDepressed: " << (bAll ? "all of " : "any of ") << nKeySyms; - - Xcb::QueryKeymap keys; - - QScopedPointer symbols(xcb_key_symbols_alloc(connection())); - if (symbols.isNull() || !keys) { + if (seq.isEmpty()) { return false; } - const auto keymap = keys->keys; - - for (int iKeySym = 0; iKeySym < nKeySyms; iKeySym++) { - uint keySymX = keySyms[ iKeySym ]; - xcb_keycode_t *keyCodes = xcb_key_symbols_get_keycode(symbols.data(), keySymX); - if (!keyCodes) { - continue; - } - xcb_keycode_t keyCodeX = keyCodes[0]; - free(keyCodes); - if (keyCodeX == XCB_NO_SYMBOL) { - continue; - } - int i = keyCodeX / 8; - char mask = 1 << (keyCodeX - (i * 8)); - - // Abort if bad index value, - if (i < 0 || i >= 32) - return false; - - qCDebug(KWIN_TABBOX) << iKeySym << ": keySymX=0x" << QString::number(keySymX, 16) - << " i=" << i << " mask=0x" << QString::number(mask, 16) - << " keymap[i]=0x" << QString::number(keymap[i], 16); - - // If ALL keys passed need to be depressed, - if (bAll) { - if ((keymap[i] & mask) == 0) - return false; - } else { - // If we are looking for ANY key press, and this key is depressed, - if (keymap[i] & mask) - return true; - } - } - - // If we were looking for ANY key press, then none was found, return false, - // If we were looking for ALL key presses, then all were found, return true. - return bAll; -} - -static bool areModKeysDepressedX11(const QKeySequence &seq) -{ - uint rgKeySyms[10]; - int nKeySyms = 0; - int mod = seq[seq.count()-1] & Qt::KeyboardModifierMask; - - if (mod & Qt::SHIFT) { - rgKeySyms[nKeySyms++] = XK_Shift_L; - rgKeySyms[nKeySyms++] = XK_Shift_R; - } - if (mod & Qt::CTRL) { - rgKeySyms[nKeySyms++] = XK_Control_L; - rgKeySyms[nKeySyms++] = XK_Control_R; - } - if (mod & Qt::ALT) { - rgKeySyms[nKeySyms++] = XK_Alt_L; - rgKeySyms[nKeySyms++] = XK_Alt_R; - } - if (mod & Qt::META) { - // It would take some code to determine whether the Win key - // is associated with Super or Meta, so check for both. - // See bug #140023 for details. - rgKeySyms[nKeySyms++] = XK_Super_L; - rgKeySyms[nKeySyms++] = XK_Super_R; - rgKeySyms[nKeySyms++] = XK_Meta_L; - rgKeySyms[nKeySyms++] = XK_Meta_R; - } - - return areKeySymXsDepressed(false, rgKeySyms, nKeySyms); -} - -static bool areModKeysDepressedWayland(const QKeySequence &seq) -{ const int mod = seq[seq.count()-1] & Qt::KeyboardModifierMask; const Qt::KeyboardModifiers mods = input()->modifiersRelevantForGlobalShortcuts(); if ((mod & Qt::SHIFT) && mods.testFlag(Qt::ShiftModifier)) { @@ -1021,16 +924,6 @@ return false; } -static bool areModKeysDepressed(const QKeySequence& seq) { - if (seq.isEmpty()) - return false; - if (kwinApp()->shouldUseWaylandForCompositing()) { - return areModKeysDepressedWayland(seq); - } else { - return areModKeysDepressedX11(seq); - } -} - void TabBox::navigatingThroughWindows(bool forward, const QKeySequence &shortcut, TabBoxMode mode) { if (!m_ready || isGrabbed() || !Workspace::self()->isOnCurrentHead()) {