Issue #186: Win32: use inline C in `#setForegroundWindow:` jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 08 Dec 2017 09:10:33 +0000
branchjv
changeset 8232 ddbaa22b9352
parent 8224 6d994e1ee4fc
child 8269 5382a417a503
Issue #186: Win32: use inline C in `#setForegroundWindow:` ...rather than FFI. It's much faster and uses lot less stack. The latter is also important since `#setForegroundWindow:` is called when opening debugger. In case a debugger is opened due to a recursion interrupt, stack space is very limited so better save every byte. https://swing.fit.cvut.cz/projects/stx-jv/ticket/186
WinWorkstation.st
--- a/WinWorkstation.st	Tue Nov 21 15:29:42 2017 +0000
+++ b/WinWorkstation.st	Fri Dec 08 09:10:33 2017 +0000
@@ -18776,7 +18776,16 @@
      a different process is currently active - in this case the title bar/icon is flashed.
      this also raises the priority of the sending thread slightly"
 
-    <apicall: bool "SetForegroundWindow" (handle) module: "user32.dll" >
+%{  /* NOCONTEXT */
+    if (__isExternalAddress(aWindowId)) {
+        HWND win = _HWNDVal(aWindowId);
+
+        if (win) {
+            SetForegroundWindow(win);            
+        }
+        RETURN ( self );
+    }
+%}
 !
 
 setIconName:aString in:aWindowId