Refresh kwin support patch with final version

This commit is contained in:
Neal Gompa 2024-01-13 08:15:59 -05:00
parent 9729db0e68
commit 07a5add7ef
2 changed files with 33 additions and 30 deletions

View File

@ -1,15 +1,21 @@
From ac94b6621c2dfa70329fbc89c77ad7a5042f1d5a Mon Sep 17 00:00:00 2001 From c5846bed1d01497c75f8347e4d5dd1077cf171e9 Mon Sep 17 00:00:00 2001
From: Neal Gompa <neal@gompa.dev> From: Neal Gompa <neal@gompa.dev>
Date: Sun, 10 Dec 2023 18:03:30 -0500 Date: Tue, 2 Jan 2024 21:36:40 -0500
Subject: [PATCH] wlheadless: Add support for kwin Subject: [PATCH] wlheadless: Add support for kwin
Even though kwin_wayland supports passing a command, it seems the actual
arguments following the command get ignored, so this is not suitable for
wlheadless.
Instead, we spawn kwin_wayland and the clients separately like we do for
weston.
--- ---
README.md | 5 ++- README.md | 5 +--
man/wlheadless-run.man | 2 +- man/wlheadless-run.man | 2 +-
meson_options.txt | 2 +- meson_options.txt | 2 +-
src/wlheadless/kwin.py | 76 ++++++++++++++++++++++++++++++++++++++ src/wlheadless/kwin.py | 70 ++++++++++++++++++++++++++++++++++++++
src/wlheadless/meson.build | 1 + src/wlheadless/meson.build | 1 +
5 files changed, 82 insertions(+), 4 deletions(-) 5 files changed, 76 insertions(+), 4 deletions(-)
create mode 100644 src/wlheadless/kwin.py create mode 100644 src/wlheadless/kwin.py
diff --git a/README.md b/README.md diff --git a/README.md b/README.md
@ -67,12 +73,12 @@ index 97367ba..535da87 100644
value: 'weston') value: 'weston')
diff --git a/src/wlheadless/kwin.py b/src/wlheadless/kwin.py diff --git a/src/wlheadless/kwin.py b/src/wlheadless/kwin.py
new file mode 100644 new file mode 100644
index 0000000..e529229 index 0000000..1721d1c
--- /dev/null --- /dev/null
+++ b/src/wlheadless/kwin.py +++ b/src/wlheadless/kwin.py
@@ -0,0 +1,76 @@ @@ -0,0 +1,70 @@
+# +#
+# Copyright © 2023 Neal Gompa. +# Copyright © 2024 Neal Gompa.
+# +#
+# This program is free software; you can redistribute it and/or +# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as +# modify it under the terms of the GNU General Public License as
@ -109,6 +115,7 @@ index 0000000..e529229
+ def __init__(self): + def __init__(self):
+ self.compositor_args = [] + self.compositor_args = []
+ self.compositor = [ + self.compositor = [
+ 'dbus-run-session',
+ 'kwin_wayland', + 'kwin_wayland',
+ '--virtual', + '--virtual',
+ ] + ]
@ -117,36 +124,29 @@ index 0000000..e529229
+ +
+ +
+ def spawn_client(self, command_args): + def spawn_client(self, command_args):
+ """Helper function to spawn kwin and the client at once.""" + """Helper function to spawn the Wayland client."""
+ wayland_display = 'wayland-' + format(getpid()) + return self.wlheadless_common.run_command(command_args)
+ 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 = []): + def spawn_xwayland(self, xserver_args = []):
+ """Helper function to spawn kwin and Xwayland at once.""" + """Helper function to spawn Xwayland."""
+ compositor = self.compositor
+ compositor.extend(self.compositor_args)
+ compositor.extend(['--'])
+ xserver_args.extend(['-fullscreen']) + xserver_args.extend(['-fullscreen'])
+ return self.xwayland.spawn_xwayland(xserver_args, compositor) + return self.xwayland.spawn_xwayland(xserver_args)
+ +
+ +
+ def wait_compositor(self): + def wait_compositor(self):
+ """Waits for the compositor to start.""" + """Waits for the compositor to start."""
+ return 0 + return self.wlheadless_common.wait_compositor()
+ +
+ +
+ def run_compositor(self, compositor_args = []): + def run_compositor(self, compositor_args = []):
+ """Starts the Wayland compositor.""" + """Helper function to spawn kwin."""
+ # Just save the given args for when we shall actually spawn the compositor. + wayland_display = 'wayland-' + format(getpid())
+ self.compositor_args = compositor_args + environ['WAYLAND_DISPLAY'] = wayland_display
+ return 0 + compositor = self.compositor
+ compositor.extend(self.compositor_args)
+ compositor.extend(['--socket', format(wayland_display)])
+ return self.wlheadless_common.run_compositor(compositor)
diff --git a/src/wlheadless/meson.build b/src/wlheadless/meson.build diff --git a/src/wlheadless/meson.build b/src/wlheadless/meson.build
index cdf650c..e6fbfce 100644 index cdf650c..e6fbfce 100644
--- a/src/wlheadless/meson.build --- a/src/wlheadless/meson.build

View File

@ -1,13 +1,13 @@
Name: xwayland-run Name: xwayland-run
Version: 0.0.2 Version: 0.0.2
Release: 2%{?dist} Release: 3%{?dist}
Summary: Set of utilities to run headless X/Wayland clients Summary: Set of utilities to run headless X/Wayland clients
License: GPL-2.0-or-later License: GPL-2.0-or-later
URL: https://gitlab.freedesktop.org/ofourdan/xwayland-run URL: https://gitlab.freedesktop.org/ofourdan/xwayland-run
Source0: %{url}/-/archive/%{version}/%{name}-%{version}.tar.gz Source0: %{url}/-/archive/%{version}/%{name}-%{version}.tar.gz
# From: https://gitlab.freedesktop.org/ofourdan/xwayland-run/-/merge_requests/4 # Backport from upstream
Patch0001: 0001-wlheadless-Add-support-for-kwin.patch Patch0001: 0001-wlheadless-Add-support-for-kwin.patch
BuildArch: noarch BuildArch: noarch
@ -15,7 +15,7 @@ BuildArch: noarch
BuildRequires: meson >= 0.60.0 BuildRequires: meson >= 0.60.0
BuildRequires: git-core BuildRequires: git-core
BuildRequires: python3-devel BuildRequires: python3-devel
Requires: (weston or kwin-wayland or mutter or cage or gnome-kiosk) Requires: (weston or cage or kwin-wayland or mutter or gnome-kiosk)
Requires: xorg-x11-server-Xwayland Requires: xorg-x11-server-Xwayland
# Provide names of the other utilities included # Provide names of the other utilities included
@ -54,6 +54,9 @@ Xwayland and various Wayland compositor headless.
%changelog %changelog
* Sat Jan 13 2024 Neal Gompa <ngompa@fedoraproject.org> - 0.0.2-3
- Refresh kwin support patch with final version
* Sun Dec 10 2023 Neal Gompa <ngompa@fedoraproject.org> - 0.0.2-2 * Sun Dec 10 2023 Neal Gompa <ngompa@fedoraproject.org> - 0.0.2-2
- Refresh kwin support patch - Refresh kwin support patch
- Add provides for other included utilities - Add provides for other included utilities