WinWorkstation.st
changeset 4726 d3edd9f38237
parent 4713 199dbf1a1406
child 4727 5a4f88a6e58b
equal deleted inserted replaced
4725:c8896df7bd3f 4726:d3edd9f38237
   484 #define BlackPixel     RGB(0, 0, 0)
   484 #define BlackPixel     RGB(0, 0, 0)
   485 
   485 
   486 /* #undef DEBUG /* */
   486 /* #undef DEBUG /* */
   487 
   487 
   488 #ifdef DEBUG
   488 #ifdef DEBUG
   489 # define PRINTF(x)              { printf x;}
   489 # define PRINTF(x)              { console_printf x;}
   490 # define CPRINTF(x)             { if (__debug__ > 1) printf x;}
   490 # define CPRINTF(x)             { if (__debug__ > 1) console_printf x;}
   491 # define RESPRINTF(x)           /*{ if (__debug__) printf x;}*/
   491 # define RESPRINTF(x)           /*{ if (__debug__) console_printf x;}*/
   492 # define RES1PRINTF(x)          /*{ if (__debug__) printf x;}*/
   492 # define RES1PRINTF(x)          /*{ if (__debug__) console_printf x;}*/
   493 # define RES_BMP_PRINTF(x)      /*{ if (__debug__) printf x;}*/
   493 # define RES_BMP_PRINTF(x)      /*{ if (__debug__) console_printf x;}*/
   494 # define TH_DPRINTF(x)          /*{ if (__debug__) printf x;}*/
   494 # define TH_DPRINTF(x)          /*{ if (__debug__) console_printf x;}*/
   495 # define DPRINTF(x)             { if (__debug__) printf x;}
   495 # define DPRINTF(x)             { if (__debug__) console_printf x;}
   496 # define NDPRINTF(x)            { if (__debugNative__) printf x;}
   496 # define NDPRINTF(x)            { if (__debugNative__) console_printf x;}
   497 # define NDPRINTF2(x)           { if (__debugNative__ > 1) printf x;}
   497 # define NDPRINTF2(x)           { if (__debugNative__ > 1) console_printf x;}
   498 # define DDPRINTF(x)            { if (__debug__ > 1) printf x;}
   498 # define DDPRINTF(x)            { if (__debug__ > 1) console_printf x;}
   499 # define BMDPRINTF(x)           { if (__debug__ > 1) printf x;}
   499 # define BMDPRINTF(x)           { if (__debug__ > 1) console_printf x;}
   500 # define EVENT_PRINTF(x)        { if (__debug__) printf x;}
   500 # define EVENT_PRINTF(x)        { if (__debug__) console_printf x;}
   501 # define EVENT_PRINTF2(x)       { if (__debug__ > 1) printf x;}
   501 # define EVENT_PRINTF2(x)       { if (__debug__ > 1) console_printf x;}
   502 # define EVENT_PRINTF3(x)       /* */
   502 # define EVENT_PRINTF3(x)       /* */
   503 # define DPRINTFIF(flag, x)                 { if (flag && __debug__) printf x;}
   503 # define DPRINTFIF(flag, x)                 { if (flag && __debug__) console_printf x;}
   504 # define EVENT_PRINTFIF(flag, x)            { if (flag && __debug__) printf x;}
   504 # define EVENT_PRINTFIF(flag, x)            { if (flag && __debug__) console_printf x;}
   505 # define UNHANDLED_EVENT_PRINTF(x)          { if (__debug__) { printf("unhandled: "); printf x; } }
   505 # define UNHANDLED_EVENT_PRINTF(x)          { if (__debug__) { console_printf("unhandled: "); console_printf x; } }
   506 # define UNHANDLED_EVENT_PRINTFIF(flag, x)  { if (flag && __debug__) { printf("unhandled: "); printf x; } }
   506 # define UNHANDLED_EVENT_PRINTFIF(flag, x)  { if (flag && __debug__) { console_printf("unhandled: "); console_printf x; } }
   507 #else
   507 #else
   508 # define PRINTF(x)              /* */
   508 # define PRINTF(x)              /* */
   509 # define CPRINTF(x)             /* */
   509 # define CPRINTF(x)             /* */
   510 # define RES_BMP_PRINTF(x)      /* */
   510 # define RES_BMP_PRINTF(x)      /* */
   511 # define RESPRINTF(x)           /* */
   511 # define RESPRINTF(x)           /* */
   525 # define UNHANDLED_EVENT_PRINTFIF(x)    /* */
   525 # define UNHANDLED_EVENT_PRINTFIF(x)    /* */
   526 #endif
   526 #endif
   527 
   527 
   528 /* # define EVENT_PRINTF(x)        { printf x;} */
   528 /* # define EVENT_PRINTF(x)        { printf x;} */
   529 
   529 
   530 #define INFOPRINT(__x__)                 \
   530 #define INFOFPRINTF(__x__)                 \
   531     if (@global(InfoPrinting) == true) { \
   531     if (@global(InfoPrinting) == true) { \
   532 	fprintf __x__;           \
   532 	console_fprintf __x__;           \
   533     }
   533     }
   534 
   534 
   535 #define DEBUGPRINT(__x__)                 \
   535 #define DEBUGFPRINTF(__x__)                 \
   536     if (@global(InfoPrinting) == true) { \
   536     if (@global(InfoPrinting) == true) { \
   537 	fprintf __x__;           \
   537 	console_fprintf __x__;           \
   538     }
   538     }
   539 
   539 
   540 #define BR_SOLID       0
   540 #define BR_SOLID       0
   541 #define BR_PATTERN     1
   541 #define BR_PATTERN     1
   542 
   542 
   979 void __debugEvent__() {}
   979 void __debugEvent__() {}
   980 
   980 
   981 #ifdef DEBUGMASK
   981 #ifdef DEBUGMASK
   982 static void
   982 static void
   983 printMask(int mask) {
   983 printMask(int mask) {
   984 	if (mask & KeyPressMask)        printf("KeyPressMask\n");
   984 	if (mask & KeyPressMask)        console_printf("KeyPressMask\n");
   985 	if (mask & KeyReleaseMask)      printf("KeyReleaseMask\n");
   985 	if (mask & KeyReleaseMask)      console_printf("KeyReleaseMask\n");
   986 	if (mask & ButtonPressMask)     printf("ButtonPressMask\n");
   986 	if (mask & ButtonPressMask)     console_printf("ButtonPressMask\n");
   987 	if (mask & ButtonReleaseMask)   printf("ButtonReleaseMask\n");
   987 	if (mask & ButtonReleaseMask)   console_printf("ButtonReleaseMask\n");
   988 	if (mask & ButtonMotionMask)    printf("ButtonMotionMask\n");
   988 	if (mask & ButtonMotionMask)    console_printf("ButtonMotionMask\n");
   989 	if (mask & PointerMotionMask)   printf("PointerMotionMask\n");
   989 	if (mask & PointerMotionMask)   console_printf("PointerMotionMask\n");
   990 	if (mask & ExposureMask)        printf("ExposureMask\n");
   990 	if (mask & ExposureMask)        console_printf("ExposureMask\n");
   991 	if (mask & FocusChangeMask)     printf("FocusChangeMask\n");
   991 	if (mask & FocusChangeMask)     console_printf("FocusChangeMask\n");
   992 	if (mask & EnterWindowMask)     printf("EnterWindowMask\n");
   992 	if (mask & EnterWindowMask)     console_printf("EnterWindowMask\n");
   993 	if (mask & LeaveWindowMask)     printf("LeaveWindowMask\n");
   993 	if (mask & LeaveWindowMask)     console_printf("LeaveWindowMask\n");
   994 	if (mask & KeymapStateMask)     printf("KeymapStateMask\n");
   994 	if (mask & KeymapStateMask)     console_printf("KeymapStateMask\n");
   995 	if (mask & VisibilityChangeMask)printf("VisibilityChangeMask\n");
   995 	if (mask & VisibilityChangeMask)console_printf("VisibilityChangeMask\n");
   996 	if (mask & StructureNotifyMask) printf("StructureNotifyMask\n");
   996 	if (mask & StructureNotifyMask) console_printf("StructureNotifyMask\n");
   997 	if (mask & ResizeRedirectMask)  printf("ResizeRedirectMask\n");
   997 	if (mask & ResizeRedirectMask)  console_printf("ResizeRedirectMask\n");
   998 	if (mask & PropertyChangeMask)  printf("PropertyChangeMask\n");
   998 	if (mask & PropertyChangeMask)  console_printf("PropertyChangeMask\n");
   999 	if (mask & ColormapChangeMask)  printf("ColormapChangeMask\n");
   999 	if (mask & ColormapChangeMask)  console_printf("ColormapChangeMask\n");
  1000 }
  1000 }
  1001 #endif
  1001 #endif
  1002 
  1002 
  1003 static int
  1003 static int
  1004 st2RGB(color, gcData)
  1004 st2RGB(color, gcData)
  1094     HANDLE o;
  1094     HANDLE o;
  1095 {
  1095 {
  1096     int r = DeleteObject(o);
  1096     int r = DeleteObject(o);
  1097 
  1097 
  1098     if (r == 0)
  1098     if (r == 0)
  1099 	fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
  1099 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
  1100     return r;
  1100     return r;
  1101 }
  1101 }
  1102 
  1102 
  1103 #else
  1103 #else
  1104 # define _DeleteObject(o,lnr)  DeleteObject(o)
  1104 # define _DeleteObject(o,lnr)  DeleteObject(o)
  1126     if ((br != __whiteBrush)
  1126     if ((br != __whiteBrush)
  1127      && (br != __blackBrush)) {
  1127      && (br != __blackBrush)) {
  1128 	r = DeleteObject(br);
  1128 	r = DeleteObject(br);
  1129 
  1129 
  1130 	if (r == 0)
  1130 	if (r == 0)
  1131 	    fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
  1131 	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
  1132 	return r;
  1132 	return r;
  1133     }
  1133     }
  1134     return 1;
  1134     return 1;
  1135 }
  1135 }
  1136 
  1136 
  1143     if ((p != __whitePen)
  1143     if ((p != __whitePen)
  1144      && (p != __blackPen)) {
  1144      && (p != __blackPen)) {
  1145 	r = DeleteObject(p);
  1145 	r = DeleteObject(p);
  1146 
  1146 
  1147 	if (r == 0)
  1147 	if (r == 0)
  1148 	    fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
  1148 	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
  1149 	return r;
  1149 	return r;
  1150     }
  1150     }
  1151     return 1;
  1151     return 1;
  1152 }
  1152 }
  1153 
  1153 
  1169 	}
  1169 	}
  1170     }
  1170     }
  1171     r = DeleteObject(p);
  1171     r = DeleteObject(p);
  1172 
  1172 
  1173     if (r == 0)
  1173     if (r == 0)
  1174 	fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
  1174 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
  1175     return r;
  1175     return r;
  1176 }
  1176 }
  1177 
  1177 
  1178 #else
  1178 #else
  1179 # define _DeletePenIfNotInCache(p, lineNr)   _DeletePen(p, lineNr)
  1179 # define _DeletePenIfNotInCache(p, lineNr)   _DeletePen(p, lineNr)
  1197 	return 1; /* not deleted, but OK */
  1197 	return 1; /* not deleted, but OK */
  1198     }
  1198     }
  1199     r = DeleteObject(br);
  1199     r = DeleteObject(br);
  1200 
  1200 
  1201     if (r == 0)
  1201     if (r == 0)
  1202 	fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
  1202 	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
  1203     return r;
  1203     return r;
  1204 }
  1204 }
  1205 
  1205 
  1206 #else
  1206 #else
  1207 # define _DeleteBrushIfNotInCache(br, lineNr)   _DeleteBrush(br, lineNr)
  1207 # define _DeleteBrushIfNotInCache(br, lineNr)   _DeleteBrush(br, lineNr)
  1216 	gcDataFreeList = gcData->u.__nextFree;
  1216 	gcDataFreeList = gcData->u.__nextFree;
  1217 	gcDataNumFree--;
  1217 	gcDataNumFree--;
  1218     } else {
  1218     } else {
  1219 	gcData = (struct gcData *) malloc(sizeof(struct gcData));
  1219 	gcData = (struct gcData *) malloc(sizeof(struct gcData));
  1220 	if (! gcData) {
  1220 	if (! gcData) {
  1221 	    fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
  1221 	    console_fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
  1222 	    return 0;
  1222 	    return 0;
  1223 	}
  1223 	}
  1224     }
  1224     }
  1225 
  1225 
  1226     memset(gcData, 0, sizeof(struct gcData));
  1226     memset(gcData, 0, sizeof(struct gcData));
  1315 	    ReleaseDC(gcData->hWnd, hDC);
  1315 	    ReleaseDC(gcData->hWnd, hDC);
  1316 #ifdef CACHE_LAST_WM_PAINT_DC
  1316 #ifdef CACHE_LAST_WM_PAINT_DC
  1317 	    if (hDC == last_wm_paint_dc) {
  1317 	    if (hDC == last_wm_paint_dc) {
  1318 		last_wm_paint_dc = last_wm_paint_win = 0;
  1318 		last_wm_paint_dc = last_wm_paint_win = 0;
  1319 # ifdef DEBUG_DC_REUSE
  1319 # ifdef DEBUG_DC_REUSE
  1320 		fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
  1320 		console_fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
  1321 # endif
  1321 # endif
  1322 	    }
  1322 	    }
  1323 #endif
  1323 #endif
  1324 	}
  1324 	}
  1325     } else if (gcData->hBitmap) {
  1325     } else if (gcData->hBitmap) {
  1366 	 && (lastGcHWIN == gcData->hWnd)
  1366 	 && (lastGcHWIN == gcData->hWnd)
  1367 	 && (lastGcHBITMAP == gcData->hBitmap)
  1367 	 && (lastGcHBITMAP == gcData->hBitmap)
  1368 	 && (lastGcOwnerThreadID == currThreadId)
  1368 	 && (lastGcOwnerThreadID == currThreadId)
  1369 	 && gcData->_hDC
  1369 	 && gcData->_hDC
  1370 	) {
  1370 	) {
  1371 	    //printf(".");
       
  1372 
       
  1373 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1371 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1374 	    if (last_wm_paint_dc == gcData->_hDC) {
  1372 	    if (last_wm_paint_dc == gcData->_hDC) {
  1375 #  ifdef DEBUG_DC_REUSE
  1373 #  ifdef DEBUG_DC_REUSE
  1376 		fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1374 		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1377 #  endif
  1375 #  endif
  1378 		last_wm_paint_dc = last_wm_paint_win = 0;
  1376 		last_wm_paint_dc = last_wm_paint_win = 0;
  1379 	    }
  1377 	    }
  1380 # endif
  1378 # endif
  1381 	    return gcData->_hDC;
  1379 	    return gcData->_hDC;
  1418 	if (gcData->clipping) {
  1416 	if (gcData->clipping) {
  1419 	    HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
  1417 	    HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
  1420 					 gcData->clipX + gcData->clipW,
  1418 					 gcData->clipX + gcData->clipW,
  1421 					 gcData->clipY + gcData->clipH);
  1419 					 gcData->clipY + gcData->clipH);
  1422 	    if (region == NULL ) {
  1420 	    if (region == NULL ) {
  1423 		fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
  1421 		console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
  1424 	    } else {
  1422 	    } else {
  1425 		if (SelectClipRgn(hDC, region) == ERROR ) {
  1423 		if (SelectClipRgn(hDC, region) == ERROR ) {
  1426 		    DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
  1424 		    DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
  1427 		}
  1425 		}
  1428 		_DeleteObject(region, __LINE__);
  1426 		_DeleteObject(region, __LINE__);
  1450     gcData->_hDC = hDC;
  1448     gcData->_hDC = hDC;
  1451 
  1449 
  1452 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1450 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
  1453     if (last_wm_paint_dc == hDC) {
  1451     if (last_wm_paint_dc == hDC) {
  1454 #  ifdef DEBUG_DC_REUSE
  1452 #  ifdef DEBUG_DC_REUSE
  1455 	fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1453 	console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  1456 #  endif
  1454 #  endif
  1457 	last_wm_paint_dc = last_wm_paint_win = 0;
  1455 	last_wm_paint_dc = last_wm_paint_win = 0;
  1458     }
  1456     }
  1459 # endif
  1457 # endif
  1460 #endif
  1458 #endif
  1809     DWORD dwWaitResult = WaitForSingleObject(hEventsMutex, 5000L);
  1807     DWORD dwWaitResult = WaitForSingleObject(hEventsMutex, 5000L);
  1810 
  1808 
  1811 #ifdef LOCK_DEBUG
  1809 #ifdef LOCK_DEBUG
  1812     lockCountEvents++;
  1810     lockCountEvents++;
  1813     if (lockCountEvents != 1) {
  1811     if (lockCountEvents != 1) {
  1814 	fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
  1812 	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
  1815 	lockCountEvents = 1;
  1813 	lockCountEvents = 1;
  1816     }
  1814     }
  1817 #endif
  1815 #endif
  1818 
  1816 
  1819     switch (dwWaitResult) {
  1817     switch (dwWaitResult) {
  1820 	case WAIT_OBJECT_0:
  1818 	case WAIT_OBJECT_0:
  1821 	    hEventsMutexOwner = whoIsLocking;
  1819 	    hEventsMutexOwner = whoIsLocking;
  1822 	    return (TRUE);
  1820 	    return (TRUE);
  1823 
  1821 
  1824 	case WAIT_ABANDONED:
  1822 	case WAIT_ABANDONED:
  1825 	    fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
  1823 	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
  1826 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
  1824 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
  1827 	    hEventsMutexOwner = whoIsLocking;
  1825 	    hEventsMutexOwner = whoIsLocking;
  1828 	    return (TRUE);
  1826 	    return (TRUE);
  1829 
  1827 
  1830 	case WAIT_TIMEOUT:
  1828 	case WAIT_TIMEOUT:
  1831 	    fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
  1829 	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
  1832 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
  1830 			(hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
  1833 	    break;
  1831 	    break;
  1834 
  1832 
  1835 	default:
  1833 	default:
  1836 	    {
  1834 	    {
  1837 		unsigned errCode = GetLastError();
  1835 		unsigned errCode = GetLastError();
  1838 
  1836 
  1839 		fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
  1837 		console_fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
  1840 			    (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
  1838 			    (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
  1841 			    dwWaitResult, errCode );
  1839 			    dwWaitResult, errCode );
  1842 	    }
  1840 	    }
  1843 	    break;
  1841 	    break;
  1844     }
  1842     }
  1848 static int
  1846 static int
  1849 unlockEvents() {
  1847 unlockEvents() {
  1850 #ifdef LOCK_DEBUG
  1848 #ifdef LOCK_DEBUG
  1851     lockCountEvents--;
  1849     lockCountEvents--;
  1852     if (lockCountEvents != 0) {
  1850     if (lockCountEvents != 0) {
  1853 	fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
  1851 	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
  1854 	lockCountEvents = 0;
  1852 	lockCountEvents = 0;
  1855     }
  1853     }
  1856 #endif
  1854 #endif
  1857     if (! ReleaseMutex(hEventsMutex)) {
  1855     if (! ReleaseMutex(hEventsMutex)) {
  1858        fprintf(stderr, "WinWorkstation [error]: unlockEvent error\n");
  1856        console_fprintf(stderr, "WinWorkstation [error]: unlockEvent error\n");
  1859        return (FALSE);
  1857        return (FALSE);
  1860     }
  1858     }
  1861     hEventsMutexOwner = NULL;
  1859     hEventsMutexOwner = NULL;
  1862 
  1860 
  1863     return (TRUE);
  1861     return (TRUE);
  1869     struct queuedEvent *bulk;
  1867     struct queuedEvent *bulk;
  1870     int i;
  1868     int i;
  1871 
  1869 
  1872     bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ);
  1870     bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ);
  1873     if (bulk == 0) {
  1871     if (bulk == 0) {
  1874 	fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
  1872 	console_fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
  1875 	return 0;
  1873 	return 0;
  1876     }
  1874     }
  1877     for (i=1; i<EV_CHUNK_CNT; i++) {
  1875     for (i=1; i<EV_CHUNK_CNT; i++) {
  1878 	bulk[i-1].ev_next = &(bulk[i]);
  1876 	bulk[i-1].ev_next = &(bulk[i]);
  1879     }
  1877     }
  1901     /* get an event struct
  1899     /* get an event struct
  1902     */
  1900     */
  1903     while (! eventFreeList) {
  1901     while (! eventFreeList) {
  1904 	if (repeatCount++ >= 5) {
  1902 	if (repeatCount++ >= 5) {
  1905 	    /* throw away sorry */
  1903 	    /* throw away sorry */
  1906 	    fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1904 	    console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1907 	    return;
  1905 	    return;
  1908 	}
  1906 	}
  1909 	fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
  1907 	console_fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
  1910 	WaitForSingleObject( hNeverTriggered, 100L );
  1908 	WaitForSingleObject( hNeverTriggered, 100L );
  1911     }
  1909     }
  1912     if (! lockEvents("enqEvent")) {
  1910     if (! lockEvents("enqEvent")) {
  1913 	fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
  1911 	console_fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
  1914 	return;
  1912 	return;
  1915     }
  1913     }
  1916 
  1914 
  1917     ev = eventFreeList;
  1915     ev = eventFreeList;
  1918 
  1916 
  1919     if (! ev) {
  1917     if (! ev) {
  1920 	fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1918 	console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
  1921 	unlockEvents();
  1919 	unlockEvents();
  1922 	return;
  1920 	return;
  1923     }
  1921     }
  1924     eventFreeList  = ev->ev_next;
  1922     eventFreeList  = ev->ev_next;
  1925     ev->ev_flag    = flag;
  1923     ev->ev_flag    = flag;
  1990     if (ev->count != -1) {
  1988     if (ev->count != -1) {
  1991 	static int anyGoodEventReceived = 1;
  1989 	static int anyGoodEventReceived = 1;
  1992 
  1990 
  1993 	if (eventempfcount != ev->count) {
  1991 	if (eventempfcount != ev->count) {
  1994 	    if (anyGoodEventReceived) {
  1992 	    if (anyGoodEventReceived) {
  1995 		fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
  1993 		console_fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
  1996 				 eventempfcount, ev->count);
  1994 				 eventempfcount, ev->count);
  1997 	    }
  1995 	    }
  1998 	    eventempfcount = ev->count;
  1996 	    eventempfcount = ev->count;
  1999 	    anyGoodEventReceived = 0;
  1997 	    anyGoodEventReceived = 0;
  2000 	} else {
  1998 	} else {
  2018 
  2016 
  2019 FALSCH: nochmals in QUEUE -> (ev_arg2 != 0) arg2 freed !!!
  2017 FALSCH: nochmals in QUEUE -> (ev_arg2 != 0) arg2 freed !!!
  2020 
  2018 
  2021 	if (ev->ev_arg1) {
  2019 	if (ev->ev_arg1) {
  2022 	    if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
  2020 	    if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
  2023 		/*printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
  2021 		/*console_printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
  2024 
  2022 
  2025 	    } else {
  2023 	    } else {
  2026 		/* noch einmal in die queue
  2024 		/* noch einmal in die queue
  2027 		*/
  2025 		*/
  2028 		if (ev->ev_arg2++ < 100) {
  2026 		if (ev->ev_arg2++ < 100) {
  2041 			free (freeArg2);
  2039 			free (freeArg2);
  2042 			freeArg2 = NULL;
  2040 			freeArg2 = NULL;
  2043 		    }
  2041 		    }
  2044 
  2042 
  2045 		    if (ev->ev_arg2 > 98) {
  2043 		    if (ev->ev_arg2 > 98) {
  2046 			fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
  2044 			console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
  2047 			sleep(1);
  2045 			sleep(1);
  2048 		    } else {
  2046 		    } else {
  2049 			sleep(0);
  2047 			sleep(0);
  2050 		    }
  2048 		    }
  2051 		    goto again;
  2049 		    goto again;
  2052 		}
  2050 		}
  2053 		/* fail evtl. später ändern und in st verzögert aufrufen
  2051 		/* fail evtl. später ändern und in st verzögert aufrufen
  2054 		*/
  2052 		*/
  2055 		fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
  2053 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
  2056 	    }
  2054 	    }
  2057 	    free((char*)ev->ev_arg1);
  2055 	    free((char*)ev->ev_arg1);
  2058 	    ev->ev_arg1 = 0;
  2056 	    ev->ev_arg1 = 0;
  2059 	}
  2057 	}
  2060 #endif
  2058 #endif
  2090 	} else {
  2088 	} else {
  2091 	    if (last_wm_paint_dc) {
  2089 	    if (last_wm_paint_dc) {
  2092 #  ifdef CACHE_LAST_DC
  2090 #  ifdef CACHE_LAST_DC
  2093 		if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
  2091 		if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
  2094 #   ifdef DEBUG_DC_REUSE
  2092 #   ifdef DEBUG_DC_REUSE
  2095 		    fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
  2093 		    console_fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
  2096 #   endif
  2094 #   endif
  2097 		    _releaseDC(lastGcData);
  2095 		    _releaseDC(lastGcData);
  2098 		} else {
  2096 		} else {
  2099 		    ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2097 		    ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
  2100 		}
  2098 		}
  2111 # endif /* CACHE_LAST_WM_PAINT_DC */
  2109 # endif /* CACHE_LAST_WM_PAINT_DC */
  2112 
  2110 
  2113 # ifdef CACHE_LAST_DC
  2111 # ifdef CACHE_LAST_DC
  2114 	if (lastGcData && (lastGcData->_hDC == dc)) {
  2112 	if (lastGcData && (lastGcData->_hDC == dc)) {
  2115 #  ifdef DEBUG_DC_REUSE
  2113 #  ifdef DEBUG_DC_REUSE
  2116 	    fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  2114 	    console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
  2117 #  endif
  2115 #  endif
  2118 	    if ((lastGcData->rop2 != R2_COPYPEN)
  2116 	    if ((lastGcData->rop2 != R2_COPYPEN)
  2119 	     || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
  2117 	     || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
  2120 		fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
  2118 		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
  2121 	    }
  2119 	    }
  2122 	    lastGcData = 0;
  2120 	    lastGcData = 0;
  2123 	}
  2121 	}
  2124 # endif
  2122 # endif
  2125 
  2123 
  2150 	    isPrivateBrush = 1;
  2148 	    isPrivateBrush = 1;
  2151 # endif
  2149 # endif
  2152 	}
  2150 	}
  2153 
  2151 
  2154 	if (! br) {
  2152 	if (! br) {
  2155 	    fprintf(stderr, "WinWorkstation [info]: no brush\n");
  2153 	    console_fprintf(stderr, "WinWorkstation [info]: no brush\n");
  2156 	}
  2154 	}
  2157 
  2155 
  2158 	if (br) {
  2156 	if (br) {
  2159 	    int i;
  2157 	    int i;
  2160 
  2158 
  2243 	    /* updateRect = ps.rcPaint;   */
  2241 	    /* updateRect = ps.rcPaint;   */
  2244 	    EndPaint(hWnd, &ps);
  2242 	    EndPaint(hWnd, &ps);
  2245 #endif
  2243 #endif
  2246 	    switch (ret) {
  2244 	    switch (ret) {
  2247 		case ERROR:
  2245 		case ERROR:
  2248 		    fprintf(stderr, "WinWorkstation [info]: errregion\n");
  2246 		    console_fprintf(stderr, "WinWorkstation [info]: errregion\n");
  2249 		    return -1;
  2247 		    return -1;
  2250 		case NULLREGION:
  2248 		case NULLREGION:
  2251 		    DDPRINTF(("nullregion\n"));
  2249 		    DDPRINTF(("nullregion\n"));
  2252 		    _DeleteObject(updRgn, __LINE__);
  2250 		    _DeleteObject(updRgn, __LINE__);
  2253 		    return 0;
  2251 		    return 0;
  2442 
  2440 
  2443 	    newChildRct = oldChildRct;
  2441 	    newChildRct = oldChildRct;
  2444 	    switch (gravity) {
  2442 	    switch (gravity) {
  2445 #if 0
  2443 #if 0
  2446 		case GRAVITY_N:
  2444 		case GRAVITY_N:
  2447 		    fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
  2445 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
  2448 		    /*
  2446 		    /*
  2449 		     * shift to the bottom, for a constant
  2447 		     * shift to the bottom, for a constant
  2450 		     * distance from the bottom edge;
  2448 		     * distance from the bottom edge;
  2451 		     */
  2449 		     */
  2452 		    newChildRct.bottom += deltaH;
  2450 		    newChildRct.bottom += deltaH;
  2453 		    anyChange = 1;
  2451 		    anyChange = 1;
  2454 		    break;
  2452 		    break;
  2455 
  2453 
  2456 		case GRAVITY_W:
  2454 		case GRAVITY_W:
  2457 		    fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
  2455 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
  2458 		    /*
  2456 		    /*
  2459 		     * shift to the right, for a constant
  2457 		     * shift to the right, for a constant
  2460 		     * distance from the right edge;
  2458 		     * distance from the right edge;
  2461 		     */
  2459 		     */
  2462 		    newChildRct.right += deltaW;
  2460 		    newChildRct.right += deltaW;
  2463 		    anyChange = 1;
  2461 		    anyChange = 1;
  2464 		    break;
  2462 		    break;
  2465 #endif
  2463 #endif
  2466 		case GRAVITY_S:
  2464 		case GRAVITY_S:
  2467 		    fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
  2465 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
  2468 		    /*
  2466 		    /*
  2469 		     * shift to the bottom, for a constant
  2467 		     * shift to the bottom, for a constant
  2470 		     * distance from the bottom edge;
  2468 		     * distance from the bottom edge;
  2471 		     */
  2469 		     */
  2472 		    newChildRct.top += deltaH;
  2470 		    newChildRct.top += deltaH;
  2473 		    newChildRct.bottom  += deltaH;
  2471 		    newChildRct.bottom  += deltaH;
  2474 		    anyChange = 1;
  2472 		    anyChange = 1;
  2475 		    break;
  2473 		    break;
  2476 
  2474 
  2477 		case GRAVITY_E:
  2475 		case GRAVITY_E:
  2478 		    fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
  2476 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
  2479 		    /*
  2477 		    /*
  2480 		     * shift to the right, for a constant
  2478 		     * shift to the right, for a constant
  2481 		     * distance from the right edge;
  2479 		     * distance from the right edge;
  2482 		     */
  2480 		     */
  2483 		    newChildRct.right += deltaW;
  2481 		    newChildRct.right += deltaW;
  2484 		    newChildRct.left  += deltaW;
  2482 		    newChildRct.left  += deltaW;
  2485 		    anyChange = 1;
  2483 		    anyChange = 1;
  2486 		    break;
  2484 		    break;
  2487 
  2485 
  2488 		case GRAVITY_SE:
  2486 		case GRAVITY_SE:
  2489 		    fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
  2487 		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
  2490 		    /*
  2488 		    /*
  2491 		     * shift to the bottom-right, for a constant
  2489 		     * shift to the bottom-right, for a constant
  2492 		     * distance from the bottom-right edge;
  2490 		     * distance from the bottom-right edge;
  2493 		     */
  2491 		     */
  2494 		    newChildRct.right += deltaW;
  2492 		    newChildRct.right += deltaW;
  2506 	    if (anyChange) {
  2504 	    if (anyChange) {
  2507 		if ((newChildRct.left < 0)
  2505 		if ((newChildRct.left < 0)
  2508 		 || (newChildRct.top < 0)
  2506 		 || (newChildRct.top < 0)
  2509 		 || (newChildRct.right >= iP->newW)
  2507 		 || (newChildRct.right >= iP->newW)
  2510 		 || (newChildRct.bottom >= iP->newH)) {
  2508 		 || (newChildRct.bottom >= iP->newH)) {
  2511 		    fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
  2509 		    console_fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
  2512 				    newChildRct.left, newChildRct.top,
  2510 				    newChildRct.left, newChildRct.top,
  2513 				    newChildRct.right, newChildRct.bottom);
  2511 				    newChildRct.right, newChildRct.bottom);
  2514 		} else {
  2512 		} else {
  2515 		    fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
  2513 		    console_fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
  2516 				    oldChildRct.left, oldChildRct.top,
  2514 				    oldChildRct.left, oldChildRct.top,
  2517 				    oldChildRct.right, oldChildRct.bottom,
  2515 				    oldChildRct.right, oldChildRct.bottom,
  2518 				    newChildRct.left, newChildRct.top,
  2516 				    newChildRct.left, newChildRct.top,
  2519 				    newChildRct.right, newChildRct.bottom);
  2517 				    newChildRct.right, newChildRct.bottom);
  2520 
  2518 
  2600 						cwi->localWindowInfo
  2598 						cwi->localWindowInfo
  2601 					       );
  2599 					       );
  2602 
  2600 
  2603 			if (hwnd == NULL) {
  2601 			if (hwnd == NULL) {
  2604 			    cwi->errCode = GetLastError();
  2602 			    cwi->errCode = GetLastError();
  2605 			    fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
  2603 			    console_fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
  2606 						cwi->errCode, cwi->errCode, __LINE__);
  2604 						cwi->errCode, cwi->errCode, __LINE__);
  2607 			} else {
  2605 			} else {
  2608 			    SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
  2606 			    SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
  2609 #ifdef DEBUG /* PARANOIA */
  2607 #ifdef DEBUG /* PARANOIA */
  2610 			    if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
  2608 			    if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
  2611 			       fprintf(stderr, "lI-Error\n");
  2609 			       console_fprintf(stderr, "lI-Error\n");
  2612 			    }
  2610 			    }
  2613 #endif
  2611 #endif
  2614 			    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
  2612 			    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
  2615 					/* SWP_NOOWNERZORDER |*/
  2613 					/* SWP_NOOWNERZORDER |*/
  2616 					SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  2614 					SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  3733 		do {
  3731 		do {
  3734 		    hWndTemp = hWndChild;
  3732 		    hWndTemp = hWndChild;
  3735 		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  3733 		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  3736 		} while ((hWndChild) && (hWndChild != hWndTemp));
  3734 		} while ((hWndChild) && (hWndChild != hWndTemp));
  3737 
  3735 
  3738 		/*printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
  3736 		/*console_printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
  3739 		if (hWndChild /*&& (hWndChild != hWnd)*/) {
  3737 		if (hWndChild /*&& (hWndChild != hWnd)*/) {
  3740 		    if (hWndChild != __currentPointerView) {
  3738 		    if (hWndChild != __currentPointerView) {
  3741 			int modifiers;
  3739 			int modifiers;
  3742 
  3740 
  3743 			modifiers = getModifiers();
  3741 			modifiers = getModifiers();
  4447     MSG msg;
  4445     MSG msg;
  4448     localWindowInfo *lI;
  4446     localWindowInfo *lI;
  4449 
  4447 
  4450     _dispatchThreadId2 = GetCurrentThreadId();
  4448     _dispatchThreadId2 = GetCurrentThreadId();
  4451 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4449 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4452     fprintf(stderr, "WinWorkstation [info]: dispatchThreadID2=%x\n", _dispatchThreadId2);
  4450     console_fprintf(stderr, "WinWorkstation [info]: dispatchThreadID2=%x\n", _dispatchThreadId2);
  4453 #endif
  4451 #endif
  4454     TH_DPRINTF(("TS %d\n", th_calls++));
  4452     TH_DPRINTF(("TS %d\n", th_calls++));
  4455     PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);   /* must be */
  4453     PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);   /* must be */
  4456 
  4454 
  4457 #if 0
  4455 #if 0
  4458     if (AttachThreadInput(_masterThreadId, _dispatchThreadId2, TRUE) != TRUE) {
  4456     if (AttachThreadInput(_masterThreadId, _dispatchThreadId2, TRUE) != TRUE) {
  4459 	fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
  4457 	console_fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
  4460     };
  4458     };
  4461 #endif
  4459 #endif
  4462 #ifndef WIN32THREADS
  4460 #ifndef WIN32THREADS
  4463 # if 0
  4461 # if 0
  4464     SetThreadPriority(_masterThread,THREAD_PRIORITY_HIGHEST);
  4462     SetThreadPriority(_masterThread,THREAD_PRIORITY_HIGHEST);
  4479 				      0, 0,
  4477 				      0, 0,
  4480 				      rect.right - rect.left, rect.bottom - rect.top,
  4478 				      rect.right - rect.left, rect.bottom - rect.top,
  4481 				      0, 0, (HANDLE) __getHInstance(), lI);
  4479 				      0, 0, (HANDLE) __getHInstance(), lI);
  4482 
  4480 
  4483 #if 0
  4481 #if 0
  4484     printf("__rootWinSpezial %x\n",__rootWinSpezial);
  4482     console_printf("__rootWinSpezial %x\n",__rootWinSpezial);
  4485 #endif
  4483 #endif
  4486     //ShowWindow(__rootWinSpezial,SW_SHOWNOACTIVATE);
  4484     //ShowWindow(__rootWinSpezial,SW_SHOWNOACTIVATE);
  4487     SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4485     SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
  4488 		 SWP_NOSENDCHANGING |
  4486 		 SWP_NOSENDCHANGING |
  4489 		 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  4487 		 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
  4490 
  4488 
  4491 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4489 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
  4492     fprintf(stderr, "WinWorkstation [info]: setting ThreadRunningEvent\n");
  4490     console_fprintf(stderr, "WinWorkstation [info]: setting ThreadRunningEvent\n");
  4493 #endif
  4491 #endif
  4494     SetEvent(hDispatchThreadRunningEvent);
  4492     SetEvent(hDispatchThreadRunningEvent);
  4495 
  4493 
  4496     for (;;) {
  4494     for (;;) {
  4497 	HANDLE dummy;
  4495 	HANDLE dummy;
  4658 						    cwi->localWindowInfo
  4656 						    cwi->localWindowInfo
  4659 						   );
  4657 						   );
  4660 
  4658 
  4661 			    if (cwi->newWinHandle == NULL) {
  4659 			    if (cwi->newWinHandle == NULL) {
  4662 				cwi->errCode = GetLastError();
  4660 				cwi->errCode = GetLastError();
  4663 				fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
  4661 				console_fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
  4664 						cwi->className, cwi->errCode, cwi->errCode, __LINE__);
  4662 						cwi->className, cwi->errCode, cwi->errCode, __LINE__);
  4665 			    } else {
  4663 			    } else {
  4666 				SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
  4664 				SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
  4667 #ifdef DEBUG /* PARANOIA */
  4665 #ifdef DEBUG /* PARANOIA */
  4668 				if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
  4666 				if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
  4669 				   fprintf(stderr, "lI-Error\n");
  4667 				   console_fprintf(stderr, "lI-Error\n");
  4670 				}
  4668 				}
  4671 #endif
  4669 #endif
  4672 			    }
  4670 			    }
  4673 
  4671 
  4674 			    ev = cwi->hCreateEvent;
  4672 			    ev = cwi->hCreateEvent;
  6942 	    HWND hWnd = _HWNDVal(windowId);
  6940 	    HWND hWnd = _HWNDVal(windowId);
  6943 	    p.x = __intVal(xp);
  6941 	    p.x = __intVal(xp);
  6944 	    p.y = __intVal(yp);
  6942 	    p.y = __intVal(yp);
  6945 	    ScreenToClient(hWnd, &p);
  6943 	    ScreenToClient(hWnd, &p);
  6946 	    child_ret = ChildWindowFromPointEx(hWnd,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  6944 	    child_ret = ChildWindowFromPointEx(hWnd,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
  6947 	    /*printf("ChildWindow From %x Point %d.%d = %x\n",hWnd,p.x,p.y,child_ret);*/
  6945 	    /*console_printf("ChildWindow From %x Point %d.%d = %x\n",hWnd,p.x,p.y,child_ret);*/
  6948 	    if ((child_ret) && (child_ret != hWnd))
  6946 	    if ((child_ret) && (child_ret != hWnd))
  6949 	    {
  6947 	    {
  6950 		RETURN ( __MKEXTERNALADDRESS(child_ret) );
  6948 		RETURN ( __MKEXTERNALADDRESS(child_ret) );
  6951 	    }
  6949 	    }
  6952 	    RETURN ( nil );
  6950 	    RETURN ( nil );
  7388      (i.e. random). Return a bitmap id or nil"
  7386      (i.e. random). Return a bitmap id or nil"
  7389 
  7387 
  7390 %{
  7388 %{
  7391     HANDLE newBitmapHandle;
  7389     HANDLE newBitmapHandle;
  7392 
  7390 
  7393     /*printf("CreateBitmap Color\n");*/
  7391     /*console_printf("CreateBitmap Color\n");*/
  7394     if (__bothSmallInteger(w, h) && __isSmallInteger(d) && ISCONNECTED) {
  7392     if (__bothSmallInteger(w, h) && __isSmallInteger(d) && ISCONNECTED) {
  7395 	if (__intVal(d) == 1) {
  7393 	if (__intVal(d) == 1) {
  7396 	    newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
  7394 	    newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
  7397 	} else {
  7395 	} else {
  7398 #if 0
  7396 #if 0
  7399 	    if (__intVal(d) != __depth) {
  7397 	    if (__intVal(d) != __depth) {
  7400 		printf("invalid depth\n");
  7398 		console_printf("invalid depth\n");
  7401 		RETURN (nil);
  7399 		RETURN (nil);
  7402 	    }
  7400 	    }
  7403 #endif
  7401 #endif
  7404 	    newBitmapHandle = CreateCompatibleBitmap(__rootDC, __intVal(w), __intVal(h) );
  7402 	    newBitmapHandle = CreateCompatibleBitmap(__rootDC, __intVal(w), __intVal(h) );
  7405 	}
  7403 	}
  7566 %{
  7564 %{
  7567     if (__isExternalAddress(aGCId)) {
  7565     if (__isExternalAddress(aGCId)) {
  7568 	struct gcData *gcData = _GCDATA(aGCId);
  7566 	struct gcData *gcData = _GCDATA(aGCId);
  7569 
  7567 
  7570 	if (gcData == NULL) {
  7568 	if (gcData == NULL) {
  7571 	    fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n");
  7569 	    console_fprintf(stderr, "WinWorkstation [warning]: trying to destroy GC twice\n");
  7572 	    RETURN(self);
  7570 	    RETURN(self);
  7573 	}
  7571 	}
  7574 
  7572 
  7575 #ifdef COUNT_RESOURCES
  7573 #ifdef COUNT_RESOURCES
  7576 	 __cnt_gcData--;
  7574 	 __cnt_gcData--;
  8174 
  8172 
  8175     /*
  8173     /*
  8176      * check if previous request has been properly processed ...
  8174      * check if previous request has been properly processed ...
  8177      */
  8175      */
  8178     if (cwi.sequenceNr && (cwi.sequenceNr != INVALIDATED_CWI)) {
  8176     if (cwi.sequenceNr && (cwi.sequenceNr != INVALIDATED_CWI)) {
  8179 	fprintf(stderr, "WinWorkstation [info]: oops - unprocessed createWindow still pending\n");
  8177 	console_fprintf(stderr, "WinWorkstation [info]: oops - unprocessed createWindow still pending\n");
  8180 	/* this prevents the event processor from interpreting this message */
  8178 	/* this prevents the event processor from interpreting this message */
  8181 	cwi.sequenceNr = nextSequenceNr;
  8179 	cwi.sequenceNr = nextSequenceNr;
  8182     }
  8180     }
  8183 
  8181 
  8184     cwi.winStyleBitsEx = WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | winEXStyleBits;
  8182     cwi.winStyleBitsEx = WS_EX_LEFT | WS_EX_NOPARENTNOTIFY | winEXStyleBits;
  8196 		winStyleBits, winEXStyleBits));
  8194 		winStyleBits, winEXStyleBits));
  8197 
  8195 
  8198     /* allocate localMemory for Window */
  8196     /* allocate localMemory for Window */
  8199     lI = (localWindowInfo *) malloc(sizeof(localWindowInfo));
  8197     lI = (localWindowInfo *) malloc(sizeof(localWindowInfo));
  8200     if (! lI) {
  8198     if (! lI) {
  8201 	fprintf(stderr, "WinWorkstation [error]: malloc failed in CreateWindow\n");
  8199 	console_fprintf(stderr, "WinWorkstation [error]: malloc failed in CreateWindow\n");
  8202 	RETURN ( nil );
  8200 	RETURN ( nil );
  8203     }
  8201     }
  8204 
  8202 
  8205     memset(lI, 0, sizeof(localWindowInfo));
  8203     memset(lI, 0, sizeof(localWindowInfo));
  8206     lI->mouseX = lI->mouseY = -9999;
  8204     lI->mouseX = lI->mouseY = -9999;
  8326 	FALSE,
  8324 	FALSE,
  8327 	FALSE,
  8325 	FALSE,
  8328 	NULL);       /* name of mutex */
  8326 	NULL);       /* name of mutex */
  8329 
  8327 
  8330     if (cwi.hCreateEvent == NULL) {
  8328     if (cwi.hCreateEvent == NULL) {
  8331 	fprintf(stderr, "WinWorkstation [error]: oops - CreateEvent failed in CreateWindow: %d\n", GetLastError() );
  8329 	console_fprintf(stderr, "WinWorkstation [error]: oops - CreateEvent failed in CreateWindow: %d\n", GetLastError() );
  8332 	cwi.sequenceNr = INVALIDATED_CWI;
  8330 	cwi.sequenceNr = INVALIDATED_CWI;
  8333 	free(lI);
  8331 	free(lI);
  8334 	RETURN ( nil );
  8332 	RETURN ( nil );
  8335     }
  8333     }
  8336 #endif
  8334 #endif
  8337 
  8335 
  8338     /*
  8336     /*
  8339      * kludge to allow for createWindow while in sizeMove processing loop
  8337      * kludge to allow for createWindow while in sizeMove processing loop
  8340      */
  8338      */
  8341     if (pendingCREATEWINDOWInfo) {
  8339     if (pendingCREATEWINDOWInfo) {
  8342 	fprintf(stderr, "WinWorkstation [error]: oops - pending create\n");
  8340 	console_fprintf(stderr, "WinWorkstation [error]: oops - pending create\n");
  8343     }
  8341     }
  8344     pendingCREATEWINDOWInfo = &cwi;
  8342     pendingCREATEWINDOWInfo = &cwi;
  8345     pendingSequenceNr = cwi.sequenceNr;
  8343     pendingSequenceNr = cwi.sequenceNr;
  8346 
  8344 
  8347     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_CREATEWINDOW, cwi.sequenceNr, (INT)(&cwi)) == FALSE) {
  8345     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_CREATEWINDOW, cwi.sequenceNr, (INT)(&cwi)) == FALSE) {
  8348 	fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in CreateWindow: err=%d\n",
  8346 	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in CreateWindow: err=%d\n",
  8349 					_dispatchThreadId, GetLastError() );
  8347 					_dispatchThreadId, GetLastError() );
  8350 	free(lI);
  8348 	free(lI);
  8351 	RETURN (nil);
  8349 	RETURN (nil);
  8352     }
  8350     }
  8353 
  8351 
  8370 	    case WAIT_OBJECT_0:
  8368 	    case WAIT_OBJECT_0:
  8371 		break;
  8369 		break;
  8372 
  8370 
  8373 	    // Cannot get mutex ownership due to time-out.
  8371 	    // Cannot get mutex ownership due to time-out.
  8374 	    case WAIT_TIMEOUT:
  8372 	    case WAIT_TIMEOUT:
  8375 		DEBUGPRINT((stderr, "WinWorkstation [error]: oops - timeout in CreateWindow\n"));
  8373 		DEBUGFPRINTF((stderr, "WinWorkstation [error]: oops - timeout in CreateWindow\n"));
  8376 		break;
  8374 		break;
  8377 
  8375 
  8378 	    // Got ownership of the abandoned mutex object.
  8376 	    // Got ownership of the abandoned mutex object.
  8379 	    default:
  8377 	    default:
  8380 		DEBUGPRINT((stderr, "WinWorkstation [warning]: CreateEvent abandoned\n"));
  8378 		DEBUGFPRINTF((stderr, "WinWorkstation [warning]: CreateEvent abandoned\n"));
  8381 		break;
  8379 		break;
  8382 	}
  8380 	}
  8383 
  8381 
  8384 #ifdef NEW_CREATE_EVENT
  8382 #ifdef NEW_CREATE_EVENT
  8385 	CloseHandle(cwi.hCreateEvent);
  8383 	CloseHandle(cwi.hCreateEvent);
  8389     pendingCREATEWINDOWInfo = 0;
  8387     pendingCREATEWINDOWInfo = 0;
  8390     newWindowHandle = cwi.newWinHandle;
  8388     newWindowHandle = cwi.newWinHandle;
  8391     DPRINTF(("handle = %x\n", newWindowHandle));
  8389     DPRINTF(("handle = %x\n", newWindowHandle));
  8392 
  8390 
  8393     if (! newWindowHandle) {
  8391     if (! newWindowHandle) {
  8394 	fprintf(stderr, "WinWorkstation [error]: CreateWindow failed: %d (0x%x) [%d]\n",
  8392 	console_fprintf(stderr, "WinWorkstation [error]: CreateWindow failed: %d (0x%x) [%d]\n",
  8395 			cwi.errCode, cwi.errCode, __LINE__ );
  8393 			cwi.errCode, cwi.errCode, __LINE__ );
  8396 	if (cwi.infoWasRead) {
  8394 	if (cwi.infoWasRead) {
  8397 	    free(lI);
  8395 	    free(lI);
  8398 	} else {
  8396 	} else {
  8399 	    fprintf(stderr, "WinWorkstation [warning]: localInfo memory leak [%d]\n", __LINE__ );
  8397 	    console_fprintf(stderr, "WinWorkstation [warning]: localInfo memory leak [%d]\n", __LINE__ );
  8400 	}
  8398 	}
  8401 	RETURN ( nil );
  8399 	RETURN ( nil );
  8402     }
  8400     }
  8403 
  8401 
  8404 #ifdef CACHE_LAST_DC
  8402 #ifdef CACHE_LAST_DC
  8467 	    /* It has to be checked whether this can be deleted!!!!! */
  8465 	    /* It has to be checked whether this can be deleted!!!!! */
  8468 	    if ( oldIcon ) {
  8466 	    if ( oldIcon ) {
  8469 		if ( DestroyIcon( oldIcon )) {
  8467 		if ( DestroyIcon( oldIcon )) {
  8470 		    DPRINTF(( "Old icon deleted\n" ));
  8468 		    DPRINTF(( "Old icon deleted\n" ));
  8471 		} else {
  8469 		} else {
  8472 		    fprintf(stderr, "failed to destroy icon\n");
  8470 		    console_fprintf(stderr, "failed to destroy icon\n");
  8473 		}
  8471 		}
  8474 	    }
  8472 	    }
  8475 #endif
  8473 #endif
  8476 	   /*printf("post WM_THREAD_DESTROYWINDOW\n");*/
  8474 	   /*console_printf("post WM_THREAD_DESTROYWINDOW\n");*/
  8477 	    PostMessage(win, WM_THREAD_DESTROYWINDOW, 0, 0);
  8475 	    PostMessage(win, WM_THREAD_DESTROYWINDOW, 0, 0);
  8478 	}
  8476 	}
  8479     }
  8477     }
  8480 %}
  8478 %}
  8481 !
  8479 !
  8875     iB = (iB << 8) | iB;
  8873     iB = (iB << 8) | iB;
  8876 
  8874 
  8877     r = __MKSMALLINT(iR);
  8875     r = __MKSMALLINT(iR);
  8878     g = __MKSMALLINT(iG);
  8876     g = __MKSMALLINT(iG);
  8879     b = __MKSMALLINT(iB);
  8877     b = __MKSMALLINT(iB);
  8880     /*printf("get color %x -> %x/%x/%x\n",id, iR, iG, iB);*/
  8878     /*console_printf("get color %x -> %x/%x/%x\n",id, iR, iG, iB);*/
  8881 %}.
  8879 %}.
  8882     ^ aBlock value:r value:g value:b
  8880     ^ aBlock value:r value:g value:b
  8883 !
  8881 !
  8884 
  8882 
  8885 getScaledRGBFromName:colorName into:aBlock
  8883 getScaledRGBFromName:colorName into:aBlock
  9332 
  9330 
  9333 	fun = dstGcData->bitbltrop2;
  9331 	fun = dstGcData->bitbltrop2;
  9334 #if 0
  9332 #if 0
  9335 	switch (fun) {
  9333 	switch (fun) {
  9336 	  case BITBLT_COPY:
  9334 	  case BITBLT_COPY:
  9337 	    printf("BITBLT_COPY\n");
  9335 	    console_printf("BITBLT_COPY\n");
  9338 	    break;
  9336 	    break;
  9339 	  case BITBLT_COPYINVERTED:
  9337 	  case BITBLT_COPYINVERTED:
  9340 	    printf("BITBLT_COPYINVERTED\n");
  9338 	    console_printf("BITBLT_COPYINVERTED\n");
  9341 	    break;
  9339 	    break;
  9342 	  case BITBLT_XOR:
  9340 	  case BITBLT_XOR:
  9343 	    printf("BITBLT_XOR\n");
  9341 	    console_printf("BITBLT_XOR\n");
  9344 	    break;
  9342 	    break;
  9345 	  case BITBLT_AND:
  9343 	  case BITBLT_AND:
  9346 	    printf("BITBLT_AND\n");
  9344 	    console_printf("BITBLT_AND\n");
  9347 	    break;
  9345 	    break;
  9348 	  case BITBLT_OR:
  9346 	  case BITBLT_OR:
  9349 	    printf("BITBLT_OR\n");
  9347 	    console_printf("BITBLT_OR\n");
  9350 	    break;
  9348 	    break;
  9351 	}
  9349 	}
  9352 #endif
  9350 #endif
  9353 
  9351 
  9354 	/*
  9352 	/*
  9522 	     srcDC,
  9520 	     srcDC,
  9523 	     __intVal(srcX), __intVal(srcY),
  9521 	     __intVal(srcX), __intVal(srcY),
  9524 	     fun)
  9522 	     fun)
  9525 	   == 0
  9523 	   == 0
  9526 	  ) {
  9524 	  ) {
  9527 	    fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
  9525 	    console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
  9528 	}
  9526 	}
  9529 
  9527 
  9530 	if (dstGcData != srcGcData) {
  9528 	if (dstGcData != srcGcData) {
  9531 	    SetBkColor(dstDC, dstGcData->bgColor);
  9529 	    SetBkColor(dstDC, dstGcData->bgColor);
  9532 	    SetTextColor(dstDC, dstGcData->fgColor);
  9530 	    SetTextColor(dstDC, dstGcData->fgColor);
 10371 	    b_height = __intVal(h);
 10369 	    b_height = __intVal(h);
 10372 	    bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
 10370 	    bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
 10373 	    bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
 10371 	    bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
 10374 	    padding = bytesPerRowWN - bytesPerRowST;
 10372 	    padding = bytesPerRowWN - bytesPerRowST;
 10375 	    nBytes = b_height * bytesPerRowWN;
 10373 	    nBytes = b_height * bytesPerRowWN;
 10376 	    /*printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
 10374 	    /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
 10377 	    if (padding) {
 10375 	    if (padding) {
 10378 		if (nBytes < sizeof(fastBits)) {
 10376 		if (nBytes < sizeof(fastBits)) {
 10379 		    cp = b_bits = fastBits;
 10377 		    cp = b_bits = fastBits;
 10380 		} else {
 10378 		} else {
 10381 		    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
 10379 		    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
 10422 	bitmap.bmiHeader.biClrUsed = 0;
 10420 	bitmap.bmiHeader.biClrUsed = 0;
 10423 	bitmap.bmiHeader.biClrImportant = 0;
 10421 	bitmap.bmiHeader.biClrImportant = 0;
 10424 	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 10422 	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
 10425 	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 10423 	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
 10426 	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 10424 	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
 10427 	/*printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
 10425 	/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
 10428 	SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
 10426 	SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
 10429 			      __intVal(w), __intVal(h),
 10427 			      __intVal(w), __intVal(h),
 10430 			      __intVal(srcx), __intVal(srcy),
 10428 			      __intVal(srcx), __intVal(srcy),
 10431 			      0,__intVal(h),
 10429 			      0,__intVal(h),
 10432 			      (void *)b_bits,
 10430 			      (void *)b_bits,
 10786     eB = __INST(eventBuffer);
 10784     eB = __INST(eventBuffer);
 10787 
 10785 
 10788     if (__isByteArray(eB)) {
 10786     if (__isByteArray(eB)) {
 10789 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 10787 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 10790     } else {
 10788     } else {
 10791 	fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 10789 	console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 10792 	RETURN (false);
 10790 	RETURN (false);
 10793     }
 10791     }
 10794     if (ev) {
 10792     if (ev) {
 10795 	_ev_buf = *ev;
 10793 	_ev_buf = *ev;
 10796 	ev = &_ev_buf;
 10794 	ev = &_ev_buf;
 11027 		w = ev->ev_w;
 11025 		w = ev->ev_w;
 11028 		h = ev->ev_h;
 11026 		h = ev->ev_h;
 11029 		DPRINTF((">>> __WM_GEXPOSE -> gExpose %d/%d -> %d/%d\n", x, y, w, h));
 11027 		DPRINTF((">>> __WM_GEXPOSE -> gExpose %d/%d -> %d/%d\n", x, y, w, h));
 11030 #if 0
 11028 #if 0
 11031 		if (GetWindow_unmapping(hWnd)) {
 11029 		if (GetWindow_unmapping(hWnd)) {
 11032 		    fprintf(stderr, "oops - __WM_GEXPOSE for unmapping\n");
 11030 		    console_fprintf(stderr, "oops - __WM_GEXPOSE for unmapping\n");
 11033 		}
 11031 		}
 11034 #endif
 11032 #endif
 11035 		(*gexpS.ilc_func)(self,
 11033 		(*gexpS.ilc_func)(self,
 11036 				  @symbol(graphicsExposeX:y:width:height:final:view:),
 11034 				  @symbol(graphicsExposeX:y:width:height:final:view:),
 11037 				  nil, &gexpS,
 11035 				  nil, &gexpS,
 11045 
 11043 
 11046 	    case __WM_NOGEXPOSE:
 11044 	    case __WM_NOGEXPOSE:
 11047 		DPRINTFIF(__debug_WM_EXPOSE__, (">>> __WM_NOGEXPOSE -> noExpose\n"));
 11045 		DPRINTFIF(__debug_WM_EXPOSE__, (">>> __WM_NOGEXPOSE -> noExpose\n"));
 11048 #if 0
 11046 #if 0
 11049 		if (GetWindow_unmapping(hWnd)) {
 11047 		if (GetWindow_unmapping(hWnd)) {
 11050 		    fprintf(stderr, "oops - __WM_NOGEXPOSE for unmapping\n");
 11048 		    console_fprintf(stderr, "oops - __WM_NOGEXPOSE for unmapping\n");
 11051 		}
 11049 		}
 11052 #endif
 11050 #endif
 11053 		 (*nexpS.ilc_func)(self,
 11051 		 (*nexpS.ilc_func)(self,
 11054 				   @symbol(noExposeView:), nil, &nexpS,
 11052 				   @symbol(noExposeView:), nil, &nexpS,
 11055 				   theView);
 11053 				   theView);
 11078 		w = ev->ev_w;
 11076 		w = ev->ev_w;
 11079 		h = ev->ev_h;
 11077 		h = ev->ev_h;
 11080 
 11078 
 11081 #if 0
 11079 #if 0
 11082 		if (GetWindow_unmapping(hWnd)) {
 11080 		if (GetWindow_unmapping(hWnd)) {
 11083 		    fprintf(stderr, "oops - WM_PAINT for unmapping\n");
 11081 		    console_fprintf(stderr, "oops - WM_PAINT for unmapping\n");
 11084 		}
 11082 		}
 11085 #endif
 11083 #endif
 11086 
 11084 
 11087 #ifndef PRE_21_NOV
 11085 #ifndef PRE_21_NOV
 11088 		__clearWindow(hWnd, x, y, w, h);
 11086 		__clearWindow(hWnd, x, y, w, h);
 11248 		if (__debug_WM_MOUSEENTER__) {
 11246 		if (__debug_WM_MOUSEENTER__) {
 11249 		    PRINTF((">>> WM_MOUSEENTER: %x %d/%d state:%x\n", ev->ev_hWnd, x, y, state));
 11247 		    PRINTF((">>> WM_MOUSEENTER: %x %d/%d state:%x\n", ev->ev_hWnd, x, y, state));
 11250 		}
 11248 		}
 11251 #if 0
 11249 #if 0
 11252 		if (GetWindow_unmapping(hWnd)) {
 11250 		if (GetWindow_unmapping(hWnd)) {
 11253 		    fprintf(stderr, "oops - WM_MOUSEENTER for unmapping\n");
 11251 		    console_fprintf(stderr, "oops - WM_MOUSEENTER for unmapping\n");
 11254 		}
 11252 		}
 11255 #endif
 11253 #endif
 11256 		(*pe.ilc_func)(self, @symbol(pointerEnter:x:y:view:),
 11254 		(*pe.ilc_func)(self, @symbol(pointerEnter:x:y:view:),
 11257 				    nil, &pe,
 11255 				    nil, &pe,
 11258 				    __MKSMALLINT(state),
 11256 				    __MKSMALLINT(state),
 11266 		if (__debug_WM_MOUSELEAVE__) {
 11264 		if (__debug_WM_MOUSELEAVE__) {
 11267 		    PRINTF((">>> WM_MOUSELEAVE: %x state:%x\n", ev->ev_hWnd, state));
 11265 		    PRINTF((">>> WM_MOUSELEAVE: %x state:%x\n", ev->ev_hWnd, state));
 11268 		}
 11266 		}
 11269 #if 0
 11267 #if 0
 11270 		if (GetWindow_unmapping(hWnd)) {
 11268 		if (GetWindow_unmapping(hWnd)) {
 11271 		    fprintf(stderr, "oops - WM_MOUSELEAVE for unmapping\n");
 11269 		    console_fprintf(stderr, "oops - WM_MOUSELEAVE for unmapping\n");
 11272 		}
 11270 		}
 11273 #endif
 11271 #endif
 11274 		(*pl.ilc_func)(self, @symbol(pointerLeave:view:),
 11272 		(*pl.ilc_func)(self, @symbol(pointerLeave:view:),
 11275 				    nil, &pl,
 11273 				    nil, &pl,
 11276 				    __MKSMALLINT(state),
 11274 				    __MKSMALLINT(state),
 11861     struct queuedEvent *ev;
 11859     struct queuedEvent *ev;
 11862     struct queuedEvent *qev;
 11860     struct queuedEvent *qev;
 11863 
 11861 
 11864     eB = __INST(eventBuffer);
 11862     eB = __INST(eventBuffer);
 11865     if (! __isByteArray(eB)) {
 11863     if (! __isByteArray(eB)) {
 11866 	fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 11864 	console_fprintf(stderr, "WinWorkstation [error]: no eventBuffer\n");
 11867 	/* RETURN (false); */
 11865 	/* RETURN (false); */
 11868     } else {
 11866     } else {
 11869 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 11867 	ev = (struct queuedEvent *)(__ByteArrayInstPtr(eB)->ba_element);
 11870 	ev->ev_message = 0;
 11868 	ev->ev_message = 0;
 11871 
 11869 
 12711 #ifdef SUPERDEBUG
 12709 #ifdef SUPERDEBUG
 12712 		    if (__debug__) {
 12710 		    if (__debug__) {
 12713 		      char buf[80];
 12711 		      char buf[80];
 12714 
 12712 
 12715 		      GetTextFace(__tmpDC,80,buf);
 12713 		      GetTextFace(__tmpDC,80,buf);
 12716 		      printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 12714 		      console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 12717 		    }
 12715 		    }
 12718 #endif
 12716 #endif
 12719 #ifndef CACHE_LAST_TMP_FONT
 12717 #ifndef CACHE_LAST_TMP_FONT
 12720 		    SelectObject(__tmpDC, prevFont);
 12718 		    SelectObject(__tmpDC, prevFont);
 12721 #endif
 12719 #endif
 12736 #ifdef SUPERDEBUG
 12734 #ifdef SUPERDEBUG
 12737 		    if (__debug__) {
 12735 		    if (__debug__) {
 12738 		      char buf[80];
 12736 		      char buf[80];
 12739 
 12737 
 12740 		      GetTextFace(__tmpDC,80,buf);
 12738 		      GetTextFace(__tmpDC,80,buf);
 12741 		      printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 12739 		      console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
 12742 		    }
 12740 		    }
 12743 #endif
 12741 #endif
 12744 #ifndef CACHE_LAST_TMP_FONT
 12742 #ifndef CACHE_LAST_TMP_FONT
 12745 		    SelectObject(__tmpDC, prevFont);
 12743 		    SelectObject(__tmpDC, prevFont);
 12746 #endif
 12744 #endif
 12992 	     */
 12990 	     */
 12993 	    if (lastGcData == gcData) {
 12991 	    if (lastGcData == gcData) {
 12994 		HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
 12992 		HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
 12995 
 12993 
 12996 		if (region == NULL ) {
 12994 		if (region == NULL ) {
 12997 		    fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
 12995 		    console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
 12998 		    FLUSH_CACHED_DC(gcData);
 12996 		    FLUSH_CACHED_DC(gcData);
 12999 		} else {
 12997 		} else {
 13000 		    if (SelectClipRgn(gcData->_hDC, region) == ERROR ) {
 12998 		    if (SelectClipRgn(gcData->_hDC, region) == ERROR ) {
 13001 			fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
 12999 			console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
 13002 			FLUSH_CACHED_DC(gcData);
 13000 			FLUSH_CACHED_DC(gcData);
 13003 		    }
 13001 		    }
 13004 		    _DeleteObject(region, __LINE__);
 13002 		    _DeleteObject(region, __LINE__);
 13005 		}
 13003 		}
 13006 	    }
 13004 	    }
 13304 	    bfun = BITBLT_OR;
 13302 	    bfun = BITBLT_OR;
 13305 	}
 13303 	}
 13306 
 13304 
 13307 	if (fun != -1) {
 13305 	if (fun != -1) {
 13308 #if 0
 13306 #if 0
 13309 	    printf("set func to");
 13307 	    console_printf("set func to");
 13310 	    switch (bfun) {
 13308 	    switch (bfun) {
 13311 		case BITBLT_COPY:
 13309 		case BITBLT_COPY:
 13312 		    printf("BITBLT_COPY\n");
 13310 		    console_printf("BITBLT_COPY\n");
 13313 		    break;
 13311 		    break;
 13314 		case BITBLT_COPYINVERTED:
 13312 		case BITBLT_COPYINVERTED:
 13315 		    printf("BITBLT_COPYINVERTED\n");
 13313 		    console_printf("BITBLT_COPYINVERTED\n");
 13316 		    break;
 13314 		    break;
 13317 		case BITBLT_XOR:
 13315 		case BITBLT_XOR:
 13318 		    printf("BITBLT_XOR\n");
 13316 		    console_printf("BITBLT_XOR\n");
 13319 		    break;
 13317 		    break;
 13320 		case BITBLT_AND:
 13318 		case BITBLT_AND:
 13321 		    printf("BITBLT_AND\n");
 13319 		    console_printf("BITBLT_AND\n");
 13322 		    break;
 13320 		    break;
 13323 		case BITBLT_OR:
 13321 		case BITBLT_OR:
 13324 		    printf("BITBLT_OR\n");
 13322 		    console_printf("BITBLT_OR\n");
 13325 		    break;
 13323 		    break;
 13326 	    }
 13324 	    }
 13327 #endif
 13325 #endif
 13328 	} else {
 13326 	} else {
 13329 	    INFOPRINT( (stderr, "WinWorkstat [warning]: unsuported Rasterfunction\n") );
 13327 	    INFOFPRINTF( (stderr, "WinWorkstat [warning]: unsuported Rasterfunction\n") );
 13330 	    fun = R2_COPYPEN;
 13328 	    fun = R2_COPYPEN;
 13331 	    bfun = BITBLT_COPY;
 13329 	    bfun = BITBLT_COPY;
 13332 	}
 13330 	}
 13333 
 13331 
 13334 	if ((fun != gcData->rop2)
 13332 	if ((fun != gcData->rop2)
 13343 		SetROP2(gcData->_hDC, fun);
 13341 		SetROP2(gcData->_hDC, fun);
 13344 	    }
 13342 	    }
 13345 #endif
 13343 #endif
 13346 	}
 13344 	}
 13347     } else {
 13345     } else {
 13348 	INFOPRINT((stderr, "WinWorkstation [warning]: Rasterfunction no GC\n"));
 13346 	INFOFPRINTF((stderr, "WinWorkstation [warning]: Rasterfunction no GC\n"));
 13349     }
 13347     }
 13350 %}
 13348 %}
 13351 !
 13349 !
 13352 
 13350 
 13353 setGraphicsExposures:aBoolean in:aGCId
 13351 setGraphicsExposures:aBoolean in:aGCId
 13498     int mask, shift, nBits;
 13496     int mask, shift, nBits;
 13499     HDC _rootDC;
 13497     HDC _rootDC;
 13500     OBJ id;
 13498     OBJ id;
 13501 
 13499 
 13502     if (firstInstance) {
 13500     if (firstInstance) {
 13503         OSVERSIONINFO osvi;
 13501 	OSVERSIONINFO osvi;
 13504         WNDCLASS wc;
 13502 	WNDCLASS wc;
 13505         firstInstance = 0;
 13503 	firstInstance = 0;
 13506         DPRINTF(("first create - registerClass\n"));
 13504 	DPRINTF(("first create - registerClass\n"));
 13507 
 13505 
 13508         memset(&osvi, 0, sizeof(OSVERSIONINFO));
 13506 	memset(&osvi, 0, sizeof(OSVERSIONINFO));
 13509         osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
 13507 	osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
 13510         GetVersionEx (&osvi);
 13508 	GetVersionEx (&osvi);
 13511 
 13509 
 13512         __INST(isWin95) = true;
 13510 	__INST(isWin95) = true;
 13513         __INST(isWinXP) = false;
 13511 	__INST(isWinXP) = false;
 13514         __isWinNT = __isWinXP = 0;
 13512 	__isWinNT = __isWinXP = 0;
 13515         __isWinNT_NEW_BEHAVIOUR = 0;
 13513 	__isWinNT_NEW_BEHAVIOUR = 0;
 13516 
 13514 
 13517         if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
 13515 	if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
 13518             __INST(isWin95) = false;
 13516 	    __INST(isWin95) = false;
 13519             __isWinNT = 1;
 13517 	    __isWinNT = 1;
 13520             __isWinNT_NEW_BEHAVIOUR = 1;
 13518 	    __isWinNT_NEW_BEHAVIOUR = 1;
 13521 
 13519 
 13522             if ((osvi.dwMajorVersion >= 5) && (osvi.dwMinorVersion >= 1)) {
 13520 	    if ((osvi.dwMajorVersion >= 5) && (osvi.dwMinorVersion >= 1)) {
 13523                 __INST(isWinXP) = true;
 13521 		__INST(isWinXP) = true;
 13524                 __isWinXP = 1;
 13522 		__isWinXP = 1;
 13525             }
 13523 	    }
 13526             NUM_PEN_CACHED = NUM_PEN_CACHED_NT;
 13524 	    NUM_PEN_CACHED = NUM_PEN_CACHED_NT;
 13527             NUM_BRUSH_CACHED = NUM_BRUSH_CACHED_NT;
 13525 	    NUM_BRUSH_CACHED = NUM_BRUSH_CACHED_NT;
 13528         }
 13526 	}
 13529 
 13527 
 13530         /*
 13528 	/*
 13531          * register class: ST/X
 13529 	 * register class: ST/X
 13532          */
 13530 	 */
 13533         wc.style = 0
 13531 	wc.style = 0
 13534                    /* | CS_OWNDC */
 13532 		   /* | CS_OWNDC */
 13535                    /* | CS_HREDRAW */
 13533 		   /* | CS_HREDRAW */
 13536                    /* | CS_VREDRAW */
 13534 		   /* | CS_VREDRAW */
 13537                   | CS_DBLCLKS;
 13535 		  | CS_DBLCLKS;
 13538         wc.lpfnWndProc = (WNDPROC) MainWndProc;
 13536 	wc.lpfnWndProc = (WNDPROC) MainWndProc;
 13539         wc.cbClsExtra = 0;
 13537 	wc.cbClsExtra = 0;
 13540         wc.cbWndExtra = N_WINDOW_PRIVATE;
 13538 	wc.cbWndExtra = N_WINDOW_PRIVATE;
 13541         wc.hInstance = (HANDLE) __getHInstance();
 13539 	wc.hInstance = (HANDLE) __getHInstance();
 13542         wc.hIcon = NULL;
 13540 	wc.hIcon = NULL;
 13543         wc.hCursor = 0;
 13541 	wc.hCursor = 0;
 13544         wc.hbrBackground = 0;
 13542 	wc.hbrBackground = 0;
 13545 
 13543 
 13546         wc.lpszMenuName =  NULL;
 13544 	wc.lpszMenuName =  NULL;
 13547         wc.lpszClassName = app_name;
 13545 	wc.lpszClassName = app_name;
 13548 
 13546 
 13549         if (!RegisterClass(&wc)) {
 13547 	if (!RegisterClass(&wc)) {
 13550             DPRINTF(("RegisterClass failed\n"));
 13548 	    DPRINTF(("RegisterClass failed\n"));
 13551         }
 13549 	}
 13552 
 13550 
 13553         /*
 13551 	/*
 13554          * register class: ST/X:Root
 13552 	 * register class: ST/X:Root
 13555          */
 13553 	 */
 13556         wc.style = 0;
 13554 	wc.style = 0;
 13557         wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13555 	wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13558         wc.cbClsExtra = 0;
 13556 	wc.cbClsExtra = 0;
 13559         wc.cbWndExtra = N_WINDOW_PRIVATE;
 13557 	wc.cbWndExtra = N_WINDOW_PRIVATE;
 13560         wc.hInstance = (HANDLE) __getHInstance();
 13558 	wc.hInstance = (HANDLE) __getHInstance();
 13561         wc.hIcon = NULL;
 13559 	wc.hIcon = NULL;
 13562         wc.hCursor = 0;
 13560 	wc.hCursor = 0;
 13563         wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13561 	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13564 
 13562 
 13565         wc.lpszMenuName =  NULL;
 13563 	wc.lpszMenuName =  NULL;
 13566         wc.lpszClassName = app_nameRoot;
 13564 	wc.lpszClassName = app_nameRoot;
 13567 
 13565 
 13568         if (! RegisterClass(&wc)) {
 13566 	if (! RegisterClass(&wc)) {
 13569             DPRINTF(("RegisterClass failed\n"));
 13567 	    DPRINTF(("RegisterClass failed\n"));
 13570         }
 13568 	}
 13571 
 13569 
 13572         /*
 13570 	/*
 13573          * register class: ST/X:Popup
 13571 	 * register class: ST/X:Popup
 13574          */
 13572 	 */
 13575         wc.style = CS_SAVEBITS;
 13573 	wc.style = CS_SAVEBITS;
 13576         if (__isWinXP) {
 13574 	if (__isWinXP) {
 13577 #ifndef CS_DROPSHADOW
 13575 #ifndef CS_DROPSHADOW
 13578 # define CS_DROPSHADOW    0x020000
 13576 # define CS_DROPSHADOW    0x020000
 13579 #endif
 13577 #endif
 13580             wc.style |= CS_DROPSHADOW;
 13578 	    wc.style |= CS_DROPSHADOW;
 13581         }
 13579 	}
 13582         wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13580 	wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13583         wc.cbClsExtra = 0;
 13581 	wc.cbClsExtra = 0;
 13584         wc.cbWndExtra = N_WINDOW_PRIVATE;
 13582 	wc.cbWndExtra = N_WINDOW_PRIVATE;
 13585         wc.hInstance = (HANDLE) __getHInstance();
 13583 	wc.hInstance = (HANDLE) __getHInstance();
 13586         wc.hIcon = NULL;
 13584 	wc.hIcon = NULL;
 13587         wc.hCursor = 0;
 13585 	wc.hCursor = 0;
 13588         wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13586 	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13589 
 13587 
 13590         wc.lpszMenuName =  NULL;
 13588 	wc.lpszMenuName =  NULL;
 13591         wc.lpszClassName = app_namePopup;
 13589 	wc.lpszClassName = app_namePopup;
 13592 
 13590 
 13593         if (! RegisterClass(&wc)) {
 13591 	if (! RegisterClass(&wc)) {
 13594             DPRINTF(("RegisterClass failed\n"));
 13592 	    DPRINTF(("RegisterClass failed\n"));
 13595         }
 13593 	}
 13596 
 13594 
 13597         /*
 13595 	/*
 13598          * register class: ST/X:Dialog
 13596 	 * register class: ST/X:Dialog
 13599          */
 13597 	 */
 13600         wc.style = CS_SAVEBITS;
 13598 	wc.style = CS_SAVEBITS;
 13601         wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13599 	wc.lpfnWndProc = (WNDPROC) MainWndProc;;
 13602         wc.cbClsExtra = 0;
 13600 	wc.cbClsExtra = 0;
 13603         wc.cbWndExtra = N_WINDOW_PRIVATE;
 13601 	wc.cbWndExtra = N_WINDOW_PRIVATE;
 13604         wc.hInstance = (HANDLE) __getHInstance();
 13602 	wc.hInstance = (HANDLE) __getHInstance();
 13605         wc.hIcon = NULL;
 13603 	wc.hIcon = NULL;
 13606         wc.hCursor = 0;
 13604 	wc.hCursor = 0;
 13607         wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13605 	wc.hbrBackground = GetStockObject(HOLLOW_BRUSH);
 13608 
 13606 
 13609         wc.lpszMenuName =  NULL;
 13607 	wc.lpszMenuName =  NULL;
 13610         wc.lpszClassName = app_nameDialog;
 13608 	wc.lpszClassName = app_nameDialog;
 13611 
 13609 
 13612         if (! RegisterClass(&wc)) {
 13610 	if (! RegisterClass(&wc)) {
 13613             DPRINTF(("RegisterClass failed\n"));
 13611 	    DPRINTF(("RegisterClass failed\n"));
 13614         }
 13612 	}
 13615 
 13613 
 13616         /*
 13614 	/*
 13617          * generate my events
 13615 	 * generate my events
 13618          */
 13616 	 */
 13619         hDispatchThreadRunningEvent = CreateEvent(
 13617 	hDispatchThreadRunningEvent = CreateEvent(
 13620                                 NULL,            /* no security attributes */
 13618 				NULL,            /* no security attributes */
 13621                                 FALSE,
 13619 				FALSE,
 13622                                 FALSE,
 13620 				FALSE,
 13623                                 "DispatchThreadRunning"); /* name of event */
 13621 				"DispatchThreadRunning"); /* name of event */
 13624 
 13622 
 13625         if (hDispatchThreadRunningEvent == NULL) {
 13623 	if (hDispatchThreadRunningEvent == NULL) {
 13626             fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-0 failed\n");
 13624 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-0 failed\n");
 13627             exit(1);
 13625 	    exit(1);
 13628         }
 13626 	}
 13629 
 13627 
 13630         hNeverTriggered = CreateEvent(
 13628 	hNeverTriggered = CreateEvent(
 13631                                 NULL,            /* no security attributes */
 13629 				NULL,            /* no security attributes */
 13632                                 FALSE,
 13630 				FALSE,
 13633                                 FALSE,
 13631 				FALSE,
 13634                                 "Never");
 13632 				"Never");
 13635 
 13633 
 13636         if (hNeverTriggered == NULL) {
 13634 	if (hNeverTriggered == NULL) {
 13637             fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-1 failed\n");
 13635 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-1 failed\n");
 13638             exit(1);
 13636 	    exit(1);
 13639         }
 13637 	}
 13640 
 13638 
 13641         hCreateEvent = CreateEvent(
 13639 	hCreateEvent = CreateEvent(
 13642                                 NULL,            /* no security attributes */
 13640 				NULL,            /* no security attributes */
 13643                                 FALSE,
 13641 				FALSE,
 13644                                 FALSE,
 13642 				FALSE,
 13645                                 "CreateEvents"); /* name of event */
 13643 				"CreateEvents"); /* name of event */
 13646 
 13644 
 13647         if (hCreateEvent == NULL) {
 13645 	if (hCreateEvent == NULL) {
 13648             fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-2 failed\n");
 13646 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-2 failed\n");
 13649             exit(1);
 13647 	    exit(1);
 13650         }
 13648 	}
 13651 
 13649 
 13652         hInputEvent = CreateEvent(
 13650 	hInputEvent = CreateEvent(
 13653                                 NULL,            /* no security attributes */
 13651 				NULL,            /* no security attributes */
 13654                                 FALSE,
 13652 				FALSE,
 13655                                 FALSE,
 13653 				FALSE,
 13656                                 "InputEvents");  /* name of event */
 13654 				"InputEvents");  /* name of event */
 13657 
 13655 
 13658         if (hInputEvent == NULL) {
 13656 	if (hInputEvent == NULL) {
 13659             fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-3 failed\n");
 13657 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateEvent-3 failed\n");
 13660             exit(1);
 13658 	    exit(1);
 13661         }
 13659 	}
 13662 
 13660 
 13663         if (hEventsMutex) {
 13661 	if (hEventsMutex) {
 13664             fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex already created\n");
 13662 	    console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex already created\n");
 13665             exit(1);
 13663 	    exit(1);
 13666         }
 13664 	}
 13667         hEventsMutex = CreateMutex(
 13665 	hEventsMutex = CreateMutex(
 13668                                 NULL,            /* no security attributes */
 13666 				NULL,            /* no security attributes */
 13669                                 FALSE,           /* initially not owned */
 13667 				FALSE,           /* initially not owned */
 13670                                 "EventsMutex");  /* name of mutex */
 13668 				"EventsMutex");  /* name of mutex */
 13671 
 13669 
 13672         if (! hEventsMutex) {
 13670 	if (! hEventsMutex) {
 13673             fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex failed\n");
 13671 	    console_fprintf(stderr, "WinWorkstation [fatal]: hEventsMutex failed\n");
 13674             exit(1);
 13672 	    exit(1);
 13675         }
 13673 	}
 13676         DuplicateHandle(GetCurrentProcess(),
 13674 	DuplicateHandle(GetCurrentProcess(),
 13677                         hEventsMutex,
 13675 			hEventsMutex,
 13678                         GetCurrentProcess(),
 13676 			GetCurrentProcess(),
 13679                         &hEventsMutex,
 13677 			&hEventsMutex,
 13680                         DUPLICATE_SAME_ACCESS,
 13678 			DUPLICATE_SAME_ACCESS,
 13681                         FALSE,
 13679 			FALSE,
 13682                         DUPLICATE_SAME_ACCESS);
 13680 			DUPLICATE_SAME_ACCESS);
 13683 
 13681 
 13684 #ifdef USE_PAINT_MUTEX
 13682 #ifdef USE_PAINT_MUTEX
 13685         hPaintMutex = CreateMutex(
 13683 	hPaintMutex = CreateMutex(
 13686                                 NULL,           /* no security attributes */
 13684 				NULL,           /* no security attributes */
 13687                                 FALSE,          /* initially not owned */
 13685 				FALSE,          /* initially not owned */
 13688                                 "PaintMutex");  /* name of mutex */
 13686 				"PaintMutex");  /* name of mutex */
 13689 
 13687 
 13690         if (hPaintMutex == NULL) {
 13688 	if (hPaintMutex == NULL) {
 13691             fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(PaintMutex) failed\n");
 13689 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(PaintMutex) failed\n");
 13692             exit(1);
 13690 	    exit(1);
 13693         }
 13691 	}
 13694         DuplicateHandle(GetCurrentProcess(),
 13692 	DuplicateHandle(GetCurrentProcess(),
 13695                         hPaintMutex,
 13693 			hPaintMutex,
 13696                         GetCurrentProcess(),
 13694 			GetCurrentProcess(),
 13697                         &hPaintMutex,
 13695 			&hPaintMutex,
 13698                         DUPLICATE_SAME_ACCESS,
 13696 			DUPLICATE_SAME_ACCESS,
 13699                         FALSE,
 13697 			FALSE,
 13700                         DUPLICATE_SAME_ACCESS);
 13698 			DUPLICATE_SAME_ACCESS);
 13701 #endif
 13699 #endif
 13702 #ifdef USE_DRAW_MUTEX
 13700 #ifdef USE_DRAW_MUTEX
 13703         hDrawMutex = CreateMutex(
 13701 	hDrawMutex = CreateMutex(
 13704                                 NULL,           /* no security attributes */
 13702 				NULL,           /* no security attributes */
 13705                                 FALSE,          /* initially not owned */
 13703 				FALSE,          /* initially not owned */
 13706                                 "DrawMutex");   /* name of mutex */
 13704 				"DrawMutex");   /* name of mutex */
 13707 
 13705 
 13708         if (hDrawMutex == NULL) {
 13706 	if (hDrawMutex == NULL) {
 13709             fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(DrawMutex) failed\n");
 13707 	    console_fprintf(stderr, "WinWorkstation [fatal]: CreateMutex(DrawMutex) failed\n");
 13710             exit(1);
 13708 	    exit(1);
 13711         }
 13709 	}
 13712         DuplicateHandle(GetCurrentProcess(),
 13710 	DuplicateHandle(GetCurrentProcess(),
 13713                         hDrawMutex,
 13711 			hDrawMutex,
 13714                         GetCurrentProcess(),
 13712 			GetCurrentProcess(),
 13715                         &hDrawMutex,
 13713 			&hDrawMutex,
 13716                         DUPLICATE_SAME_ACCESS,
 13714 			DUPLICATE_SAME_ACCESS,
 13717                         FALSE,
 13715 			FALSE,
 13718                         DUPLICATE_SAME_ACCESS);
 13716 			DUPLICATE_SAME_ACCESS);
 13719 #endif
 13717 #endif
 13720 
 13718 
 13721         _masterThreadId = GetCurrentThreadId();
 13719 	_masterThreadId = GetCurrentThreadId();
 13722 #ifndef WIN32THREADS
 13720 #ifndef WIN32THREADS
 13723         DuplicateHandle(GetCurrentProcess(),
 13721 	DuplicateHandle(GetCurrentProcess(),
 13724                         GetCurrentThread(),
 13722 			GetCurrentThread(),
 13725                         GetCurrentProcess(),
 13723 			GetCurrentProcess(),
 13726                         &_masterThread,
 13724 			&_masterThread,
 13727                         DUPLICATE_SAME_ACCESS,
 13725 			DUPLICATE_SAME_ACCESS,
 13728                         FALSE,
 13726 			FALSE,
 13729                         DUPLICATE_SAME_ACCESS);
 13727 			DUPLICATE_SAME_ACCESS);
 13730 #endif
 13728 #endif
 13731 
 13729 
 13732         initEventqueue();
 13730 	initEventqueue();
 13733 
 13731 
 13734         /*
 13732 	/*
 13735          * start the event dispatcher thread and wait for it to
 13733 	 * start the event dispatcher thread and wait for it to
 13736          * be ready
 13734 	 * be ready
 13737          */
 13735 	 */
 13738         CreateThread((LPSECURITY_ATTRIBUTES)0,
 13736 	CreateThread((LPSECURITY_ATTRIBUTES)0,
 13739                      EVENT_THREAD_STACKSIZE,
 13737 		     EVENT_THREAD_STACKSIZE,
 13740                      (LPTHREAD_START_ROUTINE)dispatchThread,
 13738 		     (LPTHREAD_START_ROUTINE)dispatchThread,
 13741                      0, 0, &_dispatchThreadId);
 13739 		     0, 0, &_dispatchThreadId);
 13742 
 13740 
 13743 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 13741 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 13744         fprintf(stderr, "WinWorkstation [info]: dispatchThreadId=%x\n", _dispatchThreadId);
 13742 	console_fprintf(stderr, "WinWorkstation [info]: dispatchThreadId=%x\n", _dispatchThreadId);
 13745 #endif
 13743 #endif
 13746 
 13744 
 13747         if (WaitForSingleObject(hDispatchThreadRunningEvent, 5000L) != WAIT_OBJECT_0) {
 13745 	if (WaitForSingleObject(hDispatchThreadRunningEvent, 5000L) != WAIT_OBJECT_0) {
 13748             fprintf(stderr, "WinWorkstation [error]: oops - timeout waiting for eventThread to start\n");
 13746 	    console_fprintf(stderr, "WinWorkstation [error]: oops - timeout waiting for eventThread to start\n");
 13749         }
 13747 	}
 13750 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 13748 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
 13751         fprintf(stderr, "WinWorkstation [info]: got ThreadRunningEvent\n");
 13749 	console_fprintf(stderr, "WinWorkstation [info]: got ThreadRunningEvent\n");
 13752 #endif
 13750 #endif
 13753     }
 13751     }
 13754 
 13752 
 13755 #if 0
 13753 #if 0
 13756     __rootDesk = OpenDesktop ("Desktop0", 0, FALSE, GENERIC_ALL);
 13754     __rootDesk = OpenDesktop ("Desktop0", 0, FALSE, GENERIC_ALL);
 13757     if (!__rootDesk) {
 13755     if (!__rootDesk) {
 13758         PRINTF(("OpenDesktop fail\n"));
 13756 	PRINTF(("OpenDesktop fail\n"));
 13759         __rootDesk = CreateDesktop ("Desktop0", NULL, NULL, 0, DESKTOP_WRITEOBJECTS, NULL);
 13757 	__rootDesk = CreateDesktop ("Desktop0", NULL, NULL, 0, DESKTOP_WRITEOBJECTS, NULL);
 13760         if (!__rootDesk) {
 13758 	if (!__rootDesk) {
 13761             PRINTF(("CreateDesktop fail\n"));
 13759 	    PRINTF(("CreateDesktop fail\n"));
 13762         }
 13760 	}
 13763     }
 13761     }
 13764 #endif
 13762 #endif
 13765 
 13763 
 13766     __rootWin = GetDesktopWindow();
 13764     __rootWin = GetDesktopWindow();
 13767     __PROTECT__(self);
 13765     __PROTECT__(self);
 13893     }
 13891     }
 13894     __logPixelSY = GetDeviceCaps(__rootDC, LOGPIXELSY);
 13892     __logPixelSY = GetDeviceCaps(__rootDC, LOGPIXELSY);
 13895     capabilities = GetDeviceCaps(__rootDC, RASTERCAPS);
 13893     capabilities = GetDeviceCaps(__rootDC, RASTERCAPS);
 13896 
 13894 
 13897 #ifdef LATER
 13895 #ifdef LATER
 13898     printf("device support:\n");
 13896     console_printf("device support:\n");
 13899     if (capabilities & RC_BANDING)
 13897     if (capabilities & RC_BANDING)
 13900 	printf(" RC_BANDING");
 13898 	console_printf(" RC_BANDING");
 13901 
 13899 
 13902     if (capabilities & RC_BITBLT)
 13900     if (capabilities & RC_BITBLT)
 13903 	printf(" RC_BITBLT");
 13901 	console_printf(" RC_BITBLT");
 13904 
 13902 
 13905     if (capabilities & RC_BITMAP64)
 13903     if (capabilities & RC_BITMAP64)
 13906 	printf(" RC_BITMAP64");
 13904 	console_printf(" RC_BITMAP64");
 13907 
 13905 
 13908     if (capabilities & RC_DI_BITMAP)
 13906     if (capabilities & RC_DI_BITMAP)
 13909 	printf(" RC_DI_BITMAP");
 13907 	console_printf(" RC_DI_BITMAP");
 13910 
 13908 
 13911     if (capabilities & RC_DIBTODEV)
 13909     if (capabilities & RC_DIBTODEV)
 13912 	printf(" RC_DIBTODEV");
 13910 	console_printf(" RC_DIBTODEV");
 13913 
 13911 
 13914     if (capabilities & RC_FLOODFILL)
 13912     if (capabilities & RC_FLOODFILL)
 13915 	printf(" RC_FLOODFILL");
 13913 	console_printf(" RC_FLOODFILL");
 13916 
 13914 
 13917     if (capabilities & RC_PALETTE)
 13915     if (capabilities & RC_PALETTE)
 13918 	printf(" RC_PALETTE");
 13916 	console_printf(" RC_PALETTE");
 13919 
 13917 
 13920     if (capabilities & RC_SCALING)
 13918     if (capabilities & RC_SCALING)
 13921 	printf(" RC_SCALING");
 13919 	console_printf(" RC_SCALING");
 13922 
 13920 
 13923     if (capabilities & RC_STRETCHBLT)
 13921     if (capabilities & RC_STRETCHBLT)
 13924 	printf(" RC_STRETCHBLT");
 13922 	console_printf(" RC_STRETCHBLT");
 13925 
 13923 
 13926     if (capabilities & RC_STRETCHDIB)
 13924     if (capabilities & RC_STRETCHDIB)
 13927 	printf(" RC_STRETCHDIB");
 13925 	console_printf(" RC_STRETCHDIB");
 13928 
 13926 
 13929     printf("\n");
 13927     console_printf("\n");
 13930     printf("cursor size %d %d\n", GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR));
 13928     console_printf("cursor size %d %d\n", GetSystemMetrics(SM_CXCURSOR), GetSystemMetrics(SM_CYCURSOR));
 13931 #endif
 13929 #endif
 13932 
 13930 
 13933     __INST(whitepixel) = __MKSMALLINT(WhitePixel);
 13931     __INST(whitepixel) = __MKSMALLINT(WhitePixel);
 13934     __INST(blackpixel) = __MKSMALLINT(BlackPixel);
 13932     __INST(blackpixel) = __MKSMALLINT(BlackPixel);
 13935 
 13933 
 13987 	      __INST(blueMask) = __MKSMALLINT(0xFF0000);
 13985 	      __INST(blueMask) = __MKSMALLINT(0xFF0000);
 13988 	    }
 13986 	    }
 13989 	}
 13987 	}
 13990     } else {
 13988     } else {
 13991 	val = GetDeviceCaps(__rootDC, SIZEPALETTE); /* First two entries are black and white. */
 13989 	val = GetDeviceCaps(__rootDC, SIZEPALETTE); /* First two entries are black and white. */
 13992 	// printf("SizeofPalette %d\n",val);
 13990 	// console_printf("SizeofPalette %d\n",val);
 13993 	__INST(ncells) = __MKSMALLINT(val);
 13991 	__INST(ncells) = __MKSMALLINT(val);
 13994 	__INST(blackpixel) = __MKSMALLINT(0);
 13992 	__INST(blackpixel) = __MKSMALLINT(0);
 13995 	__INST(whitepixel) = __MKSMALLINT(1);
 13993 	__INST(whitepixel) = __MKSMALLINT(1);
 13996 	__INST(hasColors) = true;
 13994 	__INST(hasColors) = true;
 13997 	__INST(hasGreyscales) = true;
 13995 	__INST(hasGreyscales) = true;
 14356 	char *dst = filterBuffer;
 14354 	char *dst = filterBuffer;
 14357 	unsigned int idx;
 14355 	unsigned int idx;
 14358 
 14356 
 14359 	for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 14357 	for (idx=0; idx<__arraySize(filterArrayOrNil); idx++) {
 14360 	    OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 14358 	    OBJ el = __ArrayInstPtr(filterArrayOrNil)->a_element[idx];
 14361 // printf("idx = %d\n", idx);
 14359 // console_printf("idx = %d\n", idx);
 14362 	    if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 14360 	    if (__isArrayLike(el) && (__arraySize(el) == 2)) {
 14363 		OBJ descr, filter;
 14361 		OBJ descr, filter;
 14364 
 14362 
 14365 		descr = __ArrayInstPtr(el)->a_element[0];
 14363 		descr = __ArrayInstPtr(el)->a_element[0];
 14366 		filter = __ArrayInstPtr(el)->a_element[1];
 14364 		filter = __ArrayInstPtr(el)->a_element[1];
 14367 		if (__isString(descr) && __isString(filter)) {
 14365 		if (__isString(descr) && __isString(filter)) {
 14368 		    char *src = __stringVal(descr);
 14366 		    char *src = __stringVal(descr);
 14369 
 14367 
 14370 // printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 14368 // console_printf("descr: %s filter: %s\n", __stringVal(descr), __stringVal(filter));
 14371 
 14369 
 14372 		    // append (incl 0-byte)
 14370 		    // append (incl 0-byte)
 14373 		    while (*src) {
 14371 		    while (*src) {
 14374 			*dst++ = *src++;
 14372 			*dst++ = *src++;
 14375 		    }
 14373 		    }
 15289 		   __intVal(srcX), __intVal(srcY),
 15287 		   __intVal(srcX), __intVal(srcY),
 15290 		   SRCCOPY)
 15288 		   SRCCOPY)
 15291 		 == 0
 15289 		 == 0
 15292 		)
 15290 		)
 15293 	    {
 15291 	    {
 15294 		INFOPRINT((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
 15292 		INFOFPRINTF((stderr, "WinWorkstation [warning]: in primGetBitsFrom: BitBlt\n"));
 15295 	    }
 15293 	    }
 15296 
 15294 
 15297 #ifdef CACHE_LAST_DC
 15295 #ifdef CACHE_LAST_DC
 15298 	    if (lastGcData && (lastGcData->_hDC == wDC)) {
 15296 	    if (lastGcData && (lastGcData->_hDC == wDC)) {
 15299 # ifdef DEBUG_DC_REUSE
 15297 # ifdef DEBUG_DC_REUSE
 15300 		fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
 15298 		console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - cachedDC reuse\n", __LINE__);
 15301 # endif
 15299 # endif
 15302 	    } else
 15300 	    } else
 15303 #endif
 15301 #endif
 15304 #ifdef CACHE_LAST_WM_PAINT_DC
 15302 #ifdef CACHE_LAST_WM_PAINT_DC
 15305 	    if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
 15303 	    if (last_wm_paint_dc && (last_wm_paint_dc == wDC)) {
 15306 # ifdef DEBUG_DC_REUSE
 15304 # ifdef DEBUG_DC_REUSE
 15307 		fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
 15305 		console_fprintf(stderr, "WinWorkstation [info]: Oops - dont release - last_wm_paint_dc reuse\n", __LINE__);
 15308 # endif
 15306 # endif
 15309 	    } else
 15307 	    } else
 15310 #endif
 15308 #endif
 15311 	    ReleaseDC(hWnd, wDC);
 15309 	    ReleaseDC(hWnd, wDC);
 15312 
 15310 
 15313 	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 15311 	    if (GetDIBits(bDC,hBitmap,0,height,0,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 15314 	    {
 15312 	    {
 15315 		INFOPRINT((stderr, "WinWorkstation [warning]: noinfo returned in primGetBits\n"));
 15313 		INFOFPRINTF((stderr, "WinWorkstation [warning]: noinfo returned in primGetBits\n"));
 15316 		goto fail;
 15314 		goto fail;
 15317 	    }
 15315 	    }
 15318 	    BMDPRINTF(("bitmap info:%d %d %d %d\n",
 15316 	    BMDPRINTF(("bitmap info:%d %d %d %d\n",
 15319 			bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
 15317 			bitmap.bmiHeader.biWidth, bitmap.bmiHeader.biHeight,
 15320 			bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
 15318 			bitmap.bmiHeader.biBitCount, bitmap.bmiHeader.biSizeImage));
 15321 	    numBytes = bitmap.bmiHeader.biSizeImage;
 15319 	    numBytes = bitmap.bmiHeader.biSizeImage;
 15322 	    if( numBytes != 0 ) {
 15320 	    if( numBytes != 0 ) {
 15323 		if (numBytes > __byteArraySize(imageBits)) {
 15321 		if (numBytes > __byteArraySize(imageBits)) {
 15324 		    /* imageBits too small */
 15322 		    /* imageBits too small */
 15325 		    INFOPRINT((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
 15323 		    INFOFPRINTF((stderr, "WinWorkstation [warning]: primGetBits - byteArray too small (is:%d need:%d; w:%d h:%d)\n",
 15326 				__byteArraySize(imageBits), numBytes,
 15324 				__byteArraySize(imageBits), numBytes,
 15327 				bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
 15325 				bitmap.bmiHeader.biWidth, -bitmap.bmiHeader.biHeight
 15328 			     ));
 15326 			     ));
 15329 		    goto fail;
 15327 		    goto fail;
 15330 		}
 15328 		}
 15331 		BMDPRINTF(("numBytes %d\n",numBytes));
 15329 		BMDPRINTF(("numBytes %d\n",numBytes));
 15332 
 15330 
 15333 		bitmap.bmiHeader.biHeight = -height;
 15331 		bitmap.bmiHeader.biHeight = -height;
 15334 		if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 15332 		if (GetDIBits(bDC,hBitmap,0,height,__ByteArrayInstPtr(imageBits)->ba_element,(struct tagBITMAPINFO *)&bitmap,DIB_RGB_COLORS) == 0)
 15335 		{
 15333 		{
 15336 		    INFOPRINT((stderr, "WinWorkstation [warning]: zero bits returned in primGetBits\n"));
 15334 		    INFOFPRINTF((stderr, "WinWorkstation [warning]: zero bits returned in primGetBits\n"));
 15337 		    goto fail;
 15335 		    goto fail;
 15338 		}
 15336 		}
 15339 
 15337 
 15340 		/* swap red and blue (windows delivers BGR) */
 15338 		/* swap red and blue (windows delivers BGR) */
 15341 		{
 15339 		{
 15366 			rowp += bytesPerRow;
 15364 			rowp += bytesPerRow;
 15367 		    };
 15365 		    };
 15368 #endif
 15366 #endif
 15369 		}
 15367 		}
 15370 	    } else {
 15368 	    } else {
 15371 		INFOPRINT((stderr, "WinWorkstation [warning]: unacceptable bitmap in primGetBits\n"));
 15369 		INFOFPRINTF((stderr, "WinWorkstation [warning]: unacceptable bitmap in primGetBits\n"));
 15372 		goto fail;
 15370 		goto fail;
 15373 	    }
 15371 	    }
 15374 	} else {
 15372 	} else {
 15375 	    INFOPRINT((stderr, "WinWorkstation [warning]: unacceptable bitmap in primGetBits\n"));
 15373 	    INFOFPRINTF((stderr, "WinWorkstation [warning]: unacceptable bitmap in primGetBits\n"));
 15376 	    goto fail;
 15374 	    goto fail;
 15377 	}
 15375 	}
 15378 
 15376 
 15379 	__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);                                 // bitOrder
 15377 	__ArrayInstPtr(info)->a_element[0] = @symbol(msbFirst);                                 // bitOrder
 15380 	__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(1);                                   // depth
 15378 	__ArrayInstPtr(info)->a_element[1] = __MKSMALLINT(1);                                   // depth
 15857 	    bw = GetWindow_bw(win);
 15855 	    bw = GetWindow_bw(win);
 15858 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 15856 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 15859 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 15857 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 15860 	    lI = GETLOCALWINDOWINFOPTR(win);
 15858 	    lI = GETLOCALWINDOWINFOPTR(win);
 15861 	    if (! lI) {
 15859 	    if (! lI) {
 15862 		fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in mapView\n");
 15860 		console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in mapView\n");
 15863 		RETURN (self);
 15861 		RETURN (self);
 15864 	    }
 15862 	    }
 15865 
 15863 
 15866 	    if (__bothSmallInteger(x, y)) {
 15864 	    if (__bothSmallInteger(x, y)) {
 15867 		__left = __intVal(x) + bw;
 15865 		__left = __intVal(x) + bw;
 16187 /* It has to be checked whether this can be deleted!!!!! */
 16185 /* It has to be checked whether this can be deleted!!!!! */
 16188 	    if ( oldIcon ) {
 16186 	    if ( oldIcon ) {
 16189 		if (DestroyIcon( oldIcon )) {
 16187 		if (DestroyIcon( oldIcon )) {
 16190 		    DPRINTF(( "Old icon deleted\n" ));
 16188 		    DPRINTF(( "Old icon deleted\n" ));
 16191 		} else {
 16189 		} else {
 16192 		    fprintf(stderr, "failed to delete old icon\n");
 16190 		    console_fprintf(stderr, "failed to delete old icon\n");
 16193 		}
 16191 		}
 16194 	    }
 16192 	    }
 16195 #else
 16193 #else
 16196 	    SendMessage(win, WM_SETICON,ICON_SMALL, (LPARAM)xIcon);
 16194 	    SendMessage(win, WM_SETICON,ICON_SMALL, (LPARAM)xIcon);
 16197 	    SendMessage(win, WM_SETICON,ICON_BIG, (LPARAM)xIcon);
 16195 	    SendMessage(win, WM_SETICON,ICON_BIG, (LPARAM)xIcon);
 16686 	if (win) {
 16684 	if (win) {
 16687 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 16685 	    winStyleBits = GetWindowLong(win, GWL_STYLE);
 16688 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 16686 	    winExStyleBits = GetWindowLong(win, GWL_EXSTYLE);
 16689 	    lI = GETLOCALWINDOWINFOPTR(win);
 16687 	    lI = GETLOCALWINDOWINFOPTR(win);
 16690 	    if (! lI) {
 16688 	    if (! lI) {
 16691 		fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in setMinMaxExt\n");
 16689 		console_fprintf(stderr, "WinWorkstation [info]: oops - no localInfo in setMinMaxExt\n");
 16692 		RETURN (self);
 16690 		RETURN (self);
 16693 	    }
 16691 	    }
 16694 
 16692 
 16695 	    if (__bothSmallInteger(minW, minH)) {
 16693 	    if (__bothSmallInteger(minW, minH)) {
 16696 		RECT rec;
 16694 		RECT rec;
 16756 	rgn = CreateEllipticRgn(left, top, right, bottom);
 16754 	rgn = CreateEllipticRgn(left, top, right, bottom);
 16757 	if (rgn) {
 16755 	if (rgn) {
 16758 	    winDC = GetDCEx(win, 0, DCX_WINDOW);
 16756 	    winDC = GetDCEx(win, 0, DCX_WINDOW);
 16759 	    if (winDC) {
 16757 	    if (winDC) {
 16760 		if (SelectClipRgn(winDC, rgn) == ERROR ) {
 16758 		if (SelectClipRgn(winDC, rgn) == ERROR ) {
 16761 		    fprintf(stderr, "select clipping region failed\n");
 16759 		    console_fprintf(stderr, "select clipping region failed\n");
 16762 		}
 16760 		}
 16763 		ReleaseDC(win, winDC);
 16761 		ReleaseDC(win, winDC);
 16764 	    }
 16762 	    }
 16765 	    else
 16763 	    else
 16766 		fprintf(stderr, "getDC failed\n");
 16764 		console_fprintf(stderr, "getDC failed\n");
 16767 
 16765 
 16768 	    _DeleteObject(rgn, __LINE__);
 16766 	    _DeleteObject(rgn, __LINE__);
 16769 	}
 16767 	}
 16770 	else
 16768 	else
 16771 	    fprintf(stderr, "region creation failed\n");
 16769 	    console_fprintf(stderr, "region creation failed\n");
 16772 	RETURN ( self );
 16770 	RETURN ( self );
 16773     }
 16771     }
 16774 %}.
 16772 %}.
 16775     self primitiveFailed
 16773     self primitiveFailed
 16776 !
 16774 !
 16926 ! !
 16924 ! !
 16927 
 16925 
 16928 !WinWorkstation class methodsFor:'documentation'!
 16926 !WinWorkstation class methodsFor:'documentation'!
 16929 
 16927 
 16930 version
 16928 version
 16931     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.336 2007-01-18 21:47:03 stefan Exp $'
 16929     ^ '$Header: /cvs/stx/stx/libview/WinWorkstation.st,v 1.337 2007-02-22 15:16:00 cg Exp $'
 16932 ! !
 16930 ! !
 16933 
 16931 
 16934 WinWorkstation initialize!
 16932 WinWorkstation initialize!