XWorkstation.st
changeset 963 45ebbbb40f38
parent 928 680dcd56df6b
child 972 ff1c744b8d88
--- a/XWorkstation.st	Fri Jul 19 18:38:40 1996 +0200
+++ b/XWorkstation.st	Fri Jul 19 18:39:53 1996 +0200
@@ -229,7 +229,7 @@
  * more than one display connection. (being fixed, new errorInterrupt mechanism
  * allows passing an additional argument, which is the displayID ...)
  */
-static
+
 __XErrorHandler__(dpy, event)
     Display *dpy;
     XErrorEvent *event;
@@ -254,7 +254,7 @@
 	fprintf(stderr, "XWORKSTAT: x-error cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n",
 			event->request_code, event->request_code, 
 			event->minor_code, event->minor_code, event->resourceid);
-	fprintf(stderr, "XWORKSTAT: x-error message is '%s'\n", lastErrorMsg);
+	fprintf(stderr, "XWORKSTAT: x-error message is [%d] '%s'\n", event->error_code, lastErrorMsg);
     }
 
     __errorInterruptWithIDAndParameter__(@symbol(DisplayError), __MKOBJ(dpy));
@@ -1047,7 +1047,7 @@
 
 	    if ((status == BitmapSuccess)  && newBitmap) {
 #ifdef COUNT_RESOURCES
-	        __cnt_bitmap++;
+		__cnt_bitmap++;
 #endif
 		w = __MKSMALLINT(b_width);
 		h = __MKSMALLINT(b_height);
@@ -1532,7 +1532,7 @@
 	    BEGIN_INTERRUPTSBLOCKED
 	    XFreeGC(myDpy, gc);
 #ifdef COUNT_RESOURCES
-            __cnt_gc--;
+	    __cnt_gc--;
 #endif
 	    END_INTERRUPTSBLOCKED
 	}
@@ -1547,17 +1547,17 @@
 %{  /* NOCONTEXT */
 
     if (__isExternalAddress(aDrawableId) && ISCONNECTED) {
-        Pixmap pix = _PixmapVal(aDrawableId);
-
-        if (pix) {
-            BEGIN_INTERRUPTSBLOCKED
-            XFreePixmap(myDpy, pix);
+	Pixmap pix = _PixmapVal(aDrawableId);
+
+	if (pix) {
+	    BEGIN_INTERRUPTSBLOCKED
+	    XFreePixmap(myDpy, pix);
 #ifdef COUNT_RESOURCES
-            __cnt_bitmap--;
+	    __cnt_bitmap--;
 #endif
-            END_INTERRUPTSBLOCKED
-        }
-        RETURN ( self );
+	    END_INTERRUPTSBLOCKED
+	}
+	RETURN ( self );
     }
 %}.
     self primitiveFailed
@@ -1566,16 +1566,16 @@
 destroyView:aView withId:aWindowId
 %{
     if (__isExternalAddress(aWindowId) && ISCONNECTED) {
-        Window win = _WindowVal(aWindowId);
-
-        if (win) {
-            BEGIN_INTERRUPTSBLOCKED
-            XDestroyWindow(myDpy, win);
+	Window win = _WindowVal(aWindowId);
+
+	if (win) {
+	    BEGIN_INTERRUPTSBLOCKED
+	    XDestroyWindow(myDpy, win);
 #ifdef COUNT_RESOURCES
-            __cnt_view--;
+	    __cnt_view--;
 #endif
-            END_INTERRUPTSBLOCKED
-        }
+	    END_INTERRUPTSBLOCKED
+	}
     }
 %}.
     self removeKnownView:aView
@@ -1621,7 +1621,7 @@
 			      0L, (XGCValues *)0);
 #ifdef COUNT_RESOURCES
 	if (gc)
-            __cnt_gc++;
+	    __cnt_gc++;
 #endif
 
 	END_INTERRUPTSBLOCKED
