Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlap notify #200

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pulldown-cmark = "0.11"
qrcode = { version = "0.13", default-features = false }
raw-window-handle = "0.6"
rustc-hash = "2.0"
sctk = { package = "smithay-client-toolkit", version = "0.19.1" }
cctk = { git = "https://github.com/pop-os/cosmic-protocols", package = "cosmic-client-toolkit", rev = "d218c76" }
smol = "1.0"
smol_str = "0.2"
softbuffer = { git = "https://github.com/pop-os/softbuffer", tag = "cosmic-4.0" }
Expand Down
6 changes: 3 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ workspace = true
auto-detect-theme = ["dep:dark-light"]
advanced = []
a11y = ["iced_accessibility"]
wayland = ["sctk"]
wayland = ["cctk"]

[dependencies]
bitflags.workspace = true
Expand All @@ -38,8 +38,8 @@ window_clipboard.workspace = true
dnd.workspace = true
mime.workspace = true

sctk.workspace = true
sctk.optional = true
cctk.workspace = true
cctk.optional = true
# /TODO(POP)

dark-light.workspace = true
Expand Down
6 changes: 5 additions & 1 deletion core/src/event/wayland/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
mod layer;
mod output;
mod overlap_notify;
mod popup;
mod seat;
mod session_lock;
mod window;

