XWorkstation.st
changeset 3303 8a2e99ebccb3
parent 3287 7e5ed3b98481
child 3305 05abfe559bb6
equal deleted inserted replaced
3302:c06a207c33da 3303:8a2e99ebccb3
   187 
   187 
   188 void __XTimeoutErrorHandler();
   188 void __XTimeoutErrorHandler();
   189 int __XErrorHandler__();
   189 int __XErrorHandler__();
   190 int __XIOErrorHandler__();
   190 int __XIOErrorHandler__();
   191 
   191 
   192 #if 1 /* LINUX */
   192 #define DEFAULT_XLIB_TIMEOUT   600     /* in 50ms ticks (30 seconds) */
   193 # define DEFAULT_XLIB_TIMEOUT   600     /* in 50ms ticks (30 seconds) */
       
   194   static __xlibTimeout__ = DEFAULT_XLIB_TIMEOUT;
   193   static __xlibTimeout__ = DEFAULT_XLIB_TIMEOUT;
   195 
   194 
   196 # define ENTER_XLIB()   \
   195 #define ENTER_XLIB()   \
   197     { \
   196     { \
   198 	__blockingPrimitiveTimoutHandler__ = (VOIDFUNC)__XTimeoutErrorHandler; \
   197 	__blockingPrimitiveTimoutHandler__ = (VOIDFUNC)__XTimeoutErrorHandler; \
   199 	__blockingPrimitiveTimeoutArg__ = (INT)self; \
   198 	__blockingPrimitiveTimeoutArg__ = (INT)self; \
   200 	__blockingPrimitiveTimeout__ = __xlibTimeout__; \
   199 	__blockingPrimitiveTimeout__ = __xlibTimeout__; \
   201     } {
   200     } {
   202 # define LEAVE_XLIB()   \
   201 #define LEAVE_XLIB()   \
   203     { \
   202     { \
   204 	__blockingPrimitiveTimeout__ = 0; \
   203 	__blockingPrimitiveTimeout__ = 0; \
   205     } }
   204     } }
   206 #else
       
   207 # define ENTER_XLIB() {  /* as nothing */
       
   208 # define LEAVE_XLIB() }  /* as nothing */
       
   209 #endif
       
   210 
   205 
   211 %}
   206 %}
   212 ! !
   207 ! !
   213 
   208 
   214 !XWorkstation primitiveVariables!
   209 !XWorkstation primitiveVariables!
   485     "/ some XServers crash, when given too long strings in XDrawString/XDrawInageString.
   480     "/ some XServers crash, when given too long strings in XDrawString/XDrawInageString.
   486     "/ the following is an adjustable soft-limit.
   481     "/ the following is an adjustable soft-limit.
   487     MaxStringLength := 4096.
   482     MaxStringLength := 4096.
   488 
   483 
   489     RawKeysymTranslation isNil ifTrue:[
   484     RawKeysymTranslation isNil ifTrue:[
   490         "/ the following table maps X-keyevents to ST/X
   485 	"/ the following table maps X-keyevents to ST/X
   491         "/ device independed events. 
   486 	"/ device independed events. 
   492         "/ It is NOT meant as a keyboardMap replacement.
   487 	"/ It is NOT meant as a keyboardMap replacement.
   493 
   488 
   494         RawKeysymTranslation := d := Dictionary new.
   489 	RawKeysymTranslation := d := Dictionary new.
   495         d at:'Delete_line' put:#DeleteLine.
   490 	d at:'Delete_line' put:#DeleteLine.
   496         d at:'Delete_word' put:#DeleteWord.
   491 	d at:'Delete_word' put:#DeleteWord.
   497         d at:'Down' put:#CursorDown.
   492 	d at:'Down' put:#CursorDown.
   498         d at:'Up' put:#CursorUp.
   493 	d at:'Up' put:#CursorUp.
   499         d at:'Left' put:#CursorLeft.
   494 	d at:'Left' put:#CursorLeft.
   500         d at:'Right' put:#CursorRight.
   495 	d at:'Right' put:#CursorRight.
   501     ]
   496     ]
   502 
   497 
   503     "Modified: / 27.4.1999 / 17:21:30 / cg"
   498     "Modified: / 27.4.1999 / 17:21:30 / cg"
   504 ! !
   499 ! !
   505 
   500 
   624 
   619 
   625     |prev|
   620     |prev|
   626 
   621 
   627     prev := activateOnClick ? false.
   622     prev := activateOnClick ? false.
   628     aBoolean notNil ifTrue:[
   623     aBoolean notNil ifTrue:[
   629         activateOnClick := aBoolean.
   624 	activateOnClick := aBoolean.
   630     ].
   625     ].
   631     ^ prev
   626     ^ prev
   632 
   627 
   633     "
   628     "
   634      Display class activateOnClick:true
   629      Display class activateOnClick:true
   774 translatePoint:aPoint from:windowId1 to:windowId2
   769 translatePoint:aPoint from:windowId1 to:windowId2
   775     "given a point in window1, return the coordinate in window2.
   770     "given a point in window1, return the coordinate in window2.
   776      This expects a device coordinate (relative to the first views origin)
   771      This expects a device coordinate (relative to the first views origin)
   777      in aPoint and returns a device coordinate relative to the 2nd views origin.
   772      in aPoint and returns a device coordinate relative to the 2nd views origin.
   778      - use to xlate points from a window to rootwindow"
   773      - use to xlate points from a window to rootwindow"
       
   774 
       
   775     <context: #return>
   779 
   776 
   780     |x1 y1 x2 y2|
   777     |x1 y1 x2 y2|
   781 
   778 
   782     x1 := x2 := aPoint x truncated.
   779     x1 := x2 := aPoint x truncated.
   783     y1 := y2 := aPoint y truncated.
   780     y1 := y2 := aPoint y truncated.
   843     "given a point in rootWindow, return the viewId of the subview of windowId
   840     "given a point in rootWindow, return the viewId of the subview of windowId
   844      hit by this coordinate. Return nil if no view was hit.
   841      hit by this coordinate. Return nil if no view was hit.
   845      The returned id may be the id of a non ST view.
   842      The returned id may be the id of a non ST view.
   846      - used to find the window to drop objects after a cross-view drag."
   843      - used to find the window to drop objects after a cross-view drag."
   847 
   844 
   848 %{  /* NOCONTEXT */
   845     <context: #return>
   849 
   846 
       
   847 %{
   850     int screen = __intVal(__INST(screen));
   848     int screen = __intVal(__INST(screen));
   851     OBJ xp, yp;
   849     OBJ xp, yp;
   852     int xpos, ypos;
   850     int xpos, ypos;
   853     Window child_return;
   851     Window child_return;
   854 
   852 
   939     "query for an X extension. The argument, extensionString
   937     "query for an X extension. The argument, extensionString
   940      should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc).
   938      should be the name of the extension (i.e. 'SHAPE', 'XInputExtension' etc).
   941      Return true, if that extension is available in the server.
   939      Return true, if that extension is available in the server.
   942      (which does not imply, that there is support in smalltalk for it."
   940      (which does not imply, that there is support in smalltalk for it."
   943 
   941 
       
   942     <context: #return>
   944 %{
   943 %{
   945     int dummy;
   944     int dummy;
   946     OBJ rslt = false;
   945     OBJ rslt = false;
   947 
   946 
   948     if (ISCONNECTED
   947     if (ISCONNECTED
  1043 
  1042 
  1044 iconSizes
  1043 iconSizes
  1045     "Get the preferred/supported icon sizes. These are set by the window manager.
  1044     "Get the preferred/supported icon sizes. These are set by the window manager.
  1046      We return nil (if not set) or an OrderedCollection of iconSize specs."
  1045      We return nil (if not set) or an OrderedCollection of iconSize specs."
  1047 
  1046 
       
  1047     <context: #return>
       
  1048 
  1048     |xIconSizes count ret|
  1049     |xIconSizes count ret|
  1049 
  1050 
  1050 %{
  1051 %{
  1051     int screen = __intVal(__INST(screen));
  1052     int screen = __intVal(__INST(screen));
  1052     XIconSize *sizeList;
  1053     XIconSize *sizeList;
  1120 
  1121 
  1121     "Created: 10.6.1996 / 21:06:48 / cg"
  1122     "Created: 10.6.1996 / 21:06:48 / cg"
  1122 !
  1123 !
  1123 
  1124 
  1124 queryAtom:atomName
  1125 queryAtom:atomName
       
  1126     <context: #return>
  1125 %{
  1127 %{
  1126     Display *dpy;
  1128     Display *dpy;
  1127 
  1129 
  1128     if (ISCONNECTED) {
  1130     if (ISCONNECTED) {
  1129 	dpy = myDpy;
  1131 	dpy = myDpy;
  1682 
  1684 
  1683     |bitmapId|
  1685     |bitmapId|
  1684 
  1686 
  1685     bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
  1687     bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
  1686     bitmapId isNil ifTrue:[
  1688     bitmapId isNil ifTrue:[
  1687 	self primitiveFailed
  1689 	self primitiveFailedOrClosedConnection
  1688     ].
  1690     ].
  1689     ^ bitmapId
  1691     ^ bitmapId
  1690 !
  1692 !
  1691 
  1693 
  1692 createBitmapFromFile:aString for:aForm
  1694 createBitmapFromFile:aString for:aForm
       
  1695     <context: #return>
       
  1696 
  1693     |id w h|
  1697     |id w h|
  1694 
  1698 
  1695 %{
  1699 %{
  1696     int screen = __intVal(__INST(screen));
  1700     int screen = __intVal(__INST(screen));
  1697 
  1701 
  1733 
  1737 
  1734 createBitmapWidth:w height:h
  1738 createBitmapWidth:w height:h
  1735     "allocate a bitmap on the Xserver, the contents is undefined
  1739     "allocate a bitmap on the Xserver, the contents is undefined
  1736      (i.e. random). Return a bitmap id or nil"
  1740      (i.e. random). Return a bitmap id or nil"
  1737 
  1741 
  1738 %{  /* NOCONTEXT */
  1742     <context: #return>
  1739 
  1743 
       
  1744 %{  
  1740     int screen = __intVal(__INST(screen));
  1745     int screen = __intVal(__INST(screen));
  1741     Pixmap newBitmap;
  1746     Pixmap newBitmap;
  1742 
  1747 
  1743     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1748     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1744 	Display *dpy = myDpy;
  1749 	Display *dpy = myDpy;
  1754 #endif
  1759 #endif
  1755 
  1760 
  1756 	RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil );
  1761 	RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil );
  1757     }
  1762     }
  1758 %}.
  1763 %}.
  1759     self primitiveFailed.
  1764     self primitiveFailedOrClosedConnection.
  1760     ^ nil
  1765     ^ nil
  1761 !
  1766 !
  1762 
  1767 
  1763 createPixmapWidth:w height:h depth:d
  1768 createPixmapWidth:w height:h depth:d
  1764     "allocate a pixmap on the Xserver, the contents is undefined
  1769     "allocate a pixmap on the Xserver, the contents is undefined
  1765      (i.e. random). Return a bitmap id or nil"
  1770      (i.e. random). Return a bitmap id or nil"
  1766 
  1771 
  1767 %{  /* NOCONTEXT */
  1772     <context: #return>
       
  1773 %{  
  1768 
  1774 
  1769     int screen = __intVal(__INST(screen));
  1775     int screen = __intVal(__INST(screen));
  1770     Pixmap newBitmap;
  1776     Pixmap newBitmap;
  1771 
  1777 
  1772     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1778     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1783 #endif
  1789 #endif
  1784 
  1790 
  1785 	RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil );
  1791 	RETURN ( (newBitmap != (Pixmap)0) ? __MKEXTERNALADDRESS(newBitmap) : nil );
  1786     }
  1792     }
  1787 %}.
  1793 %}.
  1788     self primitiveFailed.
  1794     self primitiveFailedOrClosedConnection.
  1789     ^ nil
  1795     ^ nil
  1790 !
  1796 !
  1791 
  1797 
  1792 createWindowFor:aView type:typeSymbol
  1798 createWindowFor:aView type:typeSymbol
  1793 		 origin:origin
  1799 		 origin:origin
  1801 		 label:wlabel
  1807 		 label:wlabel
  1802 		 owner:wowner
  1808 		 owner:wowner
  1803 		 icon:wicon iconMask:wiconMask
  1809 		 icon:wicon iconMask:wiconMask
  1804 		 iconView:wiconView
  1810 		 iconView:wiconView
  1805 
  1811 
       
  1812     <context: #return>
       
  1813 
  1806     |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight 
  1814     |xpos ypos wwidth wheight minWidth minHeight maxWidth maxHeight 
  1807      bColorId wsuperViewId wiconId wiconMaskId windowId
  1815      bColorId wsuperViewId wiconId wiconMaskId windowId
  1808      weventMask wiconViewId bitGravity viewGravity vBgColor
  1816      weventMask wiconViewId bitGravity viewGravity vBgColor
  1809      vBgForm deepForm preferredVisual preferredDepth|
  1817      vBgForm deepForm preferredVisual preferredDepth|
  1810 
  1818 
  1811     displayId isNil ifTrue:[
  1819     displayId isNil ifTrue:[
  1812 	self primitiveFailed.
  1820 	self primitiveFailedOrClosedConnection.
  1813 	^ nil
  1821 	^ nil
  1814     ].
  1822     ].
  1815 
  1823 
  1816     origin notNil ifTrue:[
  1824     origin notNil ifTrue:[
  1817 	xpos := origin x.
  1825 	xpos := origin x.
  2118     ^ windowId
  2126     ^ windowId
  2119 !
  2127 !
  2120 
  2128 
  2121 destroyGC:aGCId
  2129 destroyGC:aGCId
  2122 
  2130 
  2123 %{  /* NOCONTEXT */
  2131     <context: #return>
       
  2132 %{ 
  2124 
  2133 
  2125     if (! ISCONNECTED) {
  2134     if (! ISCONNECTED) {
  2126 	RETURN ( self );
  2135 	RETURN ( self );
  2127     }
  2136     }
  2128 
  2137 
  2140 
  2149 
  2141 	}
  2150 	}
  2142 	RETURN ( self );
  2151 	RETURN ( self );
  2143     }
  2152     }
  2144 %}.
  2153 %}.
  2145     self primitiveFailed
  2154     self primitiveFailedOrClosedConnection
  2146 !
  2155 !
  2147 
  2156 
  2148 destroyPixmap:aDrawableId
  2157 destroyPixmap:aDrawableId
  2149 
  2158 
  2150 %{  /* NOCONTEXT */
  2159     <context: #return>
       
  2160 %{
  2151 
  2161 
  2152     if (! ISCONNECTED) {
  2162     if (! ISCONNECTED) {
  2153 	RETURN ( self );
  2163 	RETURN ( self );
  2154     }
  2164     }
  2155 
  2165 
  2167 
  2177 
  2168 	}
  2178 	}
  2169 	RETURN ( self );
  2179 	RETURN ( self );
  2170     }
  2180     }
  2171 %}.
  2181 %}.
  2172     self primitiveFailed
  2182     self primitiveFailedOrClosedConnection
  2173 !
  2183 !
  2174 
  2184 
  2175 destroyView:aView withId:aWindowId
  2185 destroyView:aView withId:aWindowId
  2176     self primDestroyView:aView withId:aWindowId.
  2186     self primDestroyView:aView withId:aWindowId.
  2177     self removeKnownView:aView withId:aWindowId.
  2187     self removeKnownView:aView withId:aWindowId.
  2200 
  2210 
  2201 	RETURN ( dps ? __MKEXTERNALADDRESS(dps) : nil );
  2211 	RETURN ( dps ? __MKEXTERNALADDRESS(dps) : nil );
  2202     }
  2212     }
  2203 #endif
  2213 #endif
  2204 %}.
  2214 %}.
  2205     self primitiveFailed.
  2215     self primitiveFailedOrClosedConnection.
  2206     ^ nil
  2216     ^ nil
  2207 !
  2217 !
  2208 
  2218 
  2209 gcFor:aDrawableId
  2219 gcFor:aDrawableId
  2210 
  2220 
  2211 %{  /* NOCONTEXT */
  2221     <context: #return>
       
  2222 %{  
  2212     int screen = __intVal(__INST(screen));
  2223     int screen = __intVal(__INST(screen));
  2213     GC gc;
  2224     GC gc;
  2214 
  2225 
  2215     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
  2226     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
  2216 
  2227 
  2226 
  2237 
  2227 
  2238 
  2228 	RETURN ( gc ? __MKEXTERNALADDRESS(gc) : nil );
  2239 	RETURN ( gc ? __MKEXTERNALADDRESS(gc) : nil );
  2229     }
  2240     }
  2230 %}.
  2241 %}.
  2231     self primitiveFailed.
  2242     self primitiveFailedOrClosedConnection.
  2232     ^ nil
  2243     ^ nil
  2233 !
  2244 !
  2234 
  2245 
  2235 gcForBitmap:aDrawableId
  2246 gcForBitmap:aDrawableId
  2236     "with X, this is the same as a normal gc"
  2247     "with X, this is the same as a normal gc"
  2237 
  2248 
  2238 %{  /* NOCONTEXT */
  2249     ^ self gcFor:aDrawableId
  2239     int screen = __intVal(__INST(screen));
       
  2240     GC gc;
       
  2241 
       
  2242     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
       
  2243 
       
  2244 	ENTER_XLIB();
       
  2245 	gc = XCreateGC(myDpy, (Drawable)_WindowVal(aDrawableId),
       
  2246 			      0L, (XGCValues *)0);
       
  2247 	LEAVE_XLIB();
       
  2248 
       
  2249 #ifdef COUNT_RESOURCES
       
  2250 	if (gc)
       
  2251 	    __cnt_gc++;
       
  2252 #endif
       
  2253 
       
  2254 
       
  2255 	RETURN ( gc ? __MKEXTERNALADDRESS(gc) : nil );
       
  2256     }
       
  2257 %}.
       
  2258     ^ nil
       
  2259 !
  2250 !
  2260 
  2251 
  2261 primCreateBitmapFromArray:anArray width:w height:h
  2252 primCreateBitmapFromArray:anArray width:w height:h
       
  2253 
       
  2254     <context: #return>
  2262 
  2255 
  2263 %{  /* UNLIMITEDSTACK */
  2256 %{  /* UNLIMITEDSTACK */
  2264 
  2257 
  2265     Display *dpy;
  2258     Display *dpy;
  2266     int screen = __intVal(__INST(screen));
  2259     int screen = __intVal(__INST(screen));
  2357 	if (allocatedBits)
  2350 	if (allocatedBits)
  2358 	    free(allocatedBits);
  2351 	    free(allocatedBits);
  2359 	RETURN ( newBitmap ? __MKEXTERNALADDRESS(newBitmap) : nil );
  2352 	RETURN ( newBitmap ? __MKEXTERNALADDRESS(newBitmap) : nil );
  2360     }
  2353     }
  2361 %}.
  2354 %}.
  2362     self primitiveFailed.
  2355     self primitiveFailedOrClosedConnection.
  2363     ^ nil
  2356     ^ nil
  2364 !
  2357 !
  2365 
  2358 
  2366 primCreateWindowType:t origin:o extent:e minExtent:minE maxExtent:maxE borderWidth:bw superViewId:sv style:st inputOnly:i label:l ownerId:oId iconId:ic iconMaskId:im iconViewId:iv
  2359 primCreateWindowType:t origin:o extent:e minExtent:minE maxExtent:maxE borderWidth:bw superViewId:sv style:st inputOnly:i label:l ownerId:oId iconId:ic iconMaskId:im iconViewId:iv
  2367     "for rel5 only"
  2360     "for rel5 only"
  2368 
  2361 
  2369     ^ self primitiveFailed
  2362     ^ self primitiveFailedOrClosedConnection
  2370 
  2363 
  2371 !
  2364 !
  2372 
  2365 
  2373 primDestroyView:aView withId:aWindowId
  2366 primDestroyView:aView withId:aWindowId
       
  2367     <context: #return>
  2374 %{
  2368 %{
  2375     if (! ISCONNECTED) {
  2369     if (! ISCONNECTED) {
  2376         RETURN ( self );
  2370 	RETURN ( self );
  2377     }
  2371     }
  2378 
  2372 
  2379     if (__isExternalAddress(aWindowId)) {
  2373     if (__isExternalAddress(aWindowId)) {
  2380         Window win = _WindowVal(aWindowId);
  2374 	Window win = _WindowVal(aWindowId);
  2381 
  2375 
  2382         if (win) {
  2376 	if (win) {
  2383 
  2377 
  2384             ENTER_XLIB();
  2378 	    ENTER_XLIB();
  2385             XDestroyWindow(myDpy, win);
  2379 	    XDestroyWindow(myDpy, win);
  2386             LEAVE_XLIB();
  2380 	    LEAVE_XLIB();
  2387 #ifdef COUNT_RESOURCES
  2381 #ifdef COUNT_RESOURCES
  2388             __cnt_view--;
  2382 	    __cnt_view--;
  2389 #endif
  2383 #endif
  2390 
  2384 
  2391         }
  2385 	}
  2392     }
  2386     }
  2393 %}
  2387 %}
  2394 !
  2388 !
  2395 
  2389 
  2396 realRootWindowId
  2390 realRootWindowId
  2417 	    __INST(rootId) = id = __MKEXTERNALADDRESS(root); __STORE(self, id);
  2411 	    __INST(rootId) = id = __MKEXTERNALADDRESS(root); __STORE(self, id);
  2418 	}
  2412 	}
  2419 	RETURN (id);
  2413 	RETURN (id);
  2420     }
  2414     }
  2421 %}.
  2415 %}.
  2422     self primitiveFailed.
  2416     self primitiveFailedOrClosedConnection.
  2423     ^ nil
  2417     ^ nil
  2424 !
  2418 !
  2425 
  2419 
  2426 rootWindowId
  2420 rootWindowId
  2427     "return the id of the root window.
  2421     "return the id of the root window.
  2509 
  2503 
  2510 colorCell
  2504 colorCell
  2511     "allocate a color cell - return the color index (i.e. colorID).
  2505     "allocate a color cell - return the color index (i.e. colorID).
  2512      This method will return nil for StaticGrey, StaticGrey and TrueColor displays."
  2506      This method will return nil for StaticGrey, StaticGrey and TrueColor displays."
  2513 
  2507 
  2514 %{  /* NOCONTEXT */
  2508     <context: #return>
       
  2509 %{
  2515 
  2510 
  2516     int screen = __intVal(__INST(screen));
  2511     int screen = __intVal(__INST(screen));
  2517     XColor color;
  2512     XColor color;
  2518     unsigned long dummy;
  2513     unsigned long dummy;
  2519     Status ok;
  2514     Status ok;
  2540 
  2535 
  2541 colorNamed:aString
  2536 colorNamed:aString
  2542     "allocate a color with color name - return the color index (i.e. colorID).
  2537     "allocate a color with color name - return the color index (i.e. colorID).
  2543      Dont use this method, colornames are mostly X specific"
  2538      Dont use this method, colornames are mostly X specific"
  2544 
  2539 
  2545 %{  /* NOCONTEXT */
  2540     <context: #return>
       
  2541 %{  
  2546 
  2542 
  2547     char *colorname;
  2543     char *colorname;
  2548     XColor scolor, ecolor;
  2544     XColor scolor, ecolor;
  2549     int screen = __intVal(__INST(screen));
  2545     int screen = __intVal(__INST(screen));
  2550     int id;
  2546     int id;
  2587     ^ super colorNamed:aString
  2583     ^ super colorNamed:aString
  2588 !
  2584 !
  2589 
  2585 
  2590 colorScaledRed:r scaledGreen:g scaledBlue:b
  2586 colorScaledRed:r scaledGreen:g scaledBlue:b
  2591     "allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)"
  2587     "allocate a color with rgb values (0..16rFFFF) - return the color index (i.e. colorID)"
       
  2588 
       
  2589     <context: #return>
  2592 %{
  2590 %{
  2593     Display *dpy;
  2591     Display *dpy;
  2594     XColor ecolor;
  2592     XColor ecolor;
  2595     int screen = __intVal(__INST(screen));
  2593     int screen = __intVal(__INST(screen));
  2596     Status ok;
  2594     Status ok;
  2642 !
  2640 !
  2643 
  2641 
  2644 freeColor:colorIndex
  2642 freeColor:colorIndex
  2645     "free a display color when its no longer needed"
  2643     "free a display color when its no longer needed"
  2646 
  2644 
  2647 %{  /* NOCONTEXT */
  2645     <context: #return>
       
  2646 %{
  2648 
  2647 
  2649     Display *dpy;
  2648     Display *dpy;
  2650     unsigned long color;
  2649     unsigned long color;
  2651     int screen = __intVal(__INST(screen));
  2650     int screen = __intVal(__INST(screen));
  2652 
  2651 
  2673 #endif
  2672 #endif
  2674 
  2673 
  2675 	RETURN ( self );
  2674 	RETURN ( self );
  2676     }
  2675     }
  2677 %}.
  2676 %}.
  2678     self primitiveFailed
  2677     self primitiveFailedOrClosedConnection
  2679 !
  2678 !
  2680 
  2679 
  2681 getScaledRGBFrom:index
  2680 getScaledRGBFrom:index
  2682     "get rgb components (0 .. 16rFFFF) of color in map at:index,
  2681     "get rgb components (0 .. 16rFFFF) of color in map at:index,
  2683      and return a 3-element array containing them"
  2682      and return a 3-element array containing them"
  2684 
  2683 
       
  2684     <context: #return>
  2685 %{
  2685 %{
  2686     int screen = __intVal(__INST(screen));
  2686     int screen = __intVal(__INST(screen));
  2687     XColor color;
  2687     XColor color;
  2688     int sr, sg, sb;
  2688     int sr, sg, sb;
  2689     int bits, scale, shift;
  2689     int bits, scale, shift;
  2815 
  2815 
  2816 setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue
  2816 setColor:index scaledRed:sred scaledGreen:sgreen scaledBlue:sblue
  2817     "change color in map at:index to rgb (0..16rFFFF).
  2817     "change color in map at:index to rgb (0..16rFFFF).
  2818      This method is a noop for StaticGrey, StaticGrey and TrueColor displays."
  2818      This method is a noop for StaticGrey, StaticGrey and TrueColor displays."
  2819 
  2819 
  2820 %{  /* NOCONTEXT */
  2820     <context: #return>
       
  2821 %{ 
  2821 
  2822 
  2822     char *colorname;
  2823     char *colorname;
  2823     XColor color;
  2824     XColor color;
  2824     int screen = __intVal(__INST(screen));
  2825     int screen = __intVal(__INST(screen));
  2825     int r, g, b;
  2826     int r, g, b;
  2853 	LEAVE_XLIB();
  2854 	LEAVE_XLIB();
  2854 
  2855 
  2855 	RETURN ( self );
  2856 	RETURN ( self );
  2856     }
  2857     }
  2857 %}.
  2858 %}.
  2858     self primitiveFailed
  2859     self primitiveFailedOrClosedConnection
  2859 ! !
  2860 ! !
  2860 
  2861 
  2861 !XWorkstation methodsFor:'cursor stuff'!
  2862 !XWorkstation methodsFor:'cursor stuff'!
  2862 
  2863 
  2863 builtInCursorShapes
  2864 builtInCursorShapes
  2900 !
  2901 !
  2901 
  2902 
  2902 colorCursor:aCursorId foreground:fgColor background:bgColor
  2903 colorCursor:aCursorId foreground:fgColor background:bgColor
  2903     "change a cursors colors"
  2904     "change a cursors colors"
  2904 
  2905 
       
  2906     <context: #return>
       
  2907 
  2905     |fgR fgG fgB bgR bgG bgB|
  2908     |fgR fgG fgB bgR bgG bgB|
  2906 
  2909 
  2907     fgR := fgColor scaledRed.
  2910     fgR := fgColor scaledRed.
  2908     fgG := fgColor scaledGreen.
  2911     fgG := fgColor scaledGreen.
  2909     fgB := fgColor scaledBlue.
  2912     fgB := fgColor scaledBlue.
  2931 	LEAVE_XLIB();
  2934 	LEAVE_XLIB();
  2932 
  2935 
  2933 	RETURN ( self );
  2936 	RETURN ( self );
  2934     }
  2937     }
  2935 %}.
  2938 %}.
  2936     self primitiveFailed
  2939     self primitiveFailedOrClosedConnection
  2937 !
  2940 !
  2938 
  2941 
  2939 createCursorShape:aShape
  2942 createCursorShape:aShape
  2940     "create a cursor given a shape-symbol. This only works
  2943     "create a cursor given a shape-symbol. This only works
  2941      for a few standard cursors, and returns nil if no such cursor exists.
  2944      for a few standard cursors, and returns nil if no such cursor exists.
  2942      Senders must always care for a fallBack, in case of a nil return."
  2945      Senders must always care for a fallBack, in case of a nil return."
  2943 
  2946 
  2944     |shapeNumber id|
  2947     |shapeNumber|
  2945 
  2948 
  2946     shapeNumber := self shapeNumberFromSymbol:aShape.
  2949     shapeNumber := self shapeNumberFromSymbol:aShape.
  2947     shapeNumber isNil ifTrue:[^ nil].
  2950     shapeNumber isNil ifTrue:[^ nil].
  2948     ^ self primCreateCursorShapeNumber:shapeNumber
  2951     ^ self primCreateCursorShapeNumber:shapeNumber
  2949 !
  2952 !
  2950 
  2953 
  2951 createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h
  2954 createCursorSourceForm:sourceForm maskForm:maskForm hotX:hx hotY:hy width:w height:h
  2952     "create a cursor given 2 bitmaps (source, mask) and a hotspot"
  2955     "create a cursor given 2 bitmaps (source, mask) and a hotspot"
  2953 
  2956 
  2954     ^ self
  2957     ^ self
  2955         primCreateCursorSourceFormId:sourceForm id 
  2958 	primCreateCursorSourceFormId:sourceForm id 
  2956         maskFormId:maskForm id
  2959 	maskFormId:maskForm id
  2957         hotX:hx hotY:hy 
  2960 	hotX:hx hotY:hy 
  2958         width:w height:h
  2961 	width:w height:h
  2959 !
  2962 !
  2960 
  2963 
  2961 destroyCursor:aCursorId
  2964 destroyCursor:aCursorId
  2962     "release a cursor - frees any device resources"
  2965     "release a cursor - frees any device resources"
  2963 
  2966 
  2964 %{  /* NOCONTEXT */
  2967     <context: #return>
       
  2968 %{
  2965 
  2969 
  2966     if (! ISCONNECTED) {
  2970     if (! ISCONNECTED) {
  2967 	RETURN ( self );
  2971 	RETURN ( self );
  2968     }
  2972     }
  2969 
  2973 
  2981 
  2985 
  2982 	}
  2986 	}
  2983 	RETURN ( self );
  2987 	RETURN ( self );
  2984     }
  2988     }
  2985 %}.
  2989 %}.
  2986     self primitiveFailed
  2990     self primitiveFailedOrClosedConnection
  2987 !
  2991 !
  2988 
  2992 
  2989 needDeviceFormsForCursor
  2993 needDeviceFormsForCursor
  2990     ^ true
  2994     ^ true
  2991 !
  2995 !
  2992 
  2996 
  2993 primCreateCursorShapeNumber:aShapeNumber
  2997 primCreateCursorShapeNumber:aShapeNumber
  2994     "create a cursor given a shape-number."
  2998     "create a cursor given a shape-number."
  2995 
  2999 
       
  3000     <context: #return>
  2996 %{
  3001 %{
  2997     Cursor newCursor;
  3002     Cursor newCursor;
  2998 
  3003 
  2999     if (ISCONNECTED
  3004     if (ISCONNECTED
  3000      && __isSmallInteger(aShapeNumber)) {
  3005      && __isSmallInteger(aShapeNumber)) {
  3001 
  3006 
  3002         ENTER_XLIB();
  3007 	ENTER_XLIB();
  3003         newCursor = XCreateFontCursor(myDpy, __intVal(aShapeNumber));
  3008 	newCursor = XCreateFontCursor(myDpy, __intVal(aShapeNumber));
  3004         LEAVE_XLIB();
  3009 	LEAVE_XLIB();
  3005 #ifdef COUNT_RESOURCES
  3010 #ifdef COUNT_RESOURCES
  3006         if (newCursor)
  3011 	if (newCursor)
  3007             __cnt_cursor++;
  3012 	    __cnt_cursor++;
  3008 #endif
  3013 #endif
  3009 
  3014 
  3010         if (newCursor != (Cursor)0) {
  3015 	if (newCursor != (Cursor)0) {
  3011             RETURN (__MKEXTERNALADDRESS(newCursor));
  3016 	    RETURN (__MKEXTERNALADDRESS(newCursor));
  3012         }
  3017 	}
  3013     }
  3018     }
  3014 %}.
  3019 %}.
       
  3020     self primitiveFailedOrClosedConnection.
  3015     ^ nil
  3021     ^ nil
  3016 !
  3022 !
  3017 
  3023 
  3018 primCreateCursorSourceFormId:sourceId maskFormId:maskId hotX:hx hotY:hy width:w height:h
  3024 primCreateCursorSourceFormId:sourceId maskFormId:maskId hotX:hx hotY:hy width:w height:h
  3019     "create a cursor given 2 bitmaps (source, mask) and a hotspot"
  3025     "create a cursor given 2 bitmaps (source, mask) and a hotspot"
  3020 
  3026 
       
  3027     <context: #return>
  3021 %{
  3028 %{
  3022     Cursor newCursor;
  3029     Cursor newCursor;
  3023     XColor fgColor, bgColor;
  3030     XColor fgColor, bgColor;
  3024 
  3031 
  3025     if (ISCONNECTED
  3032     if (ISCONNECTED
  3026      && __isExternalAddress(sourceId)
  3033      && __isExternalAddress(sourceId)
  3027      && __isExternalAddress(maskId)
  3034      && __isExternalAddress(maskId)
  3028      && __bothSmallInteger(hx, hy)) {
  3035      && __bothSmallInteger(hx, hy)) {
  3029         fgColor.red = 0;        /* fg is black */
  3036 	fgColor.red = 0;        /* fg is black */
  3030         fgColor.green = 0;
  3037 	fgColor.green = 0;
  3031         fgColor.blue = 0;
  3038 	fgColor.blue = 0;
  3032         bgColor.red = 0xFFFF;   /* bg is white */
  3039 	bgColor.red = 0xFFFF;   /* bg is white */
  3033         bgColor.green = 0xFFFF;
  3040 	bgColor.green = 0xFFFF;
  3034         bgColor.blue = 0xFFFF;
  3041 	bgColor.blue = 0xFFFF;
  3035 
  3042 
  3036 
  3043 
  3037         ENTER_XLIB();
  3044 	ENTER_XLIB();
  3038         newCursor = XCreatePixmapCursor(myDpy,
  3045 	newCursor = XCreatePixmapCursor(myDpy,
  3039                                 _PixmapVal(sourceId),
  3046 				_PixmapVal(sourceId),
  3040                                 _PixmapVal(maskId),
  3047 				_PixmapVal(maskId),
  3041                                 &fgColor, &bgColor, __intVal(hx), __intVal(hy));
  3048 				&fgColor, &bgColor, __intVal(hx), __intVal(hy));
  3042         LEAVE_XLIB();
  3049 	LEAVE_XLIB();
  3043 #ifdef COUNT_RESOURCES
  3050 #ifdef COUNT_RESOURCES
  3044         if (newCursor)
  3051 	if (newCursor)
  3045             __cnt_cursor++;
  3052 	    __cnt_cursor++;
  3046 #endif
  3053 #endif
  3047 
  3054 
  3048         if (newCursor != (Cursor)0) {
  3055 	if (newCursor != (Cursor)0) {
  3049             RETURN (__MKEXTERNALADDRESS(newCursor));
  3056 	    RETURN (__MKEXTERNALADDRESS(newCursor));
  3050         }
  3057 	}
  3051     }
  3058     }
  3052 %}.
  3059 %}.
  3053     self primitiveFailed.
  3060     self primitiveFailedOrClosedConnection.
  3054     ^ nil
  3061     ^ nil
  3055 !
  3062 !
  3056 
  3063 
  3057 shapeNumberFromSymbol:shape
  3064 shapeNumberFromSymbol:shape
  3058     "given a shape-symbol, return the corresponding cursor-number,
  3065     "given a shape-symbol, return the corresponding cursor-number,
  3275     "do a bit-blt; copy bits from the rectangle defined by
  3282     "do a bit-blt; copy bits from the rectangle defined by
  3276      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3283      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3277      below dstX/dstY in the destId drawable. Trigger an error if any
  3284      below dstX/dstY in the destId drawable. Trigger an error if any
  3278      argument is not integer."
  3285      argument is not integer."
  3279 
  3286 
  3280 %{  /* NOCONTEXT */
  3287     <context: #return>
       
  3288 %{
  3281 
  3289 
  3282     GC gc;
  3290     GC gc;
  3283     Drawable source, dest;
  3291     Drawable source, dest;
  3284 
  3292 
  3285     if (ISCONNECTED
  3293     if (ISCONNECTED
  3308     }
  3316     }
  3309 %}.
  3317 %}.
  3310     "badGC, bad sourceDrawableId or destDrawableID
  3318     "badGC, bad sourceDrawableId or destDrawableID
  3311      or any non integer coordinate"
  3319      or any non integer coordinate"
  3312 
  3320 
  3313     self primitiveFailed
  3321     self primitiveFailedOrClosedConnection
  3314 !
  3322 !
  3315 
  3323 
  3316 copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3324 copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3317     "do a bit-blt from a pix- or bitmap; copy bits from the rectangle defined by
  3325     "do a bit-blt from a pix- or bitmap; copy bits from the rectangle defined by
  3318      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3326      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3319      below dstX/dstY in the destId drawable. Trigger an error if any
  3327      below dstX/dstY in the destId drawable. Trigger an error if any
  3320      argument is not integer.
  3328      argument is not integer.
  3321      This is basically the same as copyFromId:..., but does not generate expose events."
  3329      This is basically the same as copyFromId:..., but does not generate expose events."
  3322 
  3330 
  3323 %{  /* NOCONTEXT */
  3331     <context: #return>
       
  3332 %{  
  3324 
  3333 
  3325     GC gc;
  3334     GC gc;
  3326     Drawable source, dest;
  3335     Drawable source, dest;
  3327 
  3336 
  3328     if (ISCONNECTED
  3337     if (ISCONNECTED
  3349     }
  3358     }
  3350 %}.
  3359 %}.
  3351     "badGC, bad sourceDrawableId or destDrawableID
  3360     "badGC, bad sourceDrawableId or destDrawableID
  3352      or any non integer coordinate"
  3361      or any non integer coordinate"
  3353 
  3362 
  3354     self primitiveFailed
  3363     self primitiveFailedOrClosedConnection
  3355 !
  3364 !
  3356 
  3365 
  3357 copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3366 copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3358     "do a bit-blt, but only copy the low-bit plane; 
  3367     "do a bit-blt, but only copy the low-bit plane; 
  3359      copy bits from the rectangle defined by
  3368      copy bits from the rectangle defined by
  3360      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3369      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3361      below dstX/dstY in the destId drawable. Trigger an error if any
  3370      below dstX/dstY in the destId drawable. Trigger an error if any
  3362      argument is not integer."
  3371      argument is not integer."
  3363 
  3372 
  3364 %{  /* NOCONTEXT */
  3373     <context: #return>
       
  3374 %{  
  3365 
  3375 
  3366     GC gc;
  3376     GC gc;
  3367     Drawable source, dest;
  3377     Drawable source, dest;
  3368 
  3378 
  3369     if (ISCONNECTED
  3379     if (ISCONNECTED
  3386     }
  3396     }
  3387 %}.
  3397 %}.
  3388     "badGC, bad sourceDrawableId or destDrawableID
  3398     "badGC, bad sourceDrawableId or destDrawableID
  3389      or any non integer coordinate"
  3399      or any non integer coordinate"
  3390 
  3400 
  3391     self primitiveFailed
  3401     self primitiveFailedOrClosedConnection
  3392 !
  3402 !
  3393 
  3403 
  3394 copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3404 copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  3395     "do a bit-blt from a pix- or bitmap, but only copy the low-bit plane; 
  3405     "do a bit-blt from a pix- or bitmap, but only copy the low-bit plane; 
  3396      copy bits from the rectangle defined by
  3406      copy bits from the rectangle defined by
  3397      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3407      srcX/srcY and w/h from the sourceId drawable to the rectangle
  3398      below dstX/dstY in the destId drawable. Trigger an error if any
  3408      below dstX/dstY in the destId drawable. Trigger an error if any
  3399      argument is not integer.
  3409      argument is not integer.
  3400      This is the same as copyPlaneFromId:..., but does not generate graphics exposes"
  3410      This is the same as copyPlaneFromId:..., but does not generate graphics exposes"
  3401 
  3411 
  3402 %{  /* NOCONTEXT */
  3412     <context: #return>
       
  3413 %{  
  3403 
  3414 
  3404     GC gc;
  3415     GC gc;
  3405     Drawable source, dest;
  3416     Drawable source, dest;
  3406 
  3417 
  3407     if (ISCONNECTED
  3418     if (ISCONNECTED
  3428     }
  3439     }
  3429 %}.
  3440 %}.
  3430     "badGC, bad sourceDrawableId or destDrawableID
  3441     "badGC, bad sourceDrawableId or destDrawableID
  3431      or any non integer coordinate"
  3442      or any non integer coordinate"
  3432 
  3443 
  3433     self primitiveFailed
  3444     self primitiveFailedOrClosedConnection
  3434 !
  3445 !
  3435 
  3446 
  3436 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId
  3447 displayArcX:x y:y width:width height:height from:startAngle angle:angle in:aDrawableId with:aGCId
  3437     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
  3448     "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
  3438      The angles may be floats or integer - they are given in degrees."
  3449      The angles may be floats or integer - they are given in degrees."
  3439 
  3450 
  3440 %{  /* NOCONTEXT */
  3451     <context: #return>
       
  3452 %{  
  3441 
  3453 
  3442     GC gc;
  3454     GC gc;
  3443     Window win;
  3455     Window win;
  3444     int w, h, angle1, angle2;
  3456     int w, h, angle1, angle2;
  3445     double f;
  3457     double f;
  3487     bad: ;
  3499     bad: ;
  3488 %}.
  3500 %}.
  3489     "badGC, badDrawable or coordinates not integer
  3501     "badGC, badDrawable or coordinates not integer
  3490      or angle(s) not integer or float."
  3502      or angle(s) not integer or float."
  3491 
  3503 
  3492     self primitiveFailed
  3504     self primitiveFailedOrClosedConnection
  3493 !
  3505 !
  3494 
  3506 
  3495 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
  3507 displayLineFromX:x0 y:y0 toX:x1 y:y1 in:aDrawableId with:aGCId
  3496     "draw a line. If the coordinates are not integers, an error is triggered." 
  3508     "draw a line. If the coordinates are not integers, an error is triggered." 
  3497 
  3509 
  3498 %{  /* NOCONTEXT */
  3510     <context: #return>
       
  3511 %{
  3499 
  3512 
  3500     GC gc;
  3513     GC gc;
  3501     Window win;
  3514     Window win;
  3502 
  3515 
  3503     if (ISCONNECTED
  3516     if (ISCONNECTED
  3519 	LEAVE_XLIB();
  3532 	LEAVE_XLIB();
  3520 	RETURN ( self );
  3533 	RETURN ( self );
  3521     }
  3534     }
  3522 %}.
  3535 %}.
  3523     "badGC, badDrawable or coordinates not integer"
  3536     "badGC, badDrawable or coordinates not integer"
  3524     self primitiveFailed
  3537     self primitiveFailedOrClosedConnection
  3525 !
  3538 !
  3526 
  3539 
  3527 displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId
  3540 displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId
  3528     "draw a polygon starting at x; the y values derives from the collection yValues.
  3541     "draw a polygon starting at x; the y values derives from the collection yValues.
  3529      The associated x is a multiple of step. Each y value will be scaled and translated
  3542      The associated x is a multiple of step. Each y value will be scaled and translated
  3530     "
  3543     "
  3531 
  3544 
       
  3545     <context: #return>
       
  3546 
  3532     |noY|
  3547     |noY|
  3533 
  3548 
  3534     (noY := yValues size) < 2 ifTrue:[
  3549     (noY := yValues size) < 2 ifTrue:[
  3535         ^ self
  3550 	^ self
  3536     ].
  3551     ].
  3537 
  3552 
  3538 %{
  3553 %{
  3539     OBJ      yA, t;
  3554     OBJ      yA, t;
  3540     int      i, num;
  3555     int      i, num;
  3547     Window win;
  3562     Window win;
  3548 
  3563 
  3549     if (ISCONNECTED
  3564     if (ISCONNECTED
  3550      && __isExternalAddress(aGCId)
  3565      && __isExternalAddress(aGCId)
  3551      && __isExternalAddress(aDrawableId) ) {
  3566      && __isExternalAddress(aDrawableId) ) {
  3552         gc = _GCVal(aGCId);
  3567 	gc = _GCVal(aGCId);
  3553         win = _WindowVal(aDrawableId);
  3568 	win = _WindowVal(aDrawableId);
  3554 
  3569 
  3555         if( __isSmallInteger(scaleY) ) 
  3570 	if( __isSmallInteger(scaleY) ) 
  3556             sY = (float) __intVal( scaleY );
  3571 	    sY = (float) __intVal( scaleY );
  3557         else if (__isFloat(scaleY)) 
  3572 	else if (__isFloat(scaleY)) 
  3558             sY = __floatVal( scaleY );
  3573 	    sY = __floatVal( scaleY );
  3559         else if (__isShortFloat(scaleY)) 
  3574 	else if (__isShortFloat(scaleY)) 
  3560             sY = __shortFloatVal( scaleY );
  3575 	    sY = __shortFloatVal( scaleY );
  3561         else {
  3576 	else {
  3562             t = __SSEND0(scaleY, @symbol(asFloat), 0);
  3577 	    t = __SSEND0(scaleY, @symbol(asFloat), 0);
  3563             if (! __isFloat(t)) goto fail;
  3578 	    if (! __isFloat(t)) goto fail;
  3564             sY = __floatVal( t );
  3579 	    sY = __floatVal( t );
  3565         }
  3580 	}
  3566 
  3581 
  3567         if( __isSmallInteger(transY) ) 
  3582 	if( __isSmallInteger(transY) ) 
  3568             tY = (float) __intVal( transY );
  3583 	    tY = (float) __intVal( transY );
  3569         else if (__isFloat(transY)) 
  3584 	else if (__isFloat(transY)) 
  3570             tY = __floatVal( transY );
  3585 	    tY = __floatVal( transY );
  3571         else if (__isShortFloat(transY)) 
  3586 	else if (__isShortFloat(transY)) 
  3572             tY = __shortFloatVal( transY );
  3587 	    tY = __shortFloatVal( transY );
  3573         else {
  3588 	else {
  3574             t = __SSEND0(transY, @symbol(asFloat), 0);
  3589 	    t = __SSEND0(transY, @symbol(asFloat), 0);
  3575             if (! __isFloat(t)) goto fail;
  3590 	    if (! __isFloat(t)) goto fail;
  3576             tY = __floatVal( t );
  3591 	    tY = __floatVal( t );
  3577         }
  3592 	}
  3578 
  3593 
  3579         if( __isSmallInteger(startX) ) 
  3594 	if( __isSmallInteger(startX) ) 
  3580             x = (float) __intVal( startX );
  3595 	    x = (float) __intVal( startX );
  3581         else if (__isFloat(startX)) 
  3596 	else if (__isFloat(startX)) 
  3582             x = __floatVal( startX );
  3597 	    x = __floatVal( startX );
  3583         else if (__isShortFloat(startX)) 
  3598 	else if (__isShortFloat(startX)) 
  3584             x = __shortFloatVal( startX );
  3599 	    x = __shortFloatVal( startX );
  3585         else {
  3600 	else {
  3586             t = __SSEND0(startX, @symbol(asFloat), 0);
  3601 	    t = __SSEND0(startX, @symbol(asFloat), 0);
  3587             if (! __isFloat(t)) goto fail;
  3602 	    if (! __isFloat(t)) goto fail;
  3588             x = __floatVal( t );
  3603 	    x = __floatVal( t );
  3589         }
  3604 	}
  3590 
  3605 
  3591         if( __isSmallInteger(stepX) ) 
  3606 	if( __isSmallInteger(stepX) ) 
  3592             step = (float) __intVal( stepX );
  3607 	    step = (float) __intVal( stepX );
  3593         else if (__isFloat(stepX)) 
  3608 	else if (__isFloat(stepX)) 
  3594             step = __floatVal( stepX );
  3609 	    step = __floatVal( stepX );
  3595         else if (__isShortFloat(stepX)) 
  3610 	else if (__isShortFloat(stepX)) 
  3596             step = __shortFloatVal( stepX );
  3611 	    step = __shortFloatVal( stepX );
  3597         else {
  3612 	else {
  3598             t = __SSEND0(stepX, @symbol(asFloat), 0);
  3613 	    t = __SSEND0(stepX, @symbol(asFloat), 0);
  3599             if (! __isFloat(t)) goto fail;
  3614 	    if (! __isFloat(t)) goto fail;
  3600             step = __floatVal( t );
  3615 	    step = __floatVal( t );
  3601         }
  3616 	}
  3602 
  3617 
  3603         num = __intVal( noY );
  3618 	num = __intVal( noY );
  3604 
  3619 
  3605         if( num > 200 ) {
  3620 	if( num > 200 ) {
  3606             if( ! (points = (XPoint *) malloc ( sizeof(XPoint) * num )) )
  3621 	    if( ! (points = (XPoint *) malloc ( sizeof(XPoint) * num )) )
  3607                 goto fail;
  3622 		goto fail;
  3608             mustFree = 1;
  3623 	    mustFree = 1;
  3609         } else {
  3624 	} else {
  3610             points = qPoints;
  3625 	    points = qPoints;
  3611         }
  3626 	}
  3612         for( i = 0; i < num; ++i ) {
  3627 	for( i = 0; i < num; ++i ) {
  3613             yA  = __AT_(yValues, __MKSMALLINT(i+1) );
  3628 	    yA  = __AT_(yValues, __MKSMALLINT(i+1) );
  3614 
  3629 
  3615             if( __isFloat(yA) )
  3630 	    if( __isFloat(yA) )
  3616                 y = __floatVal( yA );
  3631 		y = __floatVal( yA );
  3617             else if( __isSmallInteger(yA) )
  3632 	    else if( __isSmallInteger(yA) )
  3618                 y = (float) __intVal( yA );
  3633 		y = (float) __intVal( yA );
  3619             else if( __isShortFloat( yA) )
  3634 	    else if( __isShortFloat( yA) )
  3620                 y = __shortFloatVal( yA );
  3635 		y = __shortFloatVal( yA );
  3621             else {
  3636 	    else {
  3622                 t = __SSEND0(yA, @symbol(asFloat), 0);
  3637 		t = __SSEND0(yA, @symbol(asFloat), 0);
  3623                 if (! __isFloat(t)) goto fail;
  3638 		if (! __isFloat(t)) goto fail;
  3624                 y = __floatVal( t );
  3639 		y = __floatVal( t );
  3625             }
  3640 	    }
  3626 
  3641 
  3627             points[i].x = (int) (x + 0.5);
  3642 	    points[i].x = (int) (x + 0.5);
  3628             points[i].y = (int) ((y * sY) + tY + 0.5);
  3643 	    points[i].y = (int) ((y * sY) + tY + 0.5);
  3629             x = x + step;
  3644 	    x = x + step;
  3630         }
  3645 	}
  3631 
  3646 
  3632         ENTER_XLIB();
  3647 	ENTER_XLIB();
  3633         XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
  3648 	XDrawLines(myDpy, win, gc, points, num, CoordModeOrigin);
  3634         LEAVE_XLIB();
  3649 	LEAVE_XLIB();
  3635 
  3650 
  3636         if( mustFree ) {
  3651 	if( mustFree ) {
  3637             free( points );
  3652 	    free( points );
  3638         }
  3653 	}
  3639         RETURN ( self );
  3654 	RETURN ( self );
  3640     }
  3655     }
  3641 
  3656 
  3642 fail:
  3657 fail:
  3643     if( mustFree )
  3658     if( mustFree )
  3644         free( points );
  3659 	free( points );
  3645 %}.
  3660 %}.
  3646     ^ super displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId
  3661     ^ super displayLinesFromX:startX step:stepX yValues:yValues scaleY:scaleY transY:transY in:aDrawableId with:aGCId
  3647 
  3662 
  3648     "Modified: / 13.6.1998 / 13:51:39 / cg"
  3663     "Modified: / 13.6.1998 / 13:51:39 / cg"
  3649 !
  3664 !
  3650 
  3665 
  3651 displayPointX:x y:y in:aDrawableId with:aGCId
  3666 displayPointX:x y:y in:aDrawableId with:aGCId
  3652     "draw a point. If x/y are not integers, an error is triggered." 
  3667     "draw a point. If x/y are not integers, an error is triggered." 
  3653 
  3668 
  3654 %{  /* NOCONTEXT */
  3669     <context: #return>
       
  3670 %{  
  3655 
  3671 
  3656     GC gc;
  3672     GC gc;
  3657     Window win;
  3673     Window win;
  3658 
  3674 
  3659     if (ISCONNECTED
  3675     if (ISCONNECTED
  3669 
  3685 
  3670 	RETURN ( self );
  3686 	RETURN ( self );
  3671     }
  3687     }
  3672 %}.
  3688 %}.
  3673     "badGC, badDrawable or x/y not integer"
  3689     "badGC, badDrawable or x/y not integer"
  3674     self primitiveFailed
  3690     self primitiveFailedOrClosedConnection
  3675 !
  3691 !
  3676 
  3692 
  3677 displayPolygon:aPolygon in:aDrawableId with:aGCId
  3693 displayPolygon:aPolygon in:aDrawableId with:aGCId
  3678     "draw a polygon, the argument aPolygon is a Collection of individual points, which
  3694     "draw a polygon, the argument aPolygon is a Collection of individual points, which
  3679      define the polygon.
  3695      define the polygon.
  3680      If any coordinate is not integer, an error is triggered."
  3696      If any coordinate is not integer, an error is triggered."
       
  3697 
       
  3698     <context: #return>
  3681 
  3699 
  3682     |numberOfPoints newPoints|
  3700     |numberOfPoints newPoints|
  3683 
  3701 
  3684     numberOfPoints := aPolygon size.
  3702     numberOfPoints := aPolygon size.
  3685 %{
  3703 %{
  3730 fail: ;
  3748 fail: ;
  3731     if (mustFree)
  3749     if (mustFree)
  3732 	free(points);
  3750 	free(points);
  3733 %}.
  3751 %}.
  3734     "badGC, badDrawable or coordinates not integer"
  3752     "badGC, badDrawable or coordinates not integer"
  3735     self primitiveFailed
  3753     self primitiveFailedOrClosedConnection
  3736 !
  3754 !
  3737 
  3755 
  3738 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  3756 displayRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  3739     "draw a rectangle. If the coordinates are not integers, an error is triggered." 
  3757     "draw a rectangle. If the coordinates are not integers, an error is triggered." 
  3740 
  3758 
  3741 %{  /* NOCONTEXT */
  3759     <context: #return>
       
  3760 %{  
  3742 
  3761 
  3743     GC gc;
  3762     GC gc;
  3744     Window win;
  3763     Window win;
  3745     int w, h;
  3764     int w, h;
  3746 
  3765 
  3763 	}
  3782 	}
  3764 	RETURN ( self );
  3783 	RETURN ( self );
  3765     }
  3784     }
  3766 %}.
  3785 %}.
  3767     "badGC, badDrawable or coordinates not integer"
  3786     "badGC, badDrawable or coordinates not integer"
  3768     self primitiveFailed
  3787     self primitiveFailedOrClosedConnection
  3769 !
  3788 !
  3770 
  3789 
  3771 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  3790 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  3772     "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
  3791     "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
  3773      foreground and background characters.
  3792      foreground and background characters.
  3774      If the coordinates are not integers, an error is triggered."
  3793      If the coordinates are not integers, an error is triggered."
  3775 
  3794 
  3776 %{  /* NOCONTEXT */
  3795     <context: #return>
       
  3796 %{  
  3777 
  3797 
  3778     GC gc;
  3798     GC gc;
  3779     Window win;
  3799     Window win;
  3780     char *cp;
  3800     char *cp;
  3781     OBJ cls;
  3801     OBJ cls;
  3788      && __isExternalAddress(aGCId)
  3808      && __isExternalAddress(aGCId)
  3789      && __isExternalAddress(aDrawableId)
  3809      && __isExternalAddress(aDrawableId)
  3790      && __isNonNilObject(aString)
  3810      && __isNonNilObject(aString)
  3791      && __bothSmallInteger(index1, index2)
  3811      && __bothSmallInteger(index1, index2)
  3792      && __bothSmallInteger(x, y)) {
  3812      && __bothSmallInteger(x, y)) {
       
  3813 	int lMax = __intVal(@global(XWorkstation:MaxStringLength));
  3793 	Display *dpy = myDpy;
  3814 	Display *dpy = myDpy;
  3794 	gc = _GCVal(aGCId);
  3815 	gc = _GCVal(aGCId);
  3795 	win = _WindowVal(aDrawableId);
  3816 	win = _WindowVal(aDrawableId);
  3796 	cls = __qClass(aString);
  3817 	cls = __qClass(aString);
  3797 
  3818 
  3807 
  3828 
  3808 	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
  3829 	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
  3809 		n = __stringSize(aString);
  3830 		n = __stringSize(aString);
  3810 		if (i2 < n) {
  3831 		if (i2 < n) {
  3811 		    cp += i1;
  3832 		    cp += i1;
  3812 		    if (l > 1000) l = 1000;
  3833 		    if (l > lMax) l = lMax;
  3813 		    ENTER_XLIB();
  3834 		    ENTER_XLIB();
  3814 		    if (opaque == true)
  3835 		    if (opaque == true)
  3815 			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3836 			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3816 		    else
  3837 		    else
  3817 			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3838 			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3826 	    if (__isBytes(aString)) {
  3847 	    if (__isBytes(aString)) {
  3827 		n = __byteArraySize(aString) - nInstBytes - 1;
  3848 		n = __byteArraySize(aString) - nInstBytes - 1;
  3828 
  3849 
  3829 		if (i2 < n) {
  3850 		if (i2 < n) {
  3830 		    cp += i1;
  3851 		    cp += i1;
  3831 		    if (l > 1000) l = 1000;
  3852 		    if (l > lMax) l = lMax;
  3832 		    ENTER_XLIB();
  3853 		    ENTER_XLIB();
  3833 		    if (opaque == true)
  3854 		    if (opaque == true)
  3834 			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3855 			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3835 		    else
  3856 		    else
  3836 			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3857 			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
  3851 		    int i;
  3872 		    int i;
  3852 		    XChar2b *cp2 = (XChar2b *)0;
  3873 		    XChar2b *cp2 = (XChar2b *)0;
  3853 		    int mustFree = 0;
  3874 		    int mustFree = 0;
  3854 
  3875 
  3855 		    cp += (i1 * 2);
  3876 		    cp += (i1 * 2);
  3856 		    if (l > 1000) l = 1000;
  3877 		    if (l > lMax) l = lMax;
  3857 
  3878 
  3858 		    /*
  3879 		    /*
  3859 		     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  3880 		     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  3860 		     * X expects them MSB first
  3881 		     * X expects them MSB first
  3861 		     * convert as required
  3882 		     * convert as required
  3893 	}
  3914 	}
  3894     }
  3915     }
  3895 #undef NLOCALBUFFER
  3916 #undef NLOCALBUFFER
  3896 %}.
  3917 %}.
  3897     "x/y not integer, badGC or drawable, or not a string"
  3918     "x/y not integer, badGC or drawable, or not a string"
  3898     self primitiveFailed
  3919     self primitiveFailedOrClosedConnection
  3899 !
  3920 !
  3900 
  3921 
  3901 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  3922 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  3902     "draw a string - if opaque is false, draw foreground only; otherwise, draw both
  3923     "draw a string - if opaque is false, draw foreground only; otherwise, draw both
  3903      foreground and background characters.
  3924      foreground and background characters.
  3904      If the coordinates are not integers, an error is triggered."
  3925      If the coordinates are not integers, an error is triggered."
  3905 
  3926 
  3906 %{  /* NOCONTEXT */
  3927     <context: #return>
       
  3928 %{  
  3907 
  3929 
  3908     GC gc;
  3930     GC gc;
  3909     Window win;
  3931     Window win;
  3910     char *cp;
  3932     char *cp;
  3911     int n;
  3933     int n;
  3917     if (ISCONNECTED
  3939     if (ISCONNECTED
  3918      && __isExternalAddress(aGCId)
  3940      && __isExternalAddress(aGCId)
  3919      && __isExternalAddress(aDrawableId)
  3941      && __isExternalAddress(aDrawableId)
  3920      && __isNonNilObject(aString)
  3942      && __isNonNilObject(aString)
  3921      && __bothSmallInteger(x, y)) {
  3943      && __bothSmallInteger(x, y)) {
  3922         Display *dpy = myDpy;
  3944 	int lMax = __intVal(@global(XWorkstation:MaxStringLength));
  3923         gc = _GCVal(aGCId);
  3945 	Display *dpy = myDpy;
  3924         win = _WindowVal(aDrawableId);
  3946 	gc = _GCVal(aGCId);
  3925         cls = __qClass(aString);
  3947 	win = _WindowVal(aDrawableId);
  3926 
  3948 	cls = __qClass(aString);
  3927         cp = (char *) __stringVal(aString);
  3949 
  3928 
  3950 	cp = (char *) __stringVal(aString);
  3929         if ((cls == @global(String)) || (cls == @global(Symbol))) {
  3951 
  3930             n = __stringSize(aString);
  3952 	if ((cls == @global(String)) || (cls == @global(Symbol))) {
  3931             if (n > 1000) n = 1000;
  3953 	    n = __stringSize(aString);
  3932             ENTER_XLIB();
  3954 	    if (n > lMax) n = lMax;
  3933             if (opaque == true)
  3955 	    ENTER_XLIB();
  3934                 XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3956 	    if (opaque == true)
  3935             else
  3957 		XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3936                 XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3958 	    else
  3937             LEAVE_XLIB();
  3959 		XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3938             RETURN ( self );
  3960 	    LEAVE_XLIB();
  3939         }
  3961 	    RETURN ( self );
  3940 
  3962 	}
  3941         nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  3963 
  3942         cp += nInstBytes;
  3964 	nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  3943 
  3965 	cp += nInstBytes;
  3944         if (__isBytes(aString)) {
  3966 
  3945             n = __byteArraySize(aString) - nInstBytes - 1;
  3967 	if (__isBytes(aString)) {
  3946 
  3968 	    n = __byteArraySize(aString) - nInstBytes - 1;
  3947             if (n > 1000) n = 1000;
  3969 
  3948             ENTER_XLIB();
  3970 	    if (n > lMax) n = lMax;
  3949             if (opaque == true)
  3971 	    ENTER_XLIB();
  3950                 XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3972 	    if (opaque == true)
  3951             else
  3973 		XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3952                 XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3974 	    else
  3953             LEAVE_XLIB();
  3975 		XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, n);
  3954             RETURN ( self );
  3976 	    LEAVE_XLIB();
  3955         }
  3977 	    RETURN ( self );
  3956 
  3978 	}
  3957         /* TWOBYTESTRINGS */
  3979 
  3958         if (__isWords(aString)) {
  3980 	/* TWOBYTESTRINGS */
  3959             union {
  3981 	if (__isWords(aString)) {
  3960                 char b[2];
  3982 	    union {
  3961                 unsigned short s;
  3983 		char b[2];
  3962             } u;
  3984 		unsigned short s;
  3963             int i;
  3985 	    } u;
  3964             XChar2b *cp2;
  3986 	    int i;
  3965             int mustFree = 0;
  3987 	    XChar2b *cp2;
  3966 
  3988 	    int mustFree = 0;
  3967             n = (__byteArraySize(aString) - nInstBytes) / 2;
  3989 
  3968             if (n > 1000) n = 1000;
  3990 	    n = (__byteArraySize(aString) - nInstBytes) / 2;
  3969 
  3991 	    if (n > lMax) n = lMax;
  3970             /*
  3992 
  3971              * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  3993 	    /*
  3972              * X expects them MSB first
  3994 	     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  3973              * convert as required
  3995 	     * X expects them MSB first
  3974              */
  3996 	     * convert as required
  3975 
  3997 	     */
  3976             u.s = 0x1234;
  3998 
  3977             if (u.b[0] != 0x12) {
  3999 	    u.s = 0x1234;
  3978                 if (n <= NLOCALBUFFER) {
  4000 	    if (u.b[0] != 0x12) {
  3979                     cp2 = xlatebuffer;
  4001 		if (n <= NLOCALBUFFER) {
  3980                 } else {
  4002 		    cp2 = xlatebuffer;
  3981                     cp2 = (XChar2b *)(malloc(n * 2));
  4003 		} else {
  3982                     mustFree = 1;
  4004 		    cp2 = (XChar2b *)(malloc(n * 2));
  3983                 }
  4005 		    mustFree = 1;
  3984 
  4006 		}
  3985                 for (i=0; i<n; i++) {
  4007 
  3986                     cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
  4008 		for (i=0; i<n; i++) {
  3987                     cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
  4009 		    cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
  3988                 }
  4010 		    cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
  3989                 cp = (char *) cp2;
  4011 		}
  3990             }
  4012 		cp = (char *) cp2;
  3991 
  4013 	    }
  3992             ENTER_XLIB();
  4014 
  3993             if (opaque == true)
  4015 	    ENTER_XLIB();
  3994                 XDrawImageString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
  4016 	    if (opaque == true)
  3995             else
  4017 		XDrawImageString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
  3996                 XDrawString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
  4018 	    else
  3997             LEAVE_XLIB();
  4019 		XDrawString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, n);
  3998 
  4020 	    LEAVE_XLIB();
  3999 
  4021 
  4000             if (mustFree) {
  4022 
  4001                 free(cp2);
  4023 	    if (mustFree) {
  4002             }
  4024 		free(cp2);
  4003 
  4025 	    }
  4004             RETURN ( self );
  4026 
  4005         }
  4027 	    RETURN ( self );
       
  4028 	}
  4006     }
  4029     }
  4007 #undef NLOCALBUFFER
  4030 #undef NLOCALBUFFER
  4008 %}.
  4031 %}.
  4009     ^ super displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  4032     ^ super displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque 
  4010 !
  4033 !
  4073     ifFalse:[
  4096     ifFalse:[
  4074 	"
  4097 	"
  4075 	 also happens, if a segmentation violation occurs in the 
  4098 	 also happens, if a segmentation violation occurs in the 
  4076 	 XPutImage ...
  4099 	 XPutImage ...
  4077 	"
  4100 	"
  4078 	self primitiveFailed
  4101 	self primitiveFailedOrClosedConnection
  4079     ].
  4102     ].
  4080 !
  4103 !
  4081 
  4104 
  4082 fillArcX:x y:y width:width height:height from:startAngle angle:angle
  4105 fillArcX:x y:y width:width height:height from:startAngle angle:angle
  4083 	       in:aDrawableId with:aGCId
  4106 	       in:aDrawableId with:aGCId
  4084     "fill an arc. If any coordinate is not integer, an error is triggered.
  4107     "fill an arc. If any coordinate is not integer, an error is triggered.
  4085      The angles may be floats or integer - they are given in degrees."
  4108      The angles may be floats or integer - they are given in degrees."
  4086 
  4109 
  4087 %{  /* NOCONTEXT */
  4110     <context: #return>
       
  4111 %{  
  4088 
  4112 
  4089     GC gc;
  4113     GC gc;
  4090     Window win;
  4114     Window win;
  4091     int w, h, angle1, angle2;
  4115     int w, h, angle1, angle2;
  4092     double f;
  4116     double f;
  4134     bad: ;
  4158     bad: ;
  4135 %}.
  4159 %}.
  4136     "badGC, badDrawable or coordinates not integer
  4160     "badGC, badDrawable or coordinates not integer
  4137      or non float angle(s)"
  4161      or non float angle(s)"
  4138 
  4162 
  4139     self primitiveFailed
  4163     self primitiveFailedOrClosedConnection
  4140 !
  4164 !
  4141 
  4165 
  4142 fillPolygon:aPolygon in:aDrawableId with:aGCId
  4166 fillPolygon:aPolygon in:aDrawableId with:aGCId
  4143     "fill a polygon given by its points. 
  4167     "fill a polygon given by its points. 
  4144      If any coordinate is not integer, an error is triggered."
  4168      If any coordinate is not integer, an error is triggered."
       
  4169 
       
  4170     <context: #return>
  4145 
  4171 
  4146     |numberOfPoints|
  4172     |numberOfPoints|
  4147 
  4173 
  4148     numberOfPoints := aPolygon size.
  4174     numberOfPoints := aPolygon size.
  4149 %{
  4175 %{
  4195 	if (mustFree)
  4221 	if (mustFree)
  4196 	    free(points);
  4222 	    free(points);
  4197     }
  4223     }
  4198 %}.
  4224 %}.
  4199     "badGC, badDrawable or coordinates not integer"
  4225     "badGC, badDrawable or coordinates not integer"
  4200     self primitiveFailed
  4226     self primitiveFailedOrClosedConnection
  4201 !
  4227 !
  4202 
  4228 
  4203 fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  4229 fillRectangleX:x y:y width:width height:height in:aDrawableId with:aGCId
  4204     "fill a rectangle. If any coordinate is not integer, an error is triggered."
  4230     "fill a rectangle. If any coordinate is not integer, an error is triggered."
  4205 
  4231 
  4206 %{  /* NOCONTEXT */
  4232     <context: #return>
       
  4233 %{ 
  4207 
  4234 
  4208     int w, h;
  4235     int w, h;
  4209 
  4236 
  4210     if (ISCONNECTED
  4237     if (ISCONNECTED
  4211      && __isExternalAddress(aGCId)
  4238      && __isExternalAddress(aGCId)
  4226 	}
  4253 	}
  4227 	RETURN ( self );
  4254 	RETURN ( self );
  4228     }
  4255     }
  4229 %}.
  4256 %}.
  4230     "badGC, badDrawable or coordinates not integer"
  4257     "badGC, badDrawable or coordinates not integer"
  4231     self primitiveFailed
  4258     self primitiveFailedOrClosedConnection
  4232 !
  4259 !
  4233 
  4260 
  4234 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:bitPadding
  4261 primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:bitPadding
  4235 			      width:imageWidth height:imageHeight 
  4262 			      width:imageWidth height:imageHeight 
  4236 				  x:srcx y:srcy
  4263 				  x:srcx y:srcy
  4237 			       into:aDrawableId 
  4264 			       into:aDrawableId 
  4238 				  x:dstx y:dsty 
  4265 				  x:dstx y:dsty 
  4239 			      width:w height:h 
  4266 			      width:w height:h 
  4240 			       with:aGCId
  4267 			       with:aGCId
       
  4268 
       
  4269     <context: #return>
  4241 
  4270 
  4242     "since XPutImage may allocate huge amount of stack space 
  4271     "since XPutImage may allocate huge amount of stack space 
  4243      (some implementations use alloca), this must run with unlimited stack."
  4272      (some implementations use alloca), this must run with unlimited stack."
  4244 
  4273 
  4245 %{  /* UNLIMITEDSTACK */
  4274 %{  /* UNLIMITEDSTACK */
  4366     logicalButton := buttonTranslation at:button ifAbsent:button.
  4395     logicalButton := buttonTranslation at:button ifAbsent:button.
  4367 
  4396 
  4368     buttonsPressed := buttonsPressed bitOr:(1 bitShift:logicalButton-1).
  4397     buttonsPressed := buttonsPressed bitOr:(1 bitShift:logicalButton-1).
  4369 
  4398 
  4370     multiClickTimeDelta notNil ifTrue:[
  4399     multiClickTimeDelta notNil ifTrue:[
  4371         nextMultiClickTime := time + multiClickTimeDelta.
  4400 	nextMultiClickTime := time + multiClickTimeDelta.
  4372         multiClickTime notNil ifTrue:[
  4401 	multiClickTime notNil ifTrue:[
  4373             time < multiClickTime ifTrue:[
  4402 	    time < multiClickTime ifTrue:[
  4374                 multiClickTime := nextMultiClickTime.
  4403 		multiClickTime := nextMultiClickTime.
  4375                 self buttonMultiPress:logicalButton x:x y:y view:view.
  4404 		self buttonMultiPress:logicalButton x:x y:y view:view.
  4376                 ^ self.
  4405 		^ self.
  4377             ]
  4406 	    ]
  4378         ].
  4407 	].
  4379         multiClickTime := nextMultiClickTime.
  4408 	multiClickTime := nextMultiClickTime.
  4380     ].
  4409     ].
  4381 
  4410 
  4382     self buttonPress:logicalButton x:x y:y view:view
  4411     self buttonPress:logicalButton x:x y:y view:view
  4383 !
  4412 !
  4384 
  4413 
  4385 buttonPress:button x:x y:y view:aView
  4414 buttonPress:button x:x y:y view:aView
  4386     "forward a button-press event for some view"
  4415     "forward a button-press event for some view"
  4387 
  4416 
  4388     aView isNil ifTrue:[
  4417     aView isNil ifTrue:[
  4389         "/ event arrived, after I destroyed it myself
  4418 	"/ event arrived, after I destroyed it myself
  4390         ^ self
  4419 	^ self
  4391     ].
  4420     ].
  4392     button == 1 ifTrue:[
  4421     button == 1 ifTrue:[
  4393         activateOnClick == true ifTrue:[
  4422 	activateOnClick == true ifTrue:[
  4394             "/ dont raise above an active popup view.
  4423 	    "/ dont raise above an active popup view.
  4395             (activeKeyboardGrab isNil and:[activePointerGrab isNil]) ifTrue:[
  4424 	    (activeKeyboardGrab isNil and:[activePointerGrab isNil]) ifTrue:[
  4396                 aView topView raise.
  4425 		aView topView raise.
  4397 "/            ] ifFalse:[
  4426 "/            ] ifFalse:[
  4398 "/                activeKeyboardGrab printCR.
  4427 "/                activeKeyboardGrab printCR.
  4399 "/                activePointerGrab printCR.
  4428 "/                activePointerGrab printCR.
  4400             ]
  4429 	    ]
  4401         ].
  4430 	].
  4402     ].
  4431     ].
  4403     super buttonPress:button x:x y:y view:aView
  4432     super buttonPress:button x:x y:y view:aView
  4404 
  4433 
  4405 
  4434 
  4406 
  4435 
  4473 colorMapChangeView:aView
  4502 colorMapChangeView:aView
  4474     "sent, when another colormap is installed.
  4503     "sent, when another colormap is installed.
  4475      This is a very X-specific mechanism."
  4504      This is a very X-specific mechanism."
  4476 
  4505 
  4477     aView isNil ifTrue:[
  4506     aView isNil ifTrue:[
  4478         "/ event arrived, after I destroyed it myself
  4507 	"/ event arrived, after I destroyed it myself
  4479         ^ self
  4508 	^ self
  4480     ].
  4509     ].
  4481     aView colorMapChange
  4510     aView colorMapChange
  4482 !
  4511 !
  4483 
  4512 
  4484 configure:view x:x y:y width:w height:h above:above
  4513 configure:view x:x y:y width:w height:h above:above
  4654     metaDown := state bitTest:metaModifierMask.
  4683     metaDown := state bitTest:metaModifierMask.
  4655     shiftDown := state bitTest:(self shiftModifierMask).
  4684     shiftDown := state bitTest:(self shiftModifierMask).
  4656     ctrlDown := state bitTest:(self ctrlModifierMask).
  4685     ctrlDown := state bitTest:(self ctrlModifierMask).
  4657 
  4686 
  4658     key isNil ifTrue:[
  4687     key isNil ifTrue:[
  4659         "/ happens sometimes on some systems
  4688 	"/ happens sometimes on some systems
  4660         "/ (alt-graph on sun has no keysym) 
  4689 	"/ (alt-graph on sun has no keysym) 
  4661         ^ self
  4690 	^ self
  4662     ].
  4691     ].
  4663     eventRootX := rX.
  4692     eventRootX := rX.
  4664     eventRootY := rY.
  4693     eventRootY := rY.
  4665     self keyPress:key x:x y:y view:view.
  4694     self keyPress:key x:x y:y view:view.
  4666 
  4695 
  4674     metaDown := state bitTest:metaModifierMask.
  4703     metaDown := state bitTest:metaModifierMask.
  4675     shiftDown := state bitTest:(self shiftModifierMask).
  4704     shiftDown := state bitTest:(self shiftModifierMask).
  4676     ctrlDown := state bitTest:(self ctrlModifierMask).
  4705     ctrlDown := state bitTest:(self ctrlModifierMask).
  4677 
  4706 
  4678     key isNil ifTrue:[
  4707     key isNil ifTrue:[
  4679         "/ happens sometimes on some systems
  4708 	"/ happens sometimes on some systems
  4680         "/ (alt-graph on sun has no keysym) 
  4709 	"/ (alt-graph on sun has no keysym) 
  4681         ^ self
  4710 	^ self
  4682     ].
  4711     ].
  4683     eventRootX := rX.
  4712     eventRootX := rX.
  4684     eventRootY := rY.
  4713     eventRootY := rY.
  4685     self keyRelease:key x:x y:y view:view.
  4714     self keyRelease:key x:x y:y view:view.
  4686 
  4715 
  4724 propertyChangeView:aView
  4753 propertyChangeView:aView
  4725     "sent when an X property changes.
  4754     "sent when an X property changes.
  4726      This is a very X-specific mechanism."
  4755      This is a very X-specific mechanism."
  4727 
  4756 
  4728     aView isNil ifTrue:[
  4757     aView isNil ifTrue:[
  4729         "/ event arrived, after I destroyed it myself
  4758 	"/ event arrived, after I destroyed it myself
  4730         ^ self
  4759 	^ self
  4731     ].
  4760     ].
  4732     aView propertyChange
  4761     aView propertyChange
  4733 !
  4762 !
  4734 
  4763 
  4735 reparentedView:aView
  4764 reparentedView:aView
  4797     "/ noone is interested in that ...
  4826     "/ noone is interested in that ...
  4798     "/ aView selectionClear:selectionID
  4827     "/ aView selectionClear:selectionID
  4799 !
  4828 !
  4800 
  4829 
  4801 selectionNotify:aView selection:selectionID  target:targetID property:propertyID requestor:requestorID time:time
  4830 selectionNotify:aView selection:selectionID  target:targetID property:propertyID requestor:requestorID time:time
  4802     "sent when the server returns an answer from a request for a selection.
       
  4803      This is a very X-specific mechanism."
       
  4804 
       
  4805     |s sensor|
       
  4806 
       
  4807     propertyID == 0 ifTrue:[
       
  4808         "invalid olvwm behavior"
       
  4809         s := self getLastCopyBuffer
       
  4810     ] ifFalse:[
       
  4811         targetID == self atomIDOfSTRING ifTrue:[
       
  4812             "
       
  4813              a returned string
       
  4814             "
       
  4815             s := self getTextProperty:propertyID from:requestorID.
       
  4816             s notNil ifTrue:[
       
  4817                 (s endsWith:Character cr) ifTrue:[
       
  4818                     s := s asStringCollection copyWith:''
       
  4819                 ]
       
  4820             ]
       
  4821         ] ifFalse:[
       
  4822             "
       
  4823              a returned object
       
  4824             "
       
  4825             s := self getObjectProperty:propertyID from:requestorID.
       
  4826         ].
       
  4827     ].
       
  4828 
       
  4829     s notNil ifTrue:[
       
  4830         (sensor := aView sensor) notNil ifTrue:[
       
  4831             sensor pasteFromClipBoard:s view:aView
       
  4832         ] ifFalse:[
       
  4833             "
       
  4834              if there is no sensor ...
       
  4835             "
       
  4836             aView pasteFromClipBoard:s
       
  4837         ]
       
  4838     ]
       
  4839 !
       
  4840 
       
  4841 selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView
       
  4842     "sent when the server returns an answer from a request for a selection.
  4831     "sent when the server returns an answer from a request for a selection.
  4843      This is a very X-specific mechanism."
  4832      This is a very X-specific mechanism."
  4844 
  4833 
  4845     |s sensor|
  4834     |s sensor|
  4846 
  4835 
  4876 	    aView pasteFromClipBoard:s
  4865 	    aView pasteFromClipBoard:s
  4877 	]
  4866 	]
  4878     ]
  4867     ]
  4879 !
  4868 !
  4880 
  4869 
       
  4870 selectionNotify:propertyID target:targetID selection:selectionID from:requestorID view:aView
       
  4871     "sent when the server returns an answer from a request for a selection.
       
  4872      This is a very X-specific mechanism."
       
  4873 
       
  4874     |s sensor|
       
  4875 
       
  4876     propertyID == 0 ifTrue:[
       
  4877 	"invalid olvwm behavior"
       
  4878 	s := self getLastCopyBuffer
       
  4879     ] ifFalse:[
       
  4880 	targetID == self atomIDOfSTRING ifTrue:[
       
  4881 	    "
       
  4882 	     a returned string
       
  4883 	    "
       
  4884 	    s := self getTextProperty:propertyID from:requestorID.
       
  4885 	    s notNil ifTrue:[
       
  4886 		(s endsWith:Character cr) ifTrue:[
       
  4887 		    s := s asStringCollection copyWith:''
       
  4888 		]
       
  4889 	    ]
       
  4890 	] ifFalse:[
       
  4891 	    "
       
  4892 	     a returned object
       
  4893 	    "
       
  4894 	    s := self getObjectProperty:propertyID from:requestorID.
       
  4895 	].
       
  4896     ].
       
  4897 
       
  4898     s notNil ifTrue:[
       
  4899 	(sensor := aView sensor) notNil ifTrue:[
       
  4900 	    sensor pasteFromClipBoard:s view:aView
       
  4901 	] ifFalse:[
       
  4902 	    "
       
  4903 	     if there is no sensor ...
       
  4904 	    "
       
  4905 	    aView pasteFromClipBoard:s
       
  4906 	]
       
  4907     ]
       
  4908 !
       
  4909 
  4881 selectionRequest:aView requestor:requestorID selection:selectionID target:targetID property:propertyID time:time
  4910 selectionRequest:aView requestor:requestorID selection:selectionID target:targetID property:propertyID time:time
  4882     "sent by some other X-client to ask for the selection.
  4911     "sent by some other X-client to ask for the selection.
  4883      This is a very X-specific mechanism."
  4912      This is a very X-specific mechanism."
  4884 
  4913 
  4885     |o s stream|
  4914     |o s stream|
  4886 
  4915 
  4887 "/targetID printCR.
  4916 "/targetID printCR.
  4888 
  4917 
  4889     targetID == (self atomIDOfLENGTH) ifTrue:[
  4918     targetID == (self atomIDOfLENGTH) ifTrue:[
  4890         "/
  4919 	"/
  4891         "/ the other one wants to know the size of our selection ...
  4920 	"/ the other one wants to know the size of our selection ...
  4892         "/
  4921 	"/
  4893         s := self selectionAsString.
  4922 	s := self selectionAsString.
  4894         self
  4923 	self
  4895             setLengthProperty:propertyID 
  4924 	    setLengthProperty:propertyID 
  4896             value:s size 
  4925 	    value:s size 
  4897             for:requestorID.
  4926 	    for:requestorID.
  4898 
  4927 
  4899         self
  4928 	self
  4900             sendSelectionNotifySelection:selectionID
  4929 	    sendSelectionNotifySelection:selectionID
  4901             property:propertyID
  4930 	    property:propertyID
  4902             target:targetID
  4931 	    target:targetID
  4903             time:time
  4932 	    time:time
  4904             from:aView id
  4933 	    from:aView id
  4905             to:requestorID.
  4934 	    to:requestorID.
  4906         ^ self
  4935 	^ self
  4907     ].
  4936     ].
  4908 
  4937 
  4909     (targetID == self atomIDOfSTRING or:[
  4938     (targetID == self atomIDOfSTRING or:[
  4910      targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[
  4939      targetID == (self atomIDOf:'COMPOUND_TEXT')]) ifTrue:[
  4911         "/
  4940 	"/
  4912         "/ the other view wants the selection as string
  4941 	"/ the other view wants the selection as string
  4913         "/
  4942 	"/
  4914         s := self selectionAsString.
  4943 	s := self selectionAsString.
  4915 
  4944 
  4916         self
  4945 	self
  4917             sendSelection:s 
  4946 	    sendSelection:s 
  4918             selection:primaryAtom
  4947 	    selection:primaryAtom
  4919             property:propertyID 
  4948 	    property:propertyID 
  4920             target:self atomIDOfSTRING "/ targetID, once I can provide compountText as well
  4949 	    target:self atomIDOfSTRING "/ targetID, once I can provide compountText as well
  4921             time:time
  4950 	    time:time
  4922             from:requestorID
  4951 	    from:requestorID
  4923             to:requestorID.
  4952 	    to:requestorID.
  4924         ^ self
  4953 	^ self
  4925     ].
  4954     ].
  4926 
  4955 
  4927 "/    (targetID == (self atomIDOf:'TARGETS')) ifTrue:[
  4956 "/    (targetID == (self atomIDOf:'TARGETS')) ifTrue:[
  4928 "/"/ TODO: implement this to avoid netscape paste-delay.
  4957 "/"/ TODO: implement this to avoid netscape paste-delay.
  4929 "/"/
  4958 "/"/
  4930 "/        ^ self
  4959 "/        ^ self
  4931 "/    ].
  4960 "/    ].
  4932 
  4961 
  4933     (targetID == (self atomIDOf:'ST_OBJECT')) ifTrue:[
  4962     (targetID == (self atomIDOf:'ST_OBJECT')) ifTrue:[
  4934         "/
  4963 	"/
  4935         "/ send the selection in binaryStore format
  4964 	"/ send the selection in binaryStore format
  4936         "/ (assuming, that the other view knows how to handle it)
  4965 	"/ (assuming, that the other view knows how to handle it)
  4937         "/
  4966 	"/
  4938         o := self getCopyBuffer.
  4967 	o := self getCopyBuffer.
  4939         stream := WriteStream on:(ByteArray new:200).
  4968 	stream := WriteStream on:(ByteArray new:200).
  4940         o storeBinaryOn:stream.
  4969 	o storeBinaryOn:stream.
  4941 
  4970 
  4942         ^ self
  4971 	^ self
  4943             sendSelection:(stream contents) 
  4972 	    sendSelection:(stream contents) 
  4944             selection:primaryAtom
  4973 	    selection:primaryAtom
  4945             property:propertyID 
  4974 	    property:propertyID 
  4946             target:targetID 
  4975 	    target:targetID 
  4947             time:time
  4976 	    time:time
  4948             from:aView id 
  4977 	    from:aView id 
  4949             to:requestorID
  4978 	    to:requestorID
  4950     ].
  4979     ].
  4951 
  4980 
  4952 !
  4981 !
  4953 
  4982 
  4954 selectionRequest:propertyID target:targetID selection:selectionID time:t from:windowID view:aView
  4983 selectionRequest:propertyID target:targetID selection:selectionID time:t from:windowID view:aView
  5022     "Modified: / 17.6.1998 / 20:24:40 / cg"
  5051     "Modified: / 17.6.1998 / 20:24:40 / cg"
  5023 !
  5052 !
  5024 
  5053 
  5025 visibilityNotify:aView state:how
  5054 visibilityNotify:aView state:how
  5026     aView notNil ifTrue:[
  5055     aView notNil ifTrue:[
  5027         aView visibilityChange:how
  5056 	aView visibilityChange:how
  5028     ]
  5057     ]
  5029 
  5058 
  5030 ! !
  5059 ! !
  5031 
  5060 
  5032 !XWorkstation methodsFor:'event handling'!
  5061 !XWorkstation methodsFor:'event handling'!
  5033 
  5062 
  5034 decomposeEventBuffer:aByteArray into:eventArr
  5063 decomposeEventBuffer:aByteArray into:eventArr
  5035     "extracet event fields and place them into an array:
  5064     "extracet event fields and place them into an array:
  5036      the fields are:
  5065      the fields are:
  5037         1:      windowID
  5066 	1:      windowID
  5038         2:      eventType-ID
  5067 	2:      eventType-ID
  5039         3:      eventTypeSymbol
  5068 	3:      eventTypeSymbol
  5040 
  5069 
  5041         4..     args
  5070 	4..     args
  5042     "
  5071     "
  5043 %{ 
  5072 %{ 
  5044 #   define ANYBUTTON   (Button1MotionMask | Button2MotionMask | Button3MotionMask)
  5073 #   define ANYBUTTON   (Button1MotionMask | Button2MotionMask | Button3MotionMask)
  5045 
  5074 
  5046     OBJ eB;
  5075     OBJ eB;
  5076     OBJ arg, sym, t, windowID;
  5105     OBJ arg, sym, t, windowID;
  5077 
  5106 
  5078     eB = aByteArray;
  5107     eB = aByteArray;
  5079 
  5108 
  5080     if (__isByteArray(eB)) {
  5109     if (__isByteArray(eB)) {
  5081         ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  5110 	ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  5082     } else {
  5111     } else {
  5083         printf("DISPLAY: no eventBuffer\n");
  5112 	printf("DISPLAY: no eventBuffer\n");
  5084         RETURN (false);
  5113 	RETURN (false);
  5085     }
  5114     }
  5086     if (!__isArray(eventArr)) {
  5115     if (!__isArray(eventArr)) {
  5087         printf("DISPLAY: bad argument\n");
  5116 	printf("DISPLAY: bad argument\n");
  5088         RETURN (false);
  5117 	RETURN (false);
  5089     }
  5118     }
  5090     if (__arraySize(eventArr) < 11) {
  5119     if (__arraySize(eventArr) < 11) {
  5091         printf("DISPLAY: bad argument\n");
  5120 	printf("DISPLAY: bad argument\n");
  5092         RETURN (false);
  5121 	RETURN (false);
  5093     }
  5122     }
  5094 
  5123 
  5095     if (((t = __INST(lastId)) != nil)
  5124     if (((t = __INST(lastId)) != nil)
  5096      && __isExternalAddress(t)
  5125      && __isExternalAddress(t)
  5097      && (_WindowVal(t) == ae->window)) {
  5126      && (_WindowVal(t) == ae->window)) {
  5098         windowID = t;
  5127 	windowID = t;
  5099     } else {
  5128     } else {
  5100         windowID = __MKEXTERNALADDRESS(ae->window);
  5129 	windowID = __MKEXTERNALADDRESS(ae->window);
  5101     }
  5130     }
  5102 
  5131 
  5103     __ArrayInstPtr(eventArr)->a_element[0] = windowID; __STORE(eventArr, windowID);
  5132     __ArrayInstPtr(eventArr)->a_element[0] = windowID; __STORE(eventArr, windowID);
  5104     __ArrayInstPtr(eventArr)->a_element[1] = __MKSMALLINT(ev->type);
  5133     __ArrayInstPtr(eventArr)->a_element[1] = __MKSMALLINT(ev->type);
  5105 
  5134 
  5106     switch (ev->type) {
  5135     switch (ev->type) {
  5107         case KeyRelease:
  5136 	case KeyRelease:
  5108             sym = @symbol(keyRelease:key:code:state:x:y:rootX:rootY:time:);
  5137 	    sym = @symbol(keyRelease:key:code:state:x:y:rootX:rootY:time:);
  5109             goto keyPressAndRelease;
  5138 	    goto keyPressAndRelease;
  5110 
  5139 
  5111         case KeyPress:
  5140 	case KeyPress:
  5112             sym = @symbol(keyPress:key:code:state:x:y:rootX:rootY:time:);
  5141 	    sym = @symbol(keyPress:key:code:state:x:y:rootX:rootY:time:);
  5113             /* FALL INTO */
  5142 	    /* FALL INTO */
  5114 
  5143 
  5115         keyPressAndRelease:
  5144 	keyPressAndRelease:
  5116             arg = nil;
  5145 	    arg = nil;
  5117             nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL);
  5146 	    nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL);
  5118             if (nchars 
  5147 	    if (nchars 
  5119              && (((buffer[0] >= ' ') && (buffer[0] <= '~'))
  5148 	     && (((buffer[0] >= ' ') && (buffer[0] <= '~'))
  5120                  || (buffer[0] >= 0x80))) {
  5149 		 || (buffer[0] >= 0x80))) {
  5121                 arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */;
  5150 		arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */;
  5122                 keySymString = NULL;
  5151 		keySymString = NULL;
  5123             } else {
  5152 	    } else {
  5124                 keySymString = XKeysymToString(keySym);
  5153 		keySymString = XKeysymToString(keySym);
  5125                 if (keySymString) {
  5154 		if (keySymString) {
  5126                     arg = __MKSTRING(keySymString);
  5155 		    arg = __MKSTRING(keySymString);
  5127                 }
  5156 		}
  5128             }
  5157 	    }
  5129 
  5158 
  5130             if (arg == nil) {
  5159 	    if (arg == nil) {
  5131                 /* happens sometimes (alt-graph on sun has no keysym) */
  5160 		/* happens sometimes (alt-graph on sun has no keysym) */
  5132                 RETURN (false);
  5161 		RETURN (false);
  5133             }
  5162 	    }
  5134 
  5163 
  5135             __ArrayInstPtr(eventArr)->a_element[2] = sym;
  5164 	    __ArrayInstPtr(eventArr)->a_element[2] = sym;
  5136 
  5165 
  5137             __ArrayInstPtr(eventArr)->a_element[3] = arg; __STORE(eventArr, arg);
  5166 	    __ArrayInstPtr(eventArr)->a_element[3] = arg; __STORE(eventArr, arg);
  5138             __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ke->keycode); __STORE(eventArr, t);
  5167 	    __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ke->keycode); __STORE(eventArr, t);
  5139             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ke->state);
  5168 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ke->state);
  5140             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ke->x);
  5169 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ke->x);
  5141             __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ke->y);
  5170 	    __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ke->y);
  5142             __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(ke->x_root);
  5171 	    __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(ke->x_root);
  5143             __ArrayInstPtr(eventArr)->a_element[9] = __mkSmallInteger(ke->y_root);
  5172 	    __ArrayInstPtr(eventArr)->a_element[9] = __mkSmallInteger(ke->y_root);
  5144             __ArrayInstPtr(eventArr)->a_element[10] = t = __MKUINT(ke->time); __STORE(eventArr, t);
  5173 	    __ArrayInstPtr(eventArr)->a_element[10] = t = __MKUINT(ke->time); __STORE(eventArr, t);
  5145             RETURN (true);
  5174 	    RETURN (true);
  5146 
  5175 
  5147         case ButtonPress:
  5176 	case ButtonPress:
  5148             sym = @symbol(buttonPress:button:state:x:y:rootX:rootY:time:);
  5177 	    sym = @symbol(buttonPress:button:state:x:y:rootX:rootY:time:);
  5149             goto buttonPressAndRelease;
  5178 	    goto buttonPressAndRelease;
  5150 
  5179 
  5151         case ButtonRelease:
  5180 	case ButtonRelease:
  5152             sym = @symbol(buttonRelease:button:state:x:y:rootX:rootY:time:);
  5181 	    sym = @symbol(buttonRelease:button:state:x:y:rootX:rootY:time:);
  5153             /* fall into */
  5182 	    /* fall into */
  5154 
  5183 
  5155         buttonPressAndRelease:
  5184 	buttonPressAndRelease:
  5156             __ArrayInstPtr(eventArr)->a_element[2] = sym;
  5185 	    __ArrayInstPtr(eventArr)->a_element[2] = sym;
  5157             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(be->button);
  5186 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(be->button);
  5158             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ke->state);
  5187 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ke->state);
  5159             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(be->x);
  5188 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(be->x);
  5160             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(be->y);
  5189 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(be->y);
  5161             __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(be->x_root);
  5190 	    __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(be->x_root);
  5162             __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(be->y_root);
  5191 	    __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(be->y_root);
  5163             __ArrayInstPtr(eventArr)->a_element[9] = t = __MKUINT(be->time); __STORE(eventArr, t);
  5192 	    __ArrayInstPtr(eventArr)->a_element[9] = t = __MKUINT(be->time); __STORE(eventArr, t);
  5164             RETURN (true);
  5193 	    RETURN (true);
  5165 
  5194 
  5166         case MotionNotify:
  5195 	case MotionNotify:
  5167             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(buttonMotion:state:x:y:rootX:rootY:time:);
  5196 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(buttonMotion:state:x:y:rootX:rootY:time:);
  5168 
  5197 
  5169             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(me->state);
  5198 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(me->state);
  5170             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(me->x);
  5199 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(me->x);
  5171             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(me->y);
  5200 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(me->y);
  5172             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(me->x_root);
  5201 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(me->x_root);
  5173             __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(me->y_root);
  5202 	    __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(me->y_root);
  5174             __ArrayInstPtr(eventArr)->a_element[8] = t = __MKUINT(me->time); __STORE(eventArr, t);
  5203 	    __ArrayInstPtr(eventArr)->a_element[8] = t = __MKUINT(me->time); __STORE(eventArr, t);
  5175             RETURN (true);
  5204 	    RETURN (true);
  5176 
  5205 
  5177         case FocusIn:
  5206 	case FocusIn:
  5178             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(focusIn:mode:detail:);
  5207 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(focusIn:mode:detail:);
  5179             goto focusInOut;
  5208 	    goto focusInOut;
  5180 
  5209 
  5181         case FocusOut:
  5210 	case FocusOut:
  5182             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(focusOut:mode:detail:);
  5211 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(focusOut:mode:detail:);
  5183             /* fall into */
  5212 	    /* fall into */
  5184 
  5213 
  5185         focusInOut:
  5214 	focusInOut:
  5186             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(fe->mode);
  5215 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(fe->mode);
  5187             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(fe->detail);
  5216 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(fe->detail);
  5188             RETURN (true);
  5217 	    RETURN (true);
  5189 
  5218 
  5190 
  5219 
  5191         case EnterNotify:
  5220 	case EnterNotify:
  5192             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(pointerEnter:x:y:rootX:rootY:state:mode:detail:time:);
  5221 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(pointerEnter:x:y:rootX:rootY:state:mode:detail:time:);
  5193             goto enterLeave;
  5222 	    goto enterLeave;
  5194 
  5223 
  5195         case LeaveNotify:
  5224 	case LeaveNotify:
  5196             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(pointerLeave:x:y:rootX:rootY:state:mode:detail:time:);
  5225 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(pointerLeave:x:y:rootX:rootY:state:mode:detail:time:);
  5197             /* fall into */
  5226 	    /* fall into */
  5198 
  5227 
  5199         enterLeave:
  5228 	enterLeave:
  5200             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ele->x);
  5229 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ele->x);
  5201             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ele->y);
  5230 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ele->y);
  5202             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ele->x_root);
  5231 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ele->x_root);
  5203             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ele->y_root);
  5232 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ele->y_root);
  5204             __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ele->state);
  5233 	    __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ele->state);
  5205             __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(ele->mode);
  5234 	    __ArrayInstPtr(eventArr)->a_element[8] = __mkSmallInteger(ele->mode);
  5206             __ArrayInstPtr(eventArr)->a_element[9] = __mkSmallInteger(ele->detail);
  5235 	    __ArrayInstPtr(eventArr)->a_element[9] = __mkSmallInteger(ele->detail);
  5207             __ArrayInstPtr(eventArr)->a_element[10] = t = __MKUINT(ele->time); __STORE(eventArr, t);
  5236 	    __ArrayInstPtr(eventArr)->a_element[10] = t = __MKUINT(ele->time); __STORE(eventArr, t);
  5208             RETURN (true);
  5237 	    RETURN (true);
  5209 
  5238 
  5210         case Expose:
  5239 	case Expose:
  5211             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(expose:x:y:width:height:count:);
  5240 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(expose:x:y:width:height:count:);
  5212             goto expose;
  5241 	    goto expose;
  5213 
  5242 
  5214         case GraphicsExpose:
  5243 	case GraphicsExpose:
  5215             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(graphicsExpose:x:y:width:height:count:);
  5244 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(graphicsExpose:x:y:width:height:count:);
  5216             /* fall into */
  5245 	    /* fall into */
  5217 
  5246 
  5218         expose:
  5247 	expose:
  5219             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ee->x);
  5248 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ee->x);
  5220             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ee->y);
  5249 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ee->y);
  5221             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ee->width);
  5250 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ee->width);
  5222             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ee->height);
  5251 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ee->height);
  5223             __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ee->count);
  5252 	    __ArrayInstPtr(eventArr)->a_element[7] = __mkSmallInteger(ee->count);
  5224             RETURN (true);
  5253 	    RETURN (true);
  5225 
  5254 
  5226         case NoExpose:
  5255 	case NoExpose:
  5227             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(noExposeView:);
  5256 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(noExposeView:);
  5228             RETURN (true);
  5257 	    RETURN (true);
  5229 
  5258 
  5230         case VisibilityNotify:
  5259 	case VisibilityNotify:
  5231             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(visibilityNotify:state:);
  5260 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(visibilityNotify:state:);
  5232             switch (ve->state) {
  5261 	    switch (ve->state) {
  5233                 case VisibilityUnobscured:
  5262 		case VisibilityUnobscured:
  5234                     __ArrayInstPtr(eventArr)->a_element[3] = @symbol(unobscured);
  5263 		    __ArrayInstPtr(eventArr)->a_element[3] = @symbol(unobscured);
  5235                     break;
  5264 		    break;
  5236                 case VisibilityPartiallyObscured:
  5265 		case VisibilityPartiallyObscured:
  5237                     __ArrayInstPtr(eventArr)->a_element[3] = @symbol(partiallyObscured);
  5266 		    __ArrayInstPtr(eventArr)->a_element[3] = @symbol(partiallyObscured);
  5238                     break;
  5267 		    break;
  5239                 case VisibilityFullyObscured:
  5268 		case VisibilityFullyObscured:
  5240                     __ArrayInstPtr(eventArr)->a_element[3] = @symbol(fullyObscured);
  5269 		    __ArrayInstPtr(eventArr)->a_element[3] = @symbol(fullyObscured);
  5241                     break;
  5270 		    break;
  5242             }
  5271 	    }
  5243             RETURN (true);
  5272 	    RETURN (true);
  5244 
  5273 
  5245         case CreateNotify:
  5274 	case CreateNotify:
  5246             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(createWindow:x:y:width:height:);
  5275 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(createWindow:x:y:width:height:);
  5247             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(cre->x);
  5276 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(cre->x);
  5248             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(cre->y);
  5277 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(cre->y);
  5249             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(cre->width);
  5278 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(cre->width);
  5250             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(cre->height);
  5279 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(cre->height);
  5251             RETURN (true);
  5280 	    RETURN (true);
  5252 
  5281 
  5253         case DestroyNotify:
  5282 	case DestroyNotify:
  5254             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(destroyedView:);
  5283 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(destroyedView:);
  5255             RETURN (true);
  5284 	    RETURN (true);
  5256 
  5285 
  5257         case UnmapNotify:
  5286 	case UnmapNotify:
  5258             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(unmappedView:);
  5287 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(unmappedView:);
  5259             RETURN (true);
  5288 	    RETURN (true);
  5260 
  5289 
  5261         case MapNotify:
  5290 	case MapNotify:
  5262             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappedView:);
  5291 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappedView:);
  5263             RETURN (true);
  5292 	    RETURN (true);
  5264 
  5293 
  5265         case ConfigureNotify:
  5294 	case ConfigureNotify:
  5266             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(configure:x:y:width:height:above:);
  5295 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(configure:x:y:width:height:above:);
  5267             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ce->x);
  5296 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(ce->x);
  5268             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ce->y);
  5297 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(ce->y);
  5269             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ce->width);
  5298 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(ce->width);
  5270             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ce->height);
  5299 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(ce->height);
  5271             __ArrayInstPtr(eventArr)->a_element[7] = nil;
  5300 	    __ArrayInstPtr(eventArr)->a_element[7] = nil;
  5272             if (ce->above != None) {
  5301 	    if (ce->above != None) {
  5273                 __ArrayInstPtr(eventArr)->a_element[7] = t = __MKEXTERNALADDRESS(ce->above); __STORE(eventArr, t);
  5302 		__ArrayInstPtr(eventArr)->a_element[7] = t = __MKEXTERNALADDRESS(ce->above); __STORE(eventArr, t);
  5274             }
  5303 	    }
  5275             RETURN (true);
  5304 	    RETURN (true);
  5276 
  5305 
  5277         case GravityNotify:
  5306 	case GravityNotify:
  5278             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(gravityNotify:x:y:);
  5307 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(gravityNotify:x:y:);
  5279             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(gre->x);
  5308 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(gre->x);
  5280             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(gre->y);
  5309 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(gre->y);
  5281             RETURN (true);
  5310 	    RETURN (true);
  5282             break;
  5311 	    break;
  5283 
  5312 
  5284         case ResizeRequest:
  5313 	case ResizeRequest:
  5285             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(resizeRequest:width:height:);
  5314 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(resizeRequest:width:height:);
  5286             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(rr->width);
  5315 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(rr->width);
  5287             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(rr->height);
  5316 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(rr->height);
  5288             RETURN (true);
  5317 	    RETURN (true);
  5289             break;
  5318 	    break;
  5290 
  5319 
  5291         case ConfigureRequest:
  5320 	case ConfigureRequest:
  5292             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(configureRequest:x:y:width:height:above:detail:);
  5321 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(configureRequest:x:y:width:height:above:detail:);
  5293             __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(cr->x);
  5322 	    __ArrayInstPtr(eventArr)->a_element[3] = __mkSmallInteger(cr->x);
  5294             __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(cr->y);
  5323 	    __ArrayInstPtr(eventArr)->a_element[4] = __mkSmallInteger(cr->y);
  5295             __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(cr->width);
  5324 	    __ArrayInstPtr(eventArr)->a_element[5] = __mkSmallInteger(cr->width);
  5296             __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(cr->height);
  5325 	    __ArrayInstPtr(eventArr)->a_element[6] = __mkSmallInteger(cr->height);
  5297             __ArrayInstPtr(eventArr)->a_element[7] = nil;
  5326 	    __ArrayInstPtr(eventArr)->a_element[7] = nil;
  5298             if (cr->above != None) {
  5327 	    if (cr->above != None) {
  5299                 __ArrayInstPtr(eventArr)->a_element[7] = t = __MKEXTERNALADDRESS(cr->above); __STORE(eventArr, t);
  5328 		__ArrayInstPtr(eventArr)->a_element[7] = t = __MKEXTERNALADDRESS(cr->above); __STORE(eventArr, t);
  5300             }
  5329 	    }
  5301             switch (cr->detail) {
  5330 	    switch (cr->detail) {
  5302                 case Above:
  5331 		case Above:
  5303                     __ArrayInstPtr(eventArr)->a_element[8] = @symbol(above);
  5332 		    __ArrayInstPtr(eventArr)->a_element[8] = @symbol(above);
  5304                     break;
  5333 		    break;
  5305                 case Below:
  5334 		case Below:
  5306                     __ArrayInstPtr(eventArr)->a_element[8] = @symbol(below);
  5335 		    __ArrayInstPtr(eventArr)->a_element[8] = @symbol(below);
  5307                     break;
  5336 		    break;
  5308                 case TopIf:
  5337 		case TopIf:
  5309                     __ArrayInstPtr(eventArr)->a_element[8] = @symbol(topIf);
  5338 		    __ArrayInstPtr(eventArr)->a_element[8] = @symbol(topIf);
  5310                     break;
  5339 		    break;
  5311                 case BottomIf:
  5340 		case BottomIf:
  5312                     __ArrayInstPtr(eventArr)->a_element[8] = @symbol(bottomIf);
  5341 		    __ArrayInstPtr(eventArr)->a_element[8] = @symbol(bottomIf);
  5313                     break;
  5342 		    break;
  5314                 case Opposite:
  5343 		case Opposite:
  5315                     __ArrayInstPtr(eventArr)->a_element[8] = @symbol(opposite);
  5344 		    __ArrayInstPtr(eventArr)->a_element[8] = @symbol(opposite);
  5316                     break;
  5345 		    break;
  5317                 default:
  5346 		default:
  5318                     __ArrayInstPtr(eventArr)->a_element[8] = nil;
  5347 		    __ArrayInstPtr(eventArr)->a_element[8] = nil;
  5319                     break;
  5348 		    break;
  5320             }
  5349 	    }
  5321             RETURN (true);
  5350 	    RETURN (true);
  5322             break;
  5351 	    break;
  5323 
  5352 
  5324         case CirculateNotify:
  5353 	case CirculateNotify:
  5325             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(circulateNotify:place:);
  5354 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(circulateNotify:place:);
  5326             goto circulate;
  5355 	    goto circulate;
  5327 
  5356 
  5328         case CirculateRequest:
  5357 	case CirculateRequest:
  5329             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(circulateRequest:place:);
  5358 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(circulateRequest:place:);
  5330             /* fall into */
  5359 	    /* fall into */
  5331         circulate:
  5360 	circulate:
  5332             switch (cie->place) {
  5361 	    switch (cie->place) {
  5333                 case PlaceOnTop:
  5362 		case PlaceOnTop:
  5334                     __ArrayInstPtr(eventArr)->a_element[3] = @symbol(placeOnTop);
  5363 		    __ArrayInstPtr(eventArr)->a_element[3] = @symbol(placeOnTop);
  5335                     break;
  5364 		    break;
  5336                 case PlaceOnBottom:
  5365 		case PlaceOnBottom:
  5337                     __ArrayInstPtr(eventArr)->a_element[3] = @symbol(placeOnBottom);
  5366 		    __ArrayInstPtr(eventArr)->a_element[3] = @symbol(placeOnBottom);
  5338                     break;
  5367 		    break;
  5339                 default:
  5368 		default:
  5340                     __ArrayInstPtr(eventArr)->a_element[3] = nil;
  5369 		    __ArrayInstPtr(eventArr)->a_element[3] = nil;
  5341                     break;
  5370 		    break;
  5342             }
  5371 	    }
  5343             RETURN (true);
  5372 	    RETURN (true);
  5344             break;
  5373 	    break;
  5345 
  5374 
  5346         case PropertyNotify:
  5375 	case PropertyNotify:
  5347             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(propertyChange:atom:state:time:);
  5376 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(propertyChange:atom:state:time:);
  5348             __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(pe->atom); __STORE(eventArr, t);
  5377 	    __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(pe->atom); __STORE(eventArr, t);
  5349             switch (pe->state) {
  5378 	    switch (pe->state) {
  5350                 case PropertyNewValue:
  5379 		case PropertyNewValue:
  5351                     __ArrayInstPtr(eventArr)->a_element[4] = @symbol(newValue);
  5380 		    __ArrayInstPtr(eventArr)->a_element[4] = @symbol(newValue);
  5352                     break;
  5381 		    break;
  5353                 case PropertyDelete:
  5382 		case PropertyDelete:
  5354                     __ArrayInstPtr(eventArr)->a_element[4] = @symbol(deleted);
  5383 		    __ArrayInstPtr(eventArr)->a_element[4] = @symbol(deleted);
  5355                     break;
  5384 		    break;
  5356                 default:
  5385 		default:
  5357                     __ArrayInstPtr(eventArr)->a_element[4] = nil;
  5386 		    __ArrayInstPtr(eventArr)->a_element[4] = nil;
  5358                     break;
  5387 		    break;
  5359             }
  5388 	    }
  5360             __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(pe->time); __STORE(eventArr, t);
  5389 	    __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(pe->time); __STORE(eventArr, t);
  5361             RETURN (true);
  5390 	    RETURN (true);
  5362             break;
  5391 	    break;
  5363 
  5392 
  5364         case SelectionClear:
  5393 	case SelectionClear:
  5365             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionClear:atom:time:);
  5394 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionClear:atom:time:);
  5366             __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(sce->selection); __STORE(eventArr, t);
  5395 	    __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(sce->selection); __STORE(eventArr, t);
  5367             __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(sce->time);      __STORE(eventArr, t);
  5396 	    __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(sce->time);      __STORE(eventArr, t);
  5368             RETURN (true);
  5397 	    RETURN (true);
  5369             break;
  5398 	    break;
  5370 
  5399 
  5371         case SelectionRequest:
  5400 	case SelectionRequest:
  5372             /*
  5401 	    /*
  5373              * someone wants the selection
  5402 	     * someone wants the selection
  5374              */
  5403 	     */
  5375             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionRequest:requestor:selection:target:property:time:);
  5404 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionRequest:requestor:selection:target:property:time:);
  5376             __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselectionrequest.requestor); __STORE(eventArr, t);
  5405 	    __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselectionrequest.requestor); __STORE(eventArr, t);
  5377             __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselectionrequest.selection); __STORE(eventArr, t);
  5406 	    __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselectionrequest.selection); __STORE(eventArr, t);
  5378             __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselectionrequest.target);    __STORE(eventArr, t);
  5407 	    __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselectionrequest.target);    __STORE(eventArr, t);
  5379             __ArrayInstPtr(eventArr)->a_element[6] = t = __MKUINT(ev->xselectionrequest.property);  __STORE(eventArr, t);
  5408 	    __ArrayInstPtr(eventArr)->a_element[6] = t = __MKUINT(ev->xselectionrequest.property);  __STORE(eventArr, t);
  5380             __ArrayInstPtr(eventArr)->a_element[7] = t = __MKUINT(ev->xselectionrequest.time);      __STORE(eventArr, t);
  5409 	    __ArrayInstPtr(eventArr)->a_element[7] = t = __MKUINT(ev->xselectionrequest.time);      __STORE(eventArr, t);
  5381             RETURN (true);
  5410 	    RETURN (true);
  5382 
  5411 
  5383         case SelectionNotify:
  5412 	case SelectionNotify:
  5384             /*
  5413 	    /*
  5385              * returned selection value (answer from SelectionRequest)
  5414 	     * returned selection value (answer from SelectionRequest)
  5386              */
  5415 	     */
  5387             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionNotify:selection:target:property:requestor:time:);
  5416 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(selectionNotify:selection:target:property:requestor:time:);
  5388             __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselection.selection); __STORE(eventArr, t);
  5417 	    __ArrayInstPtr(eventArr)->a_element[3] = t = __MKUINT(ev->xselection.selection); __STORE(eventArr, t);
  5389             __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselection.target);    __STORE(eventArr, t);
  5418 	    __ArrayInstPtr(eventArr)->a_element[4] = t = __MKUINT(ev->xselection.target);    __STORE(eventArr, t);
  5390             __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselection.property);  __STORE(eventArr, t);
  5419 	    __ArrayInstPtr(eventArr)->a_element[5] = t = __MKUINT(ev->xselection.property);  __STORE(eventArr, t);
  5391             __ArrayInstPtr(eventArr)->a_element[6] = t = __MKEXTERNALADDRESS(ev->xselection.requestor); __STORE(eventArr, t);
  5420 	    __ArrayInstPtr(eventArr)->a_element[6] = t = __MKEXTERNALADDRESS(ev->xselection.requestor); __STORE(eventArr, t);
  5392             __ArrayInstPtr(eventArr)->a_element[7] = t = __MKUINT(ev->xselection.time); __STORE(eventArr, t);
  5421 	    __ArrayInstPtr(eventArr)->a_element[7] = t = __MKUINT(ev->xselection.time); __STORE(eventArr, t);
  5393 
  5422 
  5394             RETURN (true);
  5423 	    RETURN (true);
  5395 
  5424 
  5396         case ColormapNotify:
  5425 	case ColormapNotify:
  5397             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(colormapNotify:state:);
  5426 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(colormapNotify:state:);
  5398             __ArrayInstPtr(eventArr)->a_element[3] = cme->state == ColormapInstalled ? true : false;
  5427 	    __ArrayInstPtr(eventArr)->a_element[3] = cme->state == ColormapInstalled ? true : false;
  5399             RETURN (true);
  5428 	    RETURN (true);
  5400             break;
  5429 	    break;
  5401 
  5430 
  5402         case ClientMessage:
  5431 	case ClientMessage:
  5403             if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) {
  5432 	    if (ev->xclient.message_type == (int) _AtomVal(__INST(protocolsAtom))) {
  5404                 if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom)))
  5433 		if ((ev->xclient.data.l[0] == (int) _AtomVal(__INST(quitAppAtom)))
  5405                  || (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) {
  5434 		 || (ev->xclient.data.l[0] == (int) _AtomVal(__INST(deleteWindowAtom)))) {
  5406                     __ArrayInstPtr(eventArr)->a_element[2] = @symbol(terminateView:);
  5435 		    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(terminateView:);
  5407                     RETURN (true);
  5436 		    RETURN (true);
  5408                 }
  5437 		}
  5409                 if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) {
  5438 		if (ev->xclient.data.l[0] == (int) _AtomVal(__INST(saveYourselfAtom))) {
  5410                     __ArrayInstPtr(eventArr)->a_element[2] = @symbol(saveAndTerminateView:);
  5439 		    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(saveAndTerminateView:);
  5411                     RETURN (true);
  5440 		    RETURN (true);
  5412                 }
  5441 		}
  5413             }
  5442 	    }
  5414             /*
  5443 	    /*
  5415              * any other client message
  5444 	     * any other client message
  5416              */
  5445 	     */
  5417             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(clientMessage:type:format:data:);
  5446 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(clientMessage:type:format:data:);
  5418             __ArrayInstPtr(eventArr)->a_element[3] = __MKSMALLINT(ev->xclient.message_type);
  5447 	    __ArrayInstPtr(eventArr)->a_element[3] = __MKSMALLINT(ev->xclient.message_type);
  5419             __ArrayInstPtr(eventArr)->a_element[4] = __MKSMALLINT(ev->xclient.format);
  5448 	    __ArrayInstPtr(eventArr)->a_element[4] = __MKSMALLINT(ev->xclient.format);
  5420             __ArrayInstPtr(eventArr)->a_element[5] = t = __MKBYTEARRAY(ev->xclient.data, sizeof(ev->xclient.data)); __STORE(eventArr, t);
  5449 	    __ArrayInstPtr(eventArr)->a_element[5] = t = __MKBYTEARRAY(ev->xclient.data, sizeof(ev->xclient.data)); __STORE(eventArr, t);
  5421             RETURN (true);
  5450 	    RETURN (true);
  5422             break;
  5451 	    break;
  5423 
  5452 
  5424         case MappingNotify:
  5453 	case MappingNotify:
  5425             switch(mape->request) {
  5454 	    switch(mape->request) {
  5426                 case MappingModifier:
  5455 		case MappingModifier:
  5427                     __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingModifier:);
  5456 		    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingModifier:);
  5428                     break;
  5457 		    break;
  5429                 case MappingKeyboard:
  5458 		case MappingKeyboard:
  5430                     __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingKeyboard:);
  5459 		    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingKeyboard:);
  5431                     break;
  5460 		    break;
  5432                 case MappingPointer:
  5461 		case MappingPointer:
  5433                     __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingPointer:);
  5462 		    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mappingPointer:);
  5434                     break;
  5463 		    break;
  5435                 default:
  5464 		default:
  5436                     arg = nil;
  5465 		    arg = nil;
  5437                     break;
  5466 		    break;
  5438             }
  5467 	    }
  5439             RETURN (true);
  5468 	    RETURN (true);
  5440 
  5469 
  5441         case KeymapNotify:
  5470 	case KeymapNotify:
  5442             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(keymapNotify:);
  5471 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(keymapNotify:);
  5443             RETURN (true);
  5472 	    RETURN (true);
  5444             break;
  5473 	    break;
  5445 
  5474 
  5446         case MapRequest:
  5475 	case MapRequest:
  5447             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mapRequest:);
  5476 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(mapRequest:);
  5448             RETURN (true);
  5477 	    RETURN (true);
  5449 
  5478 
  5450         case ReparentNotify:
  5479 	case ReparentNotify:
  5451             __ArrayInstPtr(eventArr)->a_element[2] = @symbol(reparentedView:);
  5480 	    __ArrayInstPtr(eventArr)->a_element[2] = @symbol(reparentedView:);
  5452             break;
  5481 	    break;
  5453 
  5482 
  5454 
  5483 
  5455     }
  5484     }
  5456 #undef ae
  5485 #undef ae
  5457 #undef ee
  5486 #undef ee
  5496      If the argument aViewIdOrNil is nil, events for any view are processed,
  5525      If the argument aViewIdOrNil is nil, events for any view are processed,
  5497      otherwise only events for the view with given id are processed.
  5526      otherwise only events for the view with given id are processed.
  5498      If the argument aMask is nonNil, only events for this eventMask are
  5527      If the argument aMask is nonNil, only events for this eventMask are
  5499      handled.
  5528      handled.
  5500      WARNING: this may block to wait for an event - you better check for a 
  5529      WARNING: this may block to wait for an event - you better check for a 
  5501               pending event before calling this."
  5530 	      pending event before calling this."
  5502 
  5531 
  5503     (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
  5532     (self getEventFor:aViewIdOrNil withMask:eventMask) ifTrue:[
  5504         AbortSignal handle:[:ex |
  5533 	AbortSignal handle:[:ex |
  5505             ex return
  5534 	    ex return
  5506         ] do:[
  5535 	] do:[
  5507             self newDispatchLastEvent.
  5536 	    self newDispatchLastEvent.
  5508         ]
  5537 	]
  5509     ].
  5538     ].
  5510 
  5539 
  5511     "Modified: 19.8.1997 / 17:10:42 / cg"
  5540     "Modified: 19.8.1997 / 17:10:42 / cg"
  5512 !
  5541 !
  5513 
  5542 
  6194 dispatchLastEvent:evArray
  6223 dispatchLastEvent:evArray
  6195     |viewId view evTypeNr evType arguments|
  6224     |viewId view evTypeNr evType arguments|
  6196 
  6225 
  6197     viewId := evArray at:1.
  6226     viewId := evArray at:1.
  6198     viewId notNil ifTrue:[
  6227     viewId notNil ifTrue:[
  6199         viewId = lastId ifTrue:[
  6228 	viewId = lastId ifTrue:[
  6200             view := lastView
  6229 	    view := lastView
  6201         ] ifFalse:[
  6230 	] ifFalse:[
  6202             view := self viewFromId:viewId
  6231 	    view := self viewFromId:viewId
  6203         ].
  6232 	].
  6204     ].
  6233     ].
  6205 
  6234 
  6206     evType := evArray at:3.
  6235     evType := evArray at:3.
  6207 
  6236 
  6208     (self respondsTo:evType) ifTrue:[
  6237     (self respondsTo:evType) ifTrue:[
  6209         arguments := evArray copyFrom:3 to:(3 + evType numArgs - 1).
  6238 	arguments := evArray copyFrom:3 to:(3 + evType numArgs - 1).
  6210         arguments at:1 put:view.
  6239 	arguments at:1 put:view.
  6211 
  6240 
  6212         self perform:evType withArguments:arguments.
  6241 	self perform:evType withArguments:arguments.
  6213         ^ true.
  6242 	^ true.
  6214     ].
  6243     ].
  6215 '********** unhandled event:' errorPrintCR.
  6244 '********** unhandled event:' errorPrintCR.
  6216 evType errorPrintCR.
  6245 evType errorPrintCR.
  6217 '********** see newDispatchLastEvent' errorPrintCR.
  6246 '********** see newDispatchLastEvent' errorPrintCR.
  6218     ^ false
  6247     ^ false
  6228      we only handle exposes until the graphicsExpose arrives.
  6257      we only handle exposes until the graphicsExpose arrives.
  6229      Other systems may not need such a kludge"
  6258      Other systems may not need such a kludge"
  6230 
  6259 
  6231     "interested in exposes only ?"
  6260     "interested in exposes only ?"
  6232     dispatchingExpose notNil ifTrue:[
  6261     dispatchingExpose notNil ifTrue:[
  6233         [self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[
  6262 	[self exposeEventPendingFor:dispatchingExpose withSync:false] whileTrue:[
  6234             self dispatchExposeEventFor:dispatchingExpose
  6263 	    self dispatchExposeEventFor:dispatchingExpose
  6235         ].
  6264 	].
  6236         ^ self
  6265 	^ self
  6237     ].
  6266     ].
  6238 
  6267 
  6239     [self eventPendingWithSync:false] whileTrue:[
  6268     [self eventPendingWithSync:false] whileTrue:[
  6240         (self getEventFor:nil withMask:nil) ifTrue:[
  6269 	(self getEventFor:nil withMask:nil) ifTrue:[
  6241             AbortSignal handle:[:ex |
  6270 	    AbortSignal handle:[:ex |
  6242                 ex return
  6271 		ex return
  6243             ] do:[
  6272 	    ] do:[
  6244                 self newDispatchLastEvent
  6273 		self newDispatchLastEvent
  6245             ]
  6274 	    ]
  6246         ].
  6275 	].
  6247     ]
  6276     ]
  6248 
  6277 
  6249     "Modified: 19.8.1997 / 17:11:18 / cg"
  6278     "Modified: 19.8.1997 / 17:11:18 / cg"
  6250 !
  6279 !
  6251 
  6280 
  6253     "dispose (throw away) specific events. If aWindowId is nil,
  6282     "dispose (throw away) specific events. If aWindowId is nil,
  6254      events matching the mask are thrown away regardless of which
  6283      events matching the mask are thrown away regardless of which
  6255      view they are for. Otherwise, only matching events for that 
  6284      view they are for. Otherwise, only matching events for that 
  6256      view are flushed."
  6285      view are flushed."
  6257 
  6286 
  6258 %{  /* NOCONTEXT */
  6287     <context: #return>
       
  6288 %{
  6259 
  6289 
  6260     XEvent ev;
  6290     XEvent ev;
  6261     Window win;
  6291     Window win;
  6262 
  6292 
  6263     if (ISCONNECTED
  6293     if (ISCONNECTED
  6273 	}
  6303 	}
  6274 	LEAVE_XLIB();
  6304 	LEAVE_XLIB();
  6275 	RETURN ( self );
  6305 	RETURN ( self );
  6276     }
  6306     }
  6277 %}.
  6307 %}.
  6278     self primitiveFailed
  6308     self primitiveFailedOrClosedConnection
  6279 !
  6309 !
  6280 
  6310 
  6281 eventMaskFor:anEventSymbol
  6311 eventMaskFor:anEventSymbol
  6282     "return the eventMask bit-constant corresponding to an event symbol"
  6312     "return the eventMask bit-constant corresponding to an event symbol"
  6283 
  6313 
  6330 !
  6360 !
  6331 
  6361 
  6332 eventPending:anEventMask for:aWindowIdOrNil withSync:doSync
  6362 eventPending:anEventMask for:aWindowIdOrNil withSync:doSync
  6333     "return true, if any of the masked events is pending"
  6363     "return true, if any of the masked events is pending"
  6334 
  6364 
       
  6365     <context: #return>
  6335 %{  /* UNLIMITEDSTACK */
  6366 %{  /* UNLIMITEDSTACK */
  6336 
  6367 
  6337     XEvent ev;
  6368     XEvent ev;
  6338     Window win;
  6369     Window win;
  6339     int thereIsOne;
  6370     int thereIsOne;
  6340     OBJ rslt = false;
  6371     OBJ rslt = false;
  6341 
  6372 
  6342     if (ISCONNECTED && __isSmallInteger(anEventMask)) {
  6373     if (ISCONNECTED && __isSmallInteger(anEventMask)) {
  6343         Display *dpy = myDpy;
  6374 	Display *dpy = myDpy;
  6344 
  6375 
  6345         ENTER_XLIB();
  6376 	ENTER_XLIB();
  6346         if (doSync == true) {
  6377 	if (doSync == true) {
  6347             XSync(dpy, 0);      /* make certain everything is flushed */
  6378 	    XSync(dpy, 0);      /* make certain everything is flushed */
  6348         }
  6379 	}
  6349         if (__isExternalAddress(aWindowIdOrNil)) {
  6380 	if (__isExternalAddress(aWindowIdOrNil)) {
  6350             win = _WindowVal(aWindowIdOrNil);
  6381 	    win = _WindowVal(aWindowIdOrNil);
  6351             thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev);
  6382 	    thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev);
  6352         } else {
  6383 	} else {
  6353             thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev);
  6384 	    thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev);
  6354         }
  6385 	}
  6355         if (thereIsOne) {
  6386 	if (thereIsOne) {
  6356             XPutBackEvent(dpy, &ev);
  6387 	    XPutBackEvent(dpy, &ev);
  6357             rslt = true;
  6388 	    rslt = true;
  6358         }
  6389 	}
  6359         LEAVE_XLIB();
  6390 	LEAVE_XLIB();
  6360     }
  6391     }
  6361     RETURN ( rslt );
  6392     RETURN ( rslt );
  6362 %}
  6393 %}
  6363 !
  6394 !
  6364 
  6395 
  6365 eventPendingWithSync:doSync
  6396 eventPendingWithSync:doSync
  6366     "return true, if any event is pending. 
  6397     "return true, if any event is pending. 
  6367      If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
  6398      If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
  6368      before checking."
  6399      before checking."
  6369 
  6400 
       
  6401     <context: #return>
  6370 %{  /* UNLIMITEDSTACK */
  6402 %{  /* UNLIMITEDSTACK */
  6371     OBJ rslt = false;
  6403     OBJ rslt = false;
  6372 
  6404 
  6373     if (ISCONNECTED) {
  6405     if (ISCONNECTED) {
  6374 	Display *dpy = myDpy;
  6406 	Display *dpy = myDpy;
  6424 
  6456 
  6425 exposeEventPendingFor:aWindowIdOrNil withSync:doSync
  6457 exposeEventPendingFor:aWindowIdOrNil withSync:doSync
  6426     "return true, if any expose event is pending for a specific view,
  6458     "return true, if any expose event is pending for a specific view,
  6427      or any view (if the arg is nil).
  6459      or any view (if the arg is nil).
  6428      This is an X specific, only required after a scroll operation."
  6460      This is an X specific, only required after a scroll operation."
       
  6461 
       
  6462     <context: #return>
  6429 
  6463 
  6430 %{  /* UNLIMITEDSTACK */
  6464 %{  /* UNLIMITEDSTACK */
  6431 
  6465 
  6432     XEvent ev;
  6466     XEvent ev;
  6433     Window win;
  6467     Window win;
  6488     Window win, wWanted;
  6522     Window win, wWanted;
  6489     int evMask;
  6523     int evMask;
  6490     XEvent *ev;
  6524     XEvent *ev;
  6491 
  6525 
  6492     if (! ISCONNECTED) {
  6526     if (! ISCONNECTED) {
  6493         RETURN (false);
  6527 	RETURN (false);
  6494     }
  6528     }
  6495 
  6529 
  6496     dpy = myDpy;
  6530     dpy = myDpy;
  6497 
  6531 
  6498     if (__isByteArray(anEventBuffer)) {
  6532     if (__isByteArray(anEventBuffer)) {
  6499         ev = (XEvent *)(__ByteArrayInstPtr(anEventBuffer)->ba_element);
  6533 	ev = (XEvent *)(__ByteArrayInstPtr(anEventBuffer)->ba_element);
  6500     } else {
  6534     } else {
  6501         printf("DISPLAY: bad eventBuffer\n");
  6535 	printf("DISPLAY: bad eventBuffer\n");
  6502         RETURN (false);
  6536 	RETURN (false);
  6503     }
  6537     }
  6504     ev->type = 0;
  6538     ev->type = 0;
  6505 
  6539 
  6506     if (__isSmallInteger(eventMask)) {
  6540     if (__isSmallInteger(eventMask)) {
  6507         evMask = __intVal(eventMask);
  6541 	evMask = __intVal(eventMask);
  6508     } else {
  6542     } else {
  6509         evMask = ~0;
  6543 	evMask = ~0;
  6510     }
  6544     }
  6511 
  6545 
  6512     if (__isExternalAddress(aViewIdOrNil)) {
  6546     if (__isExternalAddress(aViewIdOrNil)) {
  6513         wWanted = _WindowVal(aViewIdOrNil);
  6547 	wWanted = _WindowVal(aViewIdOrNil);
  6514         if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
  6548 	if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
  6515             RETURN ( true );
  6549 	    RETURN ( true );
  6516         }
  6550 	}
  6517     } else {
  6551     } else {
  6518         if (evMask == ~0) {
  6552 	if (evMask == ~0) {
  6519             XNextEvent(dpy, ev);
  6553 	    XNextEvent(dpy, ev);
  6520             RETURN (true);
  6554 	    RETURN (true);
  6521         }
  6555 	}
  6522         if (XCheckMaskEvent(dpy, evMask, ev)) {
  6556 	if (XCheckMaskEvent(dpy, evMask, ev)) {
  6523            RETURN (true);
  6557 	   RETURN (true);
  6524         }
  6558 	}
  6525     }
  6559     }
  6526     RETURN (false);
  6560     RETURN (false);
  6527 %}.
  6561 %}.
  6528     ^ self primitiveFailed
  6562     ^ self primitiveFailed
  6529 !
  6563 !
  6557     |arr|
  6591     |arr|
  6558 
  6592 
  6559     arr := Array new:13.
  6593     arr := Array new:13.
  6560     self decomposeEventBuffer:eventBuffer into:arr.
  6594     self decomposeEventBuffer:eventBuffer into:arr.
  6561     (self dispatchLastEvent:arr) ifFalse:[
  6595     (self dispatchLastEvent:arr) ifFalse:[
  6562         self dispatchLastEvent
  6596 	self dispatchLastEvent
  6563     ]
  6597     ]
  6564 !
  6598 !
  6565 
  6599 
  6566 setEventMask:aMask in:aWindowId
  6600 setEventMask:aMask in:aWindowId
  6567     "tell X that we are only interested in events from aMask, which
  6601     "tell X that we are only interested in events from aMask, which
  6568      is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
  6602      is the bitwise or of the eventMask bits (see 'eventMaskFor:')"
  6569 
  6603 
  6570 %{  /* NOCONTEXT */
  6604     <context: #return>
       
  6605 %{  
  6571 
  6606 
  6572     int mask;
  6607     int mask;
  6573 
  6608 
  6574     if (ISCONNECTED
  6609     if (ISCONNECTED
  6575      && __isExternalAddress(aWindowId)
  6610      && __isExternalAddress(aWindowId)
  6588 	XSelectInput(myDpy, _WindowVal(aWindowId), mask);
  6623 	XSelectInput(myDpy, _WindowVal(aWindowId), mask);
  6589 	LEAVE_XLIB();
  6624 	LEAVE_XLIB();
  6590 	RETURN ( self );
  6625 	RETURN ( self );
  6591     }
  6626     }
  6592 %}.
  6627 %}.
  6593     self primitiveFailed
  6628     self primitiveFailedOrClosedConnection
  6594 !
  6629 !
  6595 
  6630 
  6596 startDispatch
  6631 startDispatch
  6597     "redefined to clear dispatchingExpose, which is a special X feature"
  6632     "redefined to clear dispatchingExpose, which is a special X feature"
  6598 
  6633 
  6622     "/ Event.xclient.data.l[3]         = d4
  6657     "/ Event.xclient.data.l[3]         = d4
  6623     "/ Event.xclient.data.l[4]         = d5
  6658     "/ Event.xclient.data.l[4]         = d5
  6624     "/
  6659     "/
  6625     "/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event);
  6660     "/ XSendEvent(dpy,DispatchWindow,True,NoEventMask,&Event);
  6626 
  6661 
  6627 %{  /* NOCONTEXT */
  6662     <context: #return>
       
  6663 %{  
  6628     int type;
  6664     int type;
  6629     int state;
  6665     int state;
  6630 
  6666 
  6631     if (ISCONNECTED
  6667     if (ISCONNECTED
  6632      && __isInteger(msgType)
  6668      && __isInteger(msgType)
  6702 	    RETURN ( false )
  6738 	    RETURN ( false )
  6703 	}
  6739 	}
  6704 	RETURN (true)
  6740 	RETURN (true)
  6705     }
  6741     }
  6706 %}.
  6742 %}.
  6707     self primitiveFailed.
  6743     self primitiveFailedOrClosedConnection.
  6708     ^ false
  6744     ^ false
  6709 !
  6745 !
  6710 
  6746 
  6711 sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId
  6747 sendKeyOrButtonEvent:typeSymbol x:xPos y:yPos keyOrButton:keySymCodeOrButtonNr state:stateMask toViewId:targetId
  6712     "send a keyPress/Release or buttonPress/Release event to some (possibly alien) view.
  6748     "send a keyPress/Release or buttonPress/Release event to some (possibly alien) view.
  6716      or a numeric keysym code. If state is nil, the modifier bits (shift & control)
  6752      or a numeric keysym code. If state is nil, the modifier bits (shift & control)
  6717      are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
  6753      are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
  6718      The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
  6754      The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
  6719      (not very user friendly)"
  6755      (not very user friendly)"
  6720 
  6756 
  6721 %{  /* NOCONTEXT */
  6757     <context: #return>
       
  6758 %{ 
  6722     int type;
  6759     int type;
  6723     int state;
  6760     int state;
  6724 
  6761 
  6725     if (__isSmallInteger(stateMask)) {
  6762     if (__isSmallInteger(stateMask)) {
  6726 	state = __intVal(stateMask);
  6763 	state = __intVal(stateMask);
  6823 	    RETURN ( false )
  6860 	    RETURN ( false )
  6824 	}
  6861 	}
  6825 	RETURN (true)
  6862 	RETURN (true)
  6826     }
  6863     }
  6827 %}.
  6864 %}.
  6828     self primitiveFailed.
  6865     self primitiveFailedOrClosedConnection.
  6829     ^ false
  6866     ^ false
  6830 ! !
  6867 ! !
  6831 
  6868 
  6832 !XWorkstation methodsFor:'font stuff'!
  6869 !XWorkstation methodsFor:'font stuff'!
  6833 
  6870 
  6834 createFontFor:aFontName
  6871 createFontFor:aFontName
  6835     "a basic method for X-font allocation; this method allows
  6872     "a basic method for X-font allocation; this method allows
  6836      any font to be aquired (even those not conforming to
  6873      any font to be aquired (even those not conforming to
  6837      standard naming conventions, such as cursor, fixed or k14)"
  6874      standard naming conventions, such as cursor, fixed or k14)"
  6838 
  6875 
       
  6876     <context: #return>
       
  6877 
  6839 %{  /* UNLIMITEDSTACK */
  6878 %{  /* UNLIMITEDSTACK */
  6840     /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */
  6879     /* xxUNLIMITEDSTACK xxSTACK:100000 */
  6841 
  6880 
  6842     XFontStruct *newFont;
  6881     XFontStruct *newFont;
  6843 
  6882 
  6844     if (ISCONNECTED
  6883     if (ISCONNECTED
  6845      && __isNonNilObject(aFontName)
  6884      && __isNonNilObject(aFontName)
  6854 #endif
  6893 #endif
  6855 
  6894 
  6856 	RETURN ( newFont ? __MKEXTERNALADDRESS(newFont) : nil );
  6895 	RETURN ( newFont ? __MKEXTERNALADDRESS(newFont) : nil );
  6857     }
  6896     }
  6858 %}.
  6897 %}.
       
  6898     self primitiveFailedOrClosedConnection.
  6859     ^ nil
  6899     ^ nil
  6860 !
  6900 !
  6861 
  6901 
  6862 decomposeXFontName:aString into:aBlock
  6902 decomposeXFontName:aString into:aBlock
  6863     "extract family, face, style and size from an
  6903     "extract family, face, style and size from an
  7156 !
  7196 !
  7157 
  7197 
  7158 fontMetricInfoOf:fontId 
  7198 fontMetricInfoOf:fontId 
  7159     "evaluate aBlock, passing a fonts metrics as arguments"
  7199     "evaluate aBlock, passing a fonts metrics as arguments"
  7160 
  7200 
       
  7201     <context: #return>
       
  7202 
  7161     |encoding avgAscent avgDescent
  7203     |encoding avgAscent avgDescent
  7162      maxAscent maxDescent minWidth maxWidth avgWidth
  7204      maxAscent maxDescent minWidth maxWidth avgWidth
  7163      res resX resY|
  7205      res resX resY|
  7164 
  7206 
  7165 %{
  7207 %{
  7205 		avgWidth = __MKSMALLINT( len );
  7247 		avgWidth = __MKSMALLINT( len );
  7206 	    }
  7248 	    }
  7207 	}
  7249 	}
  7208     }
  7250     }
  7209 %}.
  7251 %}.
       
  7252     avgAscent == nil ifTrue:[
       
  7253 	self primitiveFailedOrClosedConnection.
       
  7254 	^ nil
       
  7255     ].
  7210     ^ Array 
  7256     ^ Array 
  7211 	with:avgAscent
  7257 	with:avgAscent
  7212 	with:avgDescent
  7258 	with:avgDescent
  7213 	with:maxAscent
  7259 	with:maxAscent
  7214 	with:maxDescent
  7260 	with:maxDescent
  7219 
  7265 
  7220 fontMetricsOf:fontId into:aBlock
  7266 fontMetricsOf:fontId into:aBlock
  7221     "evaluate aBlock, passing a fonts metrics as arguments"
  7267     "evaluate aBlock, passing a fonts metrics as arguments"
  7222 
  7268 
  7223     |info encoding avgAscent avgDescent
  7269     |info encoding avgAscent avgDescent
  7224      maxAscent maxDescent minWidth maxWidth avgWidth
  7270      maxAscent maxDescent minWidth maxWidth avgWidth|
  7225      res resX resY|
       
  7226 
  7271 
  7227     info := self fontMetricInfoOf:fontId.
  7272     info := self fontMetricInfoOf:fontId.
  7228     avgAscent := info at:1.
  7273     avgAscent := info at:1.
  7229     avgDescent := info at:2.
  7274     avgDescent := info at:2.
  7230     maxAscent  := info at:3.
  7275     maxAscent  := info at:3.
  7362 !
  7407 !
  7363 
  7408 
  7364 getAvailableFontsMatching:pattern
  7409 getAvailableFontsMatching:pattern
  7365     "return an Array filled with font names matching aPattern"
  7410     "return an Array filled with font names matching aPattern"
  7366 
  7411 
       
  7412     <context: #return>
       
  7413 
  7367 %{  /* UNLIMITEDSTACK */
  7414 %{  /* UNLIMITEDSTACK */
  7368 
  7415 
  7369     int nnames = 1500;
  7416     int nnames = 1500;
  7370     int available = nnames + 1;
  7417     int available = nnames + 1;
  7371     char **fonts;
  7418     char **fonts;
  7373     int i;
  7420     int i;
  7374 
  7421 
  7375     if (ISCONNECTED) {
  7422     if (ISCONNECTED) {
  7376 	if (__isString(pattern)) {
  7423 	if (__isString(pattern)) {
  7377 	    for (;;) {
  7424 	    for (;;) {
       
  7425 		ENTER_XLIB();
  7378 		fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available);
  7426 		fonts = XListFonts(myDpy, __stringVal(pattern), nnames, &available);
       
  7427 		LEAVE_XLIB();
  7379 		if ((fonts == NULL) || (available < nnames)) break;
  7428 		if ((fonts == NULL) || (available < nnames)) break;
  7380 		XFreeFontNames(fonts);
  7429 		XFreeFontNames(fonts);
  7381 		nnames = available * 2;
  7430 		nnames = available * 2;
  7382 	    }
  7431 	    }
  7383 	    if (fonts == NULL) {
  7432 	    if (fonts == NULL) {
  7723     "Modified: 17.4.1996 / 15:27:57 / cg"
  7772     "Modified: 17.4.1996 / 15:27:57 / cg"
  7724 !
  7773 !
  7725 
  7774 
  7726 releaseFont:aFontId
  7775 releaseFont:aFontId
  7727 
  7776 
  7728 %{  /* NOCONTEXT */
  7777     <context: #return>
       
  7778 %{  
  7729 
  7779 
  7730     XFontStruct *f;
  7780     XFontStruct *f;
  7731 
  7781 
  7732     if (! ISCONNECTED) {
  7782     if (! ISCONNECTED) {
  7733 	RETURN ( self );
  7783 	RETURN ( self );
  7774     "Created: 27.2.1996 / 01:38:15 / cg"
  7824     "Created: 27.2.1996 / 01:38:15 / cg"
  7775 !
  7825 !
  7776 
  7826 
  7777 widthOf:aString from:index1 to:index2 inFont:aFontId
  7827 widthOf:aString from:index1 to:index2 inFont:aFontId
  7778 
  7828 
  7779 %{  /* NOCONTEXT */
  7829     <context: #return>
       
  7830 %{
  7780 
  7831 
  7781     XFontStruct *f;
  7832     XFontStruct *f;
  7782     char *cp;
  7833     char *cp;
  7783     int len, n, i1, i2, l;
  7834     int len, n, i1, i2, l;
  7784     OBJ cls;
  7835     OBJ cls;
  7788 
  7839 
  7789     if (ISCONNECTED) {
  7840     if (ISCONNECTED) {
  7790 	if (__bothSmallInteger(index1, index2)
  7841 	if (__bothSmallInteger(index1, index2)
  7791 	 && __isExternalAddress(aFontId)
  7842 	 && __isExternalAddress(aFontId)
  7792 	 && __isNonNilObject(aString)) {
  7843 	 && __isNonNilObject(aString)) {
       
  7844 	    int lMax = __intVal(@global(XWorkstation:MaxStringLength));
  7793 	    f = _FontVal(aFontId);
  7845 	    f = _FontVal(aFontId);
  7794 	    if (! f) goto fail;
  7846 	    if (! f) goto fail;
  7795 
  7847 
  7796 	    i1 = __intVal(index1) - 1;
  7848 	    i1 = __intVal(index1) - 1;
  7797 	    cls = __qClass(aString);
  7849 	    cls = __qClass(aString);
  7846 			int i;
  7898 			int i;
  7847 			XChar2b *cp2 = (XChar2b *)0;
  7899 			XChar2b *cp2 = (XChar2b *)0;
  7848 			int mustFree = 0;
  7900 			int mustFree = 0;
  7849 
  7901 
  7850 			cp += (i1 * 2);
  7902 			cp += (i1 * 2);
  7851 			if (l > 1000) l = 1000;
  7903 			if (l > lMax) l = lMax;
  7852 
  7904 
  7853 			/*
  7905 			/*
  7854 			 * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  7906 			 * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  7855 			 * X expects them MSB first
  7907 			 * X expects them MSB first
  7856 			 * convert as required
  7908 			 * convert as required
  7887 	}
  7939 	}
  7888     }
  7940     }
  7889 #undef NLOCALBUFFER
  7941 #undef NLOCALBUFFER
  7890 fail: ;
  7942 fail: ;
  7891 %}.
  7943 %}.
  7892     self primitiveFailed.
  7944     self primitiveFailedOrClosedConnection.
  7893     ^ 0
  7945     ^ 0
  7894 !
  7946 !
  7895 
  7947 
  7896 widthOf:aString inFont:aFontId
  7948 widthOf:aString inFont:aFontId
  7897 
  7949 
  7898 %{  /* NOCONTEXT */
  7950     <context: #return>
       
  7951 %{
  7899 
  7952 
  7900     XFontStruct *f;
  7953     XFontStruct *f;
  7901     char *cp;
  7954     char *cp;
  7902     int len, n;
  7955     int len, n;
  7903     OBJ cls;
  7956     OBJ cls;
  7904 #   define NLOCALBUFFER 200
  7957 #   define NLOCALBUFFER 200
  7905     XChar2b xlatebuffer[NLOCALBUFFER];
  7958     XChar2b xlatebuffer[NLOCALBUFFER];
  7906     int nInstBytes;
  7959     int nInstBytes;
  7907 
  7960 
  7908     if (ISCONNECTED) {
  7961     if (ISCONNECTED) {
  7909         if (__isExternalAddress(aFontId)
  7962 	if (__isExternalAddress(aFontId)
  7910          && __isNonNilObject(aString)) {
  7963 	 && __isNonNilObject(aString)) {
  7911             f = _FontVal(aFontId);
  7964 	    int lMax = __intVal(@global(XWorkstation:MaxStringLength));
  7912             if (! f) goto fail;
  7965 	    f = _FontVal(aFontId);
  7913 
  7966 	    if (! f) goto fail;
  7914             cls = __qClass(aString);
  7967 
  7915 
  7968 	    cls = __qClass(aString);
  7916             cp = (char *) __stringVal(aString);
  7969 
  7917 
  7970 	    cp = (char *) __stringVal(aString);
  7918             if ((cls == @global(String)) || (cls == @global(Symbol))) {
  7971 
  7919                 n = __stringSize(aString);
  7972 	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
  7920 
  7973 		n = __stringSize(aString);
  7921                 ENTER_XLIB();
  7974 
  7922                 len = XTextWidth(f, cp, n);
  7975 		ENTER_XLIB();
  7923                 LEAVE_XLIB();
  7976 		len = XTextWidth(f, cp, n);
  7924 
  7977 		LEAVE_XLIB();
  7925                 RETURN ( __MKSMALLINT(len) );
  7978 
  7926             }
  7979 		RETURN ( __MKSMALLINT(len) );
  7927 
  7980 	    }
  7928             nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  7981 
  7929             cp += nInstBytes;
  7982 	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
  7930 
  7983 	    cp += nInstBytes;
  7931             if (__isBytes(aString)) {
  7984 
  7932                 n = __byteArraySize(aString) - nInstBytes;
  7985 	    if (__isBytes(aString)) {
  7933 
  7986 		n = __byteArraySize(aString) - nInstBytes;
  7934 
  7987 
  7935                 ENTER_XLIB();
  7988 
  7936                 len = XTextWidth(f, cp, n);
  7989 		ENTER_XLIB();
  7937                 LEAVE_XLIB();
  7990 		len = XTextWidth(f, cp, n);
  7938 
  7991 		LEAVE_XLIB();
  7939                 RETURN ( __MKSMALLINT(len) );
  7992 
  7940             }
  7993 		RETURN ( __MKSMALLINT(len) );
  7941 
  7994 	    }
  7942             /* TWOBYTESTRINGS */
  7995 
  7943             if (__isWords(aString)) {
  7996 	    /* TWOBYTESTRINGS */
  7944                 union {
  7997 	    if (__isWords(aString)) {
  7945                     char b[2];
  7998 		union {
  7946                     unsigned short s;
  7999 		    char b[2];
  7947                 } u;
  8000 		    unsigned short s;
  7948                 int i;
  8001 		} u;
  7949                 XChar2b *cp2;
  8002 		int i;
  7950                 int mustFree = 0;
  8003 		XChar2b *cp2;
  7951 
  8004 		int mustFree = 0;
  7952                 n = (__byteArraySize(aString) - nInstBytes) / 2;
  8005 
  7953                 if (n > 1000) n = 1000;
  8006 		n = (__byteArraySize(aString) - nInstBytes) / 2;
  7954 
  8007 		if (n > lMax) n = lMax;
  7955                 /*
  8008 
  7956                  * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  8009 		/*
  7957                  * X expects them MSB first
  8010 		 * ST/X TwoByteStrings store the asciiValue in native byteOrder;
  7958                  * convert as required
  8011 		 * X expects them MSB first
  7959                  */
  8012 		 * convert as required
  7960 
  8013 		 */
  7961                 u.s = 0x1234;
  8014 
  7962                 if (u.b[0] != 0x12) {
  8015 		u.s = 0x1234;
  7963                     if (n <= NLOCALBUFFER) {
  8016 		if (u.b[0] != 0x12) {
  7964                         cp2 = xlatebuffer;
  8017 		    if (n <= NLOCALBUFFER) {
  7965                     } else {
  8018 			cp2 = xlatebuffer;
  7966                         cp2 = (XChar2b *)(malloc(n * 2));
  8019 		    } else {
  7967                         mustFree = 1;
  8020 			cp2 = (XChar2b *)(malloc(n * 2));
  7968                     }
  8021 			mustFree = 1;
  7969 
  8022 		    }
  7970                     for (i=0; i<n; i++) {
  8023 
  7971                         cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
  8024 		    for (i=0; i<n; i++) {
  7972                         cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
  8025 			cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
  7973                     }
  8026 			cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
  7974                     cp = (char *) cp2;
  8027 		    }
  7975                 }
  8028 		    cp = (char *) cp2;
  7976 
  8029 		}
  7977 
  8030 
  7978                 ENTER_XLIB();
  8031 
  7979                 len = XTextWidth16(f, (XChar2b *)cp, n);
  8032 		ENTER_XLIB();
  7980                 LEAVE_XLIB();
  8033 		len = XTextWidth16(f, (XChar2b *)cp, n);
  7981 
  8034 		LEAVE_XLIB();
  7982 
  8035 
  7983                 if (mustFree) {
  8036 
  7984                     free(cp2);
  8037 		if (mustFree) {
  7985                 }
  8038 		    free(cp2);
  7986 
  8039 		}
  7987                 RETURN ( __MKSMALLINT(len) );
  8040 
  7988             }
  8041 		RETURN ( __MKSMALLINT(len) );
  7989         }
  8042 	    }
       
  8043 	}
  7990     }
  8044     }
  7991 #undef NLOCALBUFFER
  8045 #undef NLOCALBUFFER
  7992   fail: ;
  8046   fail: ;
  7993 %}.
  8047 %}.
  7994     ^ super widthOf:aString inFont:aFontId
  8048     ^ super widthOf:aString inFont:aFontId
  7995 ! !
  8049 ! !
  7996 
  8050 
  7997 !XWorkstation methodsFor:'grabbing'!
  8051 !XWorkstation methodsFor:'grabbing'!
  7998 
  8052 
  7999 allowEvents:mode
  8053 allowEvents:mode
  8000 %{  /* NOCONTEXT */
  8054     <context: #return>
       
  8055 %{
  8001 
  8056 
  8002     int _mode, ok = 1;
  8057     int _mode, ok = 1;
  8003 
  8058 
  8004     if (mode == @symbol(asyncPointer))
  8059     if (mode == @symbol(asyncPointer))
  8005 	_mode = AsyncPointer;
  8060 	_mode = AsyncPointer;
  8018     else if (mode == @symbol(replayKeyboard))
  8073     else if (mode == @symbol(replayKeyboard))
  8019 	_mode = ReplayKeyboard;
  8074 	_mode = ReplayKeyboard;
  8020     else
  8075     else
  8021 	ok = 0;
  8076 	ok = 0;
  8022 
  8077 
  8023     if (ok) {
  8078     if (ok
  8024 	if (ISCONNECTED) {
  8079      && ISCONNECTED) {
  8025 
  8080 	ENTER_XLIB();
  8026 	    ENTER_XLIB();
  8081 	XAllowEvents(myDpy, _mode, CurrentTime);
  8027 	    XAllowEvents(myDpy, _mode, CurrentTime);
  8082 	LEAVE_XLIB();
  8028 	    LEAVE_XLIB();
  8083 
  8029 
  8084 	RETURN (self);
  8030 	    RETURN (self);
  8085     }
  8031 	}
  8086 %}.
  8032     }
  8087     self primitiveFailedOrClosedConnection
  8033 %}.
       
  8034     self primitiveFailed
       
  8035 !
  8088 !
  8036 
  8089 
  8037 grabKeyboardIn:aWindowId
  8090 grabKeyboardIn:aWindowId
  8038     "grab the keyboard"
  8091     "grab the keyboard"
  8039 
  8092 
  8040 %{  /* NOCONTEXT */
  8093     <context: #return>
       
  8094 %{
  8041     int result, ok;
  8095     int result, ok;
  8042 
  8096 
  8043     if (ISCONNECTED) {
  8097     if (ISCONNECTED) {
  8044 	if (__isExternalAddress(aWindowId)) {
  8098 	if (__isExternalAddress(aWindowId)) {
  8045 
  8099 
  8087 
  8141 
  8088 	    RETURN ( true );
  8142 	    RETURN ( true );
  8089 	}
  8143 	}
  8090     }
  8144     }
  8091 %}.
  8145 %}.
  8092     self primitiveFailed
  8146     self primitiveFailedOrClosedConnection.
       
  8147     ^ false
  8093 !
  8148 !
  8094 
  8149 
  8095 grabPointerIn:aWindowId withCursor:aCursorId eventMask:eventMask pointerMode:pMode keyboardMode:kMode confineTo:confineId
  8150 grabPointerIn:aWindowId withCursor:aCursorId eventMask:eventMask pointerMode:pMode keyboardMode:kMode confineTo:confineId
  8096     "grap the pointer - return true if ok"
  8151     "grap the pointer - return true if ok"
  8097 
  8152 
  8098 %{  /* NOCONTEXT */
  8153     <context: #return>
       
  8154 %{ 
  8099 
  8155 
  8100     int result, ok, evMask;
  8156     int result, ok, evMask;
  8101     Window confineWin;
  8157     Window confineWin;
  8102     Cursor curs;
  8158     Cursor curs;
  8103     int pointer_mode, keyboard_mode;
  8159     int pointer_mode, keyboard_mode;
  8185 	    }
  8241 	    }
  8186 	    RETURN ( true );
  8242 	    RETURN ( true );
  8187 	}
  8243 	}
  8188     }
  8244     }
  8189 %}.
  8245 %}.
  8190     self primitiveFailed
  8246     self primitiveFailedOrClosedConnection.
       
  8247     ^ false
  8191 !
  8248 !
  8192 
  8249 
  8193 grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
  8250 grabPointerIn:aWindowId withCursor:aCursorId pointerMode:pMode keyboardMode:kMode confineTo:confineId
  8194     "grap the pointer - return true if ok"
  8251     "grap the pointer - return true if ok"
  8195 
  8252 
  8205 !
  8262 !
  8206 
  8263 
  8207 primUngrabKeyboard
  8264 primUngrabKeyboard
  8208     "release the keyboard"
  8265     "release the keyboard"
  8209 
  8266 
  8210 %{  /* NOCONTEXT */
  8267     <context: #return>
       
  8268 %{ 
  8211 
  8269 
  8212     if (ISCONNECTED) {
  8270     if (ISCONNECTED) {
  8213         Display *dpy = myDpy;
  8271 	Display *dpy = myDpy;
  8214 
  8272 
  8215         ENTER_XLIB();
  8273 	ENTER_XLIB();
  8216         XUngrabKeyboard(dpy, CurrentTime);
  8274 	XUngrabKeyboard(dpy, CurrentTime);
  8217         XSync(dpy, 0);
  8275 	XSync(dpy, 0);
  8218         LEAVE_XLIB();
  8276 	LEAVE_XLIB();
  8219 
  8277 
  8220     }
  8278     }
  8221 %}.
  8279 %}.
  8222 !
  8280 !
  8223 
  8281 
  8224 primUngrabPointer
  8282 primUngrabPointer
  8225     "release the pointer"
  8283     "release the pointer"
  8226 
  8284 
  8227 %{  /* NOCONTEXT */
  8285     <context: #return>
       
  8286 %{
  8228 
  8287 
  8229     if (ISCONNECTED) {
  8288     if (ISCONNECTED) {
  8230         Display *dpy = myDpy;
  8289 	Display *dpy = myDpy;
  8231 
  8290 
  8232         ENTER_XLIB();
  8291 	ENTER_XLIB();
  8233         XUngrabPointer(dpy, CurrentTime);
  8292 	XUngrabPointer(dpy, CurrentTime);
  8234         XSync(dpy, 0);
  8293 	XSync(dpy, 0);
  8235         LEAVE_XLIB();
  8294 	LEAVE_XLIB();
  8236 
  8295 
  8237     }
  8296     }
  8238 %}.
  8297 %}.
  8239 !
  8298 !
  8240 
  8299 
  8255 !XWorkstation methodsFor:'graphic context stuff'!
  8314 !XWorkstation methodsFor:'graphic context stuff'!
  8256 
  8315 
  8257 noClipIn:aDrawableId gc:aGCId
  8316 noClipIn:aDrawableId gc:aGCId
  8258     "disable clipping rectangle"
  8317     "disable clipping rectangle"
  8259 
  8318 
  8260 %{  /* NOCONTEXT */
  8319     <context: #return>
       
  8320 %{ 
  8261 
  8321 
  8262     XGCValues gcv;
  8322     XGCValues gcv;
  8263     GC gc;
  8323     GC gc;
  8264 
  8324 
  8265     if (ISCONNECTED) {
  8325     if (ISCONNECTED) {
  8271 	    LEAVE_XLIB();
  8331 	    LEAVE_XLIB();
  8272 	    RETURN ( self );
  8332 	    RETURN ( self );
  8273 	}
  8333 	}
  8274     }
  8334     }
  8275 %}.
  8335 %}.
  8276     self primitiveFailed
  8336     self primitiveFailedOrClosedConnection
  8277 !
  8337 !
  8278 
  8338 
  8279 setBackground:bgColorIndex in:aGCId
  8339 setBackground:bgColorIndex in:aGCId
  8280     "set background color to be drawn with"
  8340     "set background color to be drawn with"
  8281 
  8341 
  8282 %{  /* NOCONTEXT */
  8342     <context: #return>
       
  8343 %{ 
  8283 
  8344 
  8284     if (ISCONNECTED) {
  8345     if (ISCONNECTED) {
  8285 	if (__isExternalAddress(aGCId)
  8346 	if (__isExternalAddress(aGCId)
  8286 	 && __isSmallInteger(bgColorIndex)) {
  8347 	 && __isSmallInteger(bgColorIndex)) {
  8287 	    ENTER_XLIB();
  8348 	    ENTER_XLIB();
  8289 	    LEAVE_XLIB();
  8350 	    LEAVE_XLIB();
  8290 	    RETURN ( self );
  8351 	    RETURN ( self );
  8291 	}
  8352 	}
  8292     }
  8353     }
  8293 %}.
  8354 %}.
  8294     self primitiveFailed
  8355     self primitiveFailedOrClosedConnection
  8295 !
  8356 !
  8296 
  8357 
  8297 setBitmapMask:aBitmapId in:aGCId
  8358 setBitmapMask:aBitmapId in:aGCId
  8298     "set or clear the drawing mask - a bitmap mask using current fg/bg"
  8359     "set or clear the drawing mask - a bitmap mask using current fg/bg"
  8299 
  8360 
  8300 %{  /* NOCONTEXT */
  8361     <context: #return>
       
  8362 %{  
  8301 
  8363 
  8302     GC gc;
  8364     GC gc;
  8303     Pixmap bitmap;
  8365     Pixmap bitmap;
  8304 
  8366 
  8305     if (ISCONNECTED) {
  8367     if (ISCONNECTED) {
  8322 		RETURN ( self );
  8384 		RETURN ( self );
  8323 	    }
  8385 	    }
  8324 	}
  8386 	}
  8325     }
  8387     }
  8326 %}.
  8388 %}.
  8327     self primitiveFailed
  8389     self primitiveFailedOrClosedConnection
  8328 !
  8390 !
  8329 
  8391 
  8330 setClipByChildren:aBool in:aDrawableId gc:aGCId
  8392 setClipByChildren:aBool in:aDrawableId gc:aGCId
  8331     "enable/disable drawing into child views"
  8393     "enable/disable drawing into child views"
  8332 
  8394 
  8333 %{  /* NOCONTEXT */
  8395     <context: #return>
       
  8396 %{ 
  8334 
  8397 
  8335     XGCValues gcv;
  8398     XGCValues gcv;
  8336     GC gc;
  8399     GC gc;
  8337 
  8400 
  8338     if (ISCONNECTED) {
  8401     if (ISCONNECTED) {
  8348 	    LEAVE_XLIB();
  8411 	    LEAVE_XLIB();
  8349 	    RETURN ( self );
  8412 	    RETURN ( self );
  8350 	}
  8413 	}
  8351     }
  8414     }
  8352 %}.
  8415 %}.
  8353     self primitiveFailed
  8416     self primitiveFailedOrClosedConnection
  8354 !
  8417 !
  8355 
  8418 
  8356 setClipX:clipX y:clipY width:clipWidth height:clipHeight in:drawableId gc:aGCId
  8419 setClipX:clipX y:clipY width:clipWidth height:clipHeight in:drawableId gc:aGCId
  8357     "clip to a rectangle"
  8420     "clip to a rectangle"
  8358 
  8421 
  8359 %{  /* NOCONTEXT */
  8422     <context: #return>
       
  8423 %{ 
  8360 
  8424 
  8361     XRectangle r;
  8425     XRectangle r;
  8362 
  8426 
  8363     if (ISCONNECTED) {
  8427     if (ISCONNECTED) {
  8364 	if (__isExternalAddress(aGCId)
  8428 	if (__isExternalAddress(aGCId)
  8373 	    LEAVE_XLIB();
  8437 	    LEAVE_XLIB();
  8374 	    RETURN ( self );
  8438 	    RETURN ( self );
  8375 	}
  8439 	}
  8376     }
  8440     }
  8377 %}.
  8441 %}.
  8378     self primitiveFailed
  8442     self primitiveFailedOrClosedConnection
  8379 !
  8443 !
  8380 
  8444 
  8381 setDashes:dashList dashOffset:offset in:aGCId
  8445 setDashes:dashList dashOffset:offset in:aGCId
  8382     "set line attributes"
  8446     "set line attributes"
  8383 
  8447 
  8384 %{  /* NOCONTEXT */
  8448     <context: #return>
       
  8449 %{  
  8385 
  8450 
  8386     if (ISCONNECTED) {
  8451     if (ISCONNECTED) {
  8387 	if (__isExternalAddress(aGCId)
  8452 	if (__isExternalAddress(aGCId)
  8388 	 && __isSmallInteger(offset)
  8453 	 && __isSmallInteger(offset)
  8389 	 && __isByteArray(dashList)) {
  8454 	 && __isByteArray(dashList)) {
  8401     "
  8466     "
  8402      either aGCId is invalid,
  8467      either aGCId is invalid,
  8403      and/or dashList is not a byteArray
  8468      and/or dashList is not a byteArray
  8404      and/or offset is not a smallInteger
  8469      and/or offset is not a smallInteger
  8405     "
  8470     "
  8406     self primitiveFailed
  8471     self primitiveFailedOrClosedConnection
  8407 !
  8472 !
  8408 
  8473 
  8409 setFont:aFontId in:aGCId
  8474 setFont:aFontId in:aGCId
  8410     "set font to be drawn in"
  8475     "set font to be drawn in"
  8411 
  8476 
  8412 %{  /* NOCONTEXT */
  8477     <context: #return>
       
  8478 %{  
  8413 
  8479 
  8414     XFontStruct *f;
  8480     XFontStruct *f;
  8415 
  8481 
  8416     if (ISCONNECTED) {
  8482     if (ISCONNECTED) {
  8417 	if (__isExternalAddress(aFontId)
  8483 	if (__isExternalAddress(aFontId)
  8425     }
  8491     }
  8426 %}.
  8492 %}.
  8427     "
  8493     "
  8428      aGCId and/or aFontId are invalid
  8494      aGCId and/or aFontId are invalid
  8429     "
  8495     "
  8430     self primitiveFailed
  8496     self primitiveFailedOrClosedConnection
  8431 !
  8497 !
  8432 
  8498 
  8433 setForeground:fgColorIndex background:bgColorIndex in:aGCId
  8499 setForeground:fgColorIndex background:bgColorIndex in:aGCId
  8434     "set foreground and background colors to be drawn with"
  8500     "set foreground and background colors to be drawn with"
  8435 
  8501 
  8436 %{  /* NOCONTEXT */
  8502     <context: #return>
       
  8503 %{  
  8437 
  8504 
  8438     GC gc;
  8505     GC gc;
  8439 
  8506 
  8440     if (ISCONNECTED) {
  8507     if (ISCONNECTED) {
  8441 	Display *dpy = myDpy;
  8508 	Display *dpy = myDpy;
  8449 	    LEAVE_XLIB();
  8516 	    LEAVE_XLIB();
  8450 	    RETURN ( self );
  8517 	    RETURN ( self );
  8451 	}
  8518 	}
  8452     }
  8519     }
  8453 %}.
  8520 %}.
  8454     self primitiveFailed
  8521     self primitiveFailedOrClosedConnection
  8455 !
  8522 !
  8456 
  8523 
  8457 setForeground:fgColorIndex in:aGCId
  8524 setForeground:fgColorIndex in:aGCId
  8458     "set foreground color to be drawn with"
  8525     "set foreground color to be drawn with"
  8459 
  8526 
  8460 %{  /* NOCONTEXT */
  8527     <context: #return>
       
  8528 %{  
  8461 
  8529 
  8462     if (ISCONNECTED) {
  8530     if (ISCONNECTED) {
  8463 	if (__isExternalAddress(aGCId)
  8531 	if (__isExternalAddress(aGCId)
  8464 	 && __isSmallInteger(fgColorIndex)) {
  8532 	 && __isSmallInteger(fgColorIndex)) {
  8465 	    ENTER_XLIB();
  8533 	    ENTER_XLIB();
  8467 	    LEAVE_XLIB();
  8535 	    LEAVE_XLIB();
  8468 	    RETURN ( self );
  8536 	    RETURN ( self );
  8469 	}
  8537 	}
  8470     }
  8538     }
  8471 %}.
  8539 %}.
  8472     self primitiveFailed
  8540     self primitiveFailedOrClosedConnection
  8473 !
  8541 !
  8474 
  8542 
  8475 setFunction:aFunctionSymbol in:aGCId
  8543 setFunction:aFunctionSymbol in:aGCId
  8476     "set alu function to be drawn with"
  8544     "set alu function to be drawn with"
  8477 
  8545 
  8478 %{  /* NOCONTEXT */
  8546     <context: #return>
       
  8547 %{  
  8479 
  8548 
  8480     GC gc;
  8549     GC gc;
  8481     int fun = -1;
  8550     int fun = -1;
  8482 
  8551 
  8483     if (ISCONNECTED) {
  8552     if (ISCONNECTED) {
  8484         if (__isExternalAddress(aGCId)) {
  8553 	if (__isExternalAddress(aGCId)) {
  8485             gc = _GCVal(aGCId);
  8554 	    gc = _GCVal(aGCId);
  8486             if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
  8555 	    if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
  8487             else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
  8556 	    else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
  8488             else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
  8557 	    else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
  8489             else if (aFunctionSymbol == @symbol(and)) fun = GXand;
  8558 	    else if (aFunctionSymbol == @symbol(and)) fun = GXand;
  8490             else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
  8559 	    else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
  8491             else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
  8560 	    else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
  8492             else if (aFunctionSymbol == @symbol(or)) fun = GXor;
  8561 	    else if (aFunctionSymbol == @symbol(or)) fun = GXor;
  8493             else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
  8562 	    else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
  8494             else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
  8563 	    else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
  8495             else if (aFunctionSymbol == @symbol(invert)) fun = GXinvert;
  8564 	    else if (aFunctionSymbol == @symbol(invert)) fun = GXinvert;
  8496             else if (aFunctionSymbol == @symbol(clear)) fun = GXclear;
  8565 	    else if (aFunctionSymbol == @symbol(clear)) fun = GXclear;
  8497             else if (aFunctionSymbol == @symbol(set)) fun = GXset;
  8566 	    else if (aFunctionSymbol == @symbol(set)) fun = GXset;
  8498             else if (aFunctionSymbol == @symbol(noop)) fun = GXnoop;
  8567 	    else if (aFunctionSymbol == @symbol(noop)) fun = GXnoop;
  8499             else if (aFunctionSymbol == @symbol(equiv)) fun = GXequiv;
  8568 	    else if (aFunctionSymbol == @symbol(equiv)) fun = GXequiv;
  8500             else if (aFunctionSymbol == @symbol(nand)) fun = GXnand;
  8569 	    else if (aFunctionSymbol == @symbol(nand)) fun = GXnand;
  8501             if (fun != -1) {
  8570 	    if (fun != -1) {
  8502                 ENTER_XLIB();
  8571 		ENTER_XLIB();
  8503                 XSetFunction(myDpy, gc, fun);
  8572 		XSetFunction(myDpy, gc, fun);
  8504                 LEAVE_XLIB();
  8573 		LEAVE_XLIB();
  8505                 RETURN ( self );
  8574 		RETURN ( self );
  8506             }
  8575 	    }
  8507         }
  8576 	}
  8508     }
  8577     }
  8509 %}.
  8578 %}.
  8510     "
  8579     "
  8511      either aGCId is not an integer, or an invalid symbol
  8580      either aGCId is not an integer, or an invalid symbol
  8512      was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse,
  8581      was passed ... valid functions are #copy, #copyInverted, #xor, #and, #andReverse,
  8513      #andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details.
  8582      #andInverted, #or, #orReverse, #orInverted. See Xlib documentation for more details.
  8514     "
  8583     "
  8515     self primitiveFailed
  8584     self primitiveFailedOrClosedConnection
  8516 !
  8585 !
  8517 
  8586 
  8518 setGraphicsExposures:aBoolean in:aGCId
  8587 setGraphicsExposures:aBoolean in:aGCId
  8519     "set or clear the graphics exposures flag"
  8588     "set or clear the graphics exposures flag"
  8520 
  8589 
  8521 %{  /* NOCONTEXT */
  8590     <context: #return>
       
  8591 %{  
  8522 
  8592 
  8523     if (ISCONNECTED) {
  8593     if (ISCONNECTED) {
  8524 	if (__isExternalAddress(aGCId)) {
  8594 	if (__isExternalAddress(aGCId)) {
  8525 	    ENTER_XLIB();
  8595 	    ENTER_XLIB();
  8526 	    XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
  8596 	    XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
  8527 	    LEAVE_XLIB();
  8597 	    LEAVE_XLIB();
  8528 	    RETURN ( self );
  8598 	    RETURN ( self );
  8529 	}
  8599 	}
  8530     }
  8600     }
  8531 %}.
  8601 %}.
  8532     self primitiveFailed
  8602     self primitiveFailedOrClosedConnection
  8533 !
  8603 !
  8534 
  8604 
  8535 setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
  8605 setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aGCId
  8536     "set line attributes; 
  8606     "set line attributes; 
  8537      lineStyle must be one of #solid, #dashed or #doubleDashed;
  8607      lineStyle must be one of #solid, #dashed or #doubleDashed;
  8538      capStyle one of: #notLast, #butt, #round or #projecting;
  8608      capStyle one of: #notLast, #butt, #round or #projecting;
  8539      joinStyle one of: #miter, #bevel or #round."
  8609      joinStyle one of: #miter, #bevel or #round."
  8540 
  8610 
  8541 %{  /* NOCONTEXT */
  8611     <context: #return>
       
  8612 %{ 
  8542 
  8613 
  8543     int x_style, x_cap, x_join;
  8614     int x_style, x_cap, x_join;
  8544     static char dashList[2] = { 1,1 };
  8615     static char dashList[2] = { 1,1 };
  8545     static char dotList[2]  = { 4,4 };
  8616     static char dotList[2]  = { 4,4 };
  8546     static char dashDotList[4]    = { 4,1 , 1,1 };
  8617     static char dashDotList[4]    = { 4,1 , 1,1 };
  8607      and/or lineWidth is not a smallInteger,
  8678      and/or lineWidth is not a smallInteger,
  8608      and/or lineStyle is none of #solid, #dashed, #doubleDashed
  8679      and/or lineStyle is none of #solid, #dashed, #doubleDashed
  8609      and/or capStyle is none of #notLast, #butt, #round, #projecting
  8680      and/or capStyle is none of #notLast, #butt, #round, #projecting
  8610      and/or joinStyle is none of #miter, #bevel, #round
  8681      and/or joinStyle is none of #miter, #bevel, #round
  8611     "
  8682     "
  8612     self primitiveFailed
  8683     self primitiveFailedOrClosedConnection
  8613 !
  8684 !
  8614 
  8685 
  8615 setMaskOriginX:orgX y:orgY in:aGCid
  8686 setMaskOriginX:orgX y:orgY in:aGCid
  8616     "set the mask origin"
  8687     "set the mask origin"
  8617 
  8688 
  8618 %{  /* NOCONTEXT */
  8689     <context: #return>
       
  8690 %{  
  8619 
  8691 
  8620     if (ISCONNECTED) {
  8692     if (ISCONNECTED) {
  8621 	if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
  8693 	if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
  8622 	    ENTER_XLIB();
  8694 	    ENTER_XLIB();
  8623 	    XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY));
  8695 	    XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY));
  8624 	    LEAVE_XLIB();
  8696 	    LEAVE_XLIB();
  8625 	    RETURN ( self );
  8697 	    RETURN ( self );
  8626 	}
  8698 	}
  8627     }
  8699     }
  8628 %}.
  8700 %}.
  8629     self primitiveFailed
  8701     self primitiveFailedOrClosedConnection
  8630 !
  8702 !
  8631 
  8703 
  8632 setPixmapMask:aPixmapId in:aGCId
  8704 setPixmapMask:aPixmapId in:aGCId
  8633     "set or clear the drawing mask - a pixmap mask providing full color"
  8705     "set or clear the drawing mask - a pixmap mask providing full color"
  8634 
  8706 
  8635 %{  /* NOCONTEXT */
  8707     <context: #return>
       
  8708 %{  
  8636 
  8709 
  8637     GC gc;
  8710     GC gc;
  8638     Pixmap pixmap;
  8711     Pixmap pixmap;
  8639 
  8712 
  8640     if (ISCONNECTED) {
  8713     if (ISCONNECTED) {
  8657 		RETURN ( self );
  8730 		RETURN ( self );
  8658 	    }
  8731 	    }
  8659 	}
  8732 	}
  8660     }
  8733     }
  8661 %}.
  8734 %}.
  8662     self primitiveFailed
  8735     self primitiveFailedOrClosedConnection
  8663 ! !
  8736 ! !
  8664 
  8737 
  8665 !XWorkstation methodsFor:'initialize / release'!
  8738 !XWorkstation methodsFor:'initialize / release'!
  8666 
  8739 
  8667 closeConnection
  8740 closeConnection
  8668     "close down the connection to the X-server"
  8741     "close down the connection to the X-server"
  8669 
  8742 
       
  8743     <context: #return>
       
  8744 
  8670 "/ 'closing' errorPrintCR.
  8745 "/ 'closing' errorPrintCR.
  8671 "/ thisContext fullPrintAll.
  8746 "/ thisContext fullPrintAll.
  8672 
  8747 
  8673 %{
  8748 %{
  8674 
       
  8675     if (ISCONNECTED) {
  8749     if (ISCONNECTED) {
  8676 	Display *dpy = myDpy;
  8750 	Display *dpy = myDpy;
  8677 
  8751 
  8678 
  8752 
  8679 	__INST(displayId) = nil;
  8753 	__INST(displayId) = nil;
  8680 	ENTER_XLIB();
  8754 	ENTER_XLIB();
  8681 	XCloseDisplay(dpy);
  8755 	XCloseDisplay(dpy);
  8682 	LEAVE_XLIB();
  8756 	LEAVE_XLIB();
  8683 
       
  8684     }
  8757     }
  8685 %}
  8758 %}
  8686 !
  8759 !
  8687 
  8760 
  8688 emergencyCloseConnection
  8761 emergencyCloseConnection
  9178 
  9251 
  9179 %{
  9252 %{
  9180     KeySym keysym;
  9253     KeySym keysym;
  9181     char *keystring;
  9254     char *keystring;
  9182 
  9255 
  9183     if (ISCONNECTED && __isSmallInteger(code)) {
  9256     if (ISCONNECTED
       
  9257      && __isSmallInteger(code)) {
  9184 	Display *dpy = myDpy;
  9258 	Display *dpy = myDpy;
  9185 
  9259 
  9186 	if ((keysym = XKeycodeToKeysym(dpy, __intVal(code), 0)) != NoSymbol &&
  9260 	if ((keysym = XKeycodeToKeysym(dpy, __intVal(code), 0)) != NoSymbol &&
  9187 	    (keystring = XKeysymToString(keysym)) != 0) 
  9261 	    (keystring = XKeysymToString(keysym)) != 0) 
  9188 	    str = __MKSTRING(keystring);
  9262 	    str = __MKSTRING(keystring);
  9221     "Modified: / 3.12.1999 / 17:13:59 / ps"
  9295     "Modified: / 3.12.1999 / 17:13:59 / ps"
  9222 !
  9296 !
  9223 
  9297 
  9224 beep:volumeInPercent
  9298 beep:volumeInPercent
  9225     "output an audible beep"
  9299     "output an audible beep"
       
  9300 
       
  9301     <context: #return>
  9226 %{
  9302 %{
  9227     int volume;
  9303     int volume;
  9228 
  9304 
  9229     if (__isSmallInteger(volumeInPercent) && ISCONNECTED) {
  9305     if (__isSmallInteger(volumeInPercent)
       
  9306      && ISCONNECTED) {
  9230 	/* stupid: X wants -100 .. 100 and calls this percent */
  9307 	/* stupid: X wants -100 .. 100 and calls this percent */
  9231 	volume = __intVal(volumeInPercent) * 2 - 100;
  9308 	volume = __intVal(volumeInPercent) * 2 - 100;
  9232 	if (volume < -100) volume = -100;
  9309 	if (volume < -100) volume = -100;
  9233 	else if (volume > 100) volume = 100;
  9310 	else if (volume > 100) volume = 100;
  9234 
  9311 
  9235 	ENTER_XLIB();
  9312 	ENTER_XLIB();
  9236 	XBell(myDpy, volume);
  9313 	XBell(myDpy, volume);
  9237 	LEAVE_XLIB();
  9314 	LEAVE_XLIB();
  9238 
       
  9239     }
  9315     }
  9240 %}
  9316 %}
  9241 !
  9317 !
  9242 
  9318 
  9243 buffered
  9319 buffered
  9244     "buffer drawing - do not send it immediately to the display.
  9320     "buffer drawing - do not send it immediately to the display.
  9245      This is the default anyway.
  9321      This is the default anyway.
  9246      See #unBuffered for additional info."
  9322      See #unBuffered for additional info."
  9247 
  9323 
  9248 %{  /* NOCONTEXT */
  9324     <context: #return>
  9249 
  9325 %{  
  9250     if (ISCONNECTED) {
  9326     if (ISCONNECTED) {
  9251 
       
  9252 	ENTER_XLIB();
  9327 	ENTER_XLIB();
  9253 	XSynchronize(myDpy, 0);
  9328 	XSynchronize(myDpy, 0);
  9254 	LEAVE_XLIB();
  9329 	LEAVE_XLIB();
  9255 
       
  9256     }
  9330     }
  9257 %}
  9331 %}
  9258     "
  9332     "
  9259      Display buffered
  9333      Display buffered
  9260     "
  9334     "
  9266      are really sent to the display before continuing. For example,
  9340      are really sent to the display before continuing. For example,
  9267      after a cursor-change with a followup long computation.
  9341      after a cursor-change with a followup long computation.
  9268      (otherwise, the cursor change request may still be in the output buffer)
  9342      (otherwise, the cursor change request may still be in the output buffer)
  9269      See also #sync, which even waits until the request has been processed."
  9343      See also #sync, which even waits until the request has been processed."
  9270 
  9344 
  9271 %{  /* NOCONTEXT */
  9345     <context: #return>
  9272 
  9346 %{ 
  9273     if (ISCONNECTED) {
  9347     if (ISCONNECTED) {
  9274 
       
  9275 	ENTER_XLIB();
  9348 	ENTER_XLIB();
  9276 	XFlush(myDpy);
  9349 	XFlush(myDpy);
  9277 	LEAVE_XLIB();
  9350 	LEAVE_XLIB();
  9278 
  9351 
  9279     }
  9352     }
  9282 
  9355 
  9283 flushDpsContext:aDPSContext
  9356 flushDpsContext:aDPSContext
  9284 
  9357 
  9285 %{  /* NOCONTEXT */
  9358 %{  /* NOCONTEXT */
  9286 #ifdef DPS
  9359 #ifdef DPS
  9287     if (__isExternalAddress(aDPSContext)) {
  9360     if (ISCONNECTED
  9288 
  9361      && __isExternalAddress(aDPSContext)) {
  9289 	ENTER_XLIB();
  9362 	ENTER_XLIB();
  9290 	DPSFlushContext(MKDPSCONTEXT(aDPSContext));
  9363 	DPSFlushContext(MKDPSCONTEXT(aDPSContext));
  9291 	LEAVE_XLIB();
  9364 	LEAVE_XLIB();
  9292 
  9365 
  9293 	RETURN ( self );
  9366 	RETURN ( self );
  9294     }
  9367     }
  9295 #endif
  9368 #endif
  9296 %}.
  9369 %}.
  9297     self primitiveFailed
  9370     self primitiveFailedOrClosedConnection
  9298 !
  9371 !
  9299 
  9372 
  9300 refreshKeyboardMapping:eB
  9373 refreshKeyboardMapping:eB
       
  9374     <context: #return>
  9301 %{
  9375 %{
  9302     XMappingEvent *ev;
  9376     XMappingEvent *ev;
  9303 
  9377 
  9304     if (__isByteArray(eB)) {
  9378     if (ISCONNECTED
       
  9379      && __isByteArray(eB)) {
  9305 	ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  9380 	ev = (XMappingEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  9306 	ENTER_XLIB();
  9381 	ENTER_XLIB();
  9307 	XRefreshKeyboardMapping(ev);
  9382 	XRefreshKeyboardMapping(ev);
  9308 	LEAVE_XLIB();
  9383 	LEAVE_XLIB();
  9309     }
  9384 	RETURN ( self );
  9310 %}
  9385     }
       
  9386 %}.
       
  9387     self primitiveFailedOrClosedConnection
  9311 !
  9388 !
  9312 
  9389 
  9313 setInputFocusTo:aWindowId
  9390 setInputFocusTo:aWindowId
  9314     "set the focus to the view as defined by aWindowId.
  9391     "set the focus to the view as defined by aWindowId.
  9315      When released, return the focus to the root window"
  9392      When released, return the focus to the root window"
  9324      input until a new focus is set.
  9401      input until a new focus is set.
  9325      RevertSymbol specifies what should happen if the view becomes invisible;
  9402      RevertSymbol specifies what should happen if the view becomes invisible;
  9326      passing one of #parent, #root or nil specifies that the focus should be
  9403      passing one of #parent, #root or nil specifies that the focus should be
  9327      given to the parent view, the root view or no view."
  9404      given to the parent view, the root view or no view."
  9328 
  9405 
  9329 %{  /* NOCONTEXT */
  9406     <context: #return>
       
  9407 %{  
  9330     int arg;
  9408     int arg;
  9331     Window focusWindow;
  9409     Window focusWindow;
  9332 
  9410 
  9333     if (ISCONNECTED) {
  9411     if (ISCONNECTED) {
  9334 	if (__isExternalAddress(aWindowId)) {
  9412 	if (__isExternalAddress(aWindowId)) {
  9349 	LEAVE_XLIB();
  9427 	LEAVE_XLIB();
  9350 
  9428 
  9351 	RETURN ( self );
  9429 	RETURN ( self );
  9352     }
  9430     }
  9353 %}.
  9431 %}.
  9354     self primitiveFailed
  9432     self primitiveFailedOrClosedConnection
  9355 !
  9433 !
  9356 
  9434 
  9357 sync
  9435 sync
  9358     "send all buffered drawing to the display AND wait until the display
  9436     "send all buffered drawing to the display AND wait until the display
  9359      has finished drawing it.
  9437      has finished drawing it.
  9360      This is almost never needed, except if you are about to read previously
  9438      This is almost never needed, except if you are about to read previously
  9361      drawn pixels back from the display screen, or you want to wait for a beep
  9439      drawn pixels back from the display screen, or you want to wait for a beep
  9362      to be finished. See also #flush."
  9440      to be finished. See also #flush."
  9363 
  9441 
  9364 %{  /* NOCONTEXT */
  9442     <context: #return>
       
  9443 %{  
  9365 
  9444 
  9366     if (ISCONNECTED) {
  9445     if (ISCONNECTED) {
  9367 
  9446 
  9368 	ENTER_XLIB();
  9447 	ENTER_XLIB();
  9369 	XSync(myDpy, 0);
  9448 	XSync(myDpy, 0);
  9381      Be prepared, that this slows down graphics considerably.
  9460      Be prepared, that this slows down graphics considerably.
  9382      However, it allows display errors to be handled immediately and
  9461      However, it allows display errors to be handled immediately and
  9383      may be useful if you get Xdisplay errors and want to find the request
  9462      may be useful if you get Xdisplay errors and want to find the request
  9384      which was responsible for it. See also #buffered."
  9463      which was responsible for it. See also #buffered."
  9385 
  9464 
  9386 %{  /* NOCONTEXT */
  9465     <context: #return>
       
  9466 %{  
  9387 
  9467 
  9388     if (ISCONNECTED) {
  9468     if (ISCONNECTED) {
  9389 
  9469 
  9390 	ENTER_XLIB();
  9470 	ENTER_XLIB();
  9391 	XSynchronize(myDpy, 1);
  9471 	XSynchronize(myDpy, 1);
  9416     "return an integer representing the state of the pointer buttons;
  9496     "return an integer representing the state of the pointer buttons;
  9417      a one-bit in positions 0.. represent a pressed button.
  9497      a one-bit in positions 0.. represent a pressed button.
  9418      See the button1Mask/button2Mask/button3Mask,
  9498      See the button1Mask/button2Mask/button3Mask,
  9419      shiftMask/controlMask and modifierMask methods for the meaning of the bits."
  9499      shiftMask/controlMask and modifierMask methods for the meaning of the bits."
  9420 
  9500 
  9421 %{  /* NOCONTEXT*/
  9501     <context: #return>
       
  9502 %{  
  9422     Window w;
  9503     Window w;
  9423     int screen = __intVal(__INST(screen));
  9504     int screen = __intVal(__INST(screen));
  9424     Window rootRet, childRet;
  9505     Window rootRet, childRet;
  9425     int rootX, rootY, winX, winY;
  9506     int rootX, rootY, winX, winY;
  9426     unsigned int mask;
  9507     unsigned int mask;
  9446 
  9527 
  9447 	    RETURN (__MKSMALLINT(mask));
  9528 	    RETURN (__MKSMALLINT(mask));
  9448 	}
  9529 	}
  9449     }
  9530     }
  9450 %}.
  9531 %}.
  9451     self primitiveFailed
  9532     self primitiveFailedOrClosedConnection.
       
  9533     ^ nil
  9452 
  9534 
  9453     "
  9535     "
  9454      Display buttonStates     
  9536      Display buttonStates     
  9455     "
  9537     "
  9456 
  9538 
  9488     "Modified: 23.3.1996 / 12:41:43 / cg"
  9570     "Modified: 23.3.1996 / 12:41:43 / cg"
  9489 !
  9571 !
  9490 
  9572 
  9491 pointerPosition
  9573 pointerPosition
  9492     "return the current pointer position in root-window coordinates"
  9574     "return the current pointer position in root-window coordinates"
       
  9575 
       
  9576     <context: #return>
  9493 
  9577 
  9494     |xpos ypos|
  9578     |xpos ypos|
  9495 
  9579 
  9496 %{
  9580 %{
  9497     Window w;
  9581     Window w;
  9518 	xpos = __MKSMALLINT(rootX);
  9602 	xpos = __MKSMALLINT(rootX);
  9519 	ypos = __MKSMALLINT(rootY);
  9603 	ypos = __MKSMALLINT(rootY);
  9520 
  9604 
  9521     }
  9605     }
  9522 %}.
  9606 %}.
       
  9607     xpos isNil ifTrue:[
       
  9608 	self primitiveFailedOrClosedConnection.
       
  9609 	^ nil
       
  9610     ].
  9523     ^ xpos @ ypos
  9611     ^ xpos @ ypos
  9524 !
  9612 !
  9525 
  9613 
  9526 rightButtonStateMask
  9614 rightButtonStateMask
  9527     "return an integer for masking out the right button from a
  9615     "return an integer for masking out the right button from a
  9546      given windows origin (which may be the rootWindow).
  9634      given windows origin (which may be the rootWindow).
  9547      Be careful with this - its usually not very ergonimically
  9635      Be careful with this - its usually not very ergonimically
  9548      to change the mousePointer position.
  9636      to change the mousePointer position.
  9549      This interface is provided for special applications (presentation
  9637      This interface is provided for special applications (presentation
  9550      playback) and should not be used in normal applications."
  9638      playback) and should not be used in normal applications."
       
  9639 
       
  9640     <context: #return>
  9551 
  9641 
  9552     |xpos ypos|
  9642     |xpos ypos|
  9553 
  9643 
  9554     xpos := newPosition x.
  9644     xpos := newPosition x.
  9555     ypos := newPosition y.
  9645     ypos := newPosition y.
  9601 !
  9691 !
  9602 
  9692 
  9603 getProperty:propertyID from:aWindowID into:aTwoArgBlock
  9693 getProperty:propertyID from:aWindowID into:aTwoArgBlock
  9604     "get a property, evaluate aTwoArgBlock with typeID and value"
  9694     "get a property, evaluate aTwoArgBlock with typeID and value"
  9605 
  9695 
       
  9696     <context: #return>
       
  9697 
  9606     |val typeID cls|
  9698     |val typeID cls|
  9607 
  9699 
  9608     cls := ByteArray.
  9700     cls := ByteArray.
  9609 %{
  9701 %{
  9610     Window window;
  9702     Window window;
  9632 	    cp = 0;
  9724 	    cp = 0;
  9633 /*
  9725 /*
  9634 	    fprintf(stderr, "getProperty: ");
  9726 	    fprintf(stderr, "getProperty: ");
  9635  */
  9727  */
  9636 	    do {
  9728 	    do {
  9637 		if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False,
  9729 		int retVal;
  9638 				       AnyPropertyType,&actual_type,&actual_format,
  9730 
  9639 				       &nitems,&bytes_after,(unsigned char **)&data)
  9731 		ENTER_XLIB();
  9640 		    != Success) {
  9732 		retVal = XGetWindowProperty(dpy, window, property, nread/4, PROP_SIZE, False,
       
  9733 					    AnyPropertyType, &actual_type, &actual_format,
       
  9734 					    &nitems, &bytes_after, (unsigned char **)&data);
       
  9735 		LEAVE_XLIB();
       
  9736 		if (retVal != Success) {
  9641 			ok = 0;
  9737 			ok = 0;
  9642 			break;
  9738 			break;
  9643 		}
  9739 		}
  9644 		typeID = __MKATOMOBJ(actual_type);
  9740 		typeID = __MKATOMOBJ(actual_type);
  9645 		if (! cp) {
  9741 		if (! cp) {
  9742 !
  9838 !
  9743 
  9839 
  9744 setProperty:propertyID type:typeID value:anObject for:aWindowID
  9840 setProperty:propertyID type:typeID value:anObject for:aWindowID
  9745     "set a property in the XServer"
  9841     "set a property in the XServer"
  9746 
  9842 
       
  9843     <context: #return>
  9747 %{  /* UNLIMITEDSTACK */
  9844 %{  /* UNLIMITEDSTACK */
  9748     if (__isAtomID(propertyID)
  9845     if (__isAtomID(propertyID)
  9749      && __isAtomID(typeID) 
  9846      && __isAtomID(typeID) 
  9750      && ISCONNECTED
  9847      && ISCONNECTED
  9751      && (__isString(anObject) 
  9848      && (__isString(anObject) 
  9752          || __isSmallInteger(anObject) 
  9849 	 || __isSmallInteger(anObject) 
  9753          || __isSymbol(anObject) 
  9850 	 || __isSymbol(anObject) 
  9754          || __isByteArray(anObject)
  9851 	 || __isByteArray(anObject)
  9755          || __isWords(anObject))) {
  9852 	 || __isWords(anObject))) {
  9756 
  9853 
  9757         Display *dpy = myDpy;
  9854 	Display *dpy = myDpy;
  9758         Atom prop, type;
  9855 	Atom prop, type;
  9759         Window window;
  9856 	Window window;
  9760         unsigned INT value;
  9857 	unsigned INT value;
  9761 
  9858 
  9762         prop = _AtomVal(propertyID);
  9859 	prop = _AtomVal(propertyID);
  9763         type = _AtomVal(typeID);
  9860 	type = _AtomVal(typeID);
  9764 
  9861 
  9765         if (__isExternalAddress(aWindowID)) {
  9862 	if (__isExternalAddress(aWindowID)) {
  9766             window = _WindowVal(aWindowID);
  9863 	    window = _WindowVal(aWindowID);
  9767         } else if (__isSmallInteger(aWindowID)) {
  9864 	} else if (__isSmallInteger(aWindowID)) {
  9768             window = (Window)__smallIntegerVal(aWindowID);
  9865 	    window = (Window)__smallIntegerVal(aWindowID);
  9769         } else if (aWindowID == nil) {
  9866 	} else if (aWindowID == nil) {
  9770             window = DefaultRootWindow(dpy);
  9867 	    window = DefaultRootWindow(dpy);
  9771         } else {
  9868 	} else {
  9772             window = (Window)__unsignedLongIntVal(aWindowID);
  9869 	    window = (Window)__unsignedLongIntVal(aWindowID);
  9773         }
  9870 	}
  9774 
  9871 
  9775         if (__isSmallInteger(anObject)) {
  9872 	ENTER_XLIB();
  9776             value = __intVal(anObject);
  9873 	if (__isSmallInteger(anObject)) {
  9777             XChangeProperty(dpy, window, prop, type, 32,
  9874 	    value = __intVal(anObject);
  9778                             PropModeReplace,
  9875 	    XChangeProperty(dpy, window, prop, type, 32,
  9779                             (unsigned char *)(&value), sizeof(unsigned int));
  9876 			    PropModeReplace,
  9780         } else {
  9877 			    (unsigned char *)(&value), sizeof(unsigned int));
  9781             if (__isByteArray(anObject)) {
  9878 	} else {
  9782                 XChangeProperty(dpy, window, prop, type, 8,
  9879 	    if (__isByteArray(anObject)) {
  9783                                 PropModeReplace,
  9880 		XChangeProperty(dpy, window, prop, type, 8,
  9784                                 __ByteArrayInstPtr(anObject)->ba_element,
  9881 				PropModeReplace,
  9785                                 __byteArraySize(anObject));
  9882 				__ByteArrayInstPtr(anObject)->ba_element,
  9786             } else {
  9883 				__byteArraySize(anObject));
  9787                 /* string or symbol or wordArray-like (16bit-string) object */
  9884 	    } else {
  9788                 if (__isWords(__qClass(anObject))) {
  9885 		/* string or symbol or wordArray-like (16bit-string) object */
  9789                     XChangeProperty(dpy, window, prop, type, 16,
  9886 		if (__isWords(__qClass(anObject))) {
  9790                                     PropModeReplace,
  9887 		    XChangeProperty(dpy, window, prop, type, 16,
  9791                                     __stringVal(anObject),
  9888 				    PropModeReplace,
  9792                                     __wordArraySize(anObject));
  9889 				    __stringVal(anObject),
  9793                 } else {
  9890 				    __wordArraySize(anObject));
  9794                     /* must be string or symbol */
  9891 		} else {
  9795                     XChangeProperty(dpy, window, prop, type, 8,
  9892 		    /* must be string or symbol */
  9796                                     PropModeReplace,
  9893 		    XChangeProperty(dpy, window, prop, type, 8,
  9797                                     __stringVal(anObject),
  9894 				    PropModeReplace,
  9798                                     __stringSize(anObject));
  9895 				    __stringVal(anObject),
  9799                 }
  9896 				    __stringSize(anObject));
  9800             }
  9897 		}
  9801         }
  9898 	    }
  9802         DPRINTF(("changeProp win=%x prop=%x type=%x\n", window, prop, type));
  9899 	}
  9803         RETURN (true);
  9900 	LEAVE_XLIB();
       
  9901 
       
  9902 	DPRINTF(("changeProp win=%x prop=%x type=%x\n", window, prop, type));
       
  9903 	RETURN (true);
  9804     }
  9904     }
  9805 %}.
  9905 %}.
  9806     ^ false
  9906     ^ false
  9807 !
  9907 !
  9808 
  9908 
  9852 	    RETURN (nil);
  9952 	    RETURN (nil);
  9853 	}
  9953 	}
  9854 	RETURN ( __MKATOMOBJ(prop) );
  9954 	RETURN ( __MKATOMOBJ(prop) );
  9855     }
  9955     }
  9856 %}.
  9956 %}.
  9857     self primitiveFailed.
  9957     self primitiveFailedOrClosedConnection.
  9858     ^ nil
  9958     ^ nil
  9859 
  9959 
  9860     "
  9960     "
  9861      Display atomIDOf:'VT_SELECTION' create:false
  9961      Display atomIDOf:'VT_SELECTION' create:false
  9862      Display atomIDOf:'CUT_BUFFER0' create:false
  9962      Display atomIDOf:'CUT_BUFFER0' create:false
  9917 
 10017 
  9918 %{  /* NOCONTEXT */ 
 10018 %{  /* NOCONTEXT */ 
  9919     OBJ str;
 10019     OBJ str;
  9920     char *name;
 10020     char *name;
  9921 
 10021 
  9922     if (ISCONNECTED) {
 10022     if (ISCONNECTED
  9923 	if (__isAtomID(anAtomID)) {
 10023      && __isAtomID(anAtomID)) {
  9924 	    name = XGetAtomName(myDpy, _AtomVal(anAtomID));
 10024 	name = XGetAtomName(myDpy, _AtomVal(anAtomID));
  9925 	    if (name == 0) {
 10025 	if (name == 0) {
  9926 		RETURN (nil);
 10026 	    RETURN (nil);
  9927 	    }
 10027 	}
  9928 	    str = __MKSTRING(name);
 10028 	str = __MKSTRING(name);
  9929 	    XFree(name);
 10029 	XFree(name);
  9930 	    RETURN ( str );
 10030 	RETURN ( str );
  9931 	}
 10031     }
  9932     }
 10032 %}.
  9933 %}.
 10033     self primitiveFailedOrClosedConnection.
  9934     self primitiveFailed.
       
  9935     ^ nil
 10034     ^ nil
  9936 
 10035 
  9937     "
 10036     "
  9938      Display atomName:1 
 10037      Display atomName:1 
  9939      Display atomName:130  '_DEC_DEVICE_FONTNAMES'
 10038      Display atomName:130  '_DEC_DEVICE_FONTNAMES'
  9975 				  (char *) __stringVal(name));
 10074 				  (char *) __stringVal(name));
  9976 
 10075 
  9977 	RETURN (rslt ? __MKSTRING(rslt) : nil );
 10076 	RETURN (rslt ? __MKSTRING(rslt) : nil );
  9978     }
 10077     }
  9979 %}.
 10078 %}.
  9980     self primitiveFailed.
 10079     self primitiveFailedOrClosedConnection.
  9981     ^ nil
 10080     ^ nil.
  9982 
 10081 
  9983     "if your ~/.Xdefaults contains an entry such as:
 10082     "if your ~/.Xdefaults contains an entry such as:
  9984 	OpenWindows.Beep:       notices
 10083 	OpenWindows.Beep:       notices
  9985      the following returns 'notices'.
 10084      the following returns 'notices'.
  9986 
 10085 
 10039     ].
 10138     ].
 10040     "
 10139     "
 10041      some error occured - either args are not smallintegers, imageBits is not a ByteArray
 10140      some error occured - either args are not smallintegers, imageBits is not a ByteArray
 10042      or is too small to hold the bits
 10141      or is too small to hold the bits
 10043     "
 10142     "
 10044     ^ self primitiveFailed
 10143     self primitiveFailedOrClosedConnection.
       
 10144     ^ nil
 10045 !
 10145 !
 10046 
 10146 
 10047 getPixelX:x y:y from:aDrawableId with:dummyGCId
 10147 getPixelX:x y:y from:aDrawableId with:dummyGCId
 10048     "return the pixel value at x/y; coordinates start at 0/0 for the upper left.
 10148     "return the pixel value at x/y; coordinates start at 0/0 for the upper left.
 10049      Nil is returned for invalid coordinates or if any other problem arises."
 10149      Nil is returned for invalid coordinates or if any other problem arises."
 10050 
 10150 
 10051 %{  /* UNLIMITEDSTACK NOCONTEXT */
 10151     <context: #return>
       
 10152 %{  /* UNLIMITEDSTACK */
 10052 
 10153 
 10053     Window win;
 10154     Window win;
 10054     XImage *img;
 10155     XImage *img;
 10055     int ret;
 10156     int ret;
 10056     int xpos, ypos;
 10157     int xpos, ypos;
 10078 
 10179 
 10079 primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info
 10180 primGetBitsFrom:aDrawableId x:srcx y:srcy width:w height:h into:imageBits infoInto:info
 10080     "since XGetImage may allocate huge amount of stack space 
 10181     "since XGetImage may allocate huge amount of stack space 
 10081      (some implementations use alloca), this must run with unlimited stack."
 10182      (some implementations use alloca), this must run with unlimited stack."
 10082 
 10183 
       
 10184     <context: #return>
 10083 %{  /* UNLIMITEDSTACK */
 10185 %{  /* UNLIMITEDSTACK */
 10084 
 10186 
 10085     Window win;
 10187     Window win;
 10086     XImage *image = (XImage *)0;
 10188     XImage *image = (XImage *)0;
 10087     int pad, bytes_per_line, numBytes;
 10189     int pad, bytes_per_line, numBytes;
 10196 
 10298 
 10197 %{  /* NOCONTEXT */
 10299 %{  /* NOCONTEXT */
 10198     Atom selection;
 10300     Atom selection;
 10199     Window window;
 10301     Window window;
 10200 
 10302 
 10201     if (__isAtomID(selectionAtomID) && ISCONNECTED) {
 10303     if (__isAtomID(selectionAtomID)
       
 10304      && ISCONNECTED) {
 10202 	Display *dpy = myDpy;
 10305 	Display *dpy = myDpy;
 10203 
 10306 
 10204 	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
 10307 	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
 10205 	RETURN ((window == None) ? nil : __MKEXTERNALADDRESS(window));
 10308 	RETURN ((window == None) ? nil : __MKEXTERNALADDRESS(window));
 10206     }
 10309     }
 10207 %}.
 10310 %}.
 10208      self primitiveFailed.
 10311     self primitiveFailedOrClosedConnection.
 10209     ^ nil
 10312     ^ nil
 10210 !
 10313 !
 10211 
 10314 
 10212 getTextSelectionFor:drawableId
 10315 getTextSelectionFor:drawableId
 10213     "get the text selection -  either immediate, or asynchronous.
 10316     "get the text selection -  either immediate, or asynchronous.
 10264 	XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), 
 10367 	XConvertSelection(dpy, _AtomVal(selectionID), _AtomVal(typeID), 
 10265 			       _AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime);
 10368 			       _AtomVal(propertyID), _WindowVal(aWindowId), CurrentTime);
 10266 	RETURN (true);
 10369 	RETURN (true);
 10267     }
 10370     }
 10268 %}.
 10371 %}.
 10269     self primitiveFailed.
 10372     self primitiveFailedOrClosedConnection.
 10270     ^ false
 10373     ^ false
 10271 
 10374 
 10272     "
 10375     "
 10273      Display requestSelection:(Display atomIDOf:'PRIMARY')
 10376      Display requestSelection:(Display atomIDOf:'PRIMARY')
 10274 		     property:(Display atomIDOf:'VT_SELECTION')
 10377 		     property:(Display atomIDOf:'VT_SELECTION')
 10307 !
 10410 !
 10308 
 10411 
 10309 sendSelectionNotifySelection:selectionID property:propertyID target:targetID time:t from:windowID to:requestorID
 10412 sendSelectionNotifySelection:selectionID property:propertyID target:targetID time:t from:windowID to:requestorID
 10310     "send a selectionNotify back from a SelectionRequest"
 10413     "send a selectionNotify back from a SelectionRequest"
 10311 
 10414 
 10312 %{  /* NOCONTEXT */
 10415     <context: #return>
       
 10416 %{  
 10313     if (__isAtomID(propertyID)
 10417     if (__isAtomID(propertyID)
 10314      && ISCONNECTED
 10418      && ISCONNECTED
 10315      && __isAtomID(targetID)
 10419      && __isAtomID(targetID)
 10316      && __isAtomID(selectionID)) {
 10420      && __isAtomID(selectionID)) {
 10317         Display *dpy = myDpy;
 10421 	Display *dpy = myDpy;
 10318         XEvent ev;
 10422 	XEvent ev;
 10319         Window requestor, originator;
 10423 	Window requestor, originator;
 10320         Atom property = _AtomVal(propertyID);
 10424 	Atom property = _AtomVal(propertyID);
 10321         Atom target = _AtomVal(targetID);
 10425 	Atom target = _AtomVal(targetID);
 10322         Atom selection = _AtomVal(selectionID);
 10426 	Atom selection = _AtomVal(selectionID);
 10323         Status result;
 10427 	Status result;
 10324 
 10428 
 10325         if (__isExternalAddress(requestorID)) {
 10429 	if (__isExternalAddress(requestorID)) {
 10326             requestor = _WindowVal(requestorID);
 10430 	    requestor = _WindowVal(requestorID);
 10327         } else if (__isSmallInteger(requestorID)) {
 10431 	} else if (__isSmallInteger(requestorID)) {
 10328             requestor = (Window)__smallIntegerVal(requestorID);
 10432 	    requestor = (Window)__smallIntegerVal(requestorID);
 10329         } else if (requestorID == nil) {
 10433 	} else if (requestorID == nil) {
 10330             requestor = DefaultRootWindow(dpy);
 10434 	    requestor = DefaultRootWindow(dpy);
 10331         } else {
 10435 	} else {
 10332             requestor = (Window)__unsignedLongIntVal(requestorID);
 10436 	    requestor = (Window)__unsignedLongIntVal(requestorID);
 10333         }
 10437 	}
 10334         if (__isExternalAddress(windowID)) {
 10438 	if (__isExternalAddress(windowID)) {
 10335             originator = _WindowVal(windowID);
 10439 	    originator = _WindowVal(windowID);
 10336         } else if (__isSmallInteger(windowID)) {
 10440 	} else if (__isSmallInteger(windowID)) {
 10337             originator = (Window)__smallIntegerVal(windowID);
 10441 	    originator = (Window)__smallIntegerVal(windowID);
 10338         } else if (windowID == nil) {
 10442 	} else if (windowID == nil) {
 10339             originator = DefaultRootWindow(dpy);
 10443 	    originator = DefaultRootWindow(dpy);
 10340         } else {
 10444 	} else {
 10341             originator = (Window)__unsignedLongIntVal(windowID);
 10445 	    originator = (Window)__unsignedLongIntVal(windowID);
 10342         }
 10446 	}
 10343 
 10447 
 10344         ev.xselection.type = SelectionNotify;
 10448 	ev.xselection.type = SelectionNotify;
 10345         ev.xselection.display = dpy;
 10449 	ev.xselection.display = dpy;
 10346         ev.xselection.selection = selection;
 10450 	ev.xselection.selection = selection;
 10347         ev.xselection.target = target;
 10451 	ev.xselection.target = target;
 10348         ev.xselection.requestor = originator;
 10452 	ev.xselection.requestor = originator;
 10349 
 10453 
 10350         if (__isExternalAddress(t)) {
 10454 	if (__isExternalAddress(t)) {
 10351             ev.xselection.time = (INT)(__externalAddressVal(t));
 10455 	    ev.xselection.time = (INT)(__externalAddressVal(t));
 10352         } else if (__isSmallInteger(t)) {
 10456 	} else if (__isSmallInteger(t)) {
 10353             ev.xselection.time = __smallIntegerVal(t);
 10457 	    ev.xselection.time = __smallIntegerVal(t);
 10354         } else if (t == nil) {
 10458 	} else if (t == nil) {
 10355             ev.xselection.time = CurrentTime;
 10459 	    ev.xselection.time = CurrentTime;
 10356         } else {
 10460 	} else {
 10357             ev.xselection.time = (INT)__unsignedLongIntVal(t);
 10461 	    ev.xselection.time = (INT)__unsignedLongIntVal(t);
 10358         }
 10462 	}
 10359 #if 0
 10463 #if 0
 10360         printf("ev.xselection.selection: %x\n", ev.xselection.selection);
 10464 	printf("ev.xselection.selection: %x\n", ev.xselection.selection);
 10361         printf("ev.xselection.target: %x\n", ev.xselection.target);
 10465 	printf("ev.xselection.target: %x\n", ev.xselection.target);
 10362         printf("ev.xselection.requestor: %x\n", ev.xselection.requestor);
 10466 	printf("ev.xselection.requestor: %x\n", ev.xselection.requestor);
 10363         printf("ev.xselection.time: %x\n", ev.xselection.time);
 10467 	printf("ev.xselection.time: %x\n", ev.xselection.time);
 10364         printf("requestor: %x\n", requestor);
 10468 	printf("requestor: %x\n", requestor);
 10365 #endif
 10469 #endif
 10366         if (property == None)
 10470 	if (property == None)
 10367             ev.xselection.property = target;
 10471 	    ev.xselection.property = target;
 10368         else
 10472 	else
 10369             ev.xselection.property = property;
 10473 	    ev.xselection.property = property;
 10370 
 10474 
 10371         DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n",
 10475 	DPRINTF(("sending SelectionNotify sel=%x prop=%x target=%x requestor=%x to %x\n",
 10372                 ev.xselection.selection,
 10476 		ev.xselection.selection,
 10373                 ev.xselection.property,
 10477 		ev.xselection.property,
 10374                 ev.xselection.target,
 10478 		ev.xselection.target,
 10375                 ev.xselection.requestor,
 10479 		ev.xselection.requestor,
 10376                 requestor));
 10480 		requestor));
 10377 
 10481 
 10378         ENTER_XLIB();
 10482 	ENTER_XLIB();
 10379         result = XSendEvent(dpy, requestor, False, 0 , &ev);
 10483 	result = XSendEvent(dpy, requestor, False, 0 , &ev);
 10380         LEAVE_XLIB();
 10484 	LEAVE_XLIB();
 10381 
 10485 
 10382         if ((result == BadValue) || (result == BadWindow)) {
 10486 	if ((result == BadValue) || (result == BadWindow)) {
 10383             DPRINTF(("bad status\n"));
 10487 	    DPRINTF(("bad status\n"));
 10384             RETURN (false);
 10488 	    RETURN (false);
 10385         }
 10489 	}
 10386         ENTER_XLIB();
 10490 	ENTER_XLIB();
 10387         XFlush(dpy);
 10491 	XFlush(dpy);
 10388         LEAVE_XLIB();
 10492 	LEAVE_XLIB();
 10389         RETURN (true)
 10493 	RETURN (true)
 10390     }
 10494     }
 10391 %}.
 10495 %}.
 10392     self primitiveFailed.
 10496     self primitiveFailedOrClosedConnection.
 10393     ^ false
 10497     ^ false
 10394 
 10498 
 10395     "Modified: / 17.6.1998 / 20:23:20 / cg"
 10499     "Modified: / 17.6.1998 / 20:23:20 / cg"
 10396 !
 10500 !
 10397 
 10501 
 10407 !
 10511 !
 10408 
 10512 
 10409 setSelectionOwner:aWindowId of:selectionID
 10513 setSelectionOwner:aWindowId of:selectionID
 10410     "set the owner of a selection; return false if failed"
 10514     "set the owner of a selection; return false if failed"
 10411 
 10515 
 10412 %{  /* NOCONTEXT */
 10516     <context: #return>
       
 10517 %{ 
 10413     Window win;
 10518     Window win;
 10414 
 10519 
 10415     if (__isExternalAddress(aWindowId)
 10520     if (__isExternalAddress(aWindowId)
 10416      && __isAtomID(selectionID)
 10521      && __isAtomID(selectionID)
 10417      && ISCONNECTED) {
 10522      && ISCONNECTED) {
 10418 	Display *dpy = myDpy;
 10523 	Display *dpy = myDpy;
       
 10524 	Window owner;
 10419 
 10525 
 10420 	win = _WindowVal(aWindowId);
 10526 	win = _WindowVal(aWindowId);
       
 10527 	DPRINTF(("setOwner prop=%x win=%x\n", _AtomVal(selectionID), win));
       
 10528 	ENTER_XLIB();
 10421 	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
 10529 	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
 10422 	DPRINTF(("setOwner prop=%x win=%x\n", _AtomVal(selectionID), win));
 10530 	owner = XGetSelectionOwner(dpy, _AtomVal(selectionID));
 10423 	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) {
 10531 	LEAVE_XLIB();
       
 10532 	if (owner != win) {
 10424 	    RETURN (false);
 10533 	    RETURN (false);
 10425 	}
 10534 	}
 10426 	RETURN (true);
 10535 	RETURN (true);
 10427     }
 10536     }
 10428 %}.
 10537 %}.
 10429     self primitiveFailed.
 10538     self primitiveFailedOrClosedConnection.
 10430     ^ nil
 10539     ^ false
 10431 !
 10540 !
 10432 
 10541 
 10433 setTextSelection:aString owner:aWindowId
 10542 setTextSelection:aString owner:aWindowId
 10434     "set the text selection, and make aWindowId be the owner.
 10543     "set the text selection, and make aWindowId be the owner.
 10435      This can be used by any other X application."
 10544      This can be used by any other X application."
 10445 !XWorkstation methodsFor:'window stuff'!
 10554 !XWorkstation methodsFor:'window stuff'!
 10446 
 10555 
 10447 clearRectangleX:x y:y width:width height:height in:aWindowId
 10556 clearRectangleX:x y:y width:width height:height in:aWindowId
 10448     "clear a rectangular area to viewbackground"
 10557     "clear a rectangular area to viewbackground"
 10449 
 10558 
 10450 %{  /* NOCONTEXT */
 10559     <context: #return>
       
 10560 %{  
 10451 
 10561 
 10452     int w, h;
 10562     int w, h;
 10453 
 10563 
 10454     if (ISCONNECTED) {
 10564     if (ISCONNECTED) {
 10455 	if (__isExternalAddress(aWindowId)
 10565 	if (__isExternalAddress(aWindowId)
 10467 	    }
 10577 	    }
 10468 	    RETURN ( self );
 10578 	    RETURN ( self );
 10469 	}
 10579 	}
 10470     }
 10580     }
 10471 %}.
 10581 %}.
 10472     self primitiveFailed
 10582     self primitiveFailedOrClosedConnection.
 10473 !
 10583 !
 10474 
 10584 
 10475 clearWindow:aWindowId
 10585 clearWindow:aWindowId
 10476     "clear a window to viewbackground"
 10586     "clear a window to viewbackground"
 10477 
 10587 
 10478 %{  /* NOCONTEXT */
 10588     <context: #return>
       
 10589 %{ 
 10479 
 10590 
 10480     if (ISCONNECTED) {
 10591     if (ISCONNECTED) {
 10481 	if (__isExternalAddress(aWindowId)) {
 10592 	if (__isExternalAddress(aWindowId)) {
 10482 	    ENTER_XLIB();
 10593 	    ENTER_XLIB();
 10483 	    XClearWindow(myDpy, _WindowVal(aWindowId));
 10594 	    XClearWindow(myDpy, _WindowVal(aWindowId));
 10484 	    LEAVE_XLIB();
 10595 	    LEAVE_XLIB();
 10485 	    RETURN ( self );
 10596 	    RETURN ( self );
 10486 	}
 10597 	}
 10487     }
 10598     }
 10488 %}.
 10599 %}.
 10489     self primitiveFailed
 10600     self primitiveFailedOrClosedConnection
 10490 !
 10601 !
 10491 
 10602 
 10492 configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
 10603 configureWindow:aWindowId sibling:siblingId stackMode:modeSymbol
 10493     "configure stacking operation of aWindowId w.r.t siblingId"
 10604     "configure stacking operation of aWindowId w.r.t siblingId"
 10494 
 10605 
 10495 %{  /* NOCONTEXT */
 10606     <context: #return>
       
 10607 %{  
 10496 
 10608 
 10497     XWindowChanges chg;
 10609     XWindowChanges chg;
 10498     int mask = CWSibling | CWStackMode;
 10610     int mask = CWSibling | CWStackMode;
 10499 
 10611 
 10500     if (ISCONNECTED) {
 10612     if (ISCONNECTED) {
 10522 	    RETURN ( self );
 10634 	    RETURN ( self );
 10523 	}
 10635 	}
 10524     }
 10636     }
 10525 bad: ;
 10637 bad: ;
 10526 %}.
 10638 %}.
 10527     self primitiveFailed
 10639     self primitiveFailedOrClosedConnection
 10528 !
 10640 !
 10529 
 10641 
 10530 isValidWindowId:aWindowId
 10642 isValidWindowId:aWindowId
 10531     "return true, if the given window ID is (still) valid.
 10643     "return true, if the given window ID is (still) valid.
 10532      Especially useful, if the passed windowID is 
 10644      Especially useful, if the passed windowID is 
 10554 	    RETURN (true);
 10666 	    RETURN (true);
 10555 	}
 10667 	}
 10556 	RETURN (false);
 10668 	RETURN (false);
 10557     }
 10669     }
 10558 %}.
 10670 %}.
 10559     self primitiveFailed
 10671     self primitiveFailedOrClosedConnection.
       
 10672     ^ false
 10560 
 10673 
 10561     "
 10674     "
 10562      |v aWindowId ok|
 10675      |v aWindowId ok|
 10563 
 10676 
 10564      v := StandardSystemView new.
 10677      v := StandardSystemView new.
 10575 !
 10688 !
 10576 
 10689 
 10577 lowerWindow:aWindowId
 10690 lowerWindow:aWindowId
 10578     "bring a window to back"
 10691     "bring a window to back"
 10579 
 10692 
 10580 %{  /* NOCONTEXT */
 10693     <context: #return>
       
 10694 %{  
 10581 
 10695 
 10582     if (ISCONNECTED
 10696     if (ISCONNECTED
 10583      && __isExternalAddress(aWindowId)) {
 10697      && __isExternalAddress(aWindowId)) {
 10584 	ENTER_XLIB();
 10698 	ENTER_XLIB();
 10585 	XLowerWindow(myDpy, _WindowVal(aWindowId));
 10699 	XLowerWindow(myDpy, _WindowVal(aWindowId));
 10586 	LEAVE_XLIB();
 10700 	LEAVE_XLIB();
 10587 	RETURN ( self );
 10701 	RETURN ( self );
 10588     }
 10702     }
 10589 %}.
 10703 %}.
 10590     self primitiveFailed
 10704     self primitiveFailedOrClosedConnection
 10591 !
 10705 !
 10592 
 10706 
 10593 mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos 
 10707 mapView:aView id:aWindowId iconified:aBoolean atX:xPos y:yPos 
 10594 	      width:w height:h minExtent:minExt maxExtent:maxExt
 10708 	      width:w height:h minExtent:minExt maxExtent:maxExt
       
 10709 
       
 10710     <context: #return>
 10595 
 10711 
 10596     "make a window visible - either as icon or as a real view 
 10712     "make a window visible - either as icon or as a real view 
 10597      in addition, allow change of extend, position, minExtend and maxExtent.
 10713      in addition, allow change of extend, position, minExtend and maxExtent.
 10598      Needed for restart, to allow recreating a view as iconified,
 10714      Needed for restart, to allow recreating a view as iconified,
 10599      and to collaps/expand windows."
 10715      and to collaps/expand windows."
 10709 	XMapWindow(dpy, win);
 10825 	XMapWindow(dpy, win);
 10710 	LEAVE_XLIB();
 10826 	LEAVE_XLIB();
 10711 	RETURN ( self );
 10827 	RETURN ( self );
 10712     }
 10828     }
 10713 %}.
 10829 %}.
 10714     self primitiveFailed
 10830     self primitiveFailedOrClosedConnection
 10715 !
 10831 !
 10716 
 10832 
 10717 mapWindow:aWindowId
 10833 mapWindow:aWindowId
 10718     "make a window visible"
 10834     "make a window visible"
 10719 
 10835 
 10720 %{  /* NOCONTEXT */
 10836     <context: #return>
       
 10837 %{  
 10721 
 10838 
 10722     if (ISCONNECTED
 10839     if (ISCONNECTED
 10723      && __isExternalAddress(aWindowId)) {
 10840      && __isExternalAddress(aWindowId)) {
 10724 	ENTER_XLIB();
 10841 	ENTER_XLIB();
 10725 	XMapWindow(myDpy, _WindowVal(aWindowId));
 10842 	XMapWindow(myDpy, _WindowVal(aWindowId));
 10726 	LEAVE_XLIB();
 10843 	LEAVE_XLIB();
 10727 	RETURN ( self );
 10844 	RETURN ( self );
 10728     }
 10845     }
 10729 %}.
 10846 %}.
 10730     self primitiveFailed
 10847     self primitiveFailedOrClosedConnection
 10731 !
 10848 !
 10732 
 10849 
 10733 moveResizeWindow:aWindowId x:x y:y width:w height:h
 10850 moveResizeWindow:aWindowId x:x y:y width:w height:h
 10734     "move and resize a window"
 10851     "move and resize a window"
 10735 
 10852 
 10736 %{  /* NOCONTEXT */
 10853     <context: #return>
       
 10854 %{  
 10737 
 10855 
 10738     int newWidth, newHeight;
 10856     int newWidth, newHeight;
 10739 
 10857 
 10740     if (ISCONNECTED
 10858     if (ISCONNECTED
 10741      && __isExternalAddress(aWindowId)
 10859      && __isExternalAddress(aWindowId)
 10751 			      newWidth, newHeight);
 10869 			      newWidth, newHeight);
 10752 	LEAVE_XLIB();
 10870 	LEAVE_XLIB();
 10753 	RETURN ( self );
 10871 	RETURN ( self );
 10754     }
 10872     }
 10755 %}.
 10873 %}.
 10756     self primitiveFailed
 10874     self primitiveFailedOrClosedConnection
 10757 !
 10875 !
 10758 
 10876 
 10759 moveWindow:aWindowId x:x y:y
 10877 moveWindow:aWindowId x:x y:y
 10760     "move a window"
 10878     "move a window"
 10761 
 10879 
 10762 %{  /* NOCONTEXT */
 10880     <context: #return>
       
 10881 %{ 
 10763 
 10882 
 10764     if (ISCONNECTED
 10883     if (ISCONNECTED
 10765      && __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
 10884      && __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
 10766 	ENTER_XLIB();
 10885 	ENTER_XLIB();
 10767 	XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y));
 10886 	XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y));
 10768 	LEAVE_XLIB();
 10887 	LEAVE_XLIB();
 10769 	RETURN ( self );
 10888 	RETURN ( self );
 10770     }
 10889     }
 10771 %}.
 10890 %}.
 10772     self primitiveFailed
 10891     self primitiveFailedOrClosedConnection
 10773 !
 10892 !
 10774 
 10893 
 10775 raiseWindow:aWindowId
 10894 raiseWindow:aWindowId
 10776     "bring a window to front"
 10895     "bring a window to front"
 10777 
 10896 
 10778 %{  /* NOCONTEXT */
 10897     <context: #return>
       
 10898 %{ 
 10779 
 10899 
 10780     if (ISCONNECTED
 10900     if (ISCONNECTED
 10781      && __isExternalAddress(aWindowId)) {
 10901      && __isExternalAddress(aWindowId)) {
 10782 	ENTER_XLIB();
 10902 	ENTER_XLIB();
 10783 	XRaiseWindow(myDpy, _WindowVal(aWindowId));
 10903 	XRaiseWindow(myDpy, _WindowVal(aWindowId));
 10784 	LEAVE_XLIB();
 10904 	LEAVE_XLIB();
 10785 	RETURN ( self );
 10905 	RETURN ( self );
 10786     }
 10906     }
 10787 %}.
 10907 %}.
 10788     self primitiveFailed
 10908     self primitiveFailedOrClosedConnection
 10789 !
 10909 !
 10790 
 10910 
 10791 reparentWindow:windowId to:newParentWindowId
 10911 reparentWindow:windowId to:newParentWindowId
 10792     "change a windows parent (an optional interface)"
 10912     "change a windows parent (an optional interface)"
       
 10913 
       
 10914     <context: #return>
 10793 %{
 10915 %{
 10794     if (ISCONNECTED
 10916     if (ISCONNECTED
 10795      && __isExternalAddress(windowId)
 10917      && __isExternalAddress(windowId)
 10796      && __isExternalAddress(newParentWindowId)) {
 10918      && __isExternalAddress(newParentWindowId)) {
 10797 	Display *dpy = myDpy;
 10919 	Display *dpy = myDpy;
 10820 #endif
 10942 #endif
 10821 	LEAVE_XLIB();
 10943 	LEAVE_XLIB();
 10822 	RETURN ( true );
 10944 	RETURN ( true );
 10823     }
 10945     }
 10824 %}.
 10946 %}.
 10825     self primitiveFailed
 10947     self primitiveFailedOrClosedConnection
 10826 !
 10948 !
 10827 
 10949 
 10828 resizeWindow:aWindowId width:w height:h
 10950 resizeWindow:aWindowId width:w height:h
 10829     "resize a window"
 10951     "resize a window"
 10830 
 10952 
 10831 %{  /* NOCONTEXT */
 10953     <context: #return>
       
 10954 %{  
 10832 
 10955 
 10833     int newWidth, newHeight;
 10956     int newWidth, newHeight;
 10834 
 10957 
 10835     if (ISCONNECTED
 10958     if (ISCONNECTED
 10836      && __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
 10959      && __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
 10842 	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
 10965 	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
 10843 	LEAVE_XLIB();
 10966 	LEAVE_XLIB();
 10844 	RETURN ( self );
 10967 	RETURN ( self );
 10845     }
 10968     }
 10846 %}.
 10969 %}.
 10847     self primitiveFailed
 10970     self primitiveFailedOrClosedConnection
 10848 !
 10971 !
 10849 
 10972 
 10850 setBackingStore:how in:aWindowId
 10973 setBackingStore:how in:aWindowId
 10851     "turn on/off backing-store for a window"
 10974     "turn on/off backing-store for a window"
 10852 
 10975 
 10853 %{  /* NOCONTEXT */
 10976     <context: #return>
       
 10977 %{  
 10854 
 10978 
 10855     XSetWindowAttributes wa;
 10979     XSetWindowAttributes wa;
 10856 
 10980 
 10857     if (ISCONNECTED
 10981     if (ISCONNECTED
 10858      && __isExternalAddress(aWindowId)) {
 10982      && __isExternalAddress(aWindowId)) {
 10868 
 10992 
 10869 	}
 10993 	}
 10870 	RETURN ( self );
 10994 	RETURN ( self );
 10871     }
 10995     }
 10872 %}.
 10996 %}.
 10873     self primitiveFailed
 10997     self primitiveFailedOrClosedConnection
 10874 !
 10998 !
 10875 
 10999 
 10876 setBitGravity:how in:aWindowId
 11000 setBitGravity:how in:aWindowId
 10877     "set bit gravity for a window"
 11001     "set bit gravity for a window"
 10878 
 11002 
 10879 %{  /* NOCONTEXT */
 11003     <context: #return>
       
 11004 %{  
 10880 
 11005 
 10881     XSetWindowAttributes wa;
 11006     XSetWindowAttributes wa;
 10882 
 11007 
 10883     if (ISCONNECTED
 11008     if (ISCONNECTED
 10884      && __isExternalAddress(aWindowId)) {
 11009      && __isExternalAddress(aWindowId)) {
 10910 	LEAVE_XLIB();
 11035 	LEAVE_XLIB();
 10911 
 11036 
 10912 	RETURN ( self );
 11037 	RETURN ( self );
 10913     }
 11038     }
 10914 %}.
 11039 %}.
 10915     self primitiveFailed
 11040     self primitiveFailedOrClosedConnection
 10916 !
 11041 !
 10917 
 11042 
 10918 setCursor:aCursorId in:aWindowId
 11043 setCursor:aCursorId in:aWindowId
 10919     "define a windows cursor"
 11044     "define a windows cursor"
 10920 
 11045 
 10921 %{  /* NOCONTEXT */
 11046     <context: #return>
       
 11047 %{  
 10922 
 11048 
 10923     if (ISCONNECTED
 11049     if (ISCONNECTED
 10924      && __isExternalAddress(aWindowId)
 11050      && __isExternalAddress(aWindowId)
 10925      && __isExternalAddress(aCursorId)) {
 11051      && __isExternalAddress(aCursorId)) {
 10926         Display *dpy = myDpy;
 11052 	Display *dpy = myDpy;
 10927         Window w = _WindowVal(aWindowId);
 11053 	Window w = _WindowVal(aWindowId);
 10928         Cursor c = _CursorVal(aCursorId);
 11054 	Cursor c = _CursorVal(aCursorId);
 10929 
 11055 
 10930         if (w && c && dpy) {
 11056 	if (w && c) {
 10931             ENTER_XLIB();
 11057 	    ENTER_XLIB();
 10932             XDefineCursor(dpy, w, c);
 11058 	    XDefineCursor(dpy, w, c);
 10933             LEAVE_XLIB();
 11059 	    LEAVE_XLIB();
 10934         }
 11060 	}
 10935         RETURN ( self );
 11061 	RETURN ( self );
 10936     }
 11062     }
 10937 %}.
 11063 %}.
 10938     self primitiveFailed
 11064     self primitiveFailedOrClosedConnection
 10939 !
 11065 !
 10940 
 11066 
 10941 setIconName:aString in:aWindowId
 11067 setIconName:aString in:aWindowId
 10942     "define a windows iconname"
 11068     "define a windows iconname"
 10943 
 11069 
 10944 %{  /* NOCONTEXT */
 11070     <context: #return>
       
 11071 %{  
 10945 
 11072 
 10946     if (ISCONNECTED
 11073     if (ISCONNECTED
 10947      && __isNonNilObject(aString)
 11074      && __isNonNilObject(aString)
 10948      && (__qIsString(aString) || __qIsSymbol(aString))
 11075      && (__qIsString(aString) || __qIsSymbol(aString))
 10949      && __isExternalAddress(aWindowId)) {
 11076      && __isExternalAddress(aWindowId)) {
 10951 	XSetIconName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString));
 11078 	XSetIconName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString));
 10952 	LEAVE_XLIB();
 11079 	LEAVE_XLIB();
 10953 	RETURN ( self );
 11080 	RETURN ( self );
 10954     }
 11081     }
 10955 %}.
 11082 %}.
 10956     self primitiveFailed
 11083     self primitiveFailedOrClosedConnection
 10957 !
 11084 !
 10958 
 11085 
 10959 setSaveUnder:yesOrNo in:aWindowId
 11086 setSaveUnder:yesOrNo in:aWindowId
 10960     "turn on/off save-under for a window"
 11087     "turn on/off save-under for a window"
 10961 
 11088 
 10962 %{  /* NOCONTEXT */
 11089     <context: #return>
       
 11090 %{  
 10963 
 11091 
 10964     XSetWindowAttributes wa;
 11092     XSetWindowAttributes wa;
 10965 
 11093 
 10966     if (ISCONNECTED
 11094     if (ISCONNECTED
 10967      && __isExternalAddress(aWindowId)) {
 11095      && __isExternalAddress(aWindowId)) {
 10972 	    LEAVE_XLIB();
 11100 	    LEAVE_XLIB();
 10973 	}
 11101 	}
 10974 	RETURN ( self );
 11102 	RETURN ( self );
 10975     }
 11103     }
 10976 %}.
 11104 %}.
 10977     self primitiveFailed
 11105     self primitiveFailedOrClosedConnection
 10978 !
 11106 !
 10979 
 11107 
 10980 setTransient:aWindowId for:aMainWindowId
 11108 setTransient:aWindowId for:aMainWindowId
 10981     "set aWindowId to be a transient of aMainWindow"
 11109     "set aWindowId to be a transient of aMainWindow"
 10982 
 11110 
 10983 %{  /* NOCONTEXT */
 11111     <context: #return>
       
 11112 %{  
 10984 
 11113 
 10985     if (ISCONNECTED
 11114     if (ISCONNECTED
 10986      && __isExternalAddress(aWindowId)) {
 11115      && __isExternalAddress(aWindowId)) {
 10987 	Window w;
 11116 	Window w;
 10988 
 11117 
 11000 	LEAVE_XLIB();
 11129 	LEAVE_XLIB();
 11001 	RETURN ( self );
 11130 	RETURN ( self );
 11002     }
 11131     }
 11003  getOutOfHere: ;
 11132  getOutOfHere: ;
 11004 %}.
 11133 %}.
 11005     self primitiveFailed
 11134     self primitiveFailedOrClosedConnection
 11006 !
 11135 !
 11007 
 11136 
 11008 setWindowBackground:aColorIndex in:aWindowId
 11137 setWindowBackground:aColorIndex in:aWindowId
 11009     "set the windows background color. This is the color with which
 11138     "set the windows background color. This is the color with which
 11010      the view is filled whenever exposed. Do not confuse this with
 11139      the view is filled whenever exposed. Do not confuse this with
 11011      the background drawing color, which is used with opaque drawing."
 11140      the background drawing color, which is used with opaque drawing."
 11012 
 11141 
 11013 %{  /* NOCONTEXT */
 11142     <context: #return>
       
 11143 %{  
 11014 
 11144 
 11015     if (ISCONNECTED
 11145     if (ISCONNECTED
 11016      && __isExternalAddress(aWindowId)
 11146      && __isExternalAddress(aWindowId)
 11017      && __isSmallInteger(aColorIndex)) {
 11147      && __isSmallInteger(aColorIndex)) {
 11018 	ENTER_XLIB();
 11148 	ENTER_XLIB();
 11019 	XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
 11149 	XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
 11020 	LEAVE_XLIB();
 11150 	LEAVE_XLIB();
 11021 	RETURN ( self );
 11151 	RETURN ( self );
 11022     }
 11152     }
 11023 %}.
 11153 %}.
 11024     self primitiveFailed
 11154     self primitiveFailedOrClosedConnection
 11025 !
 11155 !
 11026 
 11156 
 11027 setWindowBackgroundPixmap:aPixmapId in:aWindowId
 11157 setWindowBackgroundPixmap:aPixmapId in:aWindowId
 11028     "set the windows background pattern to be a form.
 11158     "set the windows background pattern to be a form.
 11029      This is the pattern with which the view is filled whenever exposed. 
 11159      This is the pattern with which the view is filled whenever exposed. 
 11030      Do not confuse this with the background drawing color, which is used 
 11160      Do not confuse this with the background drawing color, which is used 
 11031      with opaque drawing."
 11161      with opaque drawing."
 11032 
 11162 
 11033 %{  /* NOCONTEXT */
 11163     <context: #return>
       
 11164 %{  
 11034 
 11165 
 11035     if (ISCONNECTED
 11166     if (ISCONNECTED
 11036      && __isExternalAddress(aWindowId)
 11167      && __isExternalAddress(aWindowId)
 11037      && __isExternalAddress(aPixmapId)) {
 11168      && __isExternalAddress(aPixmapId)) {
 11038 	ENTER_XLIB();
 11169 	ENTER_XLIB();
 11039 	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
 11170 	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
 11040 	LEAVE_XLIB();
 11171 	LEAVE_XLIB();
 11041 	RETURN ( self );
 11172 	RETURN ( self );
 11042     }
 11173     }
 11043 %}.
 11174 %}.
 11044     self primitiveFailed
 11175     self primitiveFailedOrClosedConnection
 11045 !
 11176 !
 11046 
 11177 
 11047 setWindowBorderColor:aColorIndex in:aWindowId
 11178 setWindowBorderColor:aColorIndex in:aWindowId
 11048     "set the windows border color"
 11179     "set the windows border color"
 11049 
 11180 
 11050 %{  /* NOCONTEXT */
 11181     <context: #return>
       
 11182 %{  
 11051 
 11183 
 11052     if (ISCONNECTED
 11184     if (ISCONNECTED
 11053      && __isExternalAddress(aWindowId)
 11185      && __isExternalAddress(aWindowId)
 11054      && __isSmallInteger(aColorIndex)) {
 11186      && __isSmallInteger(aColorIndex)) {
 11055 	ENTER_XLIB();
 11187 	ENTER_XLIB();
 11056 	XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
 11188 	XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
 11057 	LEAVE_XLIB();
 11189 	LEAVE_XLIB();
 11058 	RETURN ( self );
 11190 	RETURN ( self );
 11059     }
 11191     }
 11060 %}.
 11192 %}.
 11061     self primitiveFailed
 11193     self primitiveFailedOrClosedConnection
 11062 !
 11194 !
 11063 
 11195 
 11064 setWindowBorderPixmap:aPixmapId in:aWindowId
 11196 setWindowBorderPixmap:aPixmapId in:aWindowId
 11065     "set the windows border pattern"
 11197     "set the windows border pattern"
 11066 
 11198 
 11067 %{  /* NOCONTEXT */
 11199     <context: #return>
       
 11200 %{  
 11068 
 11201 
 11069     if (ISCONNECTED
 11202     if (ISCONNECTED
 11070      && __isExternalAddress(aWindowId)
 11203      && __isExternalAddress(aWindowId)
 11071      && __isExternalAddress(aPixmapId)) {
 11204      && __isExternalAddress(aPixmapId)) {
 11072 	ENTER_XLIB();
 11205 	ENTER_XLIB();
 11073 	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
 11206 	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
 11074 	LEAVE_XLIB();
 11207 	LEAVE_XLIB();
 11075 	RETURN ( self );
 11208 	RETURN ( self );
 11076     }
 11209     }
 11077 %}.
 11210 %}.
 11078     self primitiveFailed
 11211     self primitiveFailedOrClosedConnection
 11079 !
 11212 !
 11080 
 11213 
 11081 setWindowBorderShape:aPixmapId in:aWindowId
 11214 setWindowBorderShape:aPixmapId in:aWindowId
 11082     "set the windows border shape"
 11215     "set the windows border shape"
 11083 
 11216 
       
 11217     <context: #return>
       
 11218 
 11084     hasShapeExtension ifFalse:[^ self].
 11219     hasShapeExtension ifFalse:[^ self].
 11085 
 11220 
 11086 %{  /* NOCONTEXT */
 11221 %{ 
 11087 
 11222 
 11088 #ifdef SHAPE
 11223 #ifdef SHAPE
 11089     Pixmap shapeBitmap;
 11224     Pixmap shapeBitmap;
 11090 
 11225 
 11091     if (__isExternalAddress(aPixmapId))
 11226     if (__isExternalAddress(aPixmapId))
 11101 	LEAVE_XLIB();
 11236 	LEAVE_XLIB();
 11102 	RETURN ( self );
 11237 	RETURN ( self );
 11103     }
 11238     }
 11104 #endif
 11239 #endif
 11105 %}.
 11240 %}.
 11106     self primitiveFailed
 11241     self primitiveFailedOrClosedConnection
 11107 !
 11242 !
 11108 
 11243 
 11109 setWindowBorderWidth:aNumber in:aWindowId
 11244 setWindowBorderWidth:aNumber in:aWindowId
 11110     "set the windows border width"
 11245     "set the windows border width"
 11111 
 11246 
 11112 %{  /* NOCONTEXT */
 11247     <context: #return>
       
 11248 %{  
 11113 
 11249 
 11114     if (ISCONNECTED
 11250     if (ISCONNECTED
 11115      && __isExternalAddress(aWindowId)
 11251      && __isExternalAddress(aWindowId)
 11116      && __isSmallInteger(aNumber)) {
 11252      && __isSmallInteger(aNumber)) {
 11117 	ENTER_XLIB();
 11253 	ENTER_XLIB();
 11118 	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber));
 11254 	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber));
 11119 	LEAVE_XLIB();
 11255 	LEAVE_XLIB();
 11120 	RETURN ( self );
 11256 	RETURN ( self );
 11121     }
 11257     }
 11122 %}.
 11258 %}.
 11123     self primitiveFailed
 11259     self primitiveFailedOrClosedConnection
 11124 !
 11260 !
 11125 
 11261 
 11126 setWindowClass:wClass name:wName in:aWindowId
 11262 setWindowClass:wClass name:wName in:aWindowId
 11127     "define class and name of a window.
 11263     "define class and name of a window.
 11128      This may be used by the window manager to
 11264      This may be used by the window manager to
 11129      select client specific resources."
 11265      select client specific resources."
 11130 
 11266 
       
 11267     <context: #return>
 11131 %{
 11268 %{
 11132     if (ISCONNECTED
 11269     if (ISCONNECTED
 11133      && __isExternalAddress(aWindowId)) {
 11270      && __isExternalAddress(aWindowId)) {
 11134 	XClassHint classhint;
 11271 	XClassHint classhint;
 11135 
 11272 
 11150 	LEAVE_XLIB();
 11287 	LEAVE_XLIB();
 11151 	RETURN ( self );
 11288 	RETURN ( self );
 11152 error:;
 11289 error:;
 11153     }
 11290     }
 11154 %}.
 11291 %}.
 11155     self primitiveFailed
 11292     self primitiveFailedOrClosedConnection
 11156 !
 11293 !
 11157 
 11294 
 11158 setWindowGravity:how in:aWindowId
 11295 setWindowGravity:how in:aWindowId
 11159     "set window gravity for a window"
 11296     "set window gravity for a window"
 11160 
 11297 
 11161 %{  /* NOCONTEXT */
 11298     <context: #return>
       
 11299 %{  
 11162 
 11300 
 11163     XSetWindowAttributes wa;
 11301     XSetWindowAttributes wa;
 11164 
 11302 
 11165     if (ISCONNECTED
 11303     if (ISCONNECTED
 11166      && __isExternalAddress(aWindowId)) {
 11304      && __isExternalAddress(aWindowId)) {
 11192 	LEAVE_XLIB();
 11330 	LEAVE_XLIB();
 11193 
 11331 
 11194 	RETURN ( self );
 11332 	RETURN ( self );
 11195     }
 11333     }
 11196 %}.
 11334 %}.
 11197     self primitiveFailed
 11335     self primitiveFailedOrClosedConnection
 11198 !
 11336 !
 11199 
 11337 
 11200 setWindowIcon:aForm in:aWindowId
 11338 setWindowIcon:aForm in:aWindowId
 11201     "define a bitmap to be used as icon"
 11339     "define a bitmap to be used as icon"
       
 11340 
       
 11341     <context: #return>
 11202 
 11342 
 11203     |iconId|
 11343     |iconId|
 11204 
 11344 
 11205     aForm notNil ifTrue:[
 11345     aForm notNil ifTrue:[
 11206 	iconId := aForm id
 11346 	iconId := aForm id
 11217 	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
 11357 	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
 11218 	LEAVE_XLIB();
 11358 	LEAVE_XLIB();
 11219 	RETURN ( self );
 11359 	RETURN ( self );
 11220     }
 11360     }
 11221 %}.
 11361 %}.
 11222     self primitiveFailed
 11362     self primitiveFailedOrClosedConnection
 11223 !
 11363 !
 11224 
 11364 
 11225 setWindowIcon:aForm mask:aMaskForm in:aWindowId
 11365 setWindowIcon:aForm mask:aMaskForm in:aWindowId
 11226     "define a windows icon and (optional) iconMask."
 11366     "define a windows icon and (optional) iconMask."
       
 11367 
       
 11368     <context: #return>
 11227 
 11369 
 11228     |iconId maskId|
 11370     |iconId maskId|
 11229 
 11371 
 11230     aForm notNil ifTrue:[
 11372     aForm notNil ifTrue:[
 11231 	iconId := aForm id
 11373 	iconId := aForm id
 11250 	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
 11392 	XSetWMHints(myDpy, _WindowVal(aWindowId), &hints);
 11251 	LEAVE_XLIB();
 11393 	LEAVE_XLIB();
 11252 	RETURN ( self );
 11394 	RETURN ( self );
 11253     }
 11395     }
 11254 %}.
 11396 %}.
 11255     self primitiveFailed
 11397     self primitiveFailedOrClosedConnection
 11256 
 11398 
 11257 !
 11399 !
 11258 
 11400 
 11259 setWindowIconWindow:aView in:aWindowId
 11401 setWindowIconWindow:aView in:aWindowId
 11260     "define a window to be used as icon"
 11402     "define a window to be used as icon"
       
 11403 
       
 11404     <context: #return>
 11261 
 11405 
 11262     |iconWindowId|
 11406     |iconWindowId|
 11263 
 11407 
 11264     aView notNil ifTrue:[
 11408     aView notNil ifTrue:[
 11265 	iconWindowId := aView id
 11409 	iconWindowId := aView id
 11276 	XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints);
 11420 	XSetWMHints(myDpy, _WindowVal(aWindowId), &wmhints);
 11277 	LEAVE_XLIB();
 11421 	LEAVE_XLIB();
 11278 	RETURN ( self );
 11422 	RETURN ( self );
 11279     }
 11423     }
 11280 %}.
 11424 %}.
 11281     self primitiveFailed
 11425     self primitiveFailedOrClosedConnection
 11282 !
 11426 !
 11283 
 11427 
 11284 setWindowMinExtentX:minW y:minH maxExtentX:maxW y:maxH in:aWindowId
 11428 setWindowMinExtentX:minW y:minH maxExtentX:maxW y:maxH in:aWindowId
 11285     "set a windows minimum & max extents.
 11429     "set a windows minimum & max extents.
 11286      nil arguments are ignored."
 11430      nil arguments are ignored."
 11287 
 11431 
       
 11432     <context: #return>
 11288 %{  
 11433 %{  
 11289     if (ISCONNECTED
 11434     if (ISCONNECTED
 11290      && __isExternalAddress(aWindowId)) {
 11435      && __isExternalAddress(aWindowId)) {
 11291         Display *dpy = myDpy;
 11436 	Display *dpy = myDpy;
 11292         XSizeHints szhints;
 11437 	XSizeHints szhints;
 11293         Window win;
 11438 	Window win;
 11294 
 11439 
 11295         win = _WindowVal(aWindowId);
 11440 	win = _WindowVal(aWindowId);
 11296 
 11441 
 11297         szhints.flags = 0;
 11442 	szhints.flags = 0;
 11298         if (__bothSmallInteger(minW, minH)) {
 11443 	if (__bothSmallInteger(minW, minH)) {
 11299             szhints.flags |= PMinSize;
 11444 	    szhints.flags |= PMinSize;
 11300             szhints.min_width = __intVal(minW);
 11445 	    szhints.min_width = __intVal(minW);
 11301             szhints.min_height = __intVal(minH);
 11446 	    szhints.min_height = __intVal(minH);
 11302         }
 11447 	}
 11303         if (__bothSmallInteger(maxW, maxH)) {
 11448 	if (__bothSmallInteger(maxW, maxH)) {
 11304             szhints.flags |= PMaxSize;
 11449 	    szhints.flags |= PMaxSize;
 11305             szhints.max_width = __intVal(maxW);
 11450 	    szhints.max_width = __intVal(maxW);
 11306             szhints.max_height = __intVal(maxH);
 11451 	    szhints.max_height = __intVal(maxH);
 11307         }
 11452 	}
 11308 
 11453 
 11309         if (szhints.flags) {
 11454 	if (szhints.flags) {
 11310             ENTER_XLIB();
 11455 	    ENTER_XLIB();
 11311             XSetNormalHints(dpy, win, &szhints);
 11456 	    XSetNormalHints(dpy, win, &szhints);
 11312             LEAVE_XLIB();
 11457 	    LEAVE_XLIB();
 11313         }
 11458 	}
 11314     }
 11459     }
 11315 %}.
 11460 %}.
 11316 !
 11461 !
 11317 
 11462 
 11318 setWindowName:aString in:aWindowId
 11463 setWindowName:aString in:aWindowId
 11319     "define a windows name"
 11464     "define a windows name"
 11320 
 11465 
 11321 %{  /* NOCONTEXT */
 11466     <context: #return>
       
 11467 %{  
 11322 
 11468 
 11323     if (ISCONNECTED
 11469     if (ISCONNECTED
 11324      && __isNonNilObject(aString)
 11470      && __isNonNilObject(aString)
 11325      && (__qIsString(aString) || __qIsSymbol(aString))
 11471      && (__qIsString(aString) || __qIsSymbol(aString))
 11326      && __isExternalAddress(aWindowId)) {
 11472      && __isExternalAddress(aWindowId)) {
 11328 	XStoreName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString));
 11474 	XStoreName(myDpy, _WindowVal(aWindowId), (char *) __stringVal(aString));
 11329 	LEAVE_XLIB();
 11475 	LEAVE_XLIB();
 11330 	RETURN ( self );
 11476 	RETURN ( self );
 11331     }
 11477     }
 11332 %}.
 11478 %}.
 11333     self primitiveFailed
 11479     self primitiveFailedOrClosedConnection
 11334 !
 11480 !
 11335 
 11481 
 11336 setWindowShape:aPixmapId in:aWindowId
 11482 setWindowShape:aPixmapId in:aWindowId
 11337     "set the windows shape.
 11483     "set the windows shape.
 11338      Returns false, if the display does not support the
 11484      Returns false, if the display does not support the
 11339      X shape extension."
 11485      X shape extension."
 11340 
 11486 
       
 11487     <context: #return>
       
 11488 
 11341     hasShapeExtension ifFalse:[^ self].
 11489     hasShapeExtension ifFalse:[^ self].
 11342 
 11490 
 11343 %{  /* NOCONTEXT */
 11491 %{ 
 11344 
 11492 
 11345 #ifdef SHAPE
 11493 #ifdef SHAPE
 11346     Pixmap shapeBitmap;
 11494     Pixmap shapeBitmap;
 11347 
 11495 
 11348     if (__isExternalAddress(aPixmapId))
 11496     if (__isExternalAddress(aPixmapId))
 11359 	LEAVE_XLIB();
 11507 	LEAVE_XLIB();
 11360 	RETURN ( self );
 11508 	RETURN ( self );
 11361     }
 11509     }
 11362 #endif
 11510 #endif
 11363 %}.
 11511 %}.
 11364     self primitiveFailed
 11512     self primitiveFailedOrClosedConnection
 11365 !
 11513 !
 11366 
 11514 
 11367 unmapWindow:aWindowId
 11515 unmapWindow:aWindowId
 11368     "make a window invisible"
 11516     "make a window invisible"
 11369 
 11517 
 11370 %{  /* NOCONTEXT */
 11518     <context: #return>
       
 11519 %{  
 11371 
 11520 
 11372     if (!ISCONNECTED) {
 11521     if (!ISCONNECTED) {
 11373 	RETURN ( self );
 11522 	RETURN ( self );
 11374     }
 11523     }
 11375 
 11524 
 11378 	XUnmapWindow(myDpy, _WindowVal(aWindowId));
 11527 	XUnmapWindow(myDpy, _WindowVal(aWindowId));
 11379 	LEAVE_XLIB();
 11528 	LEAVE_XLIB();
 11380 	RETURN ( self );
 11529 	RETURN ( self );
 11381     }
 11530     }
 11382 %}.
 11531 %}.
 11383     self primitiveFailed
 11532     self primitiveFailedOrClosedConnection
 11384 !
 11533 !
 11385 
 11534 
 11386 windowIsIconified:aWindowId
 11535 windowIsIconified:aWindowId
 11387     "return true, if some window is iconified.
 11536     "return true, if some window is iconified.
 11388      The passed windowID may be an alien windows id."
 11537      The passed windowID may be an alien windows id."
 11389 
 11538 
 11390 %{  /* NOCONTEXT */
 11539     <context: #return>
       
 11540 %{  
 11391 
 11541 
 11392     if (ISCONNECTED
 11542     if (ISCONNECTED
 11393      && __isExternalAddress(aWindowId)) {
 11543      && __isExternalAddress(aWindowId)) {
 11394 	Atom JunkAtom;
 11544 	Atom JunkAtom;
 11395 	int JunkInt;
 11545 	int JunkInt;
 11413 	    }
 11563 	    }
 11414 	}
 11564 	}
 11415 	RETURN (false);
 11565 	RETURN (false);
 11416     }
 11566     }
 11417 %}.
 11567 %}.
 11418     self primitiveFailed
 11568     self primitiveFailedOrClosedConnection.
       
 11569     ^ false "/ or true or what ?
 11419 ! !
 11570 ! !
 11420 
 11571 
 11421 !XWorkstation class methodsFor:'documentation'!
 11572 !XWorkstation class methodsFor:'documentation'!
 11422 
 11573 
 11423 version
 11574 version
 11424     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.370 2000-09-04 12:25:27 cg Exp $'
 11575     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.371 2000-09-07 12:51:40 cg Exp $'
 11425 ! !
 11576 ! !
 11426 XWorkstation initialize!
 11577 XWorkstation initialize!