mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	rootston: damage views when moved
This commit is contained in:
		
							parent
							
								
									5089f2d9fb
								
							
						
					
					
						commit
						01bcc2ab01
					
				
					 7 changed files with 52 additions and 33 deletions
				
			
		| 
						 | 
					@ -62,12 +62,12 @@ struct roots_output *desktop_output_from_wlr_output(
 | 
				
			||||||
	struct roots_desktop *desktop, struct wlr_output *output);
 | 
						struct roots_desktop *desktop, struct wlr_output *output);
 | 
				
			||||||
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
 | 
					struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
 | 
				
			||||||
	double ly, struct wlr_surface **surface, double *sx, double *sy);
 | 
						double ly, struct wlr_surface **surface, double *sx, double *sy);
 | 
				
			||||||
void desktop_damage_surface(struct roots_desktop *desktop,
 | 
					 | 
				
			||||||
	struct wlr_surface *surface, double lx, double ly);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_init(struct roots_view *view, struct roots_desktop *desktop);
 | 
					void view_init(struct roots_view *view, struct roots_desktop *desktop);
 | 
				
			||||||
void view_destroy(struct roots_view *view);
 | 
					void view_destroy(struct roots_view *view);
 | 
				
			||||||
void view_activate(struct roots_view *view, bool activate);
 | 
					void view_activate(struct roots_view *view, bool activate);
 | 
				
			||||||
 | 
					void view_damage(struct roots_view *view);
 | 
				
			||||||
 | 
					void view_update_position(struct roots_view *view, double x, double y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
 | 
					void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
 | 
				
			||||||
void handle_wl_shell_surface(struct wl_listener *listener, void *data);
 | 
					void handle_wl_shell_surface(struct wl_listener *listener, void *data);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,6 @@ struct roots_output {
 | 
				
			||||||
void output_add_notify(struct wl_listener *listener, void *data);
 | 
					void output_add_notify(struct wl_listener *listener, void *data);
 | 
				
			||||||
void output_remove_notify(struct wl_listener *listener, void *data);
 | 
					void output_remove_notify(struct wl_listener *listener, void *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_damage_surface(struct roots_output *output,
 | 
					void output_damage_view(struct roots_output *output, struct roots_view *view);
 | 
				
			||||||
	struct wlr_surface *surface, double lx, double ly);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,8 +61,7 @@ void view_move(struct roots_view *view, double x, double y) {
 | 
				
			||||||
	if (view->move) {
 | 
						if (view->move) {
 | 
				
			||||||
		view->move(view, x, y);
 | 
							view->move(view, x, y);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		view->x = x;
 | 
							view_update_position(view, x, y);
 | 
				
			||||||
		view->y = y;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	view_update_output(view, &before);
 | 
						view_update_output(view, &before);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -268,6 +267,7 @@ void view_destroy(struct roots_view *view) {
 | 
				
			||||||
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
 | 
					void view_init(struct roots_view *view, struct roots_desktop *desktop) {
 | 
				
			||||||
	view->desktop = desktop;
 | 
						view->desktop = desktop;
 | 
				
			||||||
	wl_signal_init(&view->events.destroy);
 | 
						wl_signal_init(&view->events.destroy);
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void view_setup(struct roots_view *view) {
 | 
					void view_setup(struct roots_view *view) {
 | 
				
			||||||
| 
						 | 
					@ -282,6 +282,20 @@ void view_setup(struct roots_view *view) {
 | 
				
			||||||
	view_update_output(view, NULL);
 | 
						view_update_output(view, NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_damage(struct roots_view *view) {
 | 
				
			||||||
 | 
						struct roots_output *output;
 | 
				
			||||||
 | 
						wl_list_for_each(output, &view->desktop->outputs, link) {
 | 
				
			||||||
 | 
							output_damage_view(output, view);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void view_update_position(struct roots_view *view, double x, double y) {
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
 | 
						view->x = x;
 | 
				
			||||||
 | 
						view->y = y;
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static bool view_at(struct roots_view *view, double lx, double ly,
 | 
					static bool view_at(struct roots_view *view, double lx, double ly,
 | 
				
			||||||
		struct wlr_surface **surface, double *sx, double *sy) {
 | 
							struct wlr_surface **surface, double *sx, double *sy) {
 | 
				
			||||||
	if (view->type == ROOTS_WL_SHELL_VIEW &&
 | 
						if (view->type == ROOTS_WL_SHELL_VIEW &&
 | 
				
			||||||
| 
						 | 
					@ -522,11 +536,3 @@ struct roots_output *desktop_output_from_wlr_output(
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
void desktop_damage_surface(struct roots_desktop *desktop,
 | 
					 | 
				
			||||||
		struct wlr_surface *surface, double lx, double ly) {
 | 
					 | 
				
			||||||
	struct roots_output *output;
 | 
					 | 
				
			||||||
	wl_list_for_each(output, &desktop->outputs, link) {
 | 
					 | 
				
			||||||
		output_damage_surface(output, surface, lx, ly);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -337,7 +337,7 @@ static int handle_repaint(void *data) {
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void output_damage_surface(struct roots_output *output,
 | 
					static void output_damage_surface(struct roots_output *output,
 | 
				
			||||||
		struct wlr_surface *surface, double lx, double ly) {
 | 
							struct wlr_surface *surface, double lx, double ly) {
 | 
				
			||||||
	if (!wlr_surface_has_buffer(surface)) {
 | 
						if (!wlr_surface_has_buffer(surface)) {
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -355,6 +355,12 @@ void output_damage_surface(struct roots_output *output,
 | 
				
			||||||
		box.width, box.height);
 | 
							box.width, box.height);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void output_damage_view(struct roots_output *output, struct roots_view *view) {
 | 
				
			||||||
 | 
						output_damage_surface(output, view->wlr_surface, view->x, view->y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// TODO: subsurfaces, popups, etc
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void set_mode(struct wlr_output *output,
 | 
					static void set_mode(struct wlr_output *output,
 | 
				
			||||||
		struct roots_output_config *oc) {
 | 
							struct roots_output_config *oc) {
 | 
				
			||||||
	int mhz = (int)(oc->mode.refresh_rate * 1000);
 | 
						int mhz = (int)(oc->mode.refresh_rate * 1000);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,17 +90,20 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int width = wlr_surface->current->width;
 | 
						int width = wlr_surface->current->width;
 | 
				
			||||||
	int height = wlr_surface->current->height;
 | 
						int height = wlr_surface->current->height;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (view->pending_move_resize.update_x) {
 | 
						if (view->pending_move_resize.update_x) {
 | 
				
			||||||
		view->x = view->pending_move_resize.x +
 | 
							double x = view->pending_move_resize.x +
 | 
				
			||||||
			view->pending_move_resize.width - width;
 | 
								view->pending_move_resize.width - width;
 | 
				
			||||||
 | 
							view_update_position(view, x, view->y);
 | 
				
			||||||
		view->pending_move_resize.update_x = false;
 | 
							view->pending_move_resize.update_x = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (view->pending_move_resize.update_y) {
 | 
						if (view->pending_move_resize.update_y) {
 | 
				
			||||||
		view->y = view->pending_move_resize.y +
 | 
							double y = view->pending_move_resize.y +
 | 
				
			||||||
			view->pending_move_resize.height - height;
 | 
								view->pending_move_resize.height - height;
 | 
				
			||||||
 | 
							view_update_position(view, view->x, y);
 | 
				
			||||||
		view->pending_move_resize.update_y = false;
 | 
							view->pending_move_resize.update_y = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
					static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,8 +102,7 @@ static void move_resize(struct roots_view *view, double x, double y,
 | 
				
			||||||
	if (serial > 0) {
 | 
						if (serial > 0) {
 | 
				
			||||||
		roots_surface->pending_move_resize_configure_serial = serial;
 | 
							roots_surface->pending_move_resize_configure_serial = serial;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		view->x = x;
 | 
							view_update_position(view, x, y);
 | 
				
			||||||
		view->y = y;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -205,12 +204,14 @@ static void handle_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
		get_size(view, &size);
 | 
							get_size(view, &size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (view->pending_move_resize.update_x) {
 | 
							if (view->pending_move_resize.update_x) {
 | 
				
			||||||
			view->x = view->pending_move_resize.x +
 | 
								double x = view->pending_move_resize.x +
 | 
				
			||||||
				view->pending_move_resize.width - size.width;
 | 
									view->pending_move_resize.width - size.width;
 | 
				
			||||||
 | 
								view_update_position(view, x, view->y);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (view->pending_move_resize.update_y) {
 | 
							if (view->pending_move_resize.update_y) {
 | 
				
			||||||
			view->y = view->pending_move_resize.y +
 | 
								double y = view->pending_move_resize.y +
 | 
				
			||||||
				view->pending_move_resize.height - size.height;
 | 
									view->pending_move_resize.height - size.height;
 | 
				
			||||||
 | 
								view_update_position(view, view->x, y);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pending_serial == surface->configure_serial) {
 | 
							if (pending_serial == surface->configure_serial) {
 | 
				
			||||||
| 
						 | 
					@ -218,7 +219,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	desktop_damage_surface(view->desktop, view->wlr_surface, view->x, view->y);
 | 
						view_damage(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
					static void handle_destroy(struct wl_listener *listener, void *data) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,8 +18,7 @@ static void activate(struct roots_view *view, bool active) {
 | 
				
			||||||
static void move(struct roots_view *view, double x, double y) {
 | 
					static void move(struct roots_view *view, double x, double y) {
 | 
				
			||||||
	assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
						assert(view->type == ROOTS_XWAYLAND_VIEW);
 | 
				
			||||||
	struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
						struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
 | 
				
			||||||
	view->x = x;
 | 
						view_update_position(view, x, y);
 | 
				
			||||||
	view->y = y;
 | 
					 | 
				
			||||||
	wlr_xwayland_surface_configure(xwayland_surface, x, y,
 | 
						wlr_xwayland_surface_configure(xwayland_surface, x, y,
 | 
				
			||||||
		xwayland_surface->width, xwayland_surface->height);
 | 
							xwayland_surface->width, xwayland_surface->height);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -133,8 +132,7 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
 | 
				
			||||||
		roots_surface->view->xwayland_surface;
 | 
							roots_surface->view->xwayland_surface;
 | 
				
			||||||
	struct wlr_xwayland_surface_configure_event *event = data;
 | 
						struct wlr_xwayland_surface_configure_event *event = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	roots_surface->view->x = (double)event->x;
 | 
						view_update_position(roots_surface->view, event->x, event->y);
 | 
				
			||||||
	roots_surface->view->y = (double)event->y;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
 | 
						wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
 | 
				
			||||||
		event->width, event->height);
 | 
							event->width, event->height);
 | 
				
			||||||
| 
						 | 
					@ -210,15 +208,19 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	int height = wlr_surface->current->height;
 | 
						int height = wlr_surface->current->height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (view->pending_move_resize.update_x) {
 | 
						if (view->pending_move_resize.update_x) {
 | 
				
			||||||
		view->x = view->pending_move_resize.x +
 | 
							double x = view->pending_move_resize.x +
 | 
				
			||||||
			view->pending_move_resize.width - width;
 | 
								view->pending_move_resize.width - width;
 | 
				
			||||||
 | 
							view_update_position(view, x, view->y);
 | 
				
			||||||
		view->pending_move_resize.update_x = false;
 | 
							view->pending_move_resize.update_x = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (view->pending_move_resize.update_y) {
 | 
						if (view->pending_move_resize.update_y) {
 | 
				
			||||||
		view->y = view->pending_move_resize.y +
 | 
							double y = view->pending_move_resize.y +
 | 
				
			||||||
			view->pending_move_resize.height - height;
 | 
								view->pending_move_resize.height - height;
 | 
				
			||||||
 | 
							view_update_position(view, view->x, y);
 | 
				
			||||||
		view->pending_move_resize.update_y = false;
 | 
							view->pending_move_resize.update_y = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void handle_map_notify(struct wl_listener *listener, void *data) {
 | 
					static void handle_map_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
| 
						 | 
					@ -229,8 +231,9 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct roots_desktop *desktop = view->desktop;
 | 
						struct roots_desktop *desktop = view->desktop;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	view->wlr_surface = xsurface->surface;
 | 
						view->wlr_surface = xsurface->surface;
 | 
				
			||||||
	view->x = (double)xsurface->x;
 | 
						view->x = xsurface->x;
 | 
				
			||||||
	view->y = (double)xsurface->y;
 | 
						view->y = xsurface->y;
 | 
				
			||||||
 | 
						view_damage(view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	roots_surface->surface_commit.notify = handle_surface_commit;
 | 
						roots_surface->surface_commit.notify = handle_surface_commit;
 | 
				
			||||||
	wl_signal_add(&xsurface->surface->events.commit,
 | 
						wl_signal_add(&xsurface->surface->events.commit,
 | 
				
			||||||
| 
						 | 
					@ -242,10 +245,11 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
static void handle_unmap_notify(struct wl_listener *listener, void *data) {
 | 
					static void handle_unmap_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct roots_xwayland_surface *roots_surface =
 | 
						struct roots_xwayland_surface *roots_surface =
 | 
				
			||||||
		wl_container_of(listener, roots_surface, unmap_notify);
 | 
							wl_container_of(listener, roots_surface, unmap_notify);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						view_damage(roots_surface->view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	roots_surface->view->wlr_surface = NULL;
 | 
						roots_surface->view->wlr_surface = NULL;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	wl_list_remove(&roots_surface->surface_commit.link);
 | 
						wl_list_remove(&roots_surface->surface_commit.link);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	wl_list_remove(&roots_surface->view->link);
 | 
						wl_list_remove(&roots_surface->view->link);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue