Commit graph

51 commits

Author SHA1 Message Date
Vlad Zahorodnii
7d56aa3687 Merge wayland tests with other tests
This makes wayland tests organization consistent with other kwin tests.
2023-10-06 11:21:00 +00:00
Vlad Zahorodnii
de36fe82e8 wayland: Integrate KWaylandServer classes into KWin namespace 2023-09-15 16:31:15 +03:00
Vlad Zahorodnii
8bf2318800 wayland: Drop "_interface" from filenames
The cpp files in the wayland directory are named after protocol names.
"_interface" does not contribute anything new.
2023-09-15 13:13:43 +00:00
Laurent Montel
86c6238cfa Don't use QtTest => use QTest + missing include 2023-07-04 10:38:21 +00:00
David Edmundson
f88ff99d82 wayland: Truncate strings sent via plasmawindowmanager interface
Wayland has a limited size for strings in arguments. We should truncate
any strings that come from user-defined data before sending.

We keep the full title around within kwin as it keeps logic simpler.
Size length logic is lifted from QWaylandWindow's setTitle

BUG: 465775
2023-03-17 12:21:48 +00:00
Vlad Zahorodnii
9f345d4dd3 autotests: Fix remaining "using namespace KWayland::Client" 2022-11-08 23:15:17 +02:00
Vlad Zahorodnii
6d3f00e82c autotests: Remove QVERIFY(signalSpy.isValid())
We use the PMF syntax so the isValid() check is unnecessary as the
compiler will notify about wrong signal at compile time. It makes
writing autotests feel less boilerplaty.
2022-09-14 09:21:29 +00:00
Xaver Hugl
8955a2420e replace all uses of QScopedPointer with std::unique_ptr 2022-08-04 12:30:09 +00:00
Vlad Zahorodnii
b64f95b703 Integrate kwaylandserver
This makes KWin switch to in-tree copy of KWaylandServer codebase.

KWaylandServer namespace has been left as is. It will be addressed later
by renaming classes in order to fit in the KWin namespace.
2022-04-22 12:27:33 +03:00
Volker Krause
ccad0066e7 Disambiguate KWaylandServer::Display
This unfortunately clashes with a typedef in a Qt6 header.
2022-03-18 14:34:41 +00:00
Alexander Lohnau
525d12bee5 Run clang-format
If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
2021-08-29 07:11:06 +02:00
Vlad Zahorodnii
9763aec020 Send an icon only if there is one
Currently, plasma window model test fails because the null icon is
received after executing the main body of the test.

    FAIL!  : PlasmaWindowModelTest::testVirtualDesktops() '!dataChangedSpy.wait(100)' returned FALSE. ()
       Loc: [/data/projects/src/kwayland-server/autotests/client/test_plasma_window_model.cpp(583)]

We can fix the test by waiting for the iconChanged signal to be emitted,
but we will need to wait in all tests too. Furthermore, it doesn't make a
lot of sense to wait for an icon that was never set.

This change makes the compositor send an icon only if there is one.

It's a behavioral change, but it shouldn't regress anything because kwin
always sets icons via the plasma window management protocol even for apps
that have no valid app id.

It also makes the api of the PlasmaWindowInterface class more intuitive.
2021-03-16 15:43:59 +02:00
Vlad Zahorodnii
f321882177 autotests: Fix testWindowmanagement
Currently, testIcon fails because the actual and the expected pixmaps
have mismatching formats.

The root cause is that images with an alpha channel will loose the alpha
channel if they are converted to QPixmap using QPixmap::fromImage().

The >> stream operator for the QPixmap class will deserialize pixel data
in a temporary QImage and then use QPixmap::fromImage() to get a pixmap
object.

The >> stream operator for the QIcon class will delegate the task of
reading the icon from a QDataStream to QPixmapIconEngine, which uses the
>> stream operator under the hood to deserialize icon data.

In order to fix testIcon, this change constructs a dummy icon from a
pixmap object returned by QPixmap::fromImage().
2021-03-16 15:28:46 +02:00
Vlad Zahorodnii
16db81b5cc Make RegionInterface private
If a Wayland protocol deals with regions, they will be exposed as
QRegion objects in public API. Therefore, it makes sense to make
RegionInterface private as it's an implementation detail and it's
not intended to be used in public api.

The corresponding test was dropped because the CompositorInterface
no longer emits a signal to indicate that a wl_region has been created.
It should be also noted that wl_region stuff is already tested via
other means, e.g. surface damage, etc.
2021-03-15 16:28:30 +00:00
David Edmundson
1a0020b18f Move PlasmaWindowInterface lifespan management to the caller
PlasmaWindowInterface is a "Server-managed multicasting resources". We
no longer need our wrapper to outlive objects so we can tidy that up.

It's weird to have a method call to an object delete the object, so
memory management is moved to the caller to be consistent.
2021-03-11 12:01:52 +00:00
David Edmundson
09a45da505 Port all connects
This is mostly all automatic from clazy, though it got confused by a few
namespace issues.
2021-02-25 13:48:11 +00:00
Vlad Zahorodnii
09e079b78f Remove factory methods in Display
The main reason why we have factory methods is that up to some point,
kwayland had its own signal to indicate when globals have to be removed.

Now that all globals add destroy listeners for the wl_display object,
we don't have that signal. Most factory methods are equivalent to doing
new T(display).

Besides adding unnecessary boilerplate code, another reason to get rid
of the factory methods is to reduce the amount of merge conflicts. If
several persons work on implementing wayland protocols at the same time,
sooner or later someone will have to resolve merge conflicts in Display.
2020-12-14 13:04:59 +00:00
Vlad Zahorodnii
1247a53eba Allow accepting client connections on multiple sockets
libwayland-server allows the wl_display accept client connections on
more than one socket. We currently don't listen on multiple sockets,
but it would be nice if Display supported such operation mode.
2020-12-09 07:20:42 +00:00
Vlad Zahorodnii
34982850e2 Destroy all clients before destroying wl_display
One of the most disappointing things when writing autotests is dealing
with a race condition where destructor requests are processed after all
globals have been destroyed.

With this change, the Display object will destroy all clients and their
resources before destroying the wl_display object. The good thing about
doing so is that shut down logic becomes simple. We don't have to assume
that wl_resource objects can outlive their wl_global objects, etc. The
bad thing is that it exposed a couple of pre-existing latent bugs in the
data device and the xdg foreign code.

closes plasma/kwayland-server#2
2020-11-11 09:26:57 +02:00
adrien faveraux
af16210c95 Migrate Window Management to new approach 2020-09-28 11:40:51 +00:00
Aleix Pol
97219ec2d5 PlasmaWindow::internalId was deprecated in favor of ::uuid 2020-07-23 12:57:17 +00:00
Vlad Zahorodnii
33f4254bd1 Port the wl_compositor wrapper to the new approach 2020-07-15 11:05:59 +03:00
Vlad Zahorodnii
46e4f0948b Port the wl_surface wrapper to the new approach 2020-07-15 11:05:57 +03:00
Aleix Pol
306f242ac8 Port namespaces and includes 2020-04-29 16:56:38 +02:00
Aleix Pol
5d4cd7dcd3 Fix build 2020-04-29 15:59:23 +02:00
Carson Black
53a0c4faec Add test for application menu in PWM interface
Test Plan: See that the test works as expected.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D28164
2020-03-20 12:59:10 -04:00
Andreas Cord-Landwehr
9267f146fd KWayland: Convert license headers to SPDX
Summary:
Convert license headers to SPDX expressions and add license files as
required by REUSE specification.

Reviewers: zzag

Reviewed By: zzag

Subscribers: kde-frameworks-devel

Tags: #frameworks

Maniphest Tasks: T11550

Differential Revision: https://phabricator.kde.org/D28058
2020-03-16 19:57:44 +01:00
Vlad Zagorodniy
0d170cecb4 [autotests] Stabilize testWindowmanagement
Summary:
In rare cases testWindowmanagement fails because the initial iconChanged
signal gets emitted after setIcon is called.

Reviewers: #kwin

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D18421
2019-01-31 17:45:19 +02:00
Laurent Montel
6f45c74471 Remove qt include prefixx 2018-11-06 07:22:36 +01:00
Laurent Montel
f552ba47dc normalize signal/slot 2018-11-04 23:20:24 +01:00
Yuri Chornoivan
96df0ea6ae Fix minor EBN issues 2018-09-12 20:49:38 +03:00
Scott Harvey
7d3deb7e68 Add "SkipSwitcher" to API
Summary:
Adding "SkipSwitcher" to API, as a result of discussion in
BUG 375921

Depends on / related to D11924 and D11926.

Reviewers: hein, graesslin

Reviewed By: graesslin

Subscribers: kde-frameworks-devel, lbeltrame, rikmills, davidedmundson, #plasma, graesslin

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D11925
2018-05-22 10:27:43 -05:00
Marco Martin
7d10af91b1 add requestToggleKeepAbove/below
Summary: client requests to toggle those states, to be used by libtaskmanager

Test Plan: setting keep above from the taskbar works

Reviewers: #plasma, hein, graesslin, #plasma_on_wayland

Reviewed By: #plasma, hein

Subscribers: graesslin, hein, plasma-devel, #frameworks

Tags: #frameworks, #plasma

Differential Revision: https://phabricator.kde.org/D5757
2017-05-24 18:02:22 +02:00
David Edmundson
e182a2cc24 Remove pid changedSignal in Client::PlasmaWindow
Summary: Verified it it send before the initial_state and adjust tests and docs accordingly

Test Plan: All unit tests pass

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D5887
2017-05-16 15:54:08 +01:00
Sebastian Kügler
1154b2a6fd add pid to plasma window management protocol
Summary:
This patch adds a pid event to the plasma window management protocol. It
allows the compositor to tell allow a mapping between windows and processes.

Bumps the version number of the interface to 8 to indicate this.

Test Plan: autotest added, passed

Reviewers: #plasma, hein, graesslin

Reviewed By: #plasma, hein, graesslin

Subscribers: apol, davidedmundson, plasma-devel, #frameworks

Tags: #frameworks, #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5747
2017-05-13 17:09:12 +02:00
Martin Gräßlin
d92592a291 Support passing generic QIcon through PlasmaWindow interface
Summary:
Especially for Xwayland windows the compositor might not have a themed
icon name. Resulting in a task manager not having dedicated icons for
Xwayland windows.

This change deprecates the way how a compositor is supposed to set the
window icon. Instead of passing the themed icon name, it is now supposed to
pass the QIcon. In case it's a themed icon the existing way to pass to
the client is used.

Otherwise a new event is used to inform the client that there is an icon
- no data is transmitted at this point. The client can then create a
file descriptor and pass it to the compositor. The compositor serializes
the icon into the file descriptor and the client can read from it. This
all happens transparently on client side there is no api change at all.

The writing and reading of the icon is done in a thread. Due to that
Qt5::Concurrent is now a required dependency instead of an optional
dependency.

Reviewers: #plasma_on_wayland, hein

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3049
2016-10-17 07:35:21 +02:00
Martin Gräßlin
34eb146db7 [autotests] Try to make TestWindowManagement more robust
The test started to segfault on build.kde.org. It looks like an event
survives the destruction of the server. Thus this change tries to
dispatchEvents once more before destroying everything.
2016-08-22 15:57:25 +02:00
Martin Gräßlin
ccb4ac4280 Add a geometry event to PlasmaWindow
Summary:
This allows the compositor to expose the absolute window geometry to
processes which need it.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2183
2016-07-15 13:31:54 +02:00
Martin Gräßlin
d52485ffb7 Add a parent_window event to Plasma Window interface
Summary:
This change adds a parent_window event to Plasma Window. From server
side it's possible to specify that a window is a transient for another
window - that is it has a parent window.

On client side this is exposed respectively with a new change signal.

Reviewers: #plasma_on_wayland, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1779
2016-06-29 08:03:55 +02:00
Martin Gräßlin
7844e38e79 [autotests] Add test for showing desktop in PlasmaWindowManagement 2016-06-25 21:04:48 +02:00
Martin Gräßlin
c9ec19d522 [autotest] Extend testing for the requests in PlasmaWindowInterface 2016-06-25 11:41:19 +02:00
Martin Gräßlin
2120d13632 Introduce an initial state event into Plasma Window protocol
Summary:
The event is sent to the client once all initial state is transmitted.
This means the client is able to see the PlasmaWindow completely created
and not in the intermediate state with further updates being pushed after
being created.

The client side API is adjusted to emit the windowCreated signal after
the initial state event is received. In addition if the window is already
unmapped, the signal will never be emitted which means the not valid
windows are not exposed to the client at all.

The tests are adjusted to reflect the new reality, which in most cases
just means removing the comment that this needs to be improved.

There is one kind of unrelated change included: when an empty icon is
set, the client side now creates a QIcon() instead of going through
QIcon::fromTheme. This wrong behavior was exposed now by the auto tests.

Reviewers: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1773
2016-06-06 13:07:35 +02:00
Martin Gräßlin
151a910f4c [server] Properly handle the case that a PlasmaWindow is unmapped before client bound it
Summary:
So far we directly destroyed the resource on the server side. But this
causes a wayland error when the client tries to cleanup. This results in
the client being destroyed. A problem which brings down plasmashell
regularly when short living windows are shown. This happens e.g. in
Dolphin with the adress auto complete.

This change addresses the problem by creating a temporary
PlasmaWindowInterface for the already unmapped window. It doesn't get
added to the list of known windows and it's only purpose is to properly
handle the unmap and the destroy of the just created resource.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1734
2016-06-01 15:43:21 +02:00
Martin Gräßlin
2c5bc69d1d [client] Ensure PlasmaWindowManagement updates active window if it goes away
Summary:
So far when the active PlasmaWindow got unmapped or destroyed, the
PlasmaWindowManagement didn't update the activeWindow. This means it
could expose a deleted object through it's API which could result in
a crash.

This change addresses the problem by updating the active window when
a window gets unmapped or destroyed.

Test Plan: Tests added which exposed the problem

Reviewers: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1621
2016-05-17 09:02:10 +02:00
Martin Gräßlin
372955bf05 Improve the deconstruction of PlasmaWindows
Summary:
The protocol is extended by a dedicated destructor request. When a
PlasmaWindow is umapped we no longer destroy the resource directly,
but only send the unmap. The client is then supposed to clean up
(which it already did in that case) and will invoke the destructor.

The PlasmaWindowInterface object will be automatically deleted after
the unmap once all resources bound for it are destroyed.

The tests are extended by two new test cases which triggered protocol
errors on the client side prior to this change.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1594
2016-05-12 10:55:07 +02:00
Martin Gräßlin
eff6a69544 [autotest] Fix crash in TestWindowManagement::cleanup
Didn't delete the m_windowManagement causing a crash on teardown.
2016-03-02 08:16:23 +01:00
Martin Gräßlin
a28b9ee1e3 [autotests] Delete connection in thread in TestWindowmanagement
If that fixes the ASAN error, we should do it in all tests.
2015-11-11 09:03:42 +01:00
Martin Gräßlin
d72188130f [autotests] Use QStringLiteral for TestWindowManagement::testWindowTitle 2015-11-11 08:52:37 +01:00
Martin Gräßlin
9297ce9c5a [autotests/client] Use GUILESS_MAIN for TestWindowManagement 2015-11-11 08:31:04 +01:00
Martin Gräßlin
f19fedb0f6 [autotests] Cleanup surface handling in TestWindowManagement
For some reason two surfaces were created and the surface not cleaned
up before the connection thread exits.

This caused ASAN to complain.
2015-11-09 09:40:58 +01:00