added cursor_follows_focus and focus_follows_cursor

This commit is contained in:
skewballfox 2024-09-04 11:13:59 -05:00 committed by Victoria Brekenfeld
parent 52280e9823
commit 7da0bc430a
22 changed files with 844 additions and 384 deletions

View file

@ -272,7 +272,7 @@ impl State {
if let Some(target) = res {
let seat = shell.seats.last_active().clone();
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), &seat, None);
Shell::set_focus(self, Some(&target), &seat, None, true);
return true;
}
}
@ -290,7 +290,7 @@ impl State {
if let Some(target) = shell.map_layer(&layer_surface) {
let seat = shell.seats.last_active().clone();
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), &seat, None);
Shell::set_focus(self, Some(&target), &seat, None, false);
}
layer_surface.layer_surface().send_configure();
return true;

View file

@ -87,7 +87,7 @@ impl ToplevelManagementHandler for State {
}
mapped.focus_window(window);
Shell::set_focus(self, Some(&mapped.clone().into()), &seat, None);
Shell::set_focus(self, Some(&mapped.clone().into()), &seat, None, true);
return;
}
}
@ -133,7 +133,7 @@ impl ToplevelManagementHandler for State {
);
if let Some((target, _)) = res {
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), &seat, None);
Shell::set_focus(self, Some(&target), &seat, None, true);
}
return;
}

View file

@ -156,7 +156,7 @@ impl XdgActivationHandler for State {
let target = element.into();
std::mem::drop(shell);
Shell::set_focus(self, Some(&target), &seat, None);
Shell::set_focus(self, Some(&target), &seat, None, false);
} else if let Some(w) = shell.space_for(&element).map(|w| w.handle.clone())
{
shell.append_focus_stack(&element, &seat);

View file

@ -1,7 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
use smithay::{delegate_xdg_foreign, wayland::xdg_foreign::{XdgForeignHandler, XdgForeignState}};
use crate::state::State;
use smithay::{
delegate_xdg_foreign,
wayland::xdg_foreign::{XdgForeignHandler, XdgForeignState},
};
impl XdgForeignHandler for State {
fn xdg_foreign_state(&mut self) -> &mut XdgForeignState {

View file

@ -97,7 +97,13 @@ impl XdgShellHandler for State {
grab.ungrab(PopupUngrabStrategy::All);
return;
}
Shell::set_focus(self, grab.current_grab().as_ref(), &seat, Some(serial));
Shell::set_focus(
self,
grab.current_grab().as_ref(),
&seat,
Some(serial),
false,
);
keyboard.set_grab(self, PopupKeyboardGrab::new(&grab), serial);
}
@ -226,11 +232,13 @@ impl XdgShellHandler for State {
fn fullscreen_request(&mut self, surface: ToplevelSurface, output: Option<WlOutput>) {
let mut shell = self.common.shell.write().unwrap();
let seat = shell.seats.last_active().clone();
let active_output = seat.active_output();
let Some(focused_output) = seat.focused_output() else {
return;
};
let output = output
.as_ref()
.and_then(Output::from_resource)
.unwrap_or_else(|| active_output.clone());
.unwrap_or_else(|| focused_output.clone());
if let Some(mapped) = shell.element_for_surface(surface.wl_surface()).cloned() {
let from = minimize_rectangle(&output, &mapped.active_window());