WinWorkstation.st
branchjv
changeset 7311 9ca5a89f4805
parent 7255 cf03c45d3311
parent 7303 67a76c07b757
child 7312 e69b73023aea
--- a/WinWorkstation.st	Wed Apr 20 09:06:30 2016 +0100
+++ b/WinWorkstation.st	Thu Apr 21 08:01:58 2016 +0100
@@ -11,6 +11,8 @@
 "
 "{ Package: 'stx:libview' }"
 
+"{ NameSpace: Smalltalk }"
+
 DeviceWorkstation subclass:#WinWorkstation
 	instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
 		eventTrace eventBuffer lastClipboardSequenceNumber'
@@ -75,6 +77,7 @@
 #define xxBEEP_IN_WINTHREAD    /* */
 #define xxKEEP_STD_CURSORS     /* not useful - those are allocated only once, in any case */
 #define xxHANDLE_VIEWGRAVITY   /* not yet working */
+#define HANDLE_DEVICE_EVENTS
 #define COMPRESS_WINDOWPOSCHANGED
 
 #define USE_DRAW_MUTEX
@@ -184,11 +187,19 @@
 # define NOCRYPT
 # define NOMCX
 # define WIN32_LEAN_AND_MEAN
+# ifndef _WIN32_WINNT
+#  define _WIN32_WINNT 0x0500    /* need this to get certain defines from winuser.h (WM_NCXBUTTONDOWN) */
+# endif
 # include <windows.h>
 # include <shellapi.h>
+# ifdef HANDLE_DEVICE_EVENTS
+#  include <dbt.h>
+# endif
 # include <sys\timeb.h>
 # include <dir.h>
-#else
+
+#else
+
 # define _USERENTRY /**/
 # define NOATOM
 # define NOGDICAPMASKS
@@ -202,12 +213,17 @@
 # define NOCRYPT
 # define NOMCX
 # define WIN32_LEAN_AND_MEAN
-# define WINVER 0x0500    /* need this to get certain defines from winuser.h (WM_NCXBUTTONDOWN) */
-# undef WINVER
-# define WINVER 0x0501    /* need this to get AW_XXX defines from winuser.h */
+# ifndef _WIN32_WINNT
+#  define _WIN32_WINNT 0x0500    /* need this to get certain defines from winuser.h (WM_NCXBUTTONDOWN) */
+#  undef WINVER
+#  define WINVER 0x0501    /* need this to get AW_XXX defines from winuser.h */
+# endif
 
 
 # include <windows.h>
+# ifdef HANDLE_DEVICE_EVENTS
+#  include <dbt.h>
+# endif
 # include <shellapi.h>
 # include <sys\timeb.h>
 #endif
@@ -594,6 +610,8 @@
 # define UNHANDLED_EVENT_PRINTFIF(flag, x)    /* */
 #endif
 
+extern void __internalError(char *);
+
 /* # define EVENT_PRINTF(x)        { printf x;} */
 
 #define INFOFPRINTF(__x__)                 \
@@ -1201,8 +1219,7 @@
 #ifdef DEBUG_DELETEOBJECT
 
 static int
-_DeleteObject(o, lineNr)
-    HANDLE o;
+_DeleteObject(HANDLE o, int lineNr)
 {
     int r = DeleteObject(o);
 
@@ -1216,8 +1233,7 @@
 #endif
 
 static void
-_DeleteFont(f, lineNr)
-    HFONT f;
+_DeleteFont(HFONT f, int lineNr)
 {
 #ifdef CACHE_LAST_TMP_FONT
     if (f == __tmpDC_hfont) {
@@ -1229,8 +1245,7 @@
 }
 
 static int
-_DeleteBrush(br, lineNr)
-    HBRUSH br;
+_DeleteBrush(HBRUSH br, int lineNr)
 {
     int r;
 
@@ -1246,8 +1261,7 @@
 }
 
 static int
-_DeletePen(p, lineNr)
-    HPEN p;
+_DeletePen(HPEN p, int lineNr)
 {
     int r;
 
@@ -1265,8 +1279,7 @@
 #ifdef CACHE_PEN
 
 static int
-_DeletePenIfNotInCache(p, lineNr)
-    HPEN p;
+_DeletePenIfNotInCache(HPEN p, int lineNr)
 {
     int i, r;
 
@@ -1293,8 +1306,7 @@
 #ifdef CACHE_BRUSH
 
 static int
-_DeleteBrushIfNotInCache(br, lineNr)
-    HBRUSH br;
+_DeleteBrushIfNotInCache(HBRUSH br, int lineNr)
 {
     int i, r;
 
@@ -4534,6 +4546,13 @@
 	    UNHANDLED_EVENT_PRINTF(("WM_DEVICECHANGE\n"));
 	    break;
 
+	case DBT_DEVICEARRIVAL:
+	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEARRIVAL\n"));
+	    break;
+
+	case DBT_DEVICEREMOVECOMPLETE:
+	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEREMOVECOMPLETE\n"));
+	    break;
 #endif
 
 	default:
@@ -5332,6 +5351,8 @@
     "/ but are also needed to update my view colors when the settings change.
     "/ I dont know what exceed is doing there ...
     "/ IgnoreSysColorChanges := true.
+    IgnoreSysColorChanges := false.
+    SystemColorValues := IdentityDictionary new.
 
     "/ translation table from ST/X windowType symbol (system-independent)
     "/ to Windows windowClass (windows-specific).
@@ -6678,154 +6699,7 @@
     "retrieve a windows system color.
      The styleSheet/View classes may use this to setup default colors"
 
-    |rgb|
-
-%{
-    int p;
-    int __rgb, __bgr, r, g, b;
-
-    if (aKey == @symbol(COLOR_WINDOW)) {
-      p = COLOR_WINDOW;
-    } else if (aKey == @symbol(COLOR_WINDOWTEXT)) {
-      p = COLOR_WINDOWTEXT;
-    } else if (aKey == @symbol(COLOR_MENU)) {
-      p = COLOR_MENU;
-    } else if (aKey == @symbol(COLOR_MENUTEXT)) {
-      p = COLOR_MENUTEXT;
-    } else if (aKey == @symbol(COLOR_BTNFACE)) {
-      p = COLOR_BTNFACE;
-    } else if (aKey == @symbol(COLOR_BTNSHADOW)) {
-      p = COLOR_BTNSHADOW;
-    } else if (aKey == @symbol(COLOR_BTNTEXT)) {
-      p = COLOR_BTNTEXT;
-    } else if (aKey == @symbol(COLOR_GRAYTEXT)) {
-      p = COLOR_GRAYTEXT;
-    } else if (aKey == @symbol(COLOR_HIGHLIGHT)) {
-      p = COLOR_HIGHLIGHT;
-    } else if (aKey == @symbol(COLOR_HIGHLIGHTTEXT)) {
-      p = COLOR_HIGHLIGHTTEXT;
-    } else if (aKey == @symbol(COLOR_MENU)) {
-      p = COLOR_MENU;
-    } else if (aKey == @symbol(COLOR_MENUTEXT)) {
-      p = COLOR_MENUTEXT;
-    } else if (aKey == @symbol(COLOR_SCROLLBAR)) {
-      p = COLOR_SCROLLBAR;
-#ifdef COLOR_SHADOW
-    } else if (aKey == @symbol(COLOR_SHADOW)) {
-      p = COLOR_SHADOW;
-#endif
-#ifdef COLOR_BACKGROUND
-    } else if (aKey == @symbol(COLOR_BACKGROUND)) {
-      p = COLOR_BACKGROUND;
-#endif
-#ifdef COLOR_ACTIVECAPTION
-    } else if (aKey == @symbol(COLOR_ACTIVECAPTION)) {
-      p = COLOR_ACTIVECAPTION;
-#endif
-#ifdef COLOR_INACTIVECAPTION
-    } else if (aKey == @symbol(COLOR_INACTIVECAPTION)) {
-      p = COLOR_INACTIVECAPTION;
-#endif
-#ifdef COLOR_WINDOWFRAME
-    } else if (aKey == @symbol(COLOR_WINDOWFRAME)) {
-      p = COLOR_WINDOWFRAME;
-#endif
-#ifdef COLOR_CAPTIONTEXT
-    } else if (aKey == @symbol(COLOR_CAPTIONTEXT)) {
-      p = COLOR_CAPTIONTEXT;
-#endif
-#ifdef COLOR_ACTIVEBORDER
-    } else if (aKey == @symbol(COLOR_ACTIVEBORDER)) {
-      p = COLOR_ACTIVEBORDER;
-#endif
-#ifdef COLOR_INACTIVEBORDER
-    } else if (aKey == @symbol(COLOR_INACTIVEBORDER)) {
-      p = COLOR_INACTIVEBORDER;
-#endif
-#ifdef COLOR_APPWORKSPACE
-    } else if (aKey == @symbol(COLOR_APPWORKSPACE)) {
-      p = COLOR_APPWORKSPACE;
-#endif
-#ifdef COLOR_INACTIVECAPTIONTEXT
-    } else if (aKey == @symbol(COLOR_INACTIVECAPTIONTEXT)) {
-      p = COLOR_INACTIVECAPTIONTEXT;
-#endif
-#ifdef COLOR_BTNHIGHLIGHT
-    } else if (aKey == @symbol(COLOR_BTNHIGHLIGHT)) {
-      p = COLOR_BTNHIGHLIGHT;
-#endif
-#ifdef COLOR_3DDKSHADOW
-    } else if (aKey == @symbol(COLOR_3DDKSHADOW)) {
-      p = COLOR_3DDKSHADOW;
-#endif
-#ifdef COLOR_3DLIGHT
-    } else if (aKey == @symbol(COLOR_3DLIGHT)) {
-      p = COLOR_3DLIGHT;
-#endif
-#ifdef COLOR_INFOTEXT
-    } else if (aKey == @symbol(COLOR_INFOTEXT)) {
-      p = COLOR_INFOTEXT;
-#endif
-#ifdef COLOR_INFOBK
-    } else if (aKey == @symbol(COLOR_INFOBK)) {
-      p = COLOR_INFOBK;
-#endif
-#ifdef COLOR_HOTLIGHT
-    } else if (aKey == @symbol(COLOR_HOTLIGHT)) {
-      p = COLOR_HOTLIGHT;
-#endif
-#ifdef COLOR_GRADIENTACTIVECAPTION
-    } else if (aKey == @symbol(COLOR_GRADIENTACTIVECAPTION)) {
-      p = COLOR_GRADIENTACTIVECAPTION;
-#endif
-#ifdef COLOR_GRADIENTINACTIVECAPTION
-    } else if (aKey == @symbol(COLOR_GRADIENTINACTIVECAPTION)) {
-      p = COLOR_GRADIENTINACTIVECAPTION;
-#endif
-#ifdef COLOR_DESKTOP
-    } else if (aKey == @symbol(COLOR_DESKTOP)) {
-      p = COLOR_DESKTOP;
-#endif
-#ifdef COLOR_3DFACE
-    } else if (aKey == @symbol(COLOR_3DFACE)) {
-      p = COLOR_3DFACE;
-#endif
-#ifdef COLOR_3DSHADOW
-    } else if (aKey == @symbol(COLOR_3DSHADOW)) {
-      p = COLOR_3DSHADOW;
-#endif
-#ifdef COLOR_3DHIGHLIGHT
-    } else if (aKey == @symbol(COLOR_3DHIGHLIGHT)) {
-      p = COLOR_3DHIGHLIGHT;
-#endif
-#ifdef COLOR_3DHILIGHT
-    } else if (aKey == @symbol(COLOR_3DHILIGHT)) {
-      p = COLOR_3DHILIGHT;
-#endif
-#ifdef COLOR_BTNHILIGHT
-    } else if (aKey == @symbol(COLOR_BTNHILIGHT)) {
-      p = COLOR_BTNHILIGHT;
-#endif
-    } else {
-      goto getOutOfHere;
-    }
-    __bgr = GetSysColor(p);
-
-    /* win uses BGR order */
-    r = __bgr & 0xFF;
-    g = (__bgr >> 8) & 0xFF;
-    b = (__bgr >> 16) & 0xFF;
-
-    __rgb = (((r << 8) | g) << 8) | b;
-    rgb = __MKSMALLINT(__rgb);
-getOutOfHere: ;
-%}.
-    rgb isNil ifTrue:[ ^ nil ].
-
-    ^ Color
-	redByte:((rgb bitShift:-16) bitAnd:16rFF)
-	greenByte:((rgb bitShift:-8) bitAnd:16rFF)
-	blueByte:(rgb bitAnd:16rFF)
+    ^ SystemColorValues at:aKey ifAbsentPut:[self primGetSystemColor:aKey].
 
     "
      Display getSystemColor:#COLOR_WINDOW
@@ -7256,6 +7130,167 @@
     "
 !
 
+primGetSystemColor:aKey
+    "retrieve a windows system color.
+     The styleSheet/View classes may use this to setup default colors"
+
+    |rgb|
+
+%{
+    int p;
+    int __rgb, __bgr, r, g, b;
+
+    if (aKey == @symbol(COLOR_WINDOW)) {
+      p = COLOR_WINDOW;
+    } else if (aKey == @symbol(COLOR_WINDOWTEXT)) {
+      p = COLOR_WINDOWTEXT;
+    } else if (aKey == @symbol(COLOR_MENU)) {
+      p = COLOR_MENU;
+    } else if (aKey == @symbol(COLOR_MENUTEXT)) {
+      p = COLOR_MENUTEXT;
+    } else if (aKey == @symbol(COLOR_BTNFACE)) {
+      p = COLOR_BTNFACE;
+    } else if (aKey == @symbol(COLOR_BTNSHADOW)) {
+      p = COLOR_BTNSHADOW;
+    } else if (aKey == @symbol(COLOR_BTNTEXT)) {
+      p = COLOR_BTNTEXT;
+    } else if (aKey == @symbol(COLOR_GRAYTEXT)) {
+      p = COLOR_GRAYTEXT;
+    } else if (aKey == @symbol(COLOR_HIGHLIGHT)) {
+      p = COLOR_HIGHLIGHT;
+    } else if (aKey == @symbol(COLOR_HIGHLIGHTTEXT)) {
+      p = COLOR_HIGHLIGHTTEXT;
+    } else if (aKey == @symbol(COLOR_MENU)) {
+      p = COLOR_MENU;
+    } else if (aKey == @symbol(COLOR_MENUTEXT)) {
+      p = COLOR_MENUTEXT;
+    } else if (aKey == @symbol(COLOR_SCROLLBAR)) {
+      p = COLOR_SCROLLBAR;
+#ifdef COLOR_SHADOW
+    } else if (aKey == @symbol(COLOR_SHADOW)) {
+      p = COLOR_SHADOW;
+#endif
+#ifdef COLOR_BACKGROUND
+    } else if (aKey == @symbol(COLOR_BACKGROUND)) {
+      p = COLOR_BACKGROUND;
+#endif
+#ifdef COLOR_ACTIVECAPTION
+    } else if (aKey == @symbol(COLOR_ACTIVECAPTION)) {
+      p = COLOR_ACTIVECAPTION;
+#endif
+#ifdef COLOR_INACTIVECAPTION
+    } else if (aKey == @symbol(COLOR_INACTIVECAPTION)) {
+      p = COLOR_INACTIVECAPTION;
+#endif
+#ifdef COLOR_WINDOWFRAME
+    } else if (aKey == @symbol(COLOR_WINDOWFRAME)) {
+      p = COLOR_WINDOWFRAME;
+#endif
+#ifdef COLOR_CAPTIONTEXT
+    } else if (aKey == @symbol(COLOR_CAPTIONTEXT)) {
+      p = COLOR_CAPTIONTEXT;
+#endif
+#ifdef COLOR_ACTIVEBORDER
+    } else if (aKey == @symbol(COLOR_ACTIVEBORDER)) {
+      p = COLOR_ACTIVEBORDER;
+#endif
+#ifdef COLOR_INACTIVEBORDER
+    } else if (aKey == @symbol(COLOR_INACTIVEBORDER)) {
+      p = COLOR_INACTIVEBORDER;
+#endif
+#ifdef COLOR_APPWORKSPACE
+    } else if (aKey == @symbol(COLOR_APPWORKSPACE)) {
+      p = COLOR_APPWORKSPACE;
+#endif
+#ifdef COLOR_INACTIVECAPTIONTEXT
+    } else if (aKey == @symbol(COLOR_INACTIVECAPTIONTEXT)) {
+      p = COLOR_INACTIVECAPTIONTEXT;
+#endif
+#ifdef COLOR_BTNHIGHLIGHT
+    } else if (aKey == @symbol(COLOR_BTNHIGHLIGHT)) {
+      p = COLOR_BTNHIGHLIGHT;
+#endif
+#ifdef COLOR_3DDKSHADOW
+    } else if (aKey == @symbol(COLOR_3DDKSHADOW)) {
+      p = COLOR_3DDKSHADOW;
+#endif
+#ifdef COLOR_3DLIGHT
+    } else if (aKey == @symbol(COLOR_3DLIGHT)) {
+      p = COLOR_3DLIGHT;
+#endif
+#ifdef COLOR_INFOTEXT
+    } else if (aKey == @symbol(COLOR_INFOTEXT)) {
+      p = COLOR_INFOTEXT;
+#endif
+#ifdef COLOR_INFOBK
+    } else if (aKey == @symbol(COLOR_INFOBK)) {
+      p = COLOR_INFOBK;
+#endif
+#ifdef COLOR_HOTLIGHT
+    } else if (aKey == @symbol(COLOR_HOTLIGHT)) {
+      p = COLOR_HOTLIGHT;
+#endif
+#ifdef COLOR_GRADIENTACTIVECAPTION
+    } else if (aKey == @symbol(COLOR_GRADIENTACTIVECAPTION)) {
+      p = COLOR_GRADIENTACTIVECAPTION;
+#endif
+#ifdef COLOR_GRADIENTINACTIVECAPTION
+    } else if (aKey == @symbol(COLOR_GRADIENTINACTIVECAPTION)) {
+      p = COLOR_GRADIENTINACTIVECAPTION;
+#endif
+#ifdef COLOR_DESKTOP
+    } else if (aKey == @symbol(COLOR_DESKTOP)) {
+      p = COLOR_DESKTOP;
+#endif
+#ifdef COLOR_3DFACE
+    } else if (aKey == @symbol(COLOR_3DFACE)) {
+      p = COLOR_3DFACE;
+#endif
+#ifdef COLOR_3DSHADOW
+    } else if (aKey == @symbol(COLOR_3DSHADOW)) {
+      p = COLOR_3DSHADOW;
+#endif
+#ifdef COLOR_3DHIGHLIGHT
+    } else if (aKey == @symbol(COLOR_3DHIGHLIGHT)) {
+      p = COLOR_3DHIGHLIGHT;
+#endif
+#ifdef COLOR_3DHILIGHT
+    } else if (aKey == @symbol(COLOR_3DHILIGHT)) {
+      p = COLOR_3DHILIGHT;
+#endif
+#ifdef COLOR_BTNHILIGHT
+    } else if (aKey == @symbol(COLOR_BTNHILIGHT)) {
+      p = COLOR_BTNHILIGHT;
+#endif
+    } else {
+      goto getOutOfHere;
+    }
+    __bgr = GetSysColor(p);
+
+    /* win uses BGR order */
+    r = __bgr & 0xFF;
+    g = (__bgr >> 8) & 0xFF;
+    b = (__bgr >> 16) & 0xFF;
+
+    __rgb = (((r << 8) | g) << 8) | b;
+    rgb = __MKSMALLINT(__rgb);
+getOutOfHere: ;
+%}.
+    rgb isNil ifTrue:[ ^ nil ].
+
+    ^ Color
+	redByte:((rgb bitShift:-16) bitAnd:16rFF)
+	greenByte:((rgb bitShift:-8) bitAnd:16rFF)
+	blueByte:(rgb bitAnd:16rFF)
+
+    "
+     Display getSystemColor:#COLOR_WINDOW
+     Display getSystemColor:#COLOR_HIGHLIGHT
+    "
+
+    "Modified: / 30-10-2007 / 15:06:02 / cg"
+!
+
 primViewIdFromPoint:aPoint in:windowId
     "given a point in rootWindow, return the viewId of the subview of windowId
      hit by this coordinate. Return nil if no view was hit.
@@ -8383,7 +8418,7 @@
     int isTopWindow = 0, isNativeWindow = 0, isMDIChild = 0;
     localWindowInfo *lI;
     static createWindowInfo cwi;
-    static nextSequenceNr = 1;
+    static int nextSequenceNr = 1;
     unsigned char* cp;
     HBITMAP        xBitMap, maskBitmap;
     HICON          xIcon = (HICON)0;
@@ -11582,35 +11617,34 @@
 
     |anyChange|
 
-    IgnoreSysColorChanges ~~ true ifTrue:[
-	"/ first check, if there was really a change
+    IgnoreSysColorChanges ifFalse:[
+	"/ first check, if there was really a change of any color that
+	"/ we are interested in
 	"/ (when exceed is running, we get plenty of those messages ...)
 
-	SystemColorValues isNil ifTrue:[
-	    SystemColorValues := IdentityDictionary new.
-	].
 	anyChange := false.
-	self supportedSystemColorKeys do:[:key |
-	    |oldValue newValue|
-
-	    oldValue := SystemColorValues at:key ifAbsent:nil.
-	    newValue := self getSystemColor:key.
-	    oldValue ~= newValue ifTrue:[
-		SystemColorValues at:key put:newValue.
+	SystemColorValues copy keysAndValuesDo:[:eachKey :eachOldColor|
+	    |newColor|
+
+	    newColor := self primGetSystemColor:eachKey.
+	    newColor ~= eachOldColor ifTrue:[
+		SystemColorValues at:eachKey put:newColor.
 		anyChange := true.
-	    ]
+	    ].
 	].
 	anyChange ifTrue:[
 	    "/ TODO: this should go through the sensor ...
 	    "/ ...and be handled as an event by the views thread.
 	    SimpleView readStyleSheetAndUpdateAllStyleCaches.
-	    aWindow withAllSubViewsDo:[:aView |
-		aView reinitStyle
+	    aWindow withAllSubViewsDo:[:eachView |
+		eachView reinitStyle
 	    ]
 	]
     ]
 
-    "Modified: / 08-09-2006 / 19:39:20 / cg"
+    "
+	Display systemColorChange:StandardSystemView new
+    "
 !
 
 trayAction:eventCode view:aView
@@ -13702,6 +13736,7 @@
 	int avgWidth;
 	HGDIOBJ hFont;
 	HGDIOBJ prevFont;
+	// TEXTMETRIC tmet;
 	TEXTMETRICW tmet;
 	OBJ t;
 
@@ -14226,7 +14261,8 @@
     {
 	struct gcData *gcData = _GCDATA(aGCId);
 	HGDIOBJ prevFont, hFont;
-	TEXTMETRIC tmet;
+	// TEXTMETRIC tmet;
+	TEXTMETRICW tmet;
 
 	hFont = _HGDIOBJVal(aFontId);
 	if (gcData->hFont != hFont) {
@@ -14244,7 +14280,7 @@
 	    prevFont = SelectObject(__tmpDC, hFont);
 #endif
 
-	    GetTextMetrics(__tmpDC, &tmet);
+	    GetTextMetricsW(__tmpDC, &tmet);
 	    gcData->fontAscent = tmet.tmAscent;
 #ifdef SUPERDEBUG
 	    if (__debug__) {
@@ -14728,7 +14764,10 @@
 
     if (firstInstance) {
 	OSVERSIONINFO osvi;
-	WNDCLASSW wc;
+	WNDCLASSW wc_stx;
+	WNDCLASSW wc_root;
+	WNDCLASSW wc_popup;
+	WNDCLASSW wc_dialog;
 	firstInstance = 0;
 	DPRINTF(("first create - registerClass\n"));
 
@@ -14773,76 +14812,76 @@
 	/*
 	 * register class: ST/X
 	 */
-	wc.style = 0
+	wc_stx.style = 0
 		   /* | CS_OWNDC */
 		   /* | CS_HREDRAW */
 		   /* | CS_VREDRAW */
 		  | CS_DBLCLKS;
-	wc.lpfnWndProc = (WNDPROC) MainWndProc;
-	wc.cbClsExtra = 0;
-	wc.cbWndExtra = N_WINDOW_PRIVATE;
-	wc.hInstance = (HANDLE) __getHInstance();
-	wc.hIcon = NULL;
-	wc.hCursor = 0;
-	wc.hbrBackground = 0;
-
-	wc.lpszMenuName =  NULL;
-	wc.lpszClassName = wapp_name;
-	RegisterClassW(&wc);
+	wc_stx.lpfnWndProc = (WNDPROC) MainWndProc;
+	wc_stx.cbClsExtra = 0;
+	wc_stx.cbWndExtra = N_WINDOW_PRIVATE;
+	wc_stx.hInstance = (HANDLE) __getHInstance();
+	wc_stx.hIcon = NULL;
+	wc_stx.hCursor = 0;
+	wc_stx.hbrBackground = 0;
+
+	wc_stx.lpszMenuName =  NULL;
+	wc_stx.lpszClassName = wapp_name;
+	RegisterClassW( (&wc_stx) );
 
 	/*
 	 * register class: ST/X:Root
 	 */
-	wc.style = 0;
-	wc.lpfnWndProc = (WNDPROC) MainWndProc;
-	wc.cbClsExtra = 0;
-	wc.cbWndExtra = N_WINDOW_PRIVATE;
-	wc.hInstance = (HANDLE) __getHInstance();
-	wc.hIcon = NULL;
-	wc.hCursor = 0;
-	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
-
-	wc.lpszMenuName =  NULL;
-	wc.lpszClassName = wapp_nameRoot;
-	RegisterClassW(&wc);
+	wc_root.style = 0;
+	wc_root.lpfnWndProc = (WNDPROC) MainWndProc;
+	wc_root.cbClsExtra = 0;
+	wc_root.cbWndExtra = N_WINDOW_PRIVATE;
+	wc_root.hInstance = (HANDLE) __getHInstance();
+	wc_root.hIcon = NULL;
+	wc_root.hCursor = 0;
+	wc_root.hbrBackground = GetStockObject(HOLLOW_BRUSH);
+
+	wc_root.lpszMenuName =  NULL;
+	wc_root.lpszClassName = wapp_nameRoot;
+	RegisterClassW( (CONST WNDCLASSW *)(&wc_root) );
 
 	/*
 	 * register class: ST/X:Popup
 	 */
-	wc.style = CS_SAVEBITS;
+	wc_popup.style = CS_SAVEBITS;
 	if (__isWinXP) {
 #ifndef CS_DROPSHADOW
 # define CS_DROPSHADOW    0x020000
 #endif
-	    wc.style |= CS_DROPSHADOW;
-	}
-	wc.lpfnWndProc = (WNDPROC) MainWndProc;;
-	wc.cbClsExtra = 0;
-	wc.cbWndExtra = N_WINDOW_PRIVATE;
-	wc.hInstance = (HANDLE) __getHInstance();
-	wc.hIcon = NULL;
-	wc.hCursor = 0;
-	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
-
-	wc.lpszMenuName =  NULL;
-	wc.lpszClassName = wapp_namePopup;
-	RegisterClassW(&wc);
+	    wc_popup.style |= CS_DROPSHADOW;
+	}
+	wc_popup.lpfnWndProc = (WNDPROC) MainWndProc;;
+	wc_popup.cbClsExtra = 0;
+	wc_popup.cbWndExtra = N_WINDOW_PRIVATE;
+	wc_popup.hInstance = (HANDLE) __getHInstance();
+	wc_popup.hIcon = NULL;
+	wc_popup.hCursor = 0;
+	wc_popup.hbrBackground = GetStockObject(HOLLOW_BRUSH);
+
+	wc_popup.lpszMenuName =  NULL;
+	wc_popup.lpszClassName = wapp_namePopup;
+	RegisterClassW( (CONST WNDCLASSW *)(&wc_popup) );
 
 	/*
 	 * register class: ST/X:Dialog
 	 */
-	wc.style = CS_SAVEBITS;
-	wc.lpfnWndProc = (WNDPROC) MainWndProc;;
-	wc.cbClsExtra = 0;
-	wc.cbWndExtra = N_WINDOW_PRIVATE;
-	wc.hInstance = (HANDLE) __getHInstance();
-	wc.hIcon = NULL;
-	wc.hCursor = 0;
-	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
-
-	wc.lpszMenuName =  NULL;
-	wc.lpszClassName = wapp_nameDialog;
-	RegisterClassW(&wc);
+	wc_dialog.style = CS_SAVEBITS;
+	wc_dialog.lpfnWndProc = (WNDPROC) MainWndProc;;
+	wc_dialog.cbClsExtra = 0;
+	wc_dialog.cbWndExtra = N_WINDOW_PRIVATE;
+	wc_dialog.hInstance = (HANDLE) __getHInstance();
+	wc_dialog.hIcon = NULL;
+	wc_dialog.hCursor = 0;
+	wc_dialog.hbrBackground = GetStockObject(HOLLOW_BRUSH);
+
+	wc_dialog.lpszMenuName =  NULL;
+	wc_dialog.lpszClassName = wapp_nameDialog;
+	RegisterClassW( (CONST WNDCLASSW *)(&wc_dialog) );
 
 	/*
 	 * generate my events
@@ -15738,6 +15777,7 @@
     char filterBuffer[1024*4] = "\0";
     BOOL __rslt;
     jmp_buf exitJmpBuf;
+    extern void __setAtExitLongJmp(jmp_buf);
 
     if (__isExternalAddress(ownerId)) {
 	hWndOwner = _HWNDVal(ownerId);
@@ -18361,23 +18401,6 @@
 %}
 !
 
-raiseWindowToTopMost:aWindowId
-    "bring a window to the very front - above all others (even above non-st/x windows).
-     Q: is this a windows-specific thing ?"
-
-%{  /* NOCONTEXT */
-
-    if (__isExternalAddress(aWindowId)) {
-	HWND hWnd = _HWNDVal(aWindowId);
-
-	if (hWnd) {
-	    CPRINTF(("raiseWindow %x\n",hWnd));
-	    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-	}
-    }
-%}
-!
-
 raiseWindowToTop:aWindowId
     "bring a window to the very front - above all others (even above non-st/x windows).
      Q: is this a windows-specific thing ?"
@@ -18414,6 +18437,23 @@
 %}
 !
 
+raiseWindowToTopMost:aWindowId
+    "bring a window to the very front - above all others (even above non-st/x windows).
+     Q: is this a windows-specific thing ?"
+
+%{  /* NOCONTEXT */
+
+    if (__isExternalAddress(aWindowId)) {
+	HWND hWnd = _HWNDVal(aWindowId);
+
+	if (hWnd) {
+	    CPRINTF(("raiseWindow %x\n",hWnd));
+	    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+	}
+    }
+%}
+!
+
 reparentWindow:windowId to:newParentWindowId
     "change a windows parent (an optional interface)"
 
@@ -19475,11 +19515,11 @@
 !WinWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.487 2014-11-19 16:06:55 sr Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.487 2014-11-19 16:06:55 sr Exp $'
+    ^ '$Header$'
 ! !