From 39d88f2ffaeb50793bc3c7dcd9ac0404a9961bf0 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 27 Nov 2024 11:31:11 -0500 Subject: [PATCH] refactor: add namespace --- Cargo.lock | 5 ++-- Cargo.toml | 2 +- core/src/event/wayland/overlap_notify.rs | 1 + examples/sctk_todos/Cargo.toml | 1 + examples/sctk_todos/src/main.rs | 30 ++++++++++++++----- .../wayland/handlers/overlap.rs | 3 +- .../platform_specific/wayland/sctk_event.rs | 3 ++ 7 files changed, 33 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bb5111d6..5e4ad834 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "cosmic-client-toolkit" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-protocols?rev=27d70b6#27d70b6eb9c785a2a48341016f32a7b1ac4980ac" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=d218c76#d218c76b58c7a3b20dd5e7943f93fc306a1b81b8" dependencies = [ "cosmic-protocols", "libc", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "cosmic-protocols" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-protocols?rev=27d70b6#27d70b6eb9c785a2a48341016f32a7b1ac4980ac" +source = "git+https://github.com/pop-os/cosmic-protocols?rev=d218c76#d218c76b58c7a3b20dd5e7943f93fc306a1b81b8" dependencies = [ "bitflags 2.10.0", "wayland-backend", @@ -5850,6 +5850,7 @@ dependencies = [ "once_cell", "serde", "serde_json", + "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index bc9fc06e..21c5c640 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -278,7 +278,7 @@ tiny-skia = { version = "0.11", default-features = false, features = [ "std", "simd", ] } -cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "27d70b6" } +cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "d218c76" } softbuffer = { git = "https://github.com/pop-os/softbuffer", tag = "cosmic-4.0" } syntect = "5.2" tokio = "1.0" diff --git a/core/src/event/wayland/overlap_notify.rs b/core/src/event/wayland/overlap_notify.rs index 5d59c29a..60f790d8 100644 --- a/core/src/event/wayland/overlap_notify.rs +++ b/core/src/event/wayland/overlap_notify.rs @@ -11,6 +11,7 @@ pub enum OverlapNotifyEvent { }, OverlapLayerAdd { identifier: String, + namespace: String, exclusive: u32, layer: Option, logical_rect: crate::Rectangle, diff --git a/examples/sctk_todos/Cargo.toml b/examples/sctk_todos/Cargo.toml index fd14b95e..cfa96e74 100644 --- a/examples/sctk_todos/Cargo.toml +++ b/examples/sctk_todos/Cargo.toml @@ -27,6 +27,7 @@ log = "0.4.17" env_logger = "0.10.0" async-std = "1.0" directories-next = "2.0.0" +tracing = "0.1" [profile.release-opt] debug = true diff --git a/examples/sctk_todos/src/main.rs b/examples/sctk_todos/src/main.rs index 7be16c83..e2a38fda 100644 --- a/examples/sctk_todos/src/main.rs +++ b/examples/sctk_todos/src/main.rs @@ -1,8 +1,9 @@ use env_logger::Env; use iced::alignment::{self, Alignment}; use iced::event::{self, listen_raw, Event}; -use iced::platform_specific::shell::commands::layer_surface::{ - get_layer_surface, Anchor, +use iced::platform_specific::shell::commands::{ + layer_surface::{get_layer_surface, Anchor}, + overlap_notify::overlap_notify, }; use iced::theme::{self, Theme}; use iced::widget::{ @@ -24,11 +25,11 @@ use std::fmt::Debug; static INPUT_ID: Lazy = Lazy::new(|| text_input::Id::unique()); pub fn main() -> iced::Result { - let env = Env::default() - .filter_or("MY_LOG_LEVEL", "info") - .write_style_or("MY_LOG_STYLE", "always"); + // let env = Env::default() + // .filter_or("MY_LOG_LEVEL", "info") + // .write_style_or("MY_LOG_STYLE", "always"); - env_logger::init_from_env(env); + // env_logger::init_from_env(env); iced::daemon(Todos::title, Todos::update, Todos::view) .subscription(Todos::subscription) .font(include_bytes!("../fonts/icons.ttf").as_slice()) @@ -89,17 +90,20 @@ impl Debug for Message { impl Todos { fn new() -> (Todos, Task) { + let id = window::Id::unique(); ( Todos::Loading, Task::batch(vec![ Task::perform(SavedState::load(), Message::Loaded), get_layer_surface(iced::platform_specific::runtime::wayland::layer_surface::SctkLayerSurfaceSettings { + id: id.clone(), size: Some((None, Some(500))), pointer_interactivity: true, keyboard_interactivity: cctk::sctk::shell::wlr_layer::KeyboardInteractivity::OnDemand, anchor: Anchor::LEFT.union(Anchor::RIGHT).union(Anchor::TOP), ..Default::default() }), + overlap_notify(id, true) ]), ) } @@ -311,12 +315,22 @@ impl Todos { }), ( Event::PlatformSpecific(event::PlatformSpecific::Wayland( - event::wayland::Event::Window(e), + event::wayland::Event::Layer(e, ..), )), _, _, ) => { - dbg!(&e); + dbg!(e); + None + } + ( + Event::PlatformSpecific(event::PlatformSpecific::Wayland( + event::wayland::Event::OverlapNotify(e), + )), + _, + _, + ) => { + dbg!(e); None } _ => None, diff --git a/winit/src/platform_specific/wayland/handlers/overlap.rs b/winit/src/platform_specific/wayland/handlers/overlap.rs index 15db4f50..530c6a7f 100644 --- a/winit/src/platform_specific/wayland/handlers/overlap.rs +++ b/winit/src/platform_specific/wayland/handlers/overlap.rs @@ -82,13 +82,14 @@ impl Dispatch } zcosmic_overlap_notification_v1::Event::LayerEnter { identifier, + namespace, exclusive, layer, x, y, width, height, - } => SctkEvent::OverlapLayerAdd { surface, identifier, exclusive, layer: match layer { + } => SctkEvent::OverlapLayerAdd { surface, namespace, identifier, exclusive, layer: match layer { wayland_client::WEnum::Value(v) => match v { cctk::sctk::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::Layer::Background => Some(Layer::Background), cctk::sctk::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::Layer::Bottom => Some(Layer::Bottom), diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 02cb19e4..fa8f2865 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -140,6 +140,7 @@ pub enum SctkEvent { }, OverlapLayerAdd { surface: WlSurface, + namespace: String, identifier: String, exclusive: u32, layer: Option, @@ -1263,6 +1264,7 @@ impl SctkEvent { } SctkEvent::OverlapLayerAdd { surface, + namespace, identifier, exclusive, layer, @@ -1276,6 +1278,7 @@ impl SctkEvent { wayland::Event::OverlapNotify( OverlapNotifyEvent::OverlapLayerAdd { identifier, + namespace, exclusive, layer, logical_rect,