-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
organization: split compositor specific stuff into their own modules
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
- Loading branch information
Showing
5 changed files
with
242 additions
and
216 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use std::collections::HashSet; | ||
|
||
use cosmic_protocols::toplevel_info::v1::client::{ | ||
zcosmic_toplevel_handle_v1, zcosmic_toplevel_info_v1, | ||
}; | ||
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle}; | ||
|
||
use super::{AppData, ToplevelHandle, ToplevelHandleEvent, ToplevelManagerEvent, ToplevelState}; | ||
|
||
impl From<zcosmic_toplevel_handle_v1::State> for ToplevelState { | ||
fn from(value: zcosmic_toplevel_handle_v1::State) -> Self { | ||
match value { | ||
zcosmic_toplevel_handle_v1::State::Maximized => Self::Maximized, | ||
zcosmic_toplevel_handle_v1::State::Minimized => Self::Minimized, | ||
zcosmic_toplevel_handle_v1::State::Activated => Self::Activated, | ||
zcosmic_toplevel_handle_v1::State::Fullscreen => Self::Fullscreen, | ||
_ => todo!(), | ||
} | ||
} | ||
} | ||
|
||
impl From<zcosmic_toplevel_handle_v1::Event> for ToplevelHandleEvent { | ||
fn from(value: zcosmic_toplevel_handle_v1::Event) -> Self { | ||
match value { | ||
zcosmic_toplevel_handle_v1::Event::Closed => ToplevelHandleEvent::Closed, | ||
zcosmic_toplevel_handle_v1::Event::Done => ToplevelHandleEvent::Done, | ||
zcosmic_toplevel_handle_v1::Event::Title { title } => { | ||
ToplevelHandleEvent::Title { title } | ||
} | ||
zcosmic_toplevel_handle_v1::Event::AppId { app_id } => { | ||
ToplevelHandleEvent::AppId { app_id } | ||
} | ||
zcosmic_toplevel_handle_v1::Event::OutputEnter { output } => { | ||
ToplevelHandleEvent::OutputEnter { output } | ||
} | ||
zcosmic_toplevel_handle_v1::Event::OutputLeave { output } => { | ||
ToplevelHandleEvent::OutputLeave { output } | ||
} | ||
zcosmic_toplevel_handle_v1::Event::WorkspaceEnter { .. } => todo!(), | ||
zcosmic_toplevel_handle_v1::Event::WorkspaceLeave { .. } => todo!(), | ||
zcosmic_toplevel_handle_v1::Event::State { state } => { | ||
let mut r_state = HashSet::new(); | ||
for value in state.chunks_exact(4) { | ||
if let Ok(state) = zcosmic_toplevel_handle_v1::State::try_from( | ||
u32::from_ne_bytes(value[0..4].try_into().unwrap()), | ||
) { | ||
r_state.insert(ToplevelState::from(state)); | ||
} | ||
} | ||
Self::State { state: r_state } | ||
} | ||
_ => todo!(), | ||
} | ||
} | ||
} | ||
|
||
impl From<zcosmic_toplevel_info_v1::Event> for ToplevelManagerEvent { | ||
fn from(value: zcosmic_toplevel_info_v1::Event) -> Self { | ||
match value { | ||
zcosmic_toplevel_info_v1::Event::Toplevel { toplevel } => { | ||
Self::Toplevel(ToplevelHandle::Zcosmic(toplevel)) | ||
} | ||
zcosmic_toplevel_info_v1::Event::Finished => Self::Finished, | ||
_ => todo!(), | ||
} | ||
} | ||
} | ||
|
||
// COSMIC Foreign Toplevel Info | ||
|
||
impl Dispatch<zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ()> for AppData { | ||
fn event( | ||
state: &mut Self, | ||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, | ||
event: <zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1 as Proxy>::Event, | ||
_data: &(), | ||
_conn: &Connection, | ||
_qhandle: &QueueHandle<Self>, | ||
) { | ||
state.handle_toplevel_handle_event( | ||
ToplevelHandle::Zcosmic(toplevel.clone()), | ||
ToplevelHandleEvent::from(event), | ||
); | ||
} | ||
} | ||
|
||
impl Dispatch<zcosmic_toplevel_info_v1::ZcosmicToplevelInfoV1, ()> for AppData { | ||
fn event( | ||
state: &mut Self, | ||
_proxy: &zcosmic_toplevel_info_v1::ZcosmicToplevelInfoV1, | ||
event: <zcosmic_toplevel_info_v1::ZcosmicToplevelInfoV1 as Proxy>::Event, | ||
_data: &(), | ||
_conn: &Connection, | ||
_qhandle: &QueueHandle<Self>, | ||
) { | ||
state.handle_toplevel_manager_event(ToplevelManagerEvent::from(event)); | ||
} | ||
|
||
wayland_client::event_created_child!(AppData, zcosmic_toplevel_info_v1::ZcosmicToplevelInfoV1, [ | ||
zcosmic_toplevel_info_v1::EVT_TOPLEVEL_OPCODE => (zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ()) | ||
]); | ||
} |
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,34 @@ | ||
// KDE Window Management | ||
|
||
use wayland_client::{Connection, Dispatch, Proxy, QueueHandle}; | ||
use wayland_protocols_plasma::plasma_window_management::client::{ | ||
org_kde_plasma_window, org_kde_plasma_window_management, | ||
}; | ||
|
||
use super::AppData; | ||
|
||
impl Dispatch<org_kde_plasma_window::OrgKdePlasmaWindow, ()> for AppData { | ||
fn event( | ||
_state: &mut Self, | ||
_proxy: &org_kde_plasma_window::OrgKdePlasmaWindow, | ||
event: <org_kde_plasma_window::OrgKdePlasmaWindow as Proxy>::Event, | ||
_data: &(), | ||
_conn: &Connection, | ||
_qhandle: &QueueHandle<Self>, | ||
) { | ||
println!("{:?}", event); | ||
} | ||
} | ||
|
||
impl Dispatch<org_kde_plasma_window_management::OrgKdePlasmaWindowManagement, ()> for AppData { | ||
fn event( | ||
_state: &mut Self, | ||
_proxy: &org_kde_plasma_window_management::OrgKdePlasmaWindowManagement, | ||
event: <org_kde_plasma_window_management::OrgKdePlasmaWindowManagement as Proxy>::Event, | ||
_data: &(), | ||
_conn: &Connection, | ||
_qhandle: &QueueHandle<Self>, | ||
) { | ||
println!("{:?}", event); | ||
} | ||
} |
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
Oops, something went wrong.