feat: overlap notify
This commit is contained in:
parent
6e91eabf4c
commit
301892aaa5
11 changed files with 441 additions and 51 deletions
|
|
@ -2,11 +2,12 @@
|
|||
pub mod activation;
|
||||
pub mod compositor;
|
||||
pub mod output;
|
||||
// pub mod overlap;
|
||||
pub mod overlap;
|
||||
pub mod seat;
|
||||
pub mod session_lock;
|
||||
pub mod shell;
|
||||
pub mod subcompositor;
|
||||
pub mod toplevel;
|
||||
pub mod wp_fractional_scaling;
|
||||
pub mod wp_viewporter;
|
||||
|
||||
|
|
|
|||
117
winit/src/platform_specific/wayland/handlers/overlap.rs
Normal file
117
winit/src/platform_specific/wayland/handlers/overlap.rs
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
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 {
|
||||
pub surface: WlSurface,
|
||||
}
|
||||
|
||||
impl Dispatch<ZcosmicOverlapNotificationV1, OverlapNotificationV1, SctkState>
|
||||
for OverlapNotificationV1
|
||||
{
|
||||
fn event(
|
||||
state: &mut SctkState,
|
||||
_: &ZcosmicOverlapNotificationV1,
|
||||
event: <ZcosmicOverlapNotificationV1 as Proxy>::Event,
|
||||
data: &OverlapNotificationV1,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<SctkState>,
|
||||
) {
|
||||
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: OverlapNotificationV1] => OverlapNotificationV1);
|
||||
67
winit/src/platform_specific/wayland/handlers/toplevel.rs
Normal file
67
winit/src/platform_specific/wayland/handlers/toplevel.rs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
use cctk::{
|
||||
cosmic_protocols::{
|
||||
toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
|
||||
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
||||
},
|
||||
toplevel_info::{ToplevelInfoHandler, ToplevelInfoState},
|
||||
toplevel_management::ToplevelManagerHandler,
|
||||
wayland_client::{self, WEnum},
|
||||
};
|
||||
use wayland_client::{Connection, QueueHandle};
|
||||
|
||||
use crate::event_loop::state::SctkState;
|
||||
|
||||
impl ToplevelManagerHandler for SctkState {
|
||||
fn toplevel_manager_state(
|
||||
&mut self,
|
||||
) -> &mut cctk::toplevel_management::ToplevelManagerState {
|
||||
self.toplevel_manager.as_mut().unwrap()
|
||||
}
|
||||
|
||||
fn capabilities(
|
||||
&mut self,
|
||||
_conn: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
_capabilities: Vec<
|
||||
WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
|
||||
>,
|
||||
) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
impl ToplevelInfoHandler for SctkState {
|
||||
fn toplevel_info_state(&mut self) -> &mut ToplevelInfoState {
|
||||
self.toplevel_info.as_mut().unwrap()
|
||||
}
|
||||
|
||||
fn new_toplevel(
|
||||
&mut self,
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
fn update_toplevel(
|
||||
&mut self,
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
fn toplevel_closed(
|
||||
&mut self,
|
||||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
_toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
cctk::delegate_toplevel_info!(SctkState);
|
||||
cctk::delegate_toplevel_manager!(SctkState);
|
||||
Loading…
Add table
Add a link
Reference in a new issue