mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-31 06:23:13 +02:00
feat(wm): add monitor index preference cmd
This commit adds a new komorebic command, monitor-index-preference, which allows the user to set the index preference within the VecDeque of monitors based on the "size" of a display. This works as the size Rect identifies a unique display on the greater virtual screen and persists across display connections and disconnections unless the user deliberately changes the positioning of the display monitor on the virtual screen. When a new monitor is added to the state, the monitor preferences will be checked, and if a preference exists, the new monitor will be inserted at that index, otherwise, it will be pushed to the back of the VecDeque. resolve #275
This commit is contained in:
@@ -72,6 +72,7 @@ pub enum SocketMessage {
|
|||||||
ChangeLayoutCustom(PathBuf),
|
ChangeLayoutCustom(PathBuf),
|
||||||
FlipLayout(Axis),
|
FlipLayout(Axis),
|
||||||
// Monitor and Workspace Commands
|
// Monitor and Workspace Commands
|
||||||
|
MonitorIndexPreference(usize, i32, i32, i32, i32),
|
||||||
EnsureWorkspaces(usize, usize),
|
EnsureWorkspaces(usize, usize),
|
||||||
NewWorkspace,
|
NewWorkspace,
|
||||||
ToggleTiling,
|
ToggleTiling,
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ Run, komorebic.exe float-rule exe "1Password.exe", , Hide
|
|||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application class "CreativeCloudDesktopWindowClass", , Hide
|
Run, komorebic.exe identify-tray-application class "CreativeCloudDesktopWindowClass", , Hide
|
||||||
|
|
||||||
|
; ArmCord
|
||||||
|
Run, komorebic.exe identify-border-overflow-application exe "ArmCord.exe", , Hide
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application exe "ArmCord.exe", , Hide
|
||||||
|
|
||||||
; AutoHotkey
|
; AutoHotkey
|
||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application exe "AutoHotkeyU64.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "AutoHotkeyU64.exe", , Hide
|
||||||
@@ -46,9 +51,9 @@ Run, komorebic.exe identify-border-overflow-application exe "DiscordCanary.exe",
|
|||||||
Run, komorebic.exe identify-tray-application exe "DiscordCanary.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "DiscordCanary.exe", , Hide
|
||||||
|
|
||||||
; DiscordDevelopment
|
; DiscordDevelopment
|
||||||
Run, komorebic.exe identify-border-overflow-application exe "DiscordDeveloper.exe", , Hide
|
Run, komorebic.exe identify-border-overflow-application exe "DiscordDevelopment.exe", , Hide
|
||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application exe "DiscordDeveloper.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "DiscordDevelopment.exe", , Hide
|
||||||
|
|
||||||
; DiscordPTB
|
; DiscordPTB
|
||||||
Run, komorebic.exe identify-border-overflow-application exe "DiscordPTB.exe", , Hide
|
Run, komorebic.exe identify-border-overflow-application exe "DiscordPTB.exe", , Hide
|
||||||
@@ -95,6 +100,9 @@ Run, komorebic.exe identify-tray-application exe "chrome.exe", , Hide
|
|||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application exe "GoogleDriveFS.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "GoogleDriveFS.exe", , Hide
|
||||||
|
|
||||||
|
; Houdoku
|
||||||
|
Run, komorebic.exe identify-border-overflow-application exe "Houdoku.exe", , Hide
|
||||||
|
|
||||||
; Inno Setup
|
; Inno Setup
|
||||||
; Target hidden window spawned by Inno Setup applications
|
; Target hidden window spawned by Inno Setup applications
|
||||||
Run, komorebic.exe float-rule class "TApplication", , Hide
|
Run, komorebic.exe float-rule class "TApplication", , Hide
|
||||||
@@ -283,6 +291,10 @@ Run, komorebic.exe manage-rule exe "slack.exe", , Hide
|
|||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application exe "slack.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "slack.exe", , Hide
|
||||||
|
|
||||||
|
; SoulseekQt
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application exe "SoulseekQt.exe", , Hide
|
||||||
|
|
||||||
; Spotify
|
; Spotify
|
||||||
Run, komorebic.exe identify-border-overflow-application exe "Spotify.exe", , Hide
|
Run, komorebic.exe identify-border-overflow-application exe "Spotify.exe", , Hide
|
||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
@@ -291,6 +303,9 @@ Run, komorebic.exe identify-tray-application exe "Spotify.exe", , Hide
|
|||||||
; Steam
|
; Steam
|
||||||
Run, komorebic.exe identify-border-overflow-application class "vguiPopupWindow", , Hide
|
Run, komorebic.exe identify-border-overflow-application class "vguiPopupWindow", , Hide
|
||||||
|
|
||||||
|
; SystemSettings
|
||||||
|
Run, komorebic.exe float-rule class "Shell_Dialog", , Hide
|
||||||
|
|
||||||
; Task Manager
|
; Task Manager
|
||||||
Run, komorebic.exe float-rule class "TaskManagerWindow", , Hide
|
Run, komorebic.exe float-rule class "TaskManagerWindow", , Hide
|
||||||
|
|
||||||
@@ -319,6 +334,10 @@ Run, komorebic.exe identify-tray-application exe "UnrealEditor.exe", , Hide
|
|||||||
; Visual Studio Code
|
; Visual Studio Code
|
||||||
Run, komorebic.exe identify-border-overflow-application exe "Code.exe", , Hide
|
Run, komorebic.exe identify-border-overflow-application exe "Code.exe", , Hide
|
||||||
|
|
||||||
|
; WebTorrent Desktop
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application exe "WebTorrent.exe", , Hide
|
||||||
|
|
||||||
; Windows Console (conhost.exe)
|
; Windows Console (conhost.exe)
|
||||||
Run, komorebic.exe manage-rule class "ConsoleWindowClass", , Hide
|
Run, komorebic.exe manage-rule class "ConsoleWindowClass", , Hide
|
||||||
|
|
||||||
@@ -331,6 +350,14 @@ Run, komorebic.exe float-rule title "Control Panel", , Hide
|
|||||||
; Targets MSI Installers
|
; Targets MSI Installers
|
||||||
Run, komorebic.exe float-rule class "MsiDialogCloseClass", , Hide
|
Run, komorebic.exe float-rule class "MsiDialogCloseClass", , Hide
|
||||||
|
|
||||||
|
; WingetUI
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application exe "WingetUI.exe", , Hide
|
||||||
|
|
||||||
|
; WingetUI
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application exe "wingetui.exe", , Hide
|
||||||
|
|
||||||
; Wox
|
; Wox
|
||||||
; Targets a hidden window spawned by Wox
|
; Targets a hidden window spawned by Wox
|
||||||
Run, komorebic.exe float-rule title "Hotkey sink", , Hide
|
Run, komorebic.exe float-rule title "Hotkey sink", , Hide
|
||||||
@@ -338,6 +365,16 @@ Run, komorebic.exe float-rule title "Hotkey sink", , Hide
|
|||||||
; Zoom
|
; Zoom
|
||||||
Run, komorebic.exe float-rule exe "Zoom.exe", , Hide
|
Run, komorebic.exe float-rule exe "Zoom.exe", , Hide
|
||||||
|
|
||||||
|
; mpv
|
||||||
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
|
Run, komorebic.exe identify-tray-application class "mpv", , Hide
|
||||||
|
|
||||||
|
; mpv.net
|
||||||
|
Run, komorebic.exe identify-object-name-change-application exe "mpvnet.exe", , Hide
|
||||||
|
|
||||||
|
; paint.net
|
||||||
|
Run, komorebic.exe float-rule exe "paintdotnet.exe", , Hide
|
||||||
|
|
||||||
; qBittorrent
|
; qBittorrent
|
||||||
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
; If you have disabled minimize/close to tray for this application, you can delete/comment out the next line
|
||||||
Run, komorebic.exe identify-tray-application exe "qbittorrent.exe", , Hide
|
Run, komorebic.exe identify-tray-application exe "qbittorrent.exe", , Hide
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ lazy_static! {
|
|||||||
"firefox.exe".to_string(),
|
"firefox.exe".to_string(),
|
||||||
"idea64.exe".to_string(),
|
"idea64.exe".to_string(),
|
||||||
]));
|
]));
|
||||||
|
static ref MONITOR_INDEX_PREFERENCES: Arc<Mutex<HashMap<usize, Rect>>> =
|
||||||
|
Arc::new(Mutex::new(HashMap::new()));
|
||||||
static ref WORKSPACE_RULES: Arc<Mutex<HashMap<String, (usize, usize)>>> =
|
static ref WORKSPACE_RULES: Arc<Mutex<HashMap<String, (usize, usize)>>> =
|
||||||
Arc::new(Mutex::new(HashMap::new()));
|
Arc::new(Mutex::new(HashMap::new()));
|
||||||
static ref MANAGE_IDENTIFIERS: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![]));
|
static ref MANAGE_IDENTIFIERS: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(vec![]));
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ use crate::HIDING_BEHAVIOUR;
|
|||||||
use crate::INITIAL_CONFIGURATION_LOADED;
|
use crate::INITIAL_CONFIGURATION_LOADED;
|
||||||
use crate::LAYERED_WHITELIST;
|
use crate::LAYERED_WHITELIST;
|
||||||
use crate::MANAGE_IDENTIFIERS;
|
use crate::MANAGE_IDENTIFIERS;
|
||||||
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
use crate::OBJECT_NAME_CHANGE_ON_LAUNCH;
|
||||||
use crate::SUBSCRIPTION_PIPES;
|
use crate::SUBSCRIPTION_PIPES;
|
||||||
use crate::TCP_CONNECTIONS;
|
use crate::TCP_CONNECTIONS;
|
||||||
@@ -402,6 +403,18 @@ impl WindowManager {
|
|||||||
|
|
||||||
std::process::exit(0)
|
std::process::exit(0)
|
||||||
}
|
}
|
||||||
|
SocketMessage::MonitorIndexPreference(index_preference, left, top, right, bottom) => {
|
||||||
|
let mut monitor_index_preferences = MONITOR_INDEX_PREFERENCES.lock();
|
||||||
|
monitor_index_preferences.insert(
|
||||||
|
index_preference,
|
||||||
|
Rect {
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
right,
|
||||||
|
bottom,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
SocketMessage::EnsureWorkspaces(monitor_idx, workspace_count) => {
|
SocketMessage::EnsureWorkspaces(monitor_idx, workspace_count) => {
|
||||||
self.ensure_workspaces_for_monitor(monitor_idx, workspace_count)?;
|
self.ensure_workspaces_for_monitor(monitor_idx, workspace_count)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ use crate::windows_api::WindowsApi;
|
|||||||
use crate::winevent_listener::WINEVENT_CALLBACK_CHANNEL;
|
use crate::winevent_listener::WINEVENT_CALLBACK_CHANNEL;
|
||||||
use crate::BORDER_COLOUR_CURRENT;
|
use crate::BORDER_COLOUR_CURRENT;
|
||||||
use crate::BORDER_RECT;
|
use crate::BORDER_RECT;
|
||||||
|
use crate::MONITOR_INDEX_PREFERENCES;
|
||||||
use crate::TRANSPARENCY_COLOUR;
|
use crate::TRANSPARENCY_COLOUR;
|
||||||
|
|
||||||
pub extern "system" fn valid_display_monitors(
|
pub extern "system" fn valid_display_monitors(
|
||||||
@@ -71,7 +72,24 @@ pub extern "system" fn enum_display_monitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(m) = WindowsApi::monitor(hmonitor.0) {
|
if let Ok(m) = WindowsApi::monitor(hmonitor.0) {
|
||||||
monitors.elements_mut().push_back(m);
|
let monitor_index_preferences = MONITOR_INDEX_PREFERENCES.lock();
|
||||||
|
let mut index_preference = None;
|
||||||
|
for (index, monitor_size) in &*monitor_index_preferences {
|
||||||
|
if m.size() == monitor_size {
|
||||||
|
index_preference = Option::from(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(preference) = index_preference {
|
||||||
|
let current_len = monitors.elements().len();
|
||||||
|
if *preference > current_len {
|
||||||
|
monitors.elements_mut().reserve(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
monitors.elements_mut().insert(*preference, m);
|
||||||
|
} else {
|
||||||
|
monitors.elements_mut().push_back(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
true.into()
|
true.into()
|
||||||
|
|||||||
@@ -180,6 +180,10 @@ Retile() {
|
|||||||
RunWait, komorebic.exe retile, , Hide
|
RunWait, komorebic.exe retile, , Hide
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonitorIndexPreference(index_preference, left, top, right, bottom) {
|
||||||
|
RunWait, komorebic.exe monitor-index-preference %index_preference% %left% %top% %right% %bottom%, , Hide
|
||||||
|
}
|
||||||
|
|
||||||
EnsureWorkspaces(monitor, workspace_count) {
|
EnsureWorkspaces(monitor, workspace_count) {
|
||||||
RunWait, komorebic.exe ensure-workspaces %monitor% %workspace_count%, , Hide
|
RunWait, komorebic.exe ensure-workspaces %monitor% %workspace_count%, , Hide
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,6 +279,20 @@ struct WorkAreaOffset {
|
|||||||
bottom: i32,
|
bottom: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Parser, AhkFunction)]
|
||||||
|
struct MonitorIndexPreference {
|
||||||
|
/// Preferred monitor index (zero-indexed)
|
||||||
|
index_preference: usize,
|
||||||
|
/// Left value of the monitor's size Rect
|
||||||
|
left: i32,
|
||||||
|
/// Top value of the monitor's size Rect
|
||||||
|
top: i32,
|
||||||
|
/// Right value of the monitor's size Rect
|
||||||
|
right: i32,
|
||||||
|
/// Bottom value of the monitor's size Rect
|
||||||
|
bottom: i32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Parser, AhkFunction)]
|
#[derive(Parser, AhkFunction)]
|
||||||
struct EnsureWorkspaces {
|
struct EnsureWorkspaces {
|
||||||
/// Monitor index (zero-indexed)
|
/// Monitor index (zero-indexed)
|
||||||
@@ -606,6 +620,9 @@ enum SubCommand {
|
|||||||
PromoteFocus,
|
PromoteFocus,
|
||||||
/// Force the retiling of all managed windows
|
/// Force the retiling of all managed windows
|
||||||
Retile,
|
Retile,
|
||||||
|
/// Set the monitor index preference for a monitor identified using its size
|
||||||
|
#[clap(arg_required_else_help = true)]
|
||||||
|
MonitorIndexPreference(MonitorIndexPreference),
|
||||||
/// Create at least this many workspaces for the specified monitor
|
/// Create at least this many workspaces for the specified monitor
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
EnsureWorkspaces(EnsureWorkspaces),
|
EnsureWorkspaces(EnsureWorkspaces),
|
||||||
@@ -1108,6 +1125,18 @@ fn main() -> Result<()> {
|
|||||||
.as_bytes()?,
|
.as_bytes()?,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::MonitorIndexPreference(arg) => {
|
||||||
|
send_message(
|
||||||
|
&SocketMessage::MonitorIndexPreference(
|
||||||
|
arg.index_preference,
|
||||||
|
arg.left,
|
||||||
|
arg.top,
|
||||||
|
arg.right,
|
||||||
|
arg.bottom,
|
||||||
|
)
|
||||||
|
.as_bytes()?,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
SubCommand::EnsureWorkspaces(workspaces) => {
|
SubCommand::EnsureWorkspaces(workspaces) => {
|
||||||
send_message(
|
send_message(
|
||||||
&SocketMessage::EnsureWorkspaces(workspaces.monitor, workspaces.workspace_count)
|
&SocketMessage::EnsureWorkspaces(workspaces.monitor, workspaces.workspace_count)
|
||||||
|
|||||||
Reference in New Issue
Block a user