Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cosmic-panel-bin/src/iced/elements/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use calloop::LoopHandle;
use cosmic::{
iced::{id, Color, Length, Radius},
iced::{id, Color, Length},
iced_core::Shadow,
theme,
widget::horizontal_space,
Expand Down
8 changes: 2 additions & 6 deletions cosmic-panel-bin/src/iced/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cosmic::{
keyboard::{Event as KeyboardEvent, Modifiers as IcedModifiers},
mouse::{Button as MouseButton, Cursor, Event as MouseEvent, ScrollDelta},
window::Event as WindowEvent,
Limits, Point as IcedPoint, Rectangle as IcedRectangle, Size as IcedSize, Task,
Limits, Point as IcedPoint, Size as IcedSize, Task,
},
iced_core::{clipboard::Null as NullClipboard, renderer::Style, Color, Font, Length, Pixels},
iced_renderer::Renderer as IcedRenderer,
Expand All @@ -28,10 +28,7 @@ use cosmic::{
widget::Id,
Theme,
};
use iced_tiny_skia::{
graphics::{damage, Viewport},
Primitive,
};
use iced_tiny_skia::graphics::Viewport;
use once_cell::sync::Lazy;
use ordered_float::OrderedFloat;
use smithay::{
Expand Down Expand Up @@ -67,7 +64,6 @@ use smithay::{
};

pub mod elements;
pub mod panel_message;

static ID: Lazy<Id> = Lazy::new(|| Id::new("Program"));

Expand Down
9 changes: 0 additions & 9 deletions cosmic-panel-bin/src/iced/panel_message.rs

This file was deleted.

27 changes: 12 additions & 15 deletions cosmic-panel-bin/src/space/corner_element/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,18 @@ pub fn init_shaders(gles_renderer: &mut GlesRenderer) -> Result<(), GlesError> {
}
}

let rectangle_shader = gles_renderer.compile_custom_pixel_shader(
RECTANGLE_SHADER,
&[
UniformName::new("rad_tl", UniformType::_1f),
UniformName::new("rad_tr", UniformType::_1f),
UniformName::new("rad_bl", UniformType::_1f),
UniformName::new("rad_br", UniformType::_1f),
UniformName::new("loc", UniformType::_2f),
UniformName::new("rect_size", UniformType::_2f),
UniformName::new("border_width", UniformType::_1f),
UniformName::new("drop_shadow", UniformType::_1f),
UniformName::new("bg_color", UniformType::_4f),
UniformName::new("border_color", UniformType::_4f),
],
)?;
let rectangle_shader = gles_renderer.compile_custom_pixel_shader(RECTANGLE_SHADER, &[
UniformName::new("rad_tl", UniformType::_1f),
UniformName::new("rad_tr", UniformType::_1f),
UniformName::new("rad_bl", UniformType::_1f),
UniformName::new("rad_br", UniformType::_1f),
UniformName::new("loc", UniformType::_2f),
UniformName::new("rect_size", UniformType::_2f),
UniformName::new("border_width", UniformType::_1f),
UniformName::new("drop_shadow", UniformType::_1f),
UniformName::new("bg_color", UniformType::_4f),
UniformName::new("border_color", UniformType::_4f),
])?;

let egl_context = gles_renderer.egl_context();
egl_context.user_data().insert_if_missing(|| RoundedRectangleShader(rectangle_shader));
Expand Down
8 changes: 5 additions & 3 deletions cosmic-panel-bin/src/space/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ impl PanelSpace {
} else if c.shrink_priority.is_some() {
overflow_partition.movable.push(w);
} else {
// make shrinkable if no shrink priority with lowest priority so it is moved last
// make shrinkable if no shrink priority with lowest priority so it is moved
// last
overflow_partition.shrinkable.push((w.0, -1, ClientShrinkSize::AppletUnit(1)));
}
}
Expand Down Expand Up @@ -1065,8 +1066,8 @@ impl PanelSpace {
}
if overflow > 0 && !force_smaller {
tracing::info!(
"Overflow not resolved {sum:.1} {overflow}. Forcing lowest priority shrinkable applets to be \
smaller than configured...",
"Overflow not resolved {sum:.1} {overflow}. Forcing lowest priority shrinkable \
applets to be smaller than configured...",
);
return self.shrink_clients(overflow, clients, section, true);
}
Expand Down Expand Up @@ -1404,6 +1405,7 @@ impl PanelSpace {
suggested_size,
);
}

fn relax_overflow_right(
&mut self,
extra_space: u32,
Expand Down
4 changes: 2 additions & 2 deletions cosmic-panel-bin/src/space/panel_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,8 @@ impl PanelSpace {
// return early
if config.anchor() != self.config.anchor() {
panic!(
"Can't apply anchor changes when orientation changes. Requires re-creation of \
the panel."
"Can't apply anchor changes when orientation changes. Requires re-creation of the \
panel."
);
}

Expand Down
7 changes: 3 additions & 4 deletions cosmic-panel-bin/src/space/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,9 @@ impl PanelSpace {
// TODO check to make sure this is not going to cause damage issues
if not_visible {
if let Ok(mut frame) = renderer.render(dim, smithay::utils::Transform::Normal) {
_ = frame.clear(
Color32F::new(0.0, 0.0, 0.0, 0.0),
&[Rectangle::from_loc_and_size((0, 0), dim)],
);
_ = frame.clear(Color32F::new(0.0, 0.0, 0.0, 0.0), &[
Rectangle::from_loc_and_size((0, 0), dim),
]);
if let Ok(sync_point) = frame.finish() {
if let Err(err) = sync_point.wait() {
tracing::error!("Error waiting for sync point: {:?}", err);
Expand Down
11 changes: 4 additions & 7 deletions cosmic-panel-bin/src/space/wrapper_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,13 +650,10 @@ impl WrapperSpace for PanelSpace {
return;
};
if let Err(err) = pman
.update_process_env(
&key,
vec![(
"COSMIC_NOTIFICATIONS".to_string(),
fd.as_raw_fd().to_string(),
)],
)
.update_process_env(&key, vec![(
"COSMIC_NOTIFICATIONS".to_string(),
fd.as_raw_fd().to_string(),
)])
.await
{
error!("Failed to update process env: {}", err);
Expand Down
12 changes: 3 additions & 9 deletions cosmic-panel-bin/src/space_container/space_container.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
rc::Rc,
sync::Arc,
};
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc};

use crate::{
minimize::MinimizeApplet,
Expand All @@ -22,8 +17,7 @@ use crate::{
};
use cctk::{
cosmic_protocols::toplevel_info::v1::client::zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
toplevel_info::ToplevelInfo,
wayland_client::{self, protocol::wl_seat::WlSeat},
toplevel_info::ToplevelInfo, wayland_client::protocol::wl_seat::WlSeat,
workspace::WorkspaceGroup,
};
use cosmic::{cosmic_config::CosmicConfigEntry, iced::id, theme};
Expand Down Expand Up @@ -224,7 +218,7 @@ impl SpaceContainer {
layer_state: &mut LayerShell,
qh: &QueueHandle<GlobalState>,
force_output: Option<WlOutput>,
overlap_notify: Option<OverlapNotifyV1>,
_overlap_notify: Option<OverlapNotifyV1>,
) {
// if the output is set to "all", we need to check if the config is the same for
// all outputs if the output is set to a specific output, we need to
Expand Down
2 changes: 1 addition & 1 deletion cosmic-panel-bin/src/space_container/wrapper_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
wp_viewporter::ViewporterState,
},
};
use cctk::cosmic_protocols::overlap_notify;

use cosmic_panel_config::{CosmicPanelBackground, CosmicPanelContainerConfig, CosmicPanelOuput};
use itertools::Itertools;
use sctk::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
use sctk::{
compositor::CompositorHandler,
reexports::client::{protocol::wl_surface, Connection, QueueHandle},
shell::WaylandSurface,
};
use smithay::reexports::wayland_server::protocol::wl_output::Transform;

use crate::xdg_shell_wrapper::{shared_state::GlobalState, space::WrapperSpace};

Expand Down Expand Up @@ -48,41 +46,6 @@ impl CompositorHandler for GlobalState {
surface: &wl_surface::WlSurface,
new_transform: sctk::reexports::client::protocol::wl_output::Transform,
) {
for tracked_surface in &mut self.client_state.proxied_layer_surfaces {
if tracked_surface.3.wl_surface() == surface {
let transform = match new_transform {
sctk::reexports::client::protocol::wl_output::Transform::Normal => {
Transform::Normal
},
sctk::reexports::client::protocol::wl_output::Transform::_90 => Transform::_90,
sctk::reexports::client::protocol::wl_output::Transform::_180 => {
Transform::_180
},
sctk::reexports::client::protocol::wl_output::Transform::_270 => {
Transform::_270
},
sctk::reexports::client::protocol::wl_output::Transform::Flipped => {
Transform::Flipped
},
sctk::reexports::client::protocol::wl_output::Transform::Flipped90 => {
Transform::Flipped90
},
sctk::reexports::client::protocol::wl_output::Transform::Flipped180 => {
Transform::Flipped180
},
sctk::reexports::client::protocol::wl_output::Transform::Flipped270 => {
Transform::Flipped270
},
_ => {
tracing::warn!("Received unknown transform.");
return;
},
};
tracked_surface.2.wl_surface().preferred_buffer_transform(transform);
return;
}
}

self.space.transform_changed(conn, surface, new_transform);
}

Expand Down
25 changes: 3 additions & 22 deletions cosmic-panel-bin/src/xdg_shell_wrapper/client/handlers/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::xdg_shell_wrapper::{
use sctk::{
delegate_keyboard,
seat::keyboard::{KeyCode, KeyboardHandler, Keysym, RawModifiers, RepeatInfo},
shell::WaylandSurface,
};
use smithay::{backend::input::KeyState, input::keyboard::FilterResult, utils::SERIAL_COUNTER};

Expand Down Expand Up @@ -50,21 +49,9 @@ impl KeyboardHandler for GlobalState {
));
}
}
let s_surface =
self.client_state.proxied_layer_surfaces.iter_mut().find_map(|(_, _, s, c, ..)| {
if c.wl_surface() == surface {
Some(s.wl_surface().clone())
} else {
None
}
});

if let Some(s_surface) = s_surface {
kbd.set_focus(self, Some(s_surface.into()), SERIAL_COUNTER.next_serial());
} else {
let s = self.space.keyboard_enter(&seat_name, surface.clone());
kbd.set_focus(self, s.map(|s| s.into()), SERIAL_COUNTER.next_serial());
}
let s = self.space.keyboard_enter(&seat_name, surface.clone());
kbd.set_focus(self, s.map(|s| s.into()), SERIAL_COUNTER.next_serial());
}

fn leave(
Expand Down Expand Up @@ -99,13 +86,7 @@ impl KeyboardHandler for GlobalState {
}
};

let s_surface = self
.client_state
.proxied_layer_surfaces
.iter_mut()
.any(|(_, _, _, c, ..)| c.wl_surface() == surface);

if kbd_focus && !s_surface {
if kbd_focus {
self.space.keyboard_leave(&name, Some(surface.clone()));
}
kbd.set_focus(self, None, SERIAL_COUNTER.next_serial());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

use sctk::{
delegate_layer,
shell::{
wlr_layer::{LayerShellHandler, LayerSurface, LayerSurfaceConfigure},
WaylandSurface,
},
shell::wlr_layer::{LayerShellHandler, LayerSurface, LayerSurfaceConfigure},
};

use crate::xdg_shell_wrapper::{
client_state::SurfaceState, shared_state::GlobalState, space::WrapperSpace,
};
use crate::xdg_shell_wrapper::{shared_state::GlobalState, space::WrapperSpace};

impl LayerShellHandler for GlobalState {
fn closed(
Expand All @@ -19,16 +14,7 @@ impl LayerShellHandler for GlobalState {
_qh: &sctk::reexports::client::QueueHandle<Self>,
layer: &LayerSurface,
) {
if let Some(i) = self
.client_state
.proxied_layer_surfaces
.iter()
.position(|(_, _, _, s, ..)| s.wl_surface() == layer.wl_surface())
{
self.client_state.proxied_layer_surfaces.remove(i);
} else {
self.space.close_layer(layer);
}
self.space.close_layer(layer);
}

fn configure(
Expand All @@ -39,39 +25,7 @@ impl LayerShellHandler for GlobalState {
configure: LayerSurfaceConfigure,
_serial: u32,
) {
if let Some((_, _, s_layer_surface, _, mut state, ..)) = self
.client_state
.proxied_layer_surfaces
.iter_mut()
.find(|(_, _, _, s, ..)| s.wl_surface() == layer.wl_surface())
{
let mut requested_size = configure.new_size;
let generation = match state {
SurfaceState::Waiting(generation, size) => {
requested_size.0 = size.w as u32;
requested_size.1 = size.h as u32;
state = SurfaceState::Dirty(generation);
generation
},
SurfaceState::Dirty(generation) => generation,
SurfaceState::WaitingFirst(generation, size) => {
requested_size.0 = size.w as u32;
requested_size.1 = size.h as u32;
state = SurfaceState::Dirty(generation);
generation
},
};
tracing::trace!("Layer surface configure: {configure:?}, generation: {generation}");
if requested_size != configure.new_size {
s_layer_surface.layer_surface().with_pending_state(|pending_state| {
pending_state.size =
Some((configure.new_size.0 as i32, configure.new_size.1 as i32).into());
});
s_layer_surface.layer_surface().send_configure();
}
} else {
self.space.configure_layer(layer, configure);
}
self.space.configure_layer(layer, configure);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ pub struct OverlapNotificationV1 {
impl Dispatch<ZcosmicOverlapNotificationV1, OverlapNotificationV1, GlobalState>
for OverlapNotificationV1
{
event_created_child!(GlobalState, ZcosmicOverlapNotifyV1, [
0 => (ExtForeignToplevelHandleV1, Default::default())
]);

fn event(
state: &mut GlobalState,
_n: &ZcosmicOverlapNotificationV1,
Expand All @@ -74,10 +78,6 @@ impl Dispatch<ZcosmicOverlapNotificationV1, OverlapNotificationV1, GlobalState>
}
}
}

event_created_child!(GlobalState, ZcosmicOverlapNotifyV1, [
0 => (ExtForeignToplevelHandleV1, Default::default())
]);
}

wayland_client::delegate_dispatch!(GlobalState: [ZcosmicOverlapNotifyV1: GlobalData] => OverlapNotifyV1);
Expand Down
Loading