Commit graph

996 commits

Author SHA1 Message Date
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
a195223a8d wayland: Fix Qt clients not being maximized initially
Currently, Qt clients send two maximize requests separated by the
initial commit. From spec's perspective, this is totally fine, the
client should receive two configure events with "maximized" state.

But because changeMaximize() in XdgToplevelClient and setMaximized()
operate on two different maximize modes, the second maximize request
will trick kwin into thinking that the client should be restored.
2020-10-15 11:35:06 +00:00
Vlad Zahorodnii
2093820aba xwayland: Avoid creating a tree query on crash
If Xwayland has crashed, the Workspace will block stacking order updates
and start destroying all X11 clients.

Once stacking order updates are unblocked, the Workspace will mark the X
stacking order as dirty and create a new Xcb::Tree object.

We don't want to create that Xcb::Tree object because accessing it
after the XCB connection has been shut down will lead to a crash.

BUG: 427688
FIXED-IN: 5.20.1
2020-10-14 16:17:42 +00:00
Bhushan Shah
0a3e18e5a6 Fix build 2020-09-30 16:16:45 +05:30
Bhushan Shah
474d0344ca autotests: rename to testInputMethod
Relevant class got renamed, also update the test name

Related: plasma/kwin!302
2020-09-30 16:04:49 +05:30
Bhushan Shah
222b558b04 virtualkeyboard: rename class to InputMethod
VirtualKeyboard class does not implement the relevant VirtualKeyboard
protocol but rather implements the InputMethod protcol and can in theory
be used by other input method like e.g. ibus.

Make class name consistent with what it does to avoid confusion in
future.

For now only rename of main class is done and dbus service is kept as-is
to provide retro-compatibility, when input method protocol is
implemented fully, we can think of what to do wrt the dbus interface
later when we fully implement zwp_input_method_unstable_v1 protocol.
2020-09-29 20:55:24 +05:30
Bhushan Shah
6d433bdfc9 virtualkeyboard: add text-input-v3 support 2020-09-29 10:56:24 +00:00
Andreas Haratzis
6f53f62741 Fix for PlasmaSurfaceTest broken in a3b50500
TestPanelWindowsCanCover now needs to wait for the event queue to process the hover event.
2020-09-24 09:34:29 +00:00
Vlad Zahorodnii
0c266e760b Replace remaining usages of old connect syntax with new connect syntax
This change replaces the remaining usages of the old connect syntax with
the new connect syntax.

Unfortunately, there are still places where we have to use SIGNAL() and
SLOT() macros, for example the stuff that deals with d-bus business.

Clazy was used to create this change. There were a few cases that needed
manual intervention, the majority of those cases were about resolving
ambiguity caused by overloaded signals.
2020-09-24 09:33:45 +00:00
Vlad Zahorodnii
c7c35513b6 Port TestTabBoxClientModel away from deprecated QWeakPointer::data() 2020-09-10 10:26:32 +03:00
Vlad Zahorodnii
a1fe70baaa Port some tests away from a deprecated QProcess::start() overload 2020-09-10 10:19:30 +03:00
Vlad Zahorodnii
5a0a86c358 Fix unused variable warnings 2020-09-10 10:10:31 +03:00
Kai Uwe Broulik
e14a011165 [effects/fullscreen] Add effect that animates full screen changes
Just a slightly altered copy of the maximize effect
2020-09-09 18:18:16 +00:00
Vlad Zahorodnii
b13a74c908 xwayland: Replace criticalError() signal with a less fatal signal
If the Xwayland executable can't be found, the whole session will die
because a criticalError() signal will be emitted.

This change replaces the criticalError() signal with a less severe
signal.

If the errorOccurred() signal has been emitted during the startup
sequence, kwin won't die and will just continue with spawning the
session process.
2020-09-09 15:25:59 +00:00
Vlad Zahorodnii
6dbc060596 autotests: Use new xdg-shell helpers in ToplevelOpenCloseAnimationTest 2020-09-09 15:23:06 +00:00
Vlad Zahorodnii
2691b84c99 autotests: Introduce helper classes for testing xdg-shell clients
After splitting out the server part of KWayland into a separate repo,
all non-core protocol wrappers in KWayland::Client had become obsolete
and using them in new projects is highly discouraged.
2020-09-09 15:23:05 +00:00
Vlad Zahorodnii
3805f212ec autotests: Remove XdgShellSurfaceType enum
Currently, it has only one item - XdgShellStable.
2020-09-09 13:21:57 +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
d3cca65d39 Implement the layer-shell v1 protocol
The layer-shell protocol allows wayland clients to create surfaces that
can be used for building desktop environment components such as panels,
notifications, etc.

