Commit Graph

87 Commits (master)

Author SHA1 Message Date
Martin Gräßlin d02c325a61 Refactor input event handling to be based on filters
The main motivation of this change is to remove the spaghetti code
in the input event handling. Each area of processing (e.g. lock screen)
is moved into a dedicated event filter. Processing the events now just
means calling a virtual method on each of the filters. As soon as the
method returns true, the processing is stopped.

This allows to have the security for the lock screen just in one place:
whenever the screen is locked the event filter can ensure that the events
are not further processed.

Currently all event filters are implemented directly in input.cpp and
are registered by InputRedirection itself. In future it would be better
to have those moved to the area they belong to and get registered from
there. E.g. the input filter for EffectsHandlerImpl should be created
by EffectsHandlerImpl. This requires an improved API to ensure that the
filters are installed in the correct sequence.
2016-02-11 08:09:10 +01:00
Martin Gräßlin 357e082d7a Drop InputRedirection::toXPointerButton
Unused code is unused.
2016-02-09 12:39:55 +01:00
Martin Gräßlin ea77d32259 [libinput] Make signals queueable
* Declare and register enums as metatypes
* quint32 instead of uint32_t
2015-11-03 10:26:01 +01:00
Martin Gräßlin cd254c8f47 [wayland] Configure key repeat
We take the configuration from the kcminputrc config file, group
keyboard (see plasma-desktop.git/kcms/keyboard/kcmmisc.cpp)

The values are only used for libinput. For backends providing input
events we expect to get repeated key events anyway.
2015-09-15 10:29:06 +02:00
Martin Gräßlin 66ad99787c Add signal InputRedirection::keyStateChanged
Complements all other signals for internal usage that there is an
input event.

Needed by e.g. DPMS implementation to re-enable the outputs.
2015-09-10 14:31:46 +02:00
Martin Gräßlin 07414e88a5 Add support for modifier only shortcuts on Wayland
On popular demand!

This change tracks how modifiers are used and detects a modifier only
key press/release. That is:
* no other key is pressed when the modifier gets pressed
* no other key gets pressed before the modifier gets released

If such a press/release is detected, we call a configurable dbus call.
The possible shortcuts can be configured in kwinrc, group
"ModifierOnlyShortcuts". The following keys are supported:
* Shift
* Control
* Alt
* Meta

As value it takes a QStringList (comma seperated string) with
service,path,interface,method,additionalargs

E.g. to invoke Desktop Grid effect on Meta key:

[ModifierOnlyShortcuts]
Meta=org.kde.kglobalaccel,/component/kwin/,org.kde.kglobalaccel.Component,invokeShortcut,ShowDesktopGrid

I do not intend to add a config interface for it. Let's keep it a hidden
way.

REVIEW: 124954
2015-09-09 08:58:43 +02:00
Martin Gräßlin da1e063a37 Drop cmakedefine HAVE_XKB
No longer needed, we always depend on xkbcommon now.
2015-08-12 11:39:19 +02:00
Martin Gräßlin 3beff66aca [wayland] Announce modifier changes to clients 2015-07-13 14:25:09 +02:00
Martin Gräßlin 3041a7c32d [wayland] Add a plugin for kglobalaccel
The KGlobalAccelD which gets created by KWin needs a plugin for the
platform specific parts. This change introduces such a plugin. It's
linked against kwin so that it can integrate with the core.

On enable the plugin registers itself in the InputRedirection and
GlobalShortcutsManager checks the plugin whether a shortcut got
triggered.

As the loading of the plugin must happen after InputRedirection is
fully created a dedicated init method is added to InputRedirection.

REVIEW: 124187
2015-07-02 13:42:29 +02:00
Martin Gräßlin 01ac0abfd7 [wayland] Change keyboard focus window when active window changes
We used to change it only on keypresses. This resulted in the strange
situation that e.g. the input method virtual keyboard doesn't show up
until one presses a real key, because e.g. maliit only activates the
keyboard if there is an active focus object in the Qt application.
2015-06-13 17:54:08 +02:00
Martin Gräßlin 7f0758b85f [wayland] Handle pointer events for internal windows
If there is a visible internal window it gets the pointer events.
The assumption is that the last created internal window is the top
most in stacking order.
2015-06-06 17:43:13 +02:00
Martin Gräßlin 06fc00b4a9 [wayland] Support pointer warping in the backends
The X11 backend can warp the pointer.
2015-06-06 17:43:13 +02:00
Martin Gräßlin 74c111ef88 [wayland] Add support for pointer warping in InputRedirectionCursor
With libinput we do can support warping pointers, let's do it.
2015-06-06 17:43:13 +02:00
Martin Gräßlin 4a1288b0c9 [wayland] Update cursor image from current decoration 2015-06-06 17:43:12 +02:00
Martin Gräßlin 1edd689293 Handle interaction with window decoration directly in InputRedirection
So far input events were sent through Xwayland which is not needed as
we have all information available. Even more it had the pointer surface
on the wrong window when interacting with decorations as it was on the
window and not on the decoration.
2015-06-06 17:43:12 +02:00
Martin Gräßlin 8b3be23032 Don't update focused pointer window on pointer movement while button is pressed
If a button is pressed all mouse events should go to the current surface
regardless of whether the pointer is on top of it or not.
2015-06-06 17:43:12 +02:00
Martin Gräßlin 3b4c508ee3 [wayland] Pass xkb keymap to Wayland server
When creating a new xkb keymap we need to pass it to the Wayland server's
seat. As the Wayland protocol expects the keymap as a file descriptor, a
temporary file is created, mmapped and the keymap written into it. As
the Wayland protocol doesn't restrict how long the file descriptor needs
to be valid we keep any created temporary file around till the
InputRedirection gets destroyed.
2015-05-28 10:17:41 +02:00
Martin Gräßlin efa0500313 [libinput] Bind libinput support to VirtualTerminal
This change is motivated by the fact that we need to suspend libinput
before switching the virtual terminal. Also we don't want to take over
libinput if we do not have a VirtualTerminal created - in windowed mode
we don't want libinput to be started. So binding it to the backends which
create the VirtualTerminal makes sense.

The KWin::Application gains a new signal virtualTerminalCreated which is
emitted from VirtualTerminal once it's properly setup. This is used by
Input to create Libinput integration instead of binding it to logind.

Furthermore Libinput gets suspended when the VirtualTerminal reports that
it is no longer active. For re-activation we still just use logind's
session active property.
2015-04-24 12:03:19 +02:00
Martin Gräßlin 634fd68446 Ensure screens are created before fully setting up libinput
Parts rely on screens being available but input might be created
before screens are available. Thus connect to signal and delay.
2015-04-01 11:05:45 +02:00
Martin Gräßlin 7a96c3ee46 [input] Disconnect the logind connection once setupLibInput is called
Don't want it to be called again if we lose session control.
2015-04-01 11:05:45 +02:00
Martin Gräßlin 2a39e6290b [input] Try updating the modifiers after each key press
TODO: send new modifier information to wayland server.
2015-04-01 11:05:45 +02:00
Martin Gräßlin b824175e05 [input] Set a default xkb modifier map 2015-04-01 11:05:45 +02:00
Martin Gräßlin 36f987198d [wayland] Add support for processing touch events
InputRedirection gains basic support for processing touch events which
are delegated to KWayland::Server.

WaylandBackend accepts touch events from KWayland::Client and delegates
them to the InputRedirection.
2015-03-25 14:50:14 +01:00
Martin Gräßlin c29f96665d [wayland] Pass pointer input events to SeatInterface
Pointer events are no longer sent through the methods on Toplevel,
but properly sent through the SeatInterface. This has the advantage
that SeatInterface properly tracks which is the focused pointer surface
and does not need to use the xtest extension.
2015-03-17 10:20:19 +01:00
Martin Gräßlin 857219546f Update x11Time when a global shortcut is pressed
KGlobalAccel sets the timestamp as a property and we need to set our
x11Time to it otherwise following keyboard grabs might fail.

Requires 61e2a156678eef033b2629f7c72530dc78d7c3ac in kglobalaccel.
2015-02-25 08:15:53 +01:00
Martin Gräßlin da5ee2ba93 Add sanity checks before updating pointer position and on screen changes
We don't want the cursor to leave the visible area, so better check that
the cursor doesn't leave it. And when the screens changes better check
that the cursor is still on a visible screen. If not: put it back to the
center of the closest screen.
2014-10-20 14:51:24 +02:00
Martin Gräßlin a918591fef Use Logind to open/close devices needed by libinput
With libinput we have the problem that we need to have privileges to
open the device files. In order to not need wrappers or suid bits, we
use logind. This means that kwin_wayland has to be the session controler.

A LogindIntegration is added to connect to logind and wrap the dbus
calls. This is based on the logind integration done for ksld in
ksmserver. The LogindIntegration is started by Workspace and the
InputRedirection tries to become the session controller and starts the
libinput integration only after this succeeded.
2014-10-20 14:51:24 +02:00
Alex Richardson 3d9abbe6ff Don't include xkbcommon/xkbcommon.h in input.h, forward-declare instead
Some systems (e.g. openSuSE) don't install the xkbcommon header into
/usr/include/xkbcommon/xkbcommon.h (which is always in the include path),
but instead into a subdirectory, which is in the openSuSE case
/usr/include/pkg/libxkbcommon/xkbcommon/xkbcommon.h. This means that e.g.
kcm_kwinrules will not compile there since it includes input.h

REVIEW: 117069
2014-03-28 09:42:02 +01:00
Martin Gräßlin 89c2f2bf02 Support for global pointer axis activation
Just as pointer buttons...
2014-03-19 14:14:56 +01:00
Martin Gräßlin 28406d153d Support for global pointer shortcut activation
Sharing most of the code with keyboard shortcuts allowing to trigger a
QAction with holding modifiers and clicking a mouse button.
2014-03-19 14:14:56 +01:00
Martin Gräßlin b274fb9297 InputRedirection emits a signal when the modifiers change
Used by Cursor to properly emit the mouseChanged signal which for
historic reasons includes the keyboard modifiers.

Again some fiddling around with the autotests and kcmrules needed to
make it compile. This needs improvement!
2014-03-19 14:14:56 +01:00
Martin Gräßlin 24b23dfc01 Beginning of global shortcut handling inside KWin
A new GlobalShortcutsManager is introduced which is responsible for
holding the registered shortcuts and triggering the matching action.

The InputRedirection checks with the GlobalShortcutManager whether a key
press event triggers a global shortcut and stops processing the event in
that case.

At the moment the GlobalShortcutsManager only supports the very basics
for KWin internal usage. External applications can not yet make usage of
the global shortcut system inside KWin.
2014-03-19 14:14:56 +01:00
Martin Gräßlin 6baf794f88 InputRedirection for keyboard events
Major new functionality is xkbcommon support. InputRedirection holds an
instance to a small wrapper class which has the xkb context, keymap and
state. The keymap is initialied from the file descriptor we get from the
Wayland backend.

InputRedirection uses this to translate the keycodes into keysymbols and
to QString and to track the modifiers as provided by the
Qt::KeybordModifiers flags.

This provides us enough information for internal usage (e.g. pass through
effects if they have "grabbed" the keyboard).

If KWin doesn't filter out the key events, it passes them on to the
currently active Client respectively an unmanaged on top of the stack.
This needs still some improvement (not each unmanaged should get the
event). The Client/Unmnaged still uses xtest extension to send the key
events to the window. So keylogging is still possible.
2014-03-18 09:00:50 +01:00
Martin Gräßlin 7d48b92e2b Redirect pointer events to the Toplevel
InputRedirection keeps track of the Toplevel which is currently the one
which should get pointer events. This is determined by checking whether
there is an Unmanaged or a Client at the pointer position. At the moment
this is still slightly incorrect, e.g. pointer grabs are ignored,
unmanaged are not checked whether they are output only and input shapes
are not yet tracked.

The pointer events are delivered to the Toplevel as:
* enter
* leave
* move
* button press
* axis event

Nevertheless move events are still generated in InputRedirection through
xcb test for simplicity. They are still send to the root window, so all
windows get mouse move.

Button press and axis are generated only in the implementations of the
event handlers and delivered directly to the window, so other windows
won't see it.
2014-03-18 09:00:50 +01:00
Martin Gräßlin 7523c1e7d7 Integrate KWin::Cursor with InputRedirection
New inheriting class which uses the InputRedirection to track the cursor
position. It doesn't support warping of cursor.

This introduces a slight dependency loop in the startup. Cursor needs to
be created after the WaylandBackend to ensure that the operation mode is
set correctly. But the WaylandBackend itself is accessing Cursor. It
should be safe as inside the WaylandBackend it's only accessed after
callbacks.
2014-03-18 09:00:49 +01:00
Martin Gräßlin 6619faa6ac Pass pointer events through the effect system
InputRedirection forwards pointer events (currently motion, press and
release) through the EffectsHandlerImpl for the case that an effect has
intercepted pointer events.

If the KWin operation mode is not X11 only, the window for intercepting
the mouse events is no longer created.
2014-03-18 09:00:49 +01:00
Martin Gräßlin 1617deabb8 Introduce the beginning of an InputRedirection class
So far this new class is not yet doing much. The WaylandBackend forwards
the received pointer events to this InputRedirection class. From there
signals are emitted to inform internal areas about the changes first.

The events are currently forwarded to X through the xtest extension. This
will be removed in future. Input will be forwarded directly to the
surface which wants it (no matter whether X11 or Wayland).
2014-03-18 09:00:49 +01:00