Commit Graph

74 Commits (137a6a170520ad5471106665dbb93a1298cc35f1)

Author SHA1 Message Date
David Faure 6dc938907f kwin: fix compilation error with strict iterators
Summary: After insert(), image seems to be set already, no need to copy it again?

Test Plan: Builds

Reviewers: apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28578
2020-04-05 08:53:56 +02:00
Aleix Pol 6abd23ed02 Make it possible to have a separate cursor for the tablet
Summary:
As is KWin only had 1 Cursor which was a singleton. This made it impossible for
us to properly implement the tablet (as in drawing tablets) support and show where
we're drawing.
This patch makes it possible to have different Cursors in KWin, it makes all the
current code still follow the mouse but the tablet can still render a cursor.

Test Plan: Tests pass, been using it and works as well as before but with beautiful tablet cursors.

Reviewers: #kwin, cblack, davidedmundson

Reviewed By: #kwin, cblack, davidedmundson

Subscribers: davidedmundson, cblack, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28155
2020-04-03 01:16:45 +02:00
Yuri Chornoivan c66cde7307 Remove duplicate includes
Summary: The code contains duplicate includes.

Test Plan: Open the files from the patch

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28048
2020-03-14 21:19:14 +02:00
Vlad Zahorodnii be759b7d33 Use AbstractClient instead of XdgShellClient wherever possible
Summary:
Currently, we have only one shell client type - XdgShellClient. We use
it when we are dealing with Wayland clients. But it isn't really a good
idea because we may need to support shell surfaces other than xdg-shell
ones, for example input panel surfaces.

In order to make kwin more extensible, this change replaces all usages
of the XdgShellClient class with the AbstractClient class.

Test Plan: Existing tests pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27778
2020-03-04 09:57:13 +02:00
Vlad Zahorodnii 15af09c70a Introduce Toplevel::frameGeometryChanged signal
Summary:
Currently we have two signals that are emitted when the Toplevel's geometry
changes - geometryShapeChanged() and geometryChanged(). The former signal
is used primarily to invalidate cached window quads and the latter is
sort of emitted when the frame geometry changes. But it's not that easy. We
have a bunch of connects that link those signals together...

The worst part about all of this is that the window quads cache gets
invalidated every time a geometry update occurs, for example when user
moves a window around on the screen.

This change introduces a new signal and deprecates the existing geometryChanged
signal. frameGeometryChanged is similar to geometryChanged except that it is
emitted when an _actual_ geometry change has occurred.

We do still emit geometryShapeChanged signal. However, in long term, we
need to get rid of this signal or come up with something that makes sense
and doesn't require us to waste computational resources.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26863
2020-02-12 10:52:26 +02:00
Marco Martin baebfb7f7e actually draw drag icons in the mouse cursor during drags
Summary:
paint together the cursor image and the extra dnd image if available
on X11 with QDrag::setHotspot is possible to control their relative
position, which doesn't seem to have a wayland protocol correspondence
so their relative position are controlled just by the hotspot of the cursor itself

Test Plan:
folder graphics from dolphin is painted correctly
{F8086937}

Reviewers: #plasma, #kwin, davidedmundson

Reviewed By: #plasma, #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27174
2020-02-06 15:47:57 +01:00
Vlad Zahorodnii 55b4912004 Update my email address 2020-01-14 18:17:18 +02:00
Aleix Pol f6128ec875 Provide a fake approach to tablet event propagation
Summary:
At the moment, the state of wayland of getting such events isn't all
that clear. There's a zwp_tablet protocol that isn't stable yet and more
importantly isn't supported by Qt just yet.
Have it move and click the mouse about for now.

Depends on D25663 and D25763

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25764
2019-12-10 21:59:05 +01:00
Aleix Pol 4172ef3b30 Turn switch statement into a hash
Summary: This way we can reverse-lookup if we ever want the opposite information.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25763
2019-12-10 21:57:09 +01:00
Vlad Zahorodnii f93875535c Update my last name 2019-09-29 17:03:25 +03:00
Vlad Zahorodnii ffcbe24e2b Rename Client to X11Client
Summary:
Currently each managed X11 client is represented with an instance of
Client class, however the name of that class is very generic and the
only reason why it's called that way is because historically kwin
was created as an x11 window manager, so "Client" was a sensible choice.

With introduction of wayland support, things had changed and therefore
Client needs to be renamed to X11Client in order to better reflect what
that class stands for.

Renaming of Client to X11Client was agreed upon during the last KWin
sprint.

Test Plan: Compiles, the test suite is still green.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24184
2019-09-25 21:11:37 +03:00
Vlad Zagorodniy 168ea98845 Rename ShellClient to XdgShellClient
Summary:
Rename ShellClient to XdgShellClient in order to reflect that it
represents only xdg-shell clients.

Test Plan: Compiles, tests still pass.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23589
2019-09-23 17:28:56 +03:00
Vlad Zagorodniy bebe81209c Port QPA away from Wayland
Summary:
So far wayland was used by internal clients to submit raster buffers
and position themselves on the screen. While we didn't have issues with
submitting raster buffers, there were some problems with positioning
task switchers. Mostly, because we had effectively two paths that may
alter geometry.

A better approach to deal with internal clients is to let our QPA use
kwin core api directly. This way we can eliminate unnecessary roundtrips
as well make geometry handling much easier and comprehensible.

The last missing piece is shadows. Both Plasma::Dialog and Breeze widget
style use platform-specific APIs to set and unset shadows. We need to
add shadows API to KWindowSystem. Even though some internal clients lack
drop-shadows at the moment, I don't consider it to be a blocker. We can
add shadows back later on.

CCBUG: 386304

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, kwin

Tags: #kwin

Maniphest Tasks: T9600

Differential Revision: https://phabricator.kde.org/D22810
2019-09-23 17:28:56 +03:00
Vlad Zagorodniy 7f593a67ad Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.

BUG: 404152
FIXED-IN: 5.17.0

Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
  wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
  in all three cases wayland debug looked the same (except diagonal scroll
  motions).

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19000
2019-05-17 12:06:10 +03:00
Vlad Zagorodniy abe128818c Use more accurate name for Workspace::getMovingClient method
Summary:
The name of Workspace::getMovingClient() method implies that the
returned value is a client that is currently being moved around
by the user, but this is of course incorrect.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20663
2019-04-22 11:12:22 +03:00
Vlad Zagorodniy 1ca2aec77f [wayland] Don't use hardcoded move-resize cursor
Summary:
Currently, when resizing a window the cursor doesn't match the resize
direction. The reason for that is the move-resize cursor is hardcoded.

To fix that, CursorImage::updateMoveResize has to use AbstractClient::cursor.
Also, because the move-resize cursor is updated after calling startMoveResize,
we have to connect to AbstractClient::moveResizeCursorChanged.

BUG: 370339
FIXED-IN: 5.15

Reviewers: #kwin, davidedmundson, broulik, romangg, graesslin

Reviewed By: #kwin, graesslin

Subscribers: davidedmundson, romangg, graesslin, kwin

Tags: #kwin

Maniphest Tasks: T5714

Differential Revision: https://phabricator.kde.org/D3202
2018-12-31 12:35:01 +02:00
Roman Gilg 2e29711323 Rework InputDeviceHandler focus tracking
Summary:
This patch aims at improving the Toplevel, internal window and decoration
focus tracking.

In detail the goals are:
* Clean tracking of beneath and focus Toplevel as well as decoration and
internal windows. Splitting this up in well defined sub routines.
* Minimal find Toplevel operations on window stack.
* Reduce code duplication in pointer and touch child classes.
* Reuse tracking in drag operations.
* Allow direct usage of Wayland input interfaces for decoration and internal
windows in the future.
* Update touch focus on external events like VD switches correctly.

Test Plan: Manually and existing autotests.

Reviewers: #kwin

Subscribers: kwin, zzag

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15595
2018-12-02 21:36:11 +01:00
Roman Gilg eab71a8a19 Privatize variables in InputDeviceHandler
Summary:
Some members were declared protected. Better style is to have them private
with public or protected getters and setters.

This also removes the unnecessary m_input variable.

Test Plan: Builds and runs.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15519
2018-12-02 21:17:44 +01:00
Roman Gilg 6072b0cd6c Remove breaking pointer constraints functionality
Summary:
With 2694839099, 0bd5eff862 and f0ba436c72 it is now possible to
unconstrain a pointer by killing the client or deactivating the window, for
example by switching the window via the TabBox.

A user should always be able to do it therefore without needing to explicitly
break the pointer constrain as in the past with the Esc key.

Therefore remove the functionality and also remove the OSD announcing it,
which was often shown at the wrong time.

Test Plan: Manually and auto test adapted.

Reviewers: #kwin, #vdg, hein

Reviewed By: hein

Subscribers: ngraham, hein, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D15234
2018-09-12 22:55:26 +02:00
Vlad Zagorodniy 624a453109 Clean up includes
Summary:
* effects.h includes client.h and forward declares Client, both at the
  same time. Thus, delete the include;

* the blur effect includes effects.h. That, most likely, is a leftover
  after 3f5bf65a9e.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15191
2018-08-31 22:58:11 +03:00
Roman Gilg 054ccc3898 Use locked cursor position hint
Summary:
Listen for cursor position hint changes and set cursor position to the hint
on unlock if a valid position hint was set.

Test Plan: With pointer constraints test app.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Maniphest Tasks: T4693

Differential Revision: https://phabricator.kde.org/D14176
2018-07-27 17:19:33 +02:00
Roman Gilg f0ba436c72 Explicitly disable pointer constraints on TabBox invocation
Summary:
Pointer constraints should become disabled when the TabBox is invoked. Since
the current client stays activated while TabBox is enabled and currently can
not be deactivated with the risk of regression as discussed in D13758, disable
all pointer constraining explicitly and enable it again when the TabBox is
closed.

Test Plan: Manually in Wayland session.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D14142
2018-07-16 10:43:25 +02:00
Vlad Zagorodniy dc541452f1 Merge branch 'Plasma/5.13' 2018-07-15 23:05:30 +03:00
Vlad Zagorodniy 1e4703a719 [wayland] Confine pointer to screen geometry
Summary:
If the new pointer position is "off screen", PointerInputRedirection
just ignores that new position. So, pointer remains on its previous
position. In some particular cases, like reaching default panel, it
degrades desktop experience because one have to slowly move pointer in
order to reach what he/she wants.

This change addresses that problem by confining the new pointer position
to screen geometry.

BUG: 374867
FIXED-IN: 5.13.4

Test Plan: Ran tests

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14036
2018-07-15 23:05:11 +03:00
Roman Gilg 0bd5eff862 Make keyboard focus a pointer constraints necessity
Summary:
This patch changes KWin's pointer constraining behavior by only allowing
constraints if the surface has keyboard focus. In case the client activation
state changes, it rechecks it.

Test Plan:
Manually with the pointer constraints test application and opening the
launcher by pressing meta. Also amended autotest.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D13492
2018-06-26 16:45:39 +02:00
David Edmundson c857c03561 Load Kwin's internal cursors for the highest resolution of attached monitors
Test Plan:
Hovered over decoration
Looked super crystal clear
Same physical size as when I hover over window contents (which had a buffer scale of 1)

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13608
2018-06-23 23:26:54 +01:00
David Edmundson 1761b75b55 Set correct DPR on wayland cursors received from remote buffers
Summary:
It will then be renderered appropriately when painting to the output
buffer.

Test Plan: Updated unit test, plus used with other relevant patches

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13606
2018-06-23 18:17:51 +01:00
Roman Gilg 2694839099 Remove pointer constraint on resource unbind
Summary:
A client might delete its pointer lock/confinement object. This is supposed to
directly remove the pointer lock/confinement in KWin, but did not explicitly
until now.

BUG: 388885

Test Plan:
Tested manually with Neverball, Nexuiz and the new pointer constraints test
application. The pointer constraints autotest is also appended.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, graesslin, kwin

Tags: #kwin

Maniphest Tasks: T8923

Differential Revision: https://phabricator.kde.org/D13466
2018-06-11 22:46:06 +02:00
David Edmundson 5b4eb80c8f Set specific edge cursor shape when resizing
Summary:
Instead of seeing the cursor <--> on the left edge you now see an icon
that looks like |<-  .

This brings kwin decorations in line with GTK CSD icons.

In theory this is also useful to tell which window will resize in the
case of side-by-side windows (regardless of whether borders are on or
not). In practice with the adwaita icon theme I tested with it's not
very intuitive to realise which is which till you learn the icon.

Change is more involved than it should be as Qt::CursorShape doesn't
have these entries, and I don't want to shadow that enum internally or
have
to change kwin effect code.

Specifics depend on cursor icon theme if they are not present it will
fallback to the <--> icon. (Breeze does not have them currently)

Test Plan:
Resized some windows (on X and on Wayland)
Correct icon appeared on Adwaita
Existing icon appeared on Breeze

Reviewers: #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13396
2018-06-11 10:05:07 +01:00
Martin Flöser 04dab3de1b Merge branch 'Plasma/5.12' into Plasma/5.13 2018-05-19 09:00:43 +02:00
Martin Flöser e3250460cc Do not unset cursor image when cursor enters a surface
Summary:
From Wayland documentation:
"When a seat's focus enters a surface, the pointer image is undefined and
a client should respond to this event by setting an appropriate pointer
image with the set_cursor request."

KWin's interpretation so far for the undefined pointer image was to
remove the pointer image when entering a surface waiting for the client
to set a cursor image. This can result in a short flicker as there might
be a frame without a cursor image.

This patch changes the behavior by keeping the previous image till the
application set a new one. This brings some advantages:
 * if the application is not responding a cursor is still shown
 * if the same cursor is used as in the previous window we don't have a
flicker

CCBUG: 393639

Test Plan: I cannot see the flicker, so only tested with the adjusted tests

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12631
2018-05-19 08:58:42 +02:00
Aleix Pol c0226fe744 Clear both cursor caches
Summary: There are two cursor caches: m_cursors and m_cursorsByName. The second doesn't ever seem to be cleared.

Reviewers: #kwin, davidedmundson, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12542
2018-05-02 14:55:38 +02:00
Martin Flöser 507d83fb08 Ensure leave event is send to decoration when a window maximizes
Summary:
When clicking the maximize button without moving the mouse, the maximize
button stayed in hover state till the mouse moved. The reason for this
is that the PointerInputRedirection does not perform an update on the
geometry change of a window.

BUG: 385140
FIXED-IN: 5.11

Test Plan: Manual testing

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8016
2017-10-16 17:57:21 +02:00
Martin Flöser 1b01f1b300 Update pointer position whenever a window gets (un)minimized
Summary:
This fixes the following problem:
1. Have two windows maximized
2. Click minimize button on first window
3. Click minimize button on second window

What happened:
Second click was ignored as the pointer was not updated.

BUG: 378704
FIXED-IN: 5.11

Test Plan:
Nested KWin/Wayland, added two maximized windows, minimized
both without moving the mouse

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8145
2017-10-15 16:38:45 +02:00
Martin Flöser 80c3fdd684 Use App's x11 rootWindow and connection in PointerInputRedirection::warpXcbOnSurfaceLeft
It was already partially using the x11Connection and partially the global
connection. In order to prepare for removal of the global connection and
rootWindow, it is better to use only the newer variant through kwinApp.
2017-08-24 13:26:45 +02:00
Martin Gräßlin 9a13743c49 Don't update the focused pointer Surface if a button is pressed
Summary:
During pointer motion we already had the condition that an update of
focused pointer surface can only happen when no button is pressed. But
there are more conditions where we try to update the focused pointer even
if a button is pressed. E.g. if the stacking order changes.

This happens when trying to move one of Qt's dock widgets:
 1. Press inside a dock widget
 2. Qt opens another window, which is underneath the cursor
 3. KWin sends pointer leave to parent window
 4. dock widget movement breaks

This change ensures that also this sequence works as expected and the
pointer gets only updated when there are no buttons pressed, no matter
from where we go into the update code path.

BUG: 372876

Test Plan: Dock widgets in Dolphin can be moved now.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5461
2017-04-20 17:02:42 +02:00
Martin Gräßlin 1193b0da77 Initial support for popup window handling
Summary:
So far KWin did not properly handle popup windows. That is when a popup
surface got created and a click outside the surface happened KWin did not
send out the popupDone Wayland event.

This change makes KWin aware of whether a surface is a popup and tracks
through a new PopupInputFilter whether there are popup windows. In case
there are popups the new filter waits for mouse press events and cancels
the popups if the press does not happen on any surface belonging to the
same client. To quote the relevant section of the Wayland documentation:

    The popup grab continues until the window is destroyed or a mouse
    button is pressed in any other client's window. A click in any of the
    client's surfaces is reported as normal, however, clicks in other
    clients' surfaces will be discarded and trigger the callback.

So far the support is still incomplete. Not yet implemented are:
 * support xdg_shell popup windows
 * verifying whether the popup is allowed to be a popup
 * cancel the popup on more global interactions like screen lock or
   kwin effect

BUG: 366609
FIXED-IN: 5.10

Test Plan: Auto test and manual testing with QtWayland client

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5177
2017-04-07 16:14:50 +02:00
Martin Gräßlin 0bb587dcb9 Ensure PointerInputRedirection::processMotion finishes prior to warping
Summary:
Consider the following situation: we have three InputEventFilter linked
in the sequence A - B - C.

The input filters are processing pointer motion events. The expected
behavior is that the new motion is processed in the sequence
   A -> B -> C

So far this did not work correctly if the pointer gets warped during the
processing. If e.g. filter B warps the pointer we get a motion sequence:
   A (1) -> B (1) -> A (2) -> B (2) -> C (2) -> C (1)

The filters following the one warping the pointer get first the newer
than the older position. This is obviously wrong. Unfortunately it is not
just a theoretical condition, but a condition happening when interacting
with the screenedges, which warp the pointer.

This change introduces a PositionUpdateBlocker in
PointerInputRedirection::processMotion to ensure that a processMotion
call finishes prior to the next update. If the PositionUpdateBlocker is
blocked the new position gets scheduled and processed once the
PositionUpdateBlocker gets destroyed.

With this we get the expected sequence for B warping pointer:
   A (1) -> B (1) -> C (1) -> A (2) -> B (2) -> C (2)

This should hopefully improve the interaction with screen edges on
Wayland.

CCBUG: 374867

Test Plan:
Added an auto test demonstrating the issue of incorrect
ordering caused by screenedges. Prior to the change the test is failing.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5182
2017-03-27 07:08:10 +02:00
Martin Gräßlin 65ddd32d1a Split modifier only handling into a dedicated InputEventSpy
Summary:
The functionality regarding triggering modifier only shortcuts is moved
out of Xkb - where it doesn't belong to - and is turned into an input
event spy listening for the changes it is interested in. Previously
the state got queried by asking e.g. for the pressed buttons, now it's
tracked directly.

The X11 side needs a larger change due to that as now pushing the events
into Xkb does not trigger modifier only shortcuts any more. Instead the
"normal" way through the platform API needs to be used which triggers the
processing of filters and spies.

The problem here is that our redirections only process events if they are
inited and that only happens on Wayland. We cannot call init on them as
that would create all the Wayland filters and spies and processing would
probably break. As an intermediate solution the spies are now processed
and there we know that it won't matter. A future solution would be to
remove the init checks completely and just send through both filters and
spies and ensure that on X11 only the supported ones are loaded.

Closes T5220

Test Plan: Tested on Wayland and X11

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Maniphest Tasks: T5220

Differential Revision: https://phabricator.kde.org/D4578
2017-02-14 17:02:18 +01:00
Martina Flöser a68e77a711 Add native button to MouseEvent
Summary:
This adds the nativeButton to the MouseEvent allowing the InputEventSpy
to use this information. Also the InputEventFilter can be adjusted to
make use of it.

Reviewers: #kwin

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3875
2016-12-30 19:07:45 +01:00
Martin Gräßlin 84e3308149 Introduce an InputEventSpy for processing input events
Summary:
So far KWin's input event processing is mostly based on
InputEventFilters. A filter can - as the name suggest - filter out an
input event from further processing. Our code shows that this is not
sufficient for all input event processing.

We have several areas inside KWin where we need to have access to all
input events, where the processing needs to happen on all events and
filtering is not allowed. This results in sub-optimal code which has
classes which know too much and do too much.

Examples:
 * key-repeat handling done in KeyboardInputRedirection
 * Layout change OSD in Xkb
 * modifier only shortcuts in Xkb
 * emitting signals for Cursor class in KeyboardInputRedirection

Also there are misuses of the InputEventFilters and internal API
 * DebugConsole keyboard state (uses wrong information)
 * DebugConsole input events tab (uses Filter, should be a spy)

This change introduces the API needed to fix these problems. It
introduces an InputEventSpy which is modelled after the InputEventFilter
with the difference that it has only void messages and uses the KWin
introduced event classes.

The spies are always processed prior to the filters, thus we know it can
have all events.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3863
2016-12-30 18:29:40 +01:00
Martin Gräßlin 58361213de Add the modifiers relevant for global shortcuts into the input Events
Summary:
Prior to this change various event filters performed deep calls into
Xkb class to figure out the modifiers relevant for global shortcuts (aka
consumed modifiers). This shows that this is a general useful
information which should be available to all input event filters
directly.

Thus it's now added to the input events and exposed directly in
InputRedirection so that the calls into Xkb are no longer needed.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3810
2016-12-27 18:19:15 +01:00
Martin Gräßlin e3d79cdda6 Reduce code duplication for processing input events
Summary:
For every input event we have similar code. We go through all
InputFilters, invoke a method with some arguments and check whether
the filter returns true.

Instead of duplicating that logic everywhere, there is now one method
in InputRedirection which takes a std::function to call on the input
filters. The std::function is supposed to be generated with a std::bind
on the InputFilter::method with all the required arguments.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3806
2016-12-27 17:38:32 +01:00
Martin Gräßlin 696ce96e9b Show notification when pointer gets confined/locked
Summary: Inform user how the pointer constraint can be ended.

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3780
2016-12-21 20:02:01 +01:00
Hrvoje Senjan 02b9cf739f Compile with gcc <= 4.8
Reviewed-by: Martin Gräßlin
2016-12-09 17:39:57 +01:00
Martin Gräßlin 0c5ca405cc Implement support for pointer constraints
Summary:
There are two types of constraints supported:
1. Pointer confinement
2. Pointer locking

In the case of confinement the pointer is confined to a given region of
the surface. This is comparable to general operation where the pointer
is confined to the screen region.

In the second case the pointer gets locked. That means it cannot move at
all. No further position updates are provided, only relative motion
events can go to the application. There is a hint about cursor position
update on unlock which is not yet implemented in KWayland::Server, thus
also not in this change.

The implementation in KWin grants the requests for pointer constraints
when the pointer enters the constrained region, either by pointer
movement or by e.g. stacking order changes. There is no confirmation
from user required to enter that mode. But we want to show an OSD when
the pointer gets constrained, this is not yet implemented, though.

Breaking an active constraint is relatively easy. E.g. changing the
stacking order will break the constraint if another surface is under the
cursor. Also (in case of confinement) moving the pointer to an
overlapping window breaks the confinement. But as soon as one moves the
pointer back to the window a constraint might get honoured again.

To properly break there is a dedicated event filter. It listens for a
long press of the Escape key. If hold for 3sec the pointer constraint is
broken and not activated again till the pointer got moved out of the
window. Afterward when moving in the pointer might activate again.

The escape filter ensures that the key press is forwarded to the
application if it's a short press or if another key gets pressed during
the three seconds. If the three seconds way fires, the later escape
release is not sent to the application.

This basic interaction is also ensured through an added auto test.

This change implements T4605.

Test Plan: Added auto test and nested KWin Wayland with D3488

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3506
2016-12-08 19:50:24 +01:00
Martin Gräßlin fd83366e31 Implement interactive window selection for Wayland platforms
Summary:
The interactive window selection is implemented in InputRedirection
through a dedicated InputEventFilter. The InputEventFilter so far takes
care of pointer input and keyboard input. In addition it ensures that
keyboard and pointer focus is reset on start and on end.

With this change KillWindow now also works on Wayland, but only for X11
windows, as the Wayland variant is not yet implemented.

Test Plan: Tested in nested setup, auto-tests still needed

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3365
2016-11-17 09:42:12 +01:00
Martin Gräßlin b6af777230 Forward pointer gestures to Wayland server
Summary:
This change implements forwarding the pointer gestures to the new API in
SeatInterface.

While screen is locked no gestures are forwarded to the server. Also
locking the screen cancels any active gesture. Similar if areas inside
KWin would start to intercept the gestures, they need to be cancelled on
the Wayland SeatInterface.

Test Plan: Not yet

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3174
2016-11-07 13:45:08 +01:00
Martin Gräßlin 13f142b1bf Merge branch 'Plasma/5.8' 2016-10-31 11:52:43 +01:00
Martin Gräßlin 82054a406a Send a pointer leave when triggering a move resize
Summary:
When triggering a move resize all following pointer events are grabbed
by KWin itself. Thus the correct behavior is to informe the client about
it and send a pointer leave.

This ensures that after the move resize ended the pointer gets a new
enter. By sending anew pointer enter the position gets updated to the
new position which so far did not happen and the client generated events
on the wrong position.

BUG: 371573
FIXED-IN: 5.8.3

Reviewers: #kwin, #plasma_on_wayland, broulik

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3154
2016-10-31 11:51:15 +01:00