Commit Graph

254 Commits (a15966c72383f7dd7793158f3de8a5eecd6eb9aa)

Author SHA1 Message Date
Martin Gräßlin 521470b04a Improve keyboard handling for internal windows
So far the key handler in the InternalWindowEventFilter used the
PointerInputRedirection's internal window. This had the result that
key events were only delivered to an internal window if the window
was under the cursor.

This change tries sending the event to the latest created and visible
window. Thus e.g. with nested context menus it goes to the current
sub menu as expected. The return value of sendEvent is used to filter
out the event.
2016-02-17 13:34:24 +01:00
Martin Gräßlin 46e3da297c Set timestamp on WaylandSeat for key event in LockScreenFilter
Was missing.
2016-02-16 17:14:28 +01:00
Martin Gräßlin 4f66f324d7 LockScreenEventFilter passes key events to KSldApp
The KSldApp needs all key events to be able to invoke the whitelisted
global shortcuts.

Reviewed-By: Bhushan Shah
2016-02-16 13:01:32 +01:00
Martin Gräßlin 57b11f8429 [backends/drm] Use an InputEventFilter to reenable outputs
So far the DrmOutput connected to all input events when going into
power saving. As we now have the input filters it's better to just
install a filter when an output goes into powersave and remove the
input filter again when all outputs are enabled again.

To make this work InputRedirection gains a new method to add a new
filter as the first filter. This is a potentially dangerous method
as it allows to have a filter before LockScreenFilter gets the
events. But in case of DPMS it's something we actually want.

A nice new feature possible with the input filter is that we can
filter out the event which re-enables the outputs. Thus when getting
on a system with output off and screen locked, the first key hit
doesn't go to the lock screen.

Reviewed-By: Bhushan Shah
BUG: 341201
Fixed-in: 5.6.0 (Wayland-only)
2016-02-15 15:53:43 +01:00
Martin Gräßlin 4e32dcfbfe Cleanup includes of input.(h|cpp) a little bit 2016-02-15 13:51:36 +01:00
Martin Gräßlin 849d17519c Split keyboard related functionality from InputRedirection
Similar to the change regarding pointer and touch a
KeyboardInputRedirection is created. The Xkb class is also moved to
the new files keyboard_input.h and keyboard_input.cpp.

Just like in the case of PointerInputRedirection no signals are added,
but the existing signals in InputRedirection are directly invoked.
2016-02-15 13:42:48 +01:00
Martin Gräßlin 59dc3816b4 Add missing override to LockScreenFilter 2016-02-15 10:36:42 +01:00
Martin Gräßlin b8f8b2d8a0 Split out touch related functionality from InputRedirection
Similar to c044ad98be this change splits
all touch handling related functionality into a dedicated class called
TouchInputRedirection.
2016-02-15 09:36:59 +01:00
Martin Gräßlin c044ad98be Split out pointer related handling from InputRedirection
All pointer related code is moved into a new class called
PointerInputRedirection.

The main idea is to simplify the code and make it easier to maintain.
Therefore also a few changes in the setup were performed:
* before init() is called, no processing is performed
* init() is only called on Wayland and after Workspace is created
* init property is set to false once Workspace or WaylandServer is
  destroyed

Thus code can operate on the following assumptions:
* Workspace is valid
* WaylandServer is valid
* ScreenLocker integration is used

The various checks whether there is a waylandServer() and whether
there is a seat are no longer needed.

Some of the checks have been reordered to be faster in the most common
use case of using libinput. E.g. whether warping is supported is first
evaluated by the variable bound to whether we have libinput and only if
that is false the backend is checked.

The new class doesn't have signals but invokes the signals provided
by InputRedirection. I didn't want to add new signals as I consider
them as not needed. The areas in KWin needing those signals should
be ported to InputEventFilters.
2016-02-12 13:38:26 +01:00
Martin Gräßlin b8fcfbb8fc Drop bool InputRedirection::areButtonsPressed() const
Unused code, no longer needed as we have it in the events.
2016-02-11 16:30:58 +01:00
Martin Gräßlin 9b917a20fe ScreenEdgeInputFilter for checking whether a screenedge gets activated
So far the area based edges connected directly to global pointer pos
changed in InputRedirection. This didn't allow proper checking whether
the edge was triggered (e.g. missing timestamp).

