mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-22 17:37:12 +02:00
misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.
This commit is contained in:
parent
a09d314817
commit
dfb4854d19
172 changed files with 902 additions and 914 deletions
|
@ -14,19 +14,19 @@ namespace Ryujinx.Common.SystemInterop
|
|||
private const string X11LibraryName = "libX11.so.6";
|
||||
|
||||
[LibraryImport(X11LibraryName)]
|
||||
private static partial IntPtr XOpenDisplay([MarshalAs(UnmanagedType.LPStr)] string display);
|
||||
private static partial nint XOpenDisplay([MarshalAs(UnmanagedType.LPStr)] string display);
|
||||
|
||||
[LibraryImport(X11LibraryName)]
|
||||
private static partial IntPtr XGetDefault(IntPtr display, [MarshalAs(UnmanagedType.LPStr)] string program, [MarshalAs(UnmanagedType.LPStr)] string option);
|
||||
private static partial nint XGetDefault(nint display, [MarshalAs(UnmanagedType.LPStr)] string program, [MarshalAs(UnmanagedType.LPStr)] string option);
|
||||
|
||||
[LibraryImport(X11LibraryName)]
|
||||
private static partial int XDisplayWidth(IntPtr display, int screenNumber);
|
||||
private static partial int XDisplayWidth(nint display, int screenNumber);
|
||||
|
||||
[LibraryImport(X11LibraryName)]
|
||||
private static partial int XDisplayWidthMM(IntPtr display, int screenNumber);
|
||||
private static partial int XDisplayWidthMM(nint display, int screenNumber);
|
||||
|
||||
[LibraryImport(X11LibraryName)]
|
||||
private static partial int XCloseDisplay(IntPtr display);
|
||||
private static partial int XCloseDisplay(nint display);
|
||||
|
||||
private const double StandardDpiScale = 96.0;
|
||||
private const double MaxScaleFactor = 1.25;
|
||||
|
@ -51,7 +51,7 @@ namespace Ryujinx.Common.SystemInterop
|
|||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
{
|
||||
userDpiScale = GdiPlusHelper.GetDpiX(IntPtr.Zero);
|
||||
userDpiScale = GdiPlusHelper.GetDpiX(nint.Zero);
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ namespace Ryujinx.Common.SystemInterop
|
|||
|
||||
if (xdgSessionType == null || xdgSessionType == "x11")
|
||||
{
|
||||
IntPtr display = XOpenDisplay(null);
|
||||
nint display = XOpenDisplay(null);
|
||||
string dpiString = Marshal.PtrToStringAnsi(XGetDefault(display, "Xft", "dpi"));
|
||||
if (dpiString == null || !double.TryParse(dpiString, NumberStyles.Any, CultureInfo.InvariantCulture, out userDpiScale))
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Ryujinx.Common.SystemInterop
|
|||
{
|
||||
private const string LibraryName = "gdiplus.dll";
|
||||
|
||||
private static readonly IntPtr _initToken;
|
||||
private static readonly nint _initToken;
|
||||
|
||||
static GdiPlusHelper()
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ namespace Ryujinx.Common.SystemInterop
|
|||
public int GdiplusVersion;
|
||||
|
||||
#pragma warning disable CS0649 // Field is never assigned to
|
||||
public IntPtr DebugEventCallback;
|
||||
public nint DebugEventCallback;
|
||||
public int SuppressBackgroundThread;
|
||||
public int SuppressExternalCodecs;
|
||||
public int StartupParameters;
|
||||
|
@ -39,7 +39,7 @@ namespace Ryujinx.Common.SystemInterop
|
|||
{
|
||||
// We assume Windows 8 and upper
|
||||
GdiplusVersion = 2,
|
||||
DebugEventCallback = IntPtr.Zero,
|
||||
DebugEventCallback = nint.Zero,
|
||||
SuppressBackgroundThread = 0,
|
||||
SuppressExternalCodecs = 0,
|
||||
StartupParameters = 0,
|
||||
|
@ -48,25 +48,25 @@ namespace Ryujinx.Common.SystemInterop
|
|||
|
||||
private struct StartupOutput
|
||||
{
|
||||
public IntPtr NotificationHook;
|
||||
public IntPtr NotificationUnhook;
|
||||
public nint NotificationHook;
|
||||
public nint NotificationUnhook;
|
||||
}
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
private static partial int GdiplusStartup(out IntPtr token, in StartupInputEx input, out StartupOutput output);
|
||||
private static partial int GdiplusStartup(out nint token, in StartupInputEx input, out StartupOutput output);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
private static partial int GdipCreateFromHWND(IntPtr hwnd, out IntPtr graphics);
|
||||
private static partial int GdipCreateFromHWND(nint hwnd, out nint graphics);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
private static partial int GdipDeleteGraphics(IntPtr graphics);
|
||||
private static partial int GdipDeleteGraphics(nint graphics);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
private static partial int GdipGetDpiX(IntPtr graphics, out float dpi);
|
||||
private static partial int GdipGetDpiX(nint graphics, out float dpi);
|
||||
|
||||
public static float GetDpiX(IntPtr hwnd)
|
||||
public static float GetDpiX(nint hwnd)
|
||||
{
|
||||
CheckStatus(GdipCreateFromHWND(hwnd, out IntPtr graphicsHandle));
|
||||
CheckStatus(GdipCreateFromHWND(hwnd, out nint graphicsHandle));
|
||||
CheckStatus(GdipGetDpiX(graphicsHandle, out float result));
|
||||
CheckStatus(GdipDeleteGraphics(graphicsHandle));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue