Skip to content

Commit

Permalink
feat(wm): allow reapplying initial workspace rules
Browse files Browse the repository at this point in the history
This commit adds the following new socket messages and commands:
- `EnforceWorkspaceRules`: resets the `already_moved_window_handles` and
  calls `enforce_workspace_rules` so that all workspace rules, including
  initial workspace rules are applied again
- `enforce-workspace-rules`: cli command which sends the
  EnforceWorkspaceRules socket message
  • Loading branch information
alex-ds13 authored and LGUG2Z committed Dec 26, 2024
1 parent 4babf33 commit 692da90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions komorebi/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ pub enum SocketMessage {
ClearWorkspaceRules(usize, usize),
ClearNamedWorkspaceRules(String),
ClearAllWorkspaceRules,
EnforceWorkspaceRules,
#[serde(alias = "FloatRule")]
IgnoreRule(ApplicationIdentifier, String),
ManageRule(ApplicationIdentifier, String),
Expand Down
7 changes: 7 additions & 0 deletions komorebi/src/process_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@ impl WindowManager {
let mut workspace_rules = WORKSPACE_MATCHING_RULES.lock();
workspace_rules.clear();
}
SocketMessage::EnforceWorkspaceRules => {
{
let mut already_moved = self.already_moved_window_handles.lock();
already_moved.clear();
}
self.enforce_workspace_rules()?;
}
SocketMessage::ManageRule(identifier, ref id) => {
let mut manage_identifiers = MANAGE_IDENTIFIERS.lock();

Expand Down
5 changes: 5 additions & 0 deletions komorebic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,8 @@ enum SubCommand {
ClearNamedWorkspaceRules(ClearNamedWorkspaceRules),
/// Remove all application association rules for all workspaces
ClearAllWorkspaceRules,
/// Enforce all workspace rules, including initial workspace rules that have already been applied
EnforceWorkspaceRules,
/// Identify an application that sends EVENT_OBJECT_NAMECHANGE on launch
#[clap(arg_required_else_help = true)]
IdentifyObjectNameChangeApplication(IdentifyObjectNameChangeApplication),
Expand Down Expand Up @@ -2457,6 +2459,9 @@ if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) {
SubCommand::ClearAllWorkspaceRules => {
send_message(&SocketMessage::ClearAllWorkspaceRules)?;
}
SubCommand::EnforceWorkspaceRules => {
send_message(&SocketMessage::EnforceWorkspaceRules)?;
}
SubCommand::Stack(arg) => {
send_message(&SocketMessage::StackWindow(arg.operation_direction))?;
}
Expand Down

3 comments on commit 692da90

@pro470
Copy link

@pro470 pro470 commented on 692da90 Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the komorebi/src/process_command.rs the self.enforce_workspace_rules()?; expects a boolean I tried to build it in mine fork and I got this comp error:
error[E0061]: this method takes 1 argument but 0 arguments were supplied
--> komorebi\src\process_command.rs:412:22
|
412 | self.enforce_workspace_rules()?;
| ^^^^^^^^^^^^^^^^^^^^^^^-- argument #1 of type bool is missing
|

@LGUG2Z
Copy link
Owner

@LGUG2Z LGUG2Z commented on 692da90 Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I backed out my implementation of this in favor of alex's implementation which didn't require changing the function signature. Try running git fetch and git reset --hard origin/master to get the latest commit with my initial changes backed out

@pro470
Copy link

@pro470 pro470 commented on 692da90 Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now it works I had to go some commits back and merge again because I have an upstream remote branch but yeah it works now

Please sign in to comment.