From 5ff8b89aafca0143866f93dd7e2f27aee6c2b0f5 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 8 Nov 2024 09:11:56 +0300 Subject: Rework output connection to always go through on_output_config_changed() This has the following benefits: 1. connector_connected() is now more closely mirroring connector_disconnected() in that it merely lights up the connector, and doesn't check if the connector should be off from the config. 2. We can use more complex on/off logic that depends on multiple connectors. For example, this commit adds logic to only disable the laptop panel on lid close if there are other connected outputs. We don't want to disable the laptop panel on lid close if it's the only connected output because it causes screen lockers to create their surface from scratch on normal laptop unsuspend, which is undesirable and also confuses some screen lockers. --- src/niri.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/niri.rs') diff --git a/src/niri.rs b/src/niri.rs index 50cf444f..79f99858 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -143,9 +143,8 @@ use crate::ui::screenshot_ui::{OutputScreenshot, ScreenshotUi, ScreenshotUiRende use crate::utils::scale::{closest_representable_scale, guess_monitor_scale}; use crate::utils::spawning::CHILD_ENV; use crate::utils::{ - center, center_f64, get_monotonic_time, ipc_transform_to_smithay, is_laptop_panel, - logical_output, make_screenshot_path, output_matches_name, output_size, send_scale_transform, - write_png_rgba8, + center, center_f64, get_monotonic_time, ipc_transform_to_smithay, logical_output, + make_screenshot_path, output_matches_name, output_size, send_scale_transform, write_png_rgba8, }; use crate::window::{InitialConfigureState, Mapped, ResolvedWindowRules, Unmapped, WindowRef}; use crate::{animation, niri_render_elements}; @@ -4811,22 +4810,6 @@ impl Niri { .unwrap(); self.pointer_inactivity_timer = Some(token); } - - pub fn should_enable_laptop_panel(&self, connector: &str) -> bool { - // Make sure the output config is reloaded when any of the conditions in this function - // change. - - let config = self.config.borrow(); - - // We reload the output config when this flag changes. - if config.debug.keep_laptop_panel_on_when_lid_is_closed { - return true; - } - - // We reload the output config when the lid switch is toggled, and the connector name is - // static. - !(self.is_lid_closed && is_laptop_panel(connector)) - } } pub struct ClientState { -- cgit