Added capslock functionality
Added keyboard layout func
This commit is contained in:
@@ -85,6 +85,9 @@ pub struct Config {
|
||||
#[arg(long, action = clap::ArgAction::Set, num_args = 0..=1, default_value = "true", default_missing_value = "true")]
|
||||
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)]
|
||||
pub image: Option<PathBuf>,
|
||||
|
||||
|
||||
@@ -102,6 +102,11 @@ impl InputHandler {
|
||||
/// Update timers (should be called periodically)
|
||||
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
|
||||
|
||||
@@ -107,6 +107,10 @@ impl LockedSurface {
|
||||
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
|
||||
if !self.background_applied {
|
||||
if let Some(ref background) = self.background {
|
||||
|
||||
@@ -5,7 +5,6 @@ mod lock;
|
||||
mod render;
|
||||
mod screenshot;
|
||||
mod system;
|
||||
mod timer;
|
||||
mod util;
|
||||
|
||||
use config::Config;
|
||||
|
||||
+20
-1
@@ -21,7 +21,7 @@ pub struct Renderer {
|
||||
password_display: String,
|
||||
uptime_cache: String,
|
||||
last_uptime_update: Option<Instant>,
|
||||
caps_lock: bool,
|
||||
pub caps_lock: bool,
|
||||
pub system_status: SystemStatus,
|
||||
media_art_surface: Option<ImageSurface>,
|
||||
last_art_url: Option<String>,
|
||||
@@ -230,6 +230,10 @@ impl Renderer {
|
||||
self.draw_bluetooth();
|
||||
}
|
||||
|
||||
if self.config.show_keyboard_layout {
|
||||
self.draw_keyboard_layout();
|
||||
}
|
||||
|
||||
if !self.password_display.is_empty() {
|
||||
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) {
|
||||
self.context.save().unwrap();
|
||||
let target_size = 24.0;
|
||||
|
||||
Reference in New Issue
Block a user