diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-10-08 12:51:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-08 12:51:42 -0400 |
commit | 8dcf3bfdf786ceb2614d4cf572ef6747cd4bb94c (patch) | |
tree | 762bde8fa6fca8e1faa342b7965ba7e44b61ab99 /rootston/wl_shell.c | |
parent | 9e1ff2dce9eded87673c8cd7eeb7e31a421f7a22 (diff) | |
parent | b72da6cc44cf19688686383065557425d55ae9ed (diff) |
Merge pull request #239 from emersion/center-views
Center views in rootston
Diffstat (limited to 'rootston/wl_shell.c')
-rw-r--r-- | rootston/wl_shell.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 55ffd2eb..eb977367 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -49,6 +49,17 @@ static void handle_request_resize(struct wl_listener *listener, void *data) { view_begin_resize(input, event->cursor, view, e->edges); } +static void handle_surface_commit(struct wl_listener *listener, void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, surface_commit); + struct roots_view *view = roots_surface->view; + + if (view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL && + !roots_surface->initialized) { + roots_surface->initialized = view_initialize(view); + } +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); @@ -73,7 +84,9 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = calloc(1, sizeof(struct roots_wl_shell_surface)); - // TODO: all of the trimmings + if (!roots_surface) { + return; + } wl_list_init(&roots_surface->destroy.link); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); @@ -83,9 +96,14 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { wl_signal_add(&surface->events.request_move, &roots_surface->request_move); wl_list_init(&roots_surface->request_resize.link); roots_surface->request_resize.notify = handle_request_resize; - wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize); + wl_signal_add(&surface->events.request_resize, + &roots_surface->request_resize); wl_list_init(&roots_surface->request_set_fullscreen.link); wl_list_init(&roots_surface->request_set_maximized.link); + wl_list_init(&roots_surface->surface_commit.link); + roots_surface->surface_commit.notify = handle_surface_commit; + wl_signal_add(&surface->surface->signals.commit, + &roots_surface->surface_commit); struct roots_view *view = calloc(1, sizeof(struct roots_view)); view->type = ROOTS_WL_SHELL_VIEW; |