Listen to fullscreen requests

Fixes #34.
This commit is contained in:
Jente Hidskes 2019-02-14 11:38:29 +01:00
parent 5a1da1baee
commit 2669c80803
4 changed files with 24 additions and 5 deletions

View file

@ -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);
}

View file

@ -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;
};

View file

@ -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);
}

View file

@ -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);