Skip to content

Commit

Permalink
revert offscreen workspace fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Sep 7, 2023
1 parent 90b9ac2 commit 4c6415a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Threading.Tasks;
using GlazeWM.Domain.UserConfigs.Commands;
using GlazeWM.Domain.Windows;
using GlazeWM.Infrastructure.Bussing;
Expand Down Expand Up @@ -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));
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions GlazeWM.Domain/Windows/EventHandlers/WindowFocusedHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4c6415a

Please sign in to comment.