mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	view: Move xdg_surface + xwayland_surface to derived structs
Add xdg_surface_from_view() + xwayland_surface_from_view() accessors that assert() the view is of the expected type before returning. Fix a real bug in xdg.c parent_of() that dereferenced `view->xdg_surface->toplevel` without first checking `view->type`. The goal of the new accessors is to catch similar bugs in future.
This commit is contained in:
		
							parent
							
								
									df7276345f
								
							
						
					
					
						commit
						4da37c6532
					
				
					 7 changed files with 147 additions and 106 deletions
				
			
		| 
						 | 
					@ -40,13 +40,6 @@ struct view {
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link;
 | 
				
			||||||
	struct output *output;
 | 
						struct output *output;
 | 
				
			||||||
	struct workspace *workspace;
 | 
						struct workspace *workspace;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	union {
 | 
					 | 
				
			||||||
		struct wlr_xdg_surface *xdg_surface;
 | 
					 | 
				
			||||||
#if HAVE_XWAYLAND
 | 
					 | 
				
			||||||
		struct wlr_xwayland_surface *xwayland_surface;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
	struct wlr_surface *surface;
 | 
						struct wlr_surface *surface;
 | 
				
			||||||
	struct wlr_scene_tree *scene_tree;
 | 
						struct wlr_scene_tree *scene_tree;
 | 
				
			||||||
	struct wlr_scene_node *scene_node;
 | 
						struct wlr_scene_node *scene_node;
 | 
				
			||||||
| 
						 | 
					@ -97,6 +90,7 @@ struct view {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct xdg_toplevel_view {
 | 
					struct xdg_toplevel_view {
 | 
				
			||||||
	struct view base;
 | 
						struct view base;
 | 
				
			||||||
 | 
						struct wlr_xdg_surface *xdg_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Events unique to xdg-toplevel views */
 | 
						/* Events unique to xdg-toplevel views */
 | 
				
			||||||
	struct wl_listener set_app_id;
 | 
						struct wl_listener set_app_id;
 | 
				
			||||||
| 
						 | 
					@ -106,6 +100,7 @@ struct xdg_toplevel_view {
 | 
				
			||||||
#if HAVE_XWAYLAND
 | 
					#if HAVE_XWAYLAND
 | 
				
			||||||
struct xwayland_view {
 | 
					struct xwayland_view {
 | 
				
			||||||
	struct view base;
 | 
						struct view base;
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *xwayland_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Events unique to XWayland views */
 | 
						/* Events unique to XWayland views */
 | 
				
			||||||
	struct wl_listener request_configure;
 | 
						struct wl_listener request_configure;
 | 
				
			||||||
| 
						 | 
					@ -166,4 +161,12 @@ void view_adjust_size(struct view *view, int *w, int *h);
 | 
				
			||||||
void view_on_output_destroy(struct view *view);
 | 
					void view_on_output_destroy(struct view *view);
 | 
				
			||||||
void view_destroy(struct view *view);
 | 
					void view_destroy(struct view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* xdg.c */
 | 
				
			||||||
 | 
					struct wlr_xdg_surface *xdg_surface_from_view(struct view *view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* xwayland.c */
 | 
				
			||||||
 | 
					#if HAVE_XWAYLAND
 | 
				
			||||||
 | 
					struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __LABWC_VIEW_H */
 | 
					#endif /* __LABWC_VIEW_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -310,9 +310,9 @@ process_cursor_motion_out_of_surface(struct server *server, uint32_t time)
 | 
				
			||||||
	double sx = server->seat.cursor->x - lx;
 | 
						double sx = server->seat.cursor->x - lx;
 | 
				
			||||||
	double sy = server->seat.cursor->y - ly;
 | 
						double sy = server->seat.cursor->y - ly;
 | 
				
			||||||
	/* Take into account invisible xdg-shell CSD borders */
 | 
						/* Take into account invisible xdg-shell CSD borders */
 | 
				
			||||||
	if (view && view->type == LAB_XDG_SHELL_VIEW && view->xdg_surface) {
 | 
						if (view && view->type == LAB_XDG_SHELL_VIEW) {
 | 
				
			||||||
		struct wlr_box geo;
 | 
							struct wlr_box geo;
 | 
				
			||||||
		wlr_xdg_surface_get_geometry(view->xdg_surface, &geo);
 | 
							wlr_xdg_surface_get_geometry(xdg_surface_from_view(view), &geo);
 | 
				
			||||||
		sx += geo.x;
 | 
							sx += geo.x;
 | 
				
			||||||
		sy += geo.y;
 | 
							sy += geo.y;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ move_to_front(struct view *view)
 | 
				
			||||||
static struct wlr_xwayland_surface *
 | 
					static struct wlr_xwayland_surface *
 | 
				
			||||||
top_parent_of(struct view *view)
 | 
					top_parent_of(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_xwayland_surface *s = view->xwayland_surface;
 | 
						struct wlr_xwayland_surface *s = xwayland_surface_from_view(view);
 | 
				
			||||||
	while (s->parent) {
 | 
						while (s->parent) {
 | 
				
			||||||
		s = s->parent;
 | 
							s = s->parent;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,8 @@ move_xwayland_sub_views_to_front(struct view *parent)
 | 
				
			||||||
	if (!parent || parent->type != LAB_XWAYLAND_VIEW) {
 | 
						if (!parent || parent->type != LAB_XWAYLAND_VIEW) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *parent_xwayland_surface =
 | 
				
			||||||
 | 
							xwayland_surface_from_view(parent);
 | 
				
			||||||
	struct view *view, *next;
 | 
						struct view *view, *next;
 | 
				
			||||||
	wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
 | 
						wl_list_for_each_reverse_safe(view, next, &parent->server->views, link)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -48,7 +50,7 @@ move_xwayland_sub_views_to_front(struct view *parent)
 | 
				
			||||||
		if (!view->mapped && !view->minimized) {
 | 
							if (!view->mapped && !view->minimized) {
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (top_parent_of(view) != parent->xwayland_surface) {
 | 
							if (top_parent_of(view) != parent_xwayland_surface) {
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		move_to_front(view);
 | 
							move_to_front(view);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,7 +35,7 @@ is_title_different(struct view *view)
 | 
				
			||||||
#if HAVE_XWAYLAND
 | 
					#if HAVE_XWAYLAND
 | 
				
			||||||
	case LAB_XWAYLAND_VIEW:
 | 
						case LAB_XWAYLAND_VIEW:
 | 
				
			||||||
		return g_strcmp0(view_get_string_prop(view, "title"),
 | 
							return g_strcmp0(view_get_string_prop(view, "title"),
 | 
				
			||||||
			view->xwayland_surface->class);
 | 
								view_get_string_prop(view, "class"));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return 1;
 | 
						return 1;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,7 +186,8 @@ view_adjust_size(struct view *view, int *w, int *h)
 | 
				
			||||||
	int min_height = MIN_VIEW_HEIGHT;
 | 
						int min_height = MIN_VIEW_HEIGHT;
 | 
				
			||||||
#if HAVE_XWAYLAND
 | 
					#if HAVE_XWAYLAND
 | 
				
			||||||
	if (view->type == LAB_XWAYLAND_VIEW) {
 | 
						if (view->type == LAB_XWAYLAND_VIEW) {
 | 
				
			||||||
		xcb_size_hints_t *hints = view->xwayland_surface->size_hints;
 | 
							xcb_size_hints_t *hints =
 | 
				
			||||||
 | 
								xwayland_surface_from_view(view)->size_hints;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
		 * Honor size increments from WM_SIZE_HINTS. Typically, X11
 | 
							 * Honor size increments from WM_SIZE_HINTS. Typically, X11
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										112
									
								
								src/xdg.c
									
										
									
									
									
								
							
							
						
						
									
										112
									
								
								src/xdg.c
									
										
									
									
									
								
							| 
						 | 
					@ -7,6 +7,25 @@
 | 
				
			||||||
#include "view.h"
 | 
					#include "view.h"
 | 
				
			||||||
#include "workspaces.h"
 | 
					#include "workspaces.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct wlr_xdg_surface *
 | 
				
			||||||
 | 
					xdg_surface_from_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						assert(view->type == LAB_XDG_SHELL_VIEW);
 | 
				
			||||||
 | 
						struct xdg_toplevel_view *xdg_toplevel_view =
 | 
				
			||||||
 | 
							(struct xdg_toplevel_view *)view;
 | 
				
			||||||
 | 
						assert(xdg_toplevel_view->xdg_surface);
 | 
				
			||||||
 | 
						return xdg_toplevel_view->xdg_surface;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct wlr_xdg_toplevel *
 | 
				
			||||||
 | 
					xdg_toplevel_from_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
 | 
				
			||||||
 | 
						assert(xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL);
 | 
				
			||||||
 | 
						assert(xdg_surface->toplevel);
 | 
				
			||||||
 | 
						return xdg_surface->toplevel;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
handle_new_xdg_popup(struct wl_listener *listener, void *data)
 | 
					handle_new_xdg_popup(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -29,7 +48,8 @@ has_ssd(struct view *view)
 | 
				
			||||||
	 * geometry.{x,y} seems to be greater than zero. We filter on that
 | 
						 * geometry.{x,y} seems to be greater than zero. We filter on that
 | 
				
			||||||
	 * on the assumption that this will remain true.
 | 
						 * on the assumption that this will remain true.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	struct wlr_xdg_surface_state *current = &view->xdg_surface->current;
 | 
						struct wlr_xdg_surface_state *current =
 | 
				
			||||||
 | 
							&xdg_surface_from_view(view)->current;
 | 
				
			||||||
	if (current->geometry.x || current->geometry.y) {
 | 
						if (current->geometry.x || current->geometry.y) {
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -40,9 +60,11 @@ static void
 | 
				
			||||||
handle_commit(struct wl_listener *listener, void *data)
 | 
					handle_commit(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, commit);
 | 
						struct view *view = wl_container_of(listener, view, commit);
 | 
				
			||||||
 | 
						struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
 | 
				
			||||||
	assert(view->surface);
 | 
						assert(view->surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_box size;
 | 
						struct wlr_box size;
 | 
				
			||||||
	wlr_xdg_surface_get_geometry(view->xdg_surface, &size);
 | 
						wlr_xdg_surface_get_geometry(xdg_surface, &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool update_required = false;
 | 
						bool update_required = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,7 +75,7 @@ handle_commit(struct wl_listener *listener, void *data)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t serial = view->pending_move_resize.configure_serial;
 | 
						uint32_t serial = view->pending_move_resize.configure_serial;
 | 
				
			||||||
	if (serial > 0 && serial >= view->xdg_surface->current.configure_serial) {
 | 
						if (serial > 0 && serial >= xdg_surface->current.configure_serial) {
 | 
				
			||||||
		if (view->pending_move_resize.update_x) {
 | 
							if (view->pending_move_resize.update_x) {
 | 
				
			||||||
			update_required = true;
 | 
								update_required = true;
 | 
				
			||||||
			view->x = view->pending_move_resize.x +
 | 
								view->x = view->pending_move_resize.x +
 | 
				
			||||||
| 
						 | 
					@ -64,7 +86,7 @@ handle_commit(struct wl_listener *listener, void *data)
 | 
				
			||||||
			view->y = view->pending_move_resize.y +
 | 
								view->y = view->pending_move_resize.y +
 | 
				
			||||||
				view->pending_move_resize.height - size.height;
 | 
									view->pending_move_resize.height - size.height;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (serial == view->xdg_surface->current.configure_serial) {
 | 
							if (serial == xdg_surface->current.configure_serial) {
 | 
				
			||||||
			view->pending_move_resize.configure_serial = 0;
 | 
								view->pending_move_resize.configure_serial = 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -94,7 +116,7 @@ handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
	assert(view->type == LAB_XDG_SHELL_VIEW);
 | 
						assert(view->type == LAB_XDG_SHELL_VIEW);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Reset XDG specific surface for good measure */
 | 
						/* Reset XDG specific surface for good measure */
 | 
				
			||||||
	view->xdg_surface = NULL;
 | 
						((struct xdg_toplevel_view *)view)->xdg_surface = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Remove XDG specific handlers */
 | 
						/* Remove XDG specific handlers */
 | 
				
			||||||
	wl_list_remove(&view->destroy.link);
 | 
						wl_list_remove(&view->destroy.link);
 | 
				
			||||||
| 
						 | 
					@ -140,14 +162,14 @@ static void
 | 
				
			||||||
handle_request_minimize(struct wl_listener *listener, void *data)
 | 
					handle_request_minimize(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_minimize);
 | 
						struct view *view = wl_container_of(listener, view, request_minimize);
 | 
				
			||||||
	view_minimize(view, view->xdg_surface->toplevel->requested.minimized);
 | 
						view_minimize(view, xdg_toplevel_from_view(view)->requested.minimized);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
handle_request_maximize(struct wl_listener *listener, void *data)
 | 
					handle_request_maximize(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_maximize);
 | 
						struct view *view = wl_container_of(listener, view, request_maximize);
 | 
				
			||||||
	view_maximize(view, view->xdg_surface->toplevel->requested.maximized,
 | 
						view_maximize(view, xdg_toplevel_from_view(view)->requested.maximized,
 | 
				
			||||||
		/*store_natural_geometry*/ true);
 | 
							/*store_natural_geometry*/ true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -155,9 +177,9 @@ static void
 | 
				
			||||||
handle_request_fullscreen(struct wl_listener *listener, void *data)
 | 
					handle_request_fullscreen(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_fullscreen);
 | 
						struct view *view = wl_container_of(listener, view, request_fullscreen);
 | 
				
			||||||
	view_set_fullscreen(view,
 | 
						struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view);
 | 
				
			||||||
		view->xdg_surface->toplevel->requested.fullscreen,
 | 
						view_set_fullscreen(view, xdg_toplevel->requested.fullscreen,
 | 
				
			||||||
		view->xdg_surface->toplevel->requested.fullscreen_output);
 | 
							xdg_toplevel->requested.fullscreen_output);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -190,7 +212,8 @@ xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
 | 
				
			||||||
	view->pending_move_resize.width = geo.width;
 | 
						view->pending_move_resize.width = geo.width;
 | 
				
			||||||
	view->pending_move_resize.height = geo.height;
 | 
						view->pending_move_resize.height = geo.height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t serial = wlr_xdg_toplevel_set_size(view->xdg_surface->toplevel,
 | 
						struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view);
 | 
				
			||||||
 | 
						uint32_t serial = wlr_xdg_toplevel_set_size(xdg_toplevel,
 | 
				
			||||||
		(uint32_t)geo.width, (uint32_t)geo.height);
 | 
							(uint32_t)geo.width, (uint32_t)geo.height);
 | 
				
			||||||
	if (serial > 0) {
 | 
						if (serial > 0) {
 | 
				
			||||||
		view->pending_move_resize.configure_serial = serial;
 | 
							view->pending_move_resize.configure_serial = serial;
 | 
				
			||||||
| 
						 | 
					@ -212,44 +235,39 @@ xdg_toplevel_view_move(struct view *view, int x, int y)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
xdg_toplevel_view_close(struct view *view)
 | 
					xdg_toplevel_view_close(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xdg_toplevel_send_close(view->xdg_surface->toplevel);
 | 
						wlr_xdg_toplevel_send_close(xdg_toplevel_from_view(view));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
xdg_toplevel_view_maximize(struct view *view, bool maximized)
 | 
					xdg_toplevel_view_maximize(struct view *view, bool maximized)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xdg_toplevel_set_maximized(view->xdg_surface->toplevel, maximized);
 | 
						wlr_xdg_toplevel_set_maximized(xdg_toplevel_from_view(view), maximized);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
xdg_toplevel_view_set_activated(struct view *view, bool activated)
 | 
					xdg_toplevel_view_set_activated(struct view *view, bool activated)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
						wlr_xdg_toplevel_set_activated(xdg_toplevel_from_view(view), activated);
 | 
				
			||||||
	if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
					 | 
				
			||||||
		wlr_xdg_toplevel_set_activated(surface->toplevel, activated);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
xdg_toplevel_view_set_fullscreen(struct view *view, bool fullscreen)
 | 
					xdg_toplevel_view_set_fullscreen(struct view *view, bool fullscreen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xdg_toplevel_set_fullscreen(view->xdg_surface->toplevel, fullscreen);
 | 
						wlr_xdg_toplevel_set_fullscreen(xdg_toplevel_from_view(view),
 | 
				
			||||||
}
 | 
							fullscreen);
 | 
				
			||||||
 | 
					 | 
				
			||||||
static bool
 | 
					 | 
				
			||||||
istopmost(struct view *view)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return !view->xdg_surface->toplevel->parent;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct view *
 | 
					static struct view *
 | 
				
			||||||
parent_of(struct view *view)
 | 
					lookup_view_by_xdg_toplevel(struct server *server,
 | 
				
			||||||
 | 
							struct wlr_xdg_toplevel *xdg_toplevel)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *p;
 | 
						struct view *view;
 | 
				
			||||||
	wl_list_for_each(p, &view->server->views, link) {
 | 
						wl_list_for_each(view, &server->views, link) {
 | 
				
			||||||
		if (p->xdg_surface->toplevel
 | 
							if (view->type != LAB_XDG_SHELL_VIEW) {
 | 
				
			||||||
				== view->xdg_surface->toplevel->parent) {
 | 
								continue;
 | 
				
			||||||
			return p;
 | 
							}
 | 
				
			||||||
 | 
							if (xdg_toplevel_from_view(view) == xdg_toplevel) {
 | 
				
			||||||
 | 
								return view;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
| 
						 | 
					@ -258,13 +276,17 @@ parent_of(struct view *view)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
position_xdg_toplevel_view(struct view *view)
 | 
					position_xdg_toplevel_view(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (istopmost(view)) {
 | 
						struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
 | 
				
			||||||
 | 
						struct wlr_xdg_toplevel *parent_xdg_toplevel =
 | 
				
			||||||
 | 
							xdg_toplevel_from_view(view)->parent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!parent_xdg_toplevel) {
 | 
				
			||||||
		struct wlr_box box =
 | 
							struct wlr_box box =
 | 
				
			||||||
			output_usable_area_from_cursor_coords(view->server);
 | 
								output_usable_area_from_cursor_coords(view->server);
 | 
				
			||||||
		view->x = box.x;
 | 
							view->x = box.x;
 | 
				
			||||||
		view->y = box.y;
 | 
							view->y = box.y;
 | 
				
			||||||
		view->w = view->xdg_surface->current.geometry.width;
 | 
							view->w = xdg_surface->current.geometry.width;
 | 
				
			||||||
		view->h = view->xdg_surface->current.geometry.height;
 | 
							view->h = xdg_surface->current.geometry.height;
 | 
				
			||||||
		if (view->w && view->h) {
 | 
							if (view->w && view->h) {
 | 
				
			||||||
			view_center(view);
 | 
								view_center(view);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -273,12 +295,13 @@ position_xdg_toplevel_view(struct view *view)
 | 
				
			||||||
		 * If child-toplevel-views, we center-align relative to their
 | 
							 * If child-toplevel-views, we center-align relative to their
 | 
				
			||||||
		 * parents
 | 
							 * parents
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		struct view *parent = parent_of(view);
 | 
							struct view *parent = lookup_view_by_xdg_toplevel(
 | 
				
			||||||
 | 
								view->server, parent_xdg_toplevel);
 | 
				
			||||||
		assert(parent);
 | 
							assert(parent);
 | 
				
			||||||
		int center_x = parent->x + parent->w / 2;
 | 
							int center_x = parent->x + parent->w / 2;
 | 
				
			||||||
		int center_y = parent->y + parent->h / 2;
 | 
							int center_y = parent->y + parent->h / 2;
 | 
				
			||||||
		view->x = center_x - view->xdg_surface->current.geometry.width / 2;
 | 
							view->x = center_x - xdg_surface->current.geometry.width / 2;
 | 
				
			||||||
		view->y = center_y - view->xdg_surface->current.geometry.height / 2;
 | 
							view->y = center_y - xdg_surface->current.geometry.height / 2;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view->x += view->ssd.margin.left;
 | 
						view->x += view->ssd.margin.left;
 | 
				
			||||||
	view->y += view->ssd.margin.top;
 | 
						view->y += view->ssd.margin.top;
 | 
				
			||||||
| 
						 | 
					@ -287,11 +310,12 @@ position_xdg_toplevel_view(struct view *view)
 | 
				
			||||||
static const char *
 | 
					static const char *
 | 
				
			||||||
xdg_toplevel_view_get_string_prop(struct view *view, const char *prop)
 | 
					xdg_toplevel_view_get_string_prop(struct view *view, const char *prop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view);
 | 
				
			||||||
	if (!strcmp(prop, "title")) {
 | 
						if (!strcmp(prop, "title")) {
 | 
				
			||||||
		return view->xdg_surface->toplevel->title;
 | 
							return xdg_toplevel->title;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!strcmp(prop, "app_id")) {
 | 
						if (!strcmp(prop, "app_id")) {
 | 
				
			||||||
		return view->xdg_surface->toplevel->app_id;
 | 
							return xdg_toplevel->app_id;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return "";
 | 
						return "";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -303,11 +327,12 @@ xdg_toplevel_view_map(struct view *view)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view->mapped = true;
 | 
						view->mapped = true;
 | 
				
			||||||
	view->surface = view->xdg_surface->surface;
 | 
						struct wlr_xdg_surface *xdg_surface = xdg_surface_from_view(view);
 | 
				
			||||||
 | 
						view->surface = xdg_surface->surface;
 | 
				
			||||||
	wlr_scene_node_set_enabled(&view->scene_tree->node, true);
 | 
						wlr_scene_node_set_enabled(&view->scene_tree->node, true);
 | 
				
			||||||
	if (!view->been_mapped) {
 | 
						if (!view->been_mapped) {
 | 
				
			||||||
		struct wlr_xdg_toplevel_requested *requested =
 | 
							struct wlr_xdg_toplevel_requested *requested =
 | 
				
			||||||
			&view->xdg_surface->toplevel->requested;
 | 
								&xdg_toplevel_from_view(view)->requested;
 | 
				
			||||||
		foreign_toplevel_handle_create(view);
 | 
							foreign_toplevel_handle_create(view);
 | 
				
			||||||
		view_set_decorations(view, has_ssd(view));
 | 
							view_set_decorations(view, has_ssd(view));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -325,8 +350,7 @@ xdg_toplevel_view_map(struct view *view)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->commit.notify = handle_commit;
 | 
						view->commit.notify = handle_commit;
 | 
				
			||||||
	wl_signal_add(&view->xdg_surface->surface->events.commit,
 | 
						wl_signal_add(&xdg_surface->surface->events.commit, &view->commit);
 | 
				
			||||||
		&view->commit);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view_impl_map(view);
 | 
						view_impl_map(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -384,14 +408,14 @@ xdg_surface_new(struct wl_listener *listener, void *data)
 | 
				
			||||||
	view->server = server;
 | 
						view->server = server;
 | 
				
			||||||
	view->type = LAB_XDG_SHELL_VIEW;
 | 
						view->type = LAB_XDG_SHELL_VIEW;
 | 
				
			||||||
	view->impl = &xdg_toplevel_view_impl;
 | 
						view->impl = &xdg_toplevel_view_impl;
 | 
				
			||||||
	view->xdg_surface = xdg_surface;
 | 
						xdg_toplevel_view->xdg_surface = xdg_surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->workspace = server->workspace_current;
 | 
						view->workspace = server->workspace_current;
 | 
				
			||||||
	view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
 | 
						view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
 | 
				
			||||||
	wlr_scene_node_set_enabled(&view->scene_tree->node, false);
 | 
						wlr_scene_node_set_enabled(&view->scene_tree->node, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_scene_tree *tree = wlr_scene_xdg_surface_create(
 | 
						struct wlr_scene_tree *tree = wlr_scene_xdg_surface_create(
 | 
				
			||||||
		view->scene_tree, view->xdg_surface);
 | 
							view->scene_tree, xdg_surface);
 | 
				
			||||||
	if (!tree) {
 | 
						if (!tree) {
 | 
				
			||||||
		/* TODO: might need further clean up */
 | 
							/* TODO: might need further clean up */
 | 
				
			||||||
		wl_resource_post_no_memory(view->surface->resource);
 | 
							wl_resource_post_no_memory(view->surface->resource);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										109
									
								
								src/xwayland.c
									
										
									
									
									
								
							
							
						
						
									
										109
									
								
								src/xwayland.c
									
										
									
									
									
								
							| 
						 | 
					@ -14,6 +14,14 @@ xwayland_view_from_view(struct view *view)
 | 
				
			||||||
	return (struct xwayland_view *)view;
 | 
						return (struct xwayland_view *)view;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct wlr_xwayland_surface *
 | 
				
			||||||
 | 
					xwayland_surface_from_view(struct view *view)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
 | 
				
			||||||
 | 
						assert(xwayland_view->xwayland_surface);
 | 
				
			||||||
 | 
						return xwayland_view->xwayland_surface;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
handle_commit(struct wl_listener *listener, void *data)
 | 
					handle_commit(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -77,8 +85,6 @@ static void
 | 
				
			||||||
handle_map(struct wl_listener *listener, void *data)
 | 
					handle_map(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, map);
 | 
						struct view *view = wl_container_of(listener, view, map);
 | 
				
			||||||
	assert(data && data == view->xwayland_surface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view->impl->map(view);
 | 
						view->impl->map(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -86,8 +92,6 @@ static void
 | 
				
			||||||
handle_unmap(struct wl_listener *listener, void *data)
 | 
					handle_unmap(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, unmap);
 | 
						struct view *view = wl_container_of(listener, view, unmap);
 | 
				
			||||||
	assert(data && data == view->xwayland_surface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view->impl->unmap(view);
 | 
						view->impl->unmap(view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -119,8 +123,9 @@ static void
 | 
				
			||||||
handle_destroy(struct wl_listener *listener, void *data)
 | 
					handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, destroy);
 | 
						struct view *view = wl_container_of(listener, view, destroy);
 | 
				
			||||||
	assert(data && data == view->xwayland_surface);
 | 
						struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
 | 
				
			||||||
	assert(view->xwayland_surface->data == view);
 | 
						assert(data && data == xwayland_view->xwayland_surface);
 | 
				
			||||||
 | 
						assert(xwayland_view->xwayland_surface->data == view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (view->surface) {
 | 
						if (view->surface) {
 | 
				
			||||||
		/*
 | 
							/*
 | 
				
			||||||
| 
						 | 
					@ -137,8 +142,8 @@ handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
	 * may not actually be destroyed at this point; it may become an
 | 
						 * may not actually be destroyed at this point; it may become an
 | 
				
			||||||
	 * "unmanaged" surface instead.
 | 
						 * "unmanaged" surface instead.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	view->xwayland_surface->data = NULL;
 | 
						xwayland_view->xwayland_surface->data = NULL;
 | 
				
			||||||
	view->xwayland_surface = NULL;
 | 
						xwayland_view->xwayland_surface = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Remove XWayland specific handlers */
 | 
						/* Remove XWayland specific handlers */
 | 
				
			||||||
	wl_list_remove(&view->map.link);
 | 
						wl_list_remove(&view->map.link);
 | 
				
			||||||
| 
						 | 
					@ -151,7 +156,6 @@ handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
	wl_list_remove(&view->request_fullscreen.link);
 | 
						wl_list_remove(&view->request_fullscreen.link);
 | 
				
			||||||
	wl_list_remove(&view->set_title.link);
 | 
						wl_list_remove(&view->set_title.link);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct xwayland_view *xwayland_view = xwayland_view_from_view(view);
 | 
					 | 
				
			||||||
	wl_list_remove(&xwayland_view->request_configure.link);
 | 
						wl_list_remove(&xwayland_view->request_configure.link);
 | 
				
			||||||
	wl_list_remove(&xwayland_view->set_app_id.link);
 | 
						wl_list_remove(&xwayland_view->set_app_id.link);
 | 
				
			||||||
	wl_list_remove(&xwayland_view->set_decorations.link);
 | 
						wl_list_remove(&xwayland_view->set_decorations.link);
 | 
				
			||||||
| 
						 | 
					@ -166,15 +170,13 @@ handle_destroy(struct wl_listener *listener, void *data)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
configure(struct view *view, struct wlr_box geo)
 | 
					configure(struct view *view, struct wlr_box geo)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	assert(view->xwayland_surface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view->pending_move_resize.x = geo.x;
 | 
						view->pending_move_resize.x = geo.x;
 | 
				
			||||||
	view->pending_move_resize.y = geo.y;
 | 
						view->pending_move_resize.y = geo.y;
 | 
				
			||||||
	view->pending_move_resize.width = geo.width;
 | 
						view->pending_move_resize.width = geo.width;
 | 
				
			||||||
	view->pending_move_resize.height = geo.height;
 | 
						view->pending_move_resize.height = geo.height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_xwayland_surface_configure(view->xwayland_surface, geo.x, geo.y,
 | 
						wlr_xwayland_surface_configure(xwayland_surface_from_view(view),
 | 
				
			||||||
				       geo.width, geo.height);
 | 
							geo.x, geo.y, geo.width, geo.height);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* If not resizing, process the move immediately */
 | 
						/* If not resizing, process the move immediately */
 | 
				
			||||||
	if (view->w == geo.width && view->h == geo.height) {
 | 
						if (view->w == geo.width && view->h == geo.height) {
 | 
				
			||||||
| 
						 | 
					@ -229,7 +231,7 @@ static void
 | 
				
			||||||
handle_request_fullscreen(struct wl_listener *listener, void *data)
 | 
					handle_request_fullscreen(struct wl_listener *listener, void *data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct view *view = wl_container_of(listener, view, request_fullscreen);
 | 
						struct view *view = wl_container_of(listener, view, request_fullscreen);
 | 
				
			||||||
	bool fullscreen = view->xwayland_surface->fullscreen;
 | 
						bool fullscreen = xwayland_surface_from_view(view)->fullscreen;
 | 
				
			||||||
	view_set_fullscreen(view, fullscreen, NULL);
 | 
						view_set_fullscreen(view, fullscreen, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -254,8 +256,6 @@ handle_set_class(struct wl_listener *listener, void *data)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
move(struct view *view, int x, int y)
 | 
					move(struct view *view, int x, int y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	assert(view->xwayland_surface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	view->x = x;
 | 
						view->x = x;
 | 
				
			||||||
	view->y = y;
 | 
						view->y = y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -263,7 +263,7 @@ move(struct view *view, int x, int y)
 | 
				
			||||||
	view->pending_move_resize.x = x;
 | 
						view->pending_move_resize.x = x;
 | 
				
			||||||
	view->pending_move_resize.y = y;
 | 
						view->pending_move_resize.y = y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wlr_xwayland_surface *s = view->xwayland_surface;
 | 
						struct wlr_xwayland_surface *s = xwayland_surface_from_view(view);
 | 
				
			||||||
	wlr_xwayland_surface_configure(s, (int16_t)x, (int16_t)y,
 | 
						wlr_xwayland_surface_configure(s, (int16_t)x, (int16_t)y,
 | 
				
			||||||
		(uint16_t)s->width, (uint16_t)s->height);
 | 
							(uint16_t)s->width, (uint16_t)s->height);
 | 
				
			||||||
	view_moved(view);
 | 
						view_moved(view);
 | 
				
			||||||
| 
						 | 
					@ -272,29 +272,31 @@ move(struct view *view, int x, int y)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
_close(struct view *view)
 | 
					_close(struct view *view)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xwayland_surface_close(view->xwayland_surface);
 | 
						wlr_xwayland_surface_close(xwayland_surface_from_view(view));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *
 | 
					static const char *
 | 
				
			||||||
get_string_prop(struct view *view, const char *prop)
 | 
					get_string_prop(struct view *view, const char *prop)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct wlr_xwayland_surface *xwayland_surface =
 | 
				
			||||||
 | 
							xwayland_surface_from_view(view);
 | 
				
			||||||
	if (!strcmp(prop, "title")) {
 | 
						if (!strcmp(prop, "title")) {
 | 
				
			||||||
		return view->xwayland_surface->title;
 | 
							return xwayland_surface->title;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!strcmp(prop, "class")) {
 | 
						if (!strcmp(prop, "class")) {
 | 
				
			||||||
		return view->xwayland_surface->class;
 | 
							return xwayland_surface->class;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	/* We give 'class' for wlr_foreign_toplevel_handle_v1_set_app_id() */
 | 
						/* We give 'class' for wlr_foreign_toplevel_handle_v1_set_app_id() */
 | 
				
			||||||
	if (!strcmp(prop, "app_id")) {
 | 
						if (!strcmp(prop, "app_id")) {
 | 
				
			||||||
		return view->xwayland_surface->class;
 | 
							return xwayland_surface->class;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return "";
 | 
						return "";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool
 | 
					static bool
 | 
				
			||||||
want_deco(struct view *view)
 | 
					want_deco(struct wlr_xwayland_surface *xwayland_surface)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return view->xwayland_surface->decorations ==
 | 
						return xwayland_surface->decorations ==
 | 
				
			||||||
	       WLR_XWAYLAND_SURFACE_DECORATIONS_ALL;
 | 
						       WLR_XWAYLAND_SURFACE_DECORATIONS_ALL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -304,7 +306,9 @@ handle_set_decorations(struct wl_listener *listener, void *data)
 | 
				
			||||||
	struct xwayland_view *xwayland_view =
 | 
						struct xwayland_view *xwayland_view =
 | 
				
			||||||
		wl_container_of(listener, xwayland_view, set_decorations);
 | 
							wl_container_of(listener, xwayland_view, set_decorations);
 | 
				
			||||||
	struct view *view = &xwayland_view->base;
 | 
						struct view *view = &xwayland_view->base;
 | 
				
			||||||
	view_set_decorations(view, want_deco(view));
 | 
						assert(data && data == xwayland_view->xwayland_surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view_set_decorations(view, want_deco(xwayland_view->xwayland_surface));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
| 
						 | 
					@ -314,7 +318,8 @@ handle_override_redirect(struct wl_listener *listener, void *data)
 | 
				
			||||||
		wl_container_of(listener, xwayland_view, override_redirect);
 | 
							wl_container_of(listener, xwayland_view, override_redirect);
 | 
				
			||||||
	struct view *view = &xwayland_view->base;
 | 
						struct view *view = &xwayland_view->base;
 | 
				
			||||||
	struct wlr_xwayland_surface *xsurface = data;
 | 
						struct wlr_xwayland_surface *xsurface = data;
 | 
				
			||||||
	assert(xsurface && xsurface == view->xwayland_surface);
 | 
						assert(xsurface && xsurface == xwayland_view->xwayland_surface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct server *server = view->server;
 | 
						struct server *server = view->server;
 | 
				
			||||||
	bool mapped = xsurface->mapped;
 | 
						bool mapped = xsurface->mapped;
 | 
				
			||||||
	if (mapped) {
 | 
						if (mapped) {
 | 
				
			||||||
| 
						 | 
					@ -330,11 +335,12 @@ handle_override_redirect(struct wl_listener *listener, void *data)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
set_initial_position(struct view *view)
 | 
					set_initial_position(struct view *view,
 | 
				
			||||||
 | 
							struct wlr_xwayland_surface *xwayland_surface)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	/* Don't center views with position explicitly specified */
 | 
						/* Don't center views with position explicitly specified */
 | 
				
			||||||
	bool has_position = view->xwayland_surface->size_hints &&
 | 
						bool has_position = xwayland_surface->size_hints &&
 | 
				
			||||||
		(view->xwayland_surface->size_hints->flags &
 | 
							(xwayland_surface->size_hints->flags &
 | 
				
			||||||
			(XCB_ICCCM_SIZE_HINT_US_POSITION |
 | 
								(XCB_ICCCM_SIZE_HINT_US_POSITION |
 | 
				
			||||||
			 XCB_ICCCM_SIZE_HINT_P_POSITION));
 | 
								 XCB_ICCCM_SIZE_HINT_P_POSITION));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -374,21 +380,23 @@ map(struct view *view)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view->mapped = true;
 | 
						view->mapped = true;
 | 
				
			||||||
	wlr_scene_node_set_enabled(&view->scene_tree->node, true);
 | 
						wlr_scene_node_set_enabled(&view->scene_tree->node, true);
 | 
				
			||||||
	if (!view->fullscreen && view->xwayland_surface->fullscreen) {
 | 
						struct wlr_xwayland_surface *xwayland_surface =
 | 
				
			||||||
 | 
							xwayland_surface_from_view(view);
 | 
				
			||||||
 | 
						if (!view->fullscreen && xwayland_surface->fullscreen) {
 | 
				
			||||||
		view_set_fullscreen(view, true, NULL);
 | 
							view_set_fullscreen(view, true, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!view->maximized && !view->fullscreen) {
 | 
						if (!view->maximized && !view->fullscreen) {
 | 
				
			||||||
		view->x = view->xwayland_surface->x;
 | 
							view->x = xwayland_surface->x;
 | 
				
			||||||
		view->y = view->xwayland_surface->y;
 | 
							view->y = xwayland_surface->y;
 | 
				
			||||||
		view->w = view->xwayland_surface->width;
 | 
							view->w = xwayland_surface->width;
 | 
				
			||||||
		view->h = view->xwayland_surface->height;
 | 
							view->h = xwayland_surface->height;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (view->surface != view->xwayland_surface->surface) {
 | 
						if (view->surface != xwayland_surface->surface) {
 | 
				
			||||||
		if (view->surface) {
 | 
							if (view->surface) {
 | 
				
			||||||
			wl_list_remove(&view->surface_destroy.link);
 | 
								wl_list_remove(&view->surface_destroy.link);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		view->surface = view->xwayland_surface->surface;
 | 
							view->surface = xwayland_surface->surface;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Required to set the surface to NULL when destroyed by the client */
 | 
							/* Required to set the surface to NULL when destroyed by the client */
 | 
				
			||||||
		view->surface_destroy.notify = handle_surface_destroy;
 | 
							view->surface_destroy.notify = handle_surface_destroy;
 | 
				
			||||||
| 
						 | 
					@ -410,10 +418,10 @@ map(struct view *view)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!view->been_mapped) {
 | 
						if (!view->been_mapped) {
 | 
				
			||||||
		view_set_decorations(view, want_deco(view));
 | 
							view_set_decorations(view, want_deco(xwayland_surface));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!view->maximized && !view->fullscreen) {
 | 
							if (!view->maximized && !view->fullscreen) {
 | 
				
			||||||
			set_initial_position(view);
 | 
								set_initial_position(view, xwayland_surface);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		view_moved(view);
 | 
							view_moved(view);
 | 
				
			||||||
| 
						 | 
					@ -425,8 +433,7 @@ map(struct view *view)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Add commit here, as xwayland map/unmap can change the wlr_surface */
 | 
						/* Add commit here, as xwayland map/unmap can change the wlr_surface */
 | 
				
			||||||
	wl_signal_add(&view->xwayland_surface->surface->events.commit,
 | 
						wl_signal_add(&xwayland_surface->surface->events.commit, &view->commit);
 | 
				
			||||||
		      &view->commit);
 | 
					 | 
				
			||||||
	view->commit.notify = handle_commit;
 | 
						view->commit.notify = handle_commit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view_impl_map(view);
 | 
						view_impl_map(view);
 | 
				
			||||||
| 
						 | 
					@ -447,27 +454,30 @@ unmap(struct view *view)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
maximize(struct view *view, bool maximized)
 | 
					maximize(struct view *view, bool maximized)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized);
 | 
						wlr_xwayland_surface_set_maximized(xwayland_surface_from_view(view),
 | 
				
			||||||
 | 
							maximized);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
set_activated(struct view *view, bool activated)
 | 
					set_activated(struct view *view, bool activated)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct wlr_xwayland_surface *surface = view->xwayland_surface;
 | 
						struct wlr_xwayland_surface *xwayland_surface =
 | 
				
			||||||
 | 
							xwayland_surface_from_view(view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (activated && surface->minimized) {
 | 
						if (activated && xwayland_surface->minimized) {
 | 
				
			||||||
		wlr_xwayland_surface_set_minimized(surface, false);
 | 
							wlr_xwayland_surface_set_minimized(xwayland_surface, false);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_xwayland_surface_activate(surface, activated);
 | 
						wlr_xwayland_surface_activate(xwayland_surface, activated);
 | 
				
			||||||
	if (activated) {
 | 
						if (activated) {
 | 
				
			||||||
		wlr_xwayland_surface_restack(surface, NULL, XCB_STACK_MODE_ABOVE);
 | 
							wlr_xwayland_surface_restack(xwayland_surface,
 | 
				
			||||||
 | 
								NULL, XCB_STACK_MODE_ABOVE);
 | 
				
			||||||
		/* Restack unmanaged surfaces on top */
 | 
							/* Restack unmanaged surfaces on top */
 | 
				
			||||||
		struct xwayland_unmanaged *u;
 | 
							struct xwayland_unmanaged *u;
 | 
				
			||||||
		struct wl_list *list = &view->server->unmanaged_surfaces;
 | 
							struct wl_list *list = &view->server->unmanaged_surfaces;
 | 
				
			||||||
		wl_list_for_each(u, list, link) {
 | 
							wl_list_for_each(u, list, link) {
 | 
				
			||||||
			wlr_xwayland_surface_restack(u->xwayland_surface, NULL,
 | 
								wlr_xwayland_surface_restack(u->xwayland_surface,
 | 
				
			||||||
						     XCB_STACK_MODE_ABOVE);
 | 
									NULL, XCB_STACK_MODE_ABOVE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -475,7 +485,8 @@ set_activated(struct view *view, bool activated)
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
set_fullscreen(struct view *view, bool fullscreen)
 | 
					set_fullscreen(struct view *view, bool fullscreen)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
 | 
						wlr_xwayland_surface_set_fullscreen(xwayland_surface_from_view(view),
 | 
				
			||||||
 | 
							fullscreen);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct view_impl xwl_view_impl = {
 | 
					static const struct view_impl xwl_view_impl = {
 | 
				
			||||||
| 
						 | 
					@ -522,7 +533,7 @@ xwayland_surface_new(struct wl_listener *listener, void *data)
 | 
				
			||||||
	 * from the view (destroying the view) and makes it an
 | 
						 * from the view (destroying the view) and makes it an
 | 
				
			||||||
	 * "unmanaged" surface.
 | 
						 * "unmanaged" surface.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	view->xwayland_surface = xsurface;
 | 
						xwayland_view->xwayland_surface = xsurface;
 | 
				
			||||||
	xsurface->data = view;
 | 
						xsurface->data = view;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->workspace = server->workspace_current;
 | 
						view->workspace = server->workspace_current;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue