diff options
author | Guido Günther <agx@sigxcpu.org> | 2021-01-29 16:45:44 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-08-20 10:44:22 +0200 |
commit | de1522aeee04e23522398fe5cee17af67de7602a (patch) | |
tree | 3f9e2e7f35446d48dfabf1cb3ef079012d664e1c /xwayland/xwm.c | |
parent | 9b7803a9b36915d8e5f7a7e59bca578ab4c2e604 (diff) |
xwayland: Allow to retrieve _NET_STARTUP_ID
This is use for startup notifications per startup-notifiation spec
https://specifications.freedesktop.org/startup-notification-spec/startup-notification-latest.txt
Diffstat (limited to 'xwayland/xwm.c')
-rw-r--r-- | xwayland/xwm.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 2be41168..49c2f908 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -60,6 +60,7 @@ const char *const atom_map[ATOM_LAST] = { [TEXT] = "TEXT", [TIMESTAMP] = "TIMESTAMP", [DELETE] = "DELETE", + [NET_STARTUP_ID] = "_NET_STARTUP_ID", [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", @@ -165,6 +166,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create( wl_signal_init(&surface->events.set_title); wl_signal_init(&surface->events.set_parent); wl_signal_init(&surface->events.set_pid); + wl_signal_init(&surface->events.set_startup_id); wl_signal_init(&surface->events.set_window_type); wl_signal_init(&surface->events.set_hints); wl_signal_init(&surface->events.set_decorations); @@ -414,6 +416,7 @@ static void xwayland_surface_destroy( free(xsurface->role); free(xsurface->window_type); free(xsurface->protocols); + free(xsurface->startup_id); free(xsurface->hints); free(xsurface->size_hints); free(xsurface); @@ -448,6 +451,29 @@ static void read_surface_class(struct wlr_xwm *xwm, wlr_signal_emit_safe(&surface->events.set_class, surface); } +static void read_surface_startup_id(struct wlr_xwm *xwm, + struct wlr_xwayland_surface *xsurface, + xcb_get_property_reply_t *reply) { + if (reply->type != XCB_ATOM_STRING && + reply->type != xwm->atoms[UTF8_STRING]) { + return; + } + + size_t len = xcb_get_property_value_length(reply); + char *startup_id = xcb_get_property_value(reply); + + free(xsurface->startup_id); + if (len > 0) { + xsurface->startup_id = strndup(startup_id, len); + } else { + xsurface->startup_id = NULL; + } + + wlr_log(WLR_DEBUG, "XCB_ATOM_NET_STARTUP_ID: %s", + xsurface->startup_id ? xsurface->startup_id: "(null)"); + wlr_signal_emit_safe(&xsurface->events.set_startup_id, xsurface); +} + static void read_surface_role(struct wlr_xwm *xwm, struct wlr_xwayland_surface *xsurface, xcb_get_property_reply_t *reply) { @@ -791,6 +817,8 @@ static void read_surface_property(struct wlr_xwm *xwm, read_surface_motif_hints(xwm, xsurface, reply); } else if (property == xwm->atoms[WM_WINDOW_ROLE]) { read_surface_role(xwm, xsurface, reply); + } else if (property == xwm->atoms[NET_STARTUP_ID]) { + read_surface_startup_id(xwm, xsurface, reply); } else { char *prop_name = xwm_get_atom_name(xwm, property); wlr_log(WLR_DEBUG, "unhandled X11 property %" PRIu32 " (%s) for window %" PRIu32, @@ -864,6 +892,7 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, xwm->atoms[WM_HINTS], xwm->atoms[WM_NORMAL_HINTS], xwm->atoms[MOTIF_WM_HINTS], + xwm->atoms[NET_STARTUP_ID], xwm->atoms[NET_WM_STATE], xwm->atoms[NET_WM_WINDOW_TYPE], xwm->atoms[NET_WM_NAME], |