xwayland-run/0001-wlheadless-Add-support-for-kwin.patch

152 lines
5.3 KiB
Diff
Raw Normal View History

2023-12-10 22:47:20 +00:00
From 9f1392fd57e78c9d785a1211ce84bfd5ca1226e6 Mon Sep 17 00:00:00 2001
From: Neal Gompa <neal@gompa.dev>
Date: Sun, 10 Dec 2023 16:46:01 -0500
Subject: [PATCH] wlheadless: Add support for kwin
---
README.md | 5 +--
man/wlheadless-run.man | 2 +-
meson_options.txt | 2 +-
src/wlheadless/kwin.py | 76 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 81 insertions(+), 4 deletions(-)
create mode 100644 src/wlheadless/kwin.py
diff --git a/README.md b/README.md
index f4d4490..d37243e 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,7 @@ and currently support the following compositors:
* [weston](https://gitlab.freedesktop.org/wayland/weston)
* [cage](https://github.com/cage-kiosk/cage)
+ * [kwin](https://invent.kde.org/plasma/kwin)
* [gnome-kiosk](https://gitlab.gnome.org/GNOME/gnome-kiosk)
* [mutter](https://gitlab.gnome.org/GNOME/mutter)
@@ -81,7 +82,7 @@ usage: wlheadless-run [-c compositor] <compositor arguments> -- client <client a
```
The compositor must be supported by `wlheadless-run`, which currently includes
-the following compositors: `weston`, `cage`, `mutter`, `gnome-kiosk`.
+the following compositors: `weston`, `cage`, `kwin`, `mutter`, `gnome-kiosk`.
The given compositor arguments must be supported by the specified Wayland compositor
and will be added to the command line when starting the compositor. That allows for
@@ -147,7 +148,7 @@ options:
```
The compositor must be supported by `xwfb-run`, which currently includes the
-following compositors: `weston`, `cage`, `mutter`, `gnome-kiosk`.
+following compositors: `weston`, `cage`, `kwin`, `mutter`, `gnome-kiosk`.
Optional arguments passed to the Xserver (using the `-s` or `--server-args` option)
must be escaped twice to prevent `xwfb-run` from trying to parse them, e.g. `-s \\-ac`
diff --git a/man/wlheadless-run.man b/man/wlheadless-run.man
index f1f5d3a..6c52db2 100644
--- a/man/wlheadless-run.man
+++ b/man/wlheadless-run.man
@@ -32,7 +32,7 @@ running headless.
.TP 8
.B \-c COMPOSITOR
Use the compositor class implementation. Currently supported compositor
-classes are \fIweston\fP, \fImutter\fP, \fIgnome-kiosk\fP, \fIcage\fP.
+classes are \fIweston\fP, \fIkwin\fP, \fImutter\fP, \fIgnome-kiosk\fP, \fIcage\fP.
.SH FILES
.TP 8
.I wlheadless.conf
diff --git a/meson_options.txt b/meson_options.txt
index 97367ba..535da87 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,4 @@
option('compositor',
type: 'combo',
- choices: ['cage', 'gnome-kiosk', 'mutter', 'weston'],
+ choices: ['cage', 'gnome-kiosk', 'kwin', 'mutter', 'weston'],
value: 'weston')
diff --git a/src/wlheadless/kwin.py b/src/wlheadless/kwin.py
new file mode 100644
index 0000000..e529229
--- /dev/null
+++ b/src/wlheadless/kwin.py
@@ -0,0 +1,76 @@
+#
+# Copyright © 2023 Neal Gompa.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+
+""" Abstraction for running a Wayland client on kwin headless. """
+
+from os import environ, getpid
+from wlheadless.wlheadless_common import WlheadlessCommon
+from wlheadless.xwayland import Xwayland
+
+class Wlheadless:
+
+ """
+ Abstraction for running a Wayland client on kwin headless.
+ """
+
+ def __call__(self):
+ return self
+
+
+ def __init__(self):
+ self.compositor_args = []
+ self.compositor = [
+ 'kwin_wayland',
+ '--virtual',
+ ]
+ self.wlheadless_common = WlheadlessCommon()
+ self.xwayland = Xwayland()
+
+
+ def spawn_client(self, command_args):
+ """Helper function to spawn kwin and the client at once."""
+ wayland_display = 'wayland-' + format(getpid())
+ environ['WAYLAND_DISPLAY'] = wayland_display
+ compositor = self.compositor
+ compositor.extend(self.compositor_args)
+ compositor.extend(['--wayland-display', format(wayland_display)])
+ compositor.extend(['--'])
+ compositor.extend(command_args)
+ return self.wlheadless_common.run_command(compositor)
+
+
+ def spawn_xwayland(self, xserver_args = []):
+ """Helper function to spawn kwin and Xwayland at once."""
+ compositor = self.compositor
+ compositor.extend(self.compositor_args)
+ compositor.extend(['--'])
+ xserver_args.extend(['-fullscreen'])
+ return self.xwayland.spawn_xwayland(xserver_args, compositor)
+
+
+ def wait_compositor(self):
+ """Waits for the compositor to start."""
+ return 0
+
+
+ def run_compositor(self, compositor_args = []):
+ """Starts the Wayland compositor."""
+ # Just save the given args for when we shall actually spawn the compositor.
+ self.compositor_args = compositor_args
+ return 0
--
2.43.0