Use opaque region to determine if frame done should be sent

master
Ryan Dwyer 7 years ago
parent 58befcf2cd
commit 839c3a5500

@ -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

@ -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);

@ -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);
}

Loading…
Cancel
Save