-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bug/null-ref-exception-fix' into feat/window-focus-foll…
…ows-cursor
- Loading branch information
blam
committed
Jan 18, 2023
1 parent
13df734
commit 1903acf
Showing
7 changed files
with
51 additions
and
47 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
GlazeWM.Domain/Containers/CommandHandlers/CenterCursorOnContainerHandler.cs
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
GlazeWM.Domain/Containers/CommandHandlers/CenterCursorOnRectHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using GlazeWM.Domain.Containers.Commands; | ||
using GlazeWM.Domain.UserConfigs; | ||
|
||
using GlazeWM.Infrastructure.Bussing; | ||
using GlazeWM.Infrastructure.WindowsApi; | ||
using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService; | ||
|
||
namespace GlazeWM.Domain.Containers.CommandHandlers | ||
{ | ||
internal class CenterCursorOnRectHandler : ICommandHandler<CenterCursorOnRectCommand> | ||
{ | ||
private readonly UserConfigService _userConfigService; | ||
|
||
public CenterCursorOnRectHandler(UserConfigService userConfigService) | ||
{ | ||
_userConfigService = userConfigService; | ||
} | ||
|
||
public CommandResponse Handle(CenterCursorOnRectCommand command) | ||
{ | ||
var enabled = _userConfigService.GeneralConfig.CursorFollowsFocus; | ||
if (!enabled) | ||
return CommandResponse.Ok; | ||
|
||
Rect TargetRect = command.TargetRect; | ||
|
||
// Calculate center point of focused window | ||
var centerX = TargetRect.X + (TargetRect.Width / 2); | ||
var centerY = TargetRect.Y + (TargetRect.Height / 2); | ||
SetCursorPos(centerX, centerY); | ||
return CommandResponse.Ok; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
...ommands/CenterCursorOnContainerCommand.cs → ...ers/Commands/CenterCursorOnRectCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
using GlazeWM.Infrastructure.Bussing; | ||
using GlazeWM.Infrastructure.WindowsApi; | ||
|
||
namespace GlazeWM.Domain.Containers.Commands | ||
{ | ||
public class CenterCursorOnContainerCommand : Command | ||
public class CenterCursorOnRectCommand : Command | ||
{ | ||
public Container TargetContainer { get; } | ||
public Rect TargetRect { get; } | ||
|
||
/// <summary> | ||
/// Center cursor in the middle of target container | ||
/// </summary> | ||
public CenterCursorOnContainerCommand(Container target) | ||
public CenterCursorOnRectCommand(Rect target) | ||
{ | ||
TargetContainer = target; | ||
TargetRect = target; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters