mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-24 14:06:59 +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
|
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)]
|
[DllImport (Cocoa.LibObjC)]
|
||||||
extern static IntPtr class_getName(IntPtr handle);
|
extern static IntPtr class_getName(IntPtr handle);
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,15 @@ namespace OpenTK.Platform.MacOS
|
||||||
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, IntPtr intPtr1, IntPtr intPtr2, IntPtr intPtr3);
|
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")]
|
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, IntPtr p1, PointF p2);
|
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")]
|
[DllImport(LibObjC, EntryPoint="objc_msgSend")]
|
||||||
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, SizeF p1);
|
public extern static IntPtr SendIntPtr(IntPtr receiver, IntPtr selector, SizeF p1);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
internal static void Initialize()
|
internal static void Initialize()
|
||||||
{
|
{
|
||||||
// Create the NSAutoreleasePool
|
// 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
|
// Register a Quit method to be called on cmd-q
|
||||||
IntPtr nsapp = Class.Get("NSApplication");
|
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]).
|
// Tell cocoa we're ready to run the application (usually called by [NSApp run]).
|
||||||
Cocoa.SendVoid(Handle, Selector.Get("finishLaunching"));
|
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 { };
|
internal static event EventHandler<CancelEventArgs> Quit = delegate { };
|
||||||
|
|
Loading…
Reference in a new issue