aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-09-03 17:07:07 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-09-03 17:07:14 +1000
commitb8cc4a4152e5bf7bbe9644c63bcf0e874bb28322 (patch)
treee91018bcc191d95c50fe599f3a15ab1a7fc6886e
parentd22431d969d055b4ef82b21daa6f7b6dfb3e1f2b (diff)
xwayland: Introduce set_role event
-rw-r--r--include/wlr/xwayland.h2
-rw-r--r--include/xwayland/xwm.h1
-rw-r--r--xwayland/xwm.c27
3 files changed, 30 insertions, 0 deletions
diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h
index cf1c2cd1..eb5d6985 100644
--- a/include/wlr/xwayland.h
+++ b/include/wlr/xwayland.h
@@ -116,6 +116,7 @@ struct wlr_xwayland_surface {
char *title;
char *class;
char *instance;
+ char *role;
pid_t pid;
bool has_utf8_title;
@@ -157,6 +158,7 @@ struct wlr_xwayland_surface {
struct wl_signal unmap;
struct wl_signal set_title;
struct wl_signal set_class;
+ struct wl_signal set_role;
struct wl_signal set_parent;
struct wl_signal set_pid;
struct wl_signal set_window_type;
diff --git a/include/xwayland/xwm.h b/include/xwayland/xwm.h
index 607cc797..3536bbc8 100644
--- a/include/xwayland/xwm.h
+++ b/include/xwayland/xwm.h
@@ -25,6 +25,7 @@ enum atom_name {
WM_HINTS,
WM_NORMAL_HINTS,
WM_SIZE_HINTS,
+ WM_WINDOW_ROLE,
MOTIF_WM_HINTS,
UTF8_STRING,
WM_S0,
diff --git a/xwayland/xwm.c b/xwayland/xwm.c
index cebd9bbc..9c803543 100644
--- a/xwayland/xwm.c
+++ b/xwayland/xwm.c
@@ -24,6 +24,7 @@ const char *atom_map[ATOM_LAST] = {
"WM_HINTS",
"WM_NORMAL_HINTS",
"WM_SIZE_HINTS",
+ "WM_WINDOW_ROLE",
"_MOTIF_WM_HINTS",
"UTF8_STRING",
"WM_S0",
@@ -152,6 +153,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
wl_signal_init(&surface->events.map);
wl_signal_init(&surface->events.unmap);
wl_signal_init(&surface->events.set_class);
+ wl_signal_init(&surface->events.set_role);
wl_signal_init(&surface->events.set_title);
wl_signal_init(&surface->events.set_parent);
wl_signal_init(&surface->events.set_pid);
@@ -327,6 +329,7 @@ static void xwayland_surface_destroy(
free(xsurface->title);
free(xsurface->class);
free(xsurface->instance);
+ free(xsurface->role);
free(xsurface->window_type);
free(xsurface->protocols);
free(xsurface->hints);
@@ -365,6 +368,28 @@ static void read_surface_class(struct wlr_xwm *xwm,
wlr_signal_emit_safe(&surface->events.set_class, surface);
}
+static void read_surface_role(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 *role = xcb_get_property_value(reply);
+
+ free(xsurface->role);
+ if (len > 0) {
+ xsurface->role = strndup(role, len);
+ } else {
+ xsurface->role = NULL;
+ }
+
+ wlr_log(WLR_DEBUG, "XCB_ATOM_WM_WINDOW_ROLE: %s", xsurface->role);
+ wlr_signal_emit_safe(&xsurface->events.set_role, xsurface);
+}
+
static void read_surface_title(struct wlr_xwm *xwm,
struct wlr_xwayland_surface *xsurface,
xcb_get_property_reply_t *reply) {
@@ -638,6 +663,8 @@ static void read_surface_property(struct wlr_xwm *xwm,
read_surface_normal_hints(xwm, xsurface, reply);
} else if (property == xwm->atoms[MOTIF_WM_HINTS]) {
read_surface_motif_hints(xwm, xsurface, reply);
+ } else if (property == xwm->atoms[WM_WINDOW_ROLE]) {
+ read_surface_role(xwm, xsurface, reply);
} else {
char *prop_name = xwm_get_atom_name(xwm, property);
wlr_log(WLR_DEBUG, "unhandled X11 property %u (%s) for window %u",