Move tiling exceptions to configuration file
This commit is contained in:
parent
7da0bc430a
commit
e8947b8742
6 changed files with 94 additions and 77 deletions
2
Makefile
2
Makefile
|
|
@ -24,6 +24,7 @@ endif
|
||||||
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
|
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
|
||||||
|
|
||||||
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
|
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
|
||||||
|
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicComp/v1/tiling_exceptions"
|
||||||
|
|
||||||
all: extract-vendor
|
all: extract-vendor
|
||||||
cargo build $(ARGS)
|
cargo build $(ARGS)
|
||||||
|
|
@ -49,6 +50,7 @@ endif
|
||||||
install:
|
install:
|
||||||
install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(TARGET_BIN)"
|
install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(TARGET_BIN)"
|
||||||
install -Dm0644 "data/keybindings.ron" "$(KEYBINDINGS_CONF)"
|
install -Dm0644 "data/keybindings.ron" "$(KEYBINDINGS_CONF)"
|
||||||
|
install -Dm0644 "data/tiling-exceptions.ron" "$(TILING_EXCEPTIONS_CONF)"
|
||||||
|
|
||||||
install-bare-session: install
|
install-bare-session: install
|
||||||
install -Dm0644 "data/cosmic.desktop" "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
|
install -Dm0644 "data/cosmic.desktop" "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ pub struct CosmicCompConfig {
|
||||||
pub input_touchpad: input::InputConfig,
|
pub input_touchpad: input::InputConfig,
|
||||||
pub input_devices: HashMap<String, input::InputConfig>,
|
pub input_devices: HashMap<String, input::InputConfig>,
|
||||||
pub xkb_config: XkbConfig,
|
pub xkb_config: XkbConfig,
|
||||||
|
pub tiling_exceptions: Vec<ApplicationExceptions>,
|
||||||
/// Autotiling enabled
|
/// Autotiling enabled
|
||||||
pub autotile: bool,
|
pub autotile: bool,
|
||||||
/// Determines the behavior of the autotile variable
|
/// Determines the behavior of the autotile variable
|
||||||
|
|
@ -33,6 +34,12 @@ pub struct CosmicCompConfig {
|
||||||
pub descale_xwayland: bool,
|
pub descale_xwayland: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||||
|
pub struct ApplicationExceptions {
|
||||||
|
pub appid: String,
|
||||||
|
pub titles: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for CosmicCompConfig {
|
impl Default for CosmicCompConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -53,6 +60,7 @@ impl Default for CosmicCompConfig {
|
||||||
},
|
},
|
||||||
input_devices: Default::default(),
|
input_devices: Default::default(),
|
||||||
xkb_config: Default::default(),
|
xkb_config: Default::default(),
|
||||||
|
tiling_exceptions: Default::default(),
|
||||||
autotile: Default::default(),
|
autotile: Default::default(),
|
||||||
autotile_behavior: Default::default(),
|
autotile_behavior: Default::default(),
|
||||||
active_hint: true,
|
active_hint: true,
|
||||||
|
|
|
||||||
49
data/tiling-exceptions.ron
Normal file
49
data/tiling-exceptions.ron
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
[
|
||||||
|
// Any appid title only matching
|
||||||
|
(
|
||||||
|
appid: ".*",
|
||||||
|
titles: [
|
||||||
|
"Discord Updater",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
// Empty appid title only matches
|
||||||
|
(
|
||||||
|
appid: "",
|
||||||
|
titles: [
|
||||||
|
"Steam",
|
||||||
|
"wl-clipboard",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
// Appid matches
|
||||||
|
(appid: "Authy Desktop", titles: [".*"]),
|
||||||
|
(appid: "Com.github.amezin.ddterm", titles: [".*"]),
|
||||||
|
(appid: "Com.github.donadigo.eddy", titles: [".*"]),
|
||||||
|
(appid: "Enpass", titles: ["Enpass Assistant"]),
|
||||||
|
(appid: "Gjs", titles: ["Settings"]),
|
||||||
|
(appid: "Gnome-initial-setup", titles: [".*"]),
|
||||||
|
(appid: "Gnome-terminal", titles: ["Preferences - General"]),
|
||||||
|
(appid: "Guake", titles: [".*"]),
|
||||||
|
(appid: "Io.elementary.sideload", titles: [".*"]),
|
||||||
|
(appid: "KotatogramDesktop", titles: ["Media viewer"]),
|
||||||
|
(appid: "Mozilla VPN", titles: [".*"]),
|
||||||
|
(appid: "update-manager", titles: ["Software Updater"]),
|
||||||
|
(appid: "Solaar", titles: [".*"]),
|
||||||
|
(appid: "Steam", titles: ["^.*?(Guard|Login).*"]),
|
||||||
|
(appid: "TelegramDesktop", titles: ["Media viewer"]),
|
||||||
|
(appid: "Zotero", titles: ["Quick Format Citation"]),
|
||||||
|
(appid: "gjs", titles: [".*"]),
|
||||||
|
(appid: "gnome-screenshot", titles: [".*"]),
|
||||||
|
(appid: "ibus-.*", titles: [".*"]),
|
||||||
|
(appid: "jetbrains-toolbox", titles: [".*"]),
|
||||||
|
(appid: "jetbrains-webstorm", titles: ["Customize WebStorm", "License Activation", "Welcome to WebStorm"]),
|
||||||
|
(appid: "krunner", titles: [".*"]),
|
||||||
|
(appid: "pritunl", titles: [".*"]),
|
||||||
|
(appid: "re.sonny.Junction", titles: [".*"]),
|
||||||
|
(appid: "system76-driver", titles: [".*"]),
|
||||||
|
(appid: "tilda", titles: [".*"]),
|
||||||
|
(appid: "zoom", titles: [".*"]),
|
||||||
|
(appid: "^.*?action=join.*$", titles: [".*"]),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
@ -47,6 +47,7 @@ use cosmic_comp_config::{
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub dynamic_conf: DynamicConfig,
|
pub dynamic_conf: DynamicConfig,
|
||||||
pub cosmic_helper: cosmic_config::Config,
|
pub cosmic_helper: cosmic_config::Config,
|
||||||
|
/// cosmic-config comp configuration for `com.system76.CosmicComp`
|
||||||
pub cosmic_conf: CosmicCompConfig,
|
pub cosmic_conf: CosmicCompConfig,
|
||||||
/// cosmic-config context for `com.system76.CosmicSettings.Shortcuts`
|
/// cosmic-config context for `com.system76.CosmicSettings.Shortcuts`
|
||||||
pub settings_context: cosmic_config::Config,
|
pub settings_context: cosmic_config::Config,
|
||||||
|
|
|
||||||
|
|
@ -8,84 +8,13 @@ use smithay::{
|
||||||
xwayland::xwm::WmWindowType,
|
xwayland::xwm::WmWindowType,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::config::Config;
|
||||||
|
|
||||||
use super::CosmicSurface;
|
use super::CosmicSurface;
|
||||||
|
|
||||||
pub mod floating;
|
pub mod floating;
|
||||||
pub mod tiling;
|
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 {
|
pub fn is_dialog(window: &CosmicSurface) -> bool {
|
||||||
// Check "window type"
|
// Check "window type"
|
||||||
match window.0.underlying_surface() {
|
match window.0.underlying_surface() {
|
||||||
|
|
@ -126,10 +55,35 @@ pub fn is_dialog(window: &CosmicSurface) -> bool {
|
||||||
false
|
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
|
// else take a look at our exceptions
|
||||||
let appid_matches = EXCEPTIONS_APPID.matches(&window.app_id());
|
let appid_matches = exceptions.app_ids.matches(&window.app_id());
|
||||||
let title_matches = EXCEPTIONS_TITLE.matches(&window.title());
|
let title_matches = exceptions.titles.matches(&window.title());
|
||||||
for idx in appid_matches.into_iter() {
|
for idx in appid_matches.into_iter() {
|
||||||
if title_matches.matched(idx) {
|
if title_matches.matched(idx) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use calloop::LoopHandle;
|
use calloop::LoopHandle;
|
||||||
use grabs::SeatMoveGrabState;
|
use grabs::SeatMoveGrabState;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use layout::TilingExceptions;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::atomic::Ordering,
|
sync::atomic::Ordering,
|
||||||
|
|
@ -257,6 +258,7 @@ pub struct Shell {
|
||||||
Output,
|
Output,
|
||||||
)>,
|
)>,
|
||||||
resize_indicator: Option<ResizeIndicator>,
|
resize_indicator: Option<ResizeIndicator>,
|
||||||
|
tiling_exceptions: TilingExceptions,
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
pub debug_active: bool,
|
pub debug_active: bool,
|
||||||
|
|
@ -1250,6 +1252,7 @@ impl Shell {
|
||||||
resize_mode: ResizeMode::None,
|
resize_mode: ResizeMode::None,
|
||||||
resize_state: None,
|
resize_state: None,
|
||||||
resize_indicator: None,
|
resize_indicator: None,
|
||||||
|
tiling_exceptions: layout::TilingExceptions::new(config),
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
debug_active: false,
|
debug_active: false,
|
||||||
|
|
@ -2093,7 +2096,7 @@ impl Shell {
|
||||||
&& (workspace_output != seat.active_output() || active_handle != workspace.handle);
|
&& (workspace_output != seat.active_output() || active_handle != workspace.handle);
|
||||||
let workspace_handle = workspace.handle;
|
let workspace_handle = workspace.handle;
|
||||||
let is_dialog = layout::is_dialog(&window);
|
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();
|
let maybe_focused = workspace.focus_stack.get(&seat).iter().next().cloned();
|
||||||
if let Some(focused) = maybe_focused {
|
if let Some(focused) = maybe_focused {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue