mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-28 05:40:16 -04:00
xdg_shell: configure surface on initial commit
Instead of waiting for the surface to be mapped before sending a configure event, do it on initial commit. Note, wlroots 0.18 no longer sends automatic configure events on initial commit.
This commit is contained in:
parent
17af2f7be9
commit
fa90174607
3 changed files with 24 additions and 2 deletions
8
view.c
8
view.c
|
|
@ -67,7 +67,9 @@ view_maximize(struct cg_view *view, struct wlr_box *layout_box)
|
|||
view->lx = layout_box->x;
|
||||
view->ly = layout_box->y;
|
||||
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
|
||||
if (view->scene_tree) {
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
|
||||
}
|
||||
|
||||
view->impl->maximize(view, layout_box->width, layout_box->height);
|
||||
}
|
||||
|
|
@ -81,7 +83,9 @@ view_center(struct cg_view *view, struct wlr_box *layout_box)
|
|||
view->lx = (layout_box->width - width) / 2;
|
||||
view->ly = (layout_box->height - height) / 2;
|
||||
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
|
||||
if (view->scene_tree) {
|
||||
wlr_scene_node_set_position(&view->scene_tree->node, view->lx, view->ly);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
17
xdg_shell.c
17
xdg_shell.c
|
|
@ -195,12 +195,27 @@ handle_xdg_shell_surface_map(struct wl_listener *listener, void *data)
|
|||
view_map(view, xdg_shell_view->xdg_toplevel->base->surface);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!xdg_shell_view->xdg_toplevel->base->initial_commit) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* When an xdg_surface performs an initial commit, the compositor must
|
||||
* reply with a configure so the client can map the surface. */
|
||||
view_position(&xdg_shell_view->view);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_xdg_shell_surface_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, destroy);
|
||||
struct cg_view *view = &xdg_shell_view->view;
|
||||
|
||||
wl_list_remove(&xdg_shell_view->commit.link);
|
||||
wl_list_remove(&xdg_shell_view->map.link);
|
||||
wl_list_remove(&xdg_shell_view->unmap.link);
|
||||
wl_list_remove(&xdg_shell_view->destroy.link);
|
||||
|
|
@ -235,6 +250,8 @@ handle_new_xdg_toplevel(struct wl_listener *listener, void *data)
|
|||
view_init(&xdg_shell_view->view, server, CAGE_XDG_SHELL_VIEW, &xdg_shell_view_impl);
|
||||
xdg_shell_view->xdg_toplevel = toplevel;
|
||||
|
||||
xdg_shell_view->commit.notify = handle_xdg_shell_surface_commit;
|
||||
wl_signal_add(&toplevel->base->surface->events.commit, &xdg_shell_view->commit);
|
||||
xdg_shell_view->map.notify = handle_xdg_shell_surface_map;
|
||||
wl_signal_add(&toplevel->base->surface->events.map, &xdg_shell_view->map);
|
||||
xdg_shell_view->unmap.notify = handle_xdg_shell_surface_unmap;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ struct cg_xdg_shell_view {
|
|||
struct wlr_xdg_toplevel *xdg_toplevel;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener commit;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener map;
|
||||
struct wl_listener request_fullscreen;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue