Commit graph

50 commits

Author SHA1 Message Date
Vlad Zahorodnii
de36fe82e8 wayland: Integrate KWaylandServer classes into KWin namespace 2023-09-15 16:31:15 +03:00
Vlad Zahorodnii
b9ba12d02e wayland: Reimplement wl-drm
As of nowadays, most clients have switched to the linux-dmabuf protocol,
except Xwayland, which still needs the wl-drm protocol.

On the other hand, we would like to unify some buffer handling code.
There are a few options:

- drop the support for wl-drm protocol. Not doable, because Xwayland
  still needs it, even though it uses the linux dmabuf feedback protocol
  too
- re-implement the wl-drm protocol
- re-implement the minimal part of the wl-drm protocol needed by
  Xwayland

This change goes after the third option. Only the node name and the
capabilities will be sent. The buffer factory requests are not
implemented, but they can be if we discover that some clients need them.
2023-04-14 14:13:56 +00:00
Vlad Zahorodnii
e2d690e0aa Remove unused stuff in wayland_server.{h,cpp} 2023-04-11 13:39:23 +03:00
Vlad Zahorodnii
466868f5d4 wayland: Refactor linux-dmabuf buffer management
At the moment, the render backend provides its specific implementation
of LinuxDmaBufV1ClientBuffer. This has some of its limitations. For
example, due to the strong coupling, compositing restarts must be
handled carefully. It's hard to have a generic code path to import
dmabufs, which would be nice to have in order to unify graphics buffer
allocation across various backends; currently, it's all scattered.

To make the code simpler, this change drops the commented out YUV import
code path for now. Given that Mesa implicitly handles it, the need for
it is no longer so urgent.
2023-04-11 07:59:28 +00:00
Vlad Zahorodnii
e88a4e34a3 Remove some include_directories()
It seems we've settled on dir/dir/header.h includes, so let's use them
consistently.
2023-03-23 14:37:48 +02:00
David Redondo
d5679ee82c Port some connections to Qt::SingleShotConnection 2023-03-16 11:03:07 +01:00
Xaver Hugl
3204d6ac3c port all headers to pragma once 2022-12-16 20:58:17 +00:00
Vlad Zahorodnii
eec07c477d wayland: Require to reboot computer after changing primary selection option
Not all clients handle well withdrawing the primary selection global at
runtime, so apply the new primary selection option only after a reboot.
2022-12-16 12:47:11 +00:00
Vlad Zahorodnii
da229ebe85 Revert "Disable PrimarySelection in seat setPrimarySelection"
This reverts commit e60f26e0ab.

Cancelling the primary selection breaks text selection in applications
such as gedit. In those apps, you can't select text neither with your
mouse nor keyboard.

BUG: 461498
2022-12-16 12:47:11 +00:00
Xaver Hugl
0efb8d01db wayland: implement output order interface
Only thing missing is the kscreen integration bit, but that can't be done before kscreen actually stores the output order somewhere.

Depends on https://invent.kde.org/libraries/plasma-wayland-protocols/-/merge_requests/52
2022-12-15 10:08:36 +00:00
Vlad Zahorodnii
fdea693da5 wayland: Implement xwayland-shell-v1
As explained in [1], WL_SURFACE_ID is racy because wayland aggressively
reuses object ids. The xwayland-shell-v1 protocol intends to fix that by
two things:

* associating a serial number with each X11 window. This is to avoid
  potential XID reuse
* referring to the wayland surface by the wl_surface rather than
  specifying an object id

Unfortunately, we will have to maintain both legacy WL_SURFACE_ID and
WL_SURFACE_SERIAL for quiet some time until most instances of Xwayland
support the xwayland-shell-v1 protocol [2].

[1] https://gitlab.freedesktop.org/xorg/xserver/-/issues/1157
[2] https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/163
2022-12-05 17:09:01 +02:00
Xaver Hugl
b261050be1 wayland: implement tearing_control_v1 2022-12-05 12:52:18 +00:00
Xaver Hugl
49ad013295 backends/drm: remove Wayland bits for drm leasing 2022-10-21 13:33:42 +02:00
Vlad Zahorodnii
7115ea75a4 Drop WaylandOutput 2022-10-20 12:27:51 +00:00
Xaver Hugl
b99ae81b08 wayland: implement the content-type protocol 2022-10-20 13:46:58 +02:00
Méven Car
e60f26e0ab Disable PrimarySelection in seat setPrimarySelection
BUG: 456167
2022-09-29 10:32:03 +00:00
David Redondo
16a5831fee Implement xwayland-keyboard-grab protocol
Only XWayland can see and bind to this global.
When a XWayland surface is focused that has a grab, shortcuts
are inhibited.
BUG:455159
FIXED-IN:5.26
2022-09-23 15:49:01 +02:00
Vlad Zahorodnii
eeb701bfe3 Add KWin::Output handle to OutputInterface
That's a necessary change for further output related refactorings. It
also allows us to simplify some OutputInterface to Output mapping code.
2022-08-25 15:08:20 +03:00
Vlad Zahorodnii
b01cfb8514 wayland: Merge WaylandOutputDeviceV2 and OutputDeviceV2Interface 2022-08-23 07:18:39 +00:00
Vlad Zahorodnii
ca6f84dad6 Rework how wl_output and kde-output-device are created
Create wl_outputs only for outputs in Workspace.
2022-08-11 17:17:47 +03:00
Vlad Zahorodnii
a6d72d3f60 wayland: Introduce IdleDetector
The IdleDetector is an idle detection helper. Its purpose is to reduce
code duplication in our private KIdleTime plugin and the idle wayland
protocol, and make user activity simulation less error prone.
2022-06-29 20:27:50 +03:00
Méven Car
4082fdf960 WaylandServer: Add a setting to disable PrimarySelection
CCBUG: 441668
2022-06-19 05:49:20 +00:00
Vlad Zahorodnii
e6a2cbc345 wayland: Simplify keystate protocol implementation
Access input machinery directly to monitor modifiers.

Tested-by: Merge Service <https://invent.kde.org/plasma/kwin/-/merge_requests/2447>
Part-of: <https://invent.kde.org/plasma/kwin/-/merge_requests/2447>
2022-05-23 07:06:29 +00:00
Aleix Pol
1176f31e0d Support KWindowSystem interface with activation support
Allow internal uses of KWindowSystem to support activating other
clients.

BUG: 453748
BUG: 453785
2022-05-18 13:48:52 +00:00
Vlad Zahorodnii
175037d9d1 Prefer the term "window" over "client" in Workspace 2022-04-25 11:33:55 +00:00
Vlad Zahorodnii
4b91c6163f Rename XdgShellClient to XdgShellWindow
The word "client" means different things in wayland and kwin. Use a
better word to refer to windows.
2022-04-23 07:55:51 +00:00
Nils Fenner
b491aeb9ae Rename AbstractClient to Window 2022-04-22 17:39:12 +00:00
Nils Fenner
aaa429ee0a Merge Toplevel into AbstractClient
References issue #81
2022-04-18 07:42:11 +00:00
Vlad Zahorodnii
8e7a8c5a11 Rename AbstractOutput to Output
AbstractOutput is not so Abstract and it's common to avoid the word
"Abstract" in class names as it doesn't contribute any new information.
It also significantly reduces the line width in some places.
2022-04-15 17:49:49 +03:00
Vlad Zahorodnii
d43dac8f8d Merge AbstractWaylandOutput with AbstractOutput 2022-04-15 14:49:02 +00:00
Aleix Pol
e3fe69041f Centralise window filtering around a new SceneWindowFilter class
This way WaylandServer can implement its own filter with its own set of
rules without having Scene be too involved in it.
2022-04-13 11:17:34 +00:00
Xaver Hugl
c16a8e09d7 waylandserver: only signal lockScreenShown once it has actually been shown
When the system goes to suspend and screen locking for suspend is enabled,
suspend is inhibited until ScreenLocker::KSldApp::self()->lockScreenShown()
gets called, in order to make sure that the lockscreen is shown before the
system goes to standby, and thus also when the system wakes (instead of
potentially sensitive user information).
However, signalling that when the lockscreen gets mapped can't work reliably,
as it's then a matter of timing whether or not KWin actually presents an
image with the lockscreen before suspending. To fix that, this commit replaces
that logic with only calling lockScreenShown once every output actually got a
lockscreen presented.
2022-03-30 15:57:29 +02:00
Vlad Zahorodnii
7096e3ead8 Run clang-format
The .clang-format file is based on the one in ECM except the following
style options:

 - AlwaysBreakBeforeMultilineStrings
 - BinPackArguments
 - BinPackParameters
 - ColumnLimit
 - BreakBeforeBraces
 - KeepEmptyLinesAtTheStartOfBlocks
2022-03-25 13:25:15 +02:00
Weng Xuetian
7a270b5d78 Use QPointer to monitor input method server connection.
Input method may crash and leave a dangling pointer. DBus interface may
access the invalid pointer and crash kwin.
2021-12-16 03:29:00 +00:00
Aleix Pol
c1e9cc283d Implement Primary Displays on the wayland session
Adopts the kde_outputmanagement_v2 hooks for it
2021-11-09 16:55:39 +00:00
Vlad Zahorodnii
b4a4e8a45d Drop WaylandServer::terminateClientConnections()
Display will destroy all client connections before getting destroyed.
2021-10-14 10:02:50 +00:00
Vlad Zahorodnii
e550480c43 Rework input method teardown logic
Explicitly destroy input method rather than wait for the input method
connection to be destroyed by WaylandServer, it's less error prone.

BUG: 443603
2021-10-14 10:02:50 +00:00
Vlad Zahorodnii
bf620fbe04 Move Xkb::LEDs enum to KWin namespace
With the LEDs enum being defined in kwinglobals.h, wayland_server.h
won't need to include keyboard_input.h, which is good for compilation
times and wayland_server.h will drag less stuff, e.g. QtWidgets (input.h
includes QAction)
2021-10-13 17:49:19 +00:00
Vlad Zahorodnii
260b224d3b Drop WaylandServer::dispatch()
There's no any good reason to dispatch events at shutdown.
2021-10-12 06:32:55 +00:00
Vlad Zahorodnii
5be593d4e4 wayland: Drop internal connection
It's practically unused now.
2021-10-07 13:28:08 +00:00
Méven Car
8c908c69bc Port src/plugins/idletime/poller.cpp away from the internal connection 2021-10-01 15:01:23 +00:00
Méven Car
0a2c511489 Wayland: Add support for protocol kde-output-device_v2, allow to detect drm mode changes
CCBUG: 407058
2021-09-01 13:37:43 +00:00
Vlad Zahorodnii
7ffd72cbfa Decouple activation feedback from window management 2021-08-25 09:35:57 +00:00
Vlad Zahorodnii
964c487d4f wayland: Switch to ClientBuffer
The main motivation behind the split is to simplify client buffer code
and allow adding new features easier, for example referencing the shm
pool when a shm buffer is destroyed, or monitoring for readable linux
dmabuf file descriptors, etc.

Also, a referenced ClientBuffer cannot be destroyed, unlike the old
BufferInterface.
2021-07-23 15:33:38 +00:00
Aleix Pol
27e043920a xdg_activation_v1 implementation 2021-05-24 17:19:25 +02:00
Vlad Zahorodnii
33b2ea2058 wayland: Fix internal connection teardown
The internal EventQueue is a child of the registry object. This means
that after the registry is destroyed, all proxy objects in that event
queue are going to have invalid reference to it, which is not a problem
as long as the wl_display_dispatch() function is not called.

The wl_display_dispatch() function uses wl_proxy's queue reference to
enqueue incoming events to that queue.

Unfortunately, during teardown, the internal ConnectionThread may
dispatch events right after the registry object has been destroyed,
which can lead to a crash.

In order to fix the crash, we need to destroy all proxy objects and only
after that we can destroy the event queue. It's okay if wayland events
are dispatched in between.
2021-05-13 18:51:35 +00:00
Vlad Zahorodnii
7d0cad07fb autotests: Fix XwaylandInputTest
For some reason, Xwayland doesn't like starting without outputs. If
outputs are added later, it sends bogus EnterNotify and LeaveNotify
events.
2021-05-13 11:44:41 +00:00
Vlad Zahorodnii
0e63b4e8cc wayland: Simplify plasmashell surface installation code 2021-05-13 09:20:20 +03:00
Vlad Zahorodnii
c27230719c wayland: Move Wayland-specific code out of AbstractWaylandOutput
Currently, output properties are looked up either on the wl_output
object or the output device object. This puts a hard dependency on the
wayland server in the platforms.

This change intends to fix some flaws in the current output
abstractions, and allow creating/destroying wayland-specific globals as
we wish.

With the work done in this patch, the need for the AbstractWaylandOutput
class is unclear, and it might be a good idea to merge it with the base
AbstractOutput class.
2021-04-07 14:23:16 +03:00
Vlad Zahorodnii
93e0265e4e Move source code to src/ directory
Once in a while, we receive complaints from other fellow KDE developers
about the file organization of kwin. This change addresses some of those
complaints by moving all of source code in a separate directory, src/,
thus making the project structure more traditional. Things such as tests
are kept in their own toplevel directories.

This change may wreak havoc on merge requests that add new files to kwin,
but if a patch modifies an already existing file, git should be smart
enough to figure out that the file has been relocated.

We may potentially split the src/ directory further to make navigating
the source code easier, but hopefully this is good enough already.
2021-02-10 15:31:43 +00:00
Renamed from wayland_server.h (Browse further)