From 839c3a550043fd38096a15ff8dcd7de1a084efdc Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 3 Jul 2018 17:29:23 +1000 Subject: Use opaque region to determine if frame done should be sent --- swaylock/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'swaylock/main.c') 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) { wl_surface_commit(surface->surface); } +static bool image_is_opaque(cairo_surface_t *image) { + return cairo_surface_get_content(image) == CAIRO_CONTENT_COLOR; +} + static void layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *layer_surface, uint32_t serial, uint32_t width, uint32_t height) { struct swaylock_surface *surface = data; surface->width = width; surface->height = height; + + if (image_is_opaque(surface->image) && + surface->state->args.mode != BACKGROUND_MODE_CENTER && + surface->state->args.mode != BACKGROUND_MODE_FIT) { + struct wl_region *region = + wl_compositor_create_region(surface->state->compositor); + wl_region_add(region, 0, 0, width, height); + wl_surface_set_opaque_region(surface->surface, region); + wl_region_destroy(region); + } + zwlr_layer_surface_v1_ack_configure(layer_surface, serial); render_frame(surface); } -- cgit v1.2.3 From 58b2c8ed142ded772382ae7811a217a5590b0c1c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 3 Jul 2018 18:15:02 +1000 Subject: Use infinite opaque region in swaylock --- swaylock/main.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'swaylock/main.c') diff --git a/swaylock/main.c b/swaylock/main.c index a7a68e9b..a2a8a36e 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -84,6 +84,10 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener; static cairo_surface_t *select_image(struct swaylock_state *state, struct swaylock_surface *surface); +static bool image_is_opaque(cairo_surface_t *image) { + return cairo_surface_get_content(image) == CAIRO_CONTENT_COLOR; +} + static void create_layer_surface(struct swaylock_surface *surface) { struct swaylock_state *state = surface->state; @@ -108,30 +112,26 @@ static void create_layer_surface(struct swaylock_surface *surface) { surface->layer_surface, true); zwlr_layer_surface_v1_add_listener(surface->layer_surface, &layer_surface_listener, surface); - wl_surface_commit(surface->surface); -} - -static bool image_is_opaque(cairo_surface_t *image) { - return cairo_surface_get_content(image) == CAIRO_CONTENT_COLOR; -} - -static void layer_surface_configure(void *data, - struct zwlr_layer_surface_v1 *layer_surface, - uint32_t serial, uint32_t width, uint32_t height) { - struct swaylock_surface *surface = data; - surface->width = width; - surface->height = height; if (image_is_opaque(surface->image) && surface->state->args.mode != BACKGROUND_MODE_CENTER && surface->state->args.mode != BACKGROUND_MODE_FIT) { struct wl_region *region = wl_compositor_create_region(surface->state->compositor); - wl_region_add(region, 0, 0, width, height); + wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX); wl_surface_set_opaque_region(surface->surface, region); wl_region_destroy(region); } + wl_surface_commit(surface->surface); +} + +static void layer_surface_configure(void *data, + struct zwlr_layer_surface_v1 *layer_surface, + uint32_t serial, uint32_t width, uint32_t height) { + struct swaylock_surface *surface = data; + surface->width = width; + surface->height = height; zwlr_layer_surface_v1_ack_configure(layer_surface, serial); render_frame(surface); } -- cgit v1.2.3 From 3b842f4eed7276f44b0a9154976ecfeef07aa867 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 7 Jul 2018 00:17:08 +1000 Subject: Detect opaque lockscreen when using a solid color --- sway/desktop/output.c | 2 +- swaylock/main.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'swaylock/main.c') diff --git a/sway/desktop/output.c b/sway/desktop/output.c index fa85d260..329632b6 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -934,7 +934,7 @@ bool output_has_opaque_lockscreen(struct sway_output *output, .x2 = output->swayc->current.swayc_width, .y2 = output->swayc->current.swayc_height, }; - if (pixman_region32_contains_rectangle(&wlr_surface->current->opaque, + if (pixman_region32_contains_rectangle(&wlr_surface->current.opaque, &output_box)) { return true; } diff --git a/swaylock/main.c b/swaylock/main.c index a2a8a36e..1c0cef2b 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -84,8 +84,11 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener; static cairo_surface_t *select_image(struct swaylock_state *state, struct swaylock_surface *surface); -static bool image_is_opaque(cairo_surface_t *image) { - return cairo_surface_get_content(image) == CAIRO_CONTENT_COLOR; +static bool surface_is_opaque(struct swaylock_surface *surface) { + if (surface->image) { + return cairo_surface_get_content(surface->image) == CAIRO_CONTENT_COLOR; + } + return (surface->state->args.color & 0xff) == 0xff; } static void create_layer_surface(struct swaylock_surface *surface) { @@ -113,7 +116,7 @@ static void create_layer_surface(struct swaylock_surface *surface) { zwlr_layer_surface_v1_add_listener(surface->layer_surface, &layer_surface_listener, surface); - if (image_is_opaque(surface->image) && + if (surface_is_opaque(surface) && surface->state->args.mode != BACKGROUND_MODE_CENTER && surface->state->args.mode != BACKGROUND_MODE_FIT) { struct wl_region *region = -- cgit v1.2.3