forked from iced-rs/iced
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
427 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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, | ||
exclusive: u32, | ||
layer: Option<Layer>, | ||
logical_rect: crate::Rectangle, | ||
}, | ||
OverlapLayerRemove { | ||
identifier: String, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
pub mod activation; | ||
pub mod layer_surface; | ||
pub mod overlap_notify; | ||
pub mod popup; | ||
pub mod session_lock; |
14 changes: 14 additions & 0 deletions
14
winit/src/platform_specific/wayland/commands/overlap_notify.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use iced_futures::core::window::Id; | ||
use iced_runtime::{ | ||
platform_specific::{self, wayland}, | ||
task, Action, Task, | ||
}; | ||
|
||
/// Request subscription for overlap notification events on the surface | ||
pub fn overlap_notify<Message>(id: Id, enable: bool) -> Task<Message> { | ||
task::effect(Action::PlatformSpecific( | ||
platform_specific::Action::Wayland(wayland::Action::OverlapNotify( | ||
id, enable, | ||
)), | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
winit/src/platform_specific/wayland/handlers/overlap.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
use cctk::{ | ||
cosmic_protocols::overlap_notify::v1::client::{ | ||
zcosmic_overlap_notification_v1::{self, ZcosmicOverlapNotificationV1}, | ||
zcosmic_overlap_notify_v1::ZcosmicOverlapNotifyV1, | ||
}, sctk::shell::wlr_layer::Layer, wayland_client::{ | ||
self, event_created_child, | ||
globals::{BindError, GlobalList}, | ||
protocol::wl_surface::WlSurface, | ||
Connection, Dispatch, Proxy, QueueHandle, | ||
}, wayland_protocols::ext::foreign_toplevel_list::v1::client::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1 | ||
}; | ||
use cctk::sctk::globals::GlobalData; | ||
use iced_futures::core::Rectangle; | ||
|
||
use crate::{event_loop::state::SctkState, sctk_event::SctkEvent}; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct OverlapNotifyV1 { | ||
pub(crate) notify: ZcosmicOverlapNotifyV1, | ||
} | ||
|
||
impl OverlapNotifyV1 { | ||
pub fn bind( | ||
globals: &GlobalList, | ||
qh: &QueueHandle<SctkState>, | ||
) -> Result<OverlapNotifyV1, BindError> { | ||
let notify = globals.bind(qh, 1..=1, GlobalData)?; | ||
Ok(OverlapNotifyV1 { notify }) | ||
} | ||
} | ||
|
||
impl Dispatch<ZcosmicOverlapNotifyV1, GlobalData, SctkState> | ||
for OverlapNotifyV1 | ||
{ | ||
fn event( | ||
_: &mut SctkState, | ||
_: &ZcosmicOverlapNotifyV1, | ||
_: <ZcosmicOverlapNotifyV1 as Proxy>::Event, | ||
_: &GlobalData, | ||
_: &Connection, | ||
_: &QueueHandle<SctkState>, | ||
) { | ||
} | ||
} | ||
|
||
pub struct OverlapNotificationV1 { | ||
surface: WlSurface, | ||
} | ||
|
||
impl Dispatch<ZcosmicOverlapNotificationV1, GlobalData, SctkState> | ||
for OverlapNotificationV1 | ||
{ | ||
fn event( | ||
state: &mut SctkState, | ||
n: &ZcosmicOverlapNotificationV1, | ||
event: <ZcosmicOverlapNotificationV1 as Proxy>::Event, | ||
_: &GlobalData, | ||
_: &Connection, | ||
_: &QueueHandle<SctkState>, | ||
) { | ||
let data: Option<&OverlapNotificationV1> = n.data(); | ||
let Some(data) = data else { | ||
return; | ||
}; | ||
|
||
let surface = data.surface.clone(); | ||
|
||
state.sctk_events.push(match event { | ||
zcosmic_overlap_notification_v1::Event::ToplevelEnter { | ||
toplevel, | ||
x, | ||
y, | ||
width, | ||
height, | ||
} => SctkEvent::OverlapToplevelAdd { | ||
surface, | ||
toplevel, | ||
logical_rect: Rectangle::new( | ||
(x as f32, y as f32).into(), | ||
(width as f32, height as f32).into(), | ||
), | ||
}, | ||
zcosmic_overlap_notification_v1::Event::ToplevelLeave { | ||
toplevel, | ||
} => { | ||
SctkEvent::OverlapToplevelRemove { surface, toplevel } | ||
} | ||
zcosmic_overlap_notification_v1::Event::LayerEnter { | ||
identifier, | ||
exclusive, | ||
layer, | ||
x, | ||
y, | ||
width, | ||
height, | ||
} => SctkEvent::OverlapLayerAdd { surface, 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), | ||
cctk::sctk::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::Layer::Top => Some(Layer::Top), | ||
cctk::sctk::reexports::protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::Layer::Overlay => Some(Layer::Overlay), | ||
_ => Default::default(), | ||
}, | ||
wayland_client::WEnum::Unknown(_) => Default::default(), | ||
}, logical_rect: Rectangle::new( | ||
(x as f32, y as f32).into(), | ||
(width as f32, height as f32).into(), | ||
), }, | ||
zcosmic_overlap_notification_v1::Event::LayerLeave { | ||
identifier, | ||
} => SctkEvent::OverlapLayerRemove { identifier, surface }, | ||
_ => unimplemented!(), | ||
}); | ||
} | ||
|
||
event_created_child!(SctkState, ZcosmicOverlapNotifyV1, [ | ||
0 => (ExtForeignToplevelHandleV1, Default::default()) | ||
]); | ||
} | ||
|
||
wayland_client::delegate_dispatch!(SctkState: [ZcosmicOverlapNotifyV1: GlobalData] => OverlapNotifyV1); | ||
wayland_client::delegate_dispatch!(SctkState: [ZcosmicOverlapNotificationV1: GlobalData] => OverlapNotificationV1); |
Oops, something went wrong.