Mercurial > minori
comparison dep/animia/src/win/quartz.mm @ 156:cdf79282d647
dep/animia: add VERY early x11 window stuff
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 15 Nov 2023 18:04:04 -0500 |
parents | d2bbb5773616 |
children | 44c5e6dd9488 |
comparison
equal
deleted
inserted
replaced
155:d2bbb5773616 | 156:cdf79282d647 |
---|---|
9 | 9 |
10 template<typename T> | 10 template<typename T> |
11 static bool IntegerFromNSNumber(NSNumber* num, T& result) { | 11 static bool IntegerFromNSNumber(NSNumber* num, T& result) { |
12 if (!num) | 12 if (!num) |
13 return false; | 13 return false; |
14 | |
14 result = [num intValue]; | 15 result = [num intValue]; |
16 return true; | |
17 } | |
18 | |
19 static bool StringFromNSString(NSString* string, std::string& result) { | |
20 if (!string) | |
21 return false; | |
22 | |
23 result = [string UTF8String]; | |
15 return true; | 24 return true; |
16 } | 25 } |
17 | 26 |
18 static bool GetWindowTitle(unsigned int wid, std::string& result) { | 27 static bool GetWindowTitle(unsigned int wid, std::string& result) { |
19 NSWindow* window = [NSApp windowWithWindowNumber: wid]; | 28 NSWindow* window = [NSApp windowWithWindowNumber: wid]; |
20 if (!window) | 29 if (!window) |
21 return false; | 30 return false; |
22 | 31 |
23 NSString* title = [window title]; | 32 return StringFromNSString([window title], result); |
24 if (!title) | |
25 return false; | |
26 | |
27 result = [title UTF8String]; | |
28 | |
29 return true; | |
30 } | |
31 | |
32 static bool StringFromNSString(NSString* string, std::string& result) { | |
33 if (!string) | |
34 return false; | |
35 result = [string UTF8String]; | |
36 return true; | |
37 } | 33 } |
38 | 34 |
39 bool QuartzWinTools::EnumerateWindows(window_proc_t window_proc) { | 35 bool QuartzWinTools::EnumerateWindows(window_proc_t window_proc) { |
40 if (!window_proc) | 36 if (!window_proc) |
41 return false; | 37 return false; |
42 | 38 |
43 NSMutableArray* windows = (NSMutableArray*)CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID); | 39 NSMutableArray* windows = reinterpret_cast<NSMutableArray*>(CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID)); |
44 if (!windows) | 40 if (!windows) |
45 return false; | 41 return false; |
46 | 42 |
47 for (NSDictionary* window in windows) { | 43 for (NSDictionary* window in windows) { |
48 if (!window) | 44 if (!window) |