Properly support key events in TabBox over InputRedirection

Forward all key press events to the TabBox if it is currently grabbed and
connect the TabBox to the modifiers changed signal for checking if TabBox
should be ended.
This commit is contained in:
Martin Gräßlin 2013-07-10 13:20:43 +02:00
parent b274fb9297
commit 38201a8295
3 changed files with 36 additions and 0 deletions

View file

@ -21,6 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "client.h"
#include "effects.h"
#include "globalshortcuts.h"
#ifdef KWIN_BUILD_TABBOX
#include "tabbox/tabbox.h"
#endif
#include "unmanaged.h"
#include "workspace.h"
// KDE
@ -258,6 +261,14 @@ void InputRedirection::processKeyboardKey(uint32_t key, InputRedirection::Keyboa
#if HAVE_XKB
m_xkb->updateKey(key, state);
// TODO: pass to internal parts of KWin
#ifdef KWIN_BUILD_TABBOX
if (TabBox::TabBox::self()->isGrabbed()) {
if (state == KWin::InputRedirection::KeyboardKeyPressed) {
TabBox::TabBox::self()->keyPress(m_xkb->modifiers() | m_xkb->toQtKey(m_xkb->toKeysym(key)));
}
return;
}
#endif
if (effects && static_cast< EffectsHandlerImpl* >(effects)->hasKeyboardGrab()) {
const xkb_keysym_t keysym = m_xkb->toKeysym(key);
// TODO: start auto-repeat

View file

@ -470,6 +470,8 @@ TabBox::TabBox(QObject *parent)
connect(&m_delayedShowTimer, SIGNAL(timeout()), this, SLOT(show()));
connect(Workspace::self(), SIGNAL(configChanged()), this, SLOT(reconfigure()));
QDBusConnection::sessionBus().registerObject(QStringLiteral("/TabBox"), this, QDBusConnection::ExportScriptableContents);
connect(input(), &InputRedirection::keyboardModifiersChanged, this, &TabBox::modifiersChanged);
}
TabBox::~TabBox()
@ -1525,6 +1527,28 @@ void TabBox::keyRelease(const xcb_key_release_event_t *ev)
}
}
void TabBox::modifiersChanged(Qt::KeyboardModifiers mods)
{
if (m_noModifierGrab || !(!mods)) {
return;
}
if (m_tabGrab) {
bool old_control_grab = m_desktopGrab;
accept();
m_desktopGrab = old_control_grab;
}
if (m_desktopGrab) {
bool old_tab_grab = m_tabGrab;
int desktop = currentDesktop();
close();
m_tabGrab = old_tab_grab;
if (desktop != -1) {
setCurrentDesktop(desktop);
VirtualDesktopManager::self()->setCurrent(desktop);
}
}
}
int TabBox::nextDesktopStatic(int iDesktop) const
{
DesktopNext functor;

View file

@ -257,6 +257,7 @@ private:
private Q_SLOTS:
void reconfigure();
void globalShortcutChanged(QAction *action, const QKeySequence &seq);
void modifiersChanged(Qt::KeyboardModifiers mods);
private:
TabBoxMode m_tabBoxMode;