2019-01-13 20:15:32 -06:00
|
|
|
#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"
|
|
|
|
|
2023-05-02 20:00:41 -05:00
|
|
|
// Indicator state: status of authentication attempt
|
2019-01-13 20:15:32 -06:00
|
|
|
enum auth_state {
|
2023-05-02 20:00:41 -05:00
|
|
|
AUTH_STATE_IDLE, // nothing happening
|
|
|
|
AUTH_STATE_VALIDATING, // currently validating password
|
|
|
|
AUTH_STATE_INVALID, // displaying message: password was wrong
|
|
|
|
};
|
|
|
|
|
|
|
|
// Indicator state: status of password buffer / typing letters
|
|
|
|
enum input_state {
|
|
|
|
INPUT_STATE_IDLE, // nothing happening; other states decay to this after time
|
|
|
|
INPUT_STATE_CLEAR, // displaying message: password buffer was cleared
|
|
|
|
INPUT_STATE_LETTER, // pressed a key that input a letter
|
|
|
|
INPUT_STATE_BACKSPACE, // pressed backspace and removed a letter
|
|
|
|
INPUT_STATE_NEUTRAL, // pressed a key (like Ctrl) that did nothing
|
2019-01-13 20:15:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct swaylock_colorset {
|
|
|
|
uint32_t input;
|
|
|
|
uint32_t cleared;
|
2019-01-14 09:51:04 -06:00
|
|
|
uint32_t caps_lock;
|
2019-01-13 20:15:32 -06:00
|
|
|
uint32_t verifying;
|
|
|
|
uint32_t wrong;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct swaylock_colors {
|
|
|
|
uint32_t background;
|
|
|
|
uint32_t bs_highlight;
|
|
|
|
uint32_t key_highlight;
|
2019-01-14 09:51:04 -06:00
|
|
|
uint32_t caps_lock_bs_highlight;
|
|
|
|
uint32_t caps_lock_key_highlight;
|
2019-01-13 20:15:32 -06:00
|
|
|
uint32_t separator;
|
2019-02-05 09:12:54 -06:00
|
|
|
uint32_t layout_background;
|
|
|
|
uint32_t layout_border;
|
|
|
|
uint32_t layout_text;
|
2019-01-13 20:15:32 -06:00
|
|
|
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;
|
2019-05-05 04:29:44 -05:00
|
|
|
uint32_t font_size;
|
2019-01-13 20:15:32 -06:00
|
|
|
uint32_t radius;
|
|
|
|
uint32_t thickness;
|
2019-11-27 18:43:16 -06:00
|
|
|
uint32_t indicator_x_position;
|
|
|
|
uint32_t indicator_y_position;
|
|
|
|
bool override_indicator_x_position;
|
|
|
|
bool override_indicator_y_position;
|
2019-01-13 20:15:32 -06:00
|
|
|
bool ignore_empty;
|
|
|
|
bool show_indicator;
|
2019-01-14 09:51:04 -06:00
|
|
|
bool show_caps_lock_text;
|
|
|
|
bool show_caps_lock_indicator;
|
2019-02-05 09:12:54 -06:00
|
|
|
bool show_keyboard_layout;
|
2019-04-22 12:34:19 -05:00
|
|
|
bool hide_keyboard_layout;
|
2019-01-29 09:10:16 -06:00
|
|
|
bool show_failed_attempts;
|
2019-01-13 20:15:32 -06:00
|
|
|
bool daemonize;
|
2023-01-27 06:29:33 -06:00
|
|
|
int ready_fd;
|
2019-08-03 20:07:50 -05:00
|
|
|
bool indicator_idle_visible;
|
2019-01-13 20:15:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct swaylock_password {
|
|
|
|
size_t len;
|
2022-05-30 04:50:30 -05:00
|
|
|
size_t buffer_len;
|
|
|
|
char *buffer;
|
2019-01-13 20:15:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct swaylock_state {
|
|
|
|
struct loop *eventloop;
|
2023-05-02 20:00:41 -05:00
|
|
|
struct loop_timer *input_idle_timer; // timer to reset input state to IDLE
|
|
|
|
struct loop_timer *auth_idle_timer; // timer to stop displaying AUTH_STATE_INVALID
|
2019-01-13 20:15:32 -06:00
|
|
|
struct loop_timer *clear_password_timer; // clears the password buffer
|
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_compositor *compositor;
|
2019-03-12 05:16:33 -05:00
|
|
|
struct wl_subcompositor *subcompositor;
|
2019-01-13 20:15:32 -06:00
|
|
|
struct wl_shm *shm;
|
|
|
|
struct wl_list surfaces;
|
|
|
|
struct wl_list images;
|
|
|
|
struct swaylock_args args;
|
|
|
|
struct swaylock_password password;
|
|
|
|
struct swaylock_xkb xkb;
|
2023-01-14 13:51:47 -06:00
|
|
|
cairo_surface_t *test_surface;
|
|
|
|
cairo_t *test_cairo; // used to estimate font/text sizes
|
2023-05-02 20:00:41 -05:00
|
|
|
enum auth_state auth_state; // state of the authentication attempt
|
|
|
|
enum input_state input_state; // state of the password buffer and key inputs
|
2023-03-28 18:42:19 -05:00
|
|
|
uint32_t highlight_start; // position of highlight; 2048 = 1 full turn
|
2019-01-29 09:10:16 -06:00
|
|
|
int failed_attempts;
|
2023-01-27 06:18:36 -06:00
|
|
|
bool run_display, locked;
|
2021-12-20 10:25:44 -06:00
|
|
|
struct ext_session_lock_manager_v1 *ext_session_lock_manager_v1;
|
|
|
|
struct ext_session_lock_v1 *ext_session_lock_v1;
|
2019-01-13 20:15:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct swaylock_surface {
|
|
|
|
cairo_surface_t *image;
|
|
|
|
struct swaylock_state *state;
|
|
|
|
struct wl_output *output;
|
|
|
|
uint32_t output_global_name;
|
2023-03-12 15:48:58 -05:00
|
|
|
struct wl_surface *surface; // surface for background
|
|
|
|
struct wl_surface *child; // indicator surface made into subsurface
|
2019-03-12 05:16:33 -05:00
|
|
|
struct wl_subsurface *subsurface;
|
2021-12-20 10:25:44 -06:00
|
|
|
struct ext_session_lock_surface_v1 *ext_session_lock_surface_v1;
|
2019-03-12 05:16:33 -05:00
|
|
|
struct pool_buffer indicator_buffers[2];
|
2020-10-15 07:26:02 -05:00
|
|
|
bool created;
|
2019-01-13 20:15:32 -06:00
|
|
|
bool frame_pending, dirty;
|
|
|
|
uint32_t width, height;
|
|
|
|
int32_t scale;
|
|
|
|
enum wl_output_subpixel subpixel;
|
|
|
|
char *output_name;
|
|
|
|
struct wl_list link;
|
2023-03-12 15:48:58 -05:00
|
|
|
// Dimensions of last wl_buffer committed to background surface
|
|
|
|
int last_buffer_width, last_buffer_height;
|
2019-01-13 20:15:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
// 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);
|
2019-03-12 05:16:33 -05:00
|
|
|
void render_frame_background(struct swaylock_surface *surface);
|
2019-01-13 20:15:32 -06:00
|
|
|
void render_frame(struct swaylock_surface *surface);
|
|
|
|
void damage_surface(struct swaylock_surface *surface);
|
|
|
|
void damage_state(struct swaylock_state *state);
|
|
|
|
void clear_password_buffer(struct swaylock_password *pw);
|
2023-05-02 20:00:41 -05:00
|
|
|
void schedule_auth_idle(struct swaylock_state *state);
|
2019-01-13 20:15:32 -06:00
|
|
|
|
2019-01-18 07:52:17 -06:00
|
|
|
void initialize_pw_backend(int argc, char **argv);
|
2019-01-16 16:35:14 -06:00
|
|
|
void run_pw_backend_child(void);
|
|
|
|
void clear_buffer(char *buf, size_t size);
|
|
|
|
|
2019-01-13 20:15:32 -06:00
|
|
|
#endif
|