From e7d9cf58152ab78cc5b231d7cf49afcb21e1f5a1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 13 Feb 2019 11:18:46 +0100 Subject: [PATCH] xwm: Add _NET_CLIENT_LIST support Fixes: https://github.com/swaywm/wlroots/issues/1469 Signed-off-by: Uli Schlachter --- include/xwayland/xwm.h | 1 + xwayland/xwm.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h index a3bdc48c..00f2f3d5 100644 --- a/include/xwayland/xwm.h +++ b/include/xwayland/xwm.h @@ -80,6 +80,7 @@ enum atom_name { DND_ACTION_COPY, DND_ACTION_ASK, DND_ACTION_PRIVATE, + _NET_CLIENT_LIST, ATOM_LAST, }; diff --git a/xwayland/xwm.c b/xwayland/xwm.c index fc294674..9ca2c721 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -78,6 +78,7 @@ const char *atom_map[ATOM_LAST] = { "XdndActionCopy", "XdndActionAsk", "XdndActionPrivate", + "_NET_CLIENT_LIST", }; static const struct wlr_surface_role xwayland_surface_role; @@ -212,6 +213,28 @@ static void xwm_send_wm_message(struct wlr_xwayland_surface *surface, xcb_flush(xwm->xcb_conn); } +static void xwm_set_net_client_list(struct wlr_xwm *xwm) { + size_t mapped_surfaces = 0; + struct wlr_xwayland_surface *surface; + wl_list_for_each(surface, &xwm->surfaces, link) { + if (surface->mapped) { + mapped_surfaces++; + } + } + + xcb_window_t windows[mapped_surfaces + 1]; + size_t index = 0; + wl_list_for_each(surface, &xwm->surfaces, link) { + if (surface->mapped) { + windows[index++] = surface->window_id; + } + } + + xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE, + xwm->screen->root, xwm->atoms[_NET_CLIENT_LIST], + XCB_ATOM_WINDOW, 32, mapped_surfaces, windows); +} + static void xwm_send_focus_window(struct wlr_xwm *xwm, struct wlr_xwayland_surface *xsurface) { if (!xsurface) { @@ -702,6 +725,7 @@ static void xwayland_surface_role_commit(struct wlr_surface *wlr_surface) { if (!surface->mapped && wlr_surface_has_buffer(surface->surface)) { wlr_signal_emit_safe(&surface->events.map, surface); surface->mapped = true; + xwm_set_net_client_list(surface->xwm); } } @@ -718,6 +742,7 @@ static void xwayland_surface_role_precommit(struct wlr_surface *wlr_surface) { if (surface->mapped) { wlr_signal_emit_safe(&surface->events.unmap, surface); surface->mapped = false; + xwm_set_net_client_list(surface->xwm); } } } @@ -770,6 +795,7 @@ static void xsurface_unmap(struct wlr_xwayland_surface *surface) { if (surface->mapped) { surface->mapped = false; wlr_signal_emit_safe(&surface->events.unmap, surface); + xwm_set_net_client_list(surface->xwm); } if (surface->surface_id) { @@ -1712,6 +1738,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm->atoms[_NET_WM_STATE_FULLSCREEN], xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT], xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ], + xwm->atoms[_NET_CLIENT_LIST], }; xcb_change_property(xwm->xcb_conn, XCB_PROP_MODE_REPLACE,