Skip to content

Commit

Permalink
[MED] CHANGELOG v0.1.2-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Nov 18, 2024
1 parent 7674d94 commit 897d50b
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 103 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

22 changes: 22 additions & 0 deletions CHANGELOG/v0.1.2-alpha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# CHANGELOG FILE

This is a CHANGELOG FILE generated for [anvilock](https://github.com/muvilon/anvilock)

## Version: 0.1.2

---

## Type: **ALPHA**

---

## Commit type: **MEDIUM**

### Summary of Changes

1. Changed position of input field to the bottom + more changes
2. Client State now has animation state, shader state + some more updates to user_configs struct

## Footer

CHANGELOG FILE authored by nots1dd on 18/11/2024.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.1
124 changes: 85 additions & 39 deletions client_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,59 @@ struct pointer_event
uint32_t axis_source; // Source of the axis event (e.g., finger, wheel)
};

// Structure to handle session locking states
// 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; // Is the lock surface created?
bool surface_dirty; // Is the surface marked as dirty?
struct ext_session_lock_manager_v1* ext_session_lock_manager; // Manager for session lock
struct ext_session_lock_v1* ext_session_lock; // Session lock object
struct ext_session_lock_surface_v1* ext_session_lock_surface; // Surface for 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;
};

// Structure to hold the authentication state of the lock surface
struct auth_state
{
bool auth_success;
bool auth_failed;
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_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;
};

// Structure to store PAM-related state and authentication information
Expand All @@ -72,60 +105,73 @@ struct pam_state
struct auth_state auth_state; // the authentication state of the event loop
};

// Main structure for client state and interaction with Wayland
// Main structure for client state
struct client_state
{
/* Wayland Globals */
struct wl_display* wl_display; // Wayland display connection
struct wl_registry* wl_registry; // Global registry for Wayland objects
struct wl_shm* wl_shm; // Shared memory interface
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; // Wayland compositor
struct xdg_wm_base* xdg_wm_base; // XDG shell for window management
struct wl_seat* wl_seat; // Wayland seat (input device manager)
struct wl_output* wl_output; // Output display
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; // Wayland surface
struct wl_surface* wl_surface;
struct wl_egl_window* egl_window;
struct xdg_surface* xdg_surface; // XDG surface for window management
struct xdg_toplevel* xdg_toplevel; // Top-level window interface
struct wl_keyboard* wl_keyboard; // Keyboard interface
struct wl_pointer* wl_pointer; // Pointer interface
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; // Dimensions of the window surface
bool closed; // Window close flag
int width, height;
bool closed;

/* Input and Pointer State */
struct pointer_event pointer_event; // Holds the current pointer event
struct pointer_event pointer_event;

/* XKB Keyboard State */
struct xkb_state* xkb_state; // Keyboard state for XKB
struct xkb_context* xkb_context; // XKB context
struct xkb_keymap* xkb_keymap; // Keymap for XKB keyboard
struct xkb_state* xkb_state;
struct xkb_context* xkb_context;
struct xkb_keymap* xkb_keymap;

/* Offset and Frame Data */
float offset; // Offset for rendering or transformations
uint32_t last_frame; // Last rendered frame number
/* Animation and Rendering State */
struct animation_state animation;
float offset;
uint32_t last_frame;

/* PAM and Authentication State */
struct pam_state pam; // PAM state and authentication handling
struct pam_state pam;

/* Session Lock State */
struct session_lock session_lock; // Session lock management
struct session_lock session_lock;

/* Output State */
struct output_state output_state; // Current output information
struct output_state output_state;

/* user configs */
/* User Configs */
struct user_configs user_configs;

/* EGL and GLES State */
EGLDisplay egl_display; // EGL display connection
EGLContext egl_context; // EGL rendering context
EGLSurface egl_surface; // EGL surface for rendering
EGLConfig egl_config; // EGL configuration
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
50 changes: 27 additions & 23 deletions egl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ static const GLfloat tex_coords[] = {
1.0f, 1.0f // Bottom right
};

// Add these new vertex arrays for the password field
// New vertex array for the password field
static const GLfloat password_field_vertices[] = {
// Main rectangle (x, y coordinates for two triangles forming a rectangle)
-0.4f, 0.1f, // Top left
-0.4f, -0.1f, // Bottom left
0.4f, 0.1f, // Top right
0.4f, -0.1f // Bottom right
-0.4f, 0.1f, // Top left
-0.4f, -0.1f, // Bottom left
0.4f, 0.1f, // Top right
0.4f, -0.1f // Bottom right
};

// Define vertices for a single dot (small square)
Expand Down Expand Up @@ -279,10 +278,22 @@ static void render_password_field(struct client_state* state)
GLint color_location = glGetUniformLocation(program, "color");
GLint offset_location = glGetUniformLocation(program, "offset");
GLint position_location = glGetAttribLocation(program, "position");

// Draw main field background with rounded corners (using GL_TRIANGLE_STRIP)
glUniform4f(color_location, 1.0f, 1.0f, 1.0f, 0.95f); // light background with transparency
glUniform2f(offset_location, 0.0f, 0.0f);

// Compute bottom-center offset for password field
float screen_width = 1.0f; // Assuming normalized coordinates ([-1, 1] for both axes)
float screen_height = 1.0f;

// Width and height of the password field
float field_width = 0.7f; // Adjusted width for the field
float field_height = 0.15f; // Adjusted height for the field

// Position offset to center at the bottom of the screen
float offset_x = 0; // Horizontally center the field
float offset_y = -0.8f + field_height / 2.0f; // Vertically align it at the bottom

// Set up the password field background (using GL_TRIANGLE_STRIP for a rectangle)
glUniform4f(color_location, 1.0f, 1.0f, 1.0f, 0.70f); // Light background with transparency
glUniform2f(offset_location, offset_x, offset_y);

glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, password_field_vertices);
glEnableVertexAttribArray(position_location);
Expand All @@ -294,19 +305,18 @@ static void render_password_field(struct client_state* state)
glUniform4f(color_location, 0.8f, 0.8f, 0.8f, 1.0f);
glDrawArrays(GL_LINE_LOOP, 0, 4);

// Draw password dots with a nicer visual
glUniform4f(color_location, 0.3f, 0.3f, 0.3f, 1.0f); // gray dots
// Draw password dots
glUniform4f(color_location, 0.3f, 0.3f, 0.3f, 0.8f); // Gray dots

// Set up vertices for dots
glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, 0, dot_vertices);

// Adjust dot positions based on password input
float field_width = 0.7f; // Width of the password field (can be adjusted)
float dot_spacing = field_width / (state->pam.password_index + 1);
for (int i = 0; i < state->pam.password_index; i++)
{
float x_position = -0.35f + (i + 1) * dot_spacing; // Position the dots dynamically
glUniform2f(offset_location, x_position, 0.0f);
float x_position = offset_x + (i + 1) * dot_spacing - field_width / 2; // Center the dots
glUniform2f(offset_location, x_position, offset_y);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}

Expand All @@ -315,24 +325,18 @@ static void render_password_field(struct client_state* state)
{
float failColor[] = {1.0f, 0.0f, 0.0f, 1.0f}; // Red for failure

// Add a pulsing effect (optional, can be enhanced with animations)
glUniform4fv(color_location, 1, failColor);
glUniform2f(offset_location, 0.0f, 0.0f);
glUniform2f(offset_location, offset_x, offset_y);
glDrawArrays(GL_LINE_LOOP, 0, 4); // Re-draw border with failure color

// Optionally add a blinking effect here by alternating between red and white for a short
// period.
}

// Handle Authentication Success (Green border for success)
if (!state->pam.auth_state.auth_failed && state->pam.password_index > 0)
{
// Animation or color change to indicate success (e.g., green border)
float successColor[] = {0.0f, 1.0f, 0.0f, 1.0f}; // Green for success

// Animate the border to show success
glUniform4fv(color_location, 1, successColor);
glUniform2f(offset_location, 0.0f, 0.0f);
glUniform2f(offset_location, offset_x, offset_y);
glDrawArrays(GL_LINE_LOOP, 0, 4); // Re-draw border with success color
}

Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ int main(int argc, char* argv[])

// Initialize logging
state.pam.username = getlogin();
log_message(LOG_LEVEL_INFO, "Found User @ %s", state.pam.username);
log_message(LOG_LEVEL_INFO, "Session found for user @ [%s]", state.pam.username);

// Initialize Wayland
if (initialize_wayland(&state) != 0)
Expand Down

0 comments on commit 897d50b

Please sign in to comment.