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 submenu = [[[NSMenu alloc] initWithTitle:@"Window"] autorelease];
55 [submenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@""];
56 [submenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
57 [submenu addItem:[NSMenuItem separatorItem]];
58 [submenu addItemWithTitle:@"Bring All to Front" action:@selector(arrangeInFront:) keyEquivalent:@""];
59 item = [[[NSMenuItem alloc] init] autorelease];
60 [item setTitle:@"Window"];
61 [item setSubmenu:submenu];
62 [mainMenu addItem:item];
64 [self setMainMenu:mainMenu];
65 [self setWindowsMenu:submenu];
71 /***********************************************************************
74 * Run a block on the main thread synchronously.
76 void OnMainThread(dispatch_block_t block)
78 dispatch_sync(dispatch_get_main_queue(), block);
81 /***********************************************************************
84 * Run a block on the main thread asynchronously.
86 void OnMainThreadAsync(dispatch_block_t block)
88 dispatch_async(dispatch_get_main_queue(), block);