mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 22:36:59 +00:00
Merge branch 'ava/retina-scaling' into 'master'
Avalonia: fix HiDPI/Retina scaling for embedded window on macOS. See merge request [ryubing/ryujinx!210](https://git.ryujinx.app/ryubing/ryujinx/-/merge_requests/210)
This commit is contained in:
commit
452ed9899a
2 changed files with 15 additions and 2 deletions
|
|
@ -42,6 +42,9 @@ namespace Ryujinx.Common.Helper
|
|||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static partial bool bool_objc_msgSend(nint receiver, Selector selector, nint param);
|
||||
|
||||
[LibraryImport(ObjCRuntime, EntryPoint = "objc_msgSend")]
|
||||
private static partial double double_objc_msgSend(nint receiver, Selector selector);
|
||||
|
||||
public readonly struct Object
|
||||
{
|
||||
public readonly nint ObjPtr;
|
||||
|
|
@ -105,6 +108,11 @@ namespace Ryujinx.Common.Helper
|
|||
{
|
||||
return bool_objc_msgSend(ObjPtr, selector, obj.ObjPtr);
|
||||
}
|
||||
|
||||
public double GetDoubleFromMessage(string selectorName)
|
||||
{
|
||||
return double_objc_msgSend(ObjPtr, selectorName);
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct Selector
|
||||
|
|
|
|||
|
|
@ -186,12 +186,17 @@ namespace Ryujinx.Ava.UI.Renderer
|
|||
// Make its renderer our metal layer.
|
||||
child.SendMessage("setWantsLayer:", 1);
|
||||
child.SendMessage("setLayer:", metalLayer);
|
||||
metalLayer.SendMessage("setContentsScale:", Program.DesktopScaleFactor);
|
||||
|
||||
double initialScaleFactor = child.GetDoubleFromMessage("backingScaleFactor");
|
||||
|
||||
metalLayer.SendMessage("setContentsScale:", initialScaleFactor);
|
||||
|
||||
// Ensure the scale factor is up to date.
|
||||
_updateBoundsCallback = rect =>
|
||||
{
|
||||
metalLayer.SendMessage("setContentsScale:", Program.DesktopScaleFactor);
|
||||
double currentScaleFactor = child.GetDoubleFromMessage("backingScaleFactor");
|
||||
|
||||
metalLayer.SendMessage("setContentsScale:", currentScaleFactor);
|
||||
};
|
||||
|
||||
nint nsView = child.ObjPtr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue