From 1c91d0c10ffbed14cafaba79276a14f55172b7eb Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 5 Apr 2018 17:37:24 -0400 Subject: [PATCH] Add damage tracking for xwayland unmanaged surfaces --- include/sway/desktop.h | 7 +++++++ include/sway/output.h | 3 +++ sway/desktop/desktop.c | 20 ++++++++++++++++++++ sway/desktop/output.c | 6 ++++++ sway/desktop/xwayland.c | 22 +++++++++++++--------- sway/meson.build | 1 + 6 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 include/sway/desktop.h create mode 100644 sway/desktop/desktop.c diff --git a/include/sway/desktop.h b/include/sway/desktop.h new file mode 100644 index 000000000..96bdc94cc --- /dev/null +++ b/include/sway/desktop.h @@ -0,0 +1,7 @@ +#include + +void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, + double ly); + +void desktop_damage_from_surface(struct wlr_surface *surface, double lx, + double ly); diff --git a/include/sway/output.h b/include/sway/output.h index 98d0f83f2..9964a484c 100644 --- a/include/sway/output.h +++ b/include/sway/output.h @@ -37,6 +37,9 @@ void output_damage_whole(struct sway_output *output); void output_damage_whole_view(struct sway_output *output, struct sway_view *view); +void output_damage_whole_surface(struct sway_output *output, + struct wlr_surface *surface, double ox, double oy); + struct sway_container *output_by_name(const char *name); #endif diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c new file mode 100644 index 000000000..78a2d49fd --- /dev/null +++ b/sway/desktop/desktop.c @@ -0,0 +1,20 @@ +#include "sway/tree/container.h" +#include "sway/desktop.h" +#include "sway/output.h" + +void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, + double ly) { + for (int i = 0; i < root_container.children->length; ++i) { + struct sway_container *cont = root_container.children->items[i]; + if (cont->type == C_OUTPUT) { + output_damage_whole_surface(cont->sway_output, surface, + lx - cont->x, ly - cont->y); + } + } +} + +void desktop_damage_from_surface(struct wlr_surface *surface, double lx, + double ly) { + // TODO + desktop_damage_whole_surface(surface, lx, ly); +} diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 0e8a94858..0ae5e7822 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -341,6 +341,12 @@ void output_damage_whole_view(struct sway_output *output, output_damage_whole(output); } +void output_damage_whole_surface(struct sway_output *output, + struct wlr_surface *surface, double ox, double oy) { + // TODO + output_damage_whole(output); +} + static void damage_handle_destroy(struct wl_listener *listener, void *data) { struct sway_output *output = wl_container_of(listener, output, damage_destroy); diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 3842c2c85..4797b8011 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c @@ -2,17 +2,18 @@ #include #include #include -#include #include #include +#include +#include "log.h" +#include "sway/desktop.h" +#include "sway/input/input-manager.h" +#include "sway/input/seat.h" +#include "sway/output.h" +#include "sway/server.h" #include "sway/tree/container.h" #include "sway/tree/layout.h" -#include "sway/server.h" #include "sway/tree/view.h" -#include "sway/output.h" -#include "sway/input/seat.h" -#include "sway/input/input-manager.h" -#include "log.h" static void unmanaged_handle_request_configure(struct wl_listener *listener, void *data) { @@ -27,7 +28,9 @@ static void unmanaged_handle_request_configure(struct wl_listener *listener, static void unmanaged_handle_commit(struct wl_listener *listener, void *data) { struct sway_xwayland_unmanaged *surface = wl_container_of(listener, surface, commit); - // TODO: damage tracking + struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; + desktop_damage_from_surface(xsurface->surface, xsurface->x, xsurface->y); + // TODO: handle window motion } static void unmanaged_handle_map(struct wl_listener *listener, void *data) { @@ -38,15 +41,16 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) { &surface->link); wl_signal_add(&xsurface->surface->events.commit, &surface->commit); surface->commit.notify = unmanaged_handle_commit; - // TODO: damage tracking + desktop_damage_whole_surface(xsurface->surface, xsurface->x, xsurface->y); } static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) { struct sway_xwayland_unmanaged *surface = wl_container_of(listener, surface, unmap); + struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; + desktop_damage_whole_surface(xsurface->surface, xsurface->x, xsurface->y); wl_list_remove(&surface->link); wl_list_remove(&surface->commit.link); - // TODO: damage tracking } static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) { diff --git a/sway/meson.build b/sway/meson.build index ec7b4c42b..29aaa7b71 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -8,6 +8,7 @@ sway_sources = files( 'ipc-server.c', 'security.c', + 'desktop/desktop.c', 'desktop/output.c', 'desktop/layer_shell.c', 'desktop/wl_shell.c',