mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	xwayland: handle override_redirect flag changes
The override_redirect flag can change on configure notify and on map notify. This adds an event to know when it changes. This removes wlr_xwayland_surface_is_unmanaged which was wrongly using the window type to decide whether the view should be unmanaged. A similar patch was proposed to Weston, but has never been merged upstream [1]. [1]: https://patchwork.freedesktop.org/patch/211161/
This commit is contained in:
		
							parent
							
								
									7f20ab6443
								
							
						
					
					
						commit
						153f37bdf5
					
				
					 3 changed files with 21 additions and 34 deletions
				
			
		| 
						 | 
					@ -150,6 +150,7 @@ struct wlr_xwayland_surface {
 | 
				
			||||||
		struct wl_signal set_parent;
 | 
							struct wl_signal set_parent;
 | 
				
			||||||
		struct wl_signal set_pid;
 | 
							struct wl_signal set_pid;
 | 
				
			||||||
		struct wl_signal set_window_type;
 | 
							struct wl_signal set_window_type;
 | 
				
			||||||
 | 
							struct wl_signal set_override_redirect;
 | 
				
			||||||
		struct wl_signal ping_timeout;
 | 
							struct wl_signal ping_timeout;
 | 
				
			||||||
	} events;
 | 
						} events;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -200,9 +201,6 @@ void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface,
 | 
				
			||||||
void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
 | 
					void wlr_xwayland_set_seat(struct wlr_xwayland *xwayland,
 | 
				
			||||||
	struct wlr_seat *seat);
 | 
						struct wlr_seat *seat);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool wlr_xwayland_surface_is_unmanaged(
 | 
					 | 
				
			||||||
	const struct wlr_xwayland_surface *surface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface);
 | 
					bool wlr_surface_is_xwayland_surface(struct wlr_surface *surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface(
 | 
					struct wlr_xwayland_surface *wlr_xwayland_surface_from_wlr_surface(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1124,7 +1124,7 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef WLR_HAS_XWAYLAND
 | 
					#ifdef WLR_HAS_XWAYLAND
 | 
				
			||||||
	if (view && view->type == ROOTS_XWAYLAND_VIEW &&
 | 
						if (view && view->type == ROOTS_XWAYLAND_VIEW &&
 | 
				
			||||||
			wlr_xwayland_surface_is_unmanaged(view->xwayland_surface)) {
 | 
								view->xwayland_surface->override_redirect) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,6 +154,7 @@ static struct wlr_xwayland_surface *xwayland_surface_create(
 | 
				
			||||||
	wl_signal_init(&surface->events.set_parent);
 | 
						wl_signal_init(&surface->events.set_parent);
 | 
				
			||||||
	wl_signal_init(&surface->events.set_pid);
 | 
						wl_signal_init(&surface->events.set_pid);
 | 
				
			||||||
	wl_signal_init(&surface->events.set_window_type);
 | 
						wl_signal_init(&surface->events.set_window_type);
 | 
				
			||||||
 | 
						wl_signal_init(&surface->events.set_override_redirect);
 | 
				
			||||||
	wl_signal_init(&surface->events.ping_timeout);
 | 
						wl_signal_init(&surface->events.ping_timeout);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	xcb_get_geometry_reply_t *geometry_reply =
 | 
						xcb_get_geometry_reply_t *geometry_reply =
 | 
				
			||||||
| 
						 | 
					@ -764,9 +765,7 @@ static void xwm_handle_configure_request(struct wlr_xwm *xwm,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void xwm_handle_configure_notify(struct wlr_xwm *xwm,
 | 
					static void xwm_handle_configure_notify(struct wlr_xwm *xwm,
 | 
				
			||||||
		xcb_configure_notify_event_t *ev) {
 | 
							xcb_configure_notify_event_t *ev) {
 | 
				
			||||||
	struct wlr_xwayland_surface *xsurface =
 | 
						struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window);
 | 
				
			||||||
		lookup_surface(xwm, ev->window);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!xsurface) {
 | 
						if (!xsurface) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -775,6 +774,11 @@ static void xwm_handle_configure_notify(struct wlr_xwm *xwm,
 | 
				
			||||||
	xsurface->y = ev->y;
 | 
						xsurface->y = ev->y;
 | 
				
			||||||
	xsurface->width = ev->width;
 | 
						xsurface->width = ev->width;
 | 
				
			||||||
	xsurface->height = ev->height;
 | 
						xsurface->height = ev->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (xsurface->override_redirect != ev->override_redirect) {
 | 
				
			||||||
 | 
							xsurface->override_redirect = ev->override_redirect;
 | 
				
			||||||
 | 
							wlr_signal_emit_safe(&xsurface->events.set_override_redirect, xsurface);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define ICCCM_WITHDRAWN_STATE	0
 | 
					#define ICCCM_WITHDRAWN_STATE	0
 | 
				
			||||||
| 
						 | 
					@ -814,6 +818,15 @@ static void xwm_handle_map_request(struct wlr_xwm *xwm,
 | 
				
			||||||
static void xwm_handle_map_notify(struct wlr_xwm *xwm,
 | 
					static void xwm_handle_map_notify(struct wlr_xwm *xwm,
 | 
				
			||||||
		xcb_map_notify_event_t *ev) {
 | 
							xcb_map_notify_event_t *ev) {
 | 
				
			||||||
	wlr_log(WLR_DEBUG, "XCB_MAP_NOTIFY (%u)", ev->window);
 | 
						wlr_log(WLR_DEBUG, "XCB_MAP_NOTIFY (%u)", ev->window);
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window);
 | 
				
			||||||
 | 
						if (!xsurface) {
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (xsurface->override_redirect != ev->override_redirect) {
 | 
				
			||||||
 | 
							xsurface->override_redirect = ev->override_redirect;
 | 
				
			||||||
 | 
							wlr_signal_emit_safe(&xsurface->events.set_override_redirect, xsurface);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void xwm_handle_unmap_notify(struct wlr_xwm *xwm,
 | 
					static void xwm_handle_unmap_notify(struct wlr_xwm *xwm,
 | 
				
			||||||
| 
						 | 
					@ -1659,30 +1672,6 @@ bool xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms,
 | 
				
			||||||
	return false;
 | 
						return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool wlr_xwayland_surface_is_unmanaged(
 | 
					 | 
				
			||||||
		const struct wlr_xwayland_surface *surface) {
 | 
					 | 
				
			||||||
	static enum atom_name needles[] = {
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_COMBO,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_DND,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_DROPDOWN_MENU,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_MENU,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_NOTIFICATION,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_POPUP_MENU,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_SPLASH,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_TOOLTIP,
 | 
					 | 
				
			||||||
		NET_WM_WINDOW_TYPE_UTILITY,
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (size_t i = 0; i < sizeof(needles) / sizeof(needles[0]); ++i) {
 | 
					 | 
				
			||||||
		if (xwm_atoms_contains(surface->xwm, surface->window_type,
 | 
					 | 
				
			||||||
				surface->window_type_len, needles[i])) {
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return false;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void wlr_xwayland_surface_ping(struct wlr_xwayland_surface *surface) {
 | 
					void wlr_xwayland_surface_ping(struct wlr_xwayland_surface *surface) {
 | 
				
			||||||
	xcb_client_message_data_t data = { 0 };
 | 
						xcb_client_message_data_t data = { 0 };
 | 
				
			||||||
	data.data32[0] = surface->xwm->atoms[_NET_WM_PING];
 | 
						data.data32[0] = surface->xwm->atoms[_NET_WM_PING];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue