mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Add is_active_in_column
Add missing ``` Fix tests
This commit is contained in:
committed by
Ivan Molodetskikh
parent
6d9cfe2882
commit
47a8e75fd5
@@ -734,6 +734,8 @@ pub struct Match {
|
|||||||
pub is_active: Option<bool>,
|
pub is_active: Option<bool>,
|
||||||
#[knuffel(property)]
|
#[knuffel(property)]
|
||||||
pub is_focused: Option<bool>,
|
pub is_focused: Option<bool>,
|
||||||
|
#[knuffel(property)]
|
||||||
|
pub is_active_in_column: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for Match {
|
impl PartialEq for Match {
|
||||||
@@ -2416,6 +2418,7 @@ mod tests {
|
|||||||
title: None,
|
title: None,
|
||||||
is_active: None,
|
is_active: None,
|
||||||
is_focused: None,
|
is_focused: None,
|
||||||
|
is_active_in_column: None,
|
||||||
}],
|
}],
|
||||||
excludes: vec![
|
excludes: vec![
|
||||||
Match {
|
Match {
|
||||||
@@ -2423,12 +2426,14 @@ mod tests {
|
|||||||
title: Some(Regex::new("~").unwrap()),
|
title: Some(Regex::new("~").unwrap()),
|
||||||
is_active: None,
|
is_active: None,
|
||||||
is_focused: None,
|
is_focused: None,
|
||||||
|
is_active_in_column: None,
|
||||||
},
|
},
|
||||||
Match {
|
Match {
|
||||||
app_id: None,
|
app_id: None,
|
||||||
title: None,
|
title: None,
|
||||||
is_active: Some(true),
|
is_active: Some(true),
|
||||||
is_focused: Some(false),
|
is_focused: Some(false),
|
||||||
|
is_active_in_column: None,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
open_on_output: Some("eDP-1".to_owned()),
|
open_on_output: Some("eDP-1".to_owned()),
|
||||||
|
|||||||
@@ -213,6 +213,8 @@ impl LayoutElement for TestWindow {
|
|||||||
|
|
||||||
fn set_activated(&mut self, _active: bool) {}
|
fn set_activated(&mut self, _active: bool) {}
|
||||||
|
|
||||||
|
fn set_active_in_column(&mut self, _active: bool) {}
|
||||||
|
|
||||||
fn set_bounds(&self, _bounds: Size<i32, Logical>) {}
|
fn set_bounds(&self, _bounds: Size<i32, Logical>) {}
|
||||||
|
|
||||||
fn send_pending_configure(&mut self) {}
|
fn send_pending_configure(&mut self) {}
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ pub trait LayoutElement {
|
|||||||
fn output_leave(&self, output: &Output);
|
fn output_leave(&self, output: &Output);
|
||||||
fn set_offscreen_element_id(&self, id: Option<Id>);
|
fn set_offscreen_element_id(&self, id: Option<Id>);
|
||||||
fn set_activated(&mut self, active: bool);
|
fn set_activated(&mut self, active: bool);
|
||||||
|
fn set_active_in_column(&mut self, active: bool);
|
||||||
fn set_bounds(&self, bounds: Size<i32, Logical>);
|
fn set_bounds(&self, bounds: Size<i32, Logical>);
|
||||||
|
|
||||||
fn send_pending_configure(&mut self);
|
fn send_pending_configure(&mut self);
|
||||||
@@ -2190,6 +2191,8 @@ mod tests {
|
|||||||
|
|
||||||
fn send_pending_configure(&mut self) {}
|
fn send_pending_configure(&mut self) {}
|
||||||
|
|
||||||
|
fn set_active_in_column(&mut self, _active: bool) {}
|
||||||
|
|
||||||
fn is_fullscreen(&self) -> bool {
|
fn is_fullscreen(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2459,9 +2459,11 @@ impl<W: LayoutElement> Workspace<W> {
|
|||||||
|
|
||||||
for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
|
for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
|
||||||
let win = tile.window_mut();
|
let win = tile.window_mut();
|
||||||
let active = is_active
|
|
||||||
&& self.active_column_idx == col_idx
|
let active_in_column = col.active_tile_idx == tile_idx;
|
||||||
&& col.active_tile_idx == tile_idx;
|
win.set_active_in_column(active_in_column);
|
||||||
|
|
||||||
|
let active = is_active && self.active_column_idx == col_idx && active_in_column;
|
||||||
win.set_activated(active);
|
win.set_activated(active);
|
||||||
|
|
||||||
win.set_interactive_resize(col_resize_data);
|
win.set_interactive_resize(col_resize_data);
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ pub struct Mapped {
|
|||||||
/// Whether this window has the keyboard focus.
|
/// Whether this window has the keyboard focus.
|
||||||
is_focused: bool,
|
is_focused: bool,
|
||||||
|
|
||||||
|
/// Whether this window is the active window in its column.
|
||||||
|
pub is_active_in_column: bool,
|
||||||
|
|
||||||
/// Buffer to draw instead of the window when it should be blocked out.
|
/// Buffer to draw instead of the window when it should be blocked out.
|
||||||
block_out_buffer: RefCell<SolidColorBuffer>,
|
block_out_buffer: RefCell<SolidColorBuffer>,
|
||||||
|
|
||||||
@@ -102,6 +105,7 @@ impl Mapped {
|
|||||||
rules,
|
rules,
|
||||||
need_to_recompute_rules: false,
|
need_to_recompute_rules: false,
|
||||||
is_focused: false,
|
is_focused: false,
|
||||||
|
is_active_in_column: false,
|
||||||
block_out_buffer: RefCell::new(SolidColorBuffer::new((0, 0), [0., 0., 0., 1.])),
|
block_out_buffer: RefCell::new(SolidColorBuffer::new((0, 0), [0., 0., 0., 1.])),
|
||||||
animate_next_configure: false,
|
animate_next_configure: false,
|
||||||
animate_serials: Vec::new(),
|
animate_serials: Vec::new(),
|
||||||
@@ -458,6 +462,12 @@ impl LayoutElement for Mapped {
|
|||||||
self.need_to_recompute_rules |= changed;
|
self.need_to_recompute_rules |= changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_active_in_column(&mut self, active: bool) {
|
||||||
|
let changed = self.is_active_in_column != active;
|
||||||
|
self.is_active_in_column = active;
|
||||||
|
self.need_to_recompute_rules |= changed;
|
||||||
|
}
|
||||||
|
|
||||||
fn set_bounds(&self, bounds: Size<i32, Logical>) {
|
fn set_bounds(&self, bounds: Size<i32, Logical>) {
|
||||||
self.toplevel().with_pending_state(|state| {
|
self.toplevel().with_pending_state(|state| {
|
||||||
state.bounds = Some(bounds);
|
state.bounds = Some(bounds);
|
||||||
|
|||||||
@@ -85,6 +85,13 @@ impl<'a> WindowRef<'a> {
|
|||||||
WindowRef::Mapped(mapped) => mapped.is_focused(),
|
WindowRef::Mapped(mapped) => mapped.is_focused(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_active_in_column(self) -> bool {
|
||||||
|
match self {
|
||||||
|
WindowRef::Unmapped(_) => false,
|
||||||
|
WindowRef::Mapped(mapped) => mapped.is_active_in_column,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResolvedWindowRules {
|
impl ResolvedWindowRules {
|
||||||
@@ -254,5 +261,11 @@ fn window_matches(window: WindowRef, role: &XdgToplevelSurfaceRoleAttributes, m:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(is_active_in_column) = m.is_active_in_column {
|
||||||
|
if window.is_active_in_column() != is_active_in_column {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,6 +174,20 @@ window-rule {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `is-active-in-column`
|
||||||
|
|
||||||
|
Can be `true` or `false`.
|
||||||
|
Matches the window that is the "active" window in its column.
|
||||||
|
|
||||||
|
Contrary to `is-active`, there is always one `is-active-in-column` window in each column.
|
||||||
|
It is the window that was last focused in the column, i.e. the one that will gain focus if this column is focused.
|
||||||
|
|
||||||
|
```
|
||||||
|
window-rule {
|
||||||
|
match is-active-in-column=true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Window Opening Properties
|
### Window Opening Properties
|
||||||
|
|
||||||
These properties apply once, when a window first opens.
|
These properties apply once, when a window first opens.
|
||||||
|
|||||||
Reference in New Issue
Block a user