mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Add honor-xdg-activation-with-invalid-serial debug flag
This commit is contained in:
@@ -2014,6 +2014,8 @@ pub struct DebugConfig {
|
|||||||
pub disable_monitor_names: bool,
|
pub disable_monitor_names: bool,
|
||||||
#[knuffel(child)]
|
#[knuffel(child)]
|
||||||
pub strict_new_window_focus_policy: bool,
|
pub strict_new_window_focus_policy: bool,
|
||||||
|
#[knuffel(child)]
|
||||||
|
pub honor_xdg_activation_with_invalid_serial: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(knuffel::DecodeScalar, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@@ -4738,6 +4740,7 @@ mod tests {
|
|||||||
keep_laptop_panel_on_when_lid_is_closed: false,
|
keep_laptop_panel_on_when_lid_is_closed: false,
|
||||||
disable_monitor_names: false,
|
disable_monitor_names: false,
|
||||||
strict_new_window_focus_policy: false,
|
strict_new_window_focus_policy: false,
|
||||||
|
honor_xdg_activation_with_invalid_serial: false,
|
||||||
},
|
},
|
||||||
workspaces: [
|
workspaces: [
|
||||||
Workspace {
|
Workspace {
|
||||||
|
|||||||
+18
-1
@@ -709,7 +709,12 @@ impl XdgActivationHandler for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn token_created(&mut self, _token: XdgActivationToken, data: XdgActivationTokenData) -> bool {
|
fn token_created(&mut self, _token: XdgActivationToken, data: XdgActivationTokenData) -> bool {
|
||||||
// Only tokens that were created while the application has keyboard focus are valid.
|
// Tokens without a serial are urgency-only. This is not specified, but it seems to be the
|
||||||
|
// common client behavior.
|
||||||
|
//
|
||||||
|
// We don't have urgency yet, so just ignore such tokens.
|
||||||
|
//
|
||||||
|
// See also: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/150
|
||||||
let Some((serial, seat)) = data.serial else {
|
let Some((serial, seat)) = data.serial else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@@ -717,6 +722,18 @@ impl XdgActivationHandler for State {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Widely-used clients such as Discord and Telegram make new tokens (with invalid serials)
|
||||||
|
// upon clicking on their tray icon or on their notification. This debug flag makes that
|
||||||
|
// work.
|
||||||
|
//
|
||||||
|
// Clicking on a notification sends clients a perfectly valid activation token from the
|
||||||
|
// notification daemon, but alas they ignore it. Maybe in the future the clients are fixed,
|
||||||
|
// and we can remove this debug flag.
|
||||||
|
let config = self.niri.config.borrow();
|
||||||
|
if config.debug.honor_xdg_activation_with_invalid_serial {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Check the serial against both a keyboard and a pointer, since layer-shell surfaces
|
// Check the serial against both a keyboard and a pointer, since layer-shell surfaces
|
||||||
// with no keyboard interactivity won't have any keyboard focus.
|
// with no keyboard interactivity won't have any keyboard focus.
|
||||||
let kb_last_enter = seat.get_keyboard().unwrap().last_enter();
|
let kb_last_enter = seat.get_keyboard().unwrap().last_enter();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ debug {
|
|||||||
keep-laptop-panel-on-when-lid-is-closed
|
keep-laptop-panel-on-when-lid-is-closed
|
||||||
disable-monitor-names
|
disable-monitor-names
|
||||||
strict-new-window-focus-policy
|
strict-new-window-focus-policy
|
||||||
|
honor-xdg-activation-with-invalid-serial
|
||||||
}
|
}
|
||||||
|
|
||||||
binds {
|
binds {
|
||||||
@@ -238,6 +239,25 @@ debug {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `honor-xdg-activation-with-invalid-serial`
|
||||||
|
|
||||||
|
<sup>Since: next release</sup>
|
||||||
|
|
||||||
|
Widely-used clients such as Discord and Telegram make fresh xdg-activation tokens upon clicking on their tray icon or on their notification.
|
||||||
|
Most of the time, these fresh tokens will have invalid serials, because the app needs to be focused to get a valid serial, and if the user clicks on a tray icon or a notification, it is usually because the app *isn't* focused, and the user wants to focus it.
|
||||||
|
|
||||||
|
By default, niri ignores xdg-activation tokens with invalid serials, to prevent windows from randomly stealing focus.
|
||||||
|
This debug flag makes niri honor such tokens, making the aforementioned widely-used apps get focus when clicking on their tray icon or notification.
|
||||||
|
|
||||||
|
Amusingly, clicking on a notification sends the app a perfectly valid activation token from the notification daemon, but these apps seem to simply ignore it.
|
||||||
|
Maybe in the future these apps/toolkits (Electron, Qt) are fixed, making this debug flag unnecessary.
|
||||||
|
|
||||||
|
```kdl
|
||||||
|
debug {
|
||||||
|
honor-xdg-activation-with-invalid-serial
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Key Bindings
|
### Key Bindings
|
||||||
|
|
||||||
These are not debug options, but rather key bindings.
|
These are not debug options, but rather key bindings.
|
||||||
|
|||||||
Reference in New Issue
Block a user