diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-03 17:29:23 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-07 00:03:49 +1000 |
commit | 839c3a550043fd38096a15ff8dcd7de1a084efdc (patch) | |
tree | 45d1e8f64e98b4efcd2db6372f97ce74d0032a8d /swaylock/main.c | |
parent | Don't send frame done to surfaces behind lockscreen (diff) | |
download | sway-839c3a550043fd38096a15ff8dcd7de1a084efdc.tar.gz sway-839c3a550043fd38096a15ff8dcd7de1a084efdc.tar.zst sway-839c3a550043fd38096a15ff8dcd7de1a084efdc.zip |
Use opaque region to determine if frame done should be sent
Diffstat (limited to 'swaylock/main.c')
-rw-r--r-- | swaylock/main.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index f31ed679..a7a68e9b 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -111,12 +111,27 @@ static void create_layer_surface(struct swaylock_surface *surface) { | |||
111 | wl_surface_commit(surface->surface); | 111 | wl_surface_commit(surface->surface); |
112 | } | 112 | } |
113 | 113 | ||
114 | static bool image_is_opaque(cairo_surface_t *image) { | ||
115 | return cairo_surface_get_content(image) == CAIRO_CONTENT_COLOR; | ||
116 | } | ||
117 | |||
114 | static void layer_surface_configure(void *data, | 118 | static void layer_surface_configure(void *data, |
115 | struct zwlr_layer_surface_v1 *layer_surface, | 119 | struct zwlr_layer_surface_v1 *layer_surface, |
116 | uint32_t serial, uint32_t width, uint32_t height) { | 120 | uint32_t serial, uint32_t width, uint32_t height) { |
117 | struct swaylock_surface *surface = data; | 121 | struct swaylock_surface *surface = data; |
118 | surface->width = width; | 122 | surface->width = width; |
119 | surface->height = height; | 123 | surface->height = height; |
124 | |||
125 | if (image_is_opaque(surface->image) && | ||
126 | surface->state->args.mode != BACKGROUND_MODE_CENTER && | ||
127 | surface->state->args.mode != BACKGROUND_MODE_FIT) { | ||
128 | struct wl_region *region = | ||
129 | wl_compositor_create_region(surface->state->compositor); | ||
130 | wl_region_add(region, 0, 0, width, height); | ||
131 | wl_surface_set_opaque_region(surface->surface, region); | ||
132 | wl_region_destroy(region); | ||
133 | } | ||
134 | |||
120 | zwlr_layer_surface_v1_ack_configure(layer_surface, serial); | 135 | zwlr_layer_surface_v1_ack_configure(layer_surface, serial); |
121 | render_frame(surface); | 136 | render_frame(surface); |
122 | } | 137 | } |