Skip to content

Commit 99b3480

Browse files
committed
fix build
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
1 parent b6bb66e commit 99b3480

File tree

4 files changed

+30
-85
lines changed

4 files changed

+30
-85
lines changed

effects.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define _POSIX_C_SOURCE 200809
21
#define _XOPEN_SOURCE 700
32
#include <omp.h>
43
#include <limits.h>

include/swaylock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ struct swaylock_surface {
147147
struct wl_surface *surface; // surface for background
148148
struct wl_surface *child; // indicator surface made into subsurface
149149
struct wl_subsurface *subsurface;
150+
struct zwlr_screencopy_frame_v1 *screencopy_frame;
150151
struct ext_session_lock_surface_v1 *ext_session_lock_surface_v1;
151152
struct pool_buffer indicator_buffers[2];
152153
bool created;

main.c

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,6 @@ static const struct ext_session_lock_surface_v1_listener ext_session_lock_surfac
265265
static cairo_surface_t *select_image(struct swaylock_state *state,
266266
struct swaylock_surface *surface);
267267

268-
static bool surface_is_opaque(struct swaylock_surface *surface) {
269-
if (!fade_is_complete(&surface->fade)) {
270-
return false;
271-
}
272-
if (surface->image) {
273-
return cairo_surface_get_content(surface->image) == CAIRO_CONTENT_COLOR;
274-
}
275-
return (surface->state->args.colors.background & 0xff) == 0xff;
276-
}
277-
278268
static void create_surface(struct swaylock_surface *surface) {
279269
struct swaylock_state *state = surface->state;
280270

@@ -305,36 +295,14 @@ static void create_surface(struct swaylock_surface *surface) {
305295
}
306296
}
307297

308-
static void initially_render_surface(struct swaylock_surface *surface) {
309-
swaylock_log(LOG_DEBUG, "Surface for output %s ready", surface->output_name);
310-
if (surface_is_opaque(surface) &&
311-
surface->state->args.mode != BACKGROUND_MODE_CENTER &&
312-
surface->state->args.mode != BACKGROUND_MODE_FIT) {
313-
struct wl_region *region =
314-
wl_compositor_create_region(surface->state->compositor);
315-
wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX);
316-
wl_surface_set_opaque_region(surface->surface, region);
317-
wl_region_destroy(region);
318-
}
319298

320-
surface->created = true;
321-
if (!surface->state->ext_session_lock_v1) {
322-
render_frame_background(surface, true);
323-
render_frame(surface);
324-
}
325-
}
326299
static void ext_session_lock_surface_v1_handle_configure(void *data,
327300
struct ext_session_lock_surface_v1 *lock_surface, uint32_t serial,
328301
uint32_t width, uint32_t height) {
329302
struct swaylock_surface *surface = data;
330303
surface->width = width;
331304
surface->height = height;
332-
// Render before we send the ACK event, so that we minimize flickering
333-
// This means we cannot commit immediately after rendering -- we will have
334-
// to send the ACK first and then commit.
335-
render_frame_background(surface, false);
336305
ext_session_lock_surface_v1_ack_configure(lock_surface, serial);
337-
wl_surface_commit(surface->surface);
338306
surface->dirty = true;
339307
render(surface);
340308
}
@@ -370,6 +338,8 @@ static void handle_wl_output_mode(void *data, struct wl_output *output,
370338
// Who cares
371339
}
372340

