Commit graph

79 commits

Author SHA1 Message Date
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