kwin/plugins/platforms/x11/standalone/xinputintegration.h
Martin Gräßlin 66d1a0cc7a Add event filter for key press/release events while KWin grabbed keyboard on root window
Summary:
The modifier-only-shortcuts break as soon as KWin grabs the keyboard
(e.g. alt+tab, present windows, etc.). The investigation shows that in
that case KWin does not get any raw key events any more and thus gets
confused about the state of the hold modifiers. E.g. alt+tab has the
alt key pressed, but we miss the release as the keyboard is grabbed.

This change addresses the problem by installing an additional event
filter for key press and release event which only filters for key events
on the root window. That way we can be sure that it only operates when
KWin grabbed the keyboard on the root window.

Note: the problem only exists when grabbing on the root window. If the
grab is on another window (e.g. moving a window) we still do get all
events.

The problem also seems to not happen if another application grabbed
keys on the root window. E.g. for key combinations grabbed by
kglobalaccel the correct sequence of key press/release as raw events
are reported. Also while the screen is locked the evemts are reported
and kscreenlocker grabs the keyboard on the root window.

Test Plan:
Used Alt+Tab and Present Windows and tried to activate launcher
afterwards.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2980
2016-10-10 16:59:06 +02:00

68 lines
1.8 KiB
C++

/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_XINPUTINTEGRATION_H
#define KWIN_XINPUTINTEGRATION_H
#include <QObject>
#include <QPointer>
#include <QScopedPointer>
namespace KWin
{
class XInputEventFilter;
class XKeyPressReleaseEventFilter;
class X11Cursor;
class Xkb;
class XInputIntegration : public QObject
{
Q_OBJECT
public:
explicit XInputIntegration(QObject *parent);
virtual ~XInputIntegration();
void init();
void startListening();
bool hasXinput() const {
return m_hasXInput;
}
void setCursor(X11Cursor *cursor);
void setXkb(Xkb *xkb);
private:
bool m_hasXInput = false;
int m_xiOpcode = 0;
int m_majorVersion = 0;
int m_minorVersion = 0;
QPointer<X11Cursor> m_x11Cursor;
// TODO: QPointer
Xkb *m_xkb = nullptr;
QScopedPointer<XInputEventFilter> m_xiEventFilter;
QScopedPointer<XKeyPressReleaseEventFilter> m_keyPressFilter;
QScopedPointer<XKeyPressReleaseEventFilter> m_keyReleaseFilter;
};
}
#endif