diff --git a/xdg_shell.c b/xdg_shell.c index 2ef22ac..210d600 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -203,6 +203,14 @@ wlr_surface_at(struct cg_view *view, double sx, double sy, double *sub_x, double return wlr_xdg_surface_surface_at(xdg_shell_view->xdg_surface, sx, sy, sub_x, sub_y); } +static void +handle_xdg_shell_surface_request_fullscreen(struct wl_listener *listener, void *data) +{ + struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, request_fullscreen); + struct wlr_xdg_toplevel_set_fullscreen_event *event = data; + wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_surface, event->fullscreen); +} + static void handle_xdg_shell_surface_commit(struct wl_listener *listener, void *data) { @@ -247,6 +255,7 @@ handle_xdg_shell_surface_destroy(struct wl_listener *listener, void *data) wl_list_remove(&xdg_shell_view->map.link); wl_list_remove(&xdg_shell_view->unmap.link); wl_list_remove(&xdg_shell_view->destroy.link); + wl_list_remove(&xdg_shell_view->request_fullscreen.link); wl_list_remove(&xdg_shell_view->new_popup.link); xdg_shell_view->xdg_surface = NULL; @@ -290,6 +299,8 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data) wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_view->unmap); xdg_shell_view->destroy.notify = handle_xdg_shell_surface_destroy; wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy); + xdg_shell_view->request_fullscreen.notify = handle_xdg_shell_surface_request_fullscreen; + wl_signal_add(&xdg_surface->toplevel->events.request_fullscreen, &xdg_shell_view->request_fullscreen); xdg_shell_view->new_popup.notify = handle_new_xdg_popup; wl_signal_add(&xdg_surface->events.new_popup, &xdg_shell_view->new_popup); } diff --git a/xdg_shell.h b/xdg_shell.h index af87d8c..0afd6f2 100644 --- a/xdg_shell.h +++ b/xdg_shell.h @@ -14,9 +14,7 @@ struct cg_xdg_shell_view { struct wl_listener unmap; struct wl_listener map; struct wl_listener commit; - // TODO: allow applications to go to fullscreen from maximized? - // struct wl_listener request_fullscreen; - + struct wl_listener request_fullscreen; struct wl_listener new_popup; }; diff --git a/xwayland.c b/xwayland.c index 3a73aaa..0cbe412 100644 --- a/xwayland.c +++ b/xwayland.c @@ -107,6 +107,14 @@ wlr_surface_at(struct cg_view *view, double sx, double sy, double *sub_x, double return wlr_surface_surface_at(view->wlr_surface, sx, sy, sub_x, sub_y); } +static void +handle_xwayland_surface_request_fullscreen(struct wl_listener *listener, void *data) +{ + struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, request_fullscreen); + struct wlr_xwayland_surface *xwayland_surface = xwayland_view->xwayland_surface; + wlr_xwayland_surface_set_fullscreen(xwayland_view->xwayland_surface, xwayland_surface->fullscreen); +} + static void handle_xwayland_surface_commit(struct wl_listener *listener, void *data) { @@ -157,6 +165,7 @@ handle_xwayland_surface_destroy(struct wl_listener *listener, void *data) wl_list_remove(&xwayland_view->map.link); wl_list_remove(&xwayland_view->unmap.link); wl_list_remove(&xwayland_view->destroy.link); + wl_list_remove(&xwayland_view->request_fullscreen.link); xwayland_view->xwayland_surface = NULL; view_destroy(view); @@ -195,4 +204,6 @@ handle_xwayland_surface_new(struct wl_listener *listener, void *data) wl_signal_add(&xwayland_surface->events.unmap, &xwayland_view->unmap); xwayland_view->destroy.notify = handle_xwayland_surface_destroy; wl_signal_add(&xwayland_surface->events.destroy, &xwayland_view->destroy); + xwayland_view->request_fullscreen.notify = handle_xwayland_surface_request_fullscreen; + wl_signal_add(&xwayland_surface->events.request_fullscreen, &xwayland_view->request_fullscreen); } diff --git a/xwayland.h b/xwayland.h index 24ad4e4..fa9c62e 100644 --- a/xwayland.h +++ b/xwayland.h @@ -28,8 +28,7 @@ struct cg_xwayland_view { struct wl_listener unmap; struct wl_listener map; struct wl_listener commit; - // TODO: allow applications to go to fullscreen from maximized? - // struct wl_listener request_fullscreen; + struct wl_listener request_fullscreen; }; struct cg_xwayland_view *xwayland_view_from_view(struct cg_view *view);