XWorkstation.st
changeset 193 3abcc2ee1641
parent 190 4c49bdd5b80f
child 200 aa66f76133ab
equal deleted inserted replaced
192:13a9d4bafa7e 193:3abcc2ee1641
    14        instanceVariableNames:'screen
    14        instanceVariableNames:'screen
    15 			      hasShapeExtension hasFaxExtension hasShmExtension
    15 			      hasShapeExtension hasFaxExtension hasShmExtension
    16 			      hasDPSExtension hasMbufExtension hasXVideoExtension
    16 			      hasDPSExtension hasMbufExtension hasXVideoExtension
    17 			      hasSaveUnder hasPEXExtension hasImageExtension
    17 			      hasSaveUnder hasPEXExtension hasImageExtension
    18 			      hasInputExtension ignoreBackingStore
    18 			      hasInputExtension ignoreBackingStore
    19 			      blackpixel whitepixel redMask greenMask blueMask
    19 			      blackpixel whitepixel 
    20 			      protocolsAtom deleteWindowAtom saveYourselfAtom
    20 			      protocolsAtom deleteWindowAtom saveYourselfAtom
    21 			      quitAppAtom
    21 			      quitAppAtom
    22 			      primaryAtom secondaryAtom cutBuffer0Atom
    22 			      primaryAtom secondaryAtom cutBuffer0Atom
    23 			      stringAtom lengthAtom
    23 			      stringAtom lengthAtom
    24 			      listOfXFonts buttonsPressed
    24 			      listOfXFonts buttonsPressed
    34 
    34 
    35 XWorkstation comment:'
    35 XWorkstation comment:'
    36 COPYRIGHT (c) 1989 by Claus Gittinger
    36 COPYRIGHT (c) 1989 by Claus Gittinger
    37 	      All Rights Reserved
    37 	      All Rights Reserved
    38 
    38 
    39 $Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.61 1995-09-19 14:59:18 claus Exp $
    39 $Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.62 1995-10-23 16:59:47 cg Exp $
    40 '!
    40 '!
    41 
    41 
    42 !XWorkstation class methodsFor:'documentation'!
    42 !XWorkstation class methodsFor:'documentation'!
    43 
    43 
    44 copyright
    44 copyright
    55 "
    55 "
    56 !
    56 !
    57 
    57 
    58 version
    58 version
    59 "
    59 "
    60 $Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.61 1995-09-19 14:59:18 claus Exp $
    60 $Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.62 1995-10-23 16:59:47 cg Exp $
    61 "
    61 "
    62 !
    62 !
    63 
    63 
    64 documentation
    64 documentation
    65 "
    65 "
   522     int shapeEventBase, shapeErrorBase;
   522     int shapeEventBase, shapeErrorBase;
   523     int shmEventBase, shmErrorBase;
   523     int shmEventBase, shmErrorBase;
   524     int faxEventBase, faxErrorBase;
   524     int faxEventBase, faxErrorBase;
   525     char *type, *nm;
   525     char *type, *nm;
   526     int dummy;
   526     int dummy;
       
   527     int mask, shift, nBits;
   527 
   528 
   528     if (ISCONNECTED) {
   529     if (ISCONNECTED) {
   529 	BEGIN_INTERRUPTSBLOCKED
   530 	BEGIN_INTERRUPTSBLOCKED
   530 
   531 
   531 	_INST(screen) = _MKSMALLINT(scr = DefaultScreen(dpy));
   532 	_INST(screen) = _MKSMALLINT(scr = DefaultScreen(dpy));
   662 	}
   663 	}
   663 	_INST(bitsPerRGB) = _MKSMALLINT(visual->bits_per_rgb);
   664 	_INST(bitsPerRGB) = _MKSMALLINT(visual->bits_per_rgb);
   664 	_INST(redMask)   = _MKSMALLINT(visual->red_mask);
   665 	_INST(redMask)   = _MKSMALLINT(visual->red_mask);
   665 	_INST(greenMask) = _MKSMALLINT(visual->green_mask);
   666 	_INST(greenMask) = _MKSMALLINT(visual->green_mask);
   666 	_INST(blueMask)  = _MKSMALLINT(visual->blue_mask);
   667 	_INST(blueMask)  = _MKSMALLINT(visual->blue_mask);
       
   668 	switch (visual->class) {
       
   669 	    case TrueColor:
       
   670 		/* extract number of bits and shift counts */
       
   671 		mask = visual->red_mask;
       
   672 		shift = 0;
       
   673 		while (mask && ((mask & 1) == 0)) {
       
   674 		    mask >>= 1;
       
   675 		    shift++;
       
   676 		}
       
   677 		_INST(redShift) = __MKSMALLINT(shift);
       
   678 		nBits = 0;
       
   679 		while (mask) {
       
   680 		    mask >>= 1;
       
   681 		    nBits++;
       
   682 		}
       
   683 		_INST(bitsRed) = __MKSMALLINT(nBits);
       
   684 
       
   685 		mask = visual->green_mask;
       
   686 		shift = 0;
       
   687 		while (mask && ((mask & 1) == 0)) {
       
   688 		    mask >>= 1;
       
   689 		    shift++;
       
   690 		}
       
   691 		_INST(greenShift) = __MKSMALLINT(shift);
       
   692 		nBits = 0;
       
   693 		while (mask) {
       
   694 		    mask >>= 1;
       
   695 		    nBits++;
       
   696 		}
       
   697 		_INST(bitsGreen) = __MKSMALLINT(nBits);
       
   698 
       
   699 		mask = visual->blue_mask;
       
   700 		shift = 0;
       
   701 		while (mask && ((mask & 1) == 0)) {
       
   702 		    mask >>= 1;
       
   703 		    shift++;
       
   704 		}
       
   705 		_INST(blueShift) = __MKSMALLINT(shift);
       
   706 		nBits = 0;
       
   707 		while (mask) {
       
   708 		    mask >>= 1;
       
   709 		    nBits++;
       
   710 		}
       
   711 		_INST(bitsBlue) = __MKSMALLINT(nBits);
       
   712 		break;
       
   713 	}
   667 
   714 
   668 #ifndef XA_PRIMARY
   715 #ifndef XA_PRIMARY
   669 	_INST(primaryAtom) = MKOBJ( XInternAtom(dpy, "PRIMARY", True) );
   716 	_INST(primaryAtom) = MKOBJ( XInternAtom(dpy, "PRIMARY", True) );
   670 #else
   717 #else
   671 	_INST(primaryAtom) = MKOBJ( XA_PRIMARY );
   718 	_INST(primaryAtom) = MKOBJ( XA_PRIMARY );
  3087 createFontFor:aFontName
  3134 createFontFor:aFontName
  3088     "a basic method for X-font allocation; this method allows
  3135     "a basic method for X-font allocation; this method allows
  3089      any font to be aquired (even those not conforming to
  3136      any font to be aquired (even those not conforming to
  3090      standard naming conventions, such as cursor, fixed or k14)"
  3137      standard naming conventions, such as cursor, fixed or k14)"
  3091 
  3138 
  3092 %{  /* NOCONTEXT */
  3139 %{  /* UNLIMITEDSTACK */
       
  3140     /* UNLIMITEDSTACK STACK:100000 xxNOCONTEXT */
  3093 
  3141 
  3094     XFontStruct *newFont;
  3142     XFontStruct *newFont;
  3095 
  3143 
  3096     if (ISCONNECTED) {
  3144     if (ISCONNECTED) {
  3097 	if (__isString(aFontName) || __isSymbol(aFontName)) {
  3145 	if (__isString(aFontName) || __isSymbol(aFontName)) {
  3098 	    BEGIN_INTERRUPTSBLOCKED
  3146 	    BEGIN_INTERRUPTSBLOCKED
  3099 	    newFont = XLoadQueryFont(myDpy, (char *)_stringVal(aFontName));
  3147 	    newFont = XLoadQueryFont(myDpy, (char *)__stringVal(aFontName));
  3100 	    END_INTERRUPTSBLOCKED
  3148 	    END_INTERRUPTSBLOCKED
  3101 	    RETURN ( newFont ? MKOBJ(newFont) : nil );
  3149 	    RETURN ( newFont ? MKOBJ(newFont) : nil );
  3102 	}
  3150 	}
  3103     }
  3151     }
  3104 %}
  3152 %}.
  3105 .
       
  3106     self primitiveFailed.
       
  3107     ^ nil
  3153     ^ nil
  3108 !
  3154 !
  3109 
  3155 
  3110 getDefaultFont
  3156 getDefaultFont
  3111     "return a default font id - used when class Font cannot
  3157     "return a default font id - used when class Font cannot
  3805 
  3851 
  3806     Display *dpy = myDpy;
  3852     Display *dpy = myDpy;
  3807     unsigned long color;
  3853     unsigned long color;
  3808     int screen = _intVal(_INST(screen));
  3854     int screen = _intVal(_INST(screen));
  3809 
  3855 
       
  3856 #ifdef LATER
       
  3857     if (_INST(visualType) == @symbol(TrueColor)) {
       
  3858 	/* no need to do anything on TrueColor displays ... */
       
  3859 	RETURN (self);
       
  3860     }
       
  3861 #endif
  3810     if (__isSmallInteger(colorIndex) && ISCONNECTED) {
  3862     if (__isSmallInteger(colorIndex) && ISCONNECTED) {
  3811 	color = (long) _intVal(colorIndex);
  3863 	color = (long) _intVal(colorIndex);
  3812 	BEGIN_INTERRUPTSBLOCKED
  3864 	BEGIN_INTERRUPTSBLOCKED
  3813 	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
  3865 	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
  3814 	END_INTERRUPTSBLOCKED
  3866 	END_INTERRUPTSBLOCKED
  5340 
  5392 
  5341     numberOfPoints := aPolygon size.
  5393     numberOfPoints := aPolygon size.
  5342 %{
  5394 %{
  5343     GC gc = _GCVal(aGCId);
  5395     GC gc = _GCVal(aGCId);
  5344     Window win = _WindowVal(aDrawableId);
  5396     Window win = _WindowVal(aDrawableId);
  5345     extern OBJ Point;
  5397     extern OBJ Point, __AT_();
  5346     OBJ point, x, y;
  5398     OBJ point, x, y;
  5347     int i, num;
  5399     int i, num;
  5348     XPoint *points;
  5400     XPoint *points;
  5349     XPoint qPoints[100];
  5401     XPoint qPoints[100];
  5350 
  5402 
  5359 	    if (! points) goto fail;
  5411 	    if (! points) goto fail;
  5360 	} else
  5412 	} else
  5361 	    points = qPoints;
  5413 	    points = qPoints;
  5362 
  5414 
  5363 	for (i=0; i<num; i++) {
  5415 	for (i=0; i<num; i++) {
  5364 	    point = _AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1));
  5416 	    point = __AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1));
  5365 	    if (! __isPoint(point)) goto fail;
  5417 	    if (! __isPoint(point)) goto fail;
  5366 	    x = _point_X(point);
  5418 	    x = _point_X(point);
  5367 	    y = _point_Y(point);
  5419 	    y = _point_Y(point);
  5368 	    if (! __bothSmallInteger(x, y))
  5420 	    if (! __bothSmallInteger(x, y))
  5369 		goto fail;
  5421 		goto fail;
  5599     numberOfPoints := aPolygon size.
  5651     numberOfPoints := aPolygon size.
  5600 %{
  5652 %{
  5601     GC gc = _GCVal(aGCId);
  5653     GC gc = _GCVal(aGCId);
  5602     Window win = _WindowVal(aDrawableId);
  5654     Window win = _WindowVal(aDrawableId);
  5603     OBJ point, x, y;
  5655     OBJ point, x, y;
  5604     extern OBJ Point;
  5656     extern OBJ Point, __AT_();
  5605     int i, num;
  5657     int i, num;
  5606     XPoint *points;
  5658     XPoint *points;
  5607     XPoint qPoints[100];
  5659     XPoint qPoints[100];
  5608 
  5660 
  5609     if (__bothSmallInteger(aGCId, aDrawableId)
  5661     if (__bothSmallInteger(aGCId, aDrawableId)
  5619 	    points = (XPoint *) malloc(sizeof(XPoint) * num);
  5671 	    points = (XPoint *) malloc(sizeof(XPoint) * num);
  5620 	    if (! points) goto fail;
  5672 	    if (! points) goto fail;
  5621 	} else
  5673 	} else
  5622 	    points = qPoints;
  5674 	    points = qPoints;
  5623 	for (i=0; i<num; i++) {
  5675 	for (i=0; i<num; i++) {
  5624 	    point = _AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1));
  5676 	    point = __AT_(aPolygon COMMA_CON, _MKSMALLINT(i+1));
  5625 	    if (! __isPoint(point)) goto fail;
  5677 	    if (! __isPoint(point)) goto fail;
  5626 	    x = _point_X(point);
  5678 	    x = _point_X(point);
  5627 	    y = _point_Y(point);
  5679 	    y = _point_Y(point);
  5628 	    if (! __bothSmallInteger(x, y))
  5680 	    if (! __bothSmallInteger(x, y))
  5629 		goto fail;
  5681 		goto fail;
  5764 		image.bytes_per_line = _intVal(imageWidth)*2;
  5816 		image.bytes_per_line = _intVal(imageWidth)*2;
  5765 		break;
  5817 		break;
  5766 	    case 24:
  5818 	    case 24:
  5767 		image.bytes_per_line = _intVal(imageWidth)*3;
  5819 		image.bytes_per_line = _intVal(imageWidth)*3;
  5768 		break;
  5820 		break;
       
  5821 	    case 32:
       
  5822 		image.bytes_per_line = _intVal(imageWidth)*4;
       
  5823 		break;
  5769 	    default:
  5824 	    default:
  5770 #ifdef ARGDEBUG
  5825 #ifdef ARGDEBUG
  5771 		printf("bits_per_pixel=%d\n",image.bits_per_pixel);
  5826 		printf("bits_per_pixel=%d\n",image.bits_per_pixel);
  5772 #endif
  5827 #endif
  5773 		goto fail;
  5828 		goto fail;
  5779 					_intVal(dstx), _intVal(dsty),
  5834 					_intVal(dstx), _intVal(dsty),
  5780 					_intVal(w), _intVal(h));
  5835 					_intVal(w), _intVal(h));
  5781 	RETURN ( true );
  5836 	RETURN ( true );
  5782     }
  5837     }
  5783 #ifdef ARGDEBUG
  5838 #ifdef ARGDEBUG
  5784     if (! __isSmallInteger(aGCId)) printf("GC\n");
  5839     if (!! __isSmallInteger(aGCId)) printf("GC\n");
  5785     if (! __isSmallInteger(aDrawableId)) printf("aDrawableId\n");
  5840     if (!! __isSmallInteger(aDrawableId)) printf("aDrawableId\n");
  5786     if (! __isSmallInteger(srcx)) printf("srcx\n");
  5841     if (!! __isSmallInteger(srcx)) printf("srcx\n");
  5787     if (! __isSmallInteger(srcy)) printf("srcy\n");
  5842     if (!! __isSmallInteger(srcy)) printf("srcy\n");
  5788     if (! __isSmallInteger(dstx)) printf("dstx\n");
  5843     if (!! __isSmallInteger(dstx)) printf("dstx\n");
  5789     if (! __isSmallInteger(dsty)) printf("dsty\n");
  5844     if (!! __isSmallInteger(dsty)) printf("dsty\n");
  5790     if (! __isSmallInteger(w)) printf("w\n");
  5845     if (!! __isSmallInteger(w)) printf("w\n");
  5791     if (! __isSmallInteger(h)) printf("h\n");
  5846     if (!! __isSmallInteger(h)) printf("h\n");
  5792     if (! __isSmallInteger(imageWidth)) printf("imageWidth\n");
  5847     if (!! __isSmallInteger(imageWidth)) printf("imageWidth\n");
  5793     if (! __isSmallInteger(imageHeight)) printf("imageHeight\n");
  5848     if (!! __isSmallInteger(imageHeight)) printf("imageHeight\n");
  5794     if (! __isSmallInteger(imageDepth)) printf("imageDepth\n");
  5849     if (!! __isSmallInteger(imageDepth)) printf("imageDepth\n");
  5795     if (! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n");
  5850     if (!! __isSmallInteger(bitsPerPixel)) printf("bitsPerPixel\n");
  5796     if (! __isByteArray(imageBits)) printf("imageBits\n");
  5851     if (!! __isByteArray(imageBits)) printf("imageBits\n");
  5797 #endif
  5852 #endif
  5798 
  5853 
  5799 fail: ;
  5854 fail: ;
  5800 %}
  5855 %}
  5801 .
  5856 .
  6031     char *keySymString;
  6086     char *keySymString;
  6032     char keySymStringBuffer[32];
  6087     char keySymStringBuffer[32];
  6033     static unsigned multiClickTime = 0;
  6088     static unsigned multiClickTime = 0;
  6034     unsigned nextMultiClickTime;
  6089     unsigned nextMultiClickTime;
  6035     OBJ upDown;
  6090     OBJ upDown;
       
  6091     extern OBJ __AT_();
  6036 
  6092 
  6037     struct inlineCache *ipS;
  6093     struct inlineCache *ipS;
  6038     static struct inlineCache vid = _ILC1;
  6094     static struct inlineCache vid = _ILC1;
  6039 
  6095 
  6040     static struct inlineCache expS = _ILC5;
  6096     static struct inlineCache expS = _ILC5;
  6236 	     */
  6292 	     */
  6237 	    if (_INST(metaDown) == true)
  6293 	    if (_INST(metaDown) == true)
  6238 		butt = _MKSMALLINT(2);
  6294 		butt = _MKSMALLINT(2);
  6239 	    else 
  6295 	    else 
  6240 #endif
  6296 #endif
  6241 		butt = _AT_(_INST(buttonTranslation), butt);
  6297 		butt = __AT_(_INST(buttonTranslation), butt);
  6242             
  6298             
  6243 
  6299 
  6244 	    (*(*ipS).ilc_func)(self, 
  6300 	    (*(*ipS).ilc_func)(self, 
  6245 			       symS
  6301 			       symS
  6246 			       COMMA_CON, nil, ipS,
  6302 			       COMMA_CON, nil, ipS,
  6651 eventPending:anEventSymbol for:aWindowIdOrNil
  6707 eventPending:anEventSymbol for:aWindowIdOrNil
  6652     "return true, if a specific event is pending"
  6708     "return true, if a specific event is pending"
  6653 
  6709 
  6654     ^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil
  6710     ^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil
  6655 ! !
  6711 ! !
  6656