Ken Thomases : winemac: Add a custom NSApplication subclass, WineApplication.

Alexandre Julliard julliard at winehq.org
Wed Jan 9 13:30:38 CST 2013


Module: wine
Branch: master
Commit: daf0fd75e638729240f874a39ed7a28830ff02ec
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=daf0fd75e638729240f874a39ed7a28830ff02ec

Author: Ken Thomases <ken at codeweavers.com>
Date:   Mon Jan  7 14:44:31 2013 -0600

winemac: Add a custom NSApplication subclass, WineApplication.

---

 dlls/winemac.drv/Makefile.in |    1 +
 dlls/winemac.drv/cocoa_app.h |   30 +++++++++++++++++++++
 dlls/winemac.drv/cocoa_app.m |   58 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/dlls/winemac.drv/Makefile.in b/dlls/winemac.drv/Makefile.in
index 2082b37..38d8f7e 100644
--- a/dlls/winemac.drv/Makefile.in
+++ b/dlls/winemac.drv/Makefile.in
@@ -9,6 +9,7 @@ C_SRCS = \
 	window.c
 
 OBJC_SRCS = \
+	cocoa_app.m \
 	cocoa_display.m
 
 @MAKE_DLL_RULES@
diff --git a/dlls/winemac.drv/cocoa_app.h b/dlls/winemac.drv/cocoa_app.h
new file mode 100644
index 0000000..cc3ede3
--- /dev/null
+++ b/dlls/winemac.drv/cocoa_app.h
@@ -0,0 +1,30 @@
+/*
+ * MACDRV Cocoa application class declaration
+ *
+ * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#import <AppKit/AppKit.h>
+
+#include "macdrv_cocoa.h"
+
+
+ at interface WineApplication : NSApplication <NSApplicationDelegate>
+
+    - (void) transformProcessToForeground;
+
+ at end
diff --git a/dlls/winemac.drv/cocoa_app.m b/dlls/winemac.drv/cocoa_app.m
new file mode 100644
index 0000000..ee7e2f8
--- /dev/null
+++ b/dlls/winemac.drv/cocoa_app.m
@@ -0,0 +1,58 @@
+/*
+ * MACDRV Cocoa application class
+ *
+ * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#import "cocoa_app.h"
+
+
+ at implementation WineApplication
+
+    - (void) transformProcessToForeground
+    {
+        if ([self activationPolicy] != NSApplicationActivationPolicyRegular)
+        {
+            NSMenu* mainMenu;
+            NSMenu* submenu;
+            NSString* bundleName;
+            NSString* title;
+            NSMenuItem* item;
+
+            [self setActivationPolicy:NSApplicationActivationPolicyRegular];
+            [self activateIgnoringOtherApps:YES];
+
+            mainMenu = [[[NSMenu alloc] init] autorelease];
+
+            submenu = [[[NSMenu alloc] initWithTitle:@"Wine"] autorelease];
+            bundleName = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
+            if ([bundleName length])
+                title = [NSString stringWithFormat:@"Quit %@", bundleName];
+            else
+                title = @"Quit";
+            item = [submenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
+            [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
+            item = [[[NSMenuItem alloc] init] autorelease];
+            [item setTitle:@"Wine"];
+            [item setSubmenu:submenu];
+            [mainMenu addItem:item];
+
+            [self setMainMenu:mainMenu];
+        }
+    }
+
+ at end




More information about the wine-cvs mailing list