|  |  | @ -12,11 +12,11 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void get_size(const struct roots_view *view, struct wlr_box *box) { |  |  |  | static void get_size(const struct roots_view *view, struct wlr_box *box) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); |  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if (surf->geometry->width > 0 && surf->geometry->height > 0) { |  |  |  | 	if (surface->geometry->width > 0 && surface->geometry->height > 0) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		box->width = surf->geometry->width; |  |  |  | 		box->width = surface->geometry->width; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		box->height = surf->geometry->height; |  |  |  | 		box->height = surface->geometry->height; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} else { |  |  |  | 	} else { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		box->width = view->wlr_surface->current->width; |  |  |  | 		box->width = view->wlr_surface->current->width; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		box->height = view->wlr_surface->current->height; |  |  |  | 		box->height = view->wlr_surface->current->height; | 
			
		
	
	
		
		
			
				
					|  |  | @ -25,20 +25,19 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void activate(struct roots_view *view, bool active) { |  |  |  | static void activate(struct roots_view *view, bool active) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); |  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { |  |  |  | 	if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		wlr_xdg_toplevel_v6_set_activated(surf, active); |  |  |  | 		wlr_xdg_toplevel_v6_set_activated(surface, active); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf, |  |  |  | static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		uint32_t width, uint32_t height, uint32_t *dest_width, |  |  |  | 		uint32_t width, uint32_t height, uint32_t *dest_width, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		uint32_t *dest_height) { |  |  |  | 		uint32_t *dest_height) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	*dest_width = width; |  |  |  | 	*dest_width = width; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	*dest_height = height; |  |  |  | 	*dest_height = height; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_toplevel_v6_state *state = |  |  |  | 	struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		&surf->toplevel_state->current; |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	if (width < state->min_width) { |  |  |  | 	if (width < state->min_width) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		*dest_width = state->min_width; |  |  |  | 		*dest_width = state->min_width; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} else if (state->max_width > 0 && |  |  |  | 	} else if (state->max_width > 0 && | 
			
		
	
	
		
		
			
				
					|  |  | @ -55,39 +54,57 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surf, | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void resize(struct roots_view *view, uint32_t width, uint32_t height) { |  |  |  | static void resize(struct roots_view *view, uint32_t width, uint32_t height) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); |  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { |  |  |  | 	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 		return; |  |  |  | 		return; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	uint32_t contrained_width, contrained_height; |  |  |  | 	uint32_t constrained_width, constrained_height; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	apply_size_constraints(surf, width, height, &contrained_width, |  |  |  | 	apply_size_constraints(surface, width, height, &constrained_width, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		&contrained_height); |  |  |  | 		&constrained_height); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); |  |  |  | 	wlr_xdg_toplevel_v6_set_size(surface, constrained_width, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		constrained_height); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void move_resize(struct roots_view *view, double x, double y, |  |  |  | static void move_resize(struct roots_view *view, double x, double y, | 
			
		
	
		
		
			
				
					
					|  |  |  | 		uint32_t width, uint32_t height) { |  |  |  | 		uint32_t width, uint32_t height) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); |  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; |  |  |  | 	struct roots_xdg_surface_v6 *roots_surface = view->roots_xdg_surface_v6; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if (surf->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		return; |  |  |  | 		return; | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	uint32_t contrained_width, contrained_height; |  |  |  | 	bool update_x = x != view->x; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	apply_size_constraints(surf, width, height, &contrained_width, |  |  |  | 	bool update_y = y != view->y; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		&contrained_height); |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	x = x + width - contrained_width; |  |  |  | 	uint32_t constrained_width, constrained_height; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	y = y + height - contrained_height; |  |  |  | 	apply_size_constraints(surface, width, height, &constrained_width, | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		&constrained_height); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	// TODO: we should wait for an ack_configure event before updating the
 |  |  |  | 	if (update_x) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	// position
 |  |  |  | 		x = x + width - constrained_width; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	if (update_y) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		y = y + height - constrained_height; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.update_x = update_x; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.update_y = update_y; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.x = x; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.y = y; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.width = constrained_width; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	view->pending_move_resize.height = constrained_height; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	uint32_t serial = wlr_xdg_toplevel_v6_set_size(surface, constrained_width, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		constrained_height); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	if (serial > 0) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		roots_surface->pending_move_resize_configure_serial = serial; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} else { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		view->x = x; |  |  |  | 		view->x = x; | 
			
		
	
		
		
			
				
					
					|  |  |  | 		view->y = y; |  |  |  | 		view->y = y; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 	} | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height); |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void maximize(struct roots_view *view, bool maximized) { |  |  |  | static void maximize(struct roots_view *view, bool maximized) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -102,9 +119,9 @@ static void maximize(struct roots_view *view, bool maximized) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void close(struct roots_view *view) { |  |  |  | static void close(struct roots_view *view) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); |  |  |  | 	assert(view->type == ROOTS_XDG_SHELL_V6_VIEW); | 
			
		
	
		
		
			
				
					
					|  |  |  | 	struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6; |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { |  |  |  | 	if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		wlr_xdg_toplevel_v6_send_close(surf); |  |  |  | 		wlr_xdg_toplevel_v6_send_close(surface); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -151,11 +168,30 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void handle_commit(struct wl_listener *listener, void *data) { |  |  |  | static void handle_commit(struct wl_listener *listener, void *data) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	//struct roots_xdg_surface_v6 *roots_xdg_surface =
 |  |  |  | 	struct roots_xdg_surface_v6 *roots_surface = | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//	wl_container_of(listener, roots_xdg_surface, commit);
 |  |  |  | 		wl_container_of(listener, roots_surface, commit); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//struct roots_view *view = roots_xdg_surface->view;
 |  |  |  | 	struct roots_view *view = roots_surface->view; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	//struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
 |  |  |  | 	struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	// TODO
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	uint32_t pending_serial = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		roots_surface->pending_move_resize_configure_serial; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	if (pending_serial > 0 && pending_serial >= surface->configure_serial) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		struct wlr_box size; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		get_size(view, &size); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (view->pending_move_resize.update_x) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			view->x = view->pending_move_resize.x + | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				view->pending_move_resize.width - size.width; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (view->pending_move_resize.update_y) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			view->y = view->pending_move_resize.y + | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				view->pending_move_resize.height - size.height; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if (pending_serial == surface->configure_serial) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			roots_surface->pending_move_resize_configure_serial = 0; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | static void handle_destroy(struct wl_listener *listener, void *data) { |  |  |  | static void handle_destroy(struct wl_listener *listener, void *data) { | 
			
		
	
	
		
		
			
				
					|  |  | 
 |