mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	Add reply->type checks, add XCB_ATOM_WM_TRANSIENT_FOR
This commit is contained in:
		
							parent
							
								
									47d767dbc4
								
							
						
					
					
						commit
						f2b03b2ec1
					
				
					 3 changed files with 75 additions and 35 deletions
				
			
		| 
						 | 
				
			
			@ -43,6 +43,7 @@ struct wlr_xwayland_surface {
 | 
			
		|||
	char *title;
 | 
			
		||||
	char *class;
 | 
			
		||||
	char *instance;
 | 
			
		||||
	struct wlr_xwayland_surface *parent;
 | 
			
		||||
 | 
			
		||||
	struct {
 | 
			
		||||
		struct wl_signal destroy;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@
 | 
			
		|||
const char *atom_map[ATOM_LAST] = {
 | 
			
		||||
	"WL_SURFACE_ID",
 | 
			
		||||
	"WM_PROTOCOLS",
 | 
			
		||||
	"UTF8_STRING",
 | 
			
		||||
	"WM_S0",
 | 
			
		||||
	"_NET_SUPPORTED",
 | 
			
		||||
	"_NET_WM_S0",
 | 
			
		||||
| 
						 | 
				
			
			@ -84,19 +85,13 @@ static bool xcb_call(struct wlr_xwm *xwm, const char *func, uint32_t line,
 | 
			
		|||
	return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void read_surface_property(struct wlr_xwm *xwm,
 | 
			
		||||
		struct wlr_xwayland_surface *surface, xcb_atom_t property) {
 | 
			
		||||
	xcb_get_property_cookie_t cookie = xcb_get_property(xwm->xcb_conn, 0,
 | 
			
		||||
		surface->window_id, property, XCB_ATOM_ANY, 0, 2048);
 | 
			
		||||
	xcb_get_property_reply_t *reply = xcb_get_property_reply(xwm->xcb_conn,
 | 
			
		||||
		cookie, NULL);
 | 
			
		||||
	if (reply == NULL) {
 | 
			
		||||
static void read_surface_class(struct wlr_xwm *xwm,
 | 
			
		||||
		struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) {
 | 
			
		||||
	if (reply->type != XCB_ATOM_STRING &&
 | 
			
		||||
			reply->type != xwm->atoms[UTF8_STRING]) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// TODO: check reply->type
 | 
			
		||||
 | 
			
		||||
	if (property == XCB_ATOM_WM_CLASS) {
 | 
			
		||||
	size_t len = xcb_get_property_value_length(reply);
 | 
			
		||||
	char *class = xcb_get_property_value(reply);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -117,10 +112,18 @@ static void read_surface_property(struct wlr_xwm *xwm,
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_log(L_DEBUG, "XCB_ATOM_WM_CLASS: %s %s", surface->instance, surface->class);
 | 
			
		||||
	} else if (property == XCB_ATOM_WM_NAME ||
 | 
			
		||||
			property == xwm->atoms[NET_WM_NAME]) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void read_surface_title(struct wlr_xwm *xwm,
 | 
			
		||||
		struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) {
 | 
			
		||||
	if (reply->type != XCB_ATOM_STRING &&
 | 
			
		||||
			reply->type != xwm->atoms[UTF8_STRING]) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// TODO: if reply->type == XCB_ATOM_STRING, uses latin1 encoding
 | 
			
		||||
	// if reply->type == xwm->atoms[UTF8_STRING], uses utf8 encoding
 | 
			
		||||
 | 
			
		||||
	size_t len = xcb_get_property_value_length(reply);
 | 
			
		||||
	char *title = xcb_get_property_value(reply);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -132,6 +135,41 @@ static void read_surface_property(struct wlr_xwm *xwm,
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_log(L_DEBUG, "XCB_ATOM_WM_NAME: %s", surface->title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void read_surface_parent(struct wlr_xwm *xwm,
 | 
			
		||||
		struct wlr_xwayland_surface *surface, xcb_get_property_reply_t *reply) {
 | 
			
		||||
	if (reply->type != XCB_ATOM_WINDOW) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	xcb_window_t *xid = xcb_get_property_value(reply);
 | 
			
		||||
	if (xid != NULL) {
 | 
			
		||||
		surface->parent = lookup_surface_any(xwm, *xid);
 | 
			
		||||
	} else {
 | 
			
		||||
		surface->parent = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_log(L_DEBUG, "XCB_ATOM_WM_TRANSIENT_FOR: %p", xid);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void read_surface_property(struct wlr_xwm *xwm,
 | 
			
		||||
		struct wlr_xwayland_surface *surface, xcb_atom_t property) {
 | 
			
		||||
	xcb_get_property_cookie_t cookie = xcb_get_property(xwm->xcb_conn, 0,
 | 
			
		||||
		surface->window_id, property, XCB_ATOM_ANY, 0, 2048);
 | 
			
		||||
	xcb_get_property_reply_t *reply = xcb_get_property_reply(xwm->xcb_conn,
 | 
			
		||||
		cookie, NULL);
 | 
			
		||||
	if (reply == NULL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (property == XCB_ATOM_WM_CLASS) {
 | 
			
		||||
		read_surface_class(xwm, surface, reply);
 | 
			
		||||
	} else if (property == XCB_ATOM_WM_NAME ||
 | 
			
		||||
			property == xwm->atoms[NET_WM_NAME]) {
 | 
			
		||||
		read_surface_title(xwm, surface, reply);
 | 
			
		||||
	} else if (property == XCB_ATOM_WM_TRANSIENT_FOR) {
 | 
			
		||||
		read_surface_parent(xwm, surface, reply);
 | 
			
		||||
	} else {
 | 
			
		||||
		wlr_log(L_DEBUG, "unhandled x11 property %u", property);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,6 +48,7 @@
 | 
			
		|||
enum atom_name {
 | 
			
		||||
	WL_SURFACE_ID,
 | 
			
		||||
	WM_PROTOCOLS,
 | 
			
		||||
	UTF8_STRING,
 | 
			
		||||
	WM_S0,
 | 
			
		||||
	NET_SUPPORTED,
 | 
			
		||||
	NET_WM_S0,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue