From 267f24753f010e6ac7e49f7bfb27a9c85f40b62d Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 5 Oct 2017 16:24:45 +0200 Subject: [PATCH] Add support for WM_HINTS --- include/wlr/xwayland.h | 2 ++ xwayland/xwm.c | 26 +++++++++++++++++++++++++- xwayland/xwm.h | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 3cbaee59..73df1ea9 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -59,8 +59,10 @@ struct wlr_xwayland_surface { uint32_t motif_hints[5]; #ifdef HAS_XCB_ICCCM + xcb_icccm_wm_hints_t hints; xcb_size_hints_t size_hints; #else + char hints_padding[36]; char size_hints_padding[72]; #endif diff --git a/xwayland/xwm.c b/xwayland/xwm.c index afd4ef29..bc930140 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -15,6 +15,7 @@ const char *atom_map[ATOM_LAST] = { "WL_SURFACE_ID", "WM_DELETE_WINDOW", + "WM_HINTS", "WM_PROTOCOLS", "WM_NORMAL_HINTS", "WM_SIZE_HINTS", @@ -276,10 +277,30 @@ static void read_surface_protocols(struct wlr_xwm *xwm, wlr_log(L_DEBUG, "WM_PROTOCOLS (%zu)", atoms_len); } +#ifdef HAS_XCB_ICCCM +static void read_surface_hints(struct wlr_xwm *xwm, + struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) { + // According to the docs, reply->type == xwm->atoms[WM_HINTS] + // In practice, reply->type == XCB_ATOM_ATOM + if (reply->value_len == 0) { + return; + } + + xcb_icccm_get_wm_hints_from_reply(&surface->hints, reply); + + wlr_log(L_DEBUG, "WM_HINTS (%d)", reply->value_len); +} +#else +static void read_surface_hints(struct wlr_xwm *xwm, + struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) { + // Do nothing +} +#endif + #ifdef HAS_XCB_ICCCM static void read_surface_normal_hints(struct wlr_xwm *xwm, struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) { - if (reply->type != xwm->atoms[WM_SIZE_HINTS]) { + if (reply->type != xwm->atoms[WM_SIZE_HINTS] || reply->value_len == 0) { return; } @@ -331,6 +352,8 @@ static void read_surface_property(struct wlr_xwm *xwm, read_surface_protocols(xwm, surface, reply); } else if (property == xwm->atoms[NET_WM_STATE]) { read_surface_state(xwm, surface, reply); + } else if (property == xwm->atoms[WM_HINTS]) { + read_surface_hints(xwm, surface, reply); } else if (property == xwm->atoms[WM_NORMAL_HINTS]) { read_surface_normal_hints(xwm, surface, reply); } else if (property == xwm->atoms[MOTIF_WM_HINTS]) { @@ -354,6 +377,7 @@ static void map_shell_surface(struct wlr_xwm *xwm, XCB_ATOM_WM_NAME, XCB_ATOM_WM_TRANSIENT_FOR, xwm->atoms[WM_PROTOCOLS], + xwm->atoms[WM_HINTS], xwm->atoms[WM_NORMAL_HINTS], xwm->atoms[MOTIF_WM_HINTS], xwm->atoms[NET_WM_STATE], diff --git a/xwayland/xwm.h b/xwayland/xwm.h index 48504602..be710a1b 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -49,6 +49,7 @@ enum atom_name { WL_SURFACE_ID, WM_DELETE_WINDOW, WM_PROTOCOLS, + WM_HINTS, WM_NORMAL_HINTS, WM_SIZE_HINTS, MOTIF_WM_HINTS,