better handling different window state, support fullscreen mode
This commit is contained in:
61
xdg.c
61
xdg.c
@@ -92,6 +92,14 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
}
|
||||
if(toplevel->state.fullscreen)
|
||||
{
|
||||
/**
|
||||
* When a client exit during fullscreen mode, the top layer shall
|
||||
* be restored as it is currently disabled
|
||||
*/
|
||||
wlr_scene_node_set_enabled(&toplevel->output->scenes.top->node, true);
|
||||
}
|
||||
wl_list_remove(&toplevel->link);
|
||||
}
|
||||
|
||||
@@ -103,7 +111,6 @@ static void xdg_toplevel_request_move(
|
||||
* decorations. Note that a more sophisticated compositor should check the
|
||||
* provided serial against a list of button press serials sent to this
|
||||
* client, to prevent the client from requesting this whenever they want. */
|
||||
wlr_log(WLR_INFO, "Request move");
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_move);
|
||||
begin_interactive(toplevel, DIYAC_CURSOR_MOVE, 0);
|
||||
}
|
||||
@@ -116,7 +123,7 @@ static void xdg_toplevel_request_resize(
|
||||
* decorations. Note that a more sophisticated compositor should check the
|
||||
* provided serial against a list of button press serials sent to this
|
||||
* client, to prevent the client from requesting this whenever they want. */
|
||||
wlr_log(WLR_INFO, "Request resize");
|
||||
|
||||
struct wlr_xdg_toplevel_resize_event *event = data;
|
||||
struct diyac_view *toplevel = wl_container_of(listener, toplevel, request_resize);
|
||||
begin_interactive(toplevel, DIYAC_CURSOR_RESIZE, event->edges);
|
||||
@@ -133,15 +140,7 @@ static void xdg_toplevel_request_maximize(
|
||||
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_maximize);
|
||||
if(toplevel->xdg_toplevel->requested.maximized)
|
||||
{
|
||||
toplevel->requested = DIYAC_VIEW_MAXIMIZE;
|
||||
}
|
||||
else if(toplevel->state == DIYAC_VIEW_MAXIMIZE)
|
||||
{
|
||||
toplevel->requested = DIYAC_VIEW_NORMAL;
|
||||
}
|
||||
wlr_log(WLR_INFO, "Request maximize");
|
||||
toplevel->requested.maximized = toplevel->xdg_toplevel->requested.maximized;
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
}
|
||||
@@ -150,15 +149,11 @@ static void xdg_toplevel_request_fullscreen(struct wl_listener *listener, void *
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_fullscreen);
|
||||
if(toplevel->xdg_toplevel->requested.fullscreen)
|
||||
{
|
||||
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");
|
||||
toplevel->requested.fullscreen = toplevel->xdg_toplevel->requested.fullscreen;
|
||||
/**
|
||||
* TODO: use client specific output for fullscreen
|
||||
* toplevel->xdg_toplevel->requested.fullscreen_output
|
||||
*/
|
||||
diyac_reset_cursor_mode(toplevel->server);
|
||||
diyac_view_update_geometry(toplevel, false);
|
||||
}
|
||||
@@ -167,6 +162,8 @@ static void xdg_toplevel_request_minimize(struct wl_listener *listener, void *da
|
||||
{
|
||||
struct diyac_view *toplevel =
|
||||
wl_container_of(listener, toplevel, request_minimize);
|
||||
toplevel->requested.minimized = toplevel->xdg_toplevel->requested.minimized;
|
||||
//TODO implement minimize
|
||||
wlr_xdg_surface_schedule_configure(toplevel->xdg_toplevel->base);
|
||||
}
|
||||
|
||||
@@ -215,13 +212,23 @@ static void popup_unconstrain(struct diyac_popup *popup)
|
||||
struct diyac_server *server = view->server;
|
||||
struct wlr_output_layout *output_layout = server->output_layout;
|
||||
struct wlr_output *wlr_output = view->output->wlr_output;
|
||||
|
||||
struct wlr_box usable = {
|
||||
.x = 0,
|
||||
.y = 0,
|
||||
.width = view->output->wlr_output->width,
|
||||
.height = view->output->wlr_output->height
|
||||
};
|
||||
struct diyac_view *root = diyac_get_root_view(view);
|
||||
if(!root || ! root->state.fullscreen)
|
||||
{
|
||||
usable = view->output->usable_area;
|
||||
}
|
||||
struct wlr_box geo_box = diyac_view_get_geometry(view);
|
||||
struct wlr_box output_toplevel_box = {
|
||||
.x = view->output->usable_area.x - geo_box.x,
|
||||
.y = view->output->usable_area.y - geo_box.y,
|
||||
.width = view->output->usable_area.width,
|
||||
.height = view->output->usable_area.height,
|
||||
.x = usable.x - geo_box.x,
|
||||
.y = usable.y - geo_box.y,
|
||||
.width = usable.width,
|
||||
.height = usable.height,
|
||||
};
|
||||
wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup, &output_toplevel_box);
|
||||
}
|
||||
@@ -350,8 +357,8 @@ void diyac_new_xdg_surface(struct wl_listener *listener, void *data)
|
||||
wlr_xdg_surface_ping(xdg_surface);
|
||||
/* 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;
|
||||
memset(&toplevel->state, 0, sizeof(toplevel->state));
|
||||
memset(&toplevel->requested, 0, sizeof(toplevel->requested));
|
||||
toplevel->server = server;
|
||||
toplevel->xdg_toplevel = xdg_surface->toplevel;
|
||||
toplevel->xdg_surface = xdg_surface;
|
||||
|
Reference in New Issue
Block a user