diff --git a/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs index 9a7269fbe..aa4f33c76 100644 --- a/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs +++ b/GlazeWM.Domain/Containers/CommandHandlers/RedrawContainersHandler.cs @@ -68,8 +68,7 @@ private void SetWindowPosition(Window window) SetWindowPosFlags.FrameChanged | SetWindowPosFlags.NoActivate | SetWindowPosFlags.NoCopyBits | - SetWindowPosFlags.NoSendChanging | - SetWindowPosFlags.AsyncWindowPos; + SetWindowPosFlags.NoSendChanging; // Show or hide the window depending on whether the workspace is displayed. if (window.IsDisplayed) diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs index bd3e72792..b1e2106d9 100644 --- a/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs +++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/RegisterKeybindingsHandler.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Threading.Tasks; using GlazeWM.Domain.UserConfigs.Commands; using GlazeWM.Domain.Windows; using GlazeWM.Infrastructure.Bussing; @@ -38,11 +39,14 @@ public CommandResponse Handle(RegisterKeybindingsCommand command) foreach (var binding in keybindingConfig.BindingList) _keybindingService.AddGlobalKeybinding(binding, () => { - // Avoid invoking keybinding if an ignored window currently has focus. - if (_windowService.IgnoredHandles.Contains(GetForegroundWindow())) - return; + Task.Run(() => + { + // Avoid invoking keybinding if an ignored window currently has focus. + if (_windowService.IgnoredHandles.Contains(GetForegroundWindow())) + return; - _bus.InvokeAsync(new RunWithSubjectContainerCommand(commandStrings)); + _bus.Invoke(new RunWithSubjectContainerCommand(commandStrings)); + }); }); } diff --git a/GlazeWM.Domain/UserConfigs/CommandHandlers/RunWithSubjectContainerHandler.cs b/GlazeWM.Domain/UserConfigs/CommandHandlers/RunWithSubjectContainerHandler.cs index c1ce148be..9a241902d 100644 --- a/GlazeWM.Domain/UserConfigs/CommandHandlers/RunWithSubjectContainerHandler.cs +++ b/GlazeWM.Domain/UserConfigs/CommandHandlers/RunWithSubjectContainerHandler.cs @@ -2,6 +2,7 @@ using GlazeWM.Domain.Containers; using GlazeWM.Domain.UserConfigs.Commands; using GlazeWM.Infrastructure.Bussing; +using GlazeWM.Infrastructure.Utils; namespace GlazeWM.Domain.UserConfigs.CommandHandlers { @@ -24,15 +25,15 @@ public RunWithSubjectContainerHandler( public CommandResponse Handle(RunWithSubjectContainerCommand command) { - var commandStrings = command.CommandStrings; + var commandStrings = command.CommandStrings.ToList(); var subjectContainer = command.SubjectContainer ?? _containerService.FocusedContainer; var subjectContainerId = subjectContainer.Id; - // Return early if any of the commands is an ignore command. + // Evaluate ignore rules first (avoids jitters if another rule triggers a redraw). if (commandStrings.Any(command => command == "ignore")) - return CommandResponse.Ok; + commandStrings.MoveToFront("ignore"); // Invoke commands in sequence. foreach (var commandString in commandStrings) diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs index e3142a9d4..5be8315c5 100644 --- a/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs +++ b/GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs @@ -68,13 +68,8 @@ public void Handle(WindowFocusedEvent @event) var window = _windowService.GetWindows() .FirstOrDefault(window => window.Handle == @event.WindowHandle); - if (window is null) + if (window is null || window?.IsDisplayed == false) return; - if (!window.IsDisplayed) - { - var offScreenWorkspace = WorkspaceService.GetWorkspaceFromChildContainer(window); - _bus.Invoke(new FocusWorkspaceCommand(offScreenWorkspace.Name)); - } _logger.LogWindowEvent("Window focused", window);