feat: allows fullscreen support

This commit is contained in:
DanyLE
2024-04-02 23:00:11 +02:00
parent 68b1890d61
commit 1ae9cd000a
4 changed files with 65 additions and 93 deletions

67
xdg.c
View File

@@ -79,10 +79,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
toplevel->original.height = toplevel->output->usable_area.height;
}
diyac_view_update_geometry(toplevel, false);
if (toplevel->state != DIYAC_VIEW_MINIMIZE)
{
diyac_focus_view(toplevel, false);
}
diyac_focus_view(toplevel, false);
}
static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
@@ -136,74 +133,41 @@ static void xdg_toplevel_request_maximize(
struct diyac_view *toplevel =
wl_container_of(listener, toplevel, request_maximize);
if (!toplevel->mapped)
if(toplevel->xdg_toplevel->requested.maximized)
{
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, false);
// the view has not yet be mapped, don't maximize it
wlr_log(WLR_INFO, "The view has not yet be mapped, ignore maximize request");
return;
toplevel->requested = DIYAC_VIEW_MAXIMIZE;
}
else if(toplevel->state == DIYAC_VIEW_MAXIMIZE)
{
toplevel->requested = DIYAC_VIEW_NORMAL;
}
wlr_log(WLR_INFO, "Request maximize");
diyac_reset_cursor_mode(toplevel->server);
if (toplevel->state == DIYAC_VIEW_MAXIMIZE)
{
toplevel->state = DIYAC_VIEW_NORMAL;
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, false);
// restore its default geometry
}
else
{
wlr_xdg_toplevel_set_maximized(toplevel->xdg_toplevel, true);
toplevel->state = DIYAC_VIEW_MAXIMIZE;
}
diyac_view_update_geometry(toplevel, false);
// wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
}
static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
{
struct diyac_view *toplevel =
wl_container_of(listener, toplevel, request_fullscreen);
if (!toplevel->mapped)
if(toplevel->xdg_toplevel->requested.fullscreen)
{
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
// the view has not yet be mapped, don't maximize it
wlr_log(WLR_INFO, "The view has not yet be mapped, ignore fullscreen request");
return;
toplevel->requested = DIYAC_VIEW_FULL_SCREEN;
}
else if(toplevel->state == DIYAC_VIEW_FULL_SCREEN)
{
toplevel->requested = DIYAC_VIEW_NORMAL;
}
wlr_log(WLR_INFO, "Request fullscreen");
diyac_reset_cursor_mode(toplevel->server);
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
/*
if (toplevel->state == DIYAC_VIEW_FULL_SCREEN)
{
toplevel->state = DIYAC_VIEW_NORMAL;
wlr_xdg_toplevel_set_fullscreen(toplevel->xdg_toplevel, false);
// restore its default geometry
}
else
{
toplevel->state = DIYAC_VIEW_FULL_SCREEN;
}
*/
// diyac_view_update_geometry(toplevel, false);
diyac_view_update_geometry(toplevel, false);
}
static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *data)
{
struct diyac_view *toplevel =
wl_container_of(listener, toplevel, request_minimize);
if (toplevel->state == DIYAC_VIEW_MINIMIZE)
{
toplevel->state = DIYAC_VIEW_NORMAL;
// restore its default geometry
}
else
{
toplevel->state = DIYAC_VIEW_MINIMIZE;
}
diyac_view_update_geometry(toplevel, false);
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
}
static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
@@ -387,6 +351,7 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
/* Allocate a diyac_view for this surface */
struct diyac_view *toplevel = calloc(1, sizeof(*toplevel));
toplevel->state = DIYAC_VIEW_NORMAL;
toplevel->requested = DIYAC_VIEW_NORMAL;
toplevel->server = server;
toplevel->xdg_toplevel = xdg_surface->toplevel;
toplevel->xdg_surface = xdg_surface;