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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 schoenebeck 2474 /*
2 schoenebeck 3068 Copyright (c) 2013 - 2017 Christian Schoenebeck
3 schoenebeck 2474
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 schoenebeck 3068 #if __clang__
13     # define HAS_OBJC_ARC __has_feature(objc_arc)
14     #else
15     # define HAS_OBJC_ARC 0
16     #endif
17    
18 schoenebeck 2474 @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 schoenebeck 3068 #if !HAS_OBJC_ARC
53 schoenebeck 2474 [obj release];
54 schoenebeck 3068 #endif
55 schoenebeck 2474 }
56    
57 schoenebeck 3258 void macRaiseAppWindow() {
58     [NSApp activateIgnoringOtherApps:YES];
59     }
60    
61 schoenebeck 3315 #ifndef NSAppKitVersionNumber10_6
62     # define NSAppKitVersionNumber10_6 1038
63     #endif
64    
65 schoenebeck 3314 bool macIsMinMac10_6() {
66     return NSAppKitVersionNumber >= NSAppKitVersionNumber10_6;
67     }
68    
69 schoenebeck 2474 #if defined(__cplusplus)
70     }
71     #endif // __cplusplus

  ViewVC Help
Powered by ViewVC