Skip to content

Commit

Permalink
fix: Don't set dialog dim if different workspace
Browse files Browse the repository at this point in the history
This fixes an issue where windows would be dimmed when switching between
workspaces that have floating windows with the same class name.

Note that there hasn't been a new release yet, so no versions are
affected by this.
  • Loading branch information
donovanglover committed Aug 13, 2023
1 parent 4e04865 commit 65a5ac1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn main() -> hyprland::Result<()> {
let num_threads: Arc<Mutex<u16>> = Arc::new(Mutex::new(0));
let last_address: Arc<Mutex<Option<Address>>> = Arc::new(Mutex::new(None));
let last_class: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
let last_workspace: Arc<Mutex<Option<Workspace>>> = Arc::new(Mutex::new(None));
let is_set_dim: Arc<Mutex<bool>> = Arc::new(Mutex::new(false));
let in_special_workspace: Arc<Mutex<bool>> = Arc::new(Mutex::new(is_special()));

Expand Down Expand Up @@ -107,6 +108,16 @@ fn main() -> hyprland::Result<()> {
let parent_workspace = Workspace::get_active().unwrap();
let parent_workspace_window = &parent_workspace.last_window;

let mut same_workspace = false;

if let Some(ref old_workspace) = *last_workspace.lock().unwrap() {
if old_workspace.id == parent_workspace.id {
same_workspace = true;
}
}

*last_workspace.lock().unwrap() = Some(parent_workspace.clone());

// If the parent_workspace_window is NOT the same as the window_address, then we're in a special workspace
let is_special_workspace =
format!("{parent_workspace_window}") != format!("0x{window_address}");
Expand Down Expand Up @@ -136,7 +147,7 @@ fn main() -> hyprland::Result<()> {
// Enable dim when using a floating windows with the same class as the last window,
// but only if the user specified the argument to do so.
if let Some(dialog_strength) = dialog_dim {
if same_class && is_floating() {
if same_workspace && same_class && is_floating() {
*is_set_dim.lock().unwrap() = true;
set_dim(dialog_strength, persist).unwrap();
return;
Expand Down

0 comments on commit 65a5ac1

Please sign in to comment.