use crate::{time::Instant, window::Id};
use sctk::reexports::client::protocol::{
use cctk::sctk::reexports::client::protocol::{
wl_output::WlOutput, wl_seat::WlSeat, wl_surface::WlSurface,
};

pub use layer::*;
pub use output::*;
pub use overlap_notify::*;
pub use popup::*;
pub use seat::*;
pub use session_lock::*;
Expand All @@ -26,6 +28,8 @@ pub enum Event {
Popup(PopupEvent, WlSurface, Id),
/// output event
Output(OutputEvent, WlOutput),
/// Overlap notify event
OverlapNotify(overlap_notify::OverlapNotifyEvent),
/// window event
Window(WindowEvent),
/// Seat Event
Expand Down
2 changes: 1 addition & 1 deletion core/src/event/wayland/output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sctk::output::OutputInfo;
use cctk::sctk::output::OutputInfo;

/// output events
#[derive(Debug, Clone)]
Expand Down
22 changes: 22 additions & 0 deletions core/src/event/wayland/overlap_notify.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use cctk::{sctk::shell::wlr_layer::Layer, wayland_protocols::ext::foreign_toplevel_list::v1::client::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1};

#[derive(Debug, Clone, PartialEq)]
pub enum OverlapNotifyEvent {
OverlapToplevelAdd {
toplevel: ExtForeignToplevelHandleV1,
logical_rect: crate::Rectangle,
},
OverlapToplevelRemove {
toplevel: ExtForeignToplevelHandleV1,
},
OverlapLayerAdd {
identifier: String,
namespace: String,
exclusive: u32,
layer: Option<Layer>,
logical_rect: crate::Rectangle,
},
OverlapLayerRemove {
identifier: String,
},
}
2 changes: 1 addition & 1 deletion core/src/event/wayland/session_lock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::window::Id;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface;

/// session lock events
#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion examples/sctk_drag/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ iced = { path = "../..", default-features = false, features = [
] }
env_logger = "0.10"
# sctk = { package = "smithay-client-toolkit", path = "../../../fork/client-toolkit/" }
sctk.workspace = true
cctk.workspace = true
3 changes: 2 additions & 1 deletion examples/sctk_subsurface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "828b1eb" }
# sctk = { package = "smithay-client-toolkit", git = "https://github.com/smithay/client-toolkit", rev = "828b1eb" }
iced = { path = "../..", default-features = false, features = [
"tokio",
"wayland",
Expand All @@ -17,3 +17,4 @@ env_logger = "0.10"
futures-channel = "0.3.29"
calloop = "0.12.3"
rustix = { version = "0.38.30", features = ["fs", "shm"] }
cctk.workspace = true
2 changes: 1 addition & 1 deletion examples/sctk_subsurface/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use iced::{
window::{self, Id, Settings},
Element, Length, Subscription, Task,
};
use sctk::reexports::client::{Connection, Proxy};
use cctk::sctk::reexports::client::{Connection, Proxy};

mod wayland;

Expand Down
4 changes: 2 additions & 2 deletions examples/sctk_subsurface/src/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use iced::{
};
use iced_runtime::futures::subscription;
use rustix::{io::Errno, shm::ShmOFlags};
use sctk::{
use cctk::sctk::{
reexports::{
calloop_wayland_source::WaylandSource,
client::{
Expand Down Expand Up @@ -40,7 +40,7 @@ impl ProvidesRegistryState for AppData {
&mut self.registry_state
}

sctk::registry_handlers!();
cctk::sctk::registry_handlers!();
}

impl ShmHandler for AppData {
Expand Down
3 changes: 2 additions & 1 deletion examples/sctk_todos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
iced_core.workspace = true
once_cell = "1.15"
sctk.workspace = true
cctk.workspace = true
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
32 changes: 23 additions & 9 deletions examples/sctk_todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -24,11 +25,11 @@ use std::fmt::Debug;
static INPUT_ID: Lazy<text_input::Id> = 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())
Expand Down Expand Up @@ -89,17 +90,20 @@ impl Debug for Message {

impl Todos {
fn new() -> (Todos, Task<Message>) {
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: sctk::shell::wlr_layer::KeyboardInteractivity::OnDemand,
keyboard_interactivity: cctk::sctk::shell::wlr_layer::KeyboardInteractivity::OnDemand,
anchor: Anchor::LEFT.union(Anchor::RIGHT).union(Anchor::TOP),
..Default::default()
}),
overlap_notify(id, true)
]),
)
}
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ workspace = true
debug = []
multi-window = []
a11y = ["iced_accessibility", "iced_core/a11y"]
wayland = ["iced_core/wayland", "sctk"]
wayland = ["iced_core/wayland", "cctk"]

[dependencies]
bytes.workspace = true
iced_core.workspace = true
iced_futures.workspace = true
iced_futures.features = ["thread-pool"]
sctk.workspace = true
sctk.optional = true
cctk.workspace = true
cctk.optional = true
thiserror.workspace = true
raw-window-handle.workspace = true
iced_accessibility.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/platform_specific/wayland/layer_surface.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;

use iced_core::layout::Limits;
use sctk::{
use cctk::sctk::{
reexports::client::protocol::wl_output::WlOutput,
shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer},
};
Expand Down
15 changes: 11 additions & 4 deletions runtime/src/platform_specific/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

use std::fmt::Debug;

use iced_core::window::Id;

/// activation Actions
pub mod activation;

Expand All @@ -22,21 +24,26 @@ pub enum Action {
Activation(activation::Action),
/// session lock
SessionLock(session_lock::Action),
/// Overlap Notify
OverlapNotify(Id, bool),
}

impl Debug for Action {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::LayerSurface(arg0) => {
Action::LayerSurface(arg0) => {
f.debug_tuple("LayerSurface").field(arg0).finish()
}
Self::Popup(arg0) => f.debug_tuple("Popup").field(arg0).finish(),
Self::Activation(arg0) => {
Action::Popup(arg0) => f.debug_tuple("Popup").field(arg0).finish(),
Action::Activation(arg0) => {
f.debug_tuple("Activation").field(arg0).finish()
}
Self::SessionLock(arg0) => {
Action::SessionLock(arg0) => {
f.debug_tuple("SessionLock").field(arg0).finish()
}
Action::OverlapNotify(id, _) => {
f.debug_tuple("OverlapNotify").field(id).finish()
}
}
}
}
2 changes: 1 addition & 1 deletion runtime/src/platform_specific/wayland/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher};
use iced_core::layout::Limits;
use iced_core::window::Id;
use iced_core::Rectangle;
use sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{
use cctk::sctk::reexports::protocols::xdg::shell::client::xdg_positioner::{
Anchor, Gravity,
};
/// Popup creation details
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/platform_specific/wayland/session_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;

use iced_core::window::Id;

use sctk::reexports::client::protocol::wl_output::WlOutput;
use cctk::sctk::reexports::client::protocol::wl_output::WlOutput;

/// Session lock action
#[derive(Clone)]
Expand Down
2 changes: 1 addition & 1 deletion wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ resvg.optional = true

rustix = { version = "0.38" }
raw-window-handle.workspace = true
sctk.workspace = true
cctk.workspace = true
wayland-protocols.workspace = true
wayland-backend = { version = "0.3.3", features = ["client_system"] }
wayland-client = { version = "0.31.2" }
Expand Down
8 changes: 4 additions & 4 deletions wgpu/src/window/wayland.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::graphics::compositor::Window;
use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle};
use sctk::{
use cctk::sctk::{
dmabuf::{DmabufFeedback, DmabufHandler, DmabufState},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
};
use raw_window_handle::{RawDisplayHandle, WaylandDisplayHandle};
use wayland_client::{
backend::Backend, globals::registry_queue_init, protocol::wl_buffer,
Connection, QueueHandle,
Expand Down Expand Up @@ -111,5 +111,5 @@ pub fn get_wayland_device_ids<W: Window>(window: &W) -> Option<(u16, u16)> {
}
}

sctk::delegate_dmabuf!(AppData);
sctk::delegate_registry!(AppData);
cctk::sctk::delegate_dmabuf!(AppData);
cctk::sctk::delegate_registry!(AppData);
6 changes: 3 additions & 3 deletions widget/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ markdown = ["dep:pulldown-cmark", "dep:url"]
highlighter = ["dep:iced_highlighter"]
advanced = []
a11y = ["iced_accessibility"]
wayland = ["sctk", "iced_runtime/wayland"]
wayland = ["cctk", "iced_runtime/wayland"]

[dependencies]
iced_renderer.workspace = true
iced_runtime.workspace = true
iced_accessibility.workspace = true
iced_accessibility.optional = true
sctk.workspace = true
sctk.optional = true
cctk.workspace = true
cctk.optional = true
num-traits.workspace = true
once_cell.workspace = true
rustc-hash.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions winit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ program = []
x11 = ["winit/x11"]
wayland = [
"winit/wayland",
"sctk",
"cctk",
"wayland-protocols",
"raw-window-handle",
"iced_runtime/wayland",
Expand Down Expand Up @@ -58,8 +58,8 @@ sysinfo.optional = true

[target.'cfg(target_os = "linux")'.dependencies]
raw-window-handle = { version = "0.6", optional = true }
sctk.workspace = true
sctk.optional = true
cctk.workspace = true
cctk.optional = true
wayland-protocols.workspace = true
wayland-protocols.optional = true
wayland-backend = { version = "0.3.1", features = [
Expand Down
Loading
Loading