This change merges the functionality into the new input filter mechanism.
There is now a dedicated input filter for screen edges, installed after
lock screen and before effects. It always passes events on, but also passes
all events through ScreenEdges to handle the activation. As it's installed
after the lock screen filter we don't need to check for screen locked any
more.

The code is now similar strucutured to the existing X11 based variants
and maybe will allow to also merge the X11 variant with the new one.
2016-02-11 15:56:40 +01:00
Martin Gräßlin a51171720e Improve updating the pointer position after screen changes
The logic should not be tied to whether libinput is used. It's relevant
for all Wayland backends whether they use libinput or not.

In addition this should generate a pointer motion event, so that proper
processing can take place and we get proper pointer enter events.
2016-02-11 14:27:30 +01:00
Martin Gräßlin 5b5a966e48 Process pointer warped positions like normal updates
If the pointer is warped the position change should be treated like
a change coming from the input device. Our normal processing should
take place.

A problem in this case is the timestamp to pass to the wayland server.
Normally our timestamps come from the backend/libinput and we don't
know the next one. As an intermediate solution we just use the last
timestamp on the seat. In future a solution could be to not use the
backend's timestamp at all, but have our own timestamp handling.
2016-02-11 12:56:26 +01:00
Martin Gräßlin c8c33ae398 Implement lock screen security for touch events
When the screen gets locked any existing sequence gets cancelled
and the focused touch surface gets reset. While screen is locked
touch events are filtered to only go to lock screen or input methods.

Test case is added for touch event during lock screen.

Reviewed-By: Bhushan Shah
2016-02-11 08:09:10 +01:00
Martin Gräßlin a311f9bfda Add check for lock screen in InputRedirection::updateKeyboardWindow
Instead of only making the active client the focused keyboard surface,
the method now also performs the lock screen security restriction.

Also just like udatePointerWindow the method becomes public, so that
it can be used from the LockScreenEventFilter and is connected for
lock state changes. This means as soon as the screen locks the current
focused keyboard surface will get a leave event and get an enter event
once the screen unlocks.

The auto test is adjusted to verify these new conditions.

Reviewed-By: Bhushan Shah
2016-02-11 08:09:10 +01:00
Martin Gräßlin 16a33f662b Improve lock screen interaction for pointer in InputRedirection
InputRedirection connects to lockStateChanged to udate the current
pointer window. This way we can ensure that the current pointer
surface gets reset as soon as the screen locks (c.f. the expect
fail in the autotest) and also that it restores to the surface under
the mouse once the screen is unlocked.

The relevant code was not yet lock screen aware and performed an
early exit. Part of the code was fine, e.g. findToplevel is lock
screen aware. So this change adjusts the methods for updating the
internal window and decoration to be lock screen aware, that is they
get reset. With that updatePointerWindow is also lock screen aware.

Thus the LockScreenFilter can also use updatePointerWindow just like
the normal handling and does not need to reimplement parts of it. As
it now relies on other code being correct it has an additional check
to verify that the current pointer surface is a surface which is allowed
to get events. If it isn't the events are not forwarded.

Reviewed-By: Bhushan Shah
2016-02-11 08:09:10 +01:00
Martin Gräßlin 142e826191 Clear touch ids when canceling a touch sequence
Before calling touchUp would hit an abort in KWayland::Server.
2016-02-11 08:09:10 +01:00
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 a47b6f9435 Unset focused keyboard surface when screen is locked
If the screen is locked and no lock screen is shown yet we unset
the focused keyboard surface on key event. Similar we restore when
screen is unlocked.

