author | Claus Gittinger <cg@exept.de> |
Tue, 02 Apr 2019 10:50:28 +0200 | |
changeset 24034 | ba4c42171801 |
parent 24028 | cda4ff7bb993 |
child 24047 | df6ad32114b1 |
permissions | -rw-r--r-- |
21452 | 1 |
" |
2 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
21455 | 3 |
All Rights Reserved |
21452 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
17471 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
14 |
"{ NameSpace: Smalltalk }" |
|
14819 | 15 |
|
17471 | 16 |
UnixOperatingSystem subclass:#OSXOperatingSystem |
17 |
instanceVariableNames:'' |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
18 |
classVariableNames:'NSApp' |
17471 | 19 |
poolDictionaries:'' |
20 |
category:'OS-Unix' |
|
21 |
! |
|
22 |
||
21452 | 23 |
!OSXOperatingSystem primitiveDefinitions! |
24 |
%{ |
|
25 |
||
22491 | 26 |
#ifdef __osx__ |
27 |
// mhm - how could they forget this???? |
|
28 |
# ifndef __XPC_IOS_SIMULATOR_AVAILABLE_STARTING |
|
29 |
# define __XPC_IOS_SIMULATOR_AVAILABLE_STARTING(version) |
|
30 |
# endif |
|
31 |
#endif |
|
32 |
||
33 |
#ifndef __osx__ |
|
21452 | 34 |
# define NO_QUARTZ |
35 |
# define NO_COCOA |
|
22959 | 36 |
# define NO_CARBON |
21452 | 37 |
#endif |
38 |
||
22833 | 39 |
// #include <mach/clock.h> |
40 |
// #include <mach/mach.h> |
|
41 |
// #include <sys/time.h> |
|
42 |
// #include <mach/clock.h> |
|
43 |
||
21452 | 44 |
#ifndef NO_COCOA |
45 |
||
46 |
# undef Array |
|
47 |
# undef Number |
|
48 |
# undef Method |
|
49 |
# undef Point |
|
50 |
# undef Rectangle |
|
51 |
# undef Block |
|
52 |
# undef String |
|
53 |
# undef Character |
|
54 |
# undef Message |
|
55 |
# undef Object |
|
56 |
# undef Context |
|
57 |
# undef Time |
|
58 |
# undef Date |
|
59 |
# undef Set |
|
60 |
# undef Signal |
|
61 |
# undef Delay |
|
62 |
# undef NameSpace |
|
63 |
# undef Process |
|
64 |
# undef Processor |
|
65 |
# undef Class |
|
66 |
# undef FixedPoint |
|
67 |
# undef true |
|
68 |
# undef false |
|
69 |
||
70 |
# undef INT |
|
71 |
# undef UINT |
|
72 |
||
22491 | 73 |
# include <ApplicationServices/ApplicationServices.h> |
74 |
# include <CoreFoundation/CoreFoundation.h> |
|
21452 | 75 |
// #include <Foundation/Foundation.h> |
21595 | 76 |
|
77 |
// #include <CoreGraphics/CGEventTypes.h> |
|
21452 | 78 |
|
22491 | 79 |
# include <stdlib.h> |
80 |
# include <stdio.h> |
|
81 |
# include <IOKit/graphics/IOGraphicsLib.h> |
|
21452 | 82 |
|
22491 | 83 |
# include <objc/runtime.h> |
84 |
# include <objc/message.h> |
|
21452 | 85 |
|
86 |
# ifdef __DEF_Array |
|
87 |
# define Array __DEF_Array |
|
88 |
# endif |
|
89 |
# ifdef __DEF_Number |
|
90 |
# define Number __DEF_Number |
|
91 |
# endif |
|
92 |
# ifdef __DEF_Method |
|
93 |
# define Method __DEF_Method |
|
94 |
# endif |
|
95 |
# ifdef __DEF_Point |
|
96 |
# define Point __DEF_Point |
|
97 |
# endif |
|
98 |
# ifdef __DEF_Rectangle |
|
99 |
# define Rectangle __DEF_Rectangle |
|
100 |
# endif |
|
101 |
# ifdef __DEF_Block |
|
102 |
# define Block __DEF_Block |
|
103 |
# endif |
|
104 |
# ifdef __DEF_String |
|
105 |
# define String __DEF_String |
|
106 |
# endif |
|
107 |
# ifdef __DEF_Character |
|
108 |
# define Character __DEF_Character |
|
109 |
# endif |
|
110 |
# ifdef __DEF_Message |
|
111 |
# define Message __DEF_Message |
|
112 |
# endif |
|
113 |
# ifdef __DEF_Object |
|
114 |
# define Object __DEF_Object |
|
115 |
# endif |
|
116 |
# ifdef __DEF_Context |
|
117 |
# define Context __DEF_Context |
|
118 |
# endif |
|
119 |
# ifdef __DEF_Date |
|
120 |
# define Date __DEF_Date |
|
121 |
# endif |
|
122 |
# ifdef __DEF_Time |
|
123 |
# define Time __DEF_Time |
|
124 |
# endif |
|
125 |
# ifdef __DEF_Set |
|
126 |
# define Set __DEF_Set |
|
127 |
# endif |
|
128 |
# ifdef __DEF_Signal |
|
129 |
# define Signal __DEF_Signal |
|
130 |
# endif |
|
131 |
# ifdef __DEF_Delay |
|
132 |
# define Delay __DEF_Delay |
|
133 |
# endif |
|
134 |
# ifdef __DEF_NameSpace |
|
135 |
# define NameSpace __DEF_NameSpace |
|
136 |
# endif |
|
137 |
# ifdef __DEF_Process |
|
138 |
# define Process __DEF_Process |
|
139 |
# endif |
|
140 |
# ifdef __DEF_Processor |
|
141 |
# define Processor __DEF_Processor |
|
142 |
# endif |
|
143 |
# ifdef __DEF_Class |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
144 |
# define STX_Class __DEF_Class |
21452 | 145 |
# endif |
146 |
# ifdef __DEF_FixedPoint |
|
147 |
# define FixedPoint __DEF_FixedPoint |
|
148 |
# endif |
|
149 |
# ifdef __DEF_true |
|
150 |
# undef true |
|
151 |
# define true __DEF_true |
|
152 |
# endif |
|
153 |
# ifdef __DEF_false |
|
154 |
# undef false |
|
155 |
# define false __DEF_false |
|
156 |
# endif |
|
157 |
||
158 |
# define INT STX_INT |
|
159 |
# define UINT STX_UINT |
|
160 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
161 |
typedef struct CMPoint { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
162 |
double x; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
163 |
double y; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
164 |
} CMPoint; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
165 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
166 |
typedef struct CMSize { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
167 |
double width; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
168 |
double height; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
169 |
} CMSize; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
170 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
171 |
typedef struct CMRect { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
172 |
CMPoint origin; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
173 |
CMSize size; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
174 |
} CMRect; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
175 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
176 |
typedef struct AppDel { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
177 |
Class isa; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
178 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
179 |
// Will be an NSWindow later. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
180 |
id window; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
181 |
} AppDelegate; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
182 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
183 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
184 |
enum { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
185 |
NSBorderlessWindowMask = 0, |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
186 |
NSTitledWindowMask = 1 << 0, |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
187 |
NSClosableWindowMask = 1 << 1, |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
188 |
NSMiniaturizableWindowMask = 1 << 2, |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
189 |
NSResizableWindowMask = 1 << 3, |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
190 |
}; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
191 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
192 |
typedef id(*CMacsSimpleMessage)(id, SEL); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
193 |
typedef void(*CMacsVoidMessage)(id, SEL); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
194 |
typedef void(*CMacsVoidMessage1)(id, SEL, void *); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
195 |
typedef id(*CMacsRectMessage1)(id, SEL, CMRect); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
196 |
typedef id(*CMacsWindowInitMessage)(id, SEL, CMRect, int, int, bool); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
197 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
198 |
extern CMacsSimpleMessage cmacs_simple_msgSend; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
199 |
extern CMacsVoidMessage cmacs_void_msgSend; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
200 |
extern CMacsVoidMessage1 cmacs_void_msgSend1; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
201 |
extern CMacsRectMessage1 cmacs_rect_msgSend1; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
202 |
extern CMacsWindowInitMessage cmacs_window_init_msgSend; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
203 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
204 |
#endif // NO_COCOA |
21452 | 205 |
|
206 |
%} |
|
207 |
! ! |
|
208 |
||
209 |
!OSXOperatingSystem primitiveFunctions! |
|
210 |
%{ |
|
211 |
||
212 |
#ifndef NO_COCOA |
|
213 |
||
214 |
CGEventRef |
|
215 |
myCGEventCallback(CGEventTapProxy proxy, CGEventType type, |
|
216 |
CGEventRef event, void *refcon) |
|
217 |
{ |
|
218 |
// Paranoid sanity check. |
|
219 |
if ((type != kCGEventKeyDown) && (type != kCGEventKeyUp)) |
|
220 |
return event; |
|
221 |
||
222 |
// The incoming keycode. |
|
223 |
CGKeyCode keycode = (CGKeyCode)CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode); |
|
224 |
||
225 |
//Keypress code goes here. |
|
226 |
||
227 |
// We must return the event for it to be useful. |
|
228 |
return event; |
|
229 |
} |
|
230 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
231 |
BOOL |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
232 |
AppDel_didFinishLaunching(AppDelegate *self, SEL _cmd, id notification) { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
233 |
// self->window = cmacs_simple_msgSend((id)objc_getClass("NSWindow"), sel_getUid("alloc")); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
234 |
// |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
235 |
// /// Create an instance of the window. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
236 |
// self->window = cmacs_window_init_msgSend(self->window, sel_getUid("initWithContentRect:styleMask:backing:defer:"), (CMRect){0,0,1024,460}, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
237 |
// |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
238 |
// /// Create an instance of our view class. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
239 |
// /// |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
240 |
// /// Relies on the view having declared a constructor that allocates a class pair for it. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
241 |
// id view = cmacs_rect_msgSend1(cmacs_simple_msgSend((id)objc_getClass("View"), sel_getUid("alloc")), sel_getUid("initWithFrame:"), (CMRect){ 0, 0, 320, 480 }); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
242 |
// |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
243 |
// // here we simply add the view to the window. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
244 |
// cmacs_void_msgSend1(self->window, sel_getUid("setContentView:"), view); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
245 |
// cmacs_simple_msgSend(self->window, sel_getUid("becomeFirstResponder")); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
246 |
// |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
247 |
// // Shows our window in the bottom-left hand corner of the screen. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
248 |
// cmacs_void_msgSend1(self->window, sel_getUid("makeKeyAndOrderFront:"), self); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
249 |
return YES; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
250 |
} |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
251 |
|
21452 | 252 |
#endif // NO_COCOA |
253 |
||
254 |
%} |
|
255 |
! ! |
|
256 |
||
257 |
!OSXOperatingSystem class methodsFor:'documentation'! |
|
258 |
||
259 |
copyright |
|
260 |
" |
|
261 |
COPYRIGHT (c) 2013 by Claus Gittinger |
|
21455 | 262 |
All Rights Reserved |
21452 | 263 |
|
264 |
This software is furnished under a license and may be used |
|
265 |
only in accordance with the terms of that license and with the |
|
266 |
inclusion of the above copyright notice. This software may not |
|
267 |
be provided or otherwise made available to, or used by, any |
|
268 |
other person. No title to or ownership of the software is |
|
269 |
hereby transferred. |
|
270 |
" |
|
271 |
! |
|
272 |
||
273 |
documentation |
|
274 |
" |
|
275 |
a small number of OS-X specific redefinitions here. |
|
276 |
||
277 |
[Author:] |
|
21455 | 278 |
Claus Gittinger |
21452 | 279 |
" |
280 |
! ! |
|
17471 | 281 |
|
282 |
!OSXOperatingSystem class methodsFor:'initialization'! |
|
283 |
||
284 |
initializeCodeset |
|
285 |
super initializeCodeset. |
|
17493 | 286 |
Codeset := #'utf8-mac'. |
17494 | 287 |
CodesetEncoder := nil. |
17471 | 288 |
! ! |
14819 | 289 |
|
21452 | 290 |
!OSXOperatingSystem class methodsFor:'cocoa - events'! |
291 |
||
21591 | 292 |
finishLaunching |
293 |
"tell the system, that I have finished my startup phase. |
|
294 |
OSX will stop bounding the launch icon then." |
|
21596 | 295 |
|
21591 | 296 |
NSApp isNil ifTrue:[ |
21596 | 297 |
self getNSApp |
21591 | 298 |
]. |
299 |
%{ |
|
300 |
#ifndef NO_COCOA |
|
301 |
id NSApp = __externalAddressVal(@global(NSApp)); |
|
302 |
||
303 |
objc_msgSend(NSApp, sel_getUid("finishLaunching")); |
|
304 |
RETURN(self); |
|
305 |
#endif // NO_COCOA |
|
306 |
%}. |
|
307 |
"/ if compiled without COCOA support (which you should not), |
|
308 |
"/ the icon will probably continue to bounce... |
|
309 |
"/ ... but we do not want an error here. |
|
21596 | 310 |
|
21591 | 311 |
"/ self primitiveFailed |
312 |
||
313 |
" |
|
314 |
self finishLaunching |
|
315 |
" |
|
316 |
||
317 |
"Modified: / 28-02-2017 / 10:59:15 / cg" |
|
318 |
! |
|
319 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
320 |
generateButtonEvent:button down:down x:screenX y:screenY |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
321 |
"synthesize and send a button event to the screen" |
21584 | 322 |
%{ |
323 |
#ifndef NO_COCOA |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
324 |
if (__bothSmallInteger(screenX, screenY) |
21584 | 325 |
&& __isSmallInteger(button)) { |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
326 |
CGPoint pt; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
327 |
pt.x = __intVal(screenX); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
328 |
pt.y = __intVal(screenY); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
329 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
330 |
CGEventType evType; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
331 |
CGMouseButton evButton = __intVal(button); |
21584 | 332 |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
333 |
switch (evButton) { |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
334 |
case 1: |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
335 |
evType = (down == true) ? kCGEventLeftMouseDown : kCGEventLeftMouseUp; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
336 |
evButton = 0; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
337 |
break; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
338 |
case 2: |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
339 |
evType = (down == true) ? kCGEventRightMouseDown : kCGEventRightMouseUp; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
340 |
evButton = 1; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
341 |
break; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
342 |
case 3: |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
343 |
evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
344 |
evButton = 2; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
345 |
break; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
346 |
default: |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
347 |
evType = (down == true) ? kCGEventOtherMouseDown : kCGEventOtherMouseUp; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
348 |
evButton = __intVal(button) - 1; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
349 |
break; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
350 |
} |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
351 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
352 |
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, evType, pt, evButton); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
353 |
CGEventSetType(theEvent, evType); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
354 |
CGEventPost(kCGHIDEventTap, theEvent); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
355 |
CFRelease(theEvent); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
356 |
RETURN(self); |
21584 | 357 |
} |
358 |
#endif // NO_COCOA |
|
359 |
%}. |
|
360 |
self primitiveFailed |
|
361 |
||
362 |
" |
|
363 |
OperatingSystem generateButtonEvent:1 down:true x:150 y:150. |
|
364 |
OperatingSystem generateButtonEvent:1 down:false x:150 y:150. |
|
365 |
||
366 |
OperatingSystem generateButtonEvent:2 down:true x:150 y:150. |
|
367 |
OperatingSystem generateButtonEvent:2 down:false x:150 y:150. |
|
368 |
" |
|
369 |
||
370 |
"Created: / 28-02-2017 / 00:15:18 / cg" |
|
371 |
! |
|
372 |
||
21621 | 373 |
generateKeyboardEvent:keyCode down:down |
374 |
"synthesize and send a keyboard event to the screen" |
|
375 |
%{ |
|
376 |
#ifndef NO_COCOA |
|
377 |
if (__isSmallInteger(keyCode)) { |
|
21627 | 378 |
int evType; |
379 |
||
380 |
CGEventRef theEvent = CGEventCreateKeyboardEvent(NULL, __intVal(keyCode), (down==true)?1:0); |
|
381 |
CGEventSetType(theEvent, (down==true) ? kCGEventKeyDown:kCGEventKeyUp); |
|
382 |
CGEventPost(kCGHIDEventTap, theEvent); |
|
383 |
CFRelease(theEvent); |
|
384 |
RETURN(self); |
|
21621 | 385 |
} |
386 |
#endif // NO_COCOA |
|
387 |
%}. |
|
388 |
self primitiveFailed |
|
389 |
||
390 |
" |
|
391 |
OperatingSystem generateKeyboardEvent:6 down:true. |
|
392 |
OperatingSystem generateKeyboardEvent:6 down:false. |
|
393 |
" |
|
394 |
||
395 |
"Created: / 02-03-2017 / 16:35:04 / cg" |
|
396 |
! |
|
397 |
||
398 |
generateMouseMoveEventX:screenX y:screenY |
|
399 |
"synthesize and send a mosue move event to the screen" |
|
400 |
%{ |
|
401 |
#ifndef NO_COCOA |
|
402 |
if (__bothSmallInteger(screenX, screenY)) { |
|
21627 | 403 |
CGPoint pt; |
404 |
pt.x = __intVal(screenX); |
|
405 |
pt.y = __intVal(screenY); |
|
21621 | 406 |
|
21627 | 407 |
CGEventType evType; |
408 |
CGEventRef theEvent = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pt, 0); |
|
409 |
CGEventSetType(theEvent, kCGEventMouseMoved); |
|
410 |
CGEventPost(kCGHIDEventTap, theEvent); |
|
411 |
CFRelease(theEvent); |
|
412 |
RETURN(self); |
|
21621 | 413 |
} |
414 |
#endif // NO_COCOA |
|
415 |
%}. |
|
416 |
self primitiveFailed |
|
417 |
||
418 |
" |
|
419 |
OperatingSystem generateMouseMoveEventX:150 y:5. |
|
420 |
Delay waitFor:(1 seconds). |
|
421 |
OperatingSystem generateMouseMoveEventX:1050 y:150. |
|
422 |
" |
|
423 |
||
424 |
"Created: / 02-03-2017 / 20:01:51 / cg" |
|
425 |
! |
|
426 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
427 |
getNSApp |
23114 | 428 |
"get the NSApplication instance and remember in the global named NSApp" |
429 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
430 |
%{ |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
431 |
#ifndef NO_COCOA |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
432 |
Class AppDelClass = NULL; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
433 |
id NSApp = NULL; |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
434 |
|
21731 | 435 |
# if 0 /* not needed */ |
21597 | 436 |
Class poolClass = objc_getClass("NSAutoreleasePool"); |
21594 | 437 |
if (poolClass == NULL) { |
21597 | 438 |
fprintf(stderr, "OSX: Unable to get NSAutoreleasePool\n"); |
439 |
RETURN(false); |
|
21594 | 440 |
} |
441 |
id pool = objc_msgSend(poolClass, sel_registerName("alloc")); |
|
442 |
if (pool == NULL) { |
|
21597 | 443 |
fprintf(stderr, "OSX: Unable to create NSAutoreleasePool\n"); |
444 |
RETURN(false); |
|
21594 | 445 |
} |
446 |
objc_msgSend(pool, sel_registerName("init")); |
|
21731 | 447 |
# endif |
21594 | 448 |
|
21731 | 449 |
# if 0 /* not needed */ |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
450 |
AppDelClass = objc_allocateClassPair((Class)objc_getClass("NSObject"), "AppDelegate", 0); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
451 |
class_addMethod(AppDelClass, sel_getUid("applicationDidFinishLaunching:"), (IMP)AppDel_didFinishLaunching, "i@:@"); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
452 |
objc_registerClassPair(AppDelClass); |
21731 | 453 |
# endif |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
454 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
455 |
NSApp = objc_msgSend((id)objc_getClass("NSApplication"), sel_getUid("sharedApplication")); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
456 |
if (NSApp == NULL) { |
21597 | 457 |
fprintf(stderr,"OSX: Failed to initialize NSApplication\n"); |
458 |
RETURN(false); |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
459 |
} |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
460 |
@global(NSApp) = __MKEXTERNALADDRESS(NSApp); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
461 |
|
21594 | 462 |
id req = objc_msgSend(NSApp,sel_getUid("requestUserAttention:"),0); |
463 |
objc_msgSend(NSApp,sel_getUid("cancelUserAttentionRequest:"),req); |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
464 |
|
21731 | 465 |
# if 0 /* not needed */ |
21594 | 466 |
id appDelInst = objc_msgSend((id)objc_getClass("AppDelegate"), sel_getUid("alloc")); |
467 |
objc_msgSend(appDelInst, sel_getUid("init")); |
|
468 |
objc_msgSend(NSApp, sel_getUid("setDelegate:"), appDelInst); |
|
21731 | 469 |
# endif |
21594 | 470 |
|
21731 | 471 |
# if 0 /* not needed */ |
21594 | 472 |
objc_msgSend(pool, sel_registerName("release")); |
21731 | 473 |
# endif |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
474 |
RETURN(true); |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
475 |
#endif // NO_COCOA |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
476 |
%}. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
477 |
self primitiveFailed |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
478 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
479 |
" |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
480 |
self getNSApp |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
481 |
" |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
482 |
|
21594 | 483 |
"Modified: / 28-02-2017 / 13:45:39 / cg" |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
484 |
! |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
485 |
|
21591 | 486 |
receiveNextEvent |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
487 |
%{ |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
488 |
#ifndef NO_COCOA |
21591 | 489 |
CFMachPortRef eventTap; |
490 |
CGEventMask eventMask; |
|
491 |
CFRunLoopSourceRef runLoopSource; |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
492 |
|
21591 | 493 |
// Create an event tap. We are interested in key presses. |
494 |
eventMask = ((1 << kCGEventKeyDown) | (1 << kCGEventKeyUp)); |
|
495 |
eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, |
|
496 |
eventMask, NULL, myCGEventCallback); |
|
497 |
if (!eventTap) { |
|
498 |
fprintf(stderr, "failed to create event tap\n"); |
|
499 |
} else { |
|
500 |
fprintf(stderr, "ok\n"); |
|
501 |
||
502 |
// Create a run loop source. |
|
503 |
runLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, eventTap, 0); |
|
504 |
// Enable the event tap. |
|
505 |
CGEventTapEnable(eventTap, true); |
|
506 |
} |
|
507 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
508 |
#endif // NO_COCOA |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
509 |
%}. |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
510 |
self primitiveFailed |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
511 |
|
21591 | 512 |
"Modified: / 28-02-2017 / 01:05:04 / cg" |
21452 | 513 |
! ! |
514 |
||
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
515 |
!OSXOperatingSystem class methodsFor:'dummy shell operations'! |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
516 |
|
22655 | 517 |
openApplicationForDocument:aFilenameOrString operation:operationSymbol |
518 |
"open a windows-shell/mac finder/desktop application to present the document contained in aFilenameOrString. |
|
519 |
This is typically used to present help-files, html documents, pdf documents etc. |
|
520 |
operationSymbol is one of: |
|
22833 | 521 |
open |
522 |
edit |
|
523 |
explore |
|
22655 | 524 |
" |
525 |
||
526 |
|openCmd| |
|
527 |
||
528 |
(openCmd := self openApplicationHelperCommand) notNil ifTrue:[ |
|
22833 | 529 |
(operationSymbol = 'open') ifTrue:[ |
530 |
self executeCommand:'open "',aFilenameOrString asFilename pathName,'"' |
|
531 |
] ifFalse:[ |
|
532 |
(operationSymbol = 'explore') ifTrue:[ |
|
533 |
self executeCommand:'open -R "',aFilenameOrString asFilename pathName,'"' |
|
534 |
]. |
|
535 |
]. |
|
22655 | 536 |
]. |
537 |
! |
|
538 |
||
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
539 |
openApplicationHelperCommand |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
540 |
"Return a command line helper to open a default application for file or URL" |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
541 |
|
18279 | 542 |
(self canExecuteCommand: 'open') ifTrue:[ |
543 |
^ 'open' |
|
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
544 |
]. |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
545 |
^ nil |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
546 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
547 |
"Created: / 13-01-2015 / 09:23:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17427 | 548 |
! |
549 |
||
17428 | 550 |
openTerminalWithCommand:shellCommand inBackground:inBackground |
17427 | 551 |
"open a new terminal, which executes a command" |
552 |
||
17428 | 553 |
|cmd| |
554 |
||
555 |
cmd := 'osascript -e ''tell application "Terminal" to do script "%1"''' bindWith:shellCommand. |
|
556 |
||
557 |
inBackground ifTrue:[ |
|
18279 | 558 |
^ self |
559 |
startProcess:cmd |
|
560 |
inputFrom:nil |
|
561 |
outputTo:nil |
|
562 |
errorTo:nil |
|
563 |
auxFrom:nil |
|
564 |
environment:nil |
|
565 |
inDirectory:nil |
|
17428 | 566 |
] ifFalse:[ |
18279 | 567 |
^ self executeCommand:cmd |
17428 | 568 |
]. |
17427 | 569 |
|
570 |
" |
|
17428 | 571 |
OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true |
17427 | 572 |
" |
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
573 |
! ! |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
574 |
|
14819 | 575 |
!OSXOperatingSystem class methodsFor:'file queries'! |
576 |
||
577 |
caseSensitiveFilenames |
|
578 |
"return true, if the OS has caseSensitive file naming. |
|
579 |
On MSDOS, this will return false; |
|
19817 | 580 |
on a real OS, we return true. |
581 |
Be aware, that OSX can be configured to be either. |
|
582 |
Also, that it actually depends on the mounted volume" |
|
14819 | 583 |
|
18279 | 584 |
"/ actually, this is wrong and depends on the mounted volume; |
585 |
"/ so we need a query for a particular directory (and/or volume). |
|
14819 | 586 |
^ false |
587 |
||
588 |
"Modified: / 5.6.1998 / 18:35:18 / cg" |
|
16381 | 589 |
! |
590 |
||
16644 | 591 |
defaultPackagePath |
20639 | 592 |
"redefined to add /Application and /Library stuff" |
20642 | 593 |
"called by Smalltalk initSystemPath" |
594 |
"self defaultPackagePath" |
|
16644 | 595 |
|
21452 | 596 |
|path executablePath executableDir packagesDir |
20637 | 597 |
libDir appDir versionsDir vsnDirName vsnDir| |
16644 | 598 |
|
599 |
path := super defaultPackagePath. |
|
600 |
||
601 |
executablePath := OperatingSystem pathOfSTXExecutable. |
|
602 |
executablePath notNil ifTrue:[ |
|
21452 | 603 |
executableDir := executablePath asFilename directory. |
604 |
packagesDir := executableDir directory directory / 'Packages'. |
|
605 |
packagesDir exists ifTrue:[ |
|
606 |
packagesDir := packagesDir pathName. |
|
607 |
(path includes:packagesDir) ifFalse:[ |
|
608 |
path add:packagesDir. |
|
609 |
]. |
|
610 |
]. |
|
611 |
libDir := '/Library/Frameworks/SmalltalkX.framework' asFilename. |
|
612 |
libDir exists ifTrue:[ |
|
613 |
versionsDir := libDir / 'Versions'. |
|
614 |
versionsDir exists ifTrue:[ |
|
615 |
vsnDirName := '%1.%2.%3' |
|
616 |
bindWith:Smalltalk majorVersionNr |
|
617 |
with:Smalltalk minorVersionNr |
|
618 |
with:Smalltalk revisionNr. |
|
619 |
vsnDir := versionsDir / vsnDirName. |
|
620 |
vsnDir exists ifTrue:[ |
|
621 |
vsnDir := vsnDir pathName. |
|
622 |
(path includes:vsnDir) ifFalse:[ |
|
623 |
path add:vsnDir. |
|
624 |
]. |
|
625 |
]. |
|
626 |
]. |
|
627 |
]. |
|
628 |
appDir := '/Applications/SmalltalkX/' asFilename. |
|
629 |
appDir exists ifTrue:[ |
|
630 |
versionsDir := appDir / 'Versions'. |
|
631 |
versionsDir exists ifTrue:[ |
|
632 |
vsnDirName := '%1.%2.%3' |
|
633 |
bindWith:Smalltalk majorVersionNr |
|
634 |
with:Smalltalk minorVersionNr |
|
635 |
with:Smalltalk revisionNr. |
|
636 |
vsnDir := versionsDir / vsnDirName. |
|
637 |
vsnDir exists ifTrue:[ |
|
638 |
vsnDir := vsnDir pathName. |
|
639 |
(path includes:vsnDir) ifFalse:[ |
|
640 |
path add:vsnDir. |
|
641 |
]. |
|
642 |
]. |
|
643 |
]. |
|
644 |
]. |
|
16644 | 645 |
]. |
16647 | 646 |
^ path |
16644 | 647 |
! |
648 |
||
22655 | 649 |
getDocumentsDirectory |
650 |
"return your documents directory. |
|
651 |
Under osx, that's the user's 'Documents' folder. |
|
652 |
The fallback for other OS's may return the user's home directory." |
|
653 |
||
654 |
"{ Pragma: +optSpace }" |
|
655 |
||
656 |
|home documentsFolder| |
|
657 |
||
658 |
(home := self getHomeDirectory) notNil ifTrue:[ |
|
22833 | 659 |
(documentsFolder := home asFilename / 'Documents') exists ifTrue:[ |
660 |
^ documentsFolder pathName |
|
661 |
]. |
|
22655 | 662 |
]. |
663 |
^ home |
|
664 |
||
665 |
" |
|
666 |
OperatingSystem getDocumentsDirectory |
|
667 |
" |
|
668 |
! |
|
669 |
||
16677 | 670 |
getDriveList |
671 |
"return a list of volumes in the system." |
|
672 |
||
673 |
^ ('/Volumes' asFilename directoryContents) |
|
674 |
, super getDriveList |
|
675 |
! |
|
676 |
||
16381 | 677 |
getTrashDirectory |
678 |
"get the name of a trash folder (if the OS supports it), |
|
679 |
or nil, if not. |
|
680 |
Must be redefined to return non nil in concrete operating systems" |
|
681 |
||
682 |
^ '~/.Trash' |
|
16677 | 683 |
! |
684 |
||
685 |
pathNameForDrive:driveName |
|
686 |
"given a drive name, return the pathname to open it as a directory. |
|
687 |
For Windows, this is the driveName itself. |
|
688 |
For OSX, '/Volumes' is prepended. |
|
689 |
Other OSs might prepent the pount point (i.e. /mnt/)" |
|
690 |
||
16905 | 691 |
driveName isNil ifTrue:[^ nil]. |
16677 | 692 |
driveName asFilename isAbsolute ifTrue:[^ driveName]. |
693 |
^ '/Volumes/',driveName |
|
17177 | 694 |
! |
695 |
||
696 |
supportsVolumes |
|
18279 | 697 |
"return true if the os support a list of drives/volumes |
17179 | 698 |
(here we can return a list of mounted drives in /Volumes)" |
17177 | 699 |
|
700 |
^ true |
|
14819 | 701 |
! ! |
702 |
||
21452 | 703 |
!OSXOperatingSystem class methodsFor:'quartz - screen'! |
704 |
||
705 |
getFrameBufferImage:displayNr |
|
706 |
"returns the framebuffer as an image object" |
|
707 |
||
21580 | 708 |
^ self getFrameBufferImage:displayNr in:nil |
709 |
||
710 |
" |
|
711 |
self getFrameBufferImage:0 |
|
712 |
" |
|
713 |
||
714 |
"Modified: / 25-02-2017 / 10:57:17 / cg" |
|
715 |
! |
|
21452 | 716 |
|
21580 | 717 |
getFrameBufferImage:displayNr in:aRectangleOrNil |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
718 |
"returns the frameBuffer (if rect-arg is nil) |
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
719 |
or part of the framebuffer (if non-nil) as an image object" |
21580 | 720 |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
721 |
|rx ry rwidth rheight bytesPerPixel bytesPerRow address pixels depth pad img ok| |
21580 | 722 |
|
723 |
aRectangleOrNil notNil ifTrue:[ |
|
23954 | 724 |
rx := aRectangleOrNil left. |
725 |
ry := aRectangleOrNil top. |
|
726 |
rwidth := aRectangleOrNil width. |
|
727 |
rheight := aRectangleOrNil height. |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
728 |
]. |
21452 | 729 |
%{ |
21596 | 730 |
#ifndef NO_COCOA |
21580 | 731 |
CGImageRef image_ref; |
732 |
CGDirectDisplayID displayID = CGMainDisplayID(); |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
733 |
|
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
734 |
ok = false; |
21580 | 735 |
if (rx == nil) { |
23954 | 736 |
image_ref = CGDisplayCreateImage(displayID); |
21580 | 737 |
} else { |
23954 | 738 |
CGRect rect; |
739 |
rect.origin.x = (CGFloat)__intVal(rx); |
|
740 |
rect.origin.y = (CGFloat)__intVal(ry); |
|
741 |
rect.size.width = (CGFloat)__intVal(rwidth); |
|
742 |
rect.size.height = (CGFloat)__intVal(rheight); |
|
743 |
image_ref = CGDisplayCreateImageForRect(displayID, rect); |
|
21580 | 744 |
} |
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
745 |
|
21580 | 746 |
if (image_ref != NULL) { |
23954 | 747 |
CGDataProviderRef provider = CGImageGetDataProvider(image_ref); |
748 |
CFDataRef dataref = CGDataProviderCopyData(provider); |
|
749 |
size_t c_width = CGImageGetWidth(image_ref); |
|
750 |
size_t c_height = CGImageGetHeight(image_ref); |
|
751 |
size_t c_bytesPerRow = CGImageGetBytesPerRow(image_ref); |
|
752 |
size_t c_bytesPerPixel = CGImageGetBitsPerPixel(image_ref) / 8; |
|
753 |
unsigned char *c_pixels = (unsigned char *)CFDataGetBytePtr(dataref); |
|
21452 | 754 |
|
23954 | 755 |
if (c_bytesPerPixel == 4) { |
756 |
int row; |
|
757 |
pixels = __BYTEARRAY_UNINITIALIZED_NEW_INT(c_width * c_height * 3); |
|
758 |
unsigned char *srcRowPtr = c_pixels; |
|
759 |
unsigned char *dstRowPtr = __byteArrayVal(pixels); |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
760 |
|
23954 | 761 |
for (row=c_height; row>0; row--) { |
762 |
int col = c_width; |
|
763 |
unsigned int *pixSrcPtr = (int*)srcRowPtr; |
|
764 |
unsigned char *pixDstPtr = dstRowPtr; |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
765 |
|
23954 | 766 |
// convert abgr to rgb |
767 |
#if (__POINTER_SIZE__ == 8) && defined(__LSBFIRST__) |
|
768 |
for (; col > 2; col -= 2) { |
|
769 |
// pick 2 pixels |
|
770 |
unsigned INT pix12 = ((unsigned INT*)pixSrcPtr)[0]; |
|
771 |
pixSrcPtr += 2; |
|
24028 | 772 |
// a2 r2 g2 b2 a1 r1 g1 b1 => r1..g1..b1..r2..g2..b2 |
773 |
pixDstPtr[0] = (pix12 >> 16) & 0xFF; |
|
23954 | 774 |
pixDstPtr[1] = (pix12 >> 8) & 0xFF; |
24028 | 775 |
pixDstPtr[2] = pix12 & 0xFF; |
776 |
pixDstPtr[3] = (pix12 >> 48) & 0xFF; |
|
23954 | 777 |
pixDstPtr[4] = (pix12 >> 40) & 0xFF; |
24028 | 778 |
pixDstPtr[5] = (pix12 >> 32) & 0xFF; |
23954 | 779 |
pixDstPtr += 6; |
780 |
} |
|
781 |
#endif |
|
21452 | 782 |
|
23954 | 783 |
for (; col>0;col--) { |
784 |
unsigned int pix = *pixSrcPtr++; |
|
785 |
#if 0 |
|
786 |
pix = ((pix >> 16) & 0x0000FF)|((pix << 16) & 0xFF0000)|(pix & 0x00FF00); |
|
787 |
pixDstPtr[0] = (pix >> 0); |
|
788 |
pixDstPtr[1] = (pix >> 8); |
|
789 |
pixDstPtr[2] = (pix >> 16); |
|
790 |
#else |
|
24028 | 791 |
pixDstPtr[0] = (pix >> 16) & 0xFF; |
23954 | 792 |
pixDstPtr[1] = (pix >> 8) & 0xFF; |
24028 | 793 |
pixDstPtr[2] = pix & 0xFF; |
23954 | 794 |
#endif |
795 |
pixDstPtr += 3; |
|
796 |
} |
|
797 |
dstRowPtr += c_width * 3; |
|
798 |
srcRowPtr += c_bytesPerRow; |
|
799 |
} |
|
800 |
bytesPerPixel = __MKSMALLINT(3); |
|
801 |
bytesPerRow = __MKSMALLINT( c_width*3 ); |
|
802 |
ok = true; |
|
803 |
} else { |
|
804 |
// to be determined what we get... |
|
805 |
ok = false; |
|
806 |
} |
|
807 |
CFRelease(dataref); |
|
808 |
CGImageRelease(image_ref); |
|
21580 | 809 |
|
23954 | 810 |
rwidth = __MKUINT( c_width ); |
811 |
rheight = __MKUINT( c_height ); |
|
21580 | 812 |
} |
813 |
||
814 |
// the following is no longer supported by apple |
|
815 |
// CGDisplayBaseAddress is deprecated |
|
816 |
// |
|
817 |
// uint32_t rowBytes, rowUInt32s, *screen; |
|
818 |
// |
|
819 |
// CGDirectDisplayID targetDisplay = 0; |
|
820 |
// |
|
821 |
// screen = (uint32_t *)CGDisplayBaseAddress(targetDisplay); |
|
822 |
// rowBytes = CGDisplayBytesPerRow(targetDisplay); |
|
823 |
// rowUInt32s = rowBytes / 4; |
|
824 |
// rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) ); |
|
825 |
// rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) ); |
|
826 |
// |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
827 |
|
21596 | 828 |
#endif // NO_COCOA |
21452 | 829 |
|
830 |
%}. |
|
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
831 |
(ok not or:[rwidth isNil]) ifTrue:[ |
23954 | 832 |
^ self primitiveFailed |
21452 | 833 |
]. |
834 |
depth := bytesPerPixel * 8. |
|
835 |
||
21587
3ac571f08fbf
hooks to send finishLaunching to NSApp
Claus Gittinger <cg@exept.de>
parents:
21585
diff
changeset
|
836 |
"/ Transcript printf:'w:%d h:%d bpp:%d depth:%d bpr: %d\n' |
21580 | 837 |
"/ withAll:{ rwidth . rheight . bytesPerPixel . depth . bytesPerRow}. |
21452 | 838 |
|
21598 | 839 |
( #(24) includes:depth) ifFalse:[ |
23954 | 840 |
"/ check what we get here... |
841 |
^ self primitiveFailed:'unsupported depth' |
|
21452 | 842 |
]. |
843 |
||
21580 | 844 |
img := Image extent:(rwidth @ rheight) depth:depth bits:pixels. |
21598 | 845 |
depth == 24 ifTrue:[ |
23954 | 846 |
img bitsPerSample:#[8 8 8]. |
847 |
img samplesPerPixel:3. |
|
848 |
img photometric:#rgb. |
|
21598 | 849 |
] ifFalse:[ |
23954 | 850 |
depth == 16 ifTrue:[ |
851 |
"/ to be determined... |
|
852 |
img bitsPerSample:#[5 5 5]. |
|
853 |
img samplesPerPixel:3. |
|
854 |
img photometric:#rgb. |
|
855 |
]. |
|
21627 | 856 |
]. |
21452 | 857 |
^ img |
21580 | 858 |
|
859 |
" |
|
860 |
self getFrameBufferImage:0 in:nil |
|
861 |
self getFrameBufferImage:0 in:(100@100 corner:301@303) |
|
21598 | 862 |
|
863 |
Delay waitFor:3 seconds. self getFrameBufferImage:0 in:nil |
|
21580 | 864 |
" |
865 |
||
866 |
"Created: / 25-02-2017 / 09:49:07 / cg" |
|
21598 | 867 |
"Modified (comment): / 28-02-2017 / 15:22:17 / cg" |
24028 | 868 |
"Modified: / 01-04-2019 / 00:39:22 / Claus Gittinger" |
21625 | 869 |
! |
870 |
||
21627 | 871 |
getScreenBounds:displayNr |
21625 | 872 |
"returns the bounds of the screen. |
873 |
This is needed, because the dimension of the XQuartz screen does not include the dock." |
|
874 |
||
875 |
|rx ry rwidth rheight| |
|
876 |
||
877 |
%{ |
|
878 |
#ifndef NO_COCOA |
|
879 |
CGDirectDisplayID targetDisplay = 0; |
|
880 |
||
881 |
rx = ry = __MKSMALLINT(0); |
|
882 |
rwidth = __MKUINT( CGDisplayPixelsWide(targetDisplay) ); |
|
883 |
rheight = __MKUINT( CGDisplayPixelsHigh(targetDisplay) ); |
|
884 |
#endif // NO_COCOA |
|
885 |
%}. |
|
886 |
(rwidth isNil) ifTrue:[ |
|
21627 | 887 |
^ self primitiveFailed |
21625 | 888 |
]. |
889 |
^ rx@ry extent:(rwidth@rheight) |
|
890 |
||
891 |
" |
|
21627 | 892 |
self getScreenBounds:0 |
21625 | 893 |
" |
894 |
||
895 |
"Created: / 05-03-2017 / 11:10:08 / cg" |
|
21452 | 896 |
! ! |
897 |
||
22962 | 898 |
!OSXOperatingSystem class methodsFor:'sound & voice'! |
899 |
||
23314 | 900 |
canPlaySound |
901 |
^ true |
|
902 |
||
903 |
"Created: / 29-08-2018 / 09:35:52 / Claus Gittinger" |
|
904 |
! |
|
905 |
||
906 |
canSpeak |
|
907 |
^ true |
|
908 |
||
909 |
"Created: / 29-08-2018 / 09:45:16 / Claus Gittinger" |
|
910 |
! |
|
911 |
||
22962 | 912 |
playSound:soundFile |
913 |
"use 'say ...'" |
|
914 |
||
915 |
^ self executeCommand:('afplay "%1"' bindWith:soundFile asFilename pathName) |
|
916 |
||
917 |
" |
|
918 |
self speak:'hello world' |
|
919 |
" |
|
920 |
! |
|
921 |
||
22970 | 922 |
voiceCommandSpec |
923 |
^ #( |
|
23114 | 924 |
"/ triples are: |
925 |
"/ -command |
|
926 |
"/ -commandline for default voice |
|
927 |
"/ -commandline for specific voice |
|
928 |
( |
|
929 |
'say' |
|
930 |
'say "%2"' |
|
931 |
'say -v "%1" "%2"' |
|
932 |
) |
|
933 |
) |
|
22966 | 934 |
! |
935 |
||
936 |
voiceInfo |
|
937 |
"return a list of available voices plus info: |
|
938 |
for each available voice, a triple is returned, containing: |
|
23114 | 939 |
voiceName language_territory comment/description |
22966 | 940 |
" |
941 |
||
942 |
^ (PipeStream outputFromCommand:'say -v ?') |
|
23114 | 943 |
asCollectionOfLines |
944 |
collect:[:l | |
|
945 |
|s name lang comment| |
|
946 |
||
947 |
s := l readStream. |
|
948 |
"/ skip forward for two separators |
|
949 |
[ |
|
950 |
[s next isLetterOrDigit] whileTrue:[]. |
|
951 |
s peek isLetterOrDigit |
|
952 |
] whileTrue. |
|
953 |
name := l copyFrom:1 to:s position - 1. |
|
954 |
s skipSeparators. |
|
955 |
lang := s upToSeparator. |
|
956 |
s skipSeparators. |
|
957 |
s next == $# ifTrue:[ |
|
958 |
s skipSeparators. |
|
959 |
comment := s upToEnd utf8Decoded. |
|
960 |
]. |
|
961 |
{ name . lang . comment } |
|
962 |
] |
|
22962 | 963 |
|
964 |
" |
|
22966 | 965 |
OperatingSystem voiceInfo |
22962 | 966 |
" |
23314 | 967 |
! |
968 |
||
969 |
voiceMapping |
|
970 |
"return a mapping from common (OS-independent) voice names |
|
971 |
to OS-specific names or IDs. |
|
972 |
The speak:voiceName interface will recognize both. |
|
973 |
For portable programs, always use the OS-independent name and |
|
974 |
let every OS xlate to its internal name." |
|
975 |
||
976 |
|info map v| |
|
977 |
||
978 |
VoiceMapping notNil ifTrue:[^ VoiceMapping]. |
|
979 |
||
980 |
info := self voiceInfo. |
|
981 |
map := OrderedCollection new. |
|
982 |
v := info detect:[:entry | #('Tom' 'Alex' 'Fred' 'Bruce' 'Ralph' 'Daniel') includes:entry first] ifNone:nil. |
|
983 |
map add:( 'male' -> (v ? #(nil)) first ). |
|
984 |
v := info detect:[:entry | #('Samantha' 'Fiona' 'Karen' 'Moira') includes:entry first] ifNone:nil. |
|
985 |
map add:( 'female' -> (v ? #(nil)) first ). |
|
986 |
v := info detect:[:entry | #('Zarvox') includes:entry first] ifNone:nil. |
|
987 |
map add:( 'computer' -> (v ? #(nil)) first ). |
|
988 |
map add:( 'default' -> nil ). |
|
989 |
VoiceMapping := map. |
|
990 |
^ VoiceMapping |
|
991 |
||
992 |
"on OSX, this could be: |
|
993 |
^ { |
|
994 |
'male' -> 'Alex' . |
|
995 |
'female' -> 'Fiona' . |
|
996 |
'computer' -> 'Zarvox' . |
|
997 |
'default' -> 'Fiona' |
|
998 |
} |
|
999 |
" |
|
1000 |
||
1001 |
" |
|
1002 |
OperatingSystem voiceMapping |
|
1003 |
" |
|
1004 |
||
1005 |
"Created: / 29-08-2018 / 09:55:00 / Claus Gittinger" |
|
22962 | 1006 |
! ! |
1007 |
||
22833 | 1008 |
!OSXOperatingSystem class methodsFor:'time and date'! |
1009 |
||
1010 |
getOSTimeWithNanos |
|
1011 |
"This returns the OS time as a 2-element vector with milliseconds (as before) |
|
1012 |
plus nanoseconds. |
|
1013 |
The base of the returned value is not consistent across |
|
1014 |
different OS's - some return the number of nanoseconds since jan, 1st 1970; |
|
1015 |
others since 1900. The Time classes are prepared for this, and |
|
1016 |
convert as appropriate (by using my fromOSTime: conversion methods). |
|
1017 |
||
1018 |
Don't use this method in application code since it is an internal (private) |
|
1019 |
interface. For compatibility use instances of Time, Date or Timestamp to work with." |
|
1020 |
||
1021 |
|seconds millis nanos| |
|
1022 |
%{ |
|
1023 |
// all of the experiments below only return 1us resolution |
|
1024 |
// on my machine. Not sure if that has to do with the OSX version (high sierra) |
|
1025 |
// therefore, it is disabled, and we fall back to the inherited method, |
|
1026 |
// which returns microsecond resolution nanos anyway. |
|
1027 |
#if 0 |
|
1028 |
unsigned long _secs, _millis, _nanos; |
|
1029 |
||
1030 |
# if defined(CLOCK_REALTIME) && !defined(NO_CLOCK_GETTIME) |
|
1031 |
struct timespec ts; |
|
1032 |
static int has_clock_gettime = 1; |
|
1033 |
unsigned long _secs, _millis, _nanos; |
|
1034 |
||
1035 |
if (has_clock_gettime) { |
|
1036 |
if (clock_gettime(CLOCK_REALTIME, &ts) != -1) { |
|
1037 |
_secs = ts.tv_sec; |
|
1038 |
_millis = ts.tv_nsec / 1000000; |
|
1039 |
_nanos = ts.tv_nsec % 1000000; |
|
1040 |
||
1041 |
seconds = __MKUINT(_secs); |
|
1042 |
millis = __MKUINT(_millis); |
|
1043 |
nanos = __MKUINT(_nanos); |
|
1044 |
} else { |
|
1045 |
/* |
|
1046 |
* clock_gettime is not implemented in the kernel |
|
1047 |
* fall through to alternative implementation |
|
1048 |
*/ |
|
1049 |
has_clock_gettime = 0; |
|
1050 |
} |
|
1051 |
} |
|
1052 |
# else |
|
1053 |
# if 0 |
|
1054 |
// althoug documented, my osx doesn't have it... |
|
1055 |
uint32_t secpart; |
|
1056 |
uint32_t nsecpart; |
|
1057 |
||
1058 |
clock_get_calendar_nanotime(&secpart, &nsecpart); |
|
1059 |
||
1060 |
_secs = secpart; |
|
1061 |
_millis = nsecpart / 1000000; |
|
1062 |
_nanos = nsecpart % 1000000; |
|
1063 |
# else |
|
1064 |
// OS X does not have clock_gettime, use host_get_clock_service |
|
1065 |
clock_serv_t cclock; |
|
1066 |
mach_timespec_t mts; |
|
1067 |
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); |
|
1068 |
clock_get_time(cclock, &mts); |
|
1069 |
mach_port_deallocate(mach_task_self(), cclock); |
|
1070 |
||
1071 |
_secs = mts.tv_sec; |
|
1072 |
_millis = mts.tv_nsec / 1000000; |
|
1073 |
_nanos = mts.tv_nsec % 1000000; |
|
1074 |
# endif |
|
1075 |
||
1076 |
seconds = __MKUINT(_secs); |
|
1077 |
millis = __MKUINT(_millis); |
|
1078 |
nanos = __MKUINT(_nanos); |
|
1079 |
# endif |
|
1080 |
#endif |
|
1081 |
%}. |
|
1082 |
seconds notNil ifTrue:[ |
|
1083 |
^ { ((seconds * 1000) + millis) . nanos } |
|
1084 |
]. |
|
1085 |
||
1086 |
^ super getOSTimeWithNanos. |
|
1087 |
! ! |
|
1088 |
||
14819 | 1089 |
!OSXOperatingSystem class methodsFor:'documentation'! |
1090 |
||
1091 |
version |
|
19817 | 1092 |
^ '$Header$' |
14819 | 1093 |
! |
1094 |
||
1095 |
version_CVS |
|
19817 | 1096 |
^ '$Header$' |
14819 | 1097 |
! ! |
23314 | 1098 |