Skip to content

Commit

Permalink
Merge pull request #24 from mikeclayton/feature/box-layout
Browse files Browse the repository at this point in the history
#19 - configurable borders
  • Loading branch information
mikeclayton authored Jul 18, 2023
2 parents 275f4b9 + ae09721 commit 015a37c
Show file tree
Hide file tree
Showing 97 changed files with 3,361 additions and 875 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ obj

releases

*.csproj.user
*.user

wiki/anim
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ I'll continue to maintain the FancyMouse repo as an incubator for new features g

FancyMouse is a Windows utility for quickly moving the mouse large distances on high-res desktops.

See links for additional details:

* [Basic Configuration](./wiki/config/basic_config.md)
* [Advancedc Configuration](./wiki/config/advanced_config.md)

---

## The Problem

On a modern laptop that uses an Ultra-Wide external monitor you could easily have a desktop in the region of 8000+ pixels wide, and that's a lot of ground for your mouse to cover.
Expand All @@ -21,6 +28,8 @@ What tends to happen is you end up swiping the physical mouse as far as it will

FancyMouse helps by letting you click a scaled-down preview of your entire desktop and "teleport" the mouse there in an instant.

---

## Swiping

Here's an animation showing the old slow way of swiping the mouse multiple times.
Expand All @@ -29,6 +38,8 @@ Imagine you're happily working on a spreadsheet on your ultra-wide external moni

![Animation of swiping a mouse multiple times to move across a large monitor setup](wiki/images/swipe.gif)

---

## FancyMouse

And here's the same thing using FancyMouse. A hotkey or spare mouse button can be configured to activate the FancyMouse popup, and the pointer only needs to be moved a tiny amount on the preview thumbnail. A single mouse click then teleports the pointer to that location on the full-size desktop.
Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/ATOM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public ATOM(ushort value)

public static implicit operator ushort(ATOM value) => value.Value;

public static implicit operator ATOM(ushort value) => new(value);
public static explicit operator ATOM(ushort value) => new(value);

