Przeglądaj źródła

Merge branch 'master' into hell

UMTS at Teleco 3 tygodni temu
rodzic
commit
e63be38e2a
4 zmienionych plików z 39 dodań i 4 usunięć
  1. 2 2
      kiosk.toml
  2. 6 0
      src/config.rs
  3. 22 0
      src/kioskui/app.rs
  4. 9 2
      src/main.rs

+ 2 - 2
kiosk.toml

@@ -1,5 +1,5 @@
 [kiosk]
-server_url = "http://localhost:5777"
+server_url = "http://10.50.0.62:5777"
 username = "kiosk"
 password = "kiosk"
 
@@ -24,4 +24,4 @@ font_size = 24.0
 minimum_power_level_for_full_ui = 50
 timeout_seconds = 240
 enable_full_osk_button = true
-component_scale = 1.5
+scaling_factor = 1

+ 6 - 0
src/config.rs

@@ -90,6 +90,8 @@ pub struct KioskUiSettings {
     pub timeout_seconds: Option<u64>,
     #[serde(default)]
     pub enable_full_osk_button: bool,
+    #[serde(default = "default_scaling_factor")]
+    pub scaling_factor: f32,
 }
 
 fn default_kiosk_title() -> String {
@@ -103,3 +105,7 @@ fn default_scale() -> f32 {
 fn default_min_power() -> i32 {
     50
 }
+
+fn default_scaling_factor() -> f32 {
+    1.0
+}

+ 22 - 0
src/kioskui/app.rs

@@ -25,6 +25,7 @@ pub struct KioskApp {
     
     // State
     is_initialized: bool,
+    window_setup_done: bool,
     current_user: Option<UserInfo>, // The Kiosk User
     session_user: Option<UserInfo>, // The User currently logged in via Kiosk
     session_token: Option<String>,  // The Token of the User currently logged in via Kiosk
@@ -36,6 +37,8 @@ pub struct KioskApp {
     last_focused_id: Option<egui::Id>,
     osk_event_queue: Vec<egui::Event>,
     last_interaction: std::time::Instant,
+    startup_time: std::time::Instant,
+    delayed_fullscreen_done: bool,
 }
 
 impl KioskApp {
@@ -57,6 +60,7 @@ impl KioskApp {
             dashboard: KioskDashboard::new(),
             full_ui_app: Some(full_ui_app),
             is_initialized: false,
+            window_setup_done: false,
             current_user: None,
             session_user: None,
             session_token: None,
@@ -68,6 +72,8 @@ impl KioskApp {
             last_focused_id: None,
             osk_event_queue: Vec::new(),
             last_interaction: std::time::Instant::now(),
+            startup_time: std::time::Instant::now(),
+            delayed_fullscreen_done: false,
         }
     }
 
@@ -130,6 +136,22 @@ impl eframe::App for KioskApp {
             self.last_focused_id = Some(id);
         }
 
+        // Ensure window state on first frame
+        if !self.window_setup_done {
+            if self.config.ui.fullscreen {
+                ctx.send_viewport_cmd(egui::ViewportCommand::Fullscreen(true));
+            }
+
+        // Enforce fullscreen again after a short delay (to handle some window managers)
+        if !self.delayed_fullscreen_done && self.startup_time.elapsed().as_secs_f32() > 1.0 {
+            if self.config.ui.fullscreen {
+                ctx.send_viewport_cmd(egui::ViewportCommand::Fullscreen(true));
+            }
+            self.delayed_fullscreen_done = true;
+        }
+            self.window_setup_done = true;
+        }
+
         // Check for interaction (clicks or key presses, ignore mouse moves to prevent drift issues)
         let has_interaction = ctx.input(|i| {
             i.pointer.any_pressed() || 

+ 9 - 2
src/main.rs

@@ -62,14 +62,16 @@ fn main() -> eframe::Result<()> {
     if kiosk_mode {
         if let Some(config) = &kiosk_config {
             if config.ui.fullscreen {
-                viewport_builder = viewport_builder.with_fullscreen(true);
+                viewport_builder = viewport_builder
+                    .with_fullscreen(true)
+                    .with_decorations(false);
             }
         }
     }
 
     let options = eframe::NativeOptions {
         viewport: viewport_builder,
-        persist_window: true,
+        persist_window: !kiosk_mode,
         ..Default::default()
     };
 
@@ -87,6 +89,11 @@ fn main() -> eframe::Result<()> {
 
             if kiosk_mode {
                 if let Some(config) = kiosk_config {
+                    // Apply UI scaling
+                    if config.ui.scaling_factor > 0.0 {
+                        cc.egui_ctx.set_pixels_per_point(config.ui.scaling_factor);
+                    }
+
                     Ok(Box::new(KioskApp::new(
                         cc,
                         session_manager,