mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-19 08:17:10 +03:00
Implement focus-ring window rule
This commit is contained in:
parent
3e598c565e
commit
fd6c8c7790
@ -412,6 +412,19 @@ impl From<Border> for FocusRing {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FocusRing> for Border {
|
||||
fn from(value: FocusRing) -> Self {
|
||||
Self {
|
||||
off: value.off,
|
||||
width: value.width,
|
||||
active_color: value.active_color,
|
||||
inactive_color: value.inactive_color,
|
||||
active_gradient: value.active_gradient,
|
||||
inactive_gradient: value.inactive_gradient,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Color {
|
||||
pub r: u8,
|
||||
@ -701,6 +714,8 @@ pub struct WindowRule {
|
||||
#[knuffel(child, unwrap(argument))]
|
||||
pub max_height: Option<u16>,
|
||||
|
||||
#[knuffel(child, default)]
|
||||
pub focus_ring: BorderRule,
|
||||
#[knuffel(child, default)]
|
||||
pub border: BorderRule,
|
||||
#[knuffel(child, unwrap(argument))]
|
||||
@ -2048,6 +2063,11 @@ mod tests {
|
||||
open-maximized true
|
||||
open-fullscreen false
|
||||
|
||||
focus-ring {
|
||||
off
|
||||
width 3
|
||||
}
|
||||
|
||||
border {
|
||||
on
|
||||
width 8
|
||||
@ -2254,6 +2274,11 @@ mod tests {
|
||||
open_on_output: Some("eDP-1".to_owned()),
|
||||
open_maximized: Some(true),
|
||||
open_fullscreen: Some(false),
|
||||
focus_ring: BorderRule {
|
||||
off: true,
|
||||
width: Some(3),
|
||||
..Default::default()
|
||||
},
|
||||
border: BorderRule {
|
||||
on: true,
|
||||
width: Some(8),
|
||||
|
@ -109,11 +109,12 @@ impl<W: LayoutElement> Tile<W> {
|
||||
pub fn new(window: W, options: Rc<Options>) -> Self {
|
||||
let rules = window.rules();
|
||||
let border_config = rules.border.resolve_against(options.border);
|
||||
let focus_ring_config = rules.focus_ring.resolve_against(options.focus_ring.into());
|
||||
|
||||
Self {
|
||||
window,
|
||||
border: FocusRing::new(border_config.into()),
|
||||
focus_ring: FocusRing::new(options.focus_ring),
|
||||
focus_ring: FocusRing::new(focus_ring_config.into()),
|
||||
is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
|
||||
fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),
|
||||
fullscreen_size: Default::default(),
|
||||
@ -131,7 +132,11 @@ impl<W: LayoutElement> Tile<W> {
|
||||
let border_config = rules.border.resolve_against(self.options.border);
|
||||
self.border.update_config(border_config.into());
|
||||
|
||||
self.focus_ring.update_config(options.focus_ring);
|
||||
let focus_ring_config = rules
|
||||
.focus_ring
|
||||
.resolve_against(self.options.focus_ring.into());
|
||||
self.focus_ring.update_config(focus_ring_config.into());
|
||||
|
||||
self.options = options;
|
||||
}
|
||||
|
||||
@ -175,6 +180,10 @@ impl<W: LayoutElement> Tile<W> {
|
||||
let rules = self.window.rules();
|
||||
let border_config = rules.border.resolve_against(self.options.border);
|
||||
self.border.update_config(border_config.into());
|
||||
let focus_ring_config = rules
|
||||
.focus_ring
|
||||
.resolve_against(self.options.focus_ring.into());
|
||||
self.focus_ring.update_config(focus_ring_config.into());
|
||||
}
|
||||
|
||||
pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
|
||||
|
@ -48,6 +48,8 @@ pub struct ResolvedWindowRules {
|
||||
/// Extra bound on the maximum window height.
|
||||
pub max_height: Option<u16>,
|
||||
|
||||
/// Focus ring overrides.
|
||||
pub focus_ring: BorderRule,
|
||||
/// Window border overrides.
|
||||
pub border: BorderRule,
|
||||
|
||||
@ -90,6 +92,15 @@ impl ResolvedWindowRules {
|
||||
min_height: None,
|
||||
max_width: None,
|
||||
max_height: None,
|
||||
focus_ring: BorderRule {
|
||||
off: false,
|
||||
on: false,
|
||||
width: None,
|
||||
active_color: None,
|
||||
inactive_color: None,
|
||||
active_gradient: None,
|
||||
inactive_gradient: None,
|
||||
},
|
||||
border: BorderRule {
|
||||
off: false,
|
||||
on: false,
|
||||
@ -170,6 +181,7 @@ impl ResolvedWindowRules {
|
||||
resolved.max_height = Some(x);
|
||||
}
|
||||
|
||||
resolved.focus_ring.merge_with(&rule.focus_ring);
|
||||
resolved.border.merge_with(&rule.border);
|
||||
|
||||
if let Some(x) = rule.draw_border_with_background {
|
||||
|
@ -45,14 +45,18 @@ window-rule {
|
||||
block-out-from "screencast"
|
||||
// block-out-from "screen-capture"
|
||||
|
||||
border {
|
||||
focus-ring {
|
||||
// off
|
||||
on
|
||||
width 4
|
||||
active-color "#ffc87f"
|
||||
active-color "#7fc8ff"
|
||||
inactive-color "#505050"
|
||||
active-gradient from="#ffbb66" to="#ffc880" angle=45 relative-to="workspace-view"
|
||||
inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
||||
// active-gradient from="#80c8ff" to="#bbddff" angle=45
|
||||
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
|
||||
}
|
||||
|
||||
border {
|
||||
// Same as focus-ring.
|
||||
}
|
||||
|
||||
min-width 100
|
||||
@ -347,18 +351,25 @@ window-rule {
|
||||
}
|
||||
```
|
||||
|
||||
#### `border`
|
||||
#### `focus-ring` and `border`
|
||||
|
||||
<sup>Since: 0.1.6</sup>
|
||||
|
||||
Override the border options for the window.
|
||||
Override the focus ring and border options for the window.
|
||||
|
||||
This rule has the same options as the normal border config in the [layout](./Configuration:-Layout.md) section, so check the documentation there.
|
||||
These rules have the same options as the normal focus ring and border config in the [layout](./Configuration:-Layout.md) section, so check the documentation there.
|
||||
|
||||
However, in addition to `off` to disable the border, this window rule has an `on` flag that enables the border for the window even if the border is otherwise disabled.
|
||||
However, in addition to `off` to disable the border/focus ring, this window rule has an `on` flag that enables the border/focus ring for the window even if it was otherwise disabled.
|
||||
The `on` flag has precedence over the `off` flag, in case both are set.
|
||||
|
||||
```
|
||||
window-rule {
|
||||
focus-ring {
|
||||
off
|
||||
width 2
|
||||
}
|
||||
}
|
||||
|
||||
window-rule {
|
||||
border {
|
||||
on
|
||||
|
Loading…
Reference in New Issue
Block a user