From 6e74e90ea27955e9f2292827fe36a9b0fda9e1e7 Mon Sep 17 00:00:00 2001 From: Md istekhar Date: Wed, 18 Feb 2026 03:19:16 +0530 Subject: [PATCH] fix(network): focus password input in authentication dialog --- cosmic-applet-network/src/app.rs | 13 +++++++++- cosmic-applet-power/src/lib.rs | 44 ++++++++++++++------------------ 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index ed05e67b..0c15d2bd 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -34,7 +34,7 @@ use cosmic::{ iced_runtime::core::window, surface, theme, widget::{ - Column, Row, button, container, divider, + Column, Id, Row, button, container, divider, icon::{self, from_name}, scrollable, secure_input, text, text_input, }, @@ -99,6 +99,8 @@ impl From for AccessPoint { static WIFI: LazyLock = LazyLock::new(id::Toggler::unique); static AIRPLANE_MODE: LazyLock = LazyLock::new(id::Toggler::unique); +pub static SECURE_INPUT_WIFI: LazyLock = LazyLock::new(Id::unique); + #[derive(Default, Debug, Clone)] pub struct MyNetworkState { pub known_vpns: IndexMap, @@ -466,6 +468,8 @@ pub(crate) enum Message { OpenSettings, ResetFailedKnownSsid(String, HwAddress), TogglePasswordVisibility, + FocusSecureInput, + NoOp, Surface(surface::Action), ActivateVpn(Arc), // UUID of VPN to activate DeactivateVpn(Arc), // UUID of VPN to deactivate @@ -893,6 +897,7 @@ impl cosmic::Application for CosmicNetworkApplet { password: String::new().into(), password_hidden: true, }); + return cosmic::task::message(cosmic::Action::App(Message::FocusSecureInput)); } } Message::ToggleVisibleNetworks => { @@ -907,6 +912,11 @@ impl cosmic::Application for CosmicNetworkApplet { *password_hidden = !*password_hidden; } } + Message::FocusSecureInput => { + return text_input::focus(SECURE_INPUT_WIFI.clone()) + .map(|_: ()| cosmic::Action::App(Message::NoOp)); + } + Message::NoOp => {} Message::CancelNewConnection => { self.new_connection = None; } @@ -1866,6 +1876,7 @@ impl cosmic::Application for CosmicNetworkApplet { Some(Message::TogglePasswordVisibility), *password_hidden, ) + .id(SECURE_INPUT_WIFI.clone()) .on_input(|s| Message::PasswordUpdate(SecureString::from(s))) .on_paste(|s| Message::PasswordUpdate(SecureString::from(s))) .on_submit(|_| Message::ConnectWithPassword), diff --git a/cosmic-applet-power/src/lib.rs b/cosmic-applet-power/src/lib.rs index 4ae2f03b..22d23ed5 100644 --- a/cosmic-applet-power/src/lib.rs +++ b/cosmic-applet-power/src/lib.rs @@ -147,33 +147,27 @@ impl cosmic::Application for Power { tracing::error!("Wayland tx is None"); } } - Message::Action(action) => { - match action { - PowerAction::LogOut => { - if let Err(err) = process::Command::new("cosmic-osd").arg("log-out").spawn() - { - tracing::error!("Failed to spawn cosmic-osd. {err:?}"); - return PowerAction::LogOut.perform(); - } + Message::Action(action) => match action { + PowerAction::LogOut => { + if let Err(err) = process::Command::new("cosmic-osd").arg("log-out").spawn() { + tracing::error!("Failed to spawn cosmic-osd. {err:?}"); + return PowerAction::LogOut.perform(); } - PowerAction::Restart => { - if let Err(err) = process::Command::new("cosmic-osd").arg("restart").spawn() - { - tracing::error!("Failed to spawn cosmic-osd. {err:?}"); - return PowerAction::Restart.perform(); - } - } - PowerAction::Shutdown => { - if let Err(err) = - process::Command::new("cosmic-osd").arg("shutdown").spawn() - { - tracing::error!("Failed to spawn cosmic-osd. {err:?}"); - return PowerAction::Shutdown.perform(); - } - } - a => return a.perform(), } - } + PowerAction::Restart => { + if let Err(err) = process::Command::new("cosmic-osd").arg("restart").spawn() { + tracing::error!("Failed to spawn cosmic-osd. {err:?}"); + return PowerAction::Restart.perform(); + } + } + PowerAction::Shutdown => { + if let Err(err) = process::Command::new("cosmic-osd").arg("shutdown").spawn() { + tracing::error!("Failed to spawn cosmic-osd. {err:?}"); + return PowerAction::Shutdown.perform(); + } + } + a => return a.perform(), + }, Message::Zbus(result) => { if let Err(e) = result { eprintln!("cosmic-applet-power ERROR: '{e}'");