2 * MACDRV Cocoa application class
4 * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 @implementation WineApplication
26 - (void) transformProcessToForeground
28 if ([self activationPolicy] != NSApplicationActivationPolicyRegular)
36 [self setActivationPolicy:NSApplicationActivationPolicyRegular];
37 [self activateIgnoringOtherApps:YES];
39 mainMenu = [[[NSMenu alloc] init] autorelease];
41 submenu = [[[NSMenu alloc] initWithTitle:@"Wine"] autorelease];
42 bundleName = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
43 if ([bundleName length])
44 title = [NSString stringWithFormat:@"Quit %@", bundleName];
47 item = [submenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
48 [item setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
49 item = [[[NSMenuItem alloc] init] autorelease];
50 [item setTitle:@"Wine"];
51 [item setSubmenu:submenu];
52 [mainMenu addItem:item];
54 [self setMainMenu:mainMenu];
60 /***********************************************************************
63 * Run a block on the main thread synchronously.
65 void OnMainThread(dispatch_block_t block)
67 dispatch_sync(dispatch_get_main_queue(), block);
70 /***********************************************************************
73 * Run a block on the main thread asynchronously.
75 void OnMainThreadAsync(dispatch_block_t block)
77 dispatch_async(dispatch_get_main_queue(), block);