diff -r c040194dcab8 -r bc581886fe8f XWorkstation.st --- a/XWorkstation.st Wed Sep 18 12:28:04 1996 +0200 +++ b/XWorkstation.st Wed Sep 18 12:30:16 1996 +0200 @@ -182,7 +182,7 @@ needUnblock = 1; \ } -# define END_INTERRUPTSBLOCKED \ +# define END_INTERRUPTSBLOCKED_NOW \ __thisContext = __thisContext; \ __thisContext__ = 0; \ if (needUnblock) { \ @@ -190,6 +190,10 @@ } \ } +# define END_INTERRUPTSBLOCKED + __thisContext = __thisContext; \ + __thisContext__ = 0; + #endif %} ! ! @@ -224,7 +228,9 @@ Display *dpy; XErrorEvent *event; { - XGetErrorText(dpy, event->error_code, lastErrorMsg, 80); + XGetErrorText(dpy, event->error_code, lastErrorMsg, 79); + lastErrorMsg[79] = '\0'; + if (lastErrorMsg[0] == '\0') { sprintf(lastErrorMsg, "code: %d", event->error_code); } @@ -1745,7 +1751,7 @@ (unsigned char**) &newRoot ) == Success && newRoot) { vRootWin = *newRoot; - XFree(newRoot); /* XXX */ + XFree(newRoot); /* XXX */ break; } } @@ -1947,14 +1953,13 @@ |val| self getScaledRGBFromName:colorName into:[:r :g :b | - r isNil ifTrue:[ - val := aBlock value:nil value:nil value:nil - ] ifFalse:[ - val := aBlock - value:(r * 100.0 / 16rFFFF) - value:(g * 100.0 / 16rFFFF) - value:(b * 100.0 / 16rFFFF) - ] + r isNil ifTrue:[ + ^ super getRGBFromName:colorName into:aBlock + ]. + val := aBlock + value:(r * 100.0 / 16rFFFF) + value:(g * 100.0 / 16rFFFF) + value:(b * 100.0 / 16rFFFF) ]. ^ val @@ -2056,22 +2061,22 @@ aStream isNil ifTrue:[^ nil]. list := OrderedCollection new. [aStream atEnd] whileFalse:[ - line := aStream nextLine. - line notNil ifTrue:[ - "skip the r/g/b numbers" - index := 1. - [(line at:index) isSeparator] whileTrue:[index := index + 1]. - [(line at:index) isDigit] whileTrue:[index := index + 1]. - [(line at:index) isSeparator] whileTrue:[index := index + 1]. - [(line at:index) isDigit] whileTrue:[index := index + 1]. - [(line at:index) isSeparator] whileTrue:[index := index + 1]. - [(line at:index) isDigit] whileTrue:[index := index + 1]. - [(line at:index) isSeparator] whileTrue:[index := index + 1]. - colorName := line copyFrom:index. - ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ - list add:colorName - ] - ] + line := aStream nextLine. + line notNil ifTrue:[ + "skip the r/g/b numbers" + index := 1. + [(line at:index) isSeparator] whileTrue:[index := index + 1]. + [(line at:index) isDigit] whileTrue:[index := index + 1]. + [(line at:index) isSeparator] whileTrue:[index := index + 1]. + [(line at:index) isDigit] whileTrue:[index := index + 1]. + [(line at:index) isSeparator] whileTrue:[index := index + 1]. + [(line at:index) isDigit] whileTrue:[index := index + 1]. + [(line at:index) isSeparator] whileTrue:[index := index + 1]. + colorName := line copyFrom:index. + ((colorName occurrencesOf:(Character space)) == 0) ifTrue:[ + list add:colorName + ] + ] ]. aStream close. ^ list sort @@ -3183,17 +3188,17 @@ eB = __INST(eventBuffer); if (__isByteArray(eB)) { - ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); + ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element); } else { - printf("DISPLAY: no eventBuffer\n"); - RETURN (false); + printf("DISPLAY: no eventBuffer\n"); + RETURN (false); } windowID = __MKOBJ(ae->window); theView = (*vid.ilc_func)(self, @symbol(viewFromId:) COMMA_CON, nil, &vid, windowID); if ((theView == nil) && (ev->type != MappingNotify)) { - RETURN (nil); + RETURN (nil); } /* @@ -3213,217 +3218,217 @@ eventType = __MKSMALLINT(ev->type); #endif switch (ev->type) { - case KeyRelease: - symS = @symbol(keyRelease:x:y:view:); - ipS = &skrS; - upDown = false; - goto keyPressAndRelease; - - case KeyPress: - symS = @symbol(keyPress:x:y:view:); - ipS = &skpS; - upDown = true; - /* FALL INTO */ - - keyPressAndRelease: - __INST(eventRootX) = __MKSMALLINT(ke->x_root); - __INST(eventRootY) = __MKSMALLINT(ke->y_root); + case KeyRelease: + symS = @symbol(keyRelease:x:y:view:); + ipS = &skrS; + upDown = false; + goto keyPressAndRelease; + + case KeyPress: + symS = @symbol(keyPress:x:y:view:); + ipS = &skpS; + upDown = true; + /* FALL INTO */ + + keyPressAndRelease: + __INST(eventRootX) = __MKSMALLINT(ke->x_root); + __INST(eventRootY) = __MKSMALLINT(ke->y_root); #ifdef OLD - __INST(altDown) = (ke->state & Mod2Mask) ? true : false; - __INST(metaDown) = (ke->state & Mod1Mask) ? true : false; + __INST(altDown) = (ke->state & Mod2Mask) ? true : false; + __INST(metaDown) = (ke->state & Mod1Mask) ? true : false; #else - __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; - __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; + __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; + __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; #endif - __INST(shiftDown) = (ke->state & ShiftMask) ? true : false; - __INST(ctrlDown) = (ke->state & ControlMask) ? true : false; - - arg = nil; - nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); - if (nchars - && (((buffer[0] >= ' ') && (buffer[0] <= '~')) - || (buffer[0] >= 0x80))) { - arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; - keySymString = NULL; - } else { + __INST(shiftDown) = (ke->state & ShiftMask) ? true : false; + __INST(ctrlDown) = (ke->state & ControlMask) ? true : false; + + arg = nil; + nchars = XLookupString(ke, (char *)buffer, sizeof(buffer), &keySym, NULL); + if (nchars + && (((buffer[0] >= ' ') && (buffer[0] <= '~')) + || (buffer[0] >= 0x80))) { + arg = _MKCHARACTER(buffer[0])/* *_CharacterTable[buffer[0]] */; + keySymString = NULL; + } else { #ifdef OLD - switch (keySym) { - case XK_Control_L: - case XK_Control_R: - __INST(ctrlDown) = upDown; - break; - case XK_Shift_L: - case XK_Shift_R: - __INST(shiftDown) = upDown; - break; - case XK_Meta_L: - case XK_Meta_R: - __INST(metaDown) = upDown; - break; - case XK_Alt_L: - case XK_Alt_R: - __INST(altDown) = upDown; - break; - } + switch (keySym) { + case XK_Control_L: + case XK_Control_R: + __INST(ctrlDown) = upDown; + break; + case XK_Shift_L: + case XK_Shift_R: + __INST(shiftDown) = upDown; + break; + case XK_Meta_L: + case XK_Meta_R: + __INST(metaDown) = upDown; + break; + case XK_Alt_L: + case XK_Alt_R: + __INST(altDown) = upDown; + break; + } #endif - keySymString = XKeysymToString(keySym); - if (keySymString) { + keySymString = XKeysymToString(keySym); + if (keySymString) { #ifdef OLD - if (keySymString[0] == 'D') { - /* - * remove underscore, dont want it in symbols - */ - if (strcmp(keySymString, "Delete_line") == 0) { - keySymString = "DeleteLine"; - } else if (strcmp(keySymString, "Delete_word") == 0) { - keySymString = "DeleteWord"; - } - } - /* - * make names compatible - */ - if (strcmp(keySymString, "Down") == 0) { - keySymString = "CursorDown"; - } else if (strcmp(keySymString, "Up") == 0) { - keySymString = "CursorUp"; - } else if (strcmp(keySymString, "Left") == 0) { - keySymString = "CursorLeft"; - } else if (strcmp(keySymString, "Right") == 0) { - keySymString = "CursorRight"; - } - arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); + if (keySymString[0] == 'D') { + /* + * remove underscore, dont want it in symbols + */ + if (strcmp(keySymString, "Delete_line") == 0) { + keySymString = "DeleteLine"; + } else if (strcmp(keySymString, "Delete_word") == 0) { + keySymString = "DeleteWord"; + } + } + /* + * make names compatible + */ + if (strcmp(keySymString, "Down") == 0) { + keySymString = "CursorDown"; + } else if (strcmp(keySymString, "Up") == 0) { + keySymString = "CursorUp"; + } else if (strcmp(keySymString, "Left") == 0) { + keySymString = "CursorLeft"; + } else if (strcmp(keySymString, "Right") == 0) { + keySymString = "CursorRight"; + } + arg = __MKSYMBOL(keySymString, (OBJ *)0, __context); #else - __PROTECT__(theView); - arg = __MKSTRING(keySymString COMMA_CON); - __UNPROTECT__(theView); + __PROTECT__(theView); + arg = __MKSTRING(keySymString COMMA_CON); + __UNPROTECT__(theView); #endif - } - } - - if (arg == nil) { - /* happens sometimes (alt-graph on sun has no keysym) */ - break; - } - - (*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, - arg, - __MKSMALLINT(ke->x), - __MKSMALLINT(ke->y), - theView); - break; - - case ButtonPress: - __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); - __INST(eventRootX) = __MKSMALLINT(be->x_root); - __INST(eventRootY) = __MKSMALLINT(be->y_root); - - if (__isSmallInteger(__INST(multiClickTimeDelta))) - nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); - else - nextMultiClickTime = 0; - - if (multiClickTime) { - if (be->time < multiClickTime) { - multiClickTime = nextMultiClickTime; - ipS = &bmpS; - symS = @symbol(buttonMultiPress:x:y:view:); - goto sendButtonEvent; - break; - } - } - multiClickTime = nextMultiClickTime; + } + } + + if (arg == nil) { + /* happens sometimes (alt-graph on sun has no keysym) */ + break; + } + + (*(*ipS).ilc_func)(self, symS COMMA_CON, nil, ipS, + arg, + __MKSMALLINT(ke->x), + __MKSMALLINT(ke->y), + theView); + break; + + case ButtonPress: + __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) | (1 << be->button)); + __INST(eventRootX) = __MKSMALLINT(be->x_root); + __INST(eventRootY) = __MKSMALLINT(be->y_root); + + if (__isSmallInteger(__INST(multiClickTimeDelta))) + nextMultiClickTime = be->time + __intVal(__INST(multiClickTimeDelta)); + else + nextMultiClickTime = 0; + + if (multiClickTime) { + if (be->time < multiClickTime) { + multiClickTime = nextMultiClickTime; + ipS = &bmpS; + symS = @symbol(buttonMultiPress:x:y:view:); + goto sendButtonEvent; + break; + } + } + multiClickTime = nextMultiClickTime; #ifdef NO_LONGER - if (be->state & ShiftMask) { - ipS = &bspS; - symS = @symbol(buttonShiftPress:x:y:view:); - goto sendButtonEvent; - } + if (be->state & ShiftMask) { + ipS = &bspS; + symS = @symbol(buttonShiftPress:x:y:view:); + goto sendButtonEvent; + } #endif - ipS = &bpS; - symS = @symbol(buttonPress:x:y:view:); - goto sendButtonEvent; - - /* NOT REACHED */ - - case ButtonRelease: - __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); - __INST(eventRootX) = __MKSMALLINT(be->x_root); - __INST(eventRootY) = __MKSMALLINT(be->y_root); - ipS = &brS; - symS = @symbol(buttonRelease:x:y:view:); - /* fall into */ - - sendButtonEvent: - butt = __MKSMALLINT(be->button); + ipS = &bpS; + symS = @symbol(buttonPress:x:y:view:); + goto sendButtonEvent; + + /* NOT REACHED */ + + case ButtonRelease: + __INST(buttonsPressed) = __MKSMALLINT(__intVal(__INST(buttonsPressed)) & ~(1 << be->button)); + __INST(eventRootX) = __MKSMALLINT(be->x_root); + __INST(eventRootY) = __MKSMALLINT(be->y_root); + ipS = &brS; + symS = @symbol(buttonRelease:x:y:view:); + /* fall into */ + + sendButtonEvent: + butt = __MKSMALLINT(be->button); #ifdef NOTDEF - /* - * this allows operation with single button mouses: meta-click is always Button 2 - */ - if (__INST(metaDown) == true) - butt = __MKSMALLINT(2); - else + /* + * this allows operation with single button mouses: meta-click is always Button 2 + */ + if (__INST(metaDown) == true) + butt = __MKSMALLINT(2); + else #endif - butt = __AT_(__INST(buttonTranslation), butt); - - - (*(*ipS).ilc_func)(self, - symS - COMMA_CON, nil, ipS, - butt, - __MKSMALLINT(ke->x), - __MKSMALLINT(ke->y), - theView); - break; - - case MotionNotify: - if (__INST(motionEventCompression) != false) { - while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; - } - - __INST(eventRootX) = __MKSMALLINT(me->x_root); - __INST(eventRootY) = __MKSMALLINT(me->y_root); + butt = __AT_(__INST(buttonTranslation), butt); + + + (*(*ipS).ilc_func)(self, + symS + COMMA_CON, nil, ipS, + butt, + __MKSMALLINT(ke->x), + __MKSMALLINT(ke->y), + theView); + break; + + case MotionNotify: + if (__INST(motionEventCompression) != false) { + while (XCheckWindowEvent(dpy, me->window, ANYBUTTON, ev)) ;; + } + + __INST(eventRootX) = __MKSMALLINT(me->x_root); + __INST(eventRootY) = __MKSMALLINT(me->y_root); #ifdef OLD - __INST(altDown) = (me->state & Mod2Mask) ? true : false; - __INST(metaDown) = (me->state & Mod1Mask) ? true : false; + __INST(altDown) = (me->state & Mod2Mask) ? true : false; + __INST(metaDown) = (me->state & Mod1Mask) ? true : false; #else - __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; - __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; + __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; + __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; #endif - __INST(shiftDown) = (me->state & ShiftMask) ? true : false; - __INST(ctrlDown) = (me->state & ControlMask) ? true : false; - - (*motS.ilc_func)(self, - @symbol(buttonMotion:x:y:view:) - COMMA_CON, nil, &motS, - __MKSMALLINT(me->state), - __MKSMALLINT(me->x), - __MKSMALLINT(me->y), - theView); - break; - - case FocusIn: - (*focInS.ilc_func)(self, - @symbol(focusInView:) - COMMA_CON, nil, &focInS, - theView); - break; - - case FocusOut: - (*focOutS.ilc_func)(self, - @symbol(focusOutView:) - COMMA_CON, nil, &focOutS, - theView); - break; - - case EnterNotify: + __INST(shiftDown) = (me->state & ShiftMask) ? true : false; + __INST(ctrlDown) = (me->state & ControlMask) ? true : false; + + (*motS.ilc_func)(self, + @symbol(buttonMotion:x:y:view:) + COMMA_CON, nil, &motS, + __MKSMALLINT(me->state), + __MKSMALLINT(me->x), + __MKSMALLINT(me->y), + theView); + break; + + case FocusIn: + (*focInS.ilc_func)(self, + @symbol(focusInView:) + COMMA_CON, nil, &focInS, + theView); + break; + + case FocusOut: + (*focOutS.ilc_func)(self, + @symbol(focusOutView:) + COMMA_CON, nil, &focOutS, + theView); + break; + + case EnterNotify: #ifdef OLD - __INST(altDown) = (ewe->state & Mod2Mask) ? true : false; - __INST(metaDown) = (ewe->state & Mod1Mask) ? true : false; + __INST(altDown) = (ewe->state & Mod2Mask) ? true : false; + __INST(metaDown) = (ewe->state & Mod1Mask) ? true : false; #else - __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; - __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; + __INST(altDown) = (ke->state & __intVal(__INST(altModifierMask))) ? true : false; + __INST(metaDown) = (ke->state & __intVal(__INST(metaModifierMask))) ? true : false; #endif __INST(shiftDown) = (ewe->state & ShiftMask) ? true : false; __INST(ctrlDown) = (ewe->state & ControlMask) ? true : false; @@ -4501,11 +4506,11 @@ f = _FontVal(fontId); if (f) { #ifdef NOTDEF - char *cp; - XFontProp *prop; - - n = f->n_properties; - prop = f->properties; + char *cp; + XFontProp *prop; + + n = f->n_properties; + prop = f->properties; if (prop) { while (n--) { @@ -4521,29 +4526,29 @@ } #endif - avgAscent = __MKSMALLINT(f->ascent); - avgDescent = __MKSMALLINT(f->descent); - maxAscent = __MKSMALLINT(f->max_bounds.ascent); - maxDescent = __MKSMALLINT(f->max_bounds.descent); - minWidth = __MKSMALLINT(f->min_bounds.width); - maxWidth = __MKSMALLINT(f->max_bounds.width); - BEGIN_INTERRUPTSBLOCKED - len = XTextWidth(f, " ", 1); - END_INTERRUPTSBLOCKED - avgWidth = __MKSMALLINT( len ); + avgAscent = __MKSMALLINT(f->ascent); + avgDescent = __MKSMALLINT(f->descent); + maxAscent = __MKSMALLINT(f->max_bounds.ascent); + maxDescent = __MKSMALLINT(f->max_bounds.descent); + minWidth = __MKSMALLINT(f->min_bounds.width); + maxWidth = __MKSMALLINT(f->max_bounds.width); + BEGIN_INTERRUPTSBLOCKED + len = XTextWidth(f, " ", 1); + END_INTERRUPTSBLOCKED + avgWidth = __MKSMALLINT( len ); } } } %}. encoding := self encodingOf:fontId. aBlock value:encoding - value:avgAscent - value:avgDescent - value:maxAscent - value:maxDescent - value:minWidth - value:maxWidth - value:avgWidth + value:avgAscent + value:avgDescent + value:maxAscent + value:maxDescent + value:minWidth + value:maxWidth + value:avgWidth ! fontResolutionOf:fontId @@ -4557,41 +4562,41 @@ XFontStruct *f; if (ISCONNECTED) { - if (__isExternalAddress(fontId)) { - f = _FontVal(fontId); - if (f) { - char *cp; - XFontProp *prop; - Atom resolutionXAtom, resolutionYAtom; - int n; - - n = f->n_properties; - prop = f->properties; - - if (prop) { - resolutionXAtom = XInternAtom(myDpy, "RESOLUTION_X", True); - resolutionYAtom = XInternAtom(myDpy, "RESOLUTION_Y", True); - - while (n--) { - if (prop->name == resolutionXAtom) { - resX = __MKSMALLINT(prop->card32); - } else if (prop->name == resolutionYAtom) { - resY = __MKSMALLINT(prop->card32); - } else if (prop->name == XA_RESOLUTION) { - res = __MKSMALLINT(prop->card32); - } - prop++; - } - } - } - } + if (__isExternalAddress(fontId)) { + f = _FontVal(fontId); + if (f) { + char *cp; + XFontProp *prop; + Atom resolutionXAtom, resolutionYAtom; + int n; + + n = f->n_properties; + prop = f->properties; + + if (prop) { + resolutionXAtom = XInternAtom(myDpy, "RESOLUTION_X", True); + resolutionYAtom = XInternAtom(myDpy, "RESOLUTION_Y", True); + + while (n--) { + if (prop->name == resolutionXAtom) { + resX = __MKSMALLINT(prop->card32); + } else if (prop->name == resolutionYAtom) { + resY = __MKSMALLINT(prop->card32); + } else if (prop->name == XA_RESOLUTION) { + res = __MKSMALLINT(prop->card32); + } + prop++; + } + } + } + } } %}. (resX notNil and:[resY notNil]) ifTrue:[ - ^ resX @ resY + ^ resX @ resY ]. res notNil ifTrue:[ - ^ res @ res + ^ res @ res ]. ^ self resolution ! @@ -5018,13 +5023,13 @@ if (__isExternalAddress(aFontId)) { f = _FontVal(aFontId); if (f) { - BEGIN_INTERRUPTSBLOCKED - XFreeFont(myDpy, f); + BEGIN_INTERRUPTSBLOCKED + XFreeFont(myDpy, f); #ifdef COUNT_RESOURCES - __cnt_font--; + __cnt_font--; #endif - END_INTERRUPTSBLOCKED - RETURN ( self ); + END_INTERRUPTSBLOCKED + RETURN ( self ); } } } @@ -7115,7 +7120,7 @@ cp2 = cp + nread; } if (! cp) { - XFree(data); + XFree(data); goto fail; } @@ -8133,6 +8138,6 @@ !XWorkstation class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.173 1996-09-16 15:29:45 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.174 1996-09-18 10:30:16 cg Exp $' ! ! XWorkstation initialize!