Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
  • Loading branch information
ryanabx committed Aug 23, 2024
1 parent 54fc8cc commit e0ecbc7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 63 deletions.
33 changes: 5 additions & 28 deletions src/app_tray/compositor/cosmic_comp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,28 +292,6 @@ impl ToplevelInfoHandler for WaylandData {
}
}

// if let Some(security_context_manager) = security_context_manager.as_ref() {
// match security_context_manager.create_listener::<SpaceContainer>(qh) {
// Ok(security_context) => {
// security_context.set_sandbox_engine(NAME.to_string());
// security_context.commit();

// let data = security_context.data::<SecurityContext>().unwrap();
// let privileged_socket = data.conn.lock().unwrap().take().unwrap();
// applet_env.push((
// "X_PRIVILEGED_WAYLAND_SOCKET".to_string(),
// privileged_socket.as_raw_fd().to_string(),
// ));

// fds.push(privileged_socket.into());
// panel_client.security_ctx = Some(security_context);
// },
// Err(why) => {
// error!(?why, "Failed to create a listener");
// },
// }
// }

fn wayland_handler(tx: UnboundedSender<CosmicIncoming>, rx: Channel<WaylandRequest>) {
let socket = std::env::var("X_PRIVILEGED_WAYLAND_SOCKET")
.ok()
Expand Down Expand Up @@ -363,12 +341,11 @@ fn wayland_handler(tx: UnboundedSender<CosmicIncoming>, rx: Channel<WaylandReque
gpu_idx,
} => {
if let Some(activation_state) = state.activation_state.as_ref() {
let seat_and_serial = state
.seat_state
.seats()
.next()
.map(|seat| (seat, 0));
println!("HERE: {} {} {:?}, {:?}", &app_id, &exec, gpu_idx, seat_and_serial);
let seat_and_serial = state.seat_state.seats().next().map(|seat| (seat, 0));
println!(
"HERE: {} {} {:?}, {:?}",
&app_id, &exec, gpu_idx, seat_and_serial
);
activation_state.request_token_with_data(
&state.queue_handle,
ExecRequestData {
Expand Down
17 changes: 11 additions & 6 deletions src/app_tray/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ use std::collections::HashMap;
use cctk::toplevel_info::ToplevelInfo;
use cosmic_comp::CosmicCompBackend;
use cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1;
use iced::Subscription;

use super::{AppTrayMessage, ApplicationGroup};

pub mod cosmic_comp;
pub mod wlr;

#[derive(Clone, Debug)]
pub enum CompositorBackend {
Cosmic(CosmicCompBackend),
None,
#[allow(dead_code)]
NotSupported,
}
Expand All @@ -20,14 +21,16 @@ impl CompositorBackend {
pub fn new(compositor: &str) -> Self {
match compositor {
"COSMIC" => Self::Cosmic(CosmicCompBackend::new()),
"none" => Self::None,
desktop => panic!("Unsupported desktop {desktop}. Specify a backend with the env variable RYANABX_SHELL_DESKTOP"),
}
}

pub fn wayland_subscription(&self) -> iced::Subscription<WaylandIncoming> {
match self {
Self::Cosmic(backend) => backend.wayland_subscription().map(WaylandIncoming::Cosmic),
Self::NotSupported => todo!(),
Self::None => Subscription::none(),
Self::NotSupported => panic!("Not supported"),
}
}

Expand All @@ -40,8 +43,8 @@ impl CompositorBackend {
(Self::Cosmic(backend), WaylandIncoming::Cosmic(evt)) => {
backend.handle_incoming(active_toplevels, evt)
}
(Self::NotSupported, _) => todo!(),
(_, WaylandIncoming::NotSupported) => todo!(),
(Self::None, _) => None,
(Self::NotSupported, _) | (_, WaylandIncoming::NotSupported) => panic!("Not supported"),
}
}

Expand All @@ -52,7 +55,8 @@ impl CompositorBackend {
) -> Option<iced::Command<AppTrayMessage>> {
match self {
Self::Cosmic(backend) => backend.handle_outgoing(active_toplevels, outgoing),
_ => todo!(),
Self::None => None,
Self::NotSupported => panic!("Not supported"),
}
}

Expand All @@ -62,7 +66,8 @@ impl CompositorBackend {
) -> Option<WindowHandle> {
match self {
Self::Cosmic(backend) => backend.active_window(active_toplevels),
_ => todo!(),
Self::None => None,
Self::NotSupported => panic!("Not supported"),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/app_tray/compositor/wlr.rs

This file was deleted.

57 changes: 29 additions & 28 deletions src/app_tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'a> AppTray<'a> {
iced::widget::container(x)
.width(48.0)
.height(48.0)
.padding(6.0),
.padding(4.0),
)
});
iced::widget::row(app_tray_apps).into()
Expand Down Expand Up @@ -145,19 +145,21 @@ pub fn get_tray_widget<'a>(
Some(path) => {
if path.extension().is_some_and(|x| x == "svg") {
iced::widget::button(column![
get_horizontal_rule(&app_info, &active_window.as_ref(), true),
iced::widget::svg(path)
.content_fit(iced::ContentFit::Contain)
.width(Length::Fill)
.height(Length::Fill),
get_horizontal_rule(&app_info, &active_window.as_ref())
get_horizontal_rule(&app_info, &active_window.as_ref(), false)
])
} else {
iced::widget::button(column![
get_horizontal_rule(&app_info, &active_window.as_ref(), true),
iced::widget::image(path)
.content_fit(iced::ContentFit::Contain)
.width(Length::Fill)
.height(Length::Fill),
get_horizontal_rule(&app_info, &active_window.as_ref())
get_horizontal_rule(&app_info, &active_window.as_ref(), false)
])
}
}
Expand Down Expand Up @@ -195,30 +197,29 @@ pub fn get_tray_widget<'a>(
fn get_horizontal_rule<'a>(
app_info: &ApplicationGroup,
active_window: &Option<&WindowHandle>,
force_transparent: bool,
) -> Container<'a, AppTrayMessage> {
if app_info.toplevels.is_empty() {
iced::widget::container(iced::widget::Space::new(
Length::Fixed(6.0),
Length::Fixed(2.0),
))
} else {
iced::widget::container(
iced::widget::horizontal_rule(1)
.style(move |theme: &Theme| iced::widget::rule::Style {
color: theme.palette().primary,
width: (2.0) as u16,
radius: 4.into(),
fill_mode: iced::widget::rule::FillMode::Full,
})
.width(Length::Fixed(
if active_window.is_some_and(|w| app_info.toplevels.contains_key(w)) {
12.0
} else {
6.0
},
)),
)
}
let transparent = force_transparent || app_info.toplevels.is_empty();
iced::widget::container(
iced::widget::horizontal_rule(1)
.style(move |theme: &Theme| iced::widget::rule::Style {
color: if transparent {
iced::Color::TRANSPARENT
} else {
theme.palette().primary
},
width: (2.0) as u16,
radius: 4.into(),
fill_mode: iced::widget::rule::FillMode::Full,
})
.width(Length::Fixed(
if active_window.is_some_and(|w| app_info.toplevels.contains_key(w)) {
12.0
} else {
6.0
},
)),
)
.center_x(Length::Fill)
}

Expand All @@ -242,9 +243,9 @@ fn tray_button_style<'a>(
}
} else if active_window.is_some_and(|x| app_info.toplevels.contains_key(x)) {
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
(0.21, 0.2)
(0.26, 0.25)
} else {
(0.11, 0.1)
(0.21, 0.20)
}
} else {
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
Expand Down

0 comments on commit e0ecbc7

Please sign in to comment.