-
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.
Signed-off-by: Ryan Brue <ryanbrue@gmail.com>
- Loading branch information
Showing
4 changed files
with
179 additions
and
127 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
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 |
---|---|---|
@@ -1,22 +1,56 @@ | ||
use std::env; | ||
|
||
use cosmic_comp::CosmicCompBackend; | ||
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1; | ||
|
||
use crate::app_tray::AppTray; | ||
|
||
pub mod cosmic_comp; | ||
pub mod wlr; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum WaylandMessage { | ||
CosmicComp(cosmic_comp::CosmicWaylandMessage), | ||
Wlroots(), | ||
pub enum CompositorBackend { | ||
Cosmic(CosmicCompBackend), | ||
} | ||
|
||
pub(crate) fn wayland_subscription() -> iced::Subscription<WaylandMessage> { | ||
// set the environment variable RYANABX_SHELL_DESKTOP to set which desktop session should be inferred | ||
let current_compositor = match env::var("RYANABX_SHELL_DESKTOP") { | ||
Ok(val) => Ok(val), | ||
_ => env::var("XDG_CURRENT_DESKTOP"), // fall back on XDG_CURRENT_DESKTOP if not set | ||
}; | ||
match current_compositor.as_deref() { | ||
Ok("COSMIC") => cosmic_comp::wayland_subscription().map(WaylandMessage::CosmicComp), | ||
_ => panic!("Unsupported desktop"), | ||
impl CompositorBackend { | ||
pub fn new() -> Self { | ||
// set the environment variable RYANABX_SHELL_DESKTOP to set which desktop session should be inferred | ||
let current_compositor = match env::var("RYANABX_SHELL_DESKTOP") { | ||
Ok(val) => Ok(val), | ||
_ => env::var("XDG_CURRENT_DESKTOP"), // fall back on XDG_CURRENT_DESKTOP if not set | ||
}; | ||
match current_compositor.as_deref() { | ||
Ok("COSMIC") => Self::Cosmic(CosmicCompBackend::new()), | ||
_ => panic!("Unsupported desktop"), | ||
} | ||
} | ||
|
||
pub fn wayland_subscription(&self) -> iced::Subscription<WaylandEvent> { | ||
match self { | ||
Self::Cosmic(backend) => backend.wayland_subscription().map(WaylandEvent::Cosmic), | ||
} | ||
} | ||
|
||
pub fn handle_message( | ||
&mut self, | ||
app_tray: &mut AppTray, | ||
event: WaylandEvent, | ||
) -> Option<iced::Command<crate::Message>> { | ||
match (self, event) { | ||
(Self::Cosmic(backend), WaylandEvent::Cosmic(evt)) => { | ||
backend.handle_message(app_tray, evt) | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum WaylandEvent { | ||
Cosmic(cosmic_comp::CosmicWaylandMessage), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum WindowHandle { | ||
Cosmic(ZcosmicToplevelHandleV1), | ||
} |
Oops, something went wrong.