From a776ecbb860608e0f75430a53ea75a6ed19ac746 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 30 Mar 2018 13:18:50 -0400 Subject: Add lite damage tracking This skips the renderer if nothing has changed, and renders everything otherwise. --- sway/desktop/xwayland.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'sway/desktop/xwayland.c') diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index dfc54e86..79c675a0 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -14,10 +14,10 @@ #include "sway/input/input-manager.h" #include "log.h" - static bool assert_xwayland(struct sway_view *view) { - return sway_assert(view->type == SWAY_XWAYLAND_VIEW && view->wlr_xwayland_surface, - "Expected xwayland view!"); - } +static bool assert_xwayland(struct sway_view *view) { + return sway_assert(view->type == SWAY_XWAYLAND_VIEW, + "Expected xwayland view!"); +} static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { if (!assert_xwayland(view)) { @@ -99,6 +99,7 @@ static void handle_commit(struct wl_listener *listener, void *data) { // TODO: Let floating views do whatever view->width = sway_surface->pending_width; view->height = sway_surface->pending_height; + view_damage_from(view); } static void handle_destroy(struct wl_listener *listener, void *data) { @@ -117,7 +118,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_unmap(struct wl_listener *listener, void *data) { struct sway_xwayland_surface *sway_surface = wl_container_of(listener, sway_surface, unmap); - + view_damage_whole(sway_surface->view); wl_list_remove(&sway_surface->view->unmanaged_view_link); wl_list_init(&sway_surface->view->unmanaged_view_link); container_view_destroy(sway_surface->view->swayc); @@ -150,6 +151,8 @@ static void handle_map(struct wl_listener *listener, void *data) { arrange_windows(cont->parent, -1, -1); sway_input_manager_set_focus(input_manager, cont); } + + view_damage_whole(sway_surface->view); } static void handle_configure_request(struct wl_listener *listener, void *data) { -- cgit v1.2.3 From 139f80b0f03cd772e408604203df81f285ca3f67 Mon Sep 17 00:00:00 2001 From: emersion Date: Fri, 30 Mar 2018 17:43:43 -0400 Subject: Handle map/unmap events in xdg-shell-v6 --- include/sway/tree/view.h | 4 +++- sway/desktop/xdg_shell_v6.c | 44 ++++++++++++++++++++++++++++++++++---------- sway/desktop/xwayland.c | 2 -- 3 files changed, 37 insertions(+), 13 deletions(-) (limited to 'sway/desktop/xwayland.c') 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); -- cgit v1.2.3