This should hopefully fix the broken lockscreen unit test which hits
the special condition as the greeter doesn't show up on build.kde.org.
2016-02-09 08:45:29 +01:00
Martin Gräßlin d83780fea3 Fix axis direction for processing global axis shortcuts
It mixed up horizontal and vertical.
2016-02-04 09:05:38 +01:00
Martin Gräßlin 5e782ac93e Set focusedPointerSurface to null when screen is locked and no greeter window
We want to get leave events on the previously focused surface when
the screen is locked.
2016-02-02 10:21:42 +01:00
Martin Gräßlin bdb423da3d Only send key press events to the moving client
The invoked method is called keyPressEvent, thus it should not get
key release events. Before each key event was handled twice.
2016-01-29 09:52:01 +01:00
Martin Gräßlin e61ad65f10 InputRedirection::updatePointerDecoration operates on AbstractClient for deco
As decoration and decoratedClient is now in AbstractClient we don't need
to keep it as Client specific code.
2015-12-18 16:41:49 +01:00
Martin Gräßlin 55bae74aae Specify inputTransformation in Toplevel
InputRedirection uses the inputTransformation() to pass to SeatInterface
for focused pointer surface. This prepares for proper input
transformation including scaling and rotation.
2015-12-18 15:37:46 +01:00
Martin Gräßlin a055e2de82 Only compile VirtualTerminal if libinput is found
The implementation of VirtualTerminal is too linux specific and doesn't
compile on e.g. freebsd. Currently the most usage is in combination with
libinput. Only usage is:
* libinput related functionality in InputRedirection
* backends without custom input handling

Thus binding the feature to whether libinput is available is currently
the least invasive approach to get it compile on non-Linux.

In the long run this needs a different solution. The functionality
provided by VirtualTerminal is required and without the backends don't
work. It's needed to get notified about VT switches, when KWin needs to
stop rendering. So a solution for non-Linux needs to be found if
non-Linux wants to provide Wayland in future.

REVIEW: 126182
2015-12-01 07:57:39 +01:00
Martin Gräßlin 4d883a9cda Ensure pointer position is updated before screen locker enforcement
We need to update the pointer position, also if the screen is locked.
Otherwise the pointer doesn't move on the locked screen with libinput.

In addition we need to use the m_globalPointer for finding the correct
lock screen window as updatePointerWindow also does sanity checking on
the coordinates.

Also we need to introduce security checks where we use the signal.

REVIEW: 126103
2015-11-18 14:42:23 +01:00
Bhushan Shah 42ddf685c1 [InputRedirection] Don't crash on invalid Toplevel
Reviewed-By: Martin Gräßlin
2015-11-16 20:57:23 +05:30
Bhushan Shah e5a0af1589 [InputRedirection] Check if workspace is valid before accessing it
Reviewed-By: Martin Gräßlin
2015-11-16 16:20:29 +05:30
Bhushan Shah e5518dffe2 [wayland] Add some restrictions for lockscreen
When screen is locked,

- No window other then screenlocker or inputmethods gets rendered
- Only screenlocker gets keyboard events
- Only screenlocker and inputmethods get mouse events

Things that are not secured/tested are :

- Touch events
- Global shortcuts for screenlocker
- Fallback/emergency screen not yet working

REVIEW: 126015
2015-11-16 16:16:20 +05:30
Martin Gräßlin 4ebba6e134 [wayland] Don't pass keyboard events to Unmanaged windows
The way it was implemented it allowed an X11 unmanaged window to become
a key logger. Basically as soon as there was an unmanaged window it got
all key events. This problem was discovered through the xembed-sni-proxy
which broke key input to all Wayland windows in a Plasma/Wayland session.

With this change Unmanaged windows don't get any key events at all. This
might break some applications as e.g. context menus are using override
redirect windows. A test with Qt applications shows that the menus are
still functional and the events are delivered correctly internally.

If applications show problems with this change, we might need to weaken
the restriction.
2015-11-11 11:00:59 +01:00
Martin Gräßlin cebd723c2c [libinput] Add an event queue
The Connection thread fills the event queue, it gets read from the
main thread. In order to properly support the threaded approach the
setup is changed to delegate into the own thread.
2015-11-03 10:26:01 +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 a23a9d38f9 Make it possible to end move/resize through mouse button release
Properly handle the mouse press/release events in InputRedirection
while we move windows. If it's the last mouse release event we end
the move resize of the window. For that we reuse the code written
in Client.
2015-10-28 10:43:49 +01:00
Martin Gräßlin ac1f01fd3f Use AbstractClient for keyboard moving of clients
As keyPressEvent is in AbstractClient now we don't need to cast to
Client any more. This allows to end move of ShellClients as well.
2015-10-26 09:21:36 +01:00
Martin Gräßlin f84b4758f2 Fix incorrect static_casts to Client
Replace by better dynamic_casts to AbstractClient.
2015-09-16 13:54:48 +02: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 296313b2fc Keep Qt::Popup windows as internal pointer window once they leave window
A click outside a popup should close the popup and not be passed to the
window at the pointer position. Thus we only update the internal pointer
window if the internal pointer window does not represent a visible
popup.
2015-08-25 14:33:50 +02:00
Martin Gräßlin afd76b80ee [wayland] Send QKeyEvent to internal windows
Allows to navigate in e.g. Useractions menu.
2015-08-25 14:33:50 +02:00
Martin Gräßlin 73b8b3ec7b Fix moving windows in InputRedirection
* Need to pass modifiers to Client::keyPressEvent
* Need to check whether move/resize ended before updating position,
  otherwise it keeps stuck in move/resize after ending
2015-08-21 10:49:06 +02:00
Martin Gräßlin 3139dcd3b9 Drop cmakedefine HAVE_WAYLAND
Now a required build dependency.
2015-08-12 11:39:20 +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 e56520dc81 [wayland] Improve pointer movements at screen edges
So far if the new position fell outside of the screen, we ignored
the movement completely. This change only discards the event if both
x and y coordinates are outside the screen. If one component is still
on the screen it will be used. So a movement to top-left on left border
will result in a pointer movement towards top.
2015-07-20 12:35:46 +02:00
Martin Gräßlin 3beff66aca [wayland] Announce modifier changes to clients 2015-07-13 14:25:09 +02:00
Martin Gräßlin a687a58e82 [wayland] Perform mouse command on AbstractClients on touch down
If the touch window changes we simulate a left press and perform
the mouse command for a left button.

Note: this is not yet tested on real system.
2015-07-09 16:34:19 +02:00
Martin Gräßlin 0c0ad87caf [wayland] Activate AbstractClient from InputRedirection on mouse button press
This only handles button presses without modifiers so far.
2015-07-09 16:34:19 +02:00
Martin Gräßlin 810ed5d396 [wayland] Add support for FakeInput interface 2015-07-09 11:34:40 +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 97588faea2 [wayland] Add support for input shape
Toplevel provides the input shape forwarded from SurfaceInterface. The
shape is evaluated in InputRedirection when finding the Toplevel at a
given position.
2015-06-18 23:19:13 +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 7a64426085 Trigger updateMoveResize after keyboard move 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 4ca3734d12 [wayland] Support move/resize mode in pointer move handling 2015-06-06 17:43:12 +02:00
Martin Gräßlin 545c8b190e Send HoverMove event to selected window decoration if buttons are pressed
Ensures that e.g. decoration buttons get the Leave events.
2015-06-06 17:43:12 +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 0853445dce Don't pass pointer focus to a Toplevel which is not yet ready for painting 2015-05-18 15:30:10 +02:00
Martin Gräßlin 4b41c33268 Workspace::movingClient changed to AbstractClient
In events.cpp it's casted to Client as it's X11 specific.
In InputRedirections it's kind of broken, but window movement is
anyway broken.
2015-05-08 12:43:45 +02:00
Martin Gräßlin e8b14cd587 [input] Add safety checks before accessing Cursor of focused pointer
There might be no focused pointer and there might be no cursor.
2015-05-08 12:43:44 +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 30dd2ce466 [input] Add support for VT switch shortcuts
If we have a VirtualTerminal and get a XKB_KEY_XF86Switch_VT_* keysym
we trigger a VT switch.
2015-04-01 11:05:45 +02:00
Martin Gräßlin 61579506e3 [input] Only update seat state if session is active
When our session gets inactive libinput loses all devices, thus our
Seat would not have neither keyboard, pointer nor touch. To not confuse
all connected clients we block updates while libinput is suspended. After
resume we check whether something actually changed and emit the
corresponding signals to ensure everything is up to date.
2015-04-01 11:05:45 +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 c23e106c8b [input] Include more safety checks
nullptr checks as input events might be processed prior to KWin having
been fully started.
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 f7bed6a003 [libinput] Pass device capabilities to Wayland::Server::SeatInterface
We handle device added/remove to monitor whether we have keyboard,
pointer and touch devices and emit signals. Those are used to update
the SeatInferface from InputRedirection.
2015-03-26 16:19:26 +01:00
Martin Gräßlin 60783b8228 Touch support in libinput 2015-03-25 16:40:17 +01: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 405e366815 Add safety check to InputRedirection::findToplevel
InputRedirection might be invoked to process input events prior to
Workspace being started.
2015-03-20 14:43:47 +01:00
Martin Gräßlin 9a0fd94013 Introduce AbstractBackend as base class for Wayland and X11Windowed backend
The AbstractBackend registers itself in the WaylandServer allowing
external users to easily get to the backend and not needing to test
manually which backend is used.
2015-03-20 14:41:03 +01:00
Martin Gräßlin 6bf44b7db4 [wayland] Add an X11 output backend
This new backend allows to start a kwin_wayland server nested on an
X-Server by using a normal X11 window as output. This allows testing
kwin_wayland without needing to start another Wayland server first.

The behavior is triggered by using new command line arguments:
--windowed
--x11-display=<:0>

With optional --width and --height arguments.

In this mode the WaylandBackend is not created at all.

So far the backend is not fully integrated yet and only the QPainter
backend supports this mode.
2015-03-20 14:08:53 +01:00
Martin Gräßlin f600e2f6f4 [wayland] Properly handle Cursor set on focused PointerInterface
This replaces getting the Cursor through the X11CursorTracker which
is now completely dropped. The Cursor data is now passed through from
the Wayland server and forwared to the WaylandBackend.
2015-03-17 10:20:20 +01:00
Martin Gräßlin 7bb107ba6d [wayland] Pass keyboard key press/released events to SeatInterface
Improves handling by no longer sending events with xtest.
2015-03-17 10:20:19 +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
Daniel Pastushchak 0d997b1093 Introduce categorized logging for kwin core
Done by Daniel Pastushchak for KDE during GCI-2014.
2014-12-05 14:27:15 +01:00
Martin Gräßlin 4c9744fe8e Drop dependency on kdecoration.h 2014-12-02 13:50:26 +01:00
Martin Gräßlin 015c59d9fd Fix build if there is no libinput 2014-10-20 15:01:12 +02: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 ff87c989ba Center initial pointer position on screen in libinput mode 2014-10-20 14:51:24 +02:00
Martin Gräßlin f545eeb087 Connect pointer events from libinput 2014-10-20 14:51:24 +02:00
Martin Gräßlin 15a1a5b70f Add command line option to enable libinput support
kwin_wayland gains a new command line option to enable libinput support.
This is needed as logind blanks the VT when the session controller
releases the control. So a nested compositor can seriously affect the
primary session. Thus it needs a dedicated command line switch to
enable it.

By default libinput support is disabled for kwin_x11 and can be enabled
for kwin_wayland in case KWin is compiled with libinput support.
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
Martin Gräßlin c4bb3d11fc Initial support for libinput
Libinput is an optional dependency for getting low level input events.
As opening the input devices requires root privs this is rather
pointless in the current state. But there is a small added test app which
can be executed with root privs to demonstrate the functionality. To
properly get input events we need a wrapper like it's used in weston.

So far the following is setup:
* opening devices found by udev
* forwarding keyboard events to InputRedirection
* forwarding pointer button events to InputRedirection
* forwarding pointer axis events to InputRedirection
* signals emitted for pointer motion events

Pointer motion events need some further work as they are provided
as delta events. We need to track that and map them properly.

Also missing are touch events due to me not having a touch screen.
It should be fairly simple to setup the touch events, though.

Also hotplugging of devices is not yet implemented.
2014-10-20 14:51:24 +02:00
Martin Gräßlin 7091452acd Fix unused variable warnings for compilation without xkbcommon
Sorry, my fault that this generated warnings in the first place.
2014-04-28 16:57:35 +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 38201a8295 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.
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 882c2a4610 Handle keyboard events during move/resize
When moving/resizing a window we don't want the keyboard events being
passed to the Clients. Instead we want to do the normal processing.

Unfortunately moving the window through the keyboard relies on warping
the pointer which is not (yet) available on Wayland. This means that this
is not yet working, but ending through enter/escape etc. is working as
expected.
2014-03-18 09:00:50 +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 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