mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-11-26 07:00:00 -05:00
view: unconditionally center views in output layout
Whatever type or dimensions of a view, position it at center of the output layout. Then, if it is a primary view or if it extends the output layout, send request to maximize it. The client may or may not change the view dimensions after that. If not, e.g. weston-flower, the view will be kept displayed at center instead of to left. If so, the view will expand from center to fill the whole output layout. In order to update the view position, XDG shell surface commit is now handled to check for dimension change.
This commit is contained in:
parent
e7d8780f46
commit
560e9ff3ef
4 changed files with 33 additions and 31 deletions
19
xdg_shell.c
19
xdg_shell.c
|
|
@ -183,15 +183,34 @@ handle_xdg_shell_surface_unmap(struct wl_listener *listener, void *data)
|
|||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, unmap);
|
||||
struct cg_view *view = &xdg_shell_view->view;
|
||||
|
||||
wl_list_remove(&xdg_shell_view->commit.link);
|
||||
|
||||
view_unmap(view);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xdg_shell_surface_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, commit);
|
||||
struct cg_view *view = &xdg_shell_view->view;
|
||||
|
||||
// Check if view dimensions have changed
|
||||
int width, height;
|
||||
get_geometry(view, &width, &height);
|
||||
if (width != view->width || height != view->height) {
|
||||
view_position(view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xdg_shell_surface_map(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, map);
|
||||
struct cg_view *view = &xdg_shell_view->view;
|
||||
|
||||
xdg_shell_view->commit.notify = handle_xdg_shell_surface_commit;
|
||||
wl_signal_add(&xdg_shell_view->xdg_toplevel->base->surface->events.commit, &xdg_shell_view->commit);
|
||||
|
||||
view_map(view, xdg_shell_view->xdg_toplevel->base->surface);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue