mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	Check for subsurfaces and popups before using wlr_output_set_fullscreen_surface
This commit is contained in:
		
							parent
							
								
									80998cdf57
								
							
						
					
					
						commit
						abab2902f5
					
				
					 4 changed files with 43 additions and 7 deletions
				
			
		| 
						 | 
					@ -19,13 +19,14 @@ struct roots_output {
 | 
				
			||||||
	struct wlr_output *wlr_output;
 | 
						struct wlr_output *wlr_output;
 | 
				
			||||||
	struct wl_listener frame;
 | 
						struct wl_listener frame;
 | 
				
			||||||
	struct timespec last_frame;
 | 
						struct timespec last_frame;
 | 
				
			||||||
	struct wl_list link;
 | 
						struct wl_list link; // roots_desktop:outputs
 | 
				
			||||||
 | 
						struct roots_view *fullscreen_view;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct roots_desktop {
 | 
					struct roots_desktop {
 | 
				
			||||||
	struct wl_list views; // roots_view::link
 | 
						struct wl_list views; // roots_view::link
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct wl_list outputs;
 | 
						struct wl_list outputs; // roots_output::link
 | 
				
			||||||
	struct timespec last_frame;
 | 
						struct timespec last_frame;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct roots_server *server;
 | 
						struct roots_server *server;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,7 +57,7 @@ struct roots_view {
 | 
				
			||||||
	float rotation;
 | 
						float rotation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool maximized;
 | 
						bool maximized;
 | 
				
			||||||
	struct wlr_output *fullscreen_output;
 | 
						struct roots_output *fullscreen_output;
 | 
				
			||||||
	struct {
 | 
						struct {
 | 
				
			||||||
		double x, y;
 | 
							double x, y;
 | 
				
			||||||
		uint32_t width, height;
 | 
							uint32_t width, height;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -174,8 +174,14 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
 | 
				
			||||||
			output_box->height);
 | 
								output_box->height);
 | 
				
			||||||
		view->rotation = 0;
 | 
							view->rotation = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		wlr_output_set_fullscreen_surface(output, view->wlr_surface);
 | 
							struct roots_output *roots_output;
 | 
				
			||||||
		view->fullscreen_output = output;
 | 
							wl_list_for_each(roots_output, &view->desktop->outputs, link) {
 | 
				
			||||||
 | 
								if (roots_output->wlr_output == output) {
 | 
				
			||||||
 | 
									roots_output->fullscreen_view = view;
 | 
				
			||||||
 | 
									view->fullscreen_output = roots_output;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (was_fullscreen && !fullscreen) {
 | 
						if (was_fullscreen && !fullscreen) {
 | 
				
			||||||
| 
						 | 
					@ -183,7 +189,7 @@ void view_set_fullscreen(struct roots_view *view, bool fullscreen,
 | 
				
			||||||
			view->saved.height);
 | 
								view->saved.height);
 | 
				
			||||||
		view->rotation = view->saved.rotation;
 | 
							view->rotation = view->saved.rotation;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		wlr_output_set_fullscreen_surface(view->fullscreen_output, NULL);
 | 
							view->fullscreen_output->fullscreen_view = NULL;
 | 
				
			||||||
		view->fullscreen_output = NULL;
 | 
							view->fullscreen_output = NULL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -236,6 +242,10 @@ bool view_center(struct roots_view *view) {
 | 
				
			||||||
void view_destroy(struct roots_view *view) {
 | 
					void view_destroy(struct roots_view *view) {
 | 
				
			||||||
	wl_signal_emit(&view->events.destroy, view);
 | 
						wl_signal_emit(&view->events.destroy, view);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (view->fullscreen_output) {
 | 
				
			||||||
 | 
							view->fullscreen_output->fullscreen_view = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_list_remove(&view->link);
 | 
						wl_list_remove(&view->link);
 | 
				
			||||||
	free(view);
 | 
						free(view);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -174,6 +174,22 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static bool has_standalone_surface(struct roots_view *view) {
 | 
				
			||||||
 | 
						if (!wl_list_empty(&view->wlr_surface->subsurface_list)) {
 | 
				
			||||||
 | 
							wlr_log(L_DEBUG, "has subsurfaces");
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch (view->type) {
 | 
				
			||||||
 | 
						case ROOTS_XDG_SHELL_V6_VIEW:
 | 
				
			||||||
 | 
							return wl_list_empty(&view->xdg_surface_v6->popups);
 | 
				
			||||||
 | 
						case ROOTS_WL_SHELL_VIEW:
 | 
				
			||||||
 | 
							return wl_list_empty(&view->wl_shell_surface->popups);
 | 
				
			||||||
 | 
						case ROOTS_XWAYLAND_VIEW:
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void output_frame_notify(struct wl_listener *listener, void *data) {
 | 
					static void output_frame_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	struct wlr_output *wlr_output = data;
 | 
						struct wlr_output *wlr_output = data;
 | 
				
			||||||
	struct roots_output *output = wl_container_of(listener, output, frame);
 | 
						struct roots_output *output = wl_container_of(listener, output, frame);
 | 
				
			||||||
| 
						 | 
					@ -186,11 +202,20 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
 | 
				
			||||||
	wlr_output_make_current(wlr_output);
 | 
						wlr_output_make_current(wlr_output);
 | 
				
			||||||
	wlr_renderer_begin(server->renderer, wlr_output);
 | 
						wlr_renderer_begin(server->renderer, wlr_output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (wlr_output->fullscreen_surface != NULL) {
 | 
						if (output->fullscreen_view != NULL) {
 | 
				
			||||||
 | 
							if (has_standalone_surface(output->fullscreen_view)) {
 | 
				
			||||||
 | 
								wlr_output_set_fullscreen_surface(wlr_output,
 | 
				
			||||||
 | 
									output->fullscreen_view->wlr_surface);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								wlr_output_set_fullscreen_surface(wlr_output, NULL);
 | 
				
			||||||
 | 
								render_view(output->fullscreen_view, desktop, wlr_output, &now);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		wlr_renderer_end(server->renderer);
 | 
							wlr_renderer_end(server->renderer);
 | 
				
			||||||
		wlr_output_swap_buffers(wlr_output);
 | 
							wlr_output_swap_buffers(wlr_output);
 | 
				
			||||||
		output->last_frame = desktop->last_frame = now;
 | 
							output->last_frame = desktop->last_frame = now;
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							wlr_output_set_fullscreen_surface(wlr_output, NULL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct roots_view *view;
 | 
						struct roots_view *view;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue