aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-10-06 14:49:33 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-10-07 11:07:29 +1000
commit1059e173f4c0139e909c7d8b5d450f30c0adad0e (patch)
treef14474b2d5118151129593443e5f8f785c3f6ab0 /sway/tree
parent8393266eb5ab046d591595593d8966fa3c791bd5 (diff)
downloadsway-1059e173f4c0139e909c7d8b5d450f30c0adad0e.tar.xz
Only damage popups when popups have damage
The previous behaviour was to damage the entire view, which would recurse into each popup. This patch makes it damage only the popup's surface, and respect the surface damage given by the client. This adds listeners to the popup's map and unmap events rather than doing the damage in the create and destroy functions. To get the popup's position relative to the view, a new child_impl function get_root_coords has been introduced, which traverses up the parents.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/view.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 73ce55ac..50d25c4f 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -15,6 +15,7 @@
#include "log.h"
#include "sway/criteria.h"
#include "sway/commands.h"
+#include "sway/desktop.h"
#include "sway/desktop/transaction.h"
#include "sway/input/cursor.h"
#include "sway/ipc-server.h"
@@ -639,12 +640,18 @@ static void view_subsurface_create(struct sway_view *view,
view_child_init(child, NULL, view, subsurface->surface);
}
+static void view_child_damage(struct sway_view_child *child, bool whole) {
+ int sx, sy;
+ child->impl->get_root_coords(child, &sx, &sy);
+ desktop_damage_surface(child->surface,
+ child->view->x + sx, child->view->y + sy, whole);
+}
+
static void view_child_handle_surface_commit(struct wl_listener *listener,
void *data) {
struct sway_view_child *child =
wl_container_of(listener, child, surface_commit);
- // TODO: only accumulate damage from the child
- view_damage_from(child->view);
+ view_child_damage(child, false);
}
static void view_child_handle_surface_new_subsurface(
@@ -677,6 +684,20 @@ static void view_init_subsurfaces(struct sway_view *view,
}
}
+static void view_child_handle_surface_map(struct wl_listener *listener,
+ void *data) {
+ struct sway_view_child *child =
+ wl_container_of(listener, child, surface_map);
+ view_child_damage(child, true);
+}
+
+static void view_child_handle_surface_unmap(struct wl_listener *listener,
+ void *data) {
+ struct sway_view_child *child =
+ wl_container_of(listener, child, surface_unmap);
+ view_child_damage(child, true);
+}
+
void view_child_init(struct sway_view_child *child,
const struct sway_view_child_impl *impl, struct sway_view *view,
struct wlr_surface *surface) {
@@ -692,6 +713,10 @@ void view_child_init(struct sway_view_child *child,
view_child_handle_surface_new_subsurface;
wl_signal_add(&surface->events.destroy, &child->surface_destroy);
child->surface_destroy.notify = view_child_handle_surface_destroy;
+
+ child->surface_map.notify = view_child_handle_surface_map;
+ child->surface_unmap.notify = view_child_handle_surface_unmap;
+
wl_signal_add(&view->events.unmap, &child->view_unmap);
child->view_unmap.notify = view_child_handle_view_unmap;
@@ -699,15 +724,9 @@ void view_child_init(struct sway_view_child *child,
wlr_surface_send_enter(child->surface, output->wlr_output);
view_init_subsurfaces(child->view, surface);
-
- // TODO: only damage the whole child
- container_damage_whole(child->view->container);
}
void view_child_destroy(struct sway_view_child *child) {
- // TODO: only damage the whole child
- container_damage_whole(child->view->container);
-
wl_list_remove(&child->surface_commit.link);
wl_list_remove(&child->surface_destroy.link);
wl_list_remove(&child->view_unmap.link);