mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-23 02:05:33 +07:00
Implement window rule reloading and min/max size rules
This commit is contained in:
+30
-1
@@ -114,7 +114,7 @@ use crate::utils::spawning::CHILD_ENV;
|
||||
use crate::utils::{
|
||||
center, center_f64, get_monotonic_time, make_screenshot_path, output_size, write_png_rgba8,
|
||||
};
|
||||
use crate::window::{Mapped, Unmapped};
|
||||
use crate::window::{InitialConfigureState, Mapped, ResolvedWindowRules, Unmapped};
|
||||
use crate::{animation, niri_render_elements};
|
||||
|
||||
const CLEAR_COLOR: [f32; 4] = [0.2, 0.2, 0.2, 1.];
|
||||
@@ -761,6 +761,7 @@ impl State {
|
||||
let mut reload_xkb = None;
|
||||
let mut libinput_config_changed = false;
|
||||
let mut output_config_changed = false;
|
||||
let mut window_rules_changed = false;
|
||||
let mut old_config = self.niri.config.borrow_mut();
|
||||
|
||||
// Reload the cursor.
|
||||
@@ -802,6 +803,10 @@ impl State {
|
||||
self.niri.hotkey_overlay.on_hotkey_config_updated();
|
||||
}
|
||||
|
||||
if config.window_rules != old_config.window_rules {
|
||||
window_rules_changed = true;
|
||||
}
|
||||
|
||||
*old_config = config;
|
||||
|
||||
// Release the borrow.
|
||||
@@ -865,6 +870,30 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
if window_rules_changed {
|
||||
let _span = tracy_client::span!("recompute window rules");
|
||||
|
||||
let window_rules = &self.niri.config.borrow().window_rules;
|
||||
|
||||
for unmapped in self.niri.unmapped_windows.values_mut() {
|
||||
if let InitialConfigureState::Configured { rules, .. } = &mut unmapped.state {
|
||||
*rules = ResolvedWindowRules::compute(
|
||||
window_rules,
|
||||
unmapped.window.toplevel().expect("no X11 support"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mut windows = vec![];
|
||||
self.niri.layout.with_windows_mut(|mapped, _| {
|
||||
mapped.rules = ResolvedWindowRules::compute(window_rules, mapped.toplevel());
|
||||
windows.push(mapped.window.clone());
|
||||
});
|
||||
for win in windows {
|
||||
self.niri.layout.update_window(&win);
|
||||
}
|
||||
}
|
||||
|
||||
// Can't really update xdg-decoration settings since we have to hide the globals for CSD
|
||||
// due to the SDL2 bug... I don't imagine clients are prepared for the xdg-decoration
|
||||
// global suddenly appearing? Either way, right now it's live-reloaded in a sense that new
|
||||
|
||||
Reference in New Issue
Block a user