public override string ToString()
{
Expand Down
53 changes: 53 additions & 0 deletions src/FancyMouse.NativeMethods/Core/GUID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace FancyMouse.NativeMethods;

internal static partial class Core
{
/// <summary>
/// A 32-bit signed integer.The range is -2147483648 through 2147483647 decimal.
/// This type is declared in WinNT.h as follows:
/// typedef long LONG;
/// </summary>
/// <remarks>
/// See https://learn.microsoft.com/en-us/windows/win32/api/guiddef/ns-guiddef-guid
/// </remarks>
internal readonly struct GUID
{
public readonly ulong Data1;
public readonly short Data2;
public readonly short Data3;
public readonly char[] Data4;

public GUID(Guid value)
{
this.Data1 = 0;
this.Data2 = 0;
this.Data3 = 0;
this.Data4 = new[] { (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0 };
}

public GUID(ulong data1, short data2, short data3, char[] data4)
{
this.Data1 = data1;
this.Data2 = data2;
this.Data3 = data3;
this.Data4 = data4;
}

public static implicit operator Guid(GUID value) => Guid.NewGuid();

public static implicit operator GUID(Guid value) => new(
data1: 0,
data2: 0,
data3: 0,
data4: new[] { (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0, (char)0 });

public override string ToString()
{
return $"{this.GetType().Name}";
}
}
}
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/HANDLE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HANDLE(IntPtr value)

public static implicit operator IntPtr(HANDLE value) => value.Value;

public static implicit operator HANDLE(IntPtr value) => new(value);
public static explicit operator HANDLE(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
39 changes: 39 additions & 0 deletions src/FancyMouse.NativeMethods/Core/HBITMAP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace FancyMouse.NativeMethods;

internal static partial class Core
{
/// <summary>
/// A handle to a bitmap.
/// This type is declared in WinDef.h as follows:
/// typedef HANDLE HBITMAP;
/// </summary>
/// <remarks>
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
/// </remarks>
internal readonly struct HBITMAP
{
public static readonly HBITMAP Null = new(IntPtr.Zero);

public readonly IntPtr Value;

public HBITMAP(IntPtr value)
{
this.Value = value;
}

public bool IsNull => this.Value == HBITMAP.Null.Value;

public static implicit operator IntPtr(HBITMAP value) => value.Value;

public static explicit operator HBITMAP(IntPtr value) => new(value);

public static explicit operator HBITMAP(HGDIOBJ value) => new(value.Value);

public static implicit operator HGDIOBJ(HBITMAP value) => new(value.Value);

public override string ToString()
{
return $"{this.GetType().Name}({this.Value})";
}
}
}
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/HBRUSH.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HBRUSH(IntPtr value)

public static implicit operator IntPtr(HBRUSH value) => value.Value;

public static implicit operator HBRUSH(IntPtr value) => new(value);
public static explicit operator HBRUSH(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 4 additions & 0 deletions src/FancyMouse.NativeMethods/Core/HDC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public HDC(IntPtr value)

public bool IsNull => this.Value == HDC.Null.Value;

public static implicit operator IntPtr(HDC value) => value.Value;

public static explicit operator HDC(IntPtr value) => new(value);

public override string ToString()
{
return $"{this.GetType().Name}({this.Value})";
Expand Down
4 changes: 2 additions & 2 deletions src/FancyMouse.NativeMethods/Core/HDESK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public HDESK(IntPtr value)

public static implicit operator IntPtr(HDESK value) => value.Value;

public static implicit operator HDESK(IntPtr value) => new(value);
public static explicit operator HDESK(IntPtr value) => new(value);

public static implicit operator HANDLE(HDESK value) => new(value.Value);

public static implicit operator HDESK(HANDLE value) => new(value.Value);
public static explicit operator HDESK(HANDLE value) => new(value.Value);

public override string ToString()
{
Expand Down
35 changes: 35 additions & 0 deletions src/FancyMouse.NativeMethods/Core/HGDIOBJ.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace FancyMouse.NativeMethods;

internal static partial class Core
{
/// <summary>
/// A handle to a GDI object.
/// This type is declared in WinDef.h as follows:
/// typedef HANDLE HGDIOBJ;
/// </summary>
/// <remarks>
/// See https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
/// </remarks>
internal readonly struct HGDIOBJ
{
public static readonly HGDIOBJ Null = new(IntPtr.Zero);

public readonly IntPtr Value;

public HGDIOBJ(IntPtr value)
{
this.Value = value;
}

public bool IsNull => this.Value == HGDIOBJ.Null.Value;

public static implicit operator IntPtr(HGDIOBJ value) => value.Value;

public static explicit operator HGDIOBJ(IntPtr value) => new(value);

public override string ToString()
{
return $"{this.GetType().Name}({this.Value})";
}
}
}
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/HINSTANCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public HINSTANCE(IntPtr value)

public static implicit operator IntPtr(HINSTANCE value) => value.Value;

public static implicit operator HINSTANCE(IntPtr value) => new(value);
public static explicit operator HINSTANCE(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/HMODULE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public HMODULE(IntPtr value)

public static implicit operator IntPtr(HMODULE value) => value.Value;

public static implicit operator HMODULE(IntPtr value) => new(value);
public static explicit operator HMODULE(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
6 changes: 3 additions & 3 deletions src/FancyMouse.NativeMethods/Core/HMONITOR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public HMONITOR(IntPtr value)

public static implicit operator int(HMONITOR value) => value.Value.ToInt32();

public static implicit operator HMONITOR(int value) => new(value);
public static explicit operator HMONITOR(int value) => new(value);

public static implicit operator IntPtr(HMONITOR value) => value.Value;

public static implicit operator HMONITOR(IntPtr value) => new(value);
public static explicit operator HMONITOR(IntPtr value) => new(value);

public static implicit operator HANDLE(HMONITOR value) => new(value.Value);

public static implicit operator HMONITOR(HANDLE value) => new(value.Value);
public static explicit operator HMONITOR(HANDLE value) => new(value.Value);

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/HWINSTA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HWINSTA(IntPtr value)

public static implicit operator IntPtr(HWINSTA value) => value.Value;

public static implicit operator HWINSTA(IntPtr value) => new(value);
public static explicit operator HWINSTA(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPARAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public LPARAM(IntPtr value)
this.Value = value;
}

public bool IsNull => this.Value == LPARAM.Null.Value;

public static implicit operator IntPtr(LPARAM value) => value.Value;

public static implicit operator LPARAM(IntPtr value) => new(value);
public static explicit operator LPARAM(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPCRECT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public LPCRECT(CRECT value)
this.Value = LPCRECT.ToPtr(value);
}

public bool IsNull => this.Value == LPCRECT.Null.Value;

private static IntPtr ToPtr(CRECT value)
{
var ptr = Marshal.AllocHGlobal(CRECT.Size);
Expand All @@ -34,7 +36,7 @@ public void Free()

public static implicit operator IntPtr(LPCRECT value) => value.Value;

public static implicit operator LPCRECT(IntPtr value) => new(value);
public static explicit operator LPCRECT(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/LPCWSTR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public LPCWSTR(string value)

public static implicit operator IntPtr(LPCWSTR value) => value.Value;

public static implicit operator LPCWSTR(IntPtr value) => new(value);
public static explicit operator LPCWSTR(IntPtr value) => new(value);

public static implicit operator string?(LPCWSTR value) => Marshal.PtrToStringUni(value.Value);

Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPDWORD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public LPDWORD(DWORD value)
this.Value = LPDWORD.ToPtr(value);
}

public bool IsNull => this.Value == LPDWORD.Null.Value;

private static IntPtr ToPtr(DWORD value)
{
var ptr = Marshal.AllocHGlobal(DWORD.Size);
Expand All @@ -42,7 +44,7 @@ public void Free()

public static implicit operator IntPtr(LPDWORD value) => value.Value;

public static implicit operator LPDWORD(IntPtr value) => new(value);
public static explicit operator LPDWORD(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPPOINT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public LPPOINT(POINT value)
this.Value = LPPOINT.ToPtr(value);
}

public bool IsNull => this.Value == LPPOINT.Null.Value;

private static IntPtr ToPtr(POINT value)
{
var ptr = Marshal.AllocHGlobal(POINT.Size);
Expand All @@ -39,7 +41,7 @@ public void Free()

public static implicit operator IntPtr(LPPOINT value) => value.Value;

public static implicit operator LPPOINT(IntPtr value) => new(value);
public static explicit operator LPPOINT(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPRECT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public LPRECT(RECT value)
this.Value = LPRECT.ToPtr(value);
}

public bool IsNull => this.Value == LPRECT.Null.Value;

private static IntPtr ToPtr(RECT value)
{
var ptr = Marshal.AllocHGlobal(RECT.Size);
Expand All @@ -34,7 +36,7 @@ public void Free()

public static implicit operator IntPtr(LPRECT value) => value.Value;

public static implicit operator LPRECT(IntPtr value) => new(value);
public static explicit operator LPRECT(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
4 changes: 3 additions & 1 deletion src/FancyMouse.NativeMethods/Core/LPTSTR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public LPTSTR(string value)
this.Value = Marshal.StringToHGlobalAuto(value);
}

public bool IsNull => this.Value == LPTSTR.Null.Value;

public static implicit operator IntPtr(LPTSTR value) => value.Value;

public static implicit operator LPTSTR(IntPtr value) => new(value);
public static explicit operator LPTSTR(IntPtr value) => new(value);

public static implicit operator string?(LPTSTR value) => Marshal.PtrToStringUni(value.Value);

Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/LPVOID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public LPVOID(IntPtr value)

public static implicit operator IntPtr(LPVOID value) => value.Value;

public static implicit operator LPVOID(IntPtr value) => new(value);
public static explicit operator LPVOID(IntPtr value) => new(value);

public static LPVOID Allocate(int length)
{
Expand Down
2 changes: 1 addition & 1 deletion src/FancyMouse.NativeMethods/Core/LRESULT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LRESULT(IntPtr value)

public static implicit operator IntPtr(LRESULT value) => value.Value;

public static implicit operator LRESULT(IntPtr value) => new(value);
public static explicit operator LRESULT(IntPtr value) => new(value);

public override string ToString()
{
Expand Down
Loading

0 comments on commit 015a37c

Please sign in to comment.