WinWorkstation.st
changeset 5570 33913e2520ac
parent 5554 17dce8b18c2e
child 5574 c5a18b1d05fa
--- a/WinWorkstation.st	Tue Jul 06 11:48:50 2010 +0200
+++ b/WinWorkstation.st	Tue Jul 06 14:11:33 2010 +0200
@@ -6981,51 +6981,51 @@
      isPrimary mName|
 %{
     if (__isExternalAddress(aMonitorId)) {
-        HMONITOR hMonitor = _HWNDVal(aMonitorId);
-        MONITORINFOEX info;
-
-        info.cbSize = sizeof(MONITORINFOEX);
-#if 0
-        static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
-
-        if (P_GetMonitorInfo == 0) {
-            HINSTANCE hUser = LoadLibrary("user32.dll");
-            // console_printf("hUser: %x\n", hUser);
-            if (hUser) {
-                P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
-                                    GetProcAddress(hUser, "GetMonitorInfo");
-            }
-        }
-        console_printf("P_GetMonitorInfo: %x\n", P_GetMonitorInfo);
-        if ((*P_GetMonitorInfo)(hMonitor, &info))
-#else
-        if (GetMonitorInfo(hMonitor, &info))
-#endif
-        {
-            // console_printf("l %d\n", info.rcMonitor.left);
-            screenL = __MKSMALLINT(info.rcMonitor.left);
-            screenT = __MKSMALLINT(info.rcMonitor.top);
-            screenR = __MKSMALLINT(info.rcMonitor.right);
-            screenB = __MKSMALLINT(info.rcMonitor.bottom);
-            workL = __MKSMALLINT(info.rcWork.left);
-            workT = __MKSMALLINT(info.rcWork.top);
-            workR = __MKSMALLINT(info.rcWork.right);
-            workB = __MKSMALLINT(info.rcWork.bottom);
-            isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
-            info.szDevice[31] = '\0';
-            mName = __MKSTRING(info.szDevice);
-        }
+	HMONITOR hMonitor = _HWNDVal(aMonitorId);
+	MONITORINFOEX info;
+
+	info.cbSize = sizeof(MONITORINFOEX);
+#if 0
+	static BOOL (__stdcall *P_GetMonitorInfo)(HMONITOR , MONITORINFOEX *);
+
+	if (P_GetMonitorInfo == 0) {
+	    HINSTANCE hUser = LoadLibrary("user32.dll");
+	    // console_printf("hUser: %x\n", hUser);
+	    if (hUser) {
+		P_GetMonitorInfo = (BOOL (__stdcall *)(HMONITOR, MONITORINFOEX * ))
+				    GetProcAddress(hUser, "GetMonitorInfo");
+	    }
+	}
+	console_printf("P_GetMonitorInfo: %x\n", P_GetMonitorInfo);
+	if ((*P_GetMonitorInfo)(hMonitor, &info))
+#else
+	if (GetMonitorInfo(hMonitor, &info))
+#endif
+	{
+	    // console_printf("l %d\n", info.rcMonitor.left);
+	    screenL = __MKSMALLINT(info.rcMonitor.left);
+	    screenT = __MKSMALLINT(info.rcMonitor.top);
+	    screenR = __MKSMALLINT(info.rcMonitor.right);
+	    screenB = __MKSMALLINT(info.rcMonitor.bottom);
+	    workL = __MKSMALLINT(info.rcWork.left);
+	    workT = __MKSMALLINT(info.rcWork.top);
+	    workR = __MKSMALLINT(info.rcWork.right);
+	    workB = __MKSMALLINT(info.rcWork.bottom);
+	    isPrimary = (info.dwFlags & MONITORINFOF_PRIMARY) ? true : false;
+	    info.szDevice[31] = '\0';
+	    mName = __MKSTRING(info.szDevice);
+	}
     }
 %}.
     screenL isNil ifTrue:[ ^ nil ].
 
     ^ MonitorInfo new
-        screenX:screenL screenY:screenT
-        screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
-        workX:workL workY:workT
-        workWidth:(workR-workL) workHeight:(workB-workT)
-        isPrimary:isPrimary
-        name:mName
+	screenX:screenL screenY:screenT
+	screenWidth:(screenR-screenL) screenHeight:(screenB-screenT)
+	workX:workL workY:workT
+	workWidth:(workR-workL) workHeight:(workB-workT)
+	isPrimary:isPrimary
+	name:mName
 
     "
      Screen current monitorInfoFor:(Screen current monitorHandleForView:(Transcript topView id))
@@ -7442,18 +7442,18 @@
     h := hSingle := self getSystemMetrics:#SM_CYFULLSCREEN.
 
     (self numberOfMonitors) > 1 ifTrue:[
-        w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
-        h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
-        (w isNil or:[h isNil]) ifTrue:[
-            "/ not supported under win95 and win-nt4 - fallback to real extent
-            w := wSingle.
-            h := hSingle.
-        ] ifFalse:[
-            dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
-            dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
-            w := w - dx.
-            h := h - dy - 8.
-        ].
+	w := self getSystemMetrics:#SM_CXVIRTUALSCREEN.
+	h := self getSystemMetrics:#SM_CYVIRTUALSCREEN.
+	(w isNil or:[h isNil]) ifTrue:[
+	    "/ not supported under win95 and win-nt4 - fallback to real extent
+	    w := wSingle.
+	    h := hSingle.
+	] ifFalse:[
+	    dx := (self getSystemMetrics:#SM_CXSCREEN) - wSingle.
+	    dy := (self getSystemMetrics:#SM_CYSCREEN) - hSingle.
+	    w := w - dx.
+	    h := h - dy - 8.
+	].
     ].
     ^ w @ h.
 
@@ -7472,14 +7472,14 @@
     "returns the usable height of the display (in pixels) at a given point
      Normally, the same as height, but may be smaller, in
      case some menu space is taken up by the window manager (windows).
-     On multi-display systems with different sized screens, this should care for 
+     On multi-display systems with different sized screens, this should care for
      which display is at the given x-position"
 
     |info|
 
     (self numberOfMonitors) > 1 ifTrue:[
-        info := self monitorInfoFor:(self monitorHandleForPoint:(aPoint max:(0@0))).
-        info notNil ifTrue:[ ^ info workHeight ].
+	info := self monitorInfoFor:(self monitorHandleForPoint:(aPoint max:(0@0))).
+	info notNil ifTrue:[ ^ info workHeight ].
     ].
     ^ self usableHeight
 
@@ -7885,75 +7885,75 @@
     unsigned char fastBits[10000];
 
     if (__bothSmallInteger(w, h) && __isNonNilObject(anArray)) {
-        b_width = __intVal(w);
-        b_height = __intVal(h);
-        bytesPerRowST = (b_width + 7) / 8;
-        bytesPerRowWN = ((b_width + 15) / 16) * 2;
-        padding = bytesPerRowWN - bytesPerRowST;
-
-        if ((padding == 0) && (__isByteArrayLike(anArray))) {
-            b_bits = __ByteArrayInstPtr(anArray)->ba_element;
-            cp = 0;
-        } else {
-            int nBytes = b_height * bytesPerRowWN;
-
-            if (nBytes < sizeof(fastBits)) {
-                cp = b_bits = fastBits;
-            } else {
-                cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
-                if (! cp) goto fail;
-            }
-        }
-        if (cp) {
-            if (__qIsArrayLike(anArray)) {
-                OBJ *op;
-
-                index = 1;
-                op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
-                for (row = b_height; row; row--) {
-                    for (col = bytesPerRowST; col; col--) {
-                        num = *op++;
-                        if (! __isSmallInteger(num))
-                            goto fail;
-                        *cp++ = __intVal(num);
-                    }
-                    cp += padding;
-                }
-            } else if (__qIsByteArrayLike(anArray)) {
-                unsigned char *pBits;
-
-                pBits = __ByteArrayInstPtr(anArray)->ba_element;
-                for (row = b_height; row; row--) {
-                    for (col = bytesPerRowST; col; col--) {
-                        *cp++ = ( *pBits++ /*^ 0xFF*/ );
-                    }
-                    cp += padding;
-                }
-            } else {
-                goto fail;
-            }
-        }
-        CPRINTF(("create bitmap ...\n"));
-
-        newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
-
-        if (newBitmapHandle ) {
+	b_width = __intVal(w);
+	b_height = __intVal(h);
+	bytesPerRowST = (b_width + 7) / 8;
+	bytesPerRowWN = ((b_width + 15) / 16) * 2;
+	padding = bytesPerRowWN - bytesPerRowST;
+
+	if ((padding == 0) && (__isByteArrayLike(anArray))) {
+	    b_bits = __ByteArrayInstPtr(anArray)->ba_element;
+	    cp = 0;
+	} else {
+	    int nBytes = b_height * bytesPerRowWN;
+
+	    if (nBytes < sizeof(fastBits)) {
+		cp = b_bits = fastBits;
+	    } else {
+		cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+		if (! cp) goto fail;
+	    }
+	}
+	if (cp) {
+	    if (__qIsArrayLike(anArray)) {
+		OBJ *op;
+
+		index = 1;
+		op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
+		for (row = b_height; row; row--) {
+		    for (col = bytesPerRowST; col; col--) {
+			num = *op++;
+			if (! __isSmallInteger(num))
+			    goto fail;
+			*cp++ = __intVal(num);
+		    }
+		    cp += padding;
+		}
+	    } else if (__qIsByteArrayLike(anArray)) {
+		unsigned char *pBits;
+
+		pBits = __ByteArrayInstPtr(anArray)->ba_element;
+		for (row = b_height; row; row--) {
+		    for (col = bytesPerRowST; col; col--) {
+			*cp++ = ( *pBits++ /*^ 0xFF*/ );
+		    }
+		    cp += padding;
+		}
+	    } else {
+		goto fail;
+	    }
+	}
+	CPRINTF(("create bitmap ...\n"));
+
+	newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
+
+	if (newBitmapHandle ) {
 #ifdef COUNT_BMP_RESOURCES
-            __cnt_bitmap++;
-            RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
-#endif
-            DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
-            if (allocatedBits) {
-                free(allocatedBits);
-            }
-            RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
-        }
+	    __cnt_bitmap++;
+	    RES_BMP_PRINTF(("CreateBitmap %x %d\n",newBitmapHandle,__cnt_bitmap));
+#endif
+	    DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
+	    if (allocatedBits) {
+		free(allocatedBits);
+	    }
+	    RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
+	}
     }
 fail: ;
     DDPRINTF(("create bitmap FAILED!!!\n"));
     if (allocatedBits) {
-        CPRINTF(("freeing up bitmap bits ...\n"));
-        free(allocatedBits);
+	CPRINTF(("freeing up bitmap bits ...\n"));
+	free(allocatedBits);
     }
     CPRINTF(("returning nil ...\n"));
     RETURN ( nil );
@@ -9621,12 +9621,12 @@
     "free Win32 data (and remove the drop-file)"
 %{
     if (__isExternalAddress(dropHandle)) {
-        HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
-
-        __externalAddressVal(dropHandle) = 0;
-        if (hDrop) {
-            DragFinish(hDrop);
-        }
+	HDROP hDrop = (HDROP)__externalAddressVal(dropHandle);
+
+	__externalAddressVal(dropHandle) = 0;
+	if (hDrop) {
+	    DragFinish(hDrop);
+	}
     }
 %}
 ! !
@@ -13279,7 +13279,9 @@
 	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
 	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
 	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
+	__PROTECT__(rawData);
 	t = __charSetSymbolFor(tmet.tmCharSet);
+	__UNPROTECT__(rawData);
 	__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
 
 	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
@@ -14944,31 +14946,31 @@
     pY := aPoint y.
 %{
     if (__bothSmallInteger(pX, pY)) {
-        POINT p;
-        HMONITOR hMonitor;
-        p.x = __intVal(pX);
-        p.y = __intVal(pY);
-#if 0
-        static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
-
-        if (P_MonitorFromPoint == 0) {
-            HINSTANCE hUser = LoadLibrary("user32.dll");
-            // console_printf("hUser: %x\n", hUser);
-            if (hUser) {
-                P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
-                                    GetProcAddress(hUser, "MonitorFromPoint");
-            }
-        }
-        // console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
-
-        hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
-#else
-        hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
-#endif
-        if (hMonitor == 0) {
-            RETURN(nil);
-        }
-        RETURN ( __MKEXTERNALADDRESS(hMonitor) );
+	POINT p;
+	HMONITOR hMonitor;
+	p.x = __intVal(pX);
+	p.y = __intVal(pY);
+#if 0
+	static HMONITOR (__stdcall *P_MonitorFromPoint)(POINT, int);
+
+	if (P_MonitorFromPoint == 0) {
+	    HINSTANCE hUser = LoadLibrary("user32.dll");
+	    // console_printf("hUser: %x\n", hUser);
+	    if (hUser) {
+		P_MonitorFromPoint = (HMONITOR (__stdcall *)(POINT, int ))
+				    GetProcAddress(hUser, "MonitorFromPoint");
+	    }
+	}
+	// console_printf("P_MonitorFromPoint: %x\n", P_MonitorFromPoint);
+
+	hMonitor = (*P_MonitorFromPoint)(p, MONITOR_DEFAULTTONULL);
+#else
+	hMonitor = MonitorFromPoint(p, MONITOR_DEFAULTTONULL);
+#endif
+	if (hMonitor == 0) {
+	    RETURN(nil);
+	}
+	RETURN ( __MKEXTERNALADDRESS(hMonitor) );
     }
 %}
     "
@@ -18876,11 +18878,11 @@
 !WinWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.422 2010-02-03 18:14:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.423 2010-07-06 12:11:33 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.422 2010-02-03 18:14:54 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.423 2010-07-06 12:11:33 cg Exp $'
 ! !
 
 WinWorkstation initialize!