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 {
|
||||
id: usize,
|
||||
inner: Rc<RefCell<TestWindowInner>>,
|
||||
rules: ResolvedWindowRules,
|
||||
}
|
||||
|
||||
impl TestWindow {
|
||||
@@ -54,6 +55,7 @@ impl TestWindow {
|
||||
csd_shadow_width: 0,
|
||||
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 rules(&self) -> &ResolvedWindowRules {
|
||||
static EMPTY: ResolvedWindowRules = ResolvedWindowRules::empty();
|
||||
&EMPTY
|
||||
&self.rules
|
||||
}
|
||||
|
||||
fn take_animation_snapshot(&mut self) -> Option<LayoutElementRenderSnapshot> {
|
||||
|
||||
@@ -135,7 +135,7 @@ impl CompositorHandler for State {
|
||||
// there are in-flight pending configures.
|
||||
debug!("window mapped without proper initial configure");
|
||||
(
|
||||
ResolvedWindowRules::empty(),
|
||||
ResolvedWindowRules::default(),
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
|
||||
+2
-2
@@ -92,7 +92,7 @@ impl TestWindow {
|
||||
is_pending_windowed_fullscreen: Cell::new(false),
|
||||
animate_next_configure: Cell::new(false),
|
||||
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 {
|
||||
focus_ring,
|
||||
border,
|
||||
..ResolvedWindowRules::empty()
|
||||
..ResolvedWindowRules::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-71
@@ -30,7 +30,7 @@ pub enum WindowRef<'a> {
|
||||
}
|
||||
|
||||
/// Rules fully resolved for a window.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[derive(Debug, Default, PartialEq, Clone)]
|
||||
pub struct ResolvedWindowRules {
|
||||
/// Default width for this window.
|
||||
///
|
||||
@@ -174,79 +174,10 @@ impl<'a> WindowRef<'a> {
|
||||
}
|
||||
|
||||
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 {
|
||||
let _span = tracy_client::span!("ResolvedWindowRules::compute");
|
||||
|
||||
let mut resolved = ResolvedWindowRules::empty();
|
||||
let mut resolved = ResolvedWindowRules::default();
|
||||
|
||||
with_toplevel_role(window.toplevel(), |role| {
|
||||
// Ensure server_pending like in Smithay's with_pending_state().
|
||||
|
||||
Reference in New Issue
Block a user