Commit graph

275 commits

Author SHA1 Message Date
Vlad Zahorodnii
d074b47aab Fix logical error
It makes more sense to access position() if positionValid() returns true.
2021-01-28 17:18:43 +00:00
Vlad Zahorodnii
3e739ff877 Simplify InputDeviceHandler::updateDecoration() 2021-01-28 17:14:25 +00:00
Vlad Zahorodnii
3788a8285d Remove QPointer from function prototypes in some input code
As it was pointed out in 6acf35e4cc, it is
better to return raw pointers than qpointers because returning a qpointer
is equivalent to constructing a new one.
2021-01-28 16:49:29 +02:00
David Edmundson
e6c1735bdc Restore default key repeat mode
Key repeat is the default we had in 5.20, albeit under a different key.
This changes for the key repeat was reverted elsewhere, but we need to
adjust the wayland default.
2021-01-28 09:36:11 +00:00
Xaver Hugl
93ee2f6815 Add test for TouchInputRedirection::m_touches 2021-01-18 17:00:47 +00:00
Xaver Hugl
3c23194037 Process TOUCH_CANCEL events from libinput individually
This fixes a bug where cancelled touch sequences get ignored
which results in stuck touch focus.
2021-01-18 17:00:47 +00:00
Aleix Pol
617651d93e tablet_v2: Use libinput device groups to deduce the device's tablet
We can have pads without tools, tools without pads. This changes how we
figure out which tablet belongs to the input device.
2021-01-06 18:47:59 +01:00
Aleix Pol
3b807e482d tablet: do not show a cursor if no cursor surface was provided 2021-01-06 18:47:59 +01:00
Aleix Pol
1a32c64603 tablet_v2: Support remaining controls
Adds support for tablet buttons, rings and strips.
2021-01-06 18:47:59 +01:00
Vlad Zahorodnii
d96eb3897d wayland: Reload key-repeat settings when kcminputrc changes
At the moment, if key repeat settings are changed in the input kcm, kwin
will do nothing.
2020-12-16 08:17:50 +00:00
Vlad Zahorodnii
ecac025a2a Port wayland code away from factory methods in KWaylandServer::Display 2020-12-14 13:05:47 +00:00
Adrien Faveraux
50b1bb4a2b adapt Fake input to kwayland change 2020-12-07 08:12:12 +00:00
Carson Black
49c7316e8c input: update keyboard repeat config reading to reflect new configuration style 2020-12-04 17:29:42 +00:00
Bhushan Shah
3429617662 adapt to changes in seat and keyboard interface
Now several methods of keyboard_interface are public and wrappers for
them are removed from the seat_interface.
2020-11-19 06:05:45 +00:00
Vlad Zahorodnii
823e5b02ea Adjust tablet input stuff to kwayland-server changes 2020-11-05 07:09:57 +00:00
Vlad Zahorodnii
2123e9b541 Adjust input stack to relative-pointer-v1 changes in kws 2020-11-03 19:48:41 +00:00
Bhushan Shah
733692f439 input: reconfigure after setting up the libinput
Previously seat interface was keeping track of the repeat information,
but now it is taken care by KeyboardInterface, which is created only if
the setHasKeyboard is set to true.

So, since we are setting up various capabilities on seat in libinput,
re-parse configuration here, so that various information like key repeat
is notified to kwayland-server

BUG: 428039
2020-10-21 16:01:06 +05:30
Vlad Zahorodnii
41d431de27 Adapt to input region changes in kwayland-server
SurfaceInterface::inputIsInfinite() has been dropped. If the surface has
no any input region specified, SurfaceInterface::input() will return a
region that corresponds to the rect of the surface (0, 0, width, height).

While the new design is more robust, for example it's no longer possible
to forget to check SurfaceInterface::inputIsInfinite(), it has shown some
issues in the input stack of kwin.

Currently, acceptsInput() will return false if you attempt to click the
server-side decoration for a surface whose input region is not empty.

Therefore, it's possible for an application to set an input region with
a width and a height of 1. If user doesn't know about KSysGuard or the
possibility of closing apps via the task manager, they won't be able to
close such an application.

Another issue is that if an application has specified an empty input
region on purpose, user will be still able click it. With the new
behavior of SurfaceInterface::input(), this is no longer an issue and it
is handled properly by kwin.
2020-10-17 16:11:13 +03:00
Vlad Zahorodnii
ba4f6b35ae Introduce geometry conversion helpers
The new helpers are designed for the purpose of mapping points from the
global screen coordinates to the frame-local and the surface-local coords
2020-10-17 15:40:51 +03:00
David Edmundson
6acf35e4cc Avoid QPointer in return types of Input methods
QPointer is a really useful way to store a pointer over time.
It doesn't make have any value as a return value used by a short-lived
method.

There isn't a good copy constructor, it's effectively the same as
creating a new QWeakPointer reference that has to be cleaned up.

Testing if something is null is still the same. A new QPointer can be
made by the caller if it actually is needed.

Input handling is a very hot path called many times a frame, so it's
important to keep this light. focus() and at() are called a lot which
added up to slightly over 1% of CPU time when moving the mouse about.
2020-09-08 08:04:13 +00:00
Vlad Zahorodnii
811af61e88 Remove unused xdgshellclient.h include 2020-08-17 14:43:59 +03:00
Aleix Pol
1ad88bdf7c tablet: acknowledge that findTabletSeat might return nullptr
Never hit that case, but I figured it makes sense to account for the
case now since we have several paths that return nullptr.
2020-08-11 13:50:54 +00:00
Xaver Hugl
3a85b57ec2 Send out an additional TabletMove event before TabletPress.
Sometimes when a user puts the pen down too fast a TabletPress event will get triggered before a TabletMove event can occur. The app then assumes the user moved the pen very fast to the new position. The old position is there either (0,0), which often triggers the menu, or the last position the app received, which triggers apps like Xournal++ and Krita to paint a line from the old to the new position.
2020-08-11 13:49:18 +00:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Aleix Pol
e28e4cb189 Move inputConfig away from KWin::Application
We were calling it from tests that were not running a KWin::Application
and not even including the symbols from main.cpp and main.h. The only
reason they linked was that it was static_casting up the QCoreApplication.
2020-07-13 12:54:34 +02:00
Aleix Pol
89fca06bdb Make sure tablet coordinates take decorations into account
Fixes a small awkward offset on some applicaitons.

BUG: 423833


(cherry picked from commit 311094ad8be4c76df2a4655fe71e7085fa9c4e14)
2020-07-08 15:20:35 +00:00
Vlad Zahorodnii
ad73e13478 [wayland] Switch to SurfaceInterface::bufferScale()
SurfaceInterface::scale() has been renamed to SurfaceInterface::bufferScale().
2020-06-24 06:59:15 +00:00
Benjamin Port
4a90f6ab60 Add support to keyboard shortcuts inhibitor
Summary:
- Disable all global shortcuts
- For now don't disable spies (So opening menu with meta key is not disabled for now)

Depends on D29231

Test Plan: Tested with https://github.com/swaywm/wlroots/blob/master/examples/keyboard-shortcuts-inhibit.c

Reviewers: davidedmundson, zzag

Reviewed By: davidedmundson

Subscribers: romangg, broulik, apol, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29272
2020-05-29 08:49:11 +00:00
Aleix Pol
3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56:08 +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
Aleix Pol
f4e41430e5 Improve PowerOff/PowerDown behaviour
Summary:
Trigger PowerDown after pressing for 1s instead of having to wait for release
to decide, feels more natural.
Also don't operate the modifiers, it's done later by KGlobalAccel.

Reviewers: #kwin, #plasma:_mobile, bshah

Reviewed By: #plasma:_mobile, bshah

Subscribers: ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28490
2020-04-02 12:09:51 +02:00
Aleix Pol
43969122a2 Remove changes from a patch from the future 2020-03-20 03:44:59 +01:00
Aleix Pol
e0052cedcb Implement the tablet wayland protocol in kwin
Summary:
Uses the tablet classes introduced in kwayland.
Depends on D26858

Test Plan:
Scratched my tablet with a magic stick and it did things depending on the pressure.
https://youtu.be/GGx0TlNJlzs

Reviewers: #kwin, #plasma, zzag, davidedmundson

Reviewed By: #kwin, #plasma, zzag, davidedmundson

Subscribers: davidedmundson, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26859
2020-03-20 03:05:41 +01:00
Aleix Pol
cca0e15b45 Fix compiler warnings
Summary: No need to keep them around for no reason.

Test Plan: Tested the plugins I thought could be affected. Have been using it for a couple of days without problems

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28062
2020-03-17 15:07:52 +01: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
Aleix Pol
b9423a033c Send a Qt::Key_PowerDown when long pressing the power button
Summary:
This will be useful to be able to show a menu on long press and just
lock the screen on normal press, especially useful on phones and
tablets.

Test Plan:
Could not test much because on laptops doesn't work. Would need more
investigation. discussed further on the plasma mailing list.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: z3ntu, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26899
2020-02-06 12:12:48 +01:00
Vlad Zahorodnii
72ca9268ce [wayland] Provide correct input geometry for client-side decorated clients
Summary:
Currently, the input geometry for client-side decorated clients matches
the frame geometry, which makes it impossible for a user to resize such
clients by just dragging invisible area near window borders.

BUG: 416346

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: cblack, ngraham, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26716
2020-01-24 00:49:50 +02: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
f5a73b87e3 Initial support for tablets on Wayland
Summary:
This includes support for them on libinput and turns it into fake
pointer actions.
This doesn't implement zwp_tablet, this will have to happen in an
iteration later.

Test Plan:
Been playing around with it, see video.
https://www.youtube.com/watch?v=GF1WbO8FVvU

Reviewers: #plasma, #kwin, romangg

Reviewed By: #plasma, #kwin, romangg

Subscribers: zzag, davidedmundson, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25663
2019-12-10 21:56:31 +01:00
Vlad Zahorodnii
9d4a32596c Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example

    QList<QWeakPointer<TabBoxClient>> TabBoxClientList

in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?

Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.

So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24950
2019-11-27 15:54:08 +02:00
David Edmundson
aedc9e62e6 [effects] Forward wheel events
Summary:
Effects::checkInputWindowEvent(QWheelEvent *e) existed but it was not
hooked up to anything and would never be called.

This patch adds the relevant handling in the wayland filter, X filter so
the existing method gets called.

EffectQuickView is updated to handle wheel events.

Test Plan:
Used a ListView via an EffectQuickView in an effect.
I can now scroll with the mouse.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25292
2019-11-14 12:50:45 +00:00
Jan Grulich
3faeb543a7 Add support for keyboard key press and release from fake input protocol
Summary: Depends on D23766.

Reviewers: davidedmundson, #plasma, romangg

Reviewed By: davidedmundson, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23769
2019-10-22 13:25:03 +02:00
Vlad Zahorodnii
7d4471eba6 Rename geometry property to frameGeometry
Summary:
In order to properly implement xdg_surface.set_window_geometry we need
two kinds of geometry - frame and buffer. The frame geometry specifies
visible bounds of the client on the screen, excluding client-side drop
shadows. The buffer geometry specifies rectangle on the screen that the
attached buffer or x11 pixmap occupies on the screen.

This change renames the geometry property to frameGeometry in order to
reflect the new meaning assigned to it as well to make it easier to
differentiate between frame geometry and buffer geometry in the future.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24334
2019-10-02 11:46:37 +03: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 Zahorodnii
62a7db7028 Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.

This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 17:48:21 +03:00