-
-
Notifications
You must be signed in to change notification settings - Fork 379
Add MRU window navigation actions #977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5db4c37
e3bc967
b1146e3
5677748
029d215
84597fd
ea612c4
3ac6a66
f2e929d
2c69396
944a3eb
80cfd4a
b4ab021
74ee34e
46e6d59
bef1c0b
2f96fa5
b03864f
97d582d
1d57839
7a9e0e2
cf7491d
f525612
531851d
e3cc921
5bc01b1
931b9de
ccc359a
d3577fc
89cee2d
f63dd94
d9d35a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ use std::any::Any; | |
use std::cmp::min; | ||
use std::collections::hash_map::Entry; | ||
use std::collections::HashSet; | ||
use std::sync::atomic::AtomicBool; | ||
use std::time::{Duration, Instant}; | ||
|
||
use calloop::timer::{TimeoutAction, Timer}; | ||
|
@@ -129,17 +128,6 @@ impl State { | |
.is_some_and(|d| d.is_open()) | ||
&& should_hide_exit_confirm_dialog(&event); | ||
|
||
// If an event was forwarded to the focused window and it still has | ||
// a running lockin_token, cancel the token and update the timestamp | ||
// immediately | ||
if self | ||
.niri | ||
.event_forwarded_to_focused_client | ||
.swap(false, std::sync::atomic::Ordering::Relaxed) | ||
{ | ||
self.niri.lockin_focus(); | ||
} | ||
|
||
use InputEvent::*; | ||
match event { | ||
DeviceAdded { device } => self.on_device_added(device), | ||
|
@@ -430,22 +418,29 @@ impl State { | |
} | ||
} | ||
|
||
let bindings = &this.niri.config.borrow().binds; | ||
|
||
should_intercept_key( | ||
&mut this.niri.suppressed_keys, | ||
bindings, | ||
comp_mod, | ||
key_code, | ||
modified, | ||
raw, | ||
pressed, | ||
*mods, | ||
&this.niri.screenshot_ui, | ||
this.niri.config.borrow().input.disable_power_key_handling, | ||
is_inhibiting_shortcuts, | ||
&mut this.niri.event_forwarded_to_focused_client, | ||
) | ||
let intercept_result = { | ||
let bindings = &this.niri.config.borrow().binds; | ||
should_intercept_key( | ||
&mut this.niri.suppressed_keys, | ||
bindings, | ||
comp_mod, | ||
key_code, | ||
modified, | ||
raw, | ||
pressed, | ||
*mods, | ||
&this.niri.screenshot_ui, | ||
this.niri.config.borrow().input.disable_power_key_handling, | ||
is_inhibiting_shortcuts, | ||
) | ||
}; | ||
if matches!(intercept_result, FilterResult::Forward) { | ||
// Interaction with the active window, immediately update | ||
// the active window's focus timestamp without waiting for a | ||
// possible lockin period. | ||
this.niri.lockin_focus(); | ||
} | ||
intercept_result | ||
}, | ||
) else { | ||
return; | ||
|
@@ -2173,10 +2168,8 @@ impl State { | |
} | ||
|
||
// The event is getting forwarded to a client, consider that the | ||
// focus should be locked-in | ||
self.niri | ||
.event_forwarded_to_focused_client | ||
.store(true, std::sync::atomic::Ordering::Relaxed); | ||
// focus should be locked-in. | ||
self.niri.lockin_focus(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess this should also happen on touch taps and tablet touches and possibly other stuff? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed. I've sprinkled |
||
|
||
pointer.button( | ||
self, | ||
|
@@ -2968,7 +2961,6 @@ fn should_intercept_key( | |
screenshot_ui: &ScreenshotUi, | ||
disable_power_key_handling: bool, | ||
is_inhibiting_shortcuts: bool, | ||
event_forwarded_to_focused_client: &mut AtomicBool, | ||
) -> FilterResult<Option<Bind>> { | ||
// Actions are only triggered on presses, release of the key | ||
// shouldn't try to intercept anything unless we have marked | ||
|
@@ -3036,14 +3028,7 @@ fn should_intercept_key( | |
suppressed_keys.remove(&key_code); | ||
FilterResult::Intercept(None) | ||
} | ||
(None, true) => { | ||
// Interaction with the active window, the event will be picked | ||
// up by Niri on the next event loop at which point it can do an | ||
// immediate update of the active window's focus timestamp without | ||
// waiting for a possible lockin period. | ||
event_forwarded_to_focused_client.store(true, std::sync::atomic::Ordering::Relaxed); | ||
FilterResult::Forward | ||
} | ||
(None, true) => FilterResult::Forward, | ||
} | ||
} | ||
|
||
|
@@ -3612,7 +3597,6 @@ mod tests { | |
&screenshot_ui, | ||
disable_power_key_handling, | ||
is_inhibiting_shortcuts.get(), | ||
&mut AtomicBool::new(false), | ||
) | ||
}; | ||
|
||
|
@@ -3630,7 +3614,6 @@ mod tests { | |
&screenshot_ui, | ||
disable_power_key_handling, | ||
is_inhibiting_shortcuts.get(), | ||
&mut AtomicBool::new(false), | ||
) | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably ok but fwiw you don't have to handle this inside. If
keyboard.input()
returnsNone
, that means the closure returnedFilterResult::Forward
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean something like
match ...input(...) { None => { mru_commit(); return}, Some(None) => return, _ => ()}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now there's an
if let Some(Some(bind)) = keyboard.input(...)
and it has an} else {
branch, I think you can put this line into that else branch?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually not exactly since then it will catch
Some(None)
too which is not what we want.. Idk maybe there's a cleaner way here