@@ -1654,73 +1654,73 @@
     int bytesPerRow;
 
     if (! ISCONNECTED) {
-        RETURN (nil);
+	RETURN (nil);
     }
     if (firstCall) {
-        for (index=0; index < 256; index++) {
-            reverseBitTable[index] = 0;
-            if (index & 128) reverseBitTable[index] |=   1;
-            if (index &  64) reverseBitTable[index] |=   2;
-            if (index &  32) reverseBitTable[index] |=   4;
-            if (index &  16) reverseBitTable[index] |=   8;
-            if (index &   8) reverseBitTable[index] |=  16;
-            if (index &   4) reverseBitTable[index] |=  32;
-            if (index &   2) reverseBitTable[index] |=  64;
-            if (index &   1) reverseBitTable[index] |= 128;
-        }
-        firstCall = 0;
+	for (index=0; index < 256; index++) {
+	    reverseBitTable[index] = 0;
+	    if (index & 128) reverseBitTable[index] |=   1;
+	    if (index &  64) reverseBitTable[index] |=   2;
+	    if (index &  32) reverseBitTable[index] |=   4;
+	    if (index &  16) reverseBitTable[index] |=   8;
+	    if (index &   8) reverseBitTable[index] |=  16;
+	    if (index &   4) reverseBitTable[index] |=  32;
+	    if (index &   2) reverseBitTable[index] |=  64;
+	    if (index &   1) reverseBitTable[index] |= 128;
+	}
+	firstCall = 0;
     }
 
     if (__bothSmallInteger(w, h) && _isNonNilObject(anArray)) {
-        newBitmap = (Pixmap)0;
-        b_width = __intVal(w);
-        b_height = __intVal(h);
-        bytesPerRow = (b_width + 7) / 8;
-        nBytes = b_height * bytesPerRow;
-        if (nBytes < sizeof(fastBits)) {
-            cp = b_bits = fastBits;
-            allocatedBits = 0;
-        } else {
-            cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
-            if (! cp) goto fail;
-        }
-
-        if (__qClass(anArray) == @global(Array)) {
-            index = 1;
-            op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
-            for (row = b_height; row; row--) {
-                for (col = bytesPerRow; col; col--) {
-                    num = *op++;
-                    if (! __isSmallInteger(num)) goto fail;
-                    bits = __intVal(num);
-                    *cp++ = reverseBitTable[bits];
-                }
-            }
-        } else {
-            if (__qClass(anArray) == @global(ByteArray)) {
-                pBits = __ByteArrayInstPtr(anArray)->ba_element;
-                for (col = b_height*bytesPerRow; col; col--) {
-                    *cp++ = reverseBitTable[*pBits++];
-                }
-            } else {
-                goto fail;
-            }
-        }
-
-        BEGIN_INTERRUPTSBLOCKED
-        newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
-                                               (char *)b_bits, 
-                                               b_width, b_height);
+	newBitmap = (Pixmap)0;
+	b_width = __intVal(w);
+	b_height = __intVal(h);
+	bytesPerRow = (b_width + 7) / 8;
+	nBytes = b_height * bytesPerRow;
+	if (nBytes < sizeof(fastBits)) {
+	    cp = b_bits = fastBits;
+	    allocatedBits = 0;
+	} else {
+	    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
+	    if (! cp) goto fail;
+	}
+
+	if (__qClass(anArray) == @global(Array)) {
+	    index = 1;
+	    op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
+	    for (row = b_height; row; row--) {
+		for (col = bytesPerRow; col; col--) {
+		    num = *op++;
+		    if (! __isSmallInteger(num)) goto fail;
+		    bits = __intVal(num);
+		    *cp++ = reverseBitTable[bits];
+		}
+	    }
+	} else {
+	    if (__qClass(anArray) == @global(ByteArray)) {
+		pBits = __ByteArrayInstPtr(anArray)->ba_element;
+		for (col = b_height*bytesPerRow; col; col--) {
+		    *cp++ = reverseBitTable[*pBits++];
+		}
+	    } else {
+		goto fail;
+	    }
+	}
+
+	BEGIN_INTERRUPTSBLOCKED
+	newBitmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
+					       (char *)b_bits, 
+					       b_width, b_height);
 #ifdef COUNT_RESOURCES
 	if (newBitmap)
 	    __cnt_bitmap++;
 #endif
 
-        END_INTERRUPTSBLOCKED
+	END_INTERRUPTSBLOCKED
 fail: ;
-        if (allocatedBits)
-            free(allocatedBits);
-        RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil );
+	if (allocatedBits)
+	    free(allocatedBits);
+	RETURN ( newBitmap ? __MKOBJ(newBitmap) : nil );
     }
 %}
 !
@@ -1950,28 +1950,28 @@
     if (__bothSmallInteger(r, g) 
      && __isSmallInteger(b)
      && ISCONNECTED) {
-        ecolor.red = __intVal(r);
-        ecolor.green= __intVal(g);
-        ecolor.blue = __intVal(b);
+	ecolor.red = __intVal(r);
+	ecolor.green= __intVal(g);
+	ecolor.blue = __intVal(b);
 #ifdef QUICK_TRUE_COLORS
-        if (__INST(visualType) == @symbol(TrueColor)) {
-            id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
-            id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask));
-            id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask));
-            RETURN ( __MKSMALLINT(id) );
-        }
+	if (__INST(visualType) == @symbol(TrueColor)) {
+	    id = ((ecolor.red >> (16 - __intVal(__INST(bitsRed)))) << __intVal(__INST(redShift))) & __intVal(__INST(redMask));
+	    id += ((ecolor.green >> (16 - __intVal(__INST(bitsGreen)))) << __intVal(__INST(greenShift))) & __intVal(__INST(greenMask));
+	    id += ((ecolor.blue >> (16 - __intVal(__INST(bitsBlue)))) << __intVal(__INST(blueShift))) & __intVal(__INST(blueMask));
+	    RETURN ( __MKSMALLINT(id) );
+	}
 #endif
-        dpy = myDpy;
-        BEGIN_INTERRUPTSBLOCKED
-        ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
-        END_INTERRUPTSBLOCKED
-        if (! ok) {
-            RETURN ( nil );
-        }
+	dpy = myDpy;
+	BEGIN_INTERRUPTSBLOCKED
+	ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
+	END_INTERRUPTSBLOCKED
+	if (! ok) {
+	    RETURN ( nil );
+	}
 #ifdef COUNT_RESOURCES
 	__cnt_color++;
 #endif
-        RETURN ( __MKSMALLINT(ecolor.pixel) );
+	RETURN ( __MKSMALLINT(ecolor.pixel) );
     }
 %}.
     self primitiveFailed.
@@ -1999,7 +1999,7 @@
 	BEGIN_INTERRUPTSBLOCKED
 	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
 #ifdef COUNT_RESOURCES
-        __cnt_color--;
+	__cnt_color--;
 #endif
 	END_INTERRUPTSBLOCKED
 	RETURN ( self );
@@ -2263,7 +2263,7 @@
 	newCursor = XCreateFontCursor(myDpy, __intVal(number));
 #ifdef COUNT_RESOURCES
 	if (newCursor)
