mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 03:56:48 +00:00
[Mac] Disable momentum scrolling and key pop-ups
We might wish to add an option to re-enable momentum scrolling, as this might be useful to some applications for a more native feel.
This commit is contained in:
parent
15f5abe1e1
commit
9dab96c5c1
|
@ -35,6 +35,11 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
static class Class
|
||||
{
|
||||
public static readonly IntPtr NSAutoreleasePool = Get("NSAutoreleasePool");
|
||||
public static readonly IntPtr NSDictionary = Get("NSDictionary");
|
||||
public static readonly IntPtr NSNumber = Get("NSNumber");
|
||||
public static readonly IntPtr NSUserDefaults = Get("NSUserDefaults");
|
||||
|
||||
[DllImport (Cocoa.LibObjC)]
|
||||
extern static IntPtr class_getName(IntPtr handle);
|
||||
|
||||
|
|
|
@ -57,9 +57,15 @@ namespace OpenTK.Platform.MacOS
|
|||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, IntPtr intPtr1, IntPtr intPtr2, IntPtr intPtr3);
|
||||
|
||||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, IntPtr intPtr1, IntPtr intPtr2, IntPtr intPtr3, IntPtr intPtr4, IntPtr intPtr5);
|
||||
|
||||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, IntPtr p1, PointF p2);
|
||||
|
||||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, bool p1);
|
||||
|
||||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, SizeF p1);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace OpenTK.Platform.MacOS
|
|||
internal static void Initialize()
|
||||
{
|
||||
// Create the NSAutoreleasePool
|
||||
AutoreleasePool = Cocoa.SendIntPtr(Cocoa.SendIntPtr(Class.Get("NSAutoreleasePool"), Selector.Alloc), Selector.Init);
|
||||
AutoreleasePool = Cocoa.SendIntPtr(Cocoa.SendIntPtr(Class.NSAutoreleasePool, Selector.Alloc), Selector.Init);
|
||||
|
||||
// Register a Quit method to be called on cmd-q
|
||||
IntPtr nsapp = Class.Get("NSApplication");
|
||||
|
@ -80,6 +80,23 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
// Tell cocoa we're ready to run the application (usually called by [NSApp run]).
|
||||
Cocoa.SendVoid(Handle, Selector.Get("finishLaunching"));
|
||||
|
||||
// Disable momentum scrolling and long-press key pop-ups
|
||||
IntPtr settings = Cocoa.SendIntPtr(Class.NSDictionary, Selector.Alloc);
|
||||
IntPtr momentum_scrolling = Cocoa.SendIntPtr(Class.NSNumber, Selector.Get("numberWithBool:"), false);
|
||||
IntPtr press_and_hold = Cocoa.SendIntPtr(Class.NSNumber, Selector.Get("numberWithBool:"), false);
|
||||
|
||||
// Initialize and register the settings dictionary
|
||||
settings =
|
||||
Cocoa.SendIntPtr(settings, Selector.Get("initWithObjectsAndKeys:"),
|
||||
momentum_scrolling, Cocoa.ToNSString("AppleMomentumScrollSupported"),
|
||||
press_and_hold, Cocoa.ToNSString("ApplePressAndHoldEnabled"),
|
||||
IntPtr.Zero);
|
||||
Cocoa.SendVoid(
|
||||
Cocoa.SendIntPtr(Class.NSUserDefaults, Selector.Get("standardUserDefaults")),
|
||||
Selector.Get("registerDefaults:"),
|
||||
settings);
|
||||
Cocoa.SendVoid(settings, Selector.Release);
|
||||
}
|
||||
|
||||
internal static event EventHandler<CancelEventArgs> Quit = delegate { };
|
||||
|
|
Loading…
Reference in a new issue