Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor autohide #297

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion cosmic-panel-bin/src/config_watching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ pub fn watch_config(
channel::Event::Msg(ConfigUpdate::Entries(entries)) => {
let to_update = entries
.iter()
.filter(|c| !state.space.config.config_list.iter().any(|e| e.name == **c)).cloned()
.filter(|c| !state.space.config.config_list.iter().any(|e| e.name == **c))
.cloned()
.collect::<Vec<String>>();
info!("Received entries: {:?}", to_update);
for entry in to_update {
Expand Down Expand Up @@ -164,6 +165,7 @@ pub fn watch_config(
&mut state.client_state.layer_state,
&state.client_state.queue_handle,
None,
state.client_state.overlap_notify.clone(),
);
}
info!("Removing entries: {:?}", entries);
Expand All @@ -188,6 +190,7 @@ pub fn watch_config(
&mut state.client_state.layer_state,
&state.client_state.queue_handle,
None,
state.client_state.overlap_notify.clone(),
);
},
channel::Event::Closed => {},
Expand Down
3 changes: 2 additions & 1 deletion cosmic-panel-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn main() -> Result<()> {
let filter_layer =
EnvFilter::try_from_default_env().or_else(|_| EnvFilter::try_new("warn")).unwrap();
if let Ok(journal_layer) = tracing_journald::layer() {
tracing_subscriber::registry().with(journal_layer).with(filter_layer).init();
tracing_subscriber::registry().with(fmt_layer).with(filter_layer).init();
} else {
tracing_subscriber::registry().with(fmt_layer).with(filter_layer).init();
}
Expand Down Expand Up @@ -130,6 +130,7 @@ fn main() -> Result<()> {
&mut state.client_state.layer_state,
&state.client_state.queue_handle,
Some(o),
state.client_state.overlap_notify.clone(),
);
},
PanelCalloopMsg::UpdateToplevel(toplevel) => {
Expand Down
97 changes: 50 additions & 47 deletions cosmic-panel-bin/src/space/layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
i32,
slice::IterMut,
sync::{atomic::AtomicBool, Arc, MutexGuard},
time::{Duration, Instant},
Expand Down Expand Up @@ -676,53 +677,6 @@ impl PanelSpace {
border_color: [0.0, 0.0, 0.0, 0.0],
};

input_region.subtract(
0,
0,
self.dimensions.w.max(new_dim.w),
self.dimensions.h.max(new_dim.h),
);

if is_dock {
let (layer_length, actual_length) = if self.config.is_horizontal() {
(new_dim.w, self.actual_size.w)
} else {
(new_dim.h, self.actual_size.h)
};
let side = (layer_length as u32 - actual_length as u32) / 2;

let (loc, size) = match self.config.anchor {
PanelAnchor::Left => (
(-1, side as i32),
(new_logical_crosswise_dim + self.gap() as i32 + 1, container_length),
),
PanelAnchor::Right => (
(0, side as i32),
(new_logical_crosswise_dim + self.gap() as i32 + 1, container_length),
),
PanelAnchor::Top => (
(side as i32, -1),
(container_length, new_logical_crosswise_dim + self.gap() as i32 + 1),
),
PanelAnchor::Bottom => (
(side as i32, 0),
(container_length, new_logical_crosswise_dim + self.gap() as i32 + 1),
),
};

input_region.add(loc.0, loc.1, size.0, size.1);
} else {
let (loc, size) = match self.config.anchor {
PanelAnchor::Left => ((-1, 0), (new_dim.w + 1, new_dim.h)),
PanelAnchor::Right => ((0, 0), (new_dim.w + 1, new_dim.h)),
PanelAnchor::Top => ((0, -1), (new_dim.w, new_dim.h + 1)),
PanelAnchor::Bottom => ((0, 0), (new_dim.w, new_dim.h + 1)),
};

input_region.add(loc.0, loc.1, size.0, size.1);
};
layer.wl_surface().set_input_region(Some(input_region.wl_region()));

let Some(output) = self.output.as_ref().map(|o| o.1.clone()) else {
bail!("output missing");
};
Expand Down Expand Up @@ -761,6 +715,55 @@ impl PanelSpace {
self.background_element = Some(bg.clone());
self.space.map_element(CosmicMappedInternal::Background(bg), (0, 0), false);
}
input_region.subtract(0, 0, i32::MAX, i32::MAX);
let anim_gap = self.anchor_gap;

if is_dock {
let (layer_length, actual_length) = if self.config.is_horizontal() {
(new_dim.w, self.actual_size.w)
} else {
(new_dim.h, self.actual_size.h)
};
let side = (layer_length as u32 - actual_length as u32) / 2;

let (loc, size) = match self.config.anchor {
PanelAnchor::Left => (
(-1, side as i32),
(
new_logical_crosswise_dim + self.gap() as i32 + 1 + anim_gap,
container_length,
),
),
PanelAnchor::Right => (
(0, side as i32 - anim_gap),
(new_logical_crosswise_dim + self.gap() as i32 + 1, container_length),
),
PanelAnchor::Top => (
(side as i32, -1),
(
container_length,
new_logical_crosswise_dim + self.gap() as i32 + 1 + anim_gap,
),
),
PanelAnchor::Bottom => (
(side as i32, 0 - anim_gap),
(container_length, new_logical_crosswise_dim + self.gap() as i32 + 1),
),
};

input_region.add(loc.0, loc.1, size.0, size.1);
} else {
let (loc, size) = match self.config.anchor {
PanelAnchor::Left => ((-1, 0), (new_dim.w + 1 + anim_gap, new_dim.h)),
PanelAnchor::Right => ((-anim_gap, 0), (new_dim.w + 1 + anim_gap, new_dim.h)),
PanelAnchor::Top => ((0, -1), (new_dim.w, new_dim.h + 1 + anim_gap)),
PanelAnchor::Bottom => ((0, -anim_gap), (new_dim.w, new_dim.h + 1 + anim_gap)),
};

input_region.add(loc.0, loc.1, size.0, size.1);
};
layer.wl_surface().set_input_region(Some(input_region.wl_region()));

self.reorder_overflow_space(OverflowSection::Left);
self.reorder_overflow_space(OverflowSection::Center);
self.reorder_overflow_space(OverflowSection::Right);
Expand Down
Loading