toplevel_mgmt: Fix activating sticky windows

This commit is contained in:
Victoria Brekenfeld 2025-08-12 16:13:16 +02:00 committed by Victoria Brekenfeld
parent 0efdfb25f5
commit a4b2294bee

View file

@ -47,11 +47,11 @@ impl ToplevelManagementHandler for State {
.flat_map(|m| m.windows().map(|(s, _)| s)) .flat_map(|m| m.windows().map(|(s, _)| s))
.any(|w| &w == window) .any(|w| &w == window)
}); });
if let Some((idx, workspace)) = maybe {
let seat = seat.unwrap_or(shell.seats.last_active().clone());
let seat = seat.clone().unwrap_or(shell.seats.last_active().clone());
let (target, new_pos) = if let Some((idx, workspace)) = maybe {
let handle = workspace.handle; let handle = workspace.handle;
let res = shell.activate( let new_pos = shell.activate(
&output, &output,
idx, idx,
WorkspaceDelta::new_shortcut(), WorkspaceDelta::new_shortcut(),
@ -86,33 +86,51 @@ impl ToplevelManagementHandler for State {
} else { } else {
KeyboardFocusTarget::Fullscreen(window.clone()) KeyboardFocusTarget::Fullscreen(window.clone())
}; };
std::mem::drop(shell);
if seat.active_output() != *output { (target, new_pos.ok())
match res { // sticky window?
Ok(new_pos) => { } else if let Some(mapped) = shell
seat.set_active_output(&output); .workspaces
if let Some(ptr) = seat.get_pointer() { .sets
let serial = SERIAL_COUNTER.next_serial(); .get(output)
ptr.motion( .unwrap()
self, .sticky_layer
None, .mapped()
&MotionEvent { .find(|m| m.windows().any(|(w, _)| &w == window))
location: new_pos.to_f64().as_logical(), {
serial, mapped.focus_window(window);
time: self.common.clock.now().as_millis(),
}, let output_geo = output.geometry();
); let new_pos =
ptr.frame(self); output_geo.loc + Point::from((output_geo.size.w / 2, output_geo.size.h / 2));
} (KeyboardFocusTarget::Element(mapped.clone()), Some(new_pos))
} } else {
_ => {} continue;
};
std::mem::drop(shell);
if seat.active_output() != *output {
if let Some(new_pos) = new_pos {
seat.set_active_output(&output);
if let Some(ptr) = seat.get_pointer() {
let serial = SERIAL_COUNTER.next_serial();
ptr.motion(
self,
None,
&MotionEvent {
location: new_pos.to_f64().as_logical(),
serial,
time: self.common.clock.now().as_millis(),
},
);
ptr.frame(self);
} }
} }
Shell::set_focus(self, Some(&target), &seat, None, false);
return;
} }
Shell::set_focus(self, Some(&target), &seat, None, false);
return;
} }
} }