mirror of
				https://github.com/Ryujinx/Opentk.git
				synced 2025-11-04 02:04:49 +00:00 
			
		
		
		
	[Mac] Do not modify existing mainMenu
If an application already has a custom main menu, avoid overwriting that in OpenTK.
This commit is contained in:
		
							parent
							
								
									6bb7c1d406
								
							
						
					
					
						commit
						1080dec04d
					
				| 
						 | 
					@ -39,7 +39,6 @@ namespace OpenTK.Platform.MacOS
 | 
				
			||||||
    static class NSApplication
 | 
					    static class NSApplication
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        internal static IntPtr Handle;
 | 
					        internal static IntPtr Handle;
 | 
				
			||||||
        internal static IntPtr AutoreleasePool;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static readonly IntPtr selQuit = Selector.Get("quit");
 | 
					        static readonly IntPtr selQuit = Selector.Get("quit");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,9 +51,6 @@ namespace OpenTK.Platform.MacOS
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Cocoa.Initialize();
 | 
					            Cocoa.Initialize();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Create the NSAutoreleasePool
 | 
					 | 
				
			||||||
            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");
 | 
				
			||||||
            Class.RegisterMethod(nsapp, OnQuitHandler, "quit", "v@:");
 | 
					            Class.RegisterMethod(nsapp, OnQuitHandler, "quit", "v@:");
 | 
				
			||||||
| 
						 | 
					@ -66,6 +62,8 @@ namespace OpenTK.Platform.MacOS
 | 
				
			||||||
            Cocoa.SendBool(Handle, Selector.Get("setActivationPolicy:"), (int)NSApplicationActivationPolicy.Regular);
 | 
					            Cocoa.SendBool(Handle, Selector.Get("setActivationPolicy:"), (int)NSApplicationActivationPolicy.Regular);
 | 
				
			||||||
            Cocoa.SendVoid(Handle, Selector.Get("activateIgnoringOtherApps:"), true);
 | 
					            Cocoa.SendVoid(Handle, Selector.Get("activateIgnoringOtherApps:"), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (Cocoa.SendIntPtr(Handle, Selector.Get("mainMenu")) == IntPtr.Zero)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
                // Create the menu bar
 | 
					                // Create the menu bar
 | 
				
			||||||
                var menubar = Cocoa.SendIntPtr(Class.Get("NSMenu"), Selector.Alloc);
 | 
					                var menubar = Cocoa.SendIntPtr(Class.Get("NSMenu"), Selector.Alloc);
 | 
				
			||||||
                var menuItem = Cocoa.SendIntPtr(Class.Get("NSMenuItem"), Selector.Alloc);
 | 
					                var menuItem = Cocoa.SendIntPtr(Class.Get("NSMenuItem"), Selector.Alloc);
 | 
				
			||||||
| 
						 | 
					@ -81,6 +79,7 @@ namespace OpenTK.Platform.MacOS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Cocoa.SendIntPtr(appMenu, Selector.Get("addItem:"), quitMenuItem);
 | 
					                Cocoa.SendIntPtr(appMenu, Selector.Get("addItem:"), quitMenuItem);
 | 
				
			||||||
                Cocoa.SendIntPtr(menuItem, Selector.Get("setSubmenu:"), appMenu);
 | 
					                Cocoa.SendIntPtr(menuItem, Selector.Get("setSubmenu:"), appMenu);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 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"));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue