Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

fix: disable focus follows cursor while right clicking (#365)

blam9e7bf7fb31c6
diff --git a/GlazeWM.App.WindowManager/WmStartup.cs b/GlazeWM.App.WindowManager/WmStartup.cs
index a3afc16e..d1b1b311 100644
--- a/GlazeWM.App.WindowManager/WmStartup.cs
+++ b/GlazeWM.App.WindowManager/WmStartup.cs
@@ -80,7 +80,7 @@ namespace GlazeWM.App.WindowManager
if (_userConfigService.GeneralConfig.FocusFollowsCursor)
MouseEvents.MouseMoves.Sample(TimeSpan.FromMilliseconds(50)).Subscribe((@event) =>
{
_bus.InvokeAsync(new FocusContainerUnderCursorCommand(@event.Point));
});
diff --git a/GlazeWM.Infrastructure/WindowsApi/MouseEvents.cs b/GlazeWM.Infrastructure/WindowsApi/MouseEvents.cs
index 481d378f..202b3009 100644
--- a/GlazeWM.Infrastructure/WindowsApi/MouseEvents.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/MouseEvents.cs
@@ -16,7 +16,8 @@ namespace GlazeWM.Infrastructure.WindowsApi
{
var mouseEvents = new Subject<MouseMoveEvent>();
- var isMouseDown = false;
+ var isRMouseDown = false;
+ var isLMouseDown = false;
var hookProc = new HookProc((nCode, wParam, lParam) =>
{
var details = (LowLevelMouseInputEventDetails)Marshal.PtrToStructure(
@@ -27,16 +28,21 @@ namespace GlazeWM.Infrastructure.WindowsApi
// Check if mouse click is being held.
switch ((WMessages)wParam)
{
+ case WMessages.WM_RBUTTONUP:
+ isRMouseDown = false;
+ break;
+ case WMessages.WM_RBUTTONDOWN:
+ isRMouseDown = true;
+ break;
case WMessages.WM_LBUTTONUP:
- isMouseDown = false;
+ isLMouseDown = false;
break;
case WMessages.WM_LBUTTONDOWN:
- isMouseDown = true;
+ isLMouseDown = true;
break;
}
- var filteredEvent = new MouseMoveEvent(details.pt, isMouseDown, details.TimeStamp);
-
+ var filteredEvent = new MouseMoveEvent(details.pt, isRMouseDown, isLMouseDown, details.TimeStamp);
mouseEvents.OnNext(filteredEvent);
return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
diff --git a/GlazeWM.Infrastructure/WindowsApi/MouseMoveEvent.cs b/GlazeWM.Infrastructure/WindowsApi/MouseMoveEvent.cs
index 81b331f8..1aa0d0a2 100644
--- a/GlazeWM.Infrastructure/WindowsApi/MouseMoveEvent.cs
+++ b/GlazeWM.Infrastructure/WindowsApi/MouseMoveEvent.cs
@@ -13,7 +13,12 @@ public record MouseMoveEvent(
/// <summary>
/// Whether left-click is currently pressed.
/// </summary>
- bool IsMouseDown,
+ bool IsLMouseDown,
+
+ /// <summary>
+ /// Whether right-click is currently pressed.
+ /// </summary>
+ bool IsRMouseDown,
/// <summary>
/// The time stamp for this message, equivalent to what `GetMessageTime` would