OSXOperatingSystem.st
changeset 21591 c89611bc4b5c
parent 21587 3ac571f08fbf
child 21594 acb127ad113c
--- a/OSXOperatingSystem.st	Tue Feb 28 10:57:38 2017 +0100
+++ b/OSXOperatingSystem.st	Tue Feb 28 10:59:24 2017 +0100
@@ -277,6 +277,34 @@
 
 !OSXOperatingSystem class methodsFor:'cocoa - events'!
 
+finishLaunching
+    "tell the system, that I have finished my startup phase.
+     OSX will stop bounding the launch icon then."
+     
+    NSApp isNil ifTrue:[
+        self getNSApp
+    ].
+%{
+#ifndef NO_COCOA
+    id NSApp = __externalAddressVal(@global(NSApp));
+
+    objc_msgSend(NSApp, sel_getUid("finishLaunching"));
+    RETURN(self);
+#endif // NO_COCOA
+%}.
+    "/ if compiled without COCOA support (which you should not),
+    "/ the icon will probably continue to bounce...
+    "/ ... but we do not want an error here.
+    
+    "/ self primitiveFailed
+
+    "
+     self finishLaunching
+    "
+
+    "Modified: / 28-02-2017 / 10:59:15 / cg"
+!
+
 generateButtonEvent:button down:down x:screenX y:screenY
     "synthesize and send a button event to the screen"
 %{
@@ -330,35 +358,6 @@
     "Created: / 28-02-2017 / 00:15:18 / cg"
 !
 
-receiveNextEvent
-%{
-#ifndef NO_COCOA
-    CFMachPortRef      eventTap;
-    CGEventMask        eventMask;
-    CFRunLoopSourceRef runLoopSource;
-
-    // Create an event tap. We are interested in key presses.
-    eventMask = ((1 << kCGEventKeyDown) | (1 << kCGEventKeyUp));
-    eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0,
-				eventMask, NULL, myCGEventCallback);
-    if (!eventTap) {
-	fprintf(stderr, "failed to create event tap\n");
-    } else {
-	fprintf(stderr, "ok\n");
-
-	// Create a run loop source.
-	runLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, eventTap, 0);
-	// Enable the event tap.
-	CGEventTapEnable(eventTap, true);
-    }
-
-#endif // NO_COCOA
-%}.
-    self primitiveFailed
-
-    "Modified: / 28-02-2017 / 01:05:04 / cg"
-!
-
 getNSApp
 %{
 #ifndef NO_COCOA
@@ -392,25 +391,33 @@
     "Modified (comment): / 28-02-2017 / 01:35:31 / cg"
 !
 
-finishLaunching
-    NSApp isNil ifTrue:[
-	self getNSApp
-    ].
+receiveNextEvent
 %{
 #ifndef NO_COCOA
-    id NSApp = __externalAddressVal(@global(NSApp));
+    CFMachPortRef      eventTap;
+    CGEventMask        eventMask;
+    CFRunLoopSourceRef runLoopSource;
 
-    objc_msgSend(NSApp, sel_getUid("finishLaunching"));
-    RETURN(self);
+    // Create an event tap. We are interested in key presses.
+    eventMask = ((1 << kCGEventKeyDown) | (1 << kCGEventKeyUp));
+    eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0,
+				eventMask, NULL, myCGEventCallback);
+    if (!eventTap) {
+	fprintf(stderr, "failed to create event tap\n");
+    } else {
+	fprintf(stderr, "ok\n");
+
+	// Create a run loop source.
+	runLoopSource = CFMachPortCreateRunLoopSource( kCFAllocatorDefault, eventTap, 0);
+	// Enable the event tap.
+	CGEventTapEnable(eventTap, true);
+    }
+
 #endif // NO_COCOA
 %}.
     self primitiveFailed
 
-    "
-     self finishLaunching
-    "
-
-    "Modified (comment): / 28-02-2017 / 01:35:31 / cg"
+    "Modified: / 28-02-2017 / 01:05:04 / cg"
 ! !
 
 !OSXOperatingSystem class methodsFor:'dummy shell operations'!
@@ -701,3 +708,4 @@
 version_CVS
     ^ '$Header$'
 ! !
+