-            __cnt_cursor++;
+	    __cnt_cursor++;
 #endif
 	END_INTERRUPTSBLOCKED
 	if (newCursor != (Cursor)0) {
@@ -2322,19 +2322,19 @@
 %{  /* NOCONTEXT */
 
     if (ISCONNECTED) {
-        if (__isExternalAddress(aCursorId)) {
-            Cursor curs = _CursorVal(aCursorId);
-
-            if (curs) {
-                BEGIN_INTERRUPTSBLOCKED
-                XFreeCursor(myDpy, curs);
+	if (__isExternalAddress(aCursorId)) {
+	    Cursor curs = _CursorVal(aCursorId);
+
+	    if (curs) {
+		BEGIN_INTERRUPTSBLOCKED
+		XFreeCursor(myDpy, curs);
 #ifdef COUNT_RESOURCES
-                __cnt_cursor--;
+		__cnt_cursor--;
 #endif
-                END_INTERRUPTSBLOCKED
-            }
-            RETURN ( self );
-        }
+		END_INTERRUPTSBLOCKED
+	    }
+	    RETURN ( self );
+	}
     }
 %}
 .
@@ -4337,36 +4337,36 @@
 
     aString isNil ifTrue:[^ false].
     (aString startsWith:'-') ifFalse:[
-        "
-         take care for ill-named fonts (i.e. pre Rel4 fonts)
-        "
-        ('*-*-[0-9]*' match:aString) ifTrue:[
-            end := aString indexOf:$- startingAt:1.
-            family := aString copyFrom:1 to:(end - 1).
-            start := end + 1.
-            end := aString indexOf:$- startingAt:start.
-            style := aString copyFrom:start to:(end - 1).
-            start := end + 1.
-            size := aString copyFrom:start.
-            size := (Number readFromString:size onError:[^false]).
-            aBlock value:family value:nil value:style value:size value:nil.
-            ^ true.
-        ].
-        ('*-[0-9]*' match:aString) ifTrue:[
-            "
-             something like lucidasans-24
-            "
-            end := aString indexOf:$- startingAt:1.
-
-            family := aString copyFrom:1 to:(end - 1).
-            start := end + 1.
-            size := aString copyFrom:start.
-            size := (Number readFromString:size onError:[^false]).
-            aBlock value:family value:nil value:nil value:size value:nil.
-            ^ true.
-        ].
-        aBlock value:aString value:nil value:nil value:nil value:nil.
-        ^ true.
+	"
+	 take care for ill-named fonts (i.e. pre Rel4 fonts)
+	"
+	('*-*-[0-9]*' match:aString) ifTrue:[
+	    end := aString indexOf:$- startingAt:1.
+	    family := aString copyFrom:1 to:(end - 1).
+	    start := end + 1.
+	    end := aString indexOf:$- startingAt:start.
+	    style := aString copyFrom:start to:(end - 1).
+	    start := end + 1.
+	    size := aString copyFrom:start.
+	    size := (Number readFromString:size onError:[^false]).
+	    aBlock value:family value:nil value:style value:size value:nil.
+	    ^ true.
+	].
+	('*-[0-9]*' match:aString) ifTrue:[
+	    "
+	     something like lucidasans-24
+	    "
+	    end := aString indexOf:$- startingAt:1.
+
+	    family := aString copyFrom:1 to:(end - 1).
+	    start := end + 1.
+	    size := aString copyFrom:start.
+	    size := (Number readFromString:size onError:[^false]).
+	    aBlock value:family value:nil value:nil value:size value:nil.
+	    ^ true.
+	].
+	aBlock value:aString value:nil value:nil value:nil value:nil.
+	^ true.
     ].
 
     end := aString indexOf:$- startingAt:2.
@@ -4388,15 +4388,15 @@
     (end == 0) ifTrue:[^ false].
     style := aString copyFrom:start to:(end - 1).
     (style = 'o') ifTrue:[
-        style := 'oblique'
+	style := 'oblique'
     ] ifFalse:[
-        (style = 'i') ifTrue:[
-            style := 'italic'
-        ] ifFalse:[
-            (style = 'r') ifTrue:[
-                style := 'roman'
-            ]
-        ]
+	(style = 'i') ifTrue:[
+	    style := 'italic'
+	] ifFalse:[
+	    (style = 'r') ifTrue:[
+		style := 'roman'
+	    ]
+	]
     ].
 
     start := end + 1.
@@ -4446,7 +4446,7 @@
     coding := aString copyFrom:start to:(end - 1).
 
     (moreStyle ~= 'normal' and:[moreStyle ~= '']) ifTrue:[
-        style := style, '-', moreStyle.
+	style := style, '-', moreStyle.
     ].
 
     aBlock value:family value:face value:style value:size value:coding.
@@ -4729,7 +4729,7 @@
 !
 
 getFontWithFamily:familyString face:faceString
-            style:styleArgString size:sizeArg encoding:encodingSym
+	    style:styleArgString size:sizeArg encoding:encodingSym
 
     "try to get the specified font, if not available, try next smaller
      font. Access to X-fonts by name is possible, by passing the X font name
@@ -4742,22 +4742,22 @@
 
     "special: if face is nil, allow access to X-fonts"
     faceString isNil ifTrue:[
-        sizeArg notNil ifTrue:[
-            theName := familyString , '-' , sizeArg printString
-        ] ifFalse:[
-            theName := familyString
-        ].
-        theName isNil ifTrue:[
-            "
-             mhmh - fall back to the default font
-            "
-            theName := 'fixed'
-        ].
-        theId := self createFontFor:theName.
-        theId isNil ifTrue:[
-            theId := self getDefaultFont
-        ].
-        ^ theId
+	sizeArg notNil ifTrue:[
+	    theName := familyString , '-' , sizeArg printString
+	] ifFalse:[
+	    theName := familyString
+	].
+	theName isNil ifTrue:[
+	    "
+	     mhmh - fall back to the default font
+	    "
+	    theName := 'fixed'
+	].
+	theId := self createFontFor:theName.
+	theId isNil ifTrue:[
+	    theId := self getDefaultFont
+	].
+	^ theId
     ].
 
     "/ spacing other than 'normal' is contained as last component
@@ -4765,58 +4765,58 @@
 
     ((styleString endsWith:'-narrow') 
      or:[styleString endsWith:'-semicondensed']) ifTrue:[
-        |i|
-        i := styleString lastIndexOf:$-.
-        spacing := styleString copyFrom:(i+1).
-        styleString := styleString copyTo:(i-1).
+	|i|
+	i := styleString lastIndexOf:$-.
+	spacing := styleString copyFrom:(i+1).
+	styleString := styleString copyTo:(i-1).
     ] ifFalse:[
-        spacing := 'normal'.
+	spacing := 'normal'.
     ].
 
     xlatedStyle := styleString.
     xlatedStyle notNil ifTrue:[
-        xlatedStyle := xlatedStyle first asString
+	xlatedStyle := xlatedStyle first asString
     ].
 
     id := self 
-            getFontWithFoundry:'*'
-            family:familyString asLowercase
-            weight:faceString
-            slant:xlatedStyle
-            spacing:spacing
-            pixelSize:nil
-            size:sizeArg 
-            registry:encodingSym
-            encoding:'*'.
+	    getFontWithFoundry:'*'
+	    family:familyString asLowercase
+	    weight:faceString
+	    slant:xlatedStyle
+	    spacing:spacing
+	    pixelSize:nil
+	    size:sizeArg 
+	    registry:encodingSym
+	    encoding:'*'.
 
     id isNil ifTrue:[
-        (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
-            "/ too stupid: encodings come in both cases
-            "/ and X does not ignore case
-            "/
-            id := self 
-                    getFontWithFoundry:'*'
-                    family:familyString asLowercase
-                    weight:faceString
-                    slant:xlatedStyle
-                    spacing:spacing
-                    pixelSize:nil
-                    size:sizeArg 
-                    registry:encodingSym asUppercase
-                    encoding:'*'.
-            id isNil ifTrue:[
-                id := self 
-                        getFontWithFoundry:'*'
-                        family:familyString asLowercase
-                        weight:faceString
-                        slant:xlatedStyle
-                        spacing:spacing
-                        pixelSize:nil
-                        size:sizeArg 
-                        registry:encodingSym asLowercase
-                        encoding:'*'.
-            ]
-        ]
+	(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
+	    "/ too stupid: encodings come in both cases
+	    "/ and X does not ignore case
+	    "/
+	    id := self 
+		    getFontWithFoundry:'*'
+		    family:familyString asLowercase
+		    weight:faceString
+		    slant:xlatedStyle
+		    spacing:spacing
+		    pixelSize:nil
+		    size:sizeArg 
+		    registry:encodingSym asUppercase
+		    encoding:'*'.
+	    id isNil ifTrue:[
+		id := self 
+			getFontWithFoundry:'*'
+			family:familyString asLowercase
+			weight:faceString
+			slant:xlatedStyle
+			spacing:spacing
+			pixelSize:nil
+			size:sizeArg 
+			registry:encodingSym asLowercase
+			encoding:'*'.
+	    ]
+	]
     ].
     ^ id
 
@@ -5107,7 +5107,7 @@
 	    BEGIN_INTERRUPTSBLOCKED
 	    XFreeFont(myDpy, f);
 #ifdef COUNT_RESOURCES
-            __cnt_font--;
+	    __cnt_font--;
 #endif
 	    END_INTERRUPTSBLOCKED
 	    RETURN ( self );
@@ -8057,22 +8057,22 @@
 
 %{
     if (__isExternalAddress(aWindowId)) {
-        XClassHint classhint;
-
-        classhint.res_class = classhint.res_name = 0;
-
-        if (__isString(wClass) || __isSymbol(wClass)) {
-            classhint.res_class = (char *)_stringVal(wClass);
-        } else if (wClass != nil)
-            goto error;
-
-        if (__isString(wName) || __isSymbol(wName)) {
-            classhint.res_name = (char *)_stringVal(wName);
-        } else if (wName != nil)
-            goto error;
-
-        XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint);
-        RETURN ( self );
+	XClassHint classhint;
+
+	classhint.res_class = classhint.res_name = 0;
+
+	if (__isString(wClass) || __isSymbol(wClass)) {
+	    classhint.res_class = (char *)_stringVal(wClass);
+	} else if (wClass != nil)
+	    goto error;
+
+	if (__isString(wName) || __isSymbol(wName)) {
+	    classhint.res_name = (char *)_stringVal(wName);
+	} else if (wName != nil)
+	    goto error;
+
+	XSetClassHint(myDpy, _WindowVal(aWindowId), &classhint);
+	RETURN ( self );
 error:;
     }
 %}.
@@ -8213,6 +8213,6 @@
 !XWorkstation  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.153 1996-07-05 16:20:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.154 1996-07-19 16:39:53 cg Exp $'
 ! !
 XWorkstation initialize!