Skip to content

Commit 20ea5a2

Browse files
committed
fix(desktop applet): overlaps
1 parent 7d5fb79 commit 20ea5a2

File tree

1 file changed

+28
-22
lines changed

1 file changed

+28
-22
lines changed

src/app.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ pub struct App {
673673
search_id: widget::Id,
674674
size: Option<Size>,
675675
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
676+
layer_sizes: HashMap<window::Id, Size>,
677+
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
676678
surface_ids: HashMap<WlOutput, WindowId>,
677679
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
678680
surface_names: HashMap<WindowId, String>,
@@ -911,28 +913,8 @@ impl App {
911913
}
912914
}
913915

916+
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
914917
fn handle_overlap(&mut self) {
915-
let Some((bl, br, tl, tr, mut size)) = self.size.as_ref().map(|s| {
916-
(
917-
Rectangle::new(
918-
Point::new(0., s.height / 2.),
919-
Size::new(s.width / 2., s.height / 2.),
920-
),
921-
Rectangle::new(
922-
Point::new(s.width / 2., s.height / 2.),
923-
Size::new(s.width / 2., s.height / 2.),
924-
),
925-
Rectangle::new(Point::new(0., 0.), Size::new(s.width / 2., s.height / 2.)),
926-
Rectangle::new(
927-
Point::new(s.width / 2., 0.),
928-
Size::new(s.width / 2., s.height / 2.),
929-
),
930-
*s,
931-
)
932-
}) else {
933-
return;
934-
};
935-
936918
let mut overlaps: HashMap<_, _> = self
937919
.windows
938920
.keys()
@@ -943,6 +925,26 @@ impl App {
943925
.sort_by(|a, b| (b.1.width * b.1.height).total_cmp(&(a.1.width * b.1.height)));
944926

945927
for (w_id, overlap) in sorted_overlaps {
928+
let Some((bl, br, tl, tr, mut size)) = self.layer_sizes.get(w_id).map(|s| {
929+
(
930+
Rectangle::new(
931+
Point::new(0., s.height / 2.),
932+
Size::new(s.width / 2., s.height / 2.),
933+
),
934+
Rectangle::new(
935+
Point::new(s.width / 2., s.height / 2.),
936+
Size::new(s.width / 2., s.height / 2.),
937+
),
938+
Rectangle::new(Point::new(0., 0.), Size::new(s.width / 2., s.height / 2.)),
939+
Rectangle::new(
940+
Point::new(s.width / 2., 0.),
941+
Size::new(s.width / 2., s.height / 2.),
942+
),
943+
*s,
944+
)
945+
}) else {
946+
continue;
947+
};
946948
let tl = tl.intersects(overlap);
947949
let tr = tr.intersects(overlap);
948950
let bl = bl.intersects(overlap);
@@ -2153,6 +2155,8 @@ impl Application for App {
21532155
tab_drag_id: DragId::new(),
21542156
auto_scroll_speed: None,
21552157
file_dialog_opt: None,
2158+
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
2159+
layer_sizes: HashMap::new(),
21562160
};
21572161

21582162
let mut commands = vec![app.update_config()];
@@ -4624,7 +4628,9 @@ impl Application for App {
46244628
Message::Size(window_id, size) => {
46254629
if self.core.main_window_id() == Some(window_id) {
46264630
self.size = Some(size);
4627-
self.handle_overlap();
4631+
} else {
4632+
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
4633+
self.layer_sizes.insert(window_id, size);
46284634
}
46294635
}
46304636
Message::Eject => {

0 commit comments

Comments
 (0)