/[svn]/gigedit/trunk/src/gigedit/MacHelper.mm
ViewVC logotype

Contents of /gigedit/trunk/src/gigedit/MacHelper.mm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3315 - (show annotations) (download)
Wed Jul 19 12:25:47 2017 UTC (4 years, 3 months ago) by schoenebeck
File size: 1447 byte(s)
* Fixed compilation error on Mac.

1 /*
2 Copyright (c) 2013 - 2017 Christian Schoenebeck
3
4 This file is part of "gigedit" and released under the terms of the
5 GNU General Public License version 2.
6 */
7
8 #import "MacHelper.h"
9 #import <Cocoa/Cocoa.h>
10 #import <stdio.h>
11
12 #if __clang__
13 # define HAS_OBJC_ARC __has_feature(objc_arc)
14 #else
15 # define HAS_OBJC_ARC 0
16 #endif
17
18 @interface MacHelper : NSObject {
19 @public
20 void (*m_fn)(void* info);
21 void* m_info;
22 }
23 @end
24
25 @implementation MacHelper
26
27 - (id)init {
28 if ((self = [super init])) {
29 m_fn = nil;
30 m_info = nil;
31 }
32 return self;
33 }
34
35 - (void)runCFunc {
36 (*m_fn)(m_info);
37 }
38
39 @end
40
41 #if defined(__cplusplus)
42 extern "C" {
43 #endif // __cplusplus
44
45 void macHelperRunCFuncOnMainThread(void (*fn)(void* info), void* info) {
46 MacHelper* obj = [[MacHelper alloc] init];
47 obj->m_fn = fn;
48 obj->m_info = info;
49 printf("perfoming selector on main thread ...\n"); fflush(stdout);
50 [obj performSelectorOnMainThread:@selector(runCFunc) withObject:obj waitUntilDone:NO];
51 printf("Selector scheduled async. (on main thread).\n"); fflush(stdout);
52 #if !HAS_OBJC_ARC
53 [obj release];
54 #endif
55 }
56
57 void macRaiseAppWindow() {
58 [NSApp activateIgnoringOtherApps:YES];
59 }
60
61 #ifndef NSAppKitVersionNumber10_6
62 # define NSAppKitVersionNumber10_6 1038
63 #endif
64
65 bool macIsMinMac10_6() {
66 return NSAppKitVersionNumber >= NSAppKitVersionNumber10_6;
67 }
68
69 #if defined(__cplusplus)
70 }
71 #endif // __cplusplus

  ViewVC Help
Powered by ViewVC