aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sway/output.h4
-rw-r--r--sway/desktop/output.c35
-rw-r--r--swaylock/main.c15
3 files changed, 52 insertions, 2 deletions
diff --git a/include/sway/output.h b/include/sway/output.h
index 19fc5e99..e6fe55c6 100644
--- a/include/sway/output.h
+++ b/include/sway/output.h
@@ -54,4 +54,8 @@ void output_damage_whole_container(struct sway_output *output,
struct sway_container *output_by_name(const char *name);
void output_enable(struct sway_output *output);
+
+bool output_has_opaque_lockscreen(struct sway_output *output,
+ struct sway_seat *seat);
+
#endif
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 52bd1666..a6b2ebc2 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -915,6 +915,36 @@ static struct sway_container *output_get_active_workspace(
return workspace;
}
+bool output_has_opaque_lockscreen(struct sway_output *output,
+ struct sway_seat *seat) {
+ if (!seat->exclusive_client) {
+ return false;
+ }
+
+ struct wlr_layer_surface *wlr_layer_surface;
+ wl_list_for_each(wlr_layer_surface, &server.layer_shell->surfaces, link) {
+ if (wlr_layer_surface->output != output->wlr_output) {
+ continue;
+ }
+ struct wlr_surface *wlr_surface = wlr_layer_surface->surface;
+ if (wlr_surface->resource->client != seat->exclusive_client) {
+ continue;
+ }
+ int nrects;
+ pixman_box32_t *rects =
+ pixman_region32_rectangles(&wlr_surface->current->opaque, &nrects);
+ for (int i = 0; i < nrects; ++i) {
+ pixman_box32_t *rect = &rects[i];
+ if (rect->x1 <= 0 && rect->y1 <= 0 &&
+ rect->x2 >= output->swayc->current.swayc_width &&
+ rect->y2 >= output->swayc->current.swayc_height) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
static void render_output(struct sway_output *output, struct timespec *when,
pixman_region32_t *damage) {
struct wlr_output *wlr_output = output->wlr_output;
@@ -950,7 +980,7 @@ static void render_output(struct sway_output *output, struct timespec *when,
struct sway_view *fullscreen_view = workspace->current.ws_fullscreen;
struct sway_seat *seat = input_manager_current_seat(input_manager);
- if (seat->exclusive_client && seat->focused_layer) {
+ if (output_has_opaque_lockscreen(output, seat)) {
float clear_color[] = {0.0f, 0.0f, 0.0f, 1.0f};
int nrects;
@@ -1103,7 +1133,8 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) {
struct send_frame_done_data data = {
.output = output,
.when = when,
- .exclusive_client = seat->exclusive_client,
+ .exclusive_client = output_has_opaque_lockscreen(output, seat) ?
+ seat->exclusive_client : NULL,
};
struct sway_container *workspace = output_get_active_workspace(output);
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);
}