X11GraphicsContext moved
authorClaus Gittinger <cg@exept.de>
Tue, 08 May 2018 12:49:27 +0200
changeset 8358 1e93e10ae298
parent 8357 f1060ceb2b3c
child 8359 cb3e5fa8c5e6
X11GraphicsContext moved
XWorkstation.st
--- a/XWorkstation.st	Tue May 08 12:47:31 2018 +0200
+++ b/XWorkstation.st	Tue May 08 12:49:27 2018 +0200
@@ -62,12 +62,6 @@
 	privateIn:XWorkstation
 !
 
-DeviceGraphicsContext subclass:#xX11GraphicsContext
-	instanceVariableNames:'depth xftDrawId'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:XWorkstation
-!
 
 !XWorkstation primitiveDefinitions!
 %{
@@ -1298,21 +1292,21 @@
     if (ISCONNECTED
      && (__INST(rootId) != __INST(virtualRootId))
      && __isExternalAddress(__INST(virtualRootId))) {
-        Window vRootWin;
-        Window root;
-        int x, y;
-        unsigned int width, height;
-        unsigned int dummy;
-        int ret;
-
-        vRootWin = __WindowVal(__INST(virtualRootId));
-        ENTER_XLIB();
-        ret = XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height,
-                                          &dummy, &dummy);
-        LEAVE_XLIB();
-        if (ret) {
-            RETURN ( __MKPOINT_INT(width, height) );
-        }
+	Window vRootWin;
+	Window root;
+	int x, y;
+	unsigned int width, height;
+	unsigned int dummy;
+	int ret;
+
+	vRootWin = __WindowVal(__INST(virtualRootId));
+	ENTER_XLIB();
+	ret = XGetGeometry(myDpy, vRootWin, &root, &x, &y, &width, &height,
+					  &dummy, &dummy);
+	LEAVE_XLIB();
+	if (ret) {
+	    RETURN ( __MKPOINT_INT(width, height) );
+	}
     }
 %}.
     ^ width @ height
@@ -8552,71 +8546,71 @@
     KeySym keySym, *syms;
 
     if (__isStringLike(keySymCodeOrChar)) {
-        keySym = XStringToKeysym(__stringVal(keySymCodeOrChar));
+	keySym = XStringToKeysym(__stringVal(keySymCodeOrChar));
     } else {
-        if (__isCharacter(keySymCodeOrChar)) {
-            char s[2];
-
-            s[0] = __intVal(__characterVal(keySymCodeOrChar));
-            s[1] = '\0';
-            keySym = XStringToKeysym(s);
-        } else {
-            if (__isSmallInteger(keySymCodeOrChar)) {
-                keySym = (KeySym) __intVal(keySymCodeOrChar);
-            } else {
-                goto notOK;
-            }
-        }
+	if (__isCharacter(keySymCodeOrChar)) {
+	    char s[2];
+
+	    s[0] = __intVal(__characterVal(keySymCodeOrChar));
+	    s[1] = '\0';
+	    keySym = XStringToKeysym(s);
+	} else {
+	    if (__isSmallInteger(keySymCodeOrChar)) {
+		keySym = (KeySym) __intVal(keySymCodeOrChar);
+	    } else {
+		goto notOK;
+	    }
+	}
     }
 
     if (modifierMaskOrNil != nil) {
-        if (__isSmallInteger(modifierMaskOrNil)) {
-            modifierMask = __intVal(modifierMaskOrNil);
-        } else {
-            goto notOK;
-        }
+	if (__isSmallInteger(modifierMaskOrNil)) {
+	    modifierMask = __intVal(modifierMaskOrNil);
+	} else {
+	    goto notOK;
+	}
     }
 
     if (ISCONNECTED) {
-        Display *dpy;
-        Window window;
-        int keyCode;
-        int result;
-        int mKbd, mPtr;
-
-        mKbd = modeKbd == @symbol(GrabModeAsync) ? GrabModeAsync :GrabModeSync;
-        mPtr = modePtr == @symbol(GrabModeAsync) ? GrabModeAsync :GrabModeSync;
-
-        dpy = myDpy;
-        keyCode = XKeysymToKeycode(dpy, keySym);
-        if (__isExternalAddress(aWindowIdOrNil)) {
-            window = __WindowVal(aWindowIdOrNil);
-        } else {
-            int screen;
-
-            screen = DefaultScreen(dpy);
-            window = RootWindow(dpy, screen);
-        }
-        ENTER_XLIB();
-
-        result = XGrabKey (dpy,
-            keyCode, modifierMask, window,
-            False, mKbd, mPtr );
-
-        XSync(dpy, True);
-        XFlush(dpy);
-
-        LEAVE_XLIB();
-
-        if (result != Success) {
-            if (result == BadAccess) {
-                __INST(lastError) = @symbol(badAccess);
-            } else {
-                __INST(lastError) = @symbol(other);
-            }
-            RETURN (false);
-        }
-        RETURN (true);
+	Display *dpy;
+	Window window;
+	int keyCode;
+	int result;
+	int mKbd, mPtr;
+
+	mKbd = modeKbd == @symbol(GrabModeAsync) ? GrabModeAsync :GrabModeSync;
+	mPtr = modePtr == @symbol(GrabModeAsync) ? GrabModeAsync :GrabModeSync;
+
+	dpy = myDpy;
+	keyCode = XKeysymToKeycode(dpy, keySym);
+	if (__isExternalAddress(aWindowIdOrNil)) {
+	    window = __WindowVal(aWindowIdOrNil);
+	} else {
+	    int screen;
+
+	    screen = DefaultScreen(dpy);
+	    window = RootWindow(dpy, screen);
+	}
+	ENTER_XLIB();
+
+	result = XGrabKey (dpy,
+	    keyCode, modifierMask, window,
+	    False, mKbd, mPtr );
+
+	XSync(dpy, True);
+	XFlush(dpy);
+
+	LEAVE_XLIB();
+
+	if (result != Success) {
+	    if (result == BadAccess) {
+		__INST(lastError) = @symbol(badAccess);
+	    } else {
+		__INST(lastError) = @symbol(other);
+	    }
+	    RETURN (false);
+	}
+	RETURN (true);
     }
   notOK: ;
 %}.