341+
static const struct zwlr_screencopy_frame_v1_listener screencopy_frame_listener;
342+
373343
static void handle_wl_output_done(void *data, struct wl_output *output) {
374344
swaylock_trace();
375345
struct swaylock_surface *surface = data;
@@ -1878,12 +1848,6 @@ int main(int argc, char **argv) {
18781848
surface->events_pending += 1;
18791849
};
18801850

1881-
wl_list_for_each(surface, &state.surfaces, link) {
1882-
while (surface->events_pending > 0) {
1883-
wl_display_roundtrip(state.display);
1884-
}
1885-
}
1886-
18871851
// Must daemonize before we run any effects, since effects use openmp
18881852
int daemonfd;
18891853
if (state.args.daemonize) {
@@ -1899,20 +1863,6 @@ int main(int argc, char **argv) {
18991863
iter_image->cairo_surface, &state, 1);
19001864
}
19011865

1902-
if (state.ext_session_lock_manager_v1) {
1903-
swaylock_log(LOG_DEBUG, "Using ext-session-lock-v1");
1904-
state.ext_session_lock_v1 = ext_session_lock_manager_v1_lock(state.ext_session_lock_manager_v1);
1905-
ext_session_lock_v1_add_listener(state.ext_session_lock_v1,
1906-
&ext_session_lock_v1_listener, &state);
1907-
} else if (state.layer_shell && state.input_inhibit_manager) {
1908-
swaylock_log(LOG_DEBUG, "Using wlr-layer-shell + wlr-input-inhibitor");
1909-
zwlr_input_inhibit_manager_v1_get_inhibitor(state.input_inhibit_manager);
1910-
} else {
1911-
swaylock_log(LOG_ERROR, "Missing ext-session-lock-v1, wlr-layer-shell "
1912-
"and wlr-input-inhibitor");
1913-
return 1;
1914-
}
1915-
19161866
state.ext_session_lock_v1 = ext_session_lock_manager_v1_lock(state.ext_session_lock_manager_v1);
19171867
ext_session_lock_v1_add_listener(state.ext_session_lock_v1,
19181868
&ext_session_lock_v1_listener, &state);
@@ -1944,9 +1894,6 @@ int main(int argc, char **argv) {
19441894
close(state.args.ready_fd);
19451895
state.args.ready_fd = -1;
19461896
}
1947-
if (state.args.daemonize) {
1948-
daemonize();
1949-
}
19501897

19511898
wl_list_for_each(surface, &state.surfaces, link) {
19521899
while (surface->events_pending > 0) {

render.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ void render(struct swaylock_surface *surface) {
161161
surface->dirty = false;
162162
surface->frame = wl_surface_frame(surface->surface);
163163
wl_callback_add_listener(surface->frame, &surface_frame_listener, surface);
164-
if (commit) {
165-
wl_surface_commit(surface->surface);
166-
}
164+
wl_surface_commit(surface->surface);
167165

168166
if (need_destroy) {
169167
destroy_buffer(&buffer);
@@ -177,8 +175,7 @@ void render_background_fade(struct swaylock_surface *surface, uint32_t time) {
177175

178176
fade_update(&surface->fade, time);
179177

180-
render_frame_background(surface, true);
181-
render_frame(surface);
178+
render(surface);
182179
}
183180

184181
static void configure_font_drawing(cairo_t *cairo, struct swaylock_state *state,
@@ -210,7 +207,7 @@ static bool render_frame(struct swaylock_surface *surface) {
210207
char *text_l1 = NULL;
211208
char *text_l2 = NULL;
212209
const char *layout_text = NULL;
213-
double font_size;
210+
double font_size = 0;
214211

215212
bool draw_indicator = state->args.show_indicator &&
216213
(state->auth_state != AUTH_STATE_IDLE ||
@@ -222,7 +219,7 @@ static bool render_frame(struct swaylock_surface *surface) {
222219
// This message has highest priority
223220
text = state->args.text_cleared;
224221
} else if (state->auth_state == AUTH_STATE_VALIDATING) {
225-
text = state->args.text_verifyin;
222+
text = state->args.text_verifying;
226223
} else if (state->auth_state == AUTH_STATE_INVALID) {
227224
text = state->args.text_wrong;
228225
} else {
@@ -260,10 +257,10 @@ static bool render_frame(struct swaylock_surface *surface) {
260257
}
261258
}
262259

263-
if (text_l1 && !text_l2)
264-
text = text_l1;
265-
if (text_l2 && !text_l1)
266-
text = text_l2;
260+
if (text_l1 && !text_l2)
261+
text = text_l1;
262+
if (text_l2 && !text_l1)
263+
text = text_l2;
267264

268265
// Compute the size of the buffer needed
269266
int arc_radius = state->args.radius * surface->scale;
@@ -301,40 +298,41 @@ static bool render_frame(struct swaylock_surface *surface) {
301298

302299
/* Top */
303300

304-
cairo_text_extents(cairo, text_l1, &extents_l1);
305-
cairo_font_extents(cairo, &fe_l1);
301+
cairo_text_extents(state->test_cairo, text_l1, &extents_l1);
302+
cairo_font_extents(state->test_cairo, &fe_l1);
306303
x_l1 = (buffer_width / 2) -
307304
(extents_l1.width / 2 + extents_l1.x_bearing);
308305
y_l1 = (buffer_diameter / 2) +
309306
(fe_l1.height / 2 - fe_l1.descent) - arc_radius / 10.0f;
310307

311-
cairo_move_to(cairo, x_l1, y_l1);
312-
cairo_show_text(cairo, text_l1);
313-
cairo_close_path(cairo);
314-
cairo_new_sub_path(cairo);
308+
cairo_move_to(state->test_cairo, x_l1, y_l1);
309+
cairo_show_text(state->test_cairo, text_l1);
310+
cairo_close_path(state->test_cairo);
311+
cairo_new_sub_path(state->test_cairo);
315312

316313
/* Bottom */
317314

318-
cairo_set_font_size(cairo, arc_radius / 6.0f);
319-
cairo_text_extents(cairo, text_l2, &extents_l2);
320-
cairo_font_extents(cairo, &fe_l2);
315+
cairo_set_font_size(state->test_cairo, arc_radius / 6.0f);
316+
cairo_text_extents(state->test_cairo, text_l2, &extents_l2);
317+
cairo_font_extents(state->test_cairo, &fe_l2);
321318
x_l2 = (buffer_width / 2) -
322319
(extents_l2.width / 2 + extents_l2.x_bearing);
323320
y_l2 = (buffer_diameter / 2) +
324321
(fe_l2.height / 2 - fe_l2.descent) + arc_radius / 3.5f;
325322

326-
cairo_move_to(cairo, x_l2, y_l2);
327-
cairo_show_text(cairo, text_l2);
328-
cairo_close_path(cairo);
329-
cairo_new_sub_path(cairo);
323+
cairo_move_to(state->test_cairo, x_l2, y_l2);
324+
cairo_show_text(state->test_cairo, text_l2);
325+
cairo_close_path(state->test_cairo);
326+
cairo_new_sub_path(state->test_cairo);
330327

331-
if (new_width < extents_l1.width)
332-
new_width = extents_l1.width;
333-
if (new_width < extents_l2.width)
334-
new_width = extents_l2.width;
328+
double box_padding = 4.0 * surface->scale;
329+
if (buffer_width < extents_l1.width + 2 * box_padding)
330+
buffer_width = extents_l1.width + 2 * box_padding;
331+
if (buffer_width < extents_l2.width + 2 * box_padding)
332+
buffer_width = extents_l2.width + 2 * box_padding;
335333

336334

337-
cairo_set_font_size(cairo, font_size);
335+
cairo_set_font_size(state->test_cairo, font_size);
338336
}
339337
// Ensure buffer size is multiple of buffer scale - required by protocol
340338
buffer_height += surface->scale - (buffer_height % surface->scale);

0 commit comments

Comments
 (0)