forked from mortie/swaylock-effects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswaylock.h
173 lines (161 loc) · 4.64 KB
/
swaylock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef _SWAYLOCK_H
#define _SWAYLOCK_H
#include <stdbool.h>
#include <stdint.h>
#include <wayland-client.h>
#include "background-image.h"
#include "cairo.h"
#include "pool-buffer.h"
#include "seat.h"
#include "effects.h"
#include "fade.h"
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
enum auth_state {
AUTH_STATE_IDLE,
AUTH_STATE_CLEAR,
AUTH_STATE_INPUT,
AUTH_STATE_INPUT_NOP,
AUTH_STATE_BACKSPACE,
AUTH_STATE_VALIDATING,
AUTH_STATE_INVALID,
AUTH_STATE_GRACE,
};
struct swaylock_colorset {
uint32_t input;
uint32_t cleared;
uint32_t caps_lock;
uint32_t verifying;
uint32_t wrong;
};
struct swaylock_colors {
uint32_t background;
uint32_t bs_highlight;
uint32_t key_highlight;
uint32_t caps_lock_bs_highlight;
uint32_t caps_lock_key_highlight;
uint32_t separator;
uint32_t layout_background;
uint32_t layout_border;
uint32_t layout_text;
struct swaylock_colorset inside;
struct swaylock_colorset line;
struct swaylock_colorset ring;
struct swaylock_colorset text;
};
struct swaylock_args {
struct swaylock_colors colors;
enum background_mode mode;
char *font;
uint32_t font_size;
uint32_t radius;
uint32_t thickness;
uint32_t indicator_x_position;
uint32_t indicator_y_position;
bool override_indicator_x_position;
bool override_indicator_y_position;
bool ignore_empty;
bool show_indicator;
bool show_caps_lock_text;
bool show_caps_lock_indicator;
bool show_keyboard_layout;
bool hide_keyboard_layout;
bool show_failed_attempts;
bool daemonize;
bool indicator_idle_visible;
bool screenshots;
struct swaylock_effect *effects;
int effects_count;
bool time_effects;
bool indicator;
bool clock;
char *timestr;
char *datestr;
uint32_t fade_in;
bool password_submit_on_touch;
uint32_t password_grace_period;
bool password_grace_no_mouse;
bool password_grace_no_touch;
};
struct swaylock_password {
size_t len;
char buffer[1024];
};
struct swaylock_state {
struct loop *eventloop;
struct loop_timer *clear_indicator_timer; // clears the indicator
struct loop_timer *clear_password_timer; // clears the password buffer
struct wl_display *display;
struct wl_compositor *compositor;
struct wl_subcompositor *subcompositor;
struct zwlr_layer_shell_v1 *layer_shell;
struct zwlr_input_inhibit_manager_v1 *input_inhibit_manager;
struct zwlr_screencopy_manager_v1 *screencopy_manager;
struct wl_shm *shm;
struct wl_list surfaces;
struct wl_list images;
struct swaylock_args args;
struct swaylock_password password;
struct swaylock_xkb xkb;
enum auth_state auth_state;
bool indicator_dirty;
int render_randnum;
int failed_attempts;
size_t n_screenshots_done;
bool run_display;
struct zxdg_output_manager_v1 *zxdg_output_manager;
};
struct swaylock_surface {
cairo_surface_t *image;
struct {
uint32_t format, width, height, stride;
enum wl_output_transform transform;
void *data;
struct swaylock_image *image;
} screencopy;
struct swaylock_state *state;
struct wl_output *output;
uint32_t output_global_name;
struct zxdg_output_v1 *xdg_output;
struct wl_surface *surface;
struct wl_surface *child; // surface made into subsurface
struct wl_subsurface *subsurface;
struct zwlr_layer_surface_v1 *layer_surface;
struct zwlr_screencopy_frame_v1 *screencopy_frame;
struct pool_buffer buffers[2];
struct pool_buffer indicator_buffers[2];
struct pool_buffer *current_buffer;
struct swaylock_fade fade;
int events_pending;
bool frame_pending, dirty;
uint32_t width, height;
uint32_t indicator_width, indicator_height;
int32_t scale;
enum wl_output_subpixel subpixel;
enum wl_output_transform transform;
char *output_name;
struct wl_list link;
};
// There is exactly one swaylock_image for each -i argument
struct swaylock_image {
char *path;
char *output_name;
cairo_surface_t *cairo_surface;
struct wl_list link;
};
void swaylock_handle_key(struct swaylock_state *state,
xkb_keysym_t keysym, uint32_t codepoint);
void swaylock_handle_mouse(struct swaylock_state *state);
void swaylock_handle_touch(struct swaylock_state *state);
void render_frame_background(struct swaylock_surface *surface);
void render_background_fade(struct swaylock_surface *surface, uint32_t time);
void render_background_fade_prepare(struct swaylock_surface *surface, struct pool_buffer *buffer);
void render_frame(struct swaylock_surface *surface);
void render_frames(struct swaylock_state *state);
void damage_surface(struct swaylock_surface *surface);
void damage_state(struct swaylock_state *state);
void clear_password_buffer(struct swaylock_password *pw);
void schedule_indicator_clear(struct swaylock_state *state);
void initialize_pw_backend(int argc, char **argv);
void run_pw_backend_child(void);
void clear_buffer(char *buf, size_t size);
#endif