diff --git a/Cargo.lock b/Cargo.lock index 8dcea6e..5e87110 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -747,7 +747,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/libcosmic#6b517ddb0e7fe2ed8b04d6f71d1c45a374c92e14" dependencies = [ "atomicwrites", "calloop", @@ -762,7 +762,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/libcosmic#6b517ddb0e7fe2ed8b04d6f71d1c45a374c92e14" dependencies = [ "quote", "syn 1.0.109", @@ -810,7 +810,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/libcosmic#6b517ddb0e7fe2ed8b04d6f71d1c45a374c92e14" dependencies = [ "almost", "cosmic-config", @@ -1764,7 +1764,7 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "iced_accessibility", "iced_core", @@ -1779,7 +1779,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "accesskit", "accesskit_unix", @@ -1788,14 +1788,14 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "bitflags 1.3.2", "iced_accessibility", "instant", "log", "palette", - "smithay-client-toolkit 0.17.0", + "smithay-client-toolkit 0.18.0", "thiserror", "twox-hash", ] @@ -1803,7 +1803,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "futures", "iced_core", @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -1834,7 +1834,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -1847,19 +1847,19 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "iced_accessibility", "iced_core", "iced_futures", - "smithay-client-toolkit 0.17.0", + "smithay-client-toolkit 0.18.0", "thiserror", ] [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "enum-repr", "float-cmp", @@ -1871,7 +1871,7 @@ dependencies = [ "itertools", "lazy_static", "raw-window-handle", - "smithay-client-toolkit 0.17.0", + "smithay-client-toolkit 0.18.0", "smithay-clipboard", "thiserror", "tracing", @@ -1883,7 +1883,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "iced_core", "once_cell", @@ -1893,7 +1893,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "bytemuck", "cosmic-text", @@ -1911,7 +1911,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -1933,7 +1933,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/iced//?branch=sctk-session-lock#5d2e29bcd18cb45a10f5a51ce2cf37030f2f7abf" dependencies = [ "iced_renderer", "iced_runtime", @@ -2166,7 +2166,7 @@ checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#f3eb41c1d2a6aaef76f40bc872a71153f90fc113" +source = "git+https://github.com/pop-os/libcosmic#6b517ddb0e7fe2ed8b04d6f71d1c45a374c92e14" dependencies = [ "apply", "ashpd", @@ -2354,6 +2354,24 @@ dependencies = [ "libc", ] +[[package]] +name = "memmap2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" +dependencies = [ + "libc", +] + +[[package]] +name = "memmap2" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deaba38d7abf1d4cca21cc89e932e542ba2b9258664d2a9ef0e61512039c9375" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -2737,8 +2755,6 @@ dependencies = [ [[package]] name = "pam-sys" version = "1.0.0-alpha4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9dfd42858f6a6bb1081079fd9dc259ca3e2aaece6cb689fd36b1058046c969" dependencies = [ "bindgen", "libc", @@ -3526,7 +3542,34 @@ dependencies = [ "wayland-protocols 0.31.0", "wayland-protocols-wlr", "wayland-scanner 0.31.0", - "xkbcommon", + "xkbcommon 0.5.1", + "xkeysym", +] + +[[package]] +name = "smithay-client-toolkit" +version = "0.18.0" +source = "git+https://github.com/smithay/client-toolkit?rev=828b1eb#828b1eb469ad022eb3ac30be02bd5645b879922f" +dependencies = [ + "bitflags 2.4.1", + "bytemuck", + "calloop", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2 0.9.0", + "pkg-config", + "rustix 0.38.20", + "thiserror", + "wayland-backend 0.3.2", + "wayland-client 0.31.1", + "wayland-csd-frame", + "wayland-cursor 0.31.0", + "wayland-protocols 0.31.0", + "wayland-protocols-wlr", + "wayland-scanner 0.31.0", + "xkbcommon 0.7.0", "xkeysym", ] @@ -4825,6 +4868,17 @@ dependencies = [ "memmap2 0.7.1", ] +[[package]] +name = "xkbcommon" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13867d259930edc7091a6c41b4ce6eee464328c6ff9659b7e4c668ca20d4c91e" +dependencies = [ + "libc", + "memmap2 0.8.0", + "xkeysym", +] + [[package]] name = "xkeysym" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 08d8772..f78eab8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,14 @@ features = ["tokio", "wayland"] [dependencies.tokio] version = "1.33.0" features = ["full"] + +[patch."https://github.com/pop-os/libcosmic"] +iced = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_runtime = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_renderer = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_core = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_widget = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_futures = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_tiny_skia = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_style = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } +iced_sctk = { git = "https://github.com/pop-os/iced//", branch = "sctk-session-lock" } diff --git a/src/greeter.rs b/src/greeter.rs index ee5af64..0f61c06 100644 --- a/src/greeter.rs +++ b/src/greeter.rs @@ -616,7 +616,7 @@ impl cosmic::Application for App { column = column.push( //TODO: use button - widget::pick_list( + iced::widget::pick_list( &self.session_names, Some(self.selected_session.clone()), Message::Session, diff --git a/src/locker.rs b/src/locker.rs index e2f1eed..047fd65 100644 --- a/src/locker.rs +++ b/src/locker.rs @@ -6,14 +6,14 @@ use cosmic::{ executor, iced::{ self, alignment, - event::wayland::{Event as WaylandEvent, LayerEvent, OutputEvent}, + event::wayland::{Event as WaylandEvent, OutputEvent, SessionLockEvent}, futures::{self, SinkExt}, subscription, - wayland::{ - actions::layer_surface::{IcedMargin, IcedOutput, SctkLayerSurfaceSettings}, - layer_surface::{ - destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity, Layer, - }, + wayland::session_lock::{ + get_lock_surface, + lock, + destroy_lock_surface, + unlock, }, Length, Subscription, }, @@ -197,7 +197,7 @@ pub struct Flags { pub enum Message { None, OutputEvent(OutputEvent, WlOutput), - LayerEvent(LayerEvent, SurfaceId), + SessionLockEvent(SessionLockEvent), Channel(mpsc::Sender), Prompt(String, bool, Option), Submit, @@ -263,7 +263,7 @@ impl cosmic::Application for App { error_opt: None, exited: false, }, - Command::none(), + lock(), ) } @@ -337,24 +337,7 @@ impl cosmic::Application for App { } return Command::batch([ - get_layer_surface(SctkLayerSurfaceSettings { - id: surface_id, - layer: Layer::Overlay, - keyboard_interactivity: KeyboardInteractivity::Exclusive, - pointer_interactivity: true, - anchor: Anchor::TOP | Anchor::BOTTOM | Anchor::LEFT | Anchor::RIGHT, - output: IcedOutput::Output(output), - namespace: "cosmic-locker".into(), - size: Some((None, None)), - margin: IcedMargin { - top: 0, - bottom: 0, - left: 0, - right: 0, - }, - exclusive_zone: -1, - size_limits: iced::Limits::NONE.min_width(1.0).min_height(1.0), - }), + get_lock_surface(surface_id, output), widget::text_input::focus(text_input_id(surface_id)), ]); } @@ -363,7 +346,7 @@ impl cosmic::Application for App { match self.surface_ids.remove(&output) { Some(surface_id) => { self.surface_images.remove(&surface_id); - return destroy_layer_surface(surface_id); + return destroy_lock_surface(surface_id); } None => { log::warn!("output {}: no surface found", output.id()); @@ -375,18 +358,13 @@ impl cosmic::Application for App { } } } - Message::LayerEvent(layer_event, surface_id) => match layer_event { - LayerEvent::Focused => { + Message::SessionLockEvent(session_lock_event) => match session_lock_event { + SessionLockEvent::Focused(_, surface_id) => { log::info!("focus surface {}", surface_id.0); self.active_surface_id_opt = Some(surface_id); return widget::text_input::focus(text_input_id(surface_id)); } - LayerEvent::Unfocused => { - log::info!("unfocus surface {}", surface_id.0); - } - LayerEvent::Done => { - log::info!("done with surface {}", surface_id.0); - } + _ => {} }, Message::Channel(value_tx) => { self.value_tx_opt = Some(value_tx); @@ -427,10 +405,11 @@ impl cosmic::Application for App { let mut commands = Vec::new(); for (_output, surface_id) in self.surface_ids.drain() { self.surface_images.remove(&surface_id); - commands.push(destroy_layer_surface(surface_id)); + commands.push(destroy_lock_surface(surface_id)); } + commands.push(unlock()); //TODO: cleaner method to exit? - commands.push(Command::perform(async { process::exit(0) }, |x| x)); + // commands.push(Command::perform(async { process::exit(0) }, |x| x)); return Command::batch(commands); } } @@ -630,9 +609,7 @@ impl cosmic::Application for App { WaylandEvent::Output(output_event, output) => { Some(Message::OutputEvent(output_event, output)) } - WaylandEvent::Layer(layer_event, _surface, surface_id) => { - Some(Message::LayerEvent(layer_event, surface_id)) - } + WaylandEvent::SessionLock(evt) => Some(Message::SessionLockEvent(evt)), _ => None, }, _ => None,