diff options
-rw-r--r-- | include/sway/tree/view.h | 4 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 44 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 |
3 files changed, 37 insertions, 13 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 526a8485..3965d2b7 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -15,6 +15,8 @@ struct sway_xdg_surface_v6 { struct wl_listener request_move; struct wl_listener request_resize; struct wl_listener request_maximize; + struct wl_listener map; + struct wl_listener unmap; struct wl_listener destroy; int pending_width, pending_height; @@ -28,8 +30,8 @@ struct sway_xwayland_surface { struct wl_listener request_resize; struct wl_listener request_maximize; struct wl_listener request_configure; - struct wl_listener unmap; struct wl_listener map; + struct wl_listener unmap; struct wl_listener destroy; int pending_width, pending_height; diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 68abc120..713437f2 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c @@ -79,6 +79,34 @@ static void handle_commit(struct wl_listener *listener, void *data) { view_damage_from(view); } +static void handle_unmap(struct wl_listener *listener, void *data) { + struct sway_xdg_surface_v6 *sway_surface = + wl_container_of(listener, sway_surface, unmap); + view_damage_whole(sway_surface->view); + container_view_destroy(sway_surface->view->swayc); + sway_surface->view->swayc = NULL; + sway_surface->view->surface = NULL; +} + +static void handle_map(struct wl_listener *listener, void *data) { + struct sway_xdg_surface_v6 *sway_surface = + wl_container_of(listener, sway_surface, map); + struct sway_view *view = sway_surface->view; + + sway_surface->view->surface = view->wlr_xdg_surface_v6->surface; + + container_view_destroy(view->swayc); + + struct sway_seat *seat = input_manager_current_seat(input_manager); + struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); + struct sway_container *cont = container_view_create(focus, view); + view->swayc = cont; + arrange_windows(cont->parent, -1, -1); + sway_input_manager_set_focus(input_manager, cont); + + view_damage_whole(sway_surface->view); +} + static void handle_destroy(struct wl_listener *listener, void *data) { struct sway_xdg_surface_v6 *sway_xdg_surface = wl_container_of(listener, sway_xdg_surface, destroy); @@ -122,7 +150,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { sway_view->iface.close = close; sway_view->wlr_xdg_surface_v6 = xdg_surface; sway_view->sway_xdg_surface_v6 = sway_surface; - sway_view->surface = xdg_surface->surface; sway_surface->view = sway_view; // TODO: @@ -133,15 +160,12 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { sway_surface->commit.notify = handle_commit; wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit); - sway_surface->destroy.notify = handle_destroy; - wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); - - struct sway_seat *seat = input_manager_current_seat(input_manager); - struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); - struct sway_container *cont = container_view_create(focus, sway_view); - sway_view->swayc = cont; + sway_surface->map.notify = handle_map; + wl_signal_add(&xdg_surface->events.map, &sway_surface->map); - arrange_windows(cont->parent, -1, -1); + sway_surface->unmap.notify = handle_unmap; + wl_signal_add(&xdg_surface->events.unmap, &sway_surface->unmap); - sway_input_manager_set_focus(input_manager, cont); + sway_surface->destroy.notify = handle_destroy; + wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); } diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 79c675a0..01c993b3 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -127,7 +127,6 @@ static void handle_unmap(struct wl_listener *listener, void *data) { } static void handle_map(struct wl_listener *listener, void *data) { - // TODO put the view back into the tree struct sway_xwayland_surface *sway_surface = wl_container_of(listener, sway_surface, map); struct wlr_xwayland_surface *xsurface = data; @@ -193,7 +192,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { sway_view->iface.close = close_view; sway_view->wlr_xwayland_surface = xsurface; sway_view->sway_xwayland_surface = sway_surface; - sway_view->surface = xsurface->surface; sway_surface->view = sway_view; wl_list_init(&sway_view->unmanaged_view_link); |