summaryrefslogtreecommitdiffstats
path: root/swaylock/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaylock/main.c')
-rw-r--r--swaylock/main.c56
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 = {
131 .closed = layer_surface_closed, 131 .closed = layer_surface_closed,
132}; 132};
133 133
134static void handle_wl_output_geometry(void *data, struct wl_output *output, int32_t x, 134static const struct wl_callback_listener surface_frame_listener;
135 int32_t y, int32_t width_mm, int32_t height_mm, int32_t subpixel, 135
136 const char *make, const char *model, int32_t transform) { 136static void surface_frame_handle_done(void *data, struct wl_callback *callback,
137 uint32_t time) {
138 struct swaylock_surface *surface = data;
139
140 wl_callback_destroy(callback);
141 surface->frame_pending = false;
142
143 if (surface->dirty) {
144 // Schedule a frame in case the surface is damaged again
145 struct wl_callback *callback = wl_surface_frame(surface->surface);
146 wl_callback_add_listener(callback, &surface_frame_listener, surface);
147 surface->frame_pending = true;
148
149 render_frame(surface);
150 surface->dirty = false;
151 }
152}
153
154static const struct wl_callback_listener surface_frame_listener = {
155 .done = surface_frame_handle_done,
156};
157
158void damage_surface(struct swaylock_surface *surface) {
159 surface->dirty = true;
160 if (surface->frame_pending) {
161 return;
162 }
163
164 struct wl_callback *callback = wl_surface_frame(surface->surface);
165 wl_callback_add_listener(callback, &surface_frame_listener, surface);
166 surface->frame_pending = true;
167 wl_surface_commit(surface->surface);
168}
169
170void damage_state(struct swaylock_state *state) {
171 struct swaylock_surface *surface;
172 wl_list_for_each(surface, &state->surfaces, link) {
173 damage_surface(surface);
174 }
175}
176
177static void handle_wl_output_geometry(void *data, struct wl_output *output,
178 int32_t x, int32_t y, int32_t width_mm, int32_t height_mm,
179 int32_t subpixel, const char *make, const char *model,
180 int32_t transform) {
137 // Who cares 181 // Who cares
138} 182}
139 183
140static void handle_wl_output_mode(void *data, struct wl_output *output, uint32_t flags, 184static void handle_wl_output_mode(void *data, struct wl_output *output,
141 int32_t width, int32_t height, int32_t refresh) { 185 uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
142 // Who cares 186 // Who cares
143} 187}
144 188
@@ -151,7 +195,7 @@ static void handle_wl_output_scale(void *data, struct wl_output *output,
151 struct swaylock_surface *surface = data; 195 struct swaylock_surface *surface = data;
152 surface->scale = factor; 196 surface->scale = factor;
153 if (surface->state->run_display) { 197 if (surface->state->run_display) {
154 render_frames(surface->state); 198 damage_surface(surface);
155 } 199 }
156} 200}
157 201