Added capslock functionality

Added keyboard layout func
This commit is contained in:
2026-03-16 15:10:23 +01:00
parent f489a6e46e
commit 5e47f8a69c
5 changed files with 32 additions and 2 deletions
+3
View File
@@ -85,6 +85,9 @@ pub struct Config {
#[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "true", default_missing_value = "true")] #[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "true", default_missing_value = "true")]
pub show_album_art: bool, pub show_album_art: bool,
#[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "false", default_missing_value = "true")]
pub show_keyboard_layout: bool,
#[arg(long)] #[arg(long)]
pub image: Option<PathBuf>, pub image: Option<PathBuf>,
+5
View File
@@ -102,6 +102,11 @@ impl InputHandler {
/// Update timers (should be called periodically) /// Update timers (should be called periodically)
pub fn update(&mut self) { pub fn update(&mut self) {
} }
/// Get the current Caps Lock state
pub fn caps_lock(&self) -> bool {
self.caps_lock
}
} }
/// Actions that can result from keyboard input /// Actions that can result from keyboard input
+4
View File
@@ -107,6 +107,10 @@ impl LockedSurface {
self.key_highlight_shown = false; self.key_highlight_shown = false;
} }
// Update caps lock state in renderer
self.renderer.caps_lock = self.input_handler.caps_lock();
log::debug!("Caps lock state: {}", self.input_handler.caps_lock());
// Set background if available and not already applied // Set background if available and not already applied
if !self.background_applied { if !self.background_applied {
if let Some(ref background) = self.background { if let Some(ref background) = self.background {
-1
View File
@@ -5,7 +5,6 @@ mod lock;
mod render; mod render;
mod screenshot; mod screenshot;
mod system; mod system;
mod timer;
mod util; mod util;
use config::Config; use config::Config;
+20 -1
View File
@@ -21,7 +21,7 @@ pub struct Renderer {
password_display: String, password_display: String,
uptime_cache: String, uptime_cache: String,
last_uptime_update: Option<Instant>, last_uptime_update: Option<Instant>,
caps_lock: bool, pub caps_lock: bool,
pub system_status: SystemStatus, pub system_status: SystemStatus,
media_art_surface: Option<ImageSurface>, media_art_surface: Option<ImageSurface>,
last_art_url: Option<String>, last_art_url: Option<String>,
@@ -230,6 +230,10 @@ impl Renderer {
self.draw_bluetooth(); self.draw_bluetooth();
} }
if self.config.show_keyboard_layout {
self.draw_keyboard_layout();
}
if !self.password_display.is_empty() { if !self.password_display.is_empty() {
self.draw_password_display(); self.draw_password_display();
} }
@@ -703,6 +707,21 @@ impl Renderer {
} }
} }
fn draw_keyboard_layout(&self) {
if let Some(layout) = self.system_status.keyboard_layout {
let margin = 20.0;
let x = margin;
let y = margin + 80.0;
self.context.new_path();
self.context.set_source_rgba(1.0, 1.0, 1.0, self.fade_alpha);
self.context.set_font_size(16.0);
let text = format!("Layout: {}", layout);
self.context.move_to(x, y);
self.context.show_text(&text).unwrap();
}
}
fn draw_icon_at(&self, x: f64, y: f64, surface: &ImageSurface) { fn draw_icon_at(&self, x: f64, y: f64, surface: &ImageSurface) {
self.context.save().unwrap(); self.context.save().unwrap();
let target_size = 24.0; let target_size = 24.0;