Skip to content

Commit 70f5990

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

File tree

5 files changed

+42
-78
lines changed

5 files changed

+42
-78
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: 14 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -297,16 +297,7 @@ static void create_surface(struct swaylock_surface *surface) {
297297
state->ext_session_lock_v1, surface->surface, surface->output);
298298
ext_session_lock_surface_v1_add_listener(surface->ext_session_lock_surface_v1,
299299
&ext_session_lock_surface_v1_listener, surface);
300-
surface->events_pending += 1;
301300

302-
303-
if (!state->ext_session_lock_v1) {
304-
wl_surface_commit(surface->surface);
305-
}
306-
}
307-
308-
static void initially_render_surface(struct swaylock_surface *surface) {
309-
swaylock_log(LOG_DEBUG, "Surface for output %s ready", surface->output_name);
310301
if (surface_is_opaque(surface) &&
311302
surface->state->args.mode != BACKGROUND_MODE_CENTER &&
312303
surface->state->args.mode != BACKGROUND_MODE_FIT) {
@@ -317,24 +308,20 @@ static void initially_render_surface(struct swaylock_surface *surface) {
317308
wl_region_destroy(region);
318309
}
319310

320-
surface->created = true;
321-
if (!surface->state->ext_session_lock_v1) {
322-
render_frame_background(surface, true);
323-
render_frame(surface);
311+
surface->created = true;
312+
if (!state->ext_session_lock_v1) {
313+
wl_surface_commit(surface->surface);
324314
}
325315
}
316+
317+
326318
static void ext_session_lock_surface_v1_handle_configure(void *data,
327319
struct ext_session_lock_surface_v1 *lock_surface, uint32_t serial,
328320
uint32_t width, uint32_t height) {
329321
struct swaylock_surface *surface = data;
330322
surface->width = width;
331323
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);
336324
ext_session_lock_surface_v1_ack_configure(lock_surface, serial);
337-
wl_surface_commit(surface->surface);
338325
surface->dirty = true;
339326
render(surface);
340327
}
@@ -370,6 +357,8 @@ static void handle_wl_output_mode(void *data, struct wl_output *output,
370357
// Who cares
371358
}
372359

360+
static const struct zwlr_screencopy_frame_v1_listener screencopy_frame_listener;
361+
373362
static void handle_wl_output_done(void *data, struct wl_output *output) {
374363
swaylock_trace();
375364
struct swaylock_surface *surface = data;
@@ -1878,12 +1867,6 @@ int main(int argc, char **argv) {
18781867
surface->events_pending += 1;
18791868
};
18801869

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

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-
19161885
state.ext_session_lock_v1 = ext_session_lock_manager_v1_lock(state.ext_session_lock_manager_v1);
19171886
ext_session_lock_v1_add_listener(state.ext_session_lock_v1,
19181887
&ext_session_lock_v1_listener, &state);
@@ -1928,6 +1897,13 @@ int main(int argc, char **argv) {
19281897
wl_list_for_each(surface, &state.surfaces, link) {
19291898
create_surface(surface);
19301899
}
1900+
1901+
wl_list_for_each(surface, &state.surfaces, link) {
1902+
while (surface->events_pending > 0) {
1903+
wl_display_roundtrip(state.display);
1904+
}
1905+
}
1906+
swaylock_log(LOG_DEBUG, "create_surface pw check request");
19311907

19321908
while (!state.locked) {
19331909
if (wl_display_dispatch(state.display) < 0) {
@@ -1944,16 +1920,7 @@ int main(int argc, char **argv) {
19441920
close(state.args.ready_fd);
19451921
state.args.ready_fd = -1;
19461922
}
1947-
if (state.args.daemonize) {
1948-
daemonize();
1949-
}
19501923

1951-
wl_list_for_each(surface, &state.surfaces, link) {
1952-
while (surface->events_pending > 0) {
1953-
wl_display_roundtrip(state.display);
1954-
}
1955-
}
1956-
19571924
loop_add_fd(state.eventloop, wl_display_get_fd(state.display), POLLIN,
19581925
display_in, NULL);
19591926

pam.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define _POSIX_C_SOURCE 200809L
21
#include <pwd.h>
32
#include <security/pam_appl.h>
43
#include <stdbool.h>

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)