Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guido Gunther
wlroots
Commits
7c0918c6
Commit
7c0918c6
authored
Oct 19, 2021
by
Guido Gunther
Browse files
d/patches: xwayland: Allow to retrieve startup-id via _NET_STARTUP_INFO
See
Librem5/wlroots!86
parent
0e9dedc8
Pipeline
#72225
passed with stages
in 3 minutes and 28 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
debian/patches/series
View file @
7c0918c6
...
...
@@ -2,3 +2,4 @@ Revert-layer-shell-error-on-0-dimension-without-anchors.patch
pureos/Bump-soversion-to-7c.patch
upstream/examples-dmabuf-capture-stop-using-av_init_packet.patch
upstream/xwayland-Allow-to-retrieve-_NET_STARTUP_ID.patch
upstream/xwayland-Allow-to-retrieve-startup-id-via-_NET_STARTUP_IN.patch
debian/patches/upstream/xwayland-Allow-to-retrieve-startup-id-via-_NET_STARTUP_IN.patch
0 → 100644
View file @
7c0918c6
From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Fri, 29 Jan 2021 16:45:44 +0100
Subject: xwayland: Allow to retrieve startup-id via _NET_STARTUP_INFO
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
A launchee notifies with a "remove"¹ message when done starting up.
Catch these and forward to the compositor. This allows the compositor to
end the startup sequence that might have been started by another
protocol like xdg-activation.
We don't handle other messages since we expect the launcher to use a
wayland protocol like xdg-activation.
While `_NET_STARTUP_ID` helps to associate toplevels with startup-ids
this signals the end of the startup sequence.
1) https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt
(cherry picked from commit e479dc1ef0fe5165cd2456927cdf153ce206e023)
---
include/wlr/xwayland.h | 6 ++++
include/xwayland/xwm.h | 3 ++
xwayland/xwayland.c | 1 +
xwayland/xwm.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 96 insertions(+)
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index a161cc4..32f1ed7 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -73,6 +73,7 @@
struct wlr_xwayland {
struct {
struct wl_signal ready;
struct wl_signal new_surface;
+ struct wl_signal remove_startup_info;
} events;
/**
@@ -220,6 +221,11 @@
struct wlr_xwayland_move_event {
struct wlr_xwayland_surface *surface;
};
+struct wlr_xwayland_remove_startup_info_event {
+ const char *id;
+ xcb_window_t window;
+};
+
struct wlr_xwayland_resize_event {
struct wlr_xwayland_surface *surface;
uint32_t edges;
diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h
index 06ad392..9c4acc0 100644
--- a/include/xwayland/xwm.h
+++ b/include/xwayland/xwm.h
@@ -59,6 +59,8 @@
enum atom_name {
TIMESTAMP,
DELETE,
NET_STARTUP_ID,
+ NET_STARTUP_INFO,
+ NET_STARTUP_INFO_BEGIN,
NET_WM_WINDOW_TYPE_NORMAL,
NET_WM_WINDOW_TYPE_UTILITY,
NET_WM_WINDOW_TYPE_TOOLTIP,
@@ -121,6 +123,7 @@
struct wlr_xwm {
struct wl_list surfaces; // wlr_xwayland_surface::link
struct wl_list unpaired_surfaces; // wlr_xwayland_surface::unpaired_link
+ struct wl_list pending_startup_ids; // pending_startup_id
struct wlr_drag *drag;
struct wlr_xwayland_surface *drag_focus;
diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c
index 4cb103a..a4b9b29 100644
--- a/xwayland/xwayland.c
+++ b/xwayland/xwayland.c
@@ -82,6 +82,7 @@
struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display,
wl_signal_init(&xwayland->events.new_surface);
wl_signal_init(&xwayland->events.ready);
+ wl_signal_init(&xwayland->events.remove_startup_info);
struct wlr_xwayland_server_options options = {
.lazy = lazy,
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index 8055777..6f62bc3 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -57,6 +57,8 @@
const char *atom_map[ATOM_LAST] = {
[TIMESTAMP] = "TIMESTAMP",
[DELETE] = "DELETE",
[NET_STARTUP_ID] = "_NET_STARTUP_ID",
+ [NET_STARTUP_INFO] = "_NET_STARTUP_INFO",
+ [NET_STARTUP_INFO_BEGIN] = "_NET_STARTUP_INFO_BEGIN",
[NET_WM_WINDOW_TYPE_NORMAL] = "_NET_WM_WINDOW_TYPE_NORMAL",
[NET_WM_WINDOW_TYPE_UTILITY] = "_NET_WM_WINDOW_TYPE_UTILITY",
[NET_WM_WINDOW_TYPE_TOOLTIP] = "_NET_WM_WINDOW_TYPE_TOOLTIP",
@@ -84,6 +86,14 @@
const char *atom_map[ATOM_LAST] = {
[NET_CLIENT_LIST] = "_NET_CLIENT_LIST",
};
+#define STARTUP_INFO_REMOVE_PREFIX "remove: ID="
+struct pending_startup_id {
+ char *msg;
+ size_t len;
+ xcb_window_t window;
+ struct wl_list link;
+};
+
static const struct wlr_surface_role xwayland_surface_role;
bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface) {
@@ -1310,6 +1320,73 @@
static void xwm_handle_net_active_window_message(struct wlr_xwm *xwm,
wlr_signal_emit_safe(&surface->events.request_activate, surface);
}
+static void pending_startup_id_destroy(struct pending_startup_id *pending) {
+ wl_list_remove(&pending->link);
+ free(pending->msg);
+ free(pending);
+}
+
+static void xwm_handle_net_startup_info_message(struct wlr_xwm *xwm,
+ xcb_client_message_event_t *ev) {
+ struct pending_startup_id *pending, *curr = NULL;
+ wl_list_for_each(pending, &xwm->pending_startup_ids, link) {
+ if (pending->window == ev->window) {
+ curr = pending;
+ break;
+ }
+ }
+
+ char *start;
+ size_t buf_len = sizeof(ev->data);
+ if (curr) {
+ curr->msg = realloc(curr->msg, curr->len + buf_len);
+ if (!curr->msg) {
+ pending_startup_id_destroy(curr);
+ return;
+ }
+ start = curr->msg + curr->len;
+ curr->len += buf_len;
+ } else {
+ curr = calloc(1, sizeof(struct pending_startup_id));
+ if (!curr)
+ return;
+ curr->window = ev->window;
+ curr->msg = malloc(buf_len);
+ if (!curr->msg) {
+ free(curr);
+ return;
+ }
+ start = curr->msg;
+ curr->len = buf_len;
+ wl_list_insert(&xwm->pending_startup_ids, &curr->link);
+ }
+
+ char *id = NULL;
+ const char *data = (const char *)ev->data.data8;
+ for (size_t i = 0; i < buf_len; i++) {
+ start[i] = data[i];
+ if (start[i] == '\0') {
+ if (strncmp(curr->msg, STARTUP_INFO_REMOVE_PREFIX,
+ strlen(STARTUP_INFO_REMOVE_PREFIX)) == 0 &&
+ strlen(curr->msg) > strlen(STARTUP_INFO_REMOVE_PREFIX)) {
+ id = curr->msg + strlen(STARTUP_INFO_REMOVE_PREFIX);
+ break;
+ } else {
+ wlr_log(WLR_ERROR, "Unhandled message '%s'\n", curr->msg);
+ pending_startup_id_destroy(curr);
+ return;
+ }
+ }
+ }
+
+ if (id) {
+ struct wlr_xwayland_remove_startup_info_event data = { id, ev->window };
+ wlr_log(WLR_DEBUG, "Got startup id: %s", id);
+ wlr_signal_emit_safe(&xwm->xwayland->events.remove_startup_info, &data);
+ pending_startup_id_destroy(curr);
+ }
+}
+
static void xwm_handle_wm_change_state_message(struct wlr_xwm *xwm,
xcb_client_message_event_t *ev) {
struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window);
@@ -1350,6 +1427,9 @@
static void xwm_handle_client_message(struct wlr_xwm *xwm,
xwm_handle_wm_protocols_message(xwm, ev);
} else if (ev->type == xwm->atoms[NET_ACTIVE_WINDOW]) {
xwm_handle_net_active_window_message(xwm, ev);
+ } else if (ev->type == xwm->atoms[NET_STARTUP_INFO] ||
+ ev->type == xwm->atoms[NET_STARTUP_INFO_BEGIN]) {
+ xwm_handle_net_startup_info_message(xwm, ev);
} else if (ev->type == xwm->atoms[WM_CHANGE_STATE]) {
xwm_handle_wm_change_state_message(xwm, ev);
} else if (!xwm_handle_selection_client_message(xwm, ev)) {
@@ -1648,6 +1728,11 @@
void xwm_destroy(struct wlr_xwm *xwm) {
wl_list_remove(&xwm->compositor_destroy.link);
xcb_disconnect(xwm->xcb_conn);
+ struct pending_startup_id *pending, *next;
+ wl_list_for_each_safe(pending, next, &xwm->pending_startup_ids, link) {
+ pending_startup_id_destroy(pending);
+ }
+
xwm->xwayland->xwm = NULL;
free(xwm);
}
@@ -1862,6 +1947,7 @@
struct wlr_xwm *xwm_create(struct wlr_xwayland *xwayland, int wm_fd) {
xwm->xwayland = xwayland;
wl_list_init(&xwm->surfaces);
wl_list_init(&xwm->unpaired_surfaces);
+ wl_list_init(&xwm->pending_startup_ids);
xwm->ping_timeout = 10000;
xwm->xcb_conn = xcb_connect_to_fd(wm_fd, NULL);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment