d3dx9_36: Implement ID3DXFileEnumObjectImpl_GetChildren and ID3DXFileEnumObjectImpl_G...
[wine] / dlls / winemac.drv / cocoa_app.m
1 /*
2  * MACDRV Cocoa application class
3  *
4  * Copyright 2011, 2012, 2013 Ken Thomases for CodeWeavers Inc.
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #import "cocoa_app.h"
22
23
24 @implementation WineApplication
25
26     - (void) transformProcessToForeground
27     {
28         if ([self activationPolicy] != NSApplicationActivationPolicyRegular)
29         {
30             NSMenu* mainMenu;
31             NSMenu* submenu;
32             NSString* bundleName;
33             NSString* title;
34             NSMenuItem* item;
35
36             [self setActivationPolicy:NSApplicationActivationPolicyRegular];
37             [self activateIgnoringOtherApps:YES];
38
39             mainMenu = [[[NSMenu alloc] init] autorelease];
40
41             submenu = [[[NSMenu alloc] initWithTitle:@"Wine"] autorelease];
42             bundleName = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleNameKey];
43             if ([bundleName length])
44                 title = [NSString stringWithFormat:@"Quit %@", bundleName];
45             else
46                 title = @"Quit";
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];
53
54             [self setMainMenu:mainMenu];
55         }
56     }
57
58 @end
59
60 /***********************************************************************
61  *              OnMainThread
62  *
63  * Run a block on the main thread synchronously.
64  */
65 void OnMainThread(dispatch_block_t block)
66 {
67     dispatch_sync(dispatch_get_main_queue(), block);
68 }
69
70 /***********************************************************************
71  *              OnMainThreadAsync
72  *
73  * Run a block on the main thread asynchronously.
74  */
75 void OnMainThreadAsync(dispatch_block_t block)
76 {
77     dispatch_async(dispatch_get_main_queue(), block);
78 }