Add area screenshots and preserve stacking on hover focus

This commit is contained in:
Samuel Onoja committed 2026-09-26 23:22:38 +01:00
1 parent 8dc895448d
commit 5d6c610fec
9 files changed
+98 -15

No files matched your search

+17 -4
View File
@@ -895,7 +895,13 @@ impl Config {
}
pub fn bindings(&self, input: &InputSettings) -> Result<Vec<Binding>, ConfigError> {
let mut commands = HashMap::from([("terminal".to_owned(), vec!["foot".to_owned()])]);
let mut commands = HashMap::from([
("terminal".to_owned(), vec!["foot".to_owned()]),
(
"screenshot".to_owned(),
vec!["ferese-screenshot".to_owned()],
),
]);
commands.extend(self.commands.clone());
validate_commands(&commands)?;
@@ -1398,6 +1404,7 @@ fn parse_workspace(argument: &str) -> Result<u8, ConfigError> {
fn default_bindings() -> Vec<BindingConfig> {
let mut bindings = vec![
binding("Super+Enter", "spawn", Some("terminal")),
binding("Super+Shift+S", "spawn", Some("screenshot")),
binding("Super+Q", "close", None),
binding("Super+F", "toggle-maximized", None),
binding("Super+Shift+F", "toggle-fullscreen", None),
@@ -2069,7 +2076,7 @@ mod tests {
let input = config.input_settings().unwrap();
let bindings = config.bindings(&input).unwrap();
assert_eq!(bindings.len(), 42);
assert_eq!(bindings.len(), 43);
for (shift, action) in [
(false, BindingAction::ToggleMaximized),
(true, BindingAction::ToggleFullscreen),
@@ -2089,6 +2096,12 @@ mod tests {
&& binding.trigger == BindingTrigger::Keysym(keysyms::KEY_Return)
&& binding.action == BindingAction::Spawn(vec!["foot".to_owned()])
}));
assert!(bindings.iter().any(|binding| {
binding.modifiers.logo
&& binding.modifiers.shift
&& binding.trigger == BindingTrigger::Keysym(keysyms::KEY_s)
&& binding.action == BindingAction::Spawn(vec!["ferese-screenshot".to_owned()])
}));
assert!(bindings.iter().any(|binding| {
binding.modifiers.logo
&& binding.trigger == BindingTrigger::Keysym(keysyms::KEY_Tab)
@@ -2105,7 +2118,7 @@ mod tests {
let input = replaced.input_settings().unwrap();
let bindings = replaced.bindings(&input).unwrap();
assert_eq!(bindings.len(), 42);
assert_eq!(bindings.len(), 43);
assert!(bindings.iter().any(|binding| {
binding.action
== BindingAction::Spawn(vec![
@@ -2117,7 +2130,7 @@ mod tests {
let input = unbound.input_settings().unwrap();
let bindings = unbound.bindings(&input).unwrap();
assert_eq!(bindings.len(), 41);
assert_eq!(bindings.len(), 42);
assert!(
!bindings
.iter()
+14 -6
View File
@@ -217,7 +217,7 @@ impl Ferese {
crate::dimming::DimAnimation::new(f64::from(opacity)),
));
pointer.unset_grab(self, serial, event.time() as u32);
self.focus_window_at(pointer.current_location(), serial);
self.focus_window_at(pointer.current_location(), serial, true);
crate::backends::direct::render_all(self);
}
@@ -254,7 +254,7 @@ impl Ferese {
}
if event.state() == ButtonState::Pressed && !pointer.is_grabbed() {
self.focus_window_at(pointer.current_location(), serial);
self.focus_window_at(pointer.current_location(), serial, true);
}
pointer.button(
@@ -320,7 +320,7 @@ impl Ferese {
let Some(location) = self.absolute_event_position(&event) else {
return;
};
self.focus_window_at(location, SERIAL_COUNTER.next_serial());
self.focus_window_at(location, SERIAL_COUNTER.next_serial(), true);
let touch = self.seat.get_touch().expect("seat has touch capability");
let serial = SERIAL_COUNTER.next_serial();
@@ -387,7 +387,7 @@ impl Ferese {
Some(event.position_transformed(geometry.size) + geometry.loc.to_f64())
}
fn focus_window_at(&mut self, position: Point<f64, Logical>, serial: Serial) {
fn focus_window_at(&mut self, position: Point<f64, Logical>, serial: Serial, raise: bool) {
if self.session_lock.active {
self.focus_output_at(position);
self.focus_lock_surface();
@@ -412,7 +412,15 @@ impl Ferese {
return;
}
self.focused_window = focused;
self.raise_window(&window, true);
if raise {
self.raise_window(&window, true);
} else {
// Hover transfers keyboard focus without changing the persistent
// stack: an exposed window must not cover the floats above it.
for mapped in self.space.elements() {
mapped.set_activated(mapped == &window);
}
}
let surface = window
.toplevel()
.expect("mapped window has a toplevel")
@@ -455,7 +463,7 @@ impl Ferese {
return;
}
self.focus_window_at(position, SERIAL_COUNTER.next_serial());
self.focus_window_at(position, SERIAL_COUNTER.next_serial(), false);
}
fn clamp_pointer_position(&self, requested: Point<f64, Logical>) -> Point<f64, Logical> {