From 80998cdf57756fe46d55921c98a745aff4848215 Mon Sep 17 00:00:00 2001 From: emersion Date: Mon, 20 Nov 2017 17:58:26 +0100 Subject: [PATCH] Add support for fullscreen xwayland views --- include/rootston/view.h | 1 + rootston/xwayland.c | 21 +++++++++++++++++++++ types/wlr_output.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/include/rootston/view.h b/include/rootston/view.h index e1397b89..77bbfbec 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -38,6 +38,7 @@ struct roots_xwayland_surface { struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_maximize; + struct wl_listener request_fullscreen; struct wl_listener map_notify; struct wl_listener unmap_notify; }; diff --git a/rootston/xwayland.c b/rootston/xwayland.c index c92c424b..5e27afed 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -92,6 +92,13 @@ static void maximize(struct roots_view *view, bool maximized) { view->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->desktop->xwayland, + view->xwayland_surface, fullscreen); +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); @@ -170,6 +177,16 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) { view_maximize(view, maximized); } +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; + + view_set_fullscreen(view, xwayland_surface->fullscreen, NULL); +} + static void handle_map_notify(struct wl_listener *listener, void *data) { struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, map_notify); @@ -223,6 +240,9 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { roots_surface->request_maximize.notify = handle_request_maximize; wl_signal_add(&surface->events.request_maximize, &roots_surface->request_maximize); + roots_surface->request_fullscreen.notify = handle_request_fullscreen; + wl_signal_add(&surface->events.request_fullscreen, + &roots_surface->request_fullscreen); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (view == NULL) { @@ -240,6 +260,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->move = move; view->move_resize = move_resize; view->maximize = maximize; + view->set_fullscreen = set_fullscreen; view->close = close; roots_surface->view = view; view_init(view, desktop); diff --git a/types/wlr_output.c b/types/wlr_output.c index 5a8baa3d..3ef91179 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -382,6 +382,10 @@ static void output_fullscreen_surface_handle_destroy( void wlr_output_set_fullscreen_surface(struct wlr_output *output, struct wlr_surface *surface) { // TODO: hardware fullscreen + if (output->fullscreen_surface == surface) { + return; + } + output_fullscreen_surface_reset(output); output->fullscreen_surface = surface;