mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	rootston: make roots_view embedded and remove unions
This commit is contained in:
		
							parent
							
								
									9f11bf571e
								
							
						
					
					
						commit
						9adcbabea4
					
				
					 10 changed files with 411 additions and 398 deletions
				
			
		| 
						 | 
				
			
			@ -9,91 +9,6 @@
 | 
			
		|||
#include <wlr/types/wlr_xdg_shell_v6.h>
 | 
			
		||||
#include <wlr/types/wlr_xdg_shell.h>
 | 
			
		||||
 | 
			
		||||
struct roots_wl_shell_surface {
 | 
			
		||||
	struct roots_view *view;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_state;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_class;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface_v6 {
 | 
			
		||||
	struct roots_view *view;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_app_id;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
 | 
			
		||||
	uint32_t pending_move_resize_configure_serial;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_toplevel_decoration;
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface {
 | 
			
		||||
	struct roots_view *view;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_app_id;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
 | 
			
		||||
	uint32_t pending_move_resize_configure_serial;
 | 
			
		||||
 | 
			
		||||
	struct roots_xdg_toplevel_decoration *xdg_toplevel_decoration;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_xwayland_surface {
 | 
			
		||||
	struct roots_view *view;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener request_configure;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_class;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum roots_view_type {
 | 
			
		||||
	ROOTS_WL_SHELL_VIEW,
 | 
			
		||||
	ROOTS_XDG_SHELL_V6_VIEW,
 | 
			
		||||
	ROOTS_XDG_SHELL_VIEW,
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	ROOTS_XWAYLAND_VIEW,
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_view;
 | 
			
		||||
 | 
			
		||||
struct roots_view_interface {
 | 
			
		||||
| 
						 | 
				
			
			@ -108,7 +23,17 @@ struct roots_view_interface {
 | 
			
		|||
	void (*destroy)(struct roots_view *view);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum roots_view_type {
 | 
			
		||||
	ROOTS_WL_SHELL_VIEW,
 | 
			
		||||
	ROOTS_XDG_SHELL_V6_VIEW,
 | 
			
		||||
	ROOTS_XDG_SHELL_VIEW,
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	ROOTS_XWAYLAND_VIEW,
 | 
			
		||||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_view {
 | 
			
		||||
	enum roots_view_type type;
 | 
			
		||||
	const struct roots_view_interface *impl;
 | 
			
		||||
	struct roots_desktop *desktop;
 | 
			
		||||
	struct wl_list link; // roots_desktop::views
 | 
			
		||||
| 
						 | 
				
			
			@ -135,25 +60,6 @@ struct roots_view {
 | 
			
		|||
		uint32_t width, height;
 | 
			
		||||
	} pending_move_resize;
 | 
			
		||||
 | 
			
		||||
	// TODO: Something for roots-enforced width/height
 | 
			
		||||
	enum roots_view_type type;
 | 
			
		||||
	union {
 | 
			
		||||
		struct wlr_wl_shell_surface *wl_shell_surface;
 | 
			
		||||
		struct wlr_xdg_surface_v6 *xdg_surface_v6;
 | 
			
		||||
		struct wlr_xdg_surface *xdg_surface;
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
		struct wlr_xwayland_surface *xwayland_surface;
 | 
			
		||||
#endif
 | 
			
		||||
	};
 | 
			
		||||
	union {
 | 
			
		||||
		struct roots_wl_shell_surface *roots_wl_shell_surface;
 | 
			
		||||
		struct roots_xdg_surface_v6 *roots_xdg_surface_v6;
 | 
			
		||||
		struct roots_xdg_surface *roots_xdg_surface;
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
		struct roots_xwayland_surface *roots_xwayland_surface;
 | 
			
		||||
#endif
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	struct wlr_surface *wlr_surface;
 | 
			
		||||
	struct wl_list children; // roots_view_child::link
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -170,6 +76,91 @@ struct roots_view {
 | 
			
		|||
	} events;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_wl_shell_surface {
 | 
			
		||||
	struct roots_view view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_wl_shell_surface *wl_shell_surface;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_state;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_class;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface_v6 {
 | 
			
		||||
	struct roots_view view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_xdg_surface_v6 *xdg_surface_v6;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_app_id;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
 | 
			
		||||
	uint32_t pending_move_resize_configure_serial;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_toplevel_decoration;
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface {
 | 
			
		||||
	struct roots_view view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener new_popup;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_app_id;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
 | 
			
		||||
	uint32_t pending_move_resize_configure_serial;
 | 
			
		||||
 | 
			
		||||
	struct roots_xdg_toplevel_decoration *xdg_toplevel_decoration;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
struct roots_xwayland_surface {
 | 
			
		||||
	struct roots_view view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener destroy;
 | 
			
		||||
	struct wl_listener request_configure;
 | 
			
		||||
	struct wl_listener request_move;
 | 
			
		||||
	struct wl_listener request_resize;
 | 
			
		||||
	struct wl_listener request_maximize;
 | 
			
		||||
	struct wl_listener request_fullscreen;
 | 
			
		||||
	struct wl_listener map;
 | 
			
		||||
	struct wl_listener unmap;
 | 
			
		||||
	struct wl_listener set_title;
 | 
			
		||||
	struct wl_listener set_class;
 | 
			
		||||
 | 
			
		||||
	struct wl_listener surface_commit;
 | 
			
		||||
};
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct roots_view_child;
 | 
			
		||||
 | 
			
		||||
struct roots_view_child_interface {
 | 
			
		||||
| 
						 | 
				
			
			@ -228,8 +219,8 @@ struct roots_xdg_toplevel_decoration {
 | 
			
		|||
	struct wl_listener surface_commit;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct roots_view *view_create(struct roots_desktop *desktop,
 | 
			
		||||
	const struct roots_view_interface *impl);
 | 
			
		||||
void view_init(struct roots_view *view, const struct roots_view_interface *impl,
 | 
			
		||||
	enum roots_view_type type, struct roots_desktop *desktop);
 | 
			
		||||
void view_destroy(struct roots_view *view);
 | 
			
		||||
void view_activate(struct roots_view *view, bool activate);
 | 
			
		||||
void view_apply_damage(struct roots_view *view);
 | 
			
		||||
| 
						 | 
				
			
			@ -256,13 +247,19 @@ void view_close(struct roots_view *view);
 | 
			
		|||
bool view_center(struct roots_view *view);
 | 
			
		||||
void view_setup(struct roots_view *view);
 | 
			
		||||
void view_teardown(struct roots_view *view);
 | 
			
		||||
 | 
			
		||||
void view_set_title(struct roots_view *view, const char *title);
 | 
			
		||||
void view_set_app_id(struct roots_view *view, const char *app_id);
 | 
			
		||||
void view_create_foreign_toplevel_handle(struct roots_view *view);
 | 
			
		||||
 | 
			
		||||
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box);
 | 
			
		||||
 | 
			
		||||
struct roots_wl_shell_surface *roots_wl_shell_surface_from_view(
 | 
			
		||||
	struct roots_view *view);
 | 
			
		||||
struct roots_xdg_surface *roots_xdg_surface_from_view(struct roots_view *view);
 | 
			
		||||
struct roots_xdg_surface_v6 *roots_xdg_surface_v6_from_view(
 | 
			
		||||
	struct roots_view *view);
 | 
			
		||||
struct roots_xwayland_surface *roots_xwayland_surface_from_view(
 | 
			
		||||
	struct roots_view *view);
 | 
			
		||||
 | 
			
		||||
enum roots_deco_part {
 | 
			
		||||
	ROOTS_DECO_PART_NONE = 0,
 | 
			
		||||
	ROOTS_DECO_PART_TOP_BORDER = (1 << 0),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@
 | 
			
		|||
#include <sys/wait.h>
 | 
			
		||||
#include <wlr/util/log.h>
 | 
			
		||||
#include "rootston/bindings.h"
 | 
			
		||||
#include "rootston/view.h"
 | 
			
		||||
 | 
			
		||||
static bool outputs_enabled = true;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -83,8 +84,10 @@ void execute_binding_command(struct roots_seat *seat,
 | 
			
		|||
	} else if (strcmp(command, "toggle_decoration_mode") == 0) {
 | 
			
		||||
		struct roots_view *focus = roots_seat_get_focus(seat);
 | 
			
		||||
		if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
 | 
			
		||||
			struct roots_xdg_surface *xdg_surface =
 | 
			
		||||
				roots_xdg_surface_from_view(focus);
 | 
			
		||||
			struct roots_xdg_toplevel_decoration *decoration =
 | 
			
		||||
				focus->roots_xdg_surface->xdg_toplevel_decoration;
 | 
			
		||||
				xdg_surface->xdg_toplevel_decoration;
 | 
			
		||||
			if (decoration != NULL) {
 | 
			
		||||
				enum wlr_xdg_toplevel_decoration_v1_mode mode =
 | 
			
		||||
					decoration->wlr_decoration->current_mode;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,9 +38,12 @@
 | 
			
		|||
 | 
			
		||||
static bool view_at(struct roots_view *view, double lx, double ly,
 | 
			
		||||
		struct wlr_surface **surface, double *sx, double *sy) {
 | 
			
		||||
	if (view->type == ROOTS_WL_SHELL_VIEW &&
 | 
			
		||||
			view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
 | 
			
		||||
		return false;
 | 
			
		||||
	if (view->type == ROOTS_WL_SHELL_VIEW) {
 | 
			
		||||
		struct wlr_wl_shell_surface *wl_shell_surface =
 | 
			
		||||
			roots_wl_shell_surface_from_view(view)->wl_shell_surface;
 | 
			
		||||
		if (wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (view->wlr_surface == NULL) {
 | 
			
		||||
		return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -68,17 +71,23 @@ static bool view_at(struct roots_view *view, double lx, double ly,
 | 
			
		|||
	double _sx, _sy;
 | 
			
		||||
	struct wlr_surface *_surface = NULL;
 | 
			
		||||
	switch (view->type) {
 | 
			
		||||
	case ROOTS_XDG_SHELL_V6_VIEW:
 | 
			
		||||
		_surface = wlr_xdg_surface_v6_surface_at(view->xdg_surface_v6,
 | 
			
		||||
	case ROOTS_XDG_SHELL_V6_VIEW:;
 | 
			
		||||
		struct roots_xdg_surface_v6 *xdg_surface_v6 =
 | 
			
		||||
			roots_xdg_surface_v6_from_view(view);
 | 
			
		||||
		_surface = wlr_xdg_surface_v6_surface_at(xdg_surface_v6->xdg_surface_v6,
 | 
			
		||||
			view_sx, view_sy, &_sx, &_sy);
 | 
			
		||||
		break;
 | 
			
		||||
	case ROOTS_XDG_SHELL_VIEW:
 | 
			
		||||
		_surface = wlr_xdg_surface_surface_at(view->xdg_surface,
 | 
			
		||||
	case ROOTS_XDG_SHELL_VIEW:;
 | 
			
		||||
		struct roots_xdg_surface *xdg_surface =
 | 
			
		||||
			roots_xdg_surface_from_view(view);
 | 
			
		||||
		_surface = wlr_xdg_surface_surface_at(xdg_surface->xdg_surface,
 | 
			
		||||
			view_sx, view_sy, &_sx, &_sy);
 | 
			
		||||
		break;
 | 
			
		||||
	case ROOTS_WL_SHELL_VIEW:
 | 
			
		||||
		_surface = wlr_wl_shell_surface_surface_at(view->wl_shell_surface,
 | 
			
		||||
			view_sx, view_sy, &_sx, &_sy);
 | 
			
		||||
	case ROOTS_WL_SHELL_VIEW:;
 | 
			
		||||
		struct roots_wl_shell_surface *wl_shell_surface =
 | 
			
		||||
			roots_wl_shell_surface_from_view(view);
 | 
			
		||||
		_surface = wlr_wl_shell_surface_surface_at(
 | 
			
		||||
			wl_shell_surface->wl_shell_surface, view_sx, view_sy, &_sx, &_sy);
 | 
			
		||||
		break;
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	case ROOTS_XWAYLAND_VIEW:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,8 +43,9 @@ struct layout_data {
 | 
			
		|||
	float rotation;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void get_layout_position(struct layout_data *data, double *lx, double *ly,
 | 
			
		||||
		const struct wlr_surface *surface, int sx, int sy) {
 | 
			
		||||
static void get_layout_position(struct layout_data *data,
 | 
			
		||||
		double *lx, double *ly, const struct wlr_surface *surface,
 | 
			
		||||
		int sx, int sy) {
 | 
			
		||||
	double _sx = sx, _sy = sy;
 | 
			
		||||
	rotate_child_position(&_sx, &_sy, surface->current.width,
 | 
			
		||||
		surface->current.height, data->width, data->height, data->rotation);
 | 
			
		||||
| 
						 | 
				
			
			@ -78,17 +79,23 @@ static void view_for_each_surface(struct roots_view *view,
 | 
			
		|||
	layout_data->rotation = view->rotation;
 | 
			
		||||
 | 
			
		||||
	switch (view->type) {
 | 
			
		||||
	case ROOTS_XDG_SHELL_V6_VIEW:
 | 
			
		||||
		wlr_xdg_surface_v6_for_each_surface(view->xdg_surface_v6, iterator,
 | 
			
		||||
	case ROOTS_XDG_SHELL_V6_VIEW:;
 | 
			
		||||
		struct roots_xdg_surface_v6 *xdg_surface_v6 =
 | 
			
		||||
			roots_xdg_surface_v6_from_view(view);
 | 
			
		||||
		wlr_xdg_surface_v6_for_each_surface(xdg_surface_v6->xdg_surface_v6,
 | 
			
		||||
			iterator, user_data);
 | 
			
		||||
		break;
 | 
			
		||||
	case ROOTS_XDG_SHELL_VIEW:;
 | 
			
		||||
		struct roots_xdg_surface *xdg_surface =
 | 
			
		||||
			roots_xdg_surface_from_view(view);
 | 
			
		||||
		wlr_xdg_surface_for_each_surface(xdg_surface->xdg_surface, iterator,
 | 
			
		||||
			user_data);
 | 
			
		||||
		break;
 | 
			
		||||
	case ROOTS_XDG_SHELL_VIEW:
 | 
			
		||||
		wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator,
 | 
			
		||||
			user_data);
 | 
			
		||||
		break;
 | 
			
		||||
	case ROOTS_WL_SHELL_VIEW:
 | 
			
		||||
		wlr_wl_shell_surface_for_each_surface(view->wl_shell_surface, iterator,
 | 
			
		||||
			user_data);
 | 
			
		||||
	case ROOTS_WL_SHELL_VIEW:;
 | 
			
		||||
		struct roots_wl_shell_surface *wl_shell_surface =
 | 
			
		||||
			roots_wl_shell_surface_from_view(view);
 | 
			
		||||
		wlr_wl_shell_surface_for_each_surface(wl_shell_surface->wl_shell_surface,
 | 
			
		||||
			iterator, user_data);
 | 
			
		||||
		break;
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	case ROOTS_XWAYLAND_VIEW:
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +172,10 @@ static void output_for_each_surface(struct roots_output *output,
 | 
			
		|||
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
		if (view->type == ROOTS_XWAYLAND_VIEW) {
 | 
			
		||||
			xwayland_children_for_each_surface(view->xwayland_surface,
 | 
			
		||||
			struct roots_xwayland_surface *xwayland_surface =
 | 
			
		||||
				roots_xwayland_surface_from_view(view);
 | 
			
		||||
			xwayland_children_for_each_surface(
 | 
			
		||||
				xwayland_surface->xwayland_surface,
 | 
			
		||||
				iterator, layout_data, user_data);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -497,7 +507,10 @@ static void render_output(struct roots_output *output) {
 | 
			
		|||
		// the fullscreen window's children so we have to traverse the tree.
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
		if (view->type == ROOTS_XWAYLAND_VIEW) {
 | 
			
		||||
			xwayland_children_for_each_surface(view->xwayland_surface,
 | 
			
		||||
			struct roots_xwayland_surface *xwayland_surface =
 | 
			
		||||
				roots_xwayland_surface_from_view(view);
 | 
			
		||||
			xwayland_children_for_each_surface(
 | 
			
		||||
				xwayland_surface->xwayland_surface,
 | 
			
		||||
				render_surface, &data.layout, &data);
 | 
			
		||||
		}
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -568,9 +581,12 @@ static bool view_accept_damage(struct roots_output *output,
 | 
			
		|||
	if (output->fullscreen_view->type == ROOTS_XWAYLAND_VIEW &&
 | 
			
		||||
			view->type == ROOTS_XWAYLAND_VIEW) {
 | 
			
		||||
		// Special case: accept damage from children
 | 
			
		||||
		struct wlr_xwayland_surface *xsurface = view->xwayland_surface;
 | 
			
		||||
		struct wlr_xwayland_surface *xsurface =
 | 
			
		||||
			roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
		struct wlr_xwayland_surface *fullscreen_xsurface =
 | 
			
		||||
			roots_xwayland_surface_from_view(output->fullscreen_view)->xwayland_surface;
 | 
			
		||||
		while (xsurface != NULL) {
 | 
			
		||||
			if (output->fullscreen_view->xwayland_surface == xsurface) {
 | 
			
		||||
			if (fullscreen_xsurface == xsurface) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
			xsurface = xsurface->parent;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1293,9 +1293,12 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
 | 
			
		|||
	bool unfullscreen = true;
 | 
			
		||||
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	if (view && view->type == ROOTS_XWAYLAND_VIEW &&
 | 
			
		||||
			view->xwayland_surface->override_redirect) {
 | 
			
		||||
		unfullscreen = false;
 | 
			
		||||
	if (view && view->type == ROOTS_XWAYLAND_VIEW) {
 | 
			
		||||
		struct roots_xwayland_surface *xwayland_surface =
 | 
			
		||||
			roots_xwayland_surface_from_view(view);
 | 
			
		||||
		if (xwayland_surface->xwayland_surface->override_redirect) {
 | 
			
		||||
			unfullscreen = false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1322,10 +1325,13 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
#if WLR_HAS_XWAYLAND
 | 
			
		||||
	if (view && view->type == ROOTS_XWAYLAND_VIEW &&
 | 
			
		||||
			!wlr_xwayland_or_surface_wants_focus(
 | 
			
		||||
				view->xwayland_surface)) {
 | 
			
		||||
		return;
 | 
			
		||||
	if (view && view->type == ROOTS_XWAYLAND_VIEW) {
 | 
			
		||||
		struct roots_xwayland_surface *xwayland_surface =
 | 
			
		||||
			roots_xwayland_surface_from_view(view);
 | 
			
		||||
		if (!wlr_xwayland_or_surface_wants_focus(
 | 
			
		||||
				xwayland_surface->xwayland_surface)) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
	struct roots_seat_view *seat_view = NULL;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,19 +8,35 @@
 | 
			
		|||
#include "rootston/server.h"
 | 
			
		||||
#include "rootston/view.h"
 | 
			
		||||
 | 
			
		||||
struct roots_view *view_create(struct roots_desktop *desktop,
 | 
			
		||||
		const struct roots_view_interface *impl) {
 | 
			
		||||
	struct roots_view *view = calloc(1, sizeof(struct roots_view));
 | 
			
		||||
	if (!view) {
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
void view_init(struct roots_view *view, const struct roots_view_interface *impl,
 | 
			
		||||
		enum roots_view_type type, struct roots_desktop *desktop) {
 | 
			
		||||
	assert(impl->destroy);
 | 
			
		||||
	view->impl = impl;
 | 
			
		||||
	view->type = type;
 | 
			
		||||
	view->desktop = desktop;
 | 
			
		||||
	view->alpha = 1.0f;
 | 
			
		||||
	wl_signal_init(&view->events.unmap);
 | 
			
		||||
	wl_signal_init(&view->events.destroy);
 | 
			
		||||
	wl_list_init(&view->children);
 | 
			
		||||
	return view;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void view_destroy(struct roots_view *view) {
 | 
			
		||||
	if (view == NULL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wl_signal_emit(&view->events.destroy, view);
 | 
			
		||||
 | 
			
		||||
	if (view->wlr_surface != NULL) {
 | 
			
		||||
		view_unmap(view);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Can happen if fullscreened while unmapped, and hasn't been mapped
 | 
			
		||||
	if (view->fullscreen_output != NULL) {
 | 
			
		||||
		view->fullscreen_output->fullscreen_view = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	view->impl->destroy(view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
 | 
			
		||||
| 
						 | 
				
			
			@ -452,29 +468,6 @@ struct roots_subsurface *subsurface_create(struct roots_view *view,
 | 
			
		|||
	return subsurface;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void view_destroy(struct roots_view *view) {
 | 
			
		||||
	if (view == NULL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wl_signal_emit(&view->events.destroy, view);
 | 
			
		||||
 | 
			
		||||
	if (view->wlr_surface != NULL) {
 | 
			
		||||
		view_unmap(view);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Can happen if fullscreened while unmapped, and hasn't been mapped
 | 
			
		||||
	if (view->fullscreen_output != NULL) {
 | 
			
		||||
		view->fullscreen_output->fullscreen_view = NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (view->impl->destroy) {
 | 
			
		||||
		view->impl->destroy(view);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	free(view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void view_handle_new_subsurface(struct wl_listener *listener,
 | 
			
		||||
		void *data) {
 | 
			
		||||
	struct roots_view *view = wl_container_of(listener, view, new_subsurface);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void popup_handle_set_state(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_popup *popup =
 | 
			
		||||
		wl_container_of(listener, popup, set_state);
 | 
			
		||||
	popup_destroy((struct roots_view_child *)popup);
 | 
			
		||||
	view_child_destroy(&popup->view_child);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
 | 
			
		||||
| 
						 | 
				
			
			@ -68,21 +68,21 @@ static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_WL_SHELL_VIEW);
 | 
			
		||||
	struct wlr_wl_shell_surface *surf = view->wl_shell_surface;
 | 
			
		||||
	struct wlr_wl_shell_surface *surf =
 | 
			
		||||
		roots_wl_shell_surface_from_view(view)->wl_shell_surface;
 | 
			
		||||
	wlr_wl_shell_surface_configure(surf, WL_SHELL_SURFACE_RESIZE_NONE, width,
 | 
			
		||||
		height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void close(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_WL_SHELL_VIEW);
 | 
			
		||||
	struct wlr_wl_shell_surface *surf = view->wl_shell_surface;
 | 
			
		||||
	struct wlr_wl_shell_surface *surf =
 | 
			
		||||
		roots_wl_shell_surface_from_view(view)->wl_shell_surface;
 | 
			
		||||
	wl_client_destroy(surf->client);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void destroy(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_WL_SHELL_VIEW);
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface = view->roots_wl_shell_surface;
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		roots_wl_shell_surface_from_view(view);
 | 
			
		||||
	wl_list_remove(&roots_surface->destroy.link);
 | 
			
		||||
	wl_list_remove(&roots_surface->request_move.link);
 | 
			
		||||
	wl_list_remove(&roots_surface->request_resize.link);
 | 
			
		||||
| 
						 | 
				
			
			@ -104,7 +104,7 @@ static const struct roots_view_interface view_impl = {
 | 
			
		|||
static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_move);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_wl_shell_surface_move_event *e = data;
 | 
			
		||||
	struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
 | 
			
		||||
| 
						 | 
				
			
			@ -117,7 +117,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_resize);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_wl_shell_surface_resize_event *e = data;
 | 
			
		||||
	struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
 | 
			
		||||
| 
						 | 
				
			
			@ -131,7 +131,7 @@ static void handle_request_maximize(struct wl_listener *listener,
 | 
			
		|||
		void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_maximize);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	//struct wlr_wl_shell_surface_maximize_event *e = data;
 | 
			
		||||
	view_maximize(view, true);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -140,7 +140,7 @@ static void handle_request_fullscreen(struct wl_listener *listener,
 | 
			
		|||
		void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_fullscreen);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_wl_shell_surface_set_fullscreen_event *e = data;
 | 
			
		||||
	view_set_fullscreen(view, true, e->output);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -148,8 +148,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
 | 
			
		|||
static void handle_set_state(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, set_state);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct wlr_wl_shell_surface *surface = view->wl_shell_surface;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_wl_shell_surface *surface = roots_surface->wl_shell_surface;
 | 
			
		||||
	if (view->maximized &&
 | 
			
		||||
			surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
 | 
			
		||||
		view_maximize(view, false);
 | 
			
		||||
| 
						 | 
				
			
			@ -163,21 +163,21 @@ static void handle_set_state(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_set_title(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, set_state);
 | 
			
		||||
	view_set_title(roots_surface->view,
 | 
			
		||||
			roots_surface->view->wl_shell_surface->title);
 | 
			
		||||
	view_set_title(&roots_surface->view,
 | 
			
		||||
		roots_surface->wl_shell_surface->title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_set_class(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, set_state);
 | 
			
		||||
	view_set_app_id(roots_surface->view,
 | 
			
		||||
			roots_surface->view->wl_shell_surface->class);
 | 
			
		||||
	view_set_app_id(&roots_surface->view,
 | 
			
		||||
		roots_surface->wl_shell_surface->class);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, surface_commit);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_surface *wlr_surface = view->wlr_surface;
 | 
			
		||||
 | 
			
		||||
	view_apply_damage(view);
 | 
			
		||||
| 
						 | 
				
			
			@ -205,13 +205,13 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, new_popup);
 | 
			
		||||
	struct wlr_wl_shell_surface *wlr_wl_shell_surface = data;
 | 
			
		||||
	popup_create(roots_surface->view, wlr_wl_shell_surface);
 | 
			
		||||
	popup_create(&roots_surface->view, wlr_wl_shell_surface);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_wl_shell_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, destroy);
 | 
			
		||||
	view_destroy(roots_surface->view);
 | 
			
		||||
	view_destroy(&roots_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -233,6 +233,12 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
	if (!roots_surface) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	view_init(&roots_surface->view, &view_impl, ROOTS_WL_SHELL_VIEW, desktop);
 | 
			
		||||
	roots_surface->view.box.width = surface->surface->current.width;
 | 
			
		||||
	roots_surface->view.box.height = surface->surface->current.height;
 | 
			
		||||
	roots_surface->wl_shell_surface = surface;
 | 
			
		||||
 | 
			
		||||
	roots_surface->destroy.notify = handle_destroy;
 | 
			
		||||
	wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
 | 
			
		||||
	roots_surface->new_popup.notify = handle_new_popup;
 | 
			
		||||
| 
						 | 
				
			
			@ -259,42 +265,40 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
	roots_surface->surface_commit.notify = handle_surface_commit;
 | 
			
		||||
	wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
 | 
			
		||||
 | 
			
		||||
	struct roots_view *view = view_create(desktop, &view_impl);
 | 
			
		||||
	if (!view) {
 | 
			
		||||
		free(roots_surface);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	view->type = ROOTS_WL_SHELL_VIEW;
 | 
			
		||||
	view->box.width = surface->surface->current.width;
 | 
			
		||||
	view->box.height = surface->surface->current.height;
 | 
			
		||||
	view_map(&roots_surface->view, surface->surface);
 | 
			
		||||
	view_setup(&roots_surface->view);
 | 
			
		||||
 | 
			
		||||
	view->wl_shell_surface = surface;
 | 
			
		||||
	view->roots_wl_shell_surface = roots_surface;
 | 
			
		||||
	roots_surface->view = view;
 | 
			
		||||
 | 
			
		||||
	view_map(view, surface->surface);
 | 
			
		||||
	view_setup(view);
 | 
			
		||||
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
 | 
			
		||||
			view->wl_shell_surface->title ?: "none");
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
 | 
			
		||||
			view->wl_shell_surface->class ?: "none");
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_title(roots_surface->view.toplevel_handle,
 | 
			
		||||
		surface->title ?: "none");
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_app_id(roots_surface->view.toplevel_handle,
 | 
			
		||||
		surface->class ?: "none");
 | 
			
		||||
 | 
			
		||||
	if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
 | 
			
		||||
		// We need to map it relative to the parent
 | 
			
		||||
		bool found = false;
 | 
			
		||||
		struct roots_view *parent;
 | 
			
		||||
		wl_list_for_each(parent, &desktop->views, link) {
 | 
			
		||||
			if (parent->type == ROOTS_WL_SHELL_VIEW &&
 | 
			
		||||
					parent->wl_shell_surface == surface->parent) {
 | 
			
		||||
			if (parent->type != ROOTS_WL_SHELL_VIEW) {
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			struct roots_wl_shell_surface *parent_surf =
 | 
			
		||||
				roots_wl_shell_surface_from_view(parent);
 | 
			
		||||
			if (parent_surf->wl_shell_surface == surface->parent) {
 | 
			
		||||
				found = true;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if (found) {
 | 
			
		||||
			view_move(view,
 | 
			
		||||
			view_move(&roots_surface->view,
 | 
			
		||||
				parent->box.x + surface->transient_state->x,
 | 
			
		||||
				parent->box.y + surface->transient_state->y);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct roots_wl_shell_surface *roots_wl_shell_surface_from_view(
 | 
			
		||||
		struct roots_view *view) {
 | 
			
		||||
	assert(view->impl == &view_impl);
 | 
			
		||||
	return (struct roots_wl_shell_surface *)view;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,7 @@
 | 
			
		|||
#include "rootston/desktop.h"
 | 
			
		||||
#include "rootston/input.h"
 | 
			
		||||
#include "rootston/server.h"
 | 
			
		||||
#include "rootston/view.h"
 | 
			
		||||
 | 
			
		||||
static const struct roots_view_child_interface popup_impl;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -132,31 +133,31 @@ static struct roots_xdg_popup *popup_create(struct roots_view *view,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void get_size(const struct roots_view *view, struct wlr_box *box) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
static void get_size(struct roots_view *view, struct wlr_box *box) {
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
 | 
			
		||||
	struct wlr_box geo_box;
 | 
			
		||||
	wlr_xdg_surface_get_geometry(surface, &geo_box);
 | 
			
		||||
	wlr_xdg_surface_get_geometry(xdg_surface, &geo_box);
 | 
			
		||||
	box->width = geo_box.width;
 | 
			
		||||
	box->height = geo_box.height;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void activate(struct roots_view *view, bool active) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		wlr_xdg_toplevel_set_activated(surface, active);
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
	if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		wlr_xdg_toplevel_set_activated(xdg_surface, active);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void apply_size_constraints(struct wlr_xdg_surface *surface,
 | 
			
		||||
static void apply_size_constraints(struct wlr_xdg_surface *xdg_surface,
 | 
			
		||||
		uint32_t width, uint32_t height, uint32_t *dest_width,
 | 
			
		||||
		uint32_t *dest_height) {
 | 
			
		||||
	*dest_width = width;
 | 
			
		||||
	*dest_height = height;
 | 
			
		||||
 | 
			
		||||
	struct wlr_xdg_toplevel_state *state = &surface->toplevel->current;
 | 
			
		||||
	struct wlr_xdg_toplevel_state *state = &xdg_surface->toplevel->current;
 | 
			
		||||
	if (width < state->min_width) {
 | 
			
		||||
		*dest_width = state->min_width;
 | 
			
		||||
	} else if (state->max_width > 0 &&
 | 
			
		||||
| 
						 | 
				
			
			@ -172,26 +173,26 @@ static void apply_size_constraints(struct wlr_xdg_surface *surface,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
	if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	uint32_t constrained_width, constrained_height;
 | 
			
		||||
	apply_size_constraints(surface, width, height, &constrained_width,
 | 
			
		||||
	apply_size_constraints(xdg_surface, width, height, &constrained_width,
 | 
			
		||||
		&constrained_height);
 | 
			
		||||
 | 
			
		||||
	wlr_xdg_toplevel_set_size(surface, constrained_width,
 | 
			
		||||
	wlr_xdg_toplevel_set_size(xdg_surface, constrained_width,
 | 
			
		||||
		constrained_height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		||||
		uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct roots_xdg_surface *roots_surface = view->roots_xdg_surface;
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
	struct roots_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view);
 | 
			
		||||
	struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->xdg_surface;
 | 
			
		||||
	if (wlr_xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +200,7 @@ static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		|||
	bool update_y = y != view->box.y;
 | 
			
		||||
 | 
			
		||||
	uint32_t constrained_width, constrained_height;
 | 
			
		||||
	apply_size_constraints(surface, width, height, &constrained_width,
 | 
			
		||||
	apply_size_constraints(wlr_xdg_surface, width, height, &constrained_width,
 | 
			
		||||
		&constrained_height);
 | 
			
		||||
 | 
			
		||||
	if (update_x) {
 | 
			
		||||
| 
						 | 
				
			
			@ -216,48 +217,48 @@ static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		|||
	view->pending_move_resize.width = constrained_width;
 | 
			
		||||
	view->pending_move_resize.height = constrained_height;
 | 
			
		||||
 | 
			
		||||
	uint32_t serial = wlr_xdg_toplevel_set_size(surface, constrained_width,
 | 
			
		||||
		constrained_height);
 | 
			
		||||
	uint32_t serial = wlr_xdg_toplevel_set_size(wlr_xdg_surface,
 | 
			
		||||
		constrained_width, constrained_height);
 | 
			
		||||
	if (serial > 0) {
 | 
			
		||||
		roots_surface->pending_move_resize_configure_serial = serial;
 | 
			
		||||
	} else if (roots_surface->pending_move_resize_configure_serial == 0) {
 | 
			
		||||
		xdg_surface->pending_move_resize_configure_serial = serial;
 | 
			
		||||
	} else if (xdg_surface->pending_move_resize_configure_serial == 0) {
 | 
			
		||||
		view_update_position(view, x, y);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void maximize(struct roots_view *view, bool maximized) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
	if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_xdg_toplevel_set_maximized(surface, maximized);
 | 
			
		||||
	wlr_xdg_toplevel_set_maximized(xdg_surface, maximized);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
	if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
 | 
			
		||||
	wlr_xdg_toplevel_set_fullscreen(xdg_surface, fullscreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void close(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	struct wlr_xdg_surface *xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view)->xdg_surface;
 | 
			
		||||
	struct wlr_xdg_popup *popup = NULL;
 | 
			
		||||
	wl_list_for_each(popup, &surface->popups, link) {
 | 
			
		||||
	wl_list_for_each(popup, &xdg_surface->popups, link) {
 | 
			
		||||
		wlr_xdg_popup_destroy(popup->base);
 | 
			
		||||
	}
 | 
			
		||||
	wlr_xdg_toplevel_send_close(surface);
 | 
			
		||||
	wlr_xdg_toplevel_send_close(xdg_surface);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void destroy(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_VIEW);
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface = view->roots_xdg_surface;
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		roots_xdg_surface_from_view(view);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->surface_commit.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->destroy.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->new_popup.link);
 | 
			
		||||
| 
						 | 
				
			
			@ -269,7 +270,7 @@ static void destroy(struct roots_view *view) {
 | 
			
		|||
	wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->set_title.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->set_app_id.link);
 | 
			
		||||
	roots_xdg_surface->view->xdg_surface->data = NULL;
 | 
			
		||||
	roots_xdg_surface->xdg_surface->data = NULL;
 | 
			
		||||
	free(roots_xdg_surface);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +287,7 @@ static const struct roots_view_interface view_impl = {
 | 
			
		|||
static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_move);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_xdg_toplevel_move_event *e = data;
 | 
			
		||||
	struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +301,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_resize);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_xdg_toplevel_resize_event *e = data;
 | 
			
		||||
	// TODO verify event serial
 | 
			
		||||
| 
						 | 
				
			
			@ -315,8 +316,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_maximize);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = roots_xdg_surface->xdg_surface;
 | 
			
		||||
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -329,8 +330,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
 | 
			
		|||
		void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_fullscreen);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = roots_xdg_surface->xdg_surface;
 | 
			
		||||
	struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
 | 
			
		||||
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
 | 
			
		||||
| 
						 | 
				
			
			@ -344,23 +345,23 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, set_title);
 | 
			
		||||
 | 
			
		||||
	view_set_title(roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->view->xdg_surface->toplevel->title);
 | 
			
		||||
	view_set_title(&roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->xdg_surface->toplevel->title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_set_app_id(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, set_app_id);
 | 
			
		||||
 | 
			
		||||
	view_set_app_id(roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->view->xdg_surface->toplevel->app_id);
 | 
			
		||||
	view_set_app_id(&roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->xdg_surface->toplevel->app_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, surface_commit);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = view->xdg_surface;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface *surface = roots_surface->xdg_surface;
 | 
			
		||||
 | 
			
		||||
	if (!surface->mapped) {
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -397,38 +398,38 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, new_popup);
 | 
			
		||||
	struct wlr_xdg_popup *wlr_popup = data;
 | 
			
		||||
	popup_create(roots_xdg_surface->view, wlr_popup);
 | 
			
		||||
	popup_create(&roots_xdg_surface->view, wlr_popup);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_map(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, map);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_box box;
 | 
			
		||||
	get_size(view, &box);
 | 
			
		||||
	view->box.width = box.width;
 | 
			
		||||
	view->box.height = box.height;
 | 
			
		||||
 | 
			
		||||
	view_map(view, view->xdg_surface->surface);
 | 
			
		||||
	view_map(view, roots_xdg_surface->xdg_surface->surface);
 | 
			
		||||
	view_setup(view);
 | 
			
		||||
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
 | 
			
		||||
			view->xdg_surface->toplevel->title ?: "none");
 | 
			
		||||
			roots_xdg_surface->xdg_surface->toplevel->title ?: "none");
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
 | 
			
		||||
			view->xdg_surface->toplevel->app_id ?: "none");
 | 
			
		||||
			roots_xdg_surface->xdg_surface->toplevel->app_id ?: "none");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_unmap(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, unmap);
 | 
			
		||||
	view_unmap(roots_xdg_surface->view);
 | 
			
		||||
	view_unmap(&roots_xdg_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, destroy);
 | 
			
		||||
	view_destroy(roots_xdg_surface->view);
 | 
			
		||||
	view_destroy(&roots_xdg_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -452,6 +453,11 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
	if (!roots_surface) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	view_init(&roots_surface->view, &view_impl, ROOTS_XDG_SHELL_VIEW, desktop);
 | 
			
		||||
	roots_surface->xdg_surface = surface;
 | 
			
		||||
	surface->data = roots_surface;
 | 
			
		||||
 | 
			
		||||
	roots_surface->surface_commit.notify = handle_surface_commit;
 | 
			
		||||
	wl_signal_add(&surface->surface->events.commit,
 | 
			
		||||
		&roots_surface->surface_commit);
 | 
			
		||||
| 
						 | 
				
			
			@ -480,36 +486,16 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
			&roots_surface->set_app_id);
 | 
			
		||||
	roots_surface->new_popup.notify = handle_new_popup;
 | 
			
		||||
	wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
 | 
			
		||||
	surface->data = roots_surface;
 | 
			
		||||
 | 
			
		||||
	struct roots_view *view = view_create(desktop, &view_impl);
 | 
			
		||||
	if (!view) {
 | 
			
		||||
		free(roots_surface);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	view->type = ROOTS_XDG_SHELL_VIEW;
 | 
			
		||||
 | 
			
		||||
	view->xdg_surface = surface;
 | 
			
		||||
	view->roots_xdg_surface = roots_surface;
 | 
			
		||||
	roots_surface->view = view;
 | 
			
		||||
 | 
			
		||||
	if (surface->toplevel->client_pending.maximized) {
 | 
			
		||||
		view_maximize(view, true);
 | 
			
		||||
	}
 | 
			
		||||
	if (surface->toplevel->client_pending.fullscreen) {
 | 
			
		||||
		view_set_fullscreen(view, true, NULL);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void decoration_handle_destroy(struct wl_listener *listener,
 | 
			
		||||
		void *data) {
 | 
			
		||||
	struct roots_xdg_toplevel_decoration *decoration =
 | 
			
		||||
		wl_container_of(listener, decoration, destroy);
 | 
			
		||||
 | 
			
		||||
	decoration->surface->xdg_toplevel_decoration = NULL;
 | 
			
		||||
	view_update_decorated(decoration->surface->view, false);
 | 
			
		||||
	view_update_decorated(&decoration->surface->view, false);
 | 
			
		||||
	wl_list_remove(&decoration->destroy.link);
 | 
			
		||||
	wl_list_remove(&decoration->request_mode.link);
 | 
			
		||||
	wl_list_remove(&decoration->surface_commit.link);
 | 
			
		||||
| 
						 | 
				
			
			@ -536,7 +522,7 @@ static void decoration_handle_surface_commit(struct wl_listener *listener,
 | 
			
		|||
 | 
			
		||||
	bool decorated = decoration->wlr_decoration->current_mode ==
 | 
			
		||||
		WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
 | 
			
		||||
	view_update_decorated(decoration->surface->view, decorated);
 | 
			
		||||
	view_update_decorated(&decoration->surface->view, decorated);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -546,7 +532,7 @@ void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
 | 
			
		|||
 | 
			
		||||
	struct roots_xdg_surface *xdg_surface = wlr_decoration->surface->data;
 | 
			
		||||
	assert(xdg_surface != NULL);
 | 
			
		||||
	struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->view->xdg_surface;
 | 
			
		||||
	struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->xdg_surface;
 | 
			
		||||
 | 
			
		||||
	struct roots_xdg_toplevel_decoration *decoration =
 | 
			
		||||
		calloc(1, sizeof(struct roots_xdg_toplevel_decoration));
 | 
			
		||||
| 
						 | 
				
			
			@ -568,3 +554,8 @@ void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
 | 
			
		|||
 | 
			
		||||
	decoration_handle_request_mode(&decoration->request_mode, wlr_decoration);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface *roots_xdg_surface_from_view(struct roots_view *view) {
 | 
			
		||||
	assert(view->impl == &view_impl);
 | 
			
		||||
	return (struct roots_xdg_surface *)view;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -132,9 +132,9 @@ static struct roots_xdg_popup_v6 *popup_create(struct roots_view *view,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void get_size(const struct roots_view *view, struct wlr_box *box) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
static void get_size(struct roots_view *view, struct wlr_box *box) {
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
 | 
			
		||||
	struct wlr_box geo_box;
 | 
			
		||||
	wlr_xdg_surface_v6_get_geometry(surface, &geo_box);
 | 
			
		||||
| 
						 | 
				
			
			@ -143,8 +143,8 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void activate(struct roots_view *view, bool active) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
	if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		wlr_xdg_toplevel_v6_set_activated(surface, active);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -172,8 +172,8 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -188,9 +188,9 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		|||
 | 
			
		||||
static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		||||
		uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_surface = view->roots_xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = roots_surface->xdg_surface_v6;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -226,8 +226,8 @@ static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void maximize(struct roots_view *view, bool maximized) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -236,8 +236,8 @@ static void maximize(struct roots_view *view, bool maximized) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -246,8 +246,8 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void close(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_popup_v6 *popup = NULL;
 | 
			
		||||
	wl_list_for_each(popup, &surface->popups, link) {
 | 
			
		||||
		wlr_xdg_surface_v6_send_close(popup->base);
 | 
			
		||||
| 
						 | 
				
			
			@ -256,8 +256,8 @@ static void close(struct roots_view *view) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void destroy(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface = view->roots_xdg_surface_v6;
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		roots_xdg_surface_v6_from_view(view);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->surface_commit.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->destroy.link);
 | 
			
		||||
	wl_list_remove(&roots_xdg_surface->new_popup.link);
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +285,7 @@ static const struct roots_view_interface view_impl = {
 | 
			
		|||
static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_move);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_xdg_toplevel_v6_move_event *e = data;
 | 
			
		||||
	struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
 | 
			
		||||
| 
						 | 
				
			
			@ -299,7 +299,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_resize);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct roots_input *input = view->desktop->server->input;
 | 
			
		||||
	struct wlr_xdg_toplevel_v6_resize_event *e = data;
 | 
			
		||||
	// TODO verify event serial
 | 
			
		||||
| 
						 | 
				
			
			@ -314,8 +314,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_maximize);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = roots_xdg_surface->xdg_surface_v6;
 | 
			
		||||
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -328,8 +328,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
 | 
			
		|||
		void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, request_fullscreen);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = roots_xdg_surface->xdg_surface_v6;
 | 
			
		||||
	struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data;
 | 
			
		||||
 | 
			
		||||
	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
 | 
			
		||||
| 
						 | 
				
			
			@ -343,23 +343,23 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, set_title);
 | 
			
		||||
 | 
			
		||||
	view_set_title(roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->view->xdg_surface_v6->toplevel->title);
 | 
			
		||||
	view_set_title(&roots_xdg_surface->view,
 | 
			
		||||
		roots_xdg_surface->xdg_surface_v6->toplevel->title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_set_app_id(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, set_app_id);
 | 
			
		||||
 | 
			
		||||
	view_set_app_id(roots_xdg_surface->view,
 | 
			
		||||
			roots_xdg_surface->view->xdg_surface_v6->toplevel->app_id);
 | 
			
		||||
	view_set_app_id(&roots_xdg_surface->view,
 | 
			
		||||
		roots_xdg_surface->xdg_surface_v6->toplevel->app_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, surface_commit);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_xdg_surface_v6 *surface = roots_surface->xdg_surface_v6;
 | 
			
		||||
 | 
			
		||||
	if (!surface->mapped) {
 | 
			
		||||
		return;
 | 
			
		||||
| 
						 | 
				
			
			@ -396,38 +396,38 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, new_popup);
 | 
			
		||||
	struct wlr_xdg_popup_v6 *wlr_popup = data;
 | 
			
		||||
	popup_create(roots_xdg_surface->view, wlr_popup);
 | 
			
		||||
	popup_create(&roots_xdg_surface->view, wlr_popup);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_map(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, map);
 | 
			
		||||
	struct roots_view *view = roots_xdg_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_xdg_surface->view;
 | 
			
		||||
 | 
			
		||||
	struct wlr_box box;
 | 
			
		||||
	get_size(view, &box);
 | 
			
		||||
	view->box.width = box.width;
 | 
			
		||||
	view->box.height = box.height;
 | 
			
		||||
 | 
			
		||||
	view_map(view, view->xdg_surface_v6->surface);
 | 
			
		||||
	view_map(view, roots_xdg_surface->xdg_surface_v6->surface);
 | 
			
		||||
	view_setup(view);
 | 
			
		||||
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
 | 
			
		||||
			view->xdg_surface_v6->toplevel->title ?: "none");
 | 
			
		||||
		roots_xdg_surface->xdg_surface_v6->toplevel->title ?: "none");
 | 
			
		||||
	wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
 | 
			
		||||
			view->xdg_surface_v6->toplevel->app_id ?: "none");
 | 
			
		||||
		roots_xdg_surface->xdg_surface_v6->toplevel->app_id ?: "none");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_unmap(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, unmap);
 | 
			
		||||
	view_unmap(roots_xdg_surface->view);
 | 
			
		||||
	view_unmap(&roots_xdg_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xdg_surface_v6 *roots_xdg_surface =
 | 
			
		||||
		wl_container_of(listener, roots_xdg_surface, destroy);
 | 
			
		||||
	view_destroy(roots_xdg_surface->view);
 | 
			
		||||
	view_destroy(&roots_xdg_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
 | 
			
		||||
| 
						 | 
				
			
			@ -451,6 +451,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
	if (!roots_surface) {
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	view_init(&roots_surface->view, &view_impl, ROOTS_XDG_SHELL_V6_VIEW, desktop);
 | 
			
		||||
	roots_surface->xdg_surface_v6 = surface;
 | 
			
		||||
 | 
			
		||||
	roots_surface->surface_commit.notify = handle_surface_commit;
 | 
			
		||||
	wl_signal_add(&surface->surface->events.commit,
 | 
			
		||||
		&roots_surface->surface_commit);
 | 
			
		||||
| 
						 | 
				
			
			@ -480,22 +484,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
			&roots_surface->set_app_id);
 | 
			
		||||
	roots_surface->new_popup.notify = handle_new_popup;
 | 
			
		||||
	wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
 | 
			
		||||
 | 
			
		||||
	struct roots_view *view = view_create(desktop, &view_impl);
 | 
			
		||||
	if (!view) {
 | 
			
		||||
		free(roots_surface);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	view->type = ROOTS_XDG_SHELL_V6_VIEW;
 | 
			
		||||
 | 
			
		||||
	view->xdg_surface_v6 = surface;
 | 
			
		||||
	view->roots_xdg_surface_v6 = roots_surface;
 | 
			
		||||
	roots_surface->view = view;
 | 
			
		||||
 | 
			
		||||
	if (surface->toplevel->client_pending.maximized) {
 | 
			
		||||
		view_maximize(view, true);
 | 
			
		||||
	}
 | 
			
		||||
	if (surface->toplevel->client_pending.fullscreen) {
 | 
			
		||||
		view_set_fullscreen(view, true, NULL);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct roots_xdg_surface_v6 *roots_xdg_surface_v6_from_view(
 | 
			
		||||
		struct roots_view *view) {
 | 
			
		||||
	assert(view->impl == &view_impl);
 | 
			
		||||
	return (struct roots_xdg_surface_v6 *)view;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,13 +11,14 @@
 | 
			
		|||
#include "rootston/server.h"
 | 
			
		||||
 | 
			
		||||
static void activate(struct roots_view *view, bool active) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	wlr_xwayland_surface_activate(view->xwayland_surface, active);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
	wlr_xwayland_surface_activate(xwayland_surface, active);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void move(struct roots_view *view, double x, double y) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
	view_update_position(view, x, y);
 | 
			
		||||
	wlr_xwayland_surface_configure(xwayland_surface, x, y,
 | 
			
		||||
		xwayland_surface->width, xwayland_surface->height);
 | 
			
		||||
| 
						 | 
				
			
			@ -48,8 +49,8 @@ static void apply_size_constraints(
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
 | 
			
		||||
	uint32_t constrained_width, constrained_height;
 | 
			
		||||
	apply_size_constraints(xwayland_surface, width, height, &constrained_width,
 | 
			
		||||
| 
						 | 
				
			
			@ -61,8 +62,8 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
 | 
			
		|||
 | 
			
		||||
static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		||||
		uint32_t width, uint32_t height) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
 | 
			
		||||
	bool update_x = x != view->box.x;
 | 
			
		||||
	bool update_y = y != view->box.y;
 | 
			
		||||
| 
						 | 
				
			
			@ -90,25 +91,26 @@ static void move_resize(struct roots_view *view, double x, double y,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void close(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	wlr_xwayland_surface_close(view->xwayland_surface);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
	wlr_xwayland_surface_close(xwayland_surface);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void maximize(struct roots_view *view, bool maximized) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
 | 
			
		||||
	wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
	wlr_xwayland_surface_set_maximized(xwayland_surface, maximized);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
 | 
			
		||||
	wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view)->xwayland_surface;
 | 
			
		||||
	wlr_xwayland_surface_set_fullscreen(xwayland_surface, fullscreen);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void destroy(struct roots_view *view) {
 | 
			
		||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface = view->roots_xwayland_surface;
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		roots_xwayland_surface_from_view(view);
 | 
			
		||||
	wl_list_remove(&roots_surface->destroy.link);
 | 
			
		||||
	wl_list_remove(&roots_surface->request_configure.link);
 | 
			
		||||
	wl_list_remove(&roots_surface->request_move.link);
 | 
			
		||||
| 
						 | 
				
			
			@ -135,17 +137,17 @@ static const struct roots_view_interface view_impl = {
 | 
			
		|||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, destroy);
 | 
			
		||||
	view_destroy(roots_surface->view);
 | 
			
		||||
	view_destroy(&roots_surface->view);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_request_configure(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_configure);
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_surface->view->xwayland_surface;
 | 
			
		||||
		roots_surface->xwayland_surface;
 | 
			
		||||
	struct wlr_xwayland_surface_configure_event *event = data;
 | 
			
		||||
 | 
			
		||||
	view_update_position(roots_surface->view, event->x, event->y);
 | 
			
		||||
	view_update_position(&roots_surface->view, event->x, event->y);
 | 
			
		||||
 | 
			
		||||
	wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
 | 
			
		||||
		event->width, event->height);
 | 
			
		||||
| 
						 | 
				
			
			@ -167,7 +169,7 @@ static struct roots_seat *guess_seat_for_view(struct roots_view *view) {
 | 
			
		|||
static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_move);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct roots_seat *seat = guess_seat_for_view(view);
 | 
			
		||||
 | 
			
		||||
	if (!seat || seat->cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +182,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_resize);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct roots_seat *seat = guess_seat_for_view(view);
 | 
			
		||||
	struct wlr_xwayland_resize_event *e = data;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -193,8 +195,9 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_maximize);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_surface->xwayland_surface;
 | 
			
		||||
 | 
			
		||||
	bool maximized = xwayland_surface->maximized_vert &&
 | 
			
		||||
		xwayland_surface->maximized_horz;
 | 
			
		||||
| 
						 | 
				
			
			@ -205,8 +208,9 @@ static void handle_request_fullscreen(struct wl_listener *listener,
 | 
			
		|||
		void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, request_fullscreen);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_xwayland_surface *xwayland_surface =
 | 
			
		||||
		roots_surface->xwayland_surface;
 | 
			
		||||
 | 
			
		||||
	view_set_fullscreen(view, xwayland_surface->fullscreen, NULL);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -215,22 +219,22 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, set_title);
 | 
			
		||||
 | 
			
		||||
	view_set_title(roots_surface->view,
 | 
			
		||||
			roots_surface->view->xwayland_surface->title);
 | 
			
		||||
	view_set_title(&roots_surface->view,
 | 
			
		||||
		roots_surface->xwayland_surface->title);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_set_class(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, set_class);
 | 
			
		||||
 | 
			
		||||
	view_set_app_id(roots_surface->view,
 | 
			
		||||
			roots_surface->view->xwayland_surface->class);
 | 
			
		||||
	view_set_app_id(&roots_surface->view,
 | 
			
		||||
		roots_surface->xwayland_surface->class);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, surface_commit);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
	struct wlr_surface *wlr_surface = view->wlr_surface;
 | 
			
		||||
 | 
			
		||||
	view_apply_damage(view);
 | 
			
		||||
| 
						 | 
				
			
			@ -258,7 +262,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
 | 
			
		|||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, map);
 | 
			
		||||
	struct wlr_xwayland_surface *surface = data;
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
 | 
			
		||||
	view->box.x = surface->x;
 | 
			
		||||
	view->box.y = surface->y;
 | 
			
		||||
| 
						 | 
				
			
			@ -281,9 +285,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
 | 
			
		|||
		view_setup(view);
 | 
			
		||||
 | 
			
		||||
		wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
 | 
			
		||||
				view->xwayland_surface->title ?: "none");
 | 
			
		||||
			roots_surface->xwayland_surface->title ?: "none");
 | 
			
		||||
		wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
 | 
			
		||||
				view->xwayland_surface->class ?: "none");
 | 
			
		||||
			roots_surface->xwayland_surface->class ?: "none");
 | 
			
		||||
	} else {
 | 
			
		||||
		view_initial_focus(view);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -292,7 +296,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
 | 
			
		|||
static void handle_unmap(struct wl_listener *listener, void *data) {
 | 
			
		||||
	struct roots_xwayland_surface *roots_surface =
 | 
			
		||||
		wl_container_of(listener, roots_surface, unmap);
 | 
			
		||||
	struct roots_view *view = roots_surface->view;
 | 
			
		||||
	struct roots_view *view = &roots_surface->view;
 | 
			
		||||
 | 
			
		||||
	wl_list_remove(&roots_surface->surface_commit.link);
 | 
			
		||||
	view_unmap(view);
 | 
			
		||||
| 
						 | 
				
			
			@ -313,6 +317,11 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	view_init(&roots_surface->view, &view_impl, ROOTS_XWAYLAND_VIEW, desktop);
 | 
			
		||||
	roots_surface->view.box.x = surface->x;
 | 
			
		||||
	roots_surface->view.box.y = surface->y;
 | 
			
		||||
	roots_surface->xwayland_surface = surface;
 | 
			
		||||
 | 
			
		||||
	roots_surface->destroy.notify = handle_destroy;
 | 
			
		||||
	wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
 | 
			
		||||
	roots_surface->request_configure.notify = handle_request_configure;
 | 
			
		||||
| 
						 | 
				
			
			@ -338,17 +347,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
 | 
			
		|||
	roots_surface->set_class.notify = handle_set_class;
 | 
			
		||||
	wl_signal_add(&surface->events.set_class,
 | 
			
		||||
			&roots_surface->set_class);
 | 
			
		||||
 | 
			
		||||
	struct roots_view *view = view_create(desktop, &view_impl);
 | 
			
		||||
	if (view == NULL) {
 | 
			
		||||
		free(roots_surface);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	view->type = ROOTS_XWAYLAND_VIEW;
 | 
			
		||||
	view->box.x = surface->x;
 | 
			
		||||
	view->box.y = surface->y;
 | 
			
		||||
 | 
			
		||||
	view->xwayland_surface = surface;
 | 
			
		||||
	view->roots_xwayland_surface = roots_surface;
 | 
			
		||||
	roots_surface->view = view;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct roots_xwayland_surface *roots_xwayland_surface_from_view(
 | 
			
		||||
		struct roots_view *view) {
 | 
			
		||||
	assert(view->impl == &view_impl);
 | 
			
		||||
	return (struct roots_xwayland_surface *)view;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue