diff options
| author | Ryan Dwyer <RyanDwyer@users.noreply.github.com> | 2018-05-28 00:14:22 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-28 00:14:22 +1000 | 
| commit | 8fda41dab52656c7c4a0db9a835ae57cea994538 (patch) | |
| tree | 2b0c481616cd738e0f6ca92be9594eec7707799b /swaylock/main.c | |
| parent | 569f4e0e4c75562c38848ea0bbaeb3b2f230b1a9 (diff) | |
| parent | de32b6d52ef8cf7d477fba23f42ca054155add56 (diff) | |
| download | sway-8fda41dab52656c7c4a0db9a835ae57cea994538.tar.xz | |
Merge branch 'master' into cmd-swap
Diffstat (limited to 'swaylock/main.c')
| -rw-r--r-- | swaylock/main.c | 56 | 
1 files changed, 50 insertions, 6 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index f89f2849..591df7b4 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -131,14 +131,58 @@ static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {  	.closed = layer_surface_closed,  }; -static void handle_wl_output_geometry(void *data, struct wl_output *output, int32_t x, -		int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, -		const char *make, const char *model, int32_t transform) { +static const struct wl_callback_listener surface_frame_listener; + +static void surface_frame_handle_done(void *data, struct wl_callback *callback, +		uint32_t time) { +	struct swaylock_surface *surface = data; + +	wl_callback_destroy(callback); +	surface->frame_pending = false; + +	if (surface->dirty) { +		// Schedule a frame in case the surface is damaged again +		struct wl_callback *callback = wl_surface_frame(surface->surface); +		wl_callback_add_listener(callback, &surface_frame_listener, surface); +		surface->frame_pending = true; + +		render_frame(surface); +		surface->dirty = false; +	} +} + +static const struct wl_callback_listener surface_frame_listener = { +	.done = surface_frame_handle_done, +}; + +void damage_surface(struct swaylock_surface *surface) { +	surface->dirty = true; +	if (surface->frame_pending) { +		return; +	} + +	struct wl_callback *callback = wl_surface_frame(surface->surface); +	wl_callback_add_listener(callback, &surface_frame_listener, surface); +	surface->frame_pending = true; +	wl_surface_commit(surface->surface); +} + +void damage_state(struct swaylock_state *state) { +	struct swaylock_surface *surface; +	wl_list_for_each(surface, &state->surfaces, link) { +		damage_surface(surface); +	} +} + +static void handle_wl_output_geometry(void *data, struct wl_output *output, +		int32_t x, int32_t y, int32_t width_mm, int32_t height_mm, +		int32_t subpixel, const char *make, const char *model, +		int32_t transform) {  	// Who cares  } -static void handle_wl_output_mode(void *data, struct wl_output *output, uint32_t flags, -		int32_t width, int32_t height, int32_t refresh) { +static void handle_wl_output_mode(void *data, struct wl_output *output, +		uint32_t flags, int32_t width, int32_t height, int32_t refresh) {  	// Who cares  } @@ -151,7 +195,7 @@ static void handle_wl_output_scale(void *data, struct wl_output *output,  	struct swaylock_surface *surface = data;  	surface->scale = factor;  	if (surface->state->run_display) { -		render_frames(surface->state); +		damage_surface(surface);  	}  }  | 
