Move tiling exceptions to configuration file
This commit is contained in:
parent
7da0bc430a
commit
e8947b8742
6 changed files with 94 additions and 77 deletions
|
|
@ -47,6 +47,7 @@ use cosmic_comp_config::{
|
|||
pub struct Config {
|
||||
pub dynamic_conf: DynamicConfig,
|
||||
pub cosmic_helper: cosmic_config::Config,
|
||||
/// cosmic-config comp configuration for `com.system76.CosmicComp`
|
||||
pub cosmic_conf: CosmicCompConfig,
|
||||
/// cosmic-config context for `com.system76.CosmicSettings.Shortcuts`
|
||||
pub settings_context: cosmic_config::Config,
|
||||
|
|
|
|||
|
|
@ -8,84 +8,13 @@ use smithay::{
|
|||
xwayland::xwm::WmWindowType,
|
||||
};
|
||||
|
||||
use crate::config::Config;
|
||||
|
||||
use super::CosmicSurface;
|
||||
|
||||
pub mod floating;
|
||||
pub mod tiling;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref EXCEPTIONS_APPID: RegexSet = RegexSet::new(&[
|
||||
r"Authy Desktop",
|
||||
r"Com.github.amezin.ddterm",
|
||||
r"Com.github.donadigo.eddy",
|
||||
r".*",
|
||||
r"Enpass",
|
||||
r"Gjs",
|
||||
r"Gnome-initial-setup",
|
||||
r"Gnome-terminal",
|
||||
r"Guake",
|
||||
r"Io.elementary.sideload",
|
||||
r"KotatogramDesktop",
|
||||
r"Mozilla VPN",
|
||||
r"update-manager",
|
||||
r"Solaar",
|
||||
r"Steam",
|
||||
r"",
|
||||
r"TelegramDesktop",
|
||||
r"Zotero",
|
||||
r"gjs",
|
||||
r"gnome-screenshot",
|
||||
r"ibus-.*",
|
||||
r"jetbrains-toolbox",
|
||||
r"jetbrains-webstorm",
|
||||
r"jetbrains-webstorm",
|
||||
r"jetbrains-webstorm",
|
||||
r"krunner",
|
||||
r"pritunl",
|
||||
r"re.sonny.Junction",
|
||||
r"system76-driver",
|
||||
r"tilda",
|
||||
r"zoom",
|
||||
r"^.*?action=join.*$",
|
||||
r"",
|
||||
]).unwrap();
|
||||
static ref EXCEPTIONS_TITLE: RegexSet = RegexSet::new(&[
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r"Discord Updater",
|
||||
r"Enpass Assistant",
|
||||
r"Settings",
|
||||
r".*",
|
||||
r"Preferences – General",
|
||||
r".*",
|
||||
r".*",
|
||||
r"Media viewer",
|
||||
r".*",
|
||||
r"Software Updater",
|
||||
r".*",
|
||||
r"^.*?(Guard|Login).*",
|
||||
r"Steam",
|
||||
r"Media viewer",
|
||||
r"Quick Format Citation",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r"Customize WebStorm",
|
||||
r"License Activation",
|
||||
r"Welcome to WebStorm",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r".*",
|
||||
r"wl-clipboard",
|
||||
]).unwrap();
|
||||
}
|
||||
|
||||
pub fn is_dialog(window: &CosmicSurface) -> bool {
|
||||
// Check "window type"
|
||||
match window.0.underlying_surface() {
|
||||
|
|
@ -126,10 +55,35 @@ pub fn is_dialog(window: &CosmicSurface) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn has_floating_exception(window: &CosmicSurface) -> bool {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TilingExceptions {
|
||||
app_ids: RegexSet,
|
||||
titles: RegexSet,
|
||||
}
|
||||
|
||||
impl TilingExceptions {
|
||||
pub fn new(config: &Config) -> Self {
|
||||
let mut app_ids = Vec::new();
|
||||
let mut titles = Vec::new();
|
||||
|
||||
for app in &config.cosmic_conf.tiling_exceptions {
|
||||
for title in &app.titles {
|
||||
app_ids.push(app.appid.clone());
|
||||
titles.push(title.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
app_ids: RegexSet::new(app_ids).unwrap(),
|
||||
titles: RegexSet::new(titles).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_floating_exception(exceptions: &TilingExceptions, window: &CosmicSurface) -> bool {
|
||||
// else take a look at our exceptions
|
||||
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
||||
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
||||
let appid_matches = exceptions.app_ids.matches(&window.app_id());
|
||||
let title_matches = exceptions.titles.matches(&window.title());
|
||||
for idx in appid_matches.into_iter() {
|
||||
if title_matches.matched(idx) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use calloop::LoopHandle;
|
||||
use grabs::SeatMoveGrabState;
|
||||
use indexmap::IndexMap;
|
||||
use layout::TilingExceptions;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::atomic::Ordering,
|
||||
|
|
@ -257,6 +258,7 @@ pub struct Shell {
|
|||
Output,
|
||||
)>,
|
||||
resize_indicator: Option<ResizeIndicator>,
|
||||
tiling_exceptions: TilingExceptions,
|
||||
|
||||
#[cfg(feature = "debug")]
|
||||
pub debug_active: bool,
|
||||
|
|
@ -1250,6 +1252,7 @@ impl Shell {
|
|||
resize_mode: ResizeMode::None,
|
||||
resize_state: None,
|
||||
resize_indicator: None,
|
||||
tiling_exceptions: layout::TilingExceptions::new(config),
|
||||
|
||||
#[cfg(feature = "debug")]
|
||||
debug_active: false,
|
||||
|
|
@ -2093,7 +2096,7 @@ impl Shell {
|
|||
&& (workspace_output != seat.active_output() || active_handle != workspace.handle);
|
||||
let workspace_handle = workspace.handle;
|
||||
let is_dialog = layout::is_dialog(&window);
|
||||
let floating_exception = layout::has_floating_exception(&window);
|
||||
let floating_exception = layout::has_floating_exception(&self.tiling_exceptions, &window);
|
||||
|
||||
let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned();
|
||||
if let Some(focused) = maybe_focused {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue