mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Remove hand-written ResolvedWindowRules::empty()
It was only needed to be const fn.
This commit is contained in:
@@ -33,6 +33,7 @@ struct TestWindowInner {
|
|||||||
pub struct TestWindow {
|
pub struct TestWindow {
|
||||||
id: usize,
|
id: usize,
|
||||||
inner: Rc<RefCell<TestWindowInner>>,
|
inner: Rc<RefCell<TestWindowInner>>,
|
||||||
|
rules: ResolvedWindowRules,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestWindow {
|
impl TestWindow {
|
||||||
@@ -54,6 +55,7 @@ impl TestWindow {
|
|||||||
csd_shadow_width: 0,
|
csd_shadow_width: 0,
|
||||||
csd_shadow_buffer: SolidColorBuffer::new((0., 0.), [0., 0., 0., 0.3]),
|
csd_shadow_buffer: SolidColorBuffer::new((0., 0.), [0., 0., 0., 0.3]),
|
||||||
})),
|
})),
|
||||||
|
rules: ResolvedWindowRules::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,8 +253,7 @@ impl LayoutElement for TestWindow {
|
|||||||
fn refresh(&self) {}
|
fn refresh(&self) {}
|
||||||
|
|
||||||
fn rules(&self) -> &ResolvedWindowRules {
|
fn rules(&self) -> &ResolvedWindowRules {
|
||||||
static EMPTY: ResolvedWindowRules = ResolvedWindowRules::empty();
|
&self.rules
|
||||||
&EMPTY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {
|
fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ impl CompositorHandler for State {
|
|||||||
// there are in-flight pending configures.
|
// there are in-flight pending configures.
|
||||||
debug!("window mapped without proper initial configure");
|
debug!("window mapped without proper initial configure");
|
||||||
(
|
(
|
||||||
ResolvedWindowRules::empty(),
|
ResolvedWindowRules::default(),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
|
|||||||
+2
-2
@@ -92,7 +92,7 @@ impl TestWindow {
|
|||||||
is_pending_windowed_fullscreen: Cell::new(false),
|
is_pending_windowed_fullscreen: Cell::new(false),
|
||||||
animate_next_configure: Cell::new(false),
|
animate_next_configure: Cell::new(false),
|
||||||
animation_snapshot: RefCell::new(None),
|
animation_snapshot: RefCell::new(None),
|
||||||
rules: params.rules.unwrap_or(ResolvedWindowRules::empty()),
|
rules: params.rules.unwrap_or_default(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ prop_compose! {
|
|||||||
ResolvedWindowRules {
|
ResolvedWindowRules {
|
||||||
focus_ring,
|
focus_ring,
|
||||||
border,
|
border,
|
||||||
..ResolvedWindowRules::empty()
|
..ResolvedWindowRules::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-71
@@ -30,7 +30,7 @@ pub enum WindowRef<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Rules fully resolved for a window.
|
/// Rules fully resolved for a window.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, Default, PartialEq, Clone)]
|
||||||
pub struct ResolvedWindowRules {
|
pub struct ResolvedWindowRules {
|
||||||
/// Default width for this window.
|
/// Default width for this window.
|
||||||
///
|
///
|
||||||
@@ -174,79 +174,10 @@ impl<'a> WindowRef<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResolvedWindowRules {
|
impl ResolvedWindowRules {
|
||||||
pub const fn empty() -> Self {
|
|
||||||
Self {
|
|
||||||
default_width: None,
|
|
||||||
default_height: None,
|
|
||||||
default_column_display: None,
|
|
||||||
default_floating_position: None,
|
|
||||||
open_on_output: None,
|
|
||||||
open_on_workspace: None,
|
|
||||||
open_maximized: None,
|
|
||||||
open_maximized_to_edges: None,
|
|
||||||
open_fullscreen: None,
|
|
||||||
open_floating: None,
|
|
||||||
open_focused: None,
|
|
||||||
min_width: None,
|
|
||||||
min_height: None,
|
|
||||||
max_width: None,
|
|
||||||
max_height: None,
|
|
||||||
focus_ring: BorderRule {
|
|
||||||
off: false,
|
|
||||||
on: false,
|
|
||||||
width: None,
|
|
||||||
active_color: None,
|
|
||||||
inactive_color: None,
|
|
||||||
urgent_color: None,
|
|
||||||
active_gradient: None,
|
|
||||||
inactive_gradient: None,
|
|
||||||
urgent_gradient: None,
|
|
||||||
},
|
|
||||||
border: BorderRule {
|
|
||||||
off: false,
|
|
||||||
on: false,
|
|
||||||
width: None,
|
|
||||||
active_color: None,
|
|
||||||
inactive_color: None,
|
|
||||||
urgent_color: None,
|
|
||||||
active_gradient: None,
|
|
||||||
inactive_gradient: None,
|
|
||||||
urgent_gradient: None,
|
|
||||||
},
|
|
||||||
shadow: ShadowRule {
|
|
||||||
off: false,
|
|
||||||
on: false,
|
|
||||||
offset: None,
|
|
||||||
softness: None,
|
|
||||||
spread: None,
|
|
||||||
draw_behind_window: None,
|
|
||||||
color: None,
|
|
||||||
inactive_color: None,
|
|
||||||
},
|
|
||||||
tab_indicator: TabIndicatorRule {
|
|
||||||
active_color: None,
|
|
||||||
inactive_color: None,
|
|
||||||
urgent_color: None,
|
|
||||||
active_gradient: None,
|
|
||||||
inactive_gradient: None,
|
|
||||||
urgent_gradient: None,
|
|
||||||
},
|
|
||||||
draw_border_with_background: None,
|
|
||||||
opacity: None,
|
|
||||||
geometry_corner_radius: None,
|
|
||||||
clip_to_geometry: None,
|
|
||||||
baba_is_float: None,
|
|
||||||
block_out_from: None,
|
|
||||||
variable_refresh_rate: None,
|
|
||||||
scroll_factor: None,
|
|
||||||
tiled_state: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn compute(rules: &[WindowRule], window: WindowRef, is_at_startup: bool) -> Self {
|
pub fn compute(rules: &[WindowRule], window: WindowRef, is_at_startup: bool) -> Self {
|
||||||
let _span = tracy_client::span!("ResolvedWindowRules::compute");
|
let _span = tracy_client::span!("ResolvedWindowRules::compute");
|
||||||
|
|
||||||
let mut resolved = ResolvedWindowRules::empty();
|
let mut resolved = ResolvedWindowRules::default();
|
||||||
|
|
||||||
with_toplevel_role(window.toplevel(), |role| {
|
with_toplevel_role(window.toplevel(), |role| {
|
||||||
// Ensure server_pending like in Smithay's with_pending_state().
|
// Ensure server_pending like in Smithay's with_pending_state().
|
||||||
|
|||||||
Reference in New Issue
Block a user