dsound: Avoid signed-unsigned integer comparisons.
[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             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];
63
64             [self setMainMenu:mainMenu];
65             [self setWindowsMenu:submenu];
66         }
67     }
68
69 @end
70
71 /***********************************************************************
72  *              OnMainThread
73  *
74  * Run a block on the main thread synchronously.
75  */
76 void OnMainThread(dispatch_block_t block)
77 {
78     dispatch_sync(dispatch_get_main_queue(), block);
79 }
80
81 /***********************************************************************
82  *              OnMainThreadAsync
83  *
84  * Run a block on the main thread asynchronously.
85  */
86 void OnMainThreadAsync(dispatch_block_t block)
87 {
88     dispatch_async(dispatch_get_main_queue(), block);
89 }