@@ -8654,66 +8648,66 @@
     KeySym keySym, *syms;
 
     if (__isStringLike(keySymCodeOrChar)) {
-        keySym = XStringToKeysym(__stringVal(keySymCodeOrChar));
+	keySym = XStringToKeysym(__stringVal(keySymCodeOrChar));
     } else {
-        if (__isCharacter(keySymCodeOrChar)) {
-            char s[2];
-
-            s[0] = __intVal(__characterVal(keySymCodeOrChar));
-            s[1] = '\0';
-            keySym = XStringToKeysym(s);
-        } else {
-            if (__isSmallInteger(keySymCodeOrChar)) {
-                keySym = (KeySym) __intVal(keySymCodeOrChar);
-            } else {
-                goto notOK;
-            }
-        }
+	if (__isCharacter(keySymCodeOrChar)) {
+	    char s[2];
+
+	    s[0] = __intVal(__characterVal(keySymCodeOrChar));
+	    s[1] = '\0';
+	    keySym = XStringToKeysym(s);
+	} else {
+	    if (__isSmallInteger(keySymCodeOrChar)) {
+		keySym = (KeySym) __intVal(keySymCodeOrChar);
+	    } else {
+		goto notOK;
+	    }
+	}
     }
 
     if (modifierMaskOrNil != nil) {
-        if (__isSmallInteger(modifierMaskOrNil)) {
-            modifierMask = __intVal(modifierMaskOrNil);
-        } else {
-            goto notOK;
-        }
+	if (__isSmallInteger(modifierMaskOrNil)) {
+	    modifierMask = __intVal(modifierMaskOrNil);
+	} else {
+	    goto notOK;
+	}
     }
 
     if (ISCONNECTED) {
-        Display *dpy;
-        Window window;
-        int keyCode;
-        int result;
-
-        dpy = myDpy;
-        if (__isExternalAddress(aWindowIdOrNil)) {
-            window = __WindowVal(aWindowIdOrNil);
-        } else {
-            int screen;
-
-            screen = DefaultScreen(dpy);
-            window = RootWindow(dpy, screen);
-        }
-        keyCode = XKeysymToKeycode(dpy, keySym);
-
-        ENTER_XLIB();
-
-        result = XUngrabKey (dpy, keyCode, modifierMask, window);
-
-        XSync(dpy, True);
-        XFlush(dpy);
-
-        LEAVE_XLIB();
-
-        if (result != Success) {
-            if (result == BadAccess) {
-                __INST(lastError) = @symbol(badAccess);
-            } else {
-                __INST(lastError) = @symbol(other);
-            }
-            RETURN (false);
-        }
-        RETURN (true);
+	Display *dpy;
+	Window window;
+	int keyCode;
+	int result;
+
+	dpy = myDpy;
+	if (__isExternalAddress(aWindowIdOrNil)) {
+	    window = __WindowVal(aWindowIdOrNil);
+	} else {
+	    int screen;
+
+	    screen = DefaultScreen(dpy);
+	    window = RootWindow(dpy, screen);
+	}
+	keyCode = XKeysymToKeycode(dpy, keySym);
+
+	ENTER_XLIB();
+
+	result = XUngrabKey (dpy, keyCode, modifierMask, window);
+
+	XSync(dpy, True);
+	XFlush(dpy);
+
+	LEAVE_XLIB();
+
+	if (result != Success) {
+	    if (result == BadAccess) {
+		__INST(lastError) = @symbol(badAccess);
+	    } else {
+		__INST(lastError) = @symbol(other);
+	    }
+	    RETURN (false);
+	}
+	RETURN (true);
     }
   notOK: ;
 %}.
@@ -11416,22 +11410,22 @@
 
     selectionOwnerWindowId := self getSelectionOwnerOf:clipboardAtom.
     (selectionOwnerWindowId isNil   "no selection. There is the possibilty that one of our (modal) views has been closed.
-                                     Get the selection from our own buffer"
+				     Get the selection from our own buffer"
      or:[self viewIdKnown:selectionOwnerWindowId]) ifTrue:[
-        "one of our own views still holds the selection, so return my locally buffered data"
-        ^ copyBuffer
+	"one of our own views still holds the selection, so return my locally buffered data"
+	^ copyBuffer
     ].
 
     drawableId isNil ifTrue:[
-        "sorry, cannot fetch a selection, if there is no drawableId.
-         Should I borrow a drawableId from another window?"
-        ^ nil.
+	"sorry, cannot fetch a selection, if there is no drawableId.
+	 Should I borrow a drawableId from another window?"
+	^ nil.
     ].
 
     selection := SelectionFetcher
-        requestSelection:clipboardAtom
-        type:(self atomIDOf:#'ST_OBJECT')
-        onDevice:self for:drawableId.
+	requestSelection:clipboardAtom
+	type:(self atomIDOf:#'ST_OBJECT')
+	onDevice:self for:drawableId.
 
     "/ should not happen
     "/ cg: disabled the code below: I don't want any string here (when asking for an object)
@@ -11467,40 +11461,40 @@
     |selectionId selectionOwnerWindowId selection|
 
     selectionBufferSymbol == #selection ifTrue:[
-        selectionId := primaryAtom.
+	selectionId := primaryAtom.
     ] ifFalse:[
-        selectionId := clipboardAtom.
+	selectionId := clipboardAtom.
     ].
 
     selectionOwnerWindowId := self getSelectionOwnerOf:selectionId.
     (selectionOwnerWindowId isNil   "no selection. There is the possibilty that one of our (modal) views has been closed.
-                                     Get the selection from our own buffer"
+				     Get the selection from our own buffer"
      or:[self viewIdKnown:selectionOwnerWindowId]) ifTrue:[
-        "One of our own views still holds the selection, so return my locally buffered data"
-        "JV@2012-04-02: Added support for PRIMARY/SELECTION buffers."
-        ^ selectionId == primaryAtom ifTrue:[
-            self primaryBufferAsString
-        ] ifFalse:[
-            self copyBufferAsString.
-        ]
+	"One of our own views still holds the selection, so return my locally buffered data"
+	"JV@2012-04-02: Added support for PRIMARY/SELECTION buffers."
+	^ selectionId == primaryAtom ifTrue:[
+	    self primaryBufferAsString
+	] ifFalse:[
+	    self copyBufferAsString.
+	]
     ].
 
     drawableId isNil ifTrue:[
-        "sorry, cannot fetch a selection, if there is no drawableId.
-         Should I borrow a drawableId from another window?"
-         ^ nil.
+	"sorry, cannot fetch a selection, if there is no drawableId.
+	 Should I borrow a drawableId from another window?"
+	 ^ nil.
     ].
 
     selection := SelectionFetcher
-        requestSelection:selectionId
-        type:(self atomIDOf:#'UTF8_STRING')
-        onDevice:self for:drawableId.
+	requestSelection:selectionId
+	type:(self atomIDOf:#'UTF8_STRING')
+	onDevice:self for:drawableId.
 
     selection isNil ifTrue:[
-        selection := SelectionFetcher
-            requestSelection:selectionId
-            type:(self atomIDOf:#STRING)
-            onDevice:self for:drawableId.
+	selection := SelectionFetcher
+	    requestSelection:selectionId
+	    type:(self atomIDOf:#STRING)
+	    onDevice:self for:drawableId.
     ].
 
     ^ selection
@@ -11917,35 +11911,35 @@
 
     if (ISCONNECTED
      && __isExternalAddress(aWindowId)) {
-        Display *dpy = myDpy;
-        Window win = __WindowVal(aWindowId);
-        Window rootReturn, parentReturn;
-        Window* children = (Window *)0;
-        unsigned int numChildren;
-        int i;
-        int rslt;
-
-        ENTER_XLIB();
-        rslt = XQueryTree(dpy, win,
-                       &rootReturn, &parentReturn,
-                       &children, &numChildren);
-        LEAVE_XLIB();
-        if (rslt) {
-            childIdArray = __ARRAY_NEW_INT(numChildren);
-            if (childIdArray != nil) {
-                for (i=0; i < numChildren; i++) {
-                    if (children[i]) {
-                        OBJ childId;
-
-                        childId = __MKEXTERNALADDRESS(children[i]);
-                        __ArrayInstPtr(childIdArray)->a_element[i] = childId;
-                        __STORE(childIdArray, childId);
-                    }
-                }
-                if (children) XFree(children);
-            }
-            RETURN (childIdArray);
-        }
+	Display *dpy = myDpy;
+	Window win = __WindowVal(aWindowId);
+	Window rootReturn, parentReturn;
+	Window* children = (Window *)0;
+	unsigned int numChildren;
+	int i;
+	int rslt;
+
+	ENTER_XLIB();
+	rslt = XQueryTree(dpy, win,
+		       &rootReturn, &parentReturn,
+		       &children, &numChildren);
+	LEAVE_XLIB();
+	if (rslt) {
+	    childIdArray = __ARRAY_NEW_INT(numChildren);
+	    if (childIdArray != nil) {
+		for (i=0; i < numChildren; i++) {
+		    if (children[i]) {
+			OBJ childId;
+
+			childId = __MKEXTERNALADDRESS(children[i]);
+			__ArrayInstPtr(childIdArray)->a_element[i] = childId;
+			__STORE(childIdArray, childId);
+		    }
+		}
+		if (children) XFree(children);
+	    }
+	    RETURN (childIdArray);
+	}
     }
 %}.
     ^ nil.
@@ -12271,22 +12265,22 @@
 
     if (ISCONNECTED
      && __isExternalAddress(aWindowId)) {
-        char *name = NULL;
-        Status ok;
-        Window root, parent, *children = NULL;
-        unsigned int nChildren;
+	char *name = NULL;
+	Status ok;
+	Window root, parent, *children = NULL;
+	unsigned int nChildren;
 
 /*        ENTER_XLIB(); */
-        ok = XQueryTree(myDpy, __WindowVal(aWindowId),
-                        &root, &parent, &children, &nChildren);
-        if (children) {
-            XFree(children);
-        }
+	ok = XQueryTree(myDpy, __WindowVal(aWindowId),
+			&root, &parent, &children, &nChildren);
+	if (children) {
+	    XFree(children);
+	}
 /*        LEAVE_XLIB();   */
-        if (ok) {
-            RETURN (true);
-        }
-        RETURN (false);
+	if (ok) {
+	    RETURN (true);
+	}
+	RETURN (false);
     }
 %}.
     self primitiveFailedOrClosedConnection.
@@ -12539,21 +12533,21 @@
 
     if (ISCONNECTED
      && __isExternalAddress(aWindowId)) {
-        Status ok;
-        Window root, parent, *children = NULL;
-        unsigned int nChildren;
+	Status ok;
+	Window root, parent, *children = NULL;
+	unsigned int nChildren;
 
 /*        ENTER_XLIB(); */
-        ok = XQueryTree(myDpy, __WindowVal(aWindowId),
-                        &root, &parent, &children, &nChildren);
-        if (children) {
-            XFree(children);
-        }
+	ok = XQueryTree(myDpy, __WindowVal(aWindowId),
+			&root, &parent, &children, &nChildren);
+	if (children) {
+	    XFree(children);
+	}
 /*        LEAVE_XLIB();   */
-        if (! ok) {
-            RETURN ( nil );
-        }
-        RETURN ( __MKEXTERNALADDRESS(parent) );
+	if (! ok) {
+	    RETURN ( nil );
+	}
+	RETURN ( __MKEXTERNALADDRESS(parent) );
     }
 %}.
     self primitiveFailedOrClosedConnection.
@@ -13504,51 +13498,51 @@
     |selection|
 
     buffer isNil ifTrue:[
-        ^ nil.
+	^ nil.
     ].
 
     targetID == (display atomIDOf:#STRING) ifTrue:[
-        display clipboardEncoding notNil ifTrue:[
-            selection := buffer decodeFrom:display clipboardEncoding
-        ].
-        selection := buffer.
+	display clipboardEncoding notNil ifTrue:[
+	    selection := buffer decodeFrom:display clipboardEncoding
+	].
+	selection := buffer.
     ] ifFalse:[targetID == (display atomIDOf:#'UTF8_STRING') ifTrue:[
-        "/ Transcript show:'UTF8: '; showCR:buffer storeString.
-        [
-            selection := buffer utf8Decoded.
-        ] on:Error do:[
-            selection := buffer asString
-        ]            
+	"/ Transcript show:'UTF8: '; showCR:buffer storeString.
+	[
+	    selection := buffer utf8Decoded.
+	] on:Error do:[
+	    selection := buffer asString
+	]
     ] ifFalse:[targetID == (display atomIDOf:#TEXT) ifTrue:[
-        "/ Transcript show:'TEXT: '; showCR:buffer storeString.
-        selection := buffer asString
+	"/ Transcript show:'TEXT: '; showCR:buffer storeString.
+	selection := buffer asString
     ] ifFalse:[targetID == (display atomIDOf:#'COMPOUND_TEXT') ifTrue:[
-        "/ Transcript show:'COMPOUND_TEXT: '; showCR:buffer storeString.
-        selection := buffer asString
+	"/ Transcript show:'COMPOUND_TEXT: '; showCR:buffer storeString.
+	selection := buffer asString
     ]]]].
 
     selection notNil ifTrue:[
-        (selection endsWith:Character cr) ifTrue:[
-            selection := selection asStringCollection copyWith:''
-        ].
-        ^ selection.
+	(selection endsWith:Character cr) ifTrue:[
+	    selection := selection asStringCollection copyWith:''
+	].
+	^ selection.
     ].
 
     targetID == (display atomIDOf:#'TARGETS') ifTrue:[
-        ^ buffer
+	^ buffer
     ].
     targetID == (display atomIDOf:#'ST_OBJECT') ifTrue:[
-        "require libboss to be loaded"
-        (Smalltalk isClassLibraryLoaded:'libstx_libboss') ifFalse:[
-            'SelectionFetch: cannot decode object (libboss library missing)' errorPrintCR.
-            ^ nil
-        ].
-        ^ (Object
-            readBinaryFrom:(ReadStream on:buffer)
-            onError:[:ex |
-                ('SelectionFetch: error while decoding binary object: ',ex description) errorPrintCR.
-                nil
-            ])
+	"require libboss to be loaded"
+	(Smalltalk isClassLibraryLoaded:'libstx_libboss') ifFalse:[
+	    'SelectionFetch: cannot decode object (libboss library missing)' errorPrintCR.
+	    ^ nil
+	].
+	^ (Object
+	    readBinaryFrom:(ReadStream on:buffer)
+	    onError:[:ex |
+		('SelectionFetch: error while decoding binary object: ',ex description) errorPrintCR.
+		nil
+	    ])
     ].
 
     'XWorkstation: unimplemented property targetID: ' infoPrint. (display atomName:targetID) infoPrint.
@@ -13723,20 +13717,20 @@
 
 documentation
 "
-    A special window to serve as window group id. 
-    This window is never mapped. 
+    A special window to serve as window group id.
+    This window is never mapped.
     This window is used in XWMHints & _NET_WM_LEADER properties
     to define the application window group
 
     [author:]
-        Jan Vrany <jan.vrany@fit.cvut.cz>
+	Jan Vrany <jan.vrany@fit.cvut.cz>
 
     [instance variables:]
 
     [class variables:]
 
     [see also:]
-        Inter-Client Communication Conventions Manual [http://tronche.com/gui/x/icccm/]
+	Inter-Client Communication Conventions Manual [http://tronche.com/gui/x/icccm/]
 
 
 "
@@ -13748,519 +13742,6 @@
     ^ true
 ! !
 
-!XWorkstation::xX11GraphicsContext methodsFor:'accessing'!
-
-depth
-    ^ depth
-!
-
-xftDrawId
-    ^ xftDrawId
-! !
-
-!XWorkstation::xX11GraphicsContext methodsFor:'destroying'!
-
-destroy
-    xftDrawId notNil ifTrue:[
-	self destroyXftDrawId.
-    ].
-    super destroy.
-!
-
-destroyXftDrawId
-    |id|
-
-    id := xftDrawId.
-    xftDrawId := nil.
-%{
-#ifdef XFT
-    if (__isExternalAddress(id)) {
-	XftDraw *address = (XftDraw *)__externalAddressVal(id);
-	if (address) {
-	    XftDrawDestroy(address);
-	    __externalAddressVal(id) = 0;
-	}
-    }
-#endif
-%}.
-! !
-
-!XWorkstation::xX11GraphicsContext methodsFor:'displaying'!
-
-displayDeviceString:aString from:index1 to:index2 x:x y:y opaque:opaque
-    "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
-     foreground and background characters.
-     If the coordinates are not integers, an error is triggered."
-
-    <context: #return>
-
-    |displayId|
-
-    font isXftFont ifTrue:[
-	self displayDeviceXftString:aString from:index1 to:index2 x:x y:y opaque:opaque.
-	^ self.
-    ].
-
-    device flushIfAppropriate.
-    displayId := device displayIdOrErrorIfBroken.
-
-%{
-    GC gc;
-    Window win;
-    char *cp;
-    int  i1, i2, l, n;
-#   define NLOCALBUFFER 200
-    XChar2b xlatebuffer[NLOCALBUFFER];
-    int nInstBytes;
-
-    if (__isExternalAddress(displayId)
-     && __isExternalAddress(__INST(gcId))
-     && __isExternalAddress(__INST(drawableId))
-     && __isNonNilObject(aString)
-     && __bothSmallInteger(index1, index2)
-     && __bothSmallInteger(x, y)) {
-	int lMax = __intVal(@global(XWorkstation:MaxStringLength));
-	Display *dpy = __DisplayVal(displayId);
-	gc = __GCVal(__INST(gcId));
-	win = __WindowVal(__INST(drawableId));
-
-	i1 = __intVal(index1) - 1;
-	if (i1 >= 0) {
-	    OBJ cls;
-
-	    i2 = __intVal(index2) - 1;
-	    if (i2 < i1) {
-		RETURN (self);
-	    }
-	    cp = (char *) __stringVal(aString);
-	    l = i2 - i1 + 1;
-
-	    if (__isStringLike(aString)) {
-		n = __stringSize(aString);
-		if (i2 < n) {
-		    cp += i1;
-		    if (l > lMax) l = lMax;
-		    __ENTER_XLIB(1000 * __intVal(@global(XWorkstation:DefaultXLibTimeout)));
-		    if (opaque == true)
-			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
-		    else
-			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
-		    LEAVE_XLIB();
-		    RETURN ( self );
-		}
-	    }
-
-	    cls = __qClass(aString);
-	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
-	    cp += nInstBytes;
-
-	    if (__isBytes(aString)) {
-		n = __byteArraySize(aString) - nInstBytes - 1;
-
-		if (i2 < n) {
-		    cp += i1;
-		    if (l > lMax) l = lMax;
-		    __ENTER_XLIB(1000 * __intVal(@global(XWorkstation:DefaultXLibTimeout)));
-		    if (opaque == true)
-			XDrawImageString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
-		    else
-			XDrawString(dpy, win, gc, __intVal(x), __intVal(y), cp, l);
-		    LEAVE_XLIB();
-		    RETURN ( self );
-		}
-	    }
-
-	    /* TWOBYTESTRINGS */
-	    if (__isWords(aString)) {
-		n = (__byteArraySize(aString) - nInstBytes) / 2;
-		if (i2 < n) {
-		    union {
-			char b[2];
-			unsigned short s;
-		    } u;
-		    int i;
-		    XChar2b *cp2 = (XChar2b *)0;
-		    int mustFree = 0;
-
-		    cp += (i1 * 2);
-		    if (l > lMax) l = lMax;
-
-#if defined(MSBFIRST) || defined(__MSBFIRST)
-		    /*
-		     * chars already in correct order
-		     */
-#else
-# if ! (defined(LSBFIRST) || defined(__LSBFIRST))
-		    /*
-		     * ST/X TwoByteStrings store the asciiValue in native byteOrder;
-		     * X expects them MSB first
-		     * convert as required
-		     */
-		    u.s = 0x1234;
-		    if (u.b[0] != 0x12)
-# endif  // ! (defined(LSBFIRST) || defined(__LSBFIRST))
-		    {
-			if (l <= NLOCALBUFFER) {
-			    cp2 = xlatebuffer;
-			} else {
-			    cp2 = (XChar2b *)(malloc(l * 2));
-			    mustFree = 1;
-			}
-			for (i=0; i<l; i++) {
-			    cp2[i].byte1 = (((XChar2b *)cp)[i]).byte2;
-			    cp2[i].byte2 = (((XChar2b *)cp)[i]).byte1;
-			}
-			cp = (char *) cp2;
-		    }
-#endif  // ! (defined(MSBFIRST) || defined(__MSBFIRST))
-		    __ENTER_XLIB(1000 * __intVal(@global(XWorkstation:DefaultXLibTimeout)));
-		    if (opaque == true)
-			XDrawImageString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l);
-		    else
-			XDrawString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp, l);
-		    LEAVE_XLIB();
-
-		    if (mustFree) {
-			free(cp2);
-		    }
-
-		    RETURN ( self );
-		}
-	    }
-
-	    /* FOURBYTESTRINGS */
-	    if (__isLongs(aString)) {
-		n = (__byteArraySize(aString) - nInstBytes) / 4;
-		if (i2 < n) {
-		    union {
-			char b[2];
-			unsigned short s;
-		    } u;
-		    int i;
-		    XChar2b *cp2 = (XChar2b *)0;
-		    int32 *ip;
-		    int mustFree = 0;
-
-		    cp += (i1 * 4);
-		    if (l > lMax) l = lMax;
-
-		    /*
-		     * all codePoints <= 16rFFFF are draw; above 16bit range are drawn as 16rFFFF.
-		     */
-		    if (l <= NLOCALBUFFER) {
-			cp2 = xlatebuffer;
-		    } else {
-			cp2 = (XChar2b *)(malloc(l * 2));
-			mustFree = 1;
-		    }
-		    for (i=0; i<l; i++) {
-			int32 codePoint = ((int32 *)cp)[i];
-
-			if (codePoint > 0xFFFF) {
-			    codePoint = 0xFFFF;
-			}
-			cp2[i].byte1 = (codePoint >> 8) & 0xFF;
-			cp2[i].byte2 = codePoint & 0xFF;
-		    }
-
-		    __ENTER_XLIB(1000 * __intVal(@global(XWorkstation:DefaultXLibTimeout)));
-		    if (opaque == true)
-			XDrawImageString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp2, l);
-		    else
-			XDrawString16(dpy, win, gc, __intVal(x), __intVal(y), (XChar2b *)cp2, l);
-		    LEAVE_XLIB();
-
-		    if (mustFree) {
-			free(cp2);
-		    }
-
-		    RETURN ( self );
-		}
-	    }
-	}
-    }
-#undef NLOCALBUFFER
-%}.
-
-    "x/y not integer, badGC or drawable, or not a string"
-    device primitiveFailedOrClosedConnection
-!
-
-displayDeviceXftString:aString from:index1 to:index2Arg x:drawX y:drawY opaque:opaque
-    "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
-     foreground and background characters.
-     If the coordinates are not integers, an error is triggered."
-
-    <context: #return>
-
-    |index2 bytesPerCharacter
-     clipX clipY clipW clipH
-     fgR fgG fgB fgA fgPixel bgR bgG bgB bgA bgPixel
-     displayId screen error stringLen
-     newXftDrawId pixmapDepth fontId|
-
-"/    device flushIfAppropriate.
-    displayId := device displayIdOrErrorIfBroken.
-
-    "limit the string len, otherwise bad output is generated"
-    stringLen := index2Arg - index1 + 1.
-    stringLen > 1000 "8000" ifTrue:[
-	index2 := index1 + 1000 "8000" - 1.
-    ]  ifFalse:[
-	stringLen <= 0 ifTrue:[^ self].
-	index2 := index2Arg.
-    ].
-    bytesPerCharacter := aString bytesPerCharacter.
-
-    clipRect notNil ifTrue:[
-	clipX := clipRect left.
-	clipY := clipRect top.
-	clipW := clipRect width.
-	clipH := clipRect height.
-"/clipW > 32767 ifTrue:['clipW > 32767: ' errorPrint. clipW errorPrintCR. clipW := 32767].
-"/(clipX > 16384 or:[clipX < -16384]) ifTrue:['clipX > 16384: ' errorPrint. clipX errorPrintCR.].
-	"/ YES YES YES: this MUST be transformed!!
-	"/ (see htmlView) fix the notebook, please.
-    ].
-
-    fgR := paint scaledRed.
-    fgR notNil ifTrue:[
-	fgG := paint scaledGreen.
-	fgB := paint scaledBlue.
-	fgA := paint scaledAlpha.
-    ] ifFalse:[
-	"/ when drawing into a pixmap...
-	fgPixel := paint colorId.
-	fgPixel == 0 ifTrue:[
-	    fgR := fgG := fgB := 0.
-	] ifFalse:[
-	    fgR := fgG := fgB := 16rFFFF.
-	].
-	fgA := 16rFFFF.
-    ].
-
-    opaque ifTrue:[
-	bgPaint isColor ifTrue:[
-	    bgR := bgPaint scaledRed.
-	    bgR notNil ifTrue:[
-		bgG := bgPaint scaledGreen.
-		bgB := bgPaint scaledBlue.
-		bgA := bgPaint scaledAlpha.
-	    ] ifFalse:[
-		"/ when drawing into a pixmap...
-		bgPixel := bgPaint colorId.
-		bgPixel == 0 ifTrue:[
-		    bgR := bgG := bgB := 0.
-		] ifFalse:[
-		    bgR := bgG := bgB := 16rFFFF.
-		].
-		bgA := 16rFFFF.
-	    ].
-	] ifFalse:[
-	    "images as background are not yet implemented"
-	    "/ #todo: fill background rectangle
-	    bgR := bgG := bgB := bgA := 16rFFFF.
-	].
-    ].
-
-    screen := device screen.
-    self isPixmap ifTrue:[
-	pixmapDepth := depth.
-    ].
-    fontId := font getXftFontId.
-
-%{ /* STACK: 64000 */
-#ifdef XFT
-    XftColor color;
-    XGlyphInfo extents;
-    XRectangle clipRX;
-    char *string;
-    int len;
-    int __bytesPerCharacter;
-    XftDraw *__xftDrawId;
-    XftFont *__xftFont;
-
-    if (!(__bothSmallInteger(drawX, drawY)
-	  && __bothSmallInteger(index1, index2)
-	  && __isSmallInteger(bytesPerCharacter)
-	  && (__isSmallInteger(fgPixel) || (__bothSmallInteger(fgR, fgG) && __bothSmallInteger(fgB, fgA)))
-	  && (opaque == false || __isSmallInteger(bgPixel) || (__bothSmallInteger(bgR, bgG) && __bothSmallInteger(bgB, bgA)))
-	  && __isNonNilObject(aString)
-	  && __isExternalAddress(displayId)
-	  && __isExternalAddressLike(fontId)
-    )) {
-	error = @symbol(badArgument);
-	goto out;
-    }
-
-    __xftFont = XFT_FONT(fontId);
-    __bytesPerCharacter = __intVal(bytesPerCharacter);
-
-    if (__INST(xftDrawId) != nil) {
-	__xftDrawId = __externalAddressVal(__INST(xftDrawId));
-    } else {
-	if (pixmapDepth != nil) {
-	    int __pixmapDepth = __intVal(pixmapDepth);
-
-	    if (__pixmapDepth == 1) {
-		__xftDrawId = XftDrawCreateBitmap(DISPLAY(displayId), DRAWABLE(__INST(drawableId)));
-	    } else {
-		__xftDrawId = XftDrawCreateAlpha(DISPLAY(displayId), DRAWABLE(__INST(drawableId)), __pixmapDepth);
-	    }
-	} else {
-	    __xftDrawId = XftDrawCreate(DISPLAY(displayId),
-					   DRAWABLE(__INST(drawableId)),
-					   DefaultVisual(DISPLAY(displayId), SCREEN(screen)),
-					   DefaultColormap(DISPLAY(displayId), SCREEN(screen)));
-	}
-	__INST(xftDrawId) = newXftDrawId = XFT_DRAW_HANDLE_NEW(__xftDrawId);
-	__STORE(self, newXftDrawId);
-    }
-
-    string = __stringVal(aString) + ((__intVal(index1) - 1 ) * __bytesPerCharacter);
-    len = __intVal(index2) - __intVal(index1) + 1;
-
-    if (clipX != nil) {
-	clipRX.x = __intVal(clipX);
-	clipRX.y = __intVal(clipY);
-	clipRX.width = __intVal(clipW);
-	clipRX.height = __intVal(clipH);
-	XftDrawSetClipRectangles(__xftDrawId, 0, 0, &clipRX, 1);
-    } else {
-	XftDrawSetClip(__xftDrawId, 0);
-    }
-
-    if (opaque == true) {
-	if (bgPixel != nil) {
-	    color.pixel = (unsigned long)__intVal(bgPixel);
-	}
-	color.color.red = __intVal(bgR);
-	color.color.green = __intVal(bgG);
-	color.color.blue = __intVal(bgB);
-	color.color.alpha = __intVal(bgA);
-
-	switch (__bytesPerCharacter) {
-	case 1:
-	    XftTextExtents8(DISPLAY(displayId), __xftFont, (FcChar8*)string, len, &extents);
-	    break;
-	case 2:
-	    XftTextExtents16(DISPLAY(displayId), __xftFont, (FcChar16*)string, len, &extents);
-	    break;
-	case 4:
-	    XftTextExtents32(DISPLAY(displayId), __xftFont, (FcChar32*)string, len, &extents);
-	    break;
-	}
-if (extents.width < 0) printf("width: %d  < 0\n", extents.width);
-
-	XftDrawRect(__xftDrawId, &color, __intVal(drawX) - extents.x, __intVal(drawY) - __xftFont->ascent, extents.width, __xftFont->height);
-    }
-    if (__isSmallInteger(fgPixel)) {
-	color.pixel = (unsigned long)__intVal(fgPixel);
-    }
-    color.color.red = __intVal(fgR);
-    color.color.green = __intVal(fgG);
-    color.color.blue = __intVal(fgB);
-    color.color.alpha = __intVal(fgA);
-
-    switch (__bytesPerCharacter) {
-    case 1:
-	XftDrawString8(__xftDrawId, &color,__xftFont,
-			__intVal(drawX),
-			__intVal(drawY),
-			(FcChar8*)string,
-			len);
-	break;
-
-    case 2:
-	XftDrawString16(__xftDrawId, &color, __xftFont,
-			__intVal(drawX),
-			__intVal(drawY),
-			(FcChar16*)string,
-			len);
-	break;
-
-    case 4:
-	XftDrawString32(__xftDrawId, &color, __xftFont,
-			__intVal(drawX),
-			__intVal(drawY),
-			(FcChar32*)string,
-			len);
-	break;
-
-    default:
-	error = @symbol(invalidStringSize);
-	goto out;
-    }
-
-out:;
-#endif
-%}.
-    error notNil ifTrue:[
-	self primitiveFailed: error.
-    ].
-! !
-
-!XWorkstation::xX11GraphicsContext methodsFor:'drawing'!
-
-XXclearDeviceRectangleX:x y:y width:width height:height
-    device clearRectangleX:x y:y width:width height:height in:drawableId with:gcId
-!
-
-XXclearRectangleX:x y:y width:w height:h
-    "draw a filled rectangle; apply transformation if nonNil"
-
-    |pX pY nW nH pO pC|
-
-    gcId isNil ifTrue:[
-	self initGC
-    ].
-    transformation notNil ifTrue:[
-	pO := transformation transformPoint:x@y.
-	pC := transformation transformPoint:(x+w-1)@(y+h-1).
-	pX := pO x.
-	pY := pO y.
-	nW := pC x - pX + 1.
-	nH := pC y - pY + 1.
-
-	nW < 0 ifTrue:[
-	      nW := nW abs.
-	      pX := pX - nW.
-	].
-	nH < 0 ifTrue:[
-	      nH := nH abs.
-	      pY := pY - nH.
-	].
-    ] ifFalse:[
-	pX := x.
-	pY := y.
-	nW := w.
-	nH := h.
-    ].
-    pX := pX rounded.
-    pY := pY rounded.
-    nW := nW rounded.
-    nH := nH rounded.
-
-    device
-	clearRectangleX:pX
-		     y:pY
-		 width:nW
-		height:nH
-		    in:drawableId with:gcId
-! !
-
-!XWorkstation::xX11GraphicsContext methodsFor:'view creation'!
-
-createBitmapFromArray:data width:width height:height
-    depth := 1.
-    super createBitmapFromArray:data width:width height:height
-!
-
-createPixmapWidth:w height:h depth:d
-    depth := d.
-    super createPixmapWidth:w height:h depth:d
-! !
-
 !XWorkstation class methodsFor:'documentation'!
 
 version