diff options
| -rw-r--r-- | include/rootston/desktop.h | 1 | ||||
| -rw-r--r-- | include/rootston/view.h | 7 | ||||
| -rw-r--r-- | rootston/desktop.c | 25 | ||||
| -rw-r--r-- | rootston/wl_shell.c | 4 | ||||
| -rw-r--r-- | rootston/xdg_shell_v6.c | 15 | ||||
| -rw-r--r-- | rootston/xwayland.c | 7 | 
6 files changed, 38 insertions, 21 deletions
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 388fb55d..1232121a 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -69,6 +69,7 @@ void view_activate(struct roots_view *view, bool activate);  void view_apply_damage(struct roots_view *view);  void view_damage_whole(struct roots_view *view);  void view_update_position(struct roots_view *view, double x, double y); +void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);  void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);  void handle_wl_shell_surface(struct wl_listener *listener, void *data); diff --git a/include/rootston/view.h b/include/rootston/view.h index c9d1deb2..9312c8c3 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -62,6 +62,7 @@ struct roots_view {  	struct wl_list link; // roots_desktop::views  	double x, y; +	uint32_t width, height;  	float rotation;  	bool decorated; @@ -108,11 +109,7 @@ struct roots_view {  		struct wl_signal destroy;  	} events; -	// TODO: This would probably be better as a field that's updated on a -	// configure event from the xdg_shell -	// If not then this should follow the typical type/impl pattern we use -	// elsewhere -	void (*get_size)(const struct roots_view *view, struct wlr_box *box); +	// TODO: this should follow the typical type/impl pattern we use elsewhere  	void (*activate)(struct roots_view *view, bool active);  	void (*move)(struct roots_view *view, double x, double y);  	void (*resize)(struct roots_view *view, uint32_t width, uint32_t height); diff --git a/rootston/desktop.c b/rootston/desktop.c index 25930d2a..9abcfa33 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -24,18 +24,8 @@  void view_get_box(const struct roots_view *view, struct wlr_box *box) {  	box->x = view->x;  	box->y = view->y; -	if (view->get_size) { -		view->get_size(view, box); -	} else { -		if (view->wlr_surface == NULL) { -			// View is unmapped -			box->width = box->height = 0; -			return; -		} - -		box->width = view->wlr_surface->current->width; -		box->height = view->wlr_surface->current->height; -	} +	box->width = view->width; +	box->height = view->height;  }  void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) { @@ -469,6 +459,17 @@ void view_update_position(struct roots_view *view, double x, double y) {  	view_damage_whole(view);  } +void view_update_size(struct roots_view *view, uint32_t width, uint32_t height) { +	if (view->width == width && view->height == height) { +		return; +	} + +	view_damage_whole(view); +	view->width = width; +	view->height = height; +	view_damage_whole(view); +} +  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 && diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 1fc48452..267e2cf5 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -147,6 +147,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {  	int width = wlr_surface->current->width;  	int height = wlr_surface->current->height; +	view_update_size(view, width, height); +  	double x = view->x;  	double y = view->y;  	if (view->pending_move_resize.update_x) { @@ -231,6 +233,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {  		return;  	}  	view->type = ROOTS_WL_SHELL_VIEW; +	view->width = surface->surface->current->width; +	view->height = surface->surface->current->height;  	view->wl_shell_surface = surface;  	view->roots_wl_shell_surface = roots_surface; diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 0a3ca72c..b354b77b 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -245,12 +245,13 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {  	view_apply_damage(view); +	struct wlr_box size; +	get_size(view, &size); +	view_update_size(view, size.width, size.height); +  	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); -  		double x = view->x;  		double y = view->y;  		if (view->pending_move_resize.update_x) { @@ -338,10 +339,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {  		return;  	}  	view->type = ROOTS_XDG_SHELL_V6_VIEW; +  	view->xdg_surface_v6 = surface;  	view->roots_xdg_surface_v6 = roots_surface;  	view->wlr_surface = surface->surface; -	view->get_size = get_size;  	view->activate = activate;  	view->resize = resize;  	view->move_resize = move_resize; @@ -349,6 +350,12 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {  	view->set_fullscreen = set_fullscreen;  	view->close = close;  	roots_surface->view = view; + +	struct wlr_box box; +	get_size(view, &box); +	view->width = box.width; +	view->height = box.height; +  	view_init(view, desktop);  	wl_list_insert(&desktop->views, &view->link); diff --git a/rootston/xwayland.c b/rootston/xwayland.c index c0bc9ae7..a3e12d00 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -209,6 +209,8 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {  	int width = wlr_surface->current->width;  	int height = wlr_surface->current->height; +	view_update_size(view, width, height); +  	double x = view->x;  	double y = view->y;  	if (view->pending_move_resize.update_x) { @@ -234,6 +236,8 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {  	view->wlr_surface = xsurface->surface;  	view->x = xsurface->x;  	view->y = xsurface->y; +	view->width = xsurface->surface->current->width; +	view->height = xsurface->surface->current->height;  	wl_list_insert(&desktop->views, &view->link);  	struct wlr_subsurface *subsurface; @@ -264,6 +268,7 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {  	}  	view->wlr_surface = NULL; +	view->width = view->height = 0;  	wl_list_remove(&view->link);  } @@ -314,6 +319,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {  	view->type = ROOTS_XWAYLAND_VIEW;  	view->x = (double)surface->x;  	view->y = (double)surface->y; +	view->width = surface->surface->current->width; +	view->height = surface->surface->current->height;  	view->xwayland_surface = surface;  	view->roots_xwayland_surface = roots_surface;  | 
