Skip to content

Commit 811b5bf

Browse files
wash2jacobgkau
authored andcommitted
fix: use dummy surface to track rectangles
1 parent ecb5fd5 commit 811b5bf

1 file changed

Lines changed: 33 additions & 36 deletions

File tree

src/app.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -201,43 +201,45 @@ impl CosmicLauncher {
201201
}
202202

203203
fn create_dummy_layer_surface(&mut self) -> Task<Message> {
204+
self.needs_clear = true;
204205
let id = window::Id::unique();
205206
self.dummy_id = Some(id);
206-
get_layer_surface(SctkLayerSurfaceSettings {
207-
id,
208-
layer: wlr_layer::Layer::Bottom,
209-
keyboard_interactivity: wlr_layer::KeyboardInteractivity::None,
210-
input_zone: Some(Vec::new()),
211-
anchor: wlr_layer::Anchor::empty(),
212-
output:
213-
cosmic::iced::runtime::platform_specific::wayland::layer_surface::IcedOutput::Active,
214-
namespace: "cosmic_launcher_dummy".into(),
215-
margin: IcedMargin::default(),
216-
size: Some((Some(6), Some(6))),
217-
exclusive_zone: -1,
218-
size_limits: Limits::NONE,
219-
})
220-
}
221-
222-
fn show(&mut self) -> Task<Message> {
223-
self.surface_state = SurfaceState::Visible;
224-
self.needs_clear = true;
207+
self.handle_overlap();
225208

226209
Task::batch(vec![
227210
get_layer_surface(SctkLayerSurfaceSettings {
228-
id: self.window_id,
229-
keyboard_interactivity: KeyboardInteractivity::Exclusive,
230-
anchor: Anchor::TOP,
231-
namespace: "launcher".into(),
232-
size: None,
233-
size_limits: Limits::NONE.min_width(1.0).min_height(1.0).max_width(600.0),
211+
id,
212+
layer: wlr_layer::Layer::Bottom,
213+
keyboard_interactivity: wlr_layer::KeyboardInteractivity::None,
214+
input_zone: Some(Vec::new()),
215+
anchor: wlr_layer::Anchor::TOP,
216+
output:
217+
cosmic::iced::runtime::platform_specific::wayland::layer_surface::IcedOutput::Active,
218+
namespace: "cosmic_launcher_dummy".into(),
219+
margin: IcedMargin::default(),
220+
size: Some((Some(600), Some(200))),
234221
exclusive_zone: -1,
235-
..Default::default()
222+
size_limits: Limits::NONE,
236223
}),
237-
overlap_notify(self.window_id, true),
224+
overlap_notify(id, true),
238225
])
239226
}
240227

228+
fn show(&mut self) -> Task<Message> {
229+
self.surface_state = SurfaceState::Visible;
230+
231+
get_layer_surface(SctkLayerSurfaceSettings {
232+
id: self.window_id,
233+
keyboard_interactivity: KeyboardInteractivity::Exclusive,
234+
anchor: Anchor::TOP,
235+
namespace: "launcher".into(),
236+
size: None,
237+
size_limits: Limits::NONE.min_width(1.0).min_height(1.0).max_width(600.0),
238+
exclusive_zone: -1,
239+
..Default::default()
240+
})
241+
}
242+
241243
fn hide(&mut self) -> Task<Message> {
242244
self.input_value.clear();
243245
self.focused = 0;
@@ -277,9 +279,6 @@ impl CosmicLauncher {
277279
}
278280

279281
fn handle_overlap(&mut self) {
280-
if matches!(self.surface_state, SurfaceState::Hidden) {
281-
return;
282-
}
283282
let mid_height = self.height / 2.;
284283
self.margin = 0.;
285284

@@ -362,12 +361,14 @@ impl cosmic::Application for CosmicLauncher {
362361
.collect::<Vec<_>>(),
363362
margin: 0.,
364363
overlap: HashMap::new(),
365-
height: 100.,
364+
height: 500.,
366365
needs_clear: false,
367366
hand_over: String::default(),
368367
dummy_id: None,
369368
};
370369
let task = app.create_dummy_layer_surface();
370+
app.needs_clear = false;
371+
371372
(app, task)
372373
}
373374

@@ -439,11 +440,7 @@ impl cosmic::Application for CosmicLauncher {
439440
return commands::popup::destroy_popup(*MENU_ID);
440441
}
441442
}
442-
Message::Opened(size, window_id) => {
443-
if window_id == self.window_id {
444-
self.height = size.height;
445-
self.handle_overlap();
446-
}
443+
Message::Opened(_, _) => {
447444
if !self.hand_over.is_empty() {
448445
let input = self.hand_over.clone();
449446
self.hand_over.clear();

0 commit comments

Comments
 (0)