-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient_state.h
180 lines (158 loc) · 5.31 KB
/
client_state.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
174
175
176
177
178
179
180
#ifndef CLIENT_STATE_H
#define CLIENT_STATE_H
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <stdbool.h>
#include <wayland-client.h>
#include <wayland-egl.h>
#include <xkbcommon/xkbcommon.h>
// Structure for storing output-related information
struct output_state
{
uint32_t id;
int32_t width;
int32_t height;
int32_t refresh_rate;
struct wl_output* wl_output;
};
// Structure to represent pointer events and their associated state
struct pointer_axes
{
bool valid; // Indicates if the axis value is valid
wl_fixed_t value; // Value of the axis (e.g., scroll amount)
int32_t discrete; // Discrete value for axis, if applicable
};
struct pointer_event
{
uint32_t event_mask; // Mask for event type (button press/release, motion, etc.)
wl_fixed_t surface_x; // X coordinate on the surface
wl_fixed_t surface_y; // Y coordinate on the surface
uint32_t button; // Button associated with the event
uint32_t state; // Button state (pressed/released)
uint32_t time; // Time of the event
uint32_t serial; // Serial number for the event
struct pointer_axes axes[2]; // Axes information (0 = vertical, 1 = horizontal)
uint32_t axis_source; // Source of the axis event (e.g., finger, wheel)
};
// Structure to handle animation states and timings
struct animation_state
{
uint64_t frame_count; // Current frame number for animations
uint64_t last_key_frame; // Frame number when last key was pressed
uint64_t auth_fail_frame; // Frame number when authentication failed
float current_time; // Current animation time in seconds
float dot_bounce_phase; // Phase offset for dot bounce animations
float background_alpha; // Background transparency animation
struct
{
float x; // Current shake offset X
float y; // Current shake offset Y
float intensity; // Current shake intensity
uint64_t start_frame; // When shake animation started
} shake;
};
struct session_lock
{
bool surface_created;
bool surface_dirty;
struct ext_session_lock_manager_v1* ext_session_lock_manager;
struct ext_session_lock_v1* ext_session_lock;
struct ext_session_lock_surface_v1* ext_session_lock_surface;
};
struct auth_state
{
bool auth_success;
bool auth_failed;
float fail_effect_intensity; // Intensity of failure effect (0.0 - 1.0)
float success_effect_intensity; // Intensity of success effect (0.0 - 1.0)
};
struct user_configs
{
char* background_name;
char* background_path;
struct
{
float background_opacity; // Background opacity (0.0 - 1.0)
float dot_size; // Size of password dots
float corner_radius; // Radius for rounded corners
struct
{
float r, g, b, a; // Background color
} background_color;
struct
{
float r, g, b, a; // Dot color
} dot_color;
bool enable_animations; // Toggle for animations
} ui_settings;
char* font_path;
char* debug_log_option;
};
// Structure to store PAM-related state and authentication information
struct pam_state
{
bool first_enter_press; // Tracks first Enter key press for authentication
char* username; // Stores the username for authentication
char password[256]; // Password buffer
int password_index; // Current index in the password buffer
bool locked; // Locks the session if authentication fails
struct auth_state auth_state; // the authentication state of the event loop
};
// Main structure for client state
struct client_state
{
/* Wayland Globals */
struct wl_display* wl_display;
struct wl_registry* wl_registry;
struct wl_shm* wl_shm;
struct wl_shm_pool* wl_shm_pool;
struct wl_compositor* wl_compositor;
struct xdg_wm_base* xdg_wm_base;
struct wl_seat* wl_seat;
struct wl_output* wl_output;
/* Wayland Objects */
struct wl_surface* wl_surface;
struct wl_egl_window* egl_window;
struct xdg_surface* xdg_surface;
struct xdg_toplevel* xdg_toplevel;
struct wl_keyboard* wl_keyboard;
struct wl_pointer* wl_pointer;
/* Window State */
int width, height;
bool closed;
/* Input and Pointer State */
struct pointer_event pointer_event;
/* XKB Keyboard State */
struct xkb_state* xkb_state;
struct xkb_context* xkb_context;
struct xkb_keymap* xkb_keymap;
/* Animation and Rendering State */
struct animation_state animation;
float offset;
uint32_t last_frame;
/* PAM and Authentication State */
struct pam_state pam;
/* Session Lock State */
struct session_lock session_lock;
/* Output State */
struct output_state output_state;
/* User Configs */
struct user_configs user_configs;
/* EGL and GLES State */
EGLDisplay egl_display;
EGLContext egl_context;
EGLSurface egl_surface;
EGLConfig egl_config;
/* Shader Program State */
struct
{
GLuint program;
GLint color_location;
GLint offset_location;
GLint time_location;
GLint resolution_location;
GLint radius_location;
GLint position_location;
} shader_state;
};
#endif