aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-04-06 11:27:40 -0400
committerLibravatar emersion <contact@emersion.fr>2018-04-06 11:45:40 -0400
commit516f5454adb3fc7dd2e02258251b7cb6d6949aa3 (patch)
tree22c6bdfa1f79224daca6403162d24acdf611a6f9 /sway/desktop
parentMerge pull request #1755 from emersion/view-child-hidpi (diff)
downloadsway-516f5454adb3fc7dd2e02258251b7cb6d6949aa3.tar.gz
sway-516f5454adb3fc7dd2e02258251b7cb6d6949aa3.tar.zst
sway-516f5454adb3fc7dd2e02258251b7cb6d6949aa3.zip
Simplify damage tracking functions, use them in layer shell
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/desktop.c14
-rw-r--r--sway/desktop/layer_shell.c44
-rw-r--r--sway/desktop/output.c8
-rw-r--r--sway/desktop/wl_shell.c2
-rw-r--r--sway/desktop/xdg_shell_v6.c2
-rw-r--r--sway/desktop/xwayland.c18
6 files changed, 45 insertions, 43 deletions
diff --git a/sway/desktop/desktop.c b/sway/desktop/desktop.c
index 3a13191f..66f33151 100644
--- a/sway/desktop/desktop.c
+++ b/sway/desktop/desktop.c
@@ -2,19 +2,13 @@
2#include "sway/desktop.h" 2#include "sway/desktop.h"
3#include "sway/output.h" 3#include "sway/output.h"
4 4
5void desktop_damage_whole_surface(struct wlr_surface *surface, double lx, 5void desktop_damage_surface(struct wlr_surface *surface, double lx, double ly,
6 double ly) { 6 bool whole) {
7 for (int i = 0; i < root_container.children->length; ++i) { 7 for (int i = 0; i < root_container.children->length; ++i) {
8 struct sway_container *cont = root_container.children->items[i]; 8 struct sway_container *cont = root_container.children->items[i];
9 if (cont->type == C_OUTPUT) { 9 if (cont->type == C_OUTPUT) {
10 output_damage_whole_surface(cont->sway_output, 10 output_damage_surface(cont->sway_output, lx - cont->x, ly - cont->y,
11 lx - cont->x, ly - cont->y, surface); 11 surface, whole);
12 } 12 }
13 } 13 }
14} 14}
15
16void desktop_damage_from_surface(struct wlr_surface *surface, double lx,
17 double ly) {
18 // TODO
19 desktop_damage_whole_surface(surface, lx, ly);
20}
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index 663ec7ba..f841e5f1 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -229,33 +229,39 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
229 wl_container_of(listener, layer, surface_commit); 229 wl_container_of(listener, layer, surface_commit);
230 struct wlr_layer_surface *layer_surface = layer->layer_surface; 230 struct wlr_layer_surface *layer_surface = layer->layer_surface;
231 struct wlr_output *wlr_output = layer_surface->output; 231 struct wlr_output *wlr_output = layer_surface->output;
232 if (wlr_output != NULL) { 232 if (wlr_output == NULL) {
233 struct sway_output *output = wlr_output->data; 233 return;
234 struct wlr_box old_geo = layer->geo; 234 }
235 arrange_layers(output); 235
236 if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) { 236 struct sway_output *output = wlr_output->data;
237 // TODO DAMAGE apply whole surface from previous and new geos 237 struct wlr_box old_geo = layer->geo;
238 } else { 238 arrange_layers(output);
239 // TODO DAMAGE from surface damage 239 if (memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0) {
240 } 240 output_damage_surface(output, old_geo.x, old_geo.y,
241 wlr_output_damage_add_box(output->damage, &old_geo); 241 layer_surface->surface, true);
242 wlr_output_damage_add_box(output->damage, &layer->geo); 242 output_damage_surface(output, layer->geo.x, layer->geo.y,
243 layer_surface->surface, true);
244 } else {
245 output_damage_surface(output, layer->geo.x, layer->geo.y,
246 layer_surface->surface, false);
243 } 247 }
244} 248}
245 249
246static void unmap(struct sway_layer_surface *sway_layer) { 250static void unmap(struct sway_layer_surface *sway_layer) {
247 struct wlr_output *wlr_output = sway_layer->layer_surface->output; 251 struct wlr_output *wlr_output = sway_layer->layer_surface->output;
248 if (wlr_output != NULL) { 252 if (wlr_output == NULL) {
249 struct sway_output *output = wlr_output->data; 253 return;
250 wlr_output_damage_add_box(output->damage, &sway_layer->geo);
251 } 254 }
255 struct sway_output *output = wlr_output->data;
256 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
257 sway_layer->layer_surface->surface, true);
252} 258}
253 259
254static void handle_destroy(struct wl_listener *listener, void *data) { 260static void handle_destroy(struct wl_listener *listener, void *data) {
255 struct sway_layer_surface *sway_layer = wl_container_of(listener, 261 struct sway_layer_surface *sway_layer =
256 sway_layer, destroy); 262 wl_container_of(listener, sway_layer, destroy);
257 wlr_log(L_DEBUG, "Layer surface destroyed (%s)", 263 wlr_log(L_DEBUG, "Layer surface destroyed (%s)",
258 sway_layer->layer_surface->namespace); 264 sway_layer->layer_surface->namespace);
259 if (sway_layer->layer_surface->mapped) { 265 if (sway_layer->layer_surface->mapped) {
260 unmap(sway_layer); 266 unmap(sway_layer);
261 } 267 }
@@ -277,7 +283,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
277 struct sway_layer_surface *sway_layer = wl_container_of(listener, 283 struct sway_layer_surface *sway_layer = wl_container_of(listener,
278 sway_layer, map); 284 sway_layer, map);
279 struct sway_output *output = sway_layer->layer_surface->output->data; 285 struct sway_output *output = sway_layer->layer_surface->output->data;
280 wlr_output_damage_add_box(output->damage, &sway_layer->geo); 286 output_damage_surface(output, sway_layer->geo.x, sway_layer->geo.y,
287 sway_layer->layer_surface->surface, true);
288 // TODO: send enter to subsurfaces and popups
281 wlr_surface_send_enter(sway_layer->layer_surface->surface, 289 wlr_surface_send_enter(sway_layer->layer_surface->surface,
282 sway_layer->layer_surface->output); 290 sway_layer->layer_surface->output);
283} 291}
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index aa18f1b8..3bbd0bb2 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -332,14 +332,14 @@ void output_damage_whole(struct sway_output *output) {
332 wlr_output_damage_add_whole(output->damage); 332 wlr_output_damage_add_whole(output->damage);
333} 333}
334 334
335void output_damage_whole_surface(struct sway_output *output, 335void output_damage_surface(struct sway_output *output, double ox, double oy,
336 double ox, double oy, struct wlr_surface *surface) { 336 struct wlr_surface *surface, bool whole) {
337 // TODO 337 // TODO
338 output_damage_whole(output); 338 output_damage_whole(output);
339} 339}
340 340
341void output_damage_whole_view(struct sway_output *output, 341void output_damage_view(struct sway_output *output, struct sway_view *view,
342 struct sway_view *view) { 342 bool whole) {
343 // TODO 343 // TODO
344 output_damage_whole(output); 344 output_damage_whole(output);
345} 345}
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index fff31da8..b63c220c 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -79,7 +79,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
79 // TODO: Let floating views do whatever 79 // TODO: Let floating views do whatever
80 view_update_size(view, wl_shell_view->pending_width, 80 view_update_size(view, wl_shell_view->pending_width,
81 wl_shell_view->pending_height); 81 wl_shell_view->pending_height);
82 view_damage_from(view); 82 view_damage(view, false);
83} 83}
84 84
85static void handle_destroy(struct wl_listener *listener, void *data) { 85static void handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 8361aab3..b82eec8f 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -169,7 +169,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
169 // TODO: Let floating views do whatever 169 // TODO: Let floating views do whatever
170 view_update_size(view, xdg_shell_v6_view->pending_width, 170 view_update_size(view, xdg_shell_v6_view->pending_width,
171 xdg_shell_v6_view->pending_height); 171 xdg_shell_v6_view->pending_height);
172 view_damage_from(view); 172 view_damage(view, false);
173} 173}
174 174
175static void handle_new_popup(struct wl_listener *listener, void *data) { 175static void handle_new_popup(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 10bfcc89..6de1365d 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -32,15 +32,15 @@ static void unmanaged_handle_commit(struct wl_listener *listener, void *data) {
32 32
33 if (xsurface->x != surface->lx || xsurface->y != surface->ly) { 33 if (xsurface->x != surface->lx || xsurface->y != surface->ly) {
34 // Surface has moved 34 // Surface has moved
35 desktop_damage_whole_surface(xsurface->surface, 35 desktop_damage_surface(xsurface->surface, surface->lx, surface->ly,
36 surface->lx, surface->ly); 36 true);
37 surface->lx = xsurface->x; 37 surface->lx = xsurface->x;
38 surface->ly = xsurface->y; 38 surface->ly = xsurface->y;
39 desktop_damage_whole_surface(xsurface->surface, 39 desktop_damage_surface(xsurface->surface, surface->lx, surface->ly,
40 surface->lx, surface->ly); 40 true);
41 } else { 41 } else {
42 desktop_damage_from_surface(xsurface->surface, 42 desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y,
43 xsurface->x, xsurface->y); 43 false);
44 } 44 }
45} 45}
46 46
@@ -57,7 +57,7 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
57 57
58 surface->lx = xsurface->x; 58 surface->lx = xsurface->x;
59 surface->ly = xsurface->y; 59 surface->ly = xsurface->y;
60 desktop_damage_whole_surface(xsurface->surface, surface->lx, surface->ly); 60 desktop_damage_surface(xsurface->surface, surface->lx, surface->ly, true);
61 61
62 // TODO: we don't send surface enter/leave events to xwayland unmanaged 62 // TODO: we don't send surface enter/leave events to xwayland unmanaged
63 // surfaces, but xwayland doesn't support HiDPI anyway 63 // surfaces, but xwayland doesn't support HiDPI anyway
@@ -67,7 +67,7 @@ static void unmanaged_handle_unmap(struct wl_listener *listener, void *data) {
67 struct sway_xwayland_unmanaged *surface = 67 struct sway_xwayland_unmanaged *surface =
68 wl_container_of(listener, surface, unmap); 68 wl_container_of(listener, surface, unmap);
69 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface; 69 struct wlr_xwayland_surface *xsurface = surface->wlr_xwayland_surface;
70 desktop_damage_whole_surface(xsurface->surface, xsurface->x, xsurface->y); 70 desktop_damage_surface(xsurface->surface, xsurface->x, xsurface->y, true);
71 wl_list_remove(&surface->link); 71 wl_list_remove(&surface->link);
72 wl_list_remove(&surface->commit.link); 72 wl_list_remove(&surface->commit.link);
73} 73}
@@ -209,7 +209,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
209 // TODO: Let floating views do whatever 209 // TODO: Let floating views do whatever
210 view_update_size(view, xwayland_view->pending_width, 210 view_update_size(view, xwayland_view->pending_width,
211 xwayland_view->pending_height); 211 xwayland_view->pending_height);
212 view_damage_from(view); 212 view_damage(view, false);
213} 213}
214 214
215static void handle_unmap(struct wl_listener *listener, void *data) { 215static void handle_unmap(struct wl_listener *listener, void *data) {