Skip to content

Commit

Permalink
ReVOSD 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
qt-kaneko committed May 3, 2024
1 parent 4b0cf81 commit 5be979f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
1 change: 0 additions & 1 deletion ReVOSD/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ SendMessage
FindWindow

GetWindowRgnBox
GetDpiForWindow
CreateRectRgn
SetWindowRgn

Expand Down
10 changes: 1 addition & 9 deletions ReVOSD/src/MediaOsd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using static Windows.Win32.PInvoke;
using static Windows.Win32.System.SystemServices.APPCOMMAND_ID;

namespace ReMOSD;
namespace ReVOSD;

class MediaOsd
{
Expand All @@ -27,14 +27,6 @@ public void SetRegion(HRGN value)
if (result == 0) throw new Win32Exception(Marshal.GetLastWin32Error());
}

public uint GetDpi()
{
var dpi = GetDpiForWindow(HWnd);
if (dpi == 0) throw new Win32Exception(Marshal.GetLastWin32Error());

return dpi;
}

public static MediaOsd Find()
{
var shellHWnd = GetShellWindow();
Expand Down
9 changes: 3 additions & 6 deletions ReVOSD/src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using static Windows.Win32.Graphics.Gdi.GDI_REGION_TYPE;
using static Windows.Win32.PInvoke;

using ReMOSD;
using ReVOSD;

AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

Expand All @@ -19,11 +19,8 @@
// (see https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowrgn)
if (osdRegion == RGN_ERROR) // Unchanged
{
var osdScalingCoefficient = osd.GetDpi() / 96.0f;

newOsdRegion = CreateRectRgn(0, 0,
(int)Math.Round(65 * osdScalingCoefficient),
(int)Math.Round(140 * osdScalingCoefficient));
0, 0);
if (newOsdRegion == default) throw new Win32Exception(Marshal.GetLastWin32Error());
}
else // Reset
Expand All @@ -38,7 +35,7 @@ static void OnUnhandledException(object s, UnhandledExceptionEventArgs e)
var exception = e.ExceptionObject as Exception;

AllocConsole();
Console.Title = "ReMOSD";
Console.Title = "ReVOSD";

Console.WriteLine(exception);
Console.WriteLine();
Expand Down

0 comments on commit 5be979f

Please sign in to comment.