The support for the plasma-shell protocol will be dropped once plasma in
all its entirety is ported to the layer-shell protocol.
2020-09-03 18:11:44 +00:00
Aleix Pol
b2f30e7d7d testScreenEdges: no need to wait twice for Screens::changed
Now ::init does it and we don't need to account for it from test cases
2020-09-03 11:23:06 +02:00
Aleix Pol
5903c5be09 Fix testScreenEdges for good
Don't call kwinApp, because we are not on one.
The correct way to mock the geometries is by using the MockScreens,
which is already used in this test.
2020-09-02 18:05:53 +02:00
Aleix Pol
6d59c0b4e5 Small TestScreenEdges simplification 2020-09-02 15:15:03 +02:00
Aleix Pol
b92b0b0a7c Fix testScreenEdges test with ASAN
Removes unnecessary check
2020-09-02 15:15:03 +02:00
Vlad Zahorodnii
f55ae15788 Remove unused wayland-cursor.h includes 2020-09-02 15:59:36 +03:00
Aleix Pol
f5a75e70dc Fix ASAN warning
Don't leak the MockWorkspace, no other test does.
2020-09-02 13:13:33 +02:00
Aleix Pol
2d1f276c2c Fix warning
Don't include the moc of a file without Q_OBJECT
2020-09-02 13:13:33 +02:00
Aleix Pol
9750a38069 test: add test for edges on mostly overlapping outputs
Inspired in commit b2a44fb08aa140646c879226ee82509aa201ec11 by Roman
Gilg <subdiff@gmail.com> in kwinft.
2020-09-01 14:39:36 +00:00
Marco Martin
97f4712f29 Fix size restore upon keyboard close in XdgSurfaceClient
in XdgSurfaceClient setFrameGeometry is async,
so we can't rely on it having the final value immediately.
make setVirtualKeyboardGeometry a virtual.
in the implementation on setVirtualKeyboardGeometry
use requestedFrameGeometry() instead of frameGeometry()
2020-09-01 08:58:46 +00:00
Vlad Zahorodnii
432cfb44c0 xwayland: Restart the Xwayland server after it has crashed
If the Xwayland process has crashed due to some bug, the user should
still be able to start applications in Xwayland mode. There is no reason
to restart the whole session just to be able to launch some application
that doesn't have native support for Wayland.
2020-09-01 06:16:02 +00:00
Vlad Zahorodnii
472b5e7f9e autotests: Fix the license header in a test 2020-08-28 11:11:09 +03:00
Adrien Faveraux
788c65d260 Fix Build Warning 2020-08-26 19:24:02 +02:00
Vlad Zahorodnii
1c61de1990 autotests: Clean up the outputs list when client connection is closed
If the client connection has been closed, the Output::removed() signal
won't be emitted.
2020-08-20 11:56:42 +03: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
Vlad Zahorodnii
e7d02ad355 Introduce X11 default screen property in Application
This spares unnecessary looping through all available X11 screens.
2020-08-05 08:48:00 +00:00
Vlad Zahorodnii
19ad172584 Survive Xwayland crashes
If the Xwayland process crashes, it will bring down the entire session
together with itself. Obviously, we don't want that. At least, Wayland
clients should survive the crash.

This change refactors relevant X11 parts to handle Xwayland crashes in a
less fatal way.

In order to handle Xwayland crashes better, a pair of start() and stop()
methods had been introduced in the Xwayland class to allow starting and
stopping the Xwayland process at any moment.

If we detect that the Xwayland process has crashed, we will immediately
stop the Xwayland server, which in its turn will deactivate the socket
notifier and destroy all connected X11 clients. Unfortunately, a couple
of subtle changes in X11Client::releaseWindow() and Unmanaged::release()
had to be made to ensure that we are left with a valid state after the
Xwayland server has been stopped.
2020-08-05 08:48:00 +00:00
Vlad Zahorodnii
707a02071e Add a simple test to check Xwayland dying
The new test verifies that we handle Xwayland crashes gracefully.
2020-08-05 08:48:00 +00:00
Niccolò Venerandi
e41c5af676 Expose transientFor and only blur underneath when transientParent is dock 2020-08-02 10:25:28 +00:00
Vlad Zahorodnii
a17a86999b Emit clientAdded for wayland clients
Emit the clientAdded() signal also for Wayland clients in order to unify
the API of the Workspace class for different client types.
2020-07-27 15:01:07 +00:00
Vlad Zahorodnii
1330abc93d Provide hotspot in the device independent pixels
Currently, the trend is to get the coordinates of the hotspot and map it
to the device independent pixels at the call site.

This change makes the KXcursorSprite return the coordinates of the hotspot
in the device independent pixels to reduce the amount of duplicated code.
2020-07-27 15:00:13 +00:00
Benjamin Port
9225848fb0 When maximizing a window raise client and gain focus
BUG: 418938 FIXED-IN: 5.20
2020-07-27 09:26:25 +00:00
David Edmundson
83aa8dccd2 [virtualdekstops] Drop multi-head from VirtualDesktopManagement
Kwin's VirtualDesktop saved a different configuration per X screen. This
messes up with a recent refactor of our startup as now we load
virtualdesktops before the X11 screen number is set and we load from the
group "Desktops-screen--1" then save to another place.

For a wayland session it doesn't make sense to have such a strong X
tie-in. We may as well just tidy this up.

Multihead has been deprecated for a decade. There is absolutely no way
Plasma supports it. Worst case if someone magically is using mutlihead
they just get syncronised virtual desktops.

BUG: 424571
2020-07-23 22:33:14 +00:00
Vlad Zahorodnii
555885072d Check if we successfully restored input focus
In rare cases, Workspace::restoreFocus() may fail, for example when the
most recently activated client is about to be destroyed or unmapped.

If it happens that we cannot restore the focus, then mark the window in
FocusIn event as active.

CCBUG: 424223
2020-07-22 12:29:41 +00:00
Vlad Zahorodnii
80a31ab4b7 Make setFrameGeometry() re-entrant for X and internal clients
If AbstractClient::setFrameGeometry() is called from a slot connected
directly to the frameGeometryChanged() signal, then is there a good
chance that kwin will fall into an infinite recursion. However, that's
the case with only X11 and internal clients.

The root cause of the infinite recursion is that both X11Client and
InternalClient compare the new geometry against the geometry before
update blocking. In order to fix the bug, we simply need to ensure that
updateGeometryBeforeUpdateBlocking() has been called before we start
emitting the frameGeometryChanged() signal.

Furthermore, a couple of tests were added to ensure that we won't hit
this subtle bug again.
2020-07-22 05:51:23 +00:00
Vlad Zahorodnii
2717252861 Partially revert a0c4a8e766
Unfortunately, a0c4a8e766 has a major bug
where clients that track focus events may get confused by focusToNull().

One such a notable example is Dota 2. It tracks the focus events to
minimize itself after the keyboard focus has been lost as well stop
playing music while it's in background. So, when we call focusToNull(),
Dota 2 will receive a corresponding FocusOut event and ask the window
manager to minimize it. It doesn't really matter that the FocusOut
event is going to be followed by a FocusIn event because when a window
is minimized, kwin will activate the next one in the focus chain.

Since those issues can't be fixed from the window manager's side, this
patch partially reverts a0c4a leaving only the autotest.

BUG: 424223
FIXED-IN: 5.19.4
2020-07-21 12:56:21 +03:00
Andrey Butirsky
0bb05d4b1a make keyboard layout DBus API more reliable
having deferred m_dbusInterface deletion allows to send DBus signal in
more cases.
That addressed in unit tests.
2020-07-17 12:42:28 +00:00
Andrey Butirsky
8e1018de2c save default keyboard layout
Implemented for Global, Virtual Desktop and Application layout policies.
Not implemented for Window policy due separate windows do not preserve
their IDs between sessions (still could be implemented the same way as for Application policy).

Layout saving/restoring happens on Session save/load.
Covered by unit tests
2020-07-17 12:42:28 +00:00
Vlad Zahorodnii
cf27128877 Update input transformation matrix when buffer geometry changes
Currently, we update the input transformation matrix for the focused
pointer surface only when the frameGeometryChanged() signal is emitted.
However, since the input transformation matrix is computed based on the
current position of the upper left corner of the main surface, it is
wrong to do so because the frame geometry is a logical geometry that
doesn't have any direct relationship with the buffer geometry, i.e. the
rect on the screen occupied by the main surface.

If the input transformation matrix gets out of sync, user may notice
that pointer events are "shifted."

This change introduces a new signal that's emitted when the input
transformation matrix has been changed. Input related components in kwin
can connect to it to keep a copy of the input transformation matrix in
SeatInterface in sync. Under the hood, the new signal is just an alias
for the bufferGeometryChanged() signal.
2020-07-17 11:56:22 +00:00
Vlad Zahorodnii
fc839d8b29 Fix testActivities
Currently, the test passes because the activities controller doesn't
have enough time to fetch all activities. So, the test client won't be
placed on the current activity.

Since the Workspace is now created before starting the Xwayland, we now
spin the event loop, which allows the activities controller to fetch the
list of all activities and so the test client will be placed on the
current activity, i.e. client->isOnAllActivities() will no longer return
true.

This change fixes wrong assumptions in the test and makes it robust.
2020-07-17 09:10:51 +00:00
Vlad Zahorodnii
97cf90269a Start accepting client connections after creating workspace
Sub-classes of the AbstractClient class need a valid instance of the
Workspace class to function as desired. We should not create xdg-shell
clients until the workspace is created.
2020-07-17 09:10:51 +00:00