XWorkstation.st
changeset 1207 274dbb13f15a
parent 1206 cbb8c32c4b48
child 1209 98d9f8a5a2a6
equal deleted inserted replaced
1206:cbb8c32c4b48 1207:274dbb13f15a
   887      We return nil (if not set) or an OrderedCollection of iconSize specs."
   887      We return nil (if not set) or an OrderedCollection of iconSize specs."
   888 
   888 
   889     |xIconSizes count ret|
   889     |xIconSizes count ret|
   890 
   890 
   891 %{
   891 %{
   892     Display *dpy = myDpy;
       
   893     int screen = __intVal(__INST(screen));
   892     int screen = __intVal(__INST(screen));
   894     XIconSize *sizeList;
   893     XIconSize *sizeList;
   895     int cnt;
   894     int cnt;
   896 
   895 
   897     if (ISCONNECTED) {
   896     if (ISCONNECTED) {
       
   897         Display *dpy = myDpy;
       
   898 
   898 	if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) {
   899 	if (XGetIconSizes(myDpy, RootWindow(dpy, screen), &sizeList, &cnt) > 0) {
   899 	   xIconSizes = __MKEXTERNALBYTES(sizeList);
   900 	   xIconSizes = __MKEXTERNALBYTES(sizeList);
   900 	   count = __MKSMALLINT(cnt);
   901 	   count = __MKSMALLINT(cnt);
   901 	}
   902 	}
   902     }
   903     }
   971      depth, bitsPerPixel and padding values."
   972      depth, bitsPerPixel and padding values."
   972 
   973 
   973     |nFormats "{ Class: SmallInteger }"
   974     |nFormats "{ Class: SmallInteger }"
   974      formatArray|
   975      formatArray|
   975 %{
   976 %{
   976     Display *dpy = myDpy;
   977     Display *dpy;
   977 
   978 
   978     if (! ISCONNECTED) {
   979     if (! ISCONNECTED) {
   979 	RETURN (nil);
   980 	RETURN (nil);
   980     }
   981     }
       
   982 
       
   983     dpy = myDpy;
   981     nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats);
   984     nFormats = __MKSMALLINT(DISPLAYACCESS(dpy)->nformats);
   982 %}.
   985 %}.
   983     formatArray := Array new:nFormats.
   986     formatArray := Array new:nFormats.
   984     1 to:nFormats do:[:index |
   987     1 to:nFormats do:[:index |
   985 	|info bitsPerPixelInfo depthInfo paddingInfo i|
   988 	|info bitsPerPixelInfo depthInfo paddingInfo i|
  1044 
  1047 
  1045 createBitmapFromFile:aString for:aForm
  1048 createBitmapFromFile:aString for:aForm
  1046     |id w h|
  1049     |id w h|
  1047 
  1050 
  1048 %{
  1051 %{
  1049     Display *dpy = myDpy;
       
  1050     int screen = __intVal(__INST(screen));
  1052     int screen = __intVal(__INST(screen));
  1051     Pixmap newBitmap;
  1053     Pixmap newBitmap;
  1052     char *filename;
  1054     char *filename;
  1053     unsigned b_width, b_height;
  1055     unsigned b_width, b_height;
  1054     int b_x_hot, b_y_hot;
  1056     int b_x_hot, b_y_hot;
  1055     int status;
  1057     int status;
  1056 
  1058 
  1057     if (ISCONNECTED) {
  1059     if (ISCONNECTED) {
       
  1060         Display *dpy = myDpy;
       
  1061 
  1058 	if (__isString(aString) || __isSymbol(aString)) {
  1062 	if (__isString(aString) || __isSymbol(aString)) {
  1059 	    filename = (char *)_stringVal(aString);
  1063 	    filename = (char *)_stringVal(aString);
  1060 
  1064 
  1061 	    BEGIN_INTERRUPTSBLOCKED
  1065 	    BEGIN_INTERRUPTSBLOCKED
  1062 	    status = XReadBitmapFile(dpy, RootWindow(dpy, screen),
  1066 	    status = XReadBitmapFile(dpy, RootWindow(dpy, screen),
  1085     "allocate a bitmap on the Xserver, the contents is undefined
  1089     "allocate a bitmap on the Xserver, the contents is undefined
  1086      (i.e. random). Return a bitmap id or nil"
  1090      (i.e. random). Return a bitmap id or nil"
  1087 
  1091 
  1088 %{  /* NOCONTEXT */
  1092 %{  /* NOCONTEXT */
  1089 
  1093 
  1090     Display *dpy = myDpy;
       
  1091     int screen = __intVal(__INST(screen));
  1094     int screen = __intVal(__INST(screen));
  1092     Pixmap newBitmap;
  1095     Pixmap newBitmap;
  1093 
  1096 
  1094     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1097     if (__bothSmallInteger(w, h) && ISCONNECTED) {
       
  1098         Display *dpy = myDpy;
       
  1099 
  1095 	BEGIN_INTERRUPTSBLOCKED
  1100 	BEGIN_INTERRUPTSBLOCKED
  1096 	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
  1101 	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
  1097 				       __intVal(w), __intVal(h), 1);
  1102 				       __intVal(w), __intVal(h), 1);
  1098 #ifdef COUNT_RESOURCES
  1103 #ifdef COUNT_RESOURCES
  1099 	if (newBitmap)
  1104 	if (newBitmap)
  1112     "allocate a pixmap on the Xserver, the contents is undefined
  1117     "allocate a pixmap on the Xserver, the contents is undefined
  1113      (i.e. random). Return a bitmap id or nil"
  1118      (i.e. random). Return a bitmap id or nil"
  1114 
  1119 
  1115 %{  /* NOCONTEXT */
  1120 %{  /* NOCONTEXT */
  1116 
  1121 
  1117     Display *dpy = myDpy;
       
  1118     int screen = __intVal(__INST(screen));
  1122     int screen = __intVal(__INST(screen));
  1119     Pixmap newBitmap;
  1123     Pixmap newBitmap;
  1120 
  1124 
  1121     if (__bothSmallInteger(w, h) && ISCONNECTED) {
  1125     if (__bothSmallInteger(w, h) && ISCONNECTED) {
       
  1126         Display *dpy = myDpy;
       
  1127 
  1122 	BEGIN_INTERRUPTSBLOCKED
  1128 	BEGIN_INTERRUPTSBLOCKED
  1123 	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
  1129 	newBitmap = XCreatePixmap(dpy, RootWindow(dpy, screen),
  1124 				       __intVal(w), __intVal(h), __intVal(d));
  1130 				       __intVal(w), __intVal(h), __intVal(d));
  1125 #ifdef COUNT_RESOURCES
  1131 #ifdef COUNT_RESOURCES
  1126 	if (newBitmap)
  1132 	if (newBitmap)
  1609 
  1615 
  1610 primCreateBitmapFromArray:anArray width:w height:h
  1616 primCreateBitmapFromArray:anArray width:w height:h
  1611 
  1617 
  1612 %{  /* UNLIMITEDSTACK */
  1618 %{  /* UNLIMITEDSTACK */
  1613 
  1619 
  1614     Display *dpy = myDpy;
  1620     Display *dpy;
  1615     int screen = __intVal(__INST(screen));
  1621     int screen = __intVal(__INST(screen));
  1616     Pixmap newBitmap;
  1622     Pixmap newBitmap;
  1617     unsigned int b_width, b_height;
  1623     unsigned int b_width, b_height;
  1618     REGISTER unsigned char *cp;
  1624     REGISTER unsigned char *cp;
  1619     REGISTER unsigned char *pBits;
  1625     REGISTER unsigned char *pBits;
  1629     int bytesPerRow;
  1635     int bytesPerRow;
  1630 
  1636 
  1631     if (! ISCONNECTED) {
  1637     if (! ISCONNECTED) {
  1632 	RETURN (nil);
  1638 	RETURN (nil);
  1633     }
  1639     }
       
  1640 
       
  1641     dpy = myDpy;
  1634     if (firstCall) {
  1642     if (firstCall) {
  1635 	for (index=0; index < 256; index++) {
  1643 	for (index=0; index < 256; index++) {
  1636 	    reverseBitTable[index] = 0;
  1644 	    reverseBitTable[index] = 0;
  1637 	    if (index & 128) reverseBitTable[index] |=   1;
  1645 	    if (index & 128) reverseBitTable[index] |=   1;
  1638 	    if (index &  64) reverseBitTable[index] |=   2;
  1646 	    if (index &  64) reverseBitTable[index] |=   2;
  1862      Dont use this method, colornames are mostly X specific"
  1870      Dont use this method, colornames are mostly X specific"
  1863 
  1871 
  1864 %{  /* NOCONTEXT */
  1872 %{  /* NOCONTEXT */
  1865 
  1873 
  1866     char *colorname;
  1874     char *colorname;
  1867     Display *dpy = myDpy;
       
  1868     XColor scolor, ecolor;
  1875     XColor scolor, ecolor;
  1869     int screen = __intVal(__INST(screen));
  1876     int screen = __intVal(__INST(screen));
  1870     int id;
  1877     int id;
  1871     Status ok;
  1878     Status ok;
  1872 
  1879 
  1873     if (ISCONNECTED) {
  1880     if (ISCONNECTED) {
       
  1881         Display *dpy = myDpy;
       
  1882 
  1874 	if (__isString(aString) || __isSymbol(aString)) {
  1883 	if (__isString(aString) || __isSymbol(aString)) {
  1875 	    colorname = (char *)_stringVal(aString);
  1884 	    colorname = (char *)_stringVal(aString);
  1876 
  1885 
  1877 	    BEGIN_INTERRUPTSBLOCKED
  1886 	    BEGIN_INTERRUPTSBLOCKED
  1878 	    ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
  1887 	    ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
  1957 freeColor:colorIndex
  1966 freeColor:colorIndex
  1958     "free a display color when its no longer needed"
  1967     "free a display color when its no longer needed"
  1959 
  1968 
  1960 %{  /* NOCONTEXT */
  1969 %{  /* NOCONTEXT */
  1961 
  1970 
  1962     Display *dpy = myDpy;
  1971     Display *dpy;
  1963     unsigned long color;
  1972     unsigned long color;
  1964     int screen = __intVal(__INST(screen));
  1973     int screen = __intVal(__INST(screen));
  1965 
  1974 
  1966 #ifdef QUICK_TRUE_COLORS
  1975 #ifdef QUICK_TRUE_COLORS
  1967     if (__INST(visualType) == @symbol(TrueColor)) {
  1976     if (__INST(visualType) == @symbol(TrueColor)) {
  1969 	RETURN (self);
  1978 	RETURN (self);
  1970     }
  1979     }
  1971 #endif
  1980 #endif
  1972 
  1981 
  1973     if (__isSmallInteger(colorIndex) && ISCONNECTED) {
  1982     if (__isSmallInteger(colorIndex) && ISCONNECTED) {
       
  1983         dpy = myDpy;
  1974 	color = (long) __intVal(colorIndex);
  1984 	color = (long) __intVal(colorIndex);
  1975 	BEGIN_INTERRUPTSBLOCKED
  1985 	BEGIN_INTERRUPTSBLOCKED
  1976 	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
  1986 	XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
  1977 #ifdef COUNT_RESOURCES
  1987 #ifdef COUNT_RESOURCES
  1978 	__cnt_color--;
  1988 	__cnt_color--;
  3818      If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
  3828      If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
  3819      before checking."
  3829      before checking."
  3820 
  3830 
  3821 %{  /* UNLIMITEDSTACK */
  3831 %{  /* UNLIMITEDSTACK */
  3822 
  3832 
  3823     Display *dpy = myDpy;
       
  3824 
       
  3825     if (ISCONNECTED) {
  3833     if (ISCONNECTED) {
       
  3834         Display *dpy = myDpy;
       
  3835 
  3826 	if (doSync == true) {
  3836 	if (doSync == true) {
  3827 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3837 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3828 	}
  3838 	}
  3829 	if (XPending(dpy)) {
  3839 	if (XPending(dpy)) {
  3830 	    RETURN (true);
  3840 	    RETURN (true);
  3865 eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync
  3875 eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync
  3866     "return true, if any of the masked events is pending"
  3876     "return true, if any of the masked events is pending"
  3867 
  3877 
  3868 %{  /* UNLIMITEDSTACK */
  3878 %{  /* UNLIMITEDSTACK */
  3869 
  3879 
  3870     Display *dpy = myDpy;
       
  3871     XEvent ev;
  3880     XEvent ev;
  3872     Window win;
  3881     Window win;
  3873     int thereIsOne;
  3882     int thereIsOne;
  3874 
  3883 
  3875     if (ISCONNECTED && __isSmallInteger(anEventMask)) {
  3884     if (ISCONNECTED && __isSmallInteger(anEventMask)) {
       
  3885         Display *dpy = myDpy;
       
  3886 
  3876 	if (doSync == true) {
  3887 	if (doSync == true) {
  3877 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3888 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3878 	}
  3889 	}
  3879 	if (__isExternalAddress(aWindowIdOrNil)) {
  3890 	if (__isExternalAddress(aWindowIdOrNil)) {
  3880 	    win = _WindowVal(aWindowIdOrNil);
  3891 	    win = _WindowVal(aWindowIdOrNil);
  3896      or any view (if the arg is nil).
  3907      or any view (if the arg is nil).
  3897      This is an X specific, only required after a scroll operation."
  3908      This is an X specific, only required after a scroll operation."
  3898 
  3909 
  3899 %{  /* UNLIMITEDSTACK */
  3910 %{  /* UNLIMITEDSTACK */
  3900 
  3911 
  3901     Display *dpy = myDpy;
       
  3902     XEvent ev;
  3912     XEvent ev;
  3903     Window win;
  3913     Window win;
  3904     int thereIsOne;
  3914     int thereIsOne;
  3905 
  3915 
  3906     if (ISCONNECTED) {
  3916     if (ISCONNECTED) {
       
  3917         Display *dpy = myDpy;
       
  3918 
  3907 	if (doSync == true) {
  3919 	if (doSync == true) {
  3908 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3920 	    XSync(dpy, 0);      /* make certain everything is flushed */
  3909 	}
  3921 	}
  3910 	if (__isExternalAddress(aWindowIdOrNil)) {
  3922 	if (__isExternalAddress(aWindowIdOrNil)) {
  3911 	    win = _WindowVal(aWindowIdOrNil);
  3923 	    win = _WindowVal(aWindowIdOrNil);
  3938      display connections.
  3950      display connections.
  3939     "
  3951     "
  3940 
  3952 
  3941 %{  /* UNLIMITEDSTACK */
  3953 %{  /* UNLIMITEDSTACK */
  3942 
  3954 
  3943     Display *dpy = myDpy;
  3955     Display *dpy;
  3944     Window win, wWanted;
  3956     Window win, wWanted;
  3945     int evMask;
  3957     int evMask;
  3946     OBJ eB;
  3958     OBJ eB;
  3947     XEvent *ev;
  3959     XEvent *ev;
  3948 
  3960 
  3949     if (! ISCONNECTED) {
  3961     if (! ISCONNECTED) {
  3950 	RETURN (false);
  3962 	RETURN (false);
  3951     }
  3963     }
       
  3964 
       
  3965     dpy = myDpy;
  3952 
  3966 
  3953     eB = __INST(eventBuffer);
  3967     eB = __INST(eventBuffer);
  3954     if (__isByteArray(eB)) {
  3968     if (__isByteArray(eB)) {
  3955 	ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  3969 	ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
  3956     } else {
  3970     } else {
  4055      are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
  4069      are computed from the keyboardMap - if non-nil, these are passed as modifierbits.
  4056      The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
  4070      The non-nil case is the lowlevel entry, where state must include any shift/ctrl information
  4057      (not very user friendly)"
  4071      (not very user friendly)"
  4058 
  4072 
  4059 %{  /* NOCONTEXT */
  4073 %{  /* NOCONTEXT */
  4060     Display *dpy = myDpy;
       
  4061     int type;
  4074     int type;
  4062     int state;
  4075     int state;
  4063 
  4076 
  4064     if (__isSmallInteger(stateMask)) {
  4077     if (__isSmallInteger(stateMask)) {
  4065 	state = __intVal(stateMask);
  4078 	state = __intVal(stateMask);
  4069 
  4082 
  4070     if (ISCONNECTED
  4083     if (ISCONNECTED
  4071      && __isSmallInteger(xPos) && __isSmallInteger(yPos)
  4084      && __isSmallInteger(xPos) && __isSmallInteger(yPos)
  4072      && (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr))
  4085      && (__isSmallInteger(keySymCodeOrButtonNr) || __isSymbol(keySymCodeOrButtonNr) || __isString(keySymCodeOrButtonNr))
  4073      && (__isExternalAddress(targetId) || __isInteger(targetId))) {
  4086      && (__isExternalAddress(targetId) || __isInteger(targetId))) {
       
  4087         Display *dpy = myDpy;
       
  4088 
  4074 	XEvent ev;
  4089 	XEvent ev;
  4075 	Window target;
  4090 	Window target;
  4076 	Status result;
  4091 	Status result;
  4077 	KeySym keySym, *syms;
  4092 	KeySym keySym, *syms;
  4078 	int screen = __intVal(__INST(screen));
  4093 	int screen = __intVal(__INST(screen));
  4397     XFontProp *prop;
  4412     XFontProp *prop;
  4398     int n;
  4413     int n;
  4399     char *cp;
  4414     char *cp;
  4400     Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom;
  4415     Atom fontAtom, registryAtom, encodingAtom, charSetCollAtom;
  4401 
  4416 
  4402     registryAtom = XInternAtom(myDpy, "CHARSET_REGISTRY", True);
       
  4403     encodingAtom = XInternAtom(myDpy, "CHARSET_ENCODING", True);
       
  4404     charSetCollAtom = XInternAtom(myDpy, "CHARSET_COLLECTIONS", True);
       
  4405     fontAtom = XInternAtom(myDpy, "FONT", True);
       
  4406 
       
  4407     if (ISCONNECTED) {
  4417     if (ISCONNECTED) {
       
  4418         Display *dpy = myDpy;
       
  4419 
       
  4420         registryAtom = XInternAtom(dpy, "CHARSET_REGISTRY", True);
       
  4421         encodingAtom = XInternAtom(dpy, "CHARSET_ENCODING", True);
       
  4422         charSetCollAtom = XInternAtom(dpy, "CHARSET_COLLECTIONS", True);
       
  4423         fontAtom = XInternAtom(dpy, "FONT", True);
       
  4424 
  4408 	if (__isExternalAddress(aFontId)) {
  4425 	if (__isExternalAddress(aFontId)) {
  4409         
  4426         
  4410 	    f = _FontVal(aFontId);
  4427 	    f = _FontVal(aFontId);
  4411 	    if (f) {
  4428 	    if (f) {
  4412 		n = f->n_properties;
  4429 		n = f->n_properties;
  4413 		prop = f->properties;
  4430 		prop = f->properties;
  4414 		if (prop) {
  4431 		if (prop) {
  4415 		    while (n--) {
  4432 		    while (n--) {
  4416 #ifdef SUPERDEBUG
  4433 #ifdef SUPERDEBUG
  4417 			cp = XGetAtomName(myDpy, prop->name);
  4434 			cp = XGetAtomName(dpy, prop->name);
  4418 			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
  4435 			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
  4419 			XFree(cp);
  4436 			XFree(cp);
  4420 #endif
  4437 #endif
  4421 			if (prop->name == XA_FULL_NAME) {
  4438 			if (prop->name == XA_FULL_NAME) {
  4422 			    cp = XGetAtomName(myDpy, prop->card32);
  4439 			    cp = XGetAtomName(dpy, prop->card32);
  4423 			    if (cp) {
  4440 			    if (cp) {
  4424 				fullName = __MKSTRING(cp);
  4441 				fullName = __MKSTRING(cp);
  4425 #ifdef SUPERDEBUG
  4442 #ifdef SUPERDEBUG
  4426 				printf("   FULL_NAME -> %s\n", cp);
  4443 				printf("   FULL_NAME -> %s\n", cp);
  4427 #endif
  4444 #endif
  4428 				XFree(cp);
  4445 				XFree(cp);
  4429 			    }
  4446 			    }
  4430 			} else if (prop->name == fontAtom) {
  4447 			} else if (prop->name == fontAtom) {
  4431 			    cp = XGetAtomName(myDpy, prop->card32);
  4448 			    cp = XGetAtomName(dpy, prop->card32);
  4432 			    if (cp) {
  4449 			    if (cp) {
  4433 				fontName = __MKSTRING(cp);
  4450 				fontName = __MKSTRING(cp);
  4434 #ifdef SUPERDEBUG
  4451 #ifdef SUPERDEBUG
  4435 				printf("   FONT -> %s\n", cp);
  4452 				printf("   FONT -> %s\n", cp);
  4436 #endif
  4453 #endif
  4437 				XFree(cp);
  4454 				XFree(cp);
  4438 			    }
  4455 			    }
  4439 			} else if (prop->name == encodingAtom) {
  4456 			} else if (prop->name == encodingAtom) {
  4440 			    cp = XGetAtomName(myDpy, prop->card32);
  4457 			    cp = XGetAtomName(dpy, prop->card32);
  4441 			    if (cp) {
  4458 			    if (cp) {
  4442 				encoding = __MKSTRING(cp);
  4459 				encoding = __MKSTRING(cp);
  4443 #ifdef SUPERDEBUG
  4460 #ifdef SUPERDEBUG
  4444 				printf("   ENCODING -> %s\n", cp);
  4461 				printf("   ENCODING -> %s\n", cp);
  4445 #endif
  4462 #endif
  4446 				XFree(cp);
  4463 				XFree(cp);
  4447 			    }
  4464 			    }
  4448 			} else if (prop->name == registryAtom) {
  4465 			} else if (prop->name == registryAtom) {
  4449 			    cp = XGetAtomName(myDpy, prop->card32);
  4466 			    cp = XGetAtomName(dpy, prop->card32);
  4450 			    if (cp) {
  4467 			    if (cp) {
  4451 				registry = __MKSTRING(cp);
  4468 				registry = __MKSTRING(cp);
  4452 #ifdef SUPERDEBUG
  4469 #ifdef SUPERDEBUG
  4453 				printf("   REGISTRY -> %s\n", cp);
  4470 				printf("   REGISTRY -> %s\n", cp);
  4454 #endif
  4471 #endif
  4455 				XFree(cp);
  4472 				XFree(cp);
  4456 			    }
  4473 			    }
  4457 			} else if (prop->name == charSetCollAtom) {
  4474 			} else if (prop->name == charSetCollAtom) {
  4458 			    cp = XGetAtomName(myDpy, prop->card32);
  4475 			    cp = XGetAtomName(dpy, prop->card32);
  4459 			    if (cp) {
  4476 			    if (cp) {
  4460 				charSetCollections = __MKSTRING(cp);
  4477 				charSetCollections = __MKSTRING(cp);
  4461 #ifdef SUPERDEBUG
  4478 #ifdef SUPERDEBUG
  4462 				printf("   CHARSET_COLLECTIONS -> %s\n", cp);
  4479 				printf("   CHARSET_COLLECTIONS -> %s\n", cp);
  4463 #endif
  4480 #endif
  4600 
  4617 
  4601 %{
  4618 %{
  4602     XFontStruct *f;
  4619     XFontStruct *f;
  4603 
  4620 
  4604     if (ISCONNECTED) {
  4621     if (ISCONNECTED) {
       
  4622         Display *dpy = myDpy;
       
  4623 
  4605 	if (__isExternalAddress(fontId)) {
  4624 	if (__isExternalAddress(fontId)) {
  4606 	    f = _FontVal(fontId);
  4625 	    f = _FontVal(fontId);
  4607 	    if (f) {
  4626 	    if (f) {
  4608 		char *cp;
  4627 		char *cp;
  4609 		XFontProp *prop;
  4628 		XFontProp *prop;
  4612 
  4631 
  4613 		n = f->n_properties;
  4632 		n = f->n_properties;
  4614 		prop = f->properties;
  4633 		prop = f->properties;
  4615 
  4634 
  4616 		if (prop) {
  4635 		if (prop) {
  4617 		    resolutionXAtom = XInternAtom(myDpy, "RESOLUTION_X", True);
  4636 		    resolutionXAtom = XInternAtom(dpy, "RESOLUTION_X", True);
  4618 		    resolutionYAtom = XInternAtom(myDpy, "RESOLUTION_Y", True);
  4637 		    resolutionYAtom = XInternAtom(dpy, "RESOLUTION_Y", True);
  4619 
  4638 
  4620 		    while (n--) {
  4639 		    while (n--) {
  4621 			if (prop->name == resolutionXAtom) {
  4640 			if (prop->name == resolutionXAtom) {
  4622 			    resX = __MKSMALLINT(prop->card32);
  4641 			    resX = __MKSMALLINT(prop->card32);
  4623 			} else if (prop->name == resolutionYAtom) {
  4642 			} else if (prop->name == resolutionYAtom) {
  4653     XFontProp *prop;
  4672     XFontProp *prop;
  4654     int n;
  4673     int n;
  4655     char *cp;
  4674     char *cp;
  4656     Atom fontAtom;
  4675     Atom fontAtom;
  4657 
  4676 
  4658     fontAtom = XInternAtom(myDpy, "FONT", True);
       
  4659 
       
  4660     if (ISCONNECTED) {
  4677     if (ISCONNECTED) {
       
  4678         Display *dpy = myDpy;
       
  4679 
       
  4680         fontAtom = XInternAtom(dpy, "FONT", True);
       
  4681 
  4661 	if (__isExternalAddress(aFontId)) {
  4682 	if (__isExternalAddress(aFontId)) {
  4662         
  4683         
  4663 	    f = _FontVal(aFontId);
  4684 	    f = _FontVal(aFontId);
  4664 	    if (f) {
  4685 	    if (f) {
  4665 		n = f->n_properties;
  4686 		n = f->n_properties;
  4666 		prop = f->properties;
  4687 		prop = f->properties;
  4667 		if (prop) {
  4688 		if (prop) {
  4668 		    while (n--) {
  4689 		    while (n--) {
  4669 #ifdef SUPERDEBUG
  4690 #ifdef SUPERDEBUG
  4670 			cp = XGetAtomName(myDpy, prop->name);
  4691 			cp = XGetAtomName(dpy, prop->name);
  4671 			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
  4692 			printf("%s (%d) -> %d\n", cp, prop->name, prop->card32);
  4672 			XFree(cp);
  4693 			XFree(cp);
  4673 #endif
  4694 #endif
  4674 			if (prop->name == XA_FULL_NAME) {
  4695 			if (prop->name == XA_FULL_NAME) {
  4675 			    cp = XGetAtomName(myDpy, prop->card32);
  4696 			    cp = XGetAtomName(dpy, prop->card32);
  4676 			    if (cp) {
  4697 			    if (cp) {
  4677 				fullName = __MKSTRING(cp);
  4698 				fullName = __MKSTRING(cp);
  4678 #ifdef SUPERDEBUG
  4699 #ifdef SUPERDEBUG
  4679 				printf("   FULL_NAME -> %s\n", cp);
  4700 				printf("   FULL_NAME -> %s\n", cp);
  4680 #endif
  4701 #endif
  4681 				XFree(cp);
  4702 				XFree(cp);
  4682 			    }
  4703 			    }
  4683 			}
  4704 			}
  4684 			if (prop->name == fontAtom) {
  4705 			if (prop->name == fontAtom) {
  4685 			    cp = XGetAtomName(myDpy, prop->card32);
  4706 			    cp = XGetAtomName(dpy, prop->card32);
  4686 			    if (cp) {
  4707 			    if (cp) {
  4687 				fontName = __MKSTRING(cp);
  4708 				fontName = __MKSTRING(cp);
  4688 #ifdef SUPERDEBUG
  4709 #ifdef SUPERDEBUG
  4689 				printf("   FONT -> %s\n", cp);
  4710 				printf("   FONT -> %s\n", cp);
  4690 #endif
  4711 #endif
  5333 	_mode = ReplayKeyboard;
  5354 	_mode = ReplayKeyboard;
  5334     else
  5355     else
  5335 	ok = 0;
  5356 	ok = 0;
  5336 
  5357 
  5337     if (ok) {
  5358     if (ok) {
  5338 	BEGIN_INTERRUPTSBLOCKED
  5359         if (ISCONNECTED) {
  5339 	XAllowEvents(myDpy, _mode, CurrentTime);
  5360 	    BEGIN_INTERRUPTSBLOCKED
  5340 	END_INTERRUPTSBLOCKED
  5361 	    XAllowEvents(myDpy, _mode, CurrentTime);
  5341 	RETURN (self);
  5362 	    END_INTERRUPTSBLOCKED
       
  5363 	    RETURN (self);
       
  5364 	}
  5342     }
  5365     }
  5343 %}.
  5366 %}.
  5344     self primitiveFailed
  5367     self primitiveFailed
  5345 !
  5368 !
  5346 
  5369 
  5348     "grab the keyboard"
  5371     "grab the keyboard"
  5349 
  5372 
  5350 %{  /* NOCONTEXT */
  5373 %{  /* NOCONTEXT */
  5351     int result, ok;
  5374     int result, ok;
  5352 
  5375 
  5353     if (__isExternalAddress(aWindowId)) {
  5376     if (ISCONNECTED) {
  5354 	BEGIN_INTERRUPTSBLOCKED
  5377         if (__isExternalAddress(aWindowId)) {
  5355 	result = XGrabKeyboard(myDpy,
  5378 	    BEGIN_INTERRUPTSBLOCKED
  5356 			       _WindowVal(aWindowId),
  5379 	    result = XGrabKeyboard(myDpy,
  5357 			       True /* False */,
  5380 			           _WindowVal(aWindowId),
  5358 			       GrabModeAsync,
  5381 			           True /* False */,
  5359 			       GrabModeAsync,
  5382 			           GrabModeAsync,
  5360 			       CurrentTime);
  5383 			           GrabModeAsync,
  5361 	END_INTERRUPTSBLOCKED
  5384 			           CurrentTime);
  5362 	ok = 0;
  5385 	    END_INTERRUPTSBLOCKED
  5363 	switch(result) {
  5386 	    ok = 0;
  5364 	    case AlreadyGrabbed: 
  5387 	    switch(result) {
  5365 		if (@global(ErrorPrinting) == true) {
  5388 	        case AlreadyGrabbed: 
  5366 		    fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n");
  5389 		    if (@global(ErrorPrinting) == true) {
  5367 		}
  5390 		        fprintf(stderr, "XWorkstation [warning]: grab keyboard: AlreadyGrabbed\n");
  5368 		break;
  5391 		    }
  5369 	    case GrabNotViewable: 
  5392 		    break;
  5370 		if (@global(ErrorPrinting) == true) {
  5393 	        case GrabNotViewable: 
  5371 		    fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n");
  5394 		    if (@global(ErrorPrinting) == true) {
  5372 		}
  5395 		        fprintf(stderr, "XWorkstation [warning]: grab keyboard: GrabNotViewable\n");
  5373 		break;
  5396 		    }
  5374 	    case GrabInvalidTime: 
  5397 		    break;
  5375 		if (@global(ErrorPrinting) == true) {
  5398 	        case GrabInvalidTime: 
  5376 		    fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n");
  5399 		    if (@global(ErrorPrinting) == true) {
  5377 		}
  5400 		        fprintf(stderr, "XWorkstation [warning]: grab keyboard: InvalidTime\n");
  5378 		break;
  5401 		    }
  5379 	    case GrabFrozen: 
  5402 		    break;
  5380 		if (@global(ErrorPrinting) == true) {
  5403 	        case GrabFrozen: 
  5381 		    fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n");
  5404 		    if (@global(ErrorPrinting) == true) {
  5382 		}
  5405 		        fprintf(stderr, "XWorkstation [warning]: grab keyboard: Frozen\n");
  5383 		break;
  5406 		    }
  5384 	    default:
  5407 		    break;
  5385 		ok = 1;
  5408 	        default:
  5386 		break;
  5409 		    ok = 1;
  5387 	}
  5410 		    break;
  5388 	if (! ok) {
  5411 	    }
  5389 	    XUngrabKeyboard(myDpy, CurrentTime);
  5412 	    if (! ok) {
  5390 	    RETURN (false);
  5413 	        XUngrabKeyboard(myDpy, CurrentTime);
  5391 	}
  5414 	        RETURN (false);
  5392 
  5415 	    }
  5393 	RETURN ( true );
  5416 
       
  5417 	    RETURN ( true );
       
  5418 	}
  5394     }
  5419     }
  5395 %}.
  5420 %}.
  5396     self primitiveFailed
  5421     self primitiveFailed
  5397 !
  5422 !
  5398 
  5423 
  5404     int result, ok;
  5429     int result, ok;
  5405     Window confineWin;
  5430     Window confineWin;
  5406     Cursor curs;
  5431     Cursor curs;
  5407     int pointer_mode, keyboard_mode;
  5432     int pointer_mode, keyboard_mode;
  5408 
  5433 
  5409     if (__isExternalAddress(aWindowId)) {
  5434     if (ISCONNECTED) {
  5410 	if (__isExternalAddress(confineId)) 
  5435         if (__isExternalAddress(aWindowId)) {
  5411 	    confineWin = _WindowVal(confineId);
  5436 	    if (__isExternalAddress(confineId)) 
  5412 	else
  5437 	        confineWin = _WindowVal(confineId);
  5413 	    confineWin = (Window) None;
  5438 	    else
  5414 
  5439 	        confineWin = (Window) None;
  5415 	if (__isExternalAddress(aCursorId)) 
  5440 
  5416 	    curs = _CursorVal(aCursorId);
  5441 	    if (__isExternalAddress(aCursorId)) 
  5417 	else
  5442 	        curs = _CursorVal(aCursorId);
  5418 	    curs = (Cursor) None;
  5443 	    else
  5419 
  5444 	        curs = (Cursor) None;
  5420 	if (pMode == @symbol(sync))
  5445 
  5421 	    pointer_mode = GrabModeSync;
  5446 	    if (pMode == @symbol(sync))
  5422 	else
  5447 	        pointer_mode = GrabModeSync;
  5423 	    pointer_mode = GrabModeAsync;
  5448 	    else
  5424 
  5449 	        pointer_mode = GrabModeAsync;
  5425 	if (kMode == @symbol(sync))
  5450 
  5426 	    keyboard_mode = GrabModeSync;
  5451 	    if (kMode == @symbol(sync))
  5427 	else
  5452 	        keyboard_mode = GrabModeSync;
  5428 	    keyboard_mode = GrabModeAsync;
  5453 	    else
  5429 
  5454 	        keyboard_mode = GrabModeAsync;
  5430 	BEGIN_INTERRUPTSBLOCKED
  5455 
  5431 	result = XGrabPointer(myDpy,
  5456 	    BEGIN_INTERRUPTSBLOCKED
  5432 			      _WindowVal(aWindowId), 
  5457 	    result = XGrabPointer(myDpy,
  5433 			      False, 
  5458 			          _WindowVal(aWindowId), 
  5434 			      ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
  5459 			          False, 
  5435 			      pointer_mode, keyboard_mode,
  5460 			          ButtonPressMask | ButtonMotionMask | ButtonReleaseMask,
  5436 			      confineWin,
  5461 			          pointer_mode, keyboard_mode,
  5437 			      curs,
  5462 			          confineWin,
  5438 			      CurrentTime);
  5463 			          curs,
  5439 	END_INTERRUPTSBLOCKED
  5464 			          CurrentTime);
  5440 
  5465 	    END_INTERRUPTSBLOCKED
  5441 	ok = 0;
  5466 
  5442 	switch (result) {
  5467 	    ok = 0;
  5443 	    case AlreadyGrabbed: 
  5468 	    switch (result) {
  5444 		if (@global(ErrorPrinting) == true) {
  5469 	        case AlreadyGrabbed: 
  5445 		    fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n");
  5470 		    if (@global(ErrorPrinting) == true) {
  5446 		}
  5471 		        fprintf(stderr, "XWorkstation [warning]: grab pointer: AlreadyGrabbed\n");
  5447 		break;
  5472 		    }
  5448 	    case GrabNotViewable: 
  5473 		    break;
  5449 		if (@global(ErrorPrinting) == true) {
  5474 	        case GrabNotViewable: 
  5450 		    fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n");
  5475 		    if (@global(ErrorPrinting) == true) {
  5451 		}
  5476 		        fprintf(stderr, "XWorkstation [warning]: grab pointer: GrabNotViewable\n");
  5452 		break;
  5477 		    }
  5453 	    case GrabInvalidTime: 
  5478 		    break;
  5454 		if (@global(ErrorPrinting) == true) {
  5479 	        case GrabInvalidTime: 
  5455 		    fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n");
  5480 		    if (@global(ErrorPrinting) == true) {
  5456 		}
  5481 		        fprintf(stderr, "XWorkstation [warning]: grab pointer: InvalidTime\n");
  5457 		break;
  5482 		    }
  5458 	    case GrabFrozen: 
  5483 		    break;
  5459 		if (@global(ErrorPrinting) == true) {
  5484 	        case GrabFrozen: 
  5460 		    fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n");
  5485 		    if (@global(ErrorPrinting) == true) {
  5461 		}
  5486 		        fprintf(stderr, "XWorkstation [warning]: grab pointer: Frozen\n");
  5462 		break;
  5487 		    }
  5463 	    default:
  5488 		    break;
  5464 		ok = 1;
  5489 	        default:
  5465 		break;
  5490 		    ok = 1;
  5466 	}
  5491 		    break;
  5467 
  5492 	    }
  5468 	if (! ok) {
  5493 
  5469 	    XUngrabPointer(myDpy, CurrentTime);
  5494 	    if (! ok) {
  5470 	    RETURN (false);
  5495 	        XUngrabPointer(myDpy, CurrentTime);
  5471 	}
  5496 	        RETURN (false);
  5472 	RETURN ( true );
  5497 	    }
       
  5498 	    RETURN ( true );
       
  5499 	}
  5473     }
  5500     }
  5474 %}.
  5501 %}.
  5475     self primitiveFailed
  5502     self primitiveFailed
  5476 !
  5503 !
  5477 
  5504 
  5513 %{  /* NOCONTEXT */
  5540 %{  /* NOCONTEXT */
  5514 
  5541 
  5515     XGCValues gcv;
  5542     XGCValues gcv;
  5516     GC gc;
  5543     GC gc;
  5517 
  5544 
  5518     if (__isExternalAddress(aGCId)) {
  5545     if (ISCONNECTED) {
  5519 	gc = _GCVal(aGCId);
  5546         if (__isExternalAddress(aGCId)) {
  5520 	gcv.clip_mask = None;
  5547 	    gc = _GCVal(aGCId);
  5521 	XChangeGC(myDpy, gc, GCClipMask, &gcv);
  5548 	    gcv.clip_mask = None;
  5522 	RETURN ( self );
  5549 	    XChangeGC(myDpy, gc, GCClipMask, &gcv);
       
  5550 	    RETURN ( self );
       
  5551         }
  5523     }
  5552     }
  5524 %}.
  5553 %}.
  5525     self primitiveFailed
  5554     self primitiveFailed
  5526 !
  5555 !
  5527 
  5556 
  5528 setBackground:bgColorIndex in:aGCId
  5557 setBackground:bgColorIndex in:aGCId
  5529     "set background color to be drawn with"
  5558     "set background color to be drawn with"
  5530 
  5559 
  5531 %{  /* NOCONTEXT */
  5560 %{  /* NOCONTEXT */
  5532 
  5561 
  5533     if (__isExternalAddress(aGCId)
  5562     if (ISCONNECTED) {
  5534      && __isSmallInteger(bgColorIndex)) {
  5563         if (__isExternalAddress(aGCId)
  5535 	XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex));
  5564          && __isSmallInteger(bgColorIndex)) {
  5536 	RETURN ( self );
  5565 	    XSetBackground(myDpy, _GCVal(aGCId), __intVal(bgColorIndex));
       
  5566 	    RETURN ( self );
       
  5567         }
  5537     }
  5568     }
  5538 %}.
  5569 %}.
  5539     self primitiveFailed
  5570     self primitiveFailed
  5540 !
  5571 !
  5541 
  5572 
  5542 setBitmapMask:aBitmapId in:aGCId
  5573 setBitmapMask:aBitmapId in:aGCId
  5543     "set or clear the drawing mask - a bitmap mask using current fg/bg"
  5574     "set or clear the drawing mask - a bitmap mask using current fg/bg"
  5544 
  5575 
  5545 %{  /* NOCONTEXT */
  5576 %{  /* NOCONTEXT */
  5546 
  5577 
  5547     Display *dpy = myDpy;
       
  5548     GC gc;
  5578     GC gc;
  5549     Pixmap bitmap;
  5579     Pixmap bitmap;
  5550 
  5580 
  5551     if (__isExternalAddress(aGCId)) {
  5581     if (ISCONNECTED) {
  5552 	gc = _GCVal(aGCId);
  5582         Display *dpy = myDpy;
  5553 	if (__isExternalAddress(aBitmapId)) {
  5583 
  5554 	    bitmap = _PixmapVal(aBitmapId);
  5584         if (__isExternalAddress(aGCId)) {
  5555 	    XSetStipple(dpy, gc, bitmap);
  5585 	    gc = _GCVal(aGCId);
  5556 	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5586 	    if (__isExternalAddress(aBitmapId)) {
  5557 	    RETURN ( self );
  5587 	        bitmap = _PixmapVal(aBitmapId);
  5558 	}
  5588 	        XSetStipple(dpy, gc, bitmap);
  5559 	if (aBitmapId == nil) {
  5589 	        XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5560 	    XSetFillStyle(dpy, gc, FillSolid);
  5590 	        RETURN ( self );
  5561 	    RETURN ( self );
  5591 	    }
       
  5592 	    if (aBitmapId == nil) {
       
  5593 	        XSetFillStyle(dpy, gc, FillSolid);
       
  5594 	        RETURN ( self );
       
  5595 	    }
  5562 	}
  5596 	}
  5563     }
  5597     }
  5564 %}.
  5598 %}.
  5565     self primitiveFailed
  5599     self primitiveFailed
  5566 !
  5600 !
  5571 %{  /* NOCONTEXT */
  5605 %{  /* NOCONTEXT */
  5572 
  5606 
  5573     XGCValues gcv;
  5607     XGCValues gcv;
  5574     GC gc;
  5608     GC gc;
  5575 
  5609 
  5576     if (__isExternalAddress(aGCId)) {
  5610     if (ISCONNECTED) {
  5577 	gc = _GCVal(aGCId);
  5611         if (__isExternalAddress(aGCId)) {
  5578 	if (aBool == true)
  5612 	    gc = _GCVal(aGCId);
  5579 	    gcv.subwindow_mode = ClipByChildren;
  5613 	    if (aBool == true)
  5580 	else
  5614 	        gcv.subwindow_mode = ClipByChildren;
  5581 	    gcv.subwindow_mode = IncludeInferiors;
  5615 	    else
  5582 
  5616 	        gcv.subwindow_mode = IncludeInferiors;
  5583 	XChangeGC(myDpy, gc, GCSubwindowMode, &gcv);
  5617 
  5584 	RETURN ( self );
  5618 	    XChangeGC(myDpy, gc, GCSubwindowMode, &gcv);
       
  5619 	    RETURN ( self );
       
  5620 	}
  5585     }
  5621     }
  5586 %}.
  5622 %}.
  5587     self primitiveFailed
  5623     self primitiveFailed
  5588 !
  5624 !
  5589 
  5625 
  5592 
  5628 
  5593 %{  /* NOCONTEXT */
  5629 %{  /* NOCONTEXT */
  5594 
  5630 
  5595     XRectangle r;
  5631     XRectangle r;
  5596 
  5632 
  5597     if (__isExternalAddress(aGCId)
  5633     if (ISCONNECTED) {
  5598      && __bothSmallInteger(clipX, clipY)
  5634         if (__isExternalAddress(aGCId)
  5599      && __bothSmallInteger(clipWidth, clipHeight)) {
  5635          && __bothSmallInteger(clipX, clipY)
  5600 	r.x = __intVal(clipX);
  5636          && __bothSmallInteger(clipWidth, clipHeight)) {
  5601 	r.y = __intVal(clipY);
  5637 	    r.x = __intVal(clipX);
  5602 	r.width = __intVal(clipWidth);
  5638 	    r.y = __intVal(clipY);
  5603 	r.height = __intVal(clipHeight);
  5639 	    r.width = __intVal(clipWidth);
  5604 	XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted);
  5640 	    r.height = __intVal(clipHeight);
  5605 	RETURN ( self );
  5641 	    XSetClipRectangles(myDpy, _GCVal(aGCId), 0, 0, &r, 1, Unsorted);
       
  5642 	    RETURN ( self );
       
  5643 	}
  5606     }
  5644     }
  5607 %}.
  5645 %}.
  5608     self primitiveFailed
  5646     self primitiveFailed
  5609 !
  5647 !
  5610 
  5648 
  5611 setDashes:dashList dashOffset:offset in:aGCId
  5649 setDashes:dashList dashOffset:offset in:aGCId
  5612     "set line attributes"
  5650     "set line attributes"
  5613 
  5651 
  5614 %{  /* NOCONTEXT */
  5652 %{  /* NOCONTEXT */
  5615 
  5653 
  5616     if (__isExternalAddress(aGCId)
  5654     if (ISCONNECTED) {
  5617      && __isSmallInteger(offset)
  5655         if (__isExternalAddress(aGCId)
  5618      && __isByteArray(dashList)) {
  5656          && __isSmallInteger(offset)
  5619 	XSetDashes(myDpy, _GCVal(aGCId), 
  5657          && __isByteArray(dashList)) {
  5620 		   __intVal(offset),
  5658 	    XSetDashes(myDpy, _GCVal(aGCId), 
  5621 		   __ByteArrayInstPtr(dashList)->ba_element,
  5659 		       __intVal(offset),
  5622 		   __byteArraySize(dashList));
  5660 		       __ByteArrayInstPtr(dashList)->ba_element,
  5623 	RETURN ( self );
  5661 		       __byteArraySize(dashList));
       
  5662 	    RETURN ( self );
       
  5663 	}
  5624     }
  5664     }
  5625 bad: ;
  5665 bad: ;
  5626 %}.
  5666 %}.
  5627     "
  5667     "
  5628      either aGCId is invalid,
  5668      either aGCId is invalid,
  5637 
  5677 
  5638 %{  /* NOCONTEXT */
  5678 %{  /* NOCONTEXT */
  5639 
  5679 
  5640     XFontStruct *f;
  5680     XFontStruct *f;
  5641 
  5681 
  5642     if (__isExternalAddress(aFontId)
  5682     if (ISCONNECTED) {
  5643      && __isExternalAddress(aGCId)) {
  5683         if (__isExternalAddress(aFontId)
  5644 	f = (XFontStruct *) _FontVal(aFontId);
  5684          && __isExternalAddress(aGCId)) {
  5645 	XSetFont(myDpy, _GCVal(aGCId), f->fid);
  5685 	    f = (XFontStruct *) _FontVal(aFontId);
  5646 	RETURN ( self );
  5686 	    XSetFont(myDpy, _GCVal(aGCId), f->fid);
       
  5687 	    RETURN ( self );
       
  5688 	}
  5647     }
  5689     }
  5648 %}.
  5690 %}.
  5649     "
  5691     "
  5650      aGCId and/or aFontId are invalid
  5692      aGCId and/or aFontId are invalid
  5651     "
  5693     "
  5655 setForeground:fgColorIndex background:bgColorIndex in:aGCId
  5697 setForeground:fgColorIndex background:bgColorIndex in:aGCId
  5656     "set foreground and background colors to be drawn with"
  5698     "set foreground and background colors to be drawn with"
  5657 
  5699 
  5658 %{  /* NOCONTEXT */
  5700 %{  /* NOCONTEXT */
  5659 
  5701 
  5660     Display *dpy = myDpy;
       
  5661     GC gc;
  5702     GC gc;
  5662 
  5703 
  5663     if (__bothSmallInteger(fgColorIndex, bgColorIndex)
  5704     if (ISCONNECTED) {
  5664      && __isExternalAddress(aGCId)) {
  5705         Display *dpy = myDpy;
  5665 	gc = _GCVal(aGCId);
  5706         if (__bothSmallInteger(fgColorIndex, bgColorIndex)
  5666 
  5707          && __isExternalAddress(aGCId)) {
  5667 	XSetForeground(dpy, gc, __intVal(fgColorIndex));
  5708 	    gc = _GCVal(aGCId);
  5668 	XSetBackground(dpy, gc, __intVal(bgColorIndex));
  5709 
  5669 	RETURN ( self );
  5710 	    XSetForeground(dpy, gc, __intVal(fgColorIndex));
       
  5711 	    XSetBackground(dpy, gc, __intVal(bgColorIndex));
       
  5712 	    RETURN ( self );
       
  5713 	}
  5670     }
  5714     }
  5671 %}.
  5715 %}.
  5672     self primitiveFailed
  5716     self primitiveFailed
  5673 !
  5717 !
  5674 
  5718 
  5676     "set foreground and background colors to be drawn with using mask or
  5720     "set foreground and background colors to be drawn with using mask or
  5677      solid (if aBitmapId is nil)"
  5721      solid (if aBitmapId is nil)"
  5678 
  5722 
  5679 %{  /* NOCONTEXT */
  5723 %{  /* NOCONTEXT */
  5680 
  5724 
  5681     Display *dpy = myDpy;
       
  5682     GC gc;
  5725     GC gc;
  5683 
  5726 
  5684     if (__isExternalAddress(aGCId)) {
  5727     if (ISCONNECTED) {
  5685 	gc = _GCVal(aGCId);
  5728         Display *dpy = myDpy;
  5686 	if (__isSmallInteger(fgColor))
  5729 
  5687 	    XSetForeground(dpy, gc, __intVal(fgColor));
  5730         if (__isExternalAddress(aGCId)) {
  5688 	if (__isSmallInteger(bgColor))
  5731 	    gc = _GCVal(aGCId);
  5689 	    XSetBackground(dpy, gc, __intVal(bgColor));
  5732 	    if (__isSmallInteger(fgColor))
  5690 
  5733 	        XSetForeground(dpy, gc, __intVal(fgColor));
  5691 	if (__isExternalAddress(aBitmapId)) {
  5734 	    if (__isSmallInteger(bgColor))
  5692 	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
  5735 	        XSetBackground(dpy, gc, __intVal(bgColor));
  5693 	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5736 
  5694 	    RETURN ( self );
  5737 	    if (__isExternalAddress(aBitmapId)) {
  5695 	}
  5738 	        XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
  5696 	if (aBitmapId == nil) {
  5739 	        XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5697 	    XSetFillStyle(dpy, gc, FillSolid);
  5740 	        RETURN ( self );
  5698 	    RETURN ( self );
  5741 	    }
       
  5742 	    if (aBitmapId == nil) {
       
  5743 	        XSetFillStyle(dpy, gc, FillSolid);
       
  5744 	        RETURN ( self );
       
  5745 	    }
  5699 	}
  5746 	}
  5700     }
  5747     }
  5701 %}.
  5748 %}.
  5702     self primitiveFailed
  5749     self primitiveFailed
  5703 !
  5750 !
  5706     "set foreground and background colors to be drawn with using mask or
  5753     "set foreground and background colors to be drawn with using mask or
  5707      solid (if aBitmapId is nil); also set lineWidth"
  5754      solid (if aBitmapId is nil); also set lineWidth"
  5708 
  5755 
  5709 %{  /* NOCONTEXT */
  5756 %{  /* NOCONTEXT */
  5710 
  5757 
  5711     Display *dpy = myDpy;
       
  5712     GC gc;
  5758     GC gc;
  5713 
  5759 
  5714     if (__isExternalAddress(aGCId)) {
  5760     if (ISCONNECTED) {
  5715 	gc = _GCVal(aGCId);
  5761         Display *dpy = myDpy;
  5716 	if (__isSmallInteger(lw)) {
  5762 
  5717 	    XSetLineAttributes(dpy, gc, __intVal(lw),
  5763         if (__isExternalAddress(aGCId)) {
  5718 				    LineSolid, CapNotLast, JoinMiter);
  5764 	    gc = _GCVal(aGCId);
  5719 	}
  5765 	    if (__isSmallInteger(lw)) {
  5720 	if (__isSmallInteger(fgColor))
  5766 	        XSetLineAttributes(dpy, gc, __intVal(lw),
  5721 	    XSetForeground(dpy, gc, __intVal(fgColor));
  5767 				        LineSolid, CapNotLast, JoinMiter);
  5722 	if (__isSmallInteger(bgColor))
  5768 	    }
  5723 	    XSetBackground(dpy, gc, __intVal(bgColor));
  5769 	    if (__isSmallInteger(fgColor))
  5724 
  5770 	        XSetForeground(dpy, gc, __intVal(fgColor));
  5725 	if (__isExternalAddress(aBitmapId)) {
  5771 	    if (__isSmallInteger(bgColor))
  5726 	    XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
  5772 	        XSetBackground(dpy, gc, __intVal(bgColor));
  5727 	    XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5773 
  5728 	    RETURN ( self );
  5774 	    if (__isExternalAddress(aBitmapId)) {
  5729 	}
  5775 	        XSetStipple(dpy, gc, _PixmapVal(aBitmapId));
  5730 	if (aBitmapId == nil) {
  5776 	        XSetFillStyle(dpy, gc, FillOpaqueStippled);
  5731 	    XSetFillStyle(dpy, gc, FillSolid);
  5777 	        RETURN ( self );
  5732 	    RETURN ( self );
  5778 	    }
       
  5779 	    if (aBitmapId == nil) {
       
  5780 	        XSetFillStyle(dpy, gc, FillSolid);
       
  5781 	        RETURN ( self );
       
  5782 	    }
  5733 	}
  5783 	}
  5734     }
  5784     }
  5735 %}.
  5785 %}.
  5736     self primitiveFailed
  5786     self primitiveFailed
  5737 !
  5787 !
  5739 setForeground:fgColorIndex in:aGCId
  5789 setForeground:fgColorIndex in:aGCId
  5740     "set foreground color to be drawn with"
  5790     "set foreground color to be drawn with"
  5741 
  5791 
  5742 %{  /* NOCONTEXT */
  5792 %{  /* NOCONTEXT */
  5743 
  5793 
  5744     if (__isExternalAddress(aGCId)
  5794     if (ISCONNECTED) {
  5745      && __isSmallInteger(fgColorIndex)) {
  5795         if (__isExternalAddress(aGCId)
  5746 	XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex));
  5796          && __isSmallInteger(fgColorIndex)) {
  5747 	RETURN ( self );
  5797 	    XSetForeground(myDpy, _GCVal(aGCId), __intVal(fgColorIndex));
       
  5798 	    RETURN ( self );
       
  5799         }
  5748     }
  5800     }
  5749 %}.
  5801 %}.
  5750     self primitiveFailed
  5802     self primitiveFailed
  5751 !
  5803 !
  5752 
  5804 
  5756 %{  /* NOCONTEXT */
  5808 %{  /* NOCONTEXT */
  5757 
  5809 
  5758     GC gc;
  5810     GC gc;
  5759     int fun = -1;
  5811     int fun = -1;
  5760 
  5812 
  5761     if (__isExternalAddress(aGCId)) {
  5813     if (ISCONNECTED) {
  5762 	gc = _GCVal(aGCId);
  5814         if (__isExternalAddress(aGCId)) {
  5763 	if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
  5815 	    gc = _GCVal(aGCId);
  5764 	else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
  5816 	    if (aFunctionSymbol == @symbol(copy)) fun = GXcopy;
  5765 	else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
  5817 	    else if (aFunctionSymbol == @symbol(copyInverted)) fun = GXcopyInverted;
  5766 	else if (aFunctionSymbol == @symbol(and)) fun = GXand;
  5818 	    else if (aFunctionSymbol == @symbol(xor)) fun = GXxor;
  5767 	else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
  5819 	    else if (aFunctionSymbol == @symbol(and)) fun = GXand;
  5768 	else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
  5820 	    else if (aFunctionSymbol == @symbol(andReverse)) fun = GXandReverse;
  5769 	else if (aFunctionSymbol == @symbol(or)) fun = GXor;
  5821 	    else if (aFunctionSymbol == @symbol(andInverted)) fun = GXandInverted;
  5770 	else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
  5822 	    else if (aFunctionSymbol == @symbol(or)) fun = GXor;
  5771 	else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
  5823 	    else if (aFunctionSymbol == @symbol(orReverse)) fun = GXorReverse;
  5772 	if (fun != -1) {
  5824 	    else if (aFunctionSymbol == @symbol(orInverted)) fun = GXorInverted;
  5773 	    XSetFunction(myDpy, gc, fun);
  5825 	    if (fun != -1) {
  5774 	    RETURN ( self );
  5826 	        XSetFunction(myDpy, gc, fun);
       
  5827 	        RETURN ( self );
       
  5828 	    }
  5775 	}
  5829 	}
  5776     }
  5830     }
  5777 %}.
  5831 %}.
  5778     "
  5832     "
  5779      either aGCId is not an integer, or an invalid symbol
  5833      either aGCId is not an integer, or an invalid symbol
  5786 setGraphicsExposures:aBoolean in:aGCId
  5840 setGraphicsExposures:aBoolean in:aGCId
  5787     "set or clear the graphics exposures flag"
  5841     "set or clear the graphics exposures flag"
  5788 
  5842 
  5789 %{  /* NOCONTEXT */
  5843 %{  /* NOCONTEXT */
  5790 
  5844 
  5791     if (__isExternalAddress(aGCId)) {
  5845     if (ISCONNECTED) {
  5792 	XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
  5846         if (__isExternalAddress(aGCId)) {
  5793 	RETURN ( self );
  5847 	    XSetGraphicsExposures(myDpy, _GCVal(aGCId), (aBoolean==true)?1:0);
       
  5848 	    RETURN ( self );
       
  5849 	}
  5794     }
  5850     }
  5795 %}
  5851 %}
  5796 .
  5852 .
  5797     self primitiveFailed
  5853     self primitiveFailed
  5798 !
  5854 !
  5802 
  5858 
  5803 %{  /* NOCONTEXT */
  5859 %{  /* NOCONTEXT */
  5804 
  5860 
  5805     int x_style, x_cap, x_join;
  5861     int x_style, x_cap, x_join;
  5806 
  5862 
  5807     if (__isExternalAddress(aGCId)
  5863     if (ISCONNECTED) {
  5808      && __isSmallInteger(aNumber)) {
  5864         if (__isExternalAddress(aGCId)
  5809 	if (lineStyle == @symbol(solid)) x_style = LineSolid;
  5865          && __isSmallInteger(aNumber)) {
  5810 	else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash;
  5866 	    if (lineStyle == @symbol(solid)) x_style = LineSolid;
  5811 	else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash;
  5867 	    else if (lineStyle == @symbol(dashed)) x_style = LineOnOffDash;
  5812 	else  goto bad;
  5868 	    else if (lineStyle == @symbol(doubleDashed)) x_style = LineDoubleDash;
  5813 
  5869 	    else  goto bad;
  5814 	if (capStyle == @symbol(notLast)) x_cap = CapNotLast;
  5870 
  5815 	else if (capStyle == @symbol(butt)) x_cap = CapButt;
  5871 	    if (capStyle == @symbol(notLast)) x_cap = CapNotLast;
  5816 	else if (capStyle == @symbol(round)) x_cap  = CapRound;
  5872 	    else if (capStyle == @symbol(butt)) x_cap = CapButt;
  5817 	else if (capStyle == @symbol(projecting)) x_cap  = CapProjecting;
  5873 	    else if (capStyle == @symbol(round)) x_cap  = CapRound;
  5818 	else  goto bad;
  5874 	    else if (capStyle == @symbol(projecting)) x_cap  = CapProjecting;
  5819 
  5875 	    else  goto bad;
  5820 	if (joinStyle == @symbol(miter)) x_join = JoinMiter;
  5876 
  5821 	else if (joinStyle == @symbol(bevel)) x_join = JoinBevel;
  5877 	    if (joinStyle == @symbol(miter)) x_join = JoinMiter;
  5822 	else if (joinStyle == @symbol(round)) x_join  = JoinRound;
  5878 	    else if (joinStyle == @symbol(bevel)) x_join = JoinBevel;
  5823 	else  goto bad;
  5879 	    else if (joinStyle == @symbol(round)) x_join  = JoinRound;
  5824 
  5880 	    else  goto bad;
  5825 	XSetLineAttributes(myDpy,
  5881 
  5826 			   _GCVal(aGCId), __intVal(aNumber),
  5882 	    XSetLineAttributes(myDpy,
  5827 			   x_style, x_cap, x_join);
  5883 			       _GCVal(aGCId), __intVal(aNumber),
  5828 	RETURN ( self );
  5884 			       x_style, x_cap, x_join);
       
  5885 	    RETURN ( self );
       
  5886 	}
  5829     }
  5887     }
  5830 bad: ;
  5888 bad: ;
  5831 %}.
  5889 %}.
  5832     "
  5890     "
  5833      either aGCId is invalid,
  5891      either aGCId is invalid,
  5841 setMaskOriginX:orgX y:orgY in:aGCid
  5899 setMaskOriginX:orgX y:orgY in:aGCid
  5842     "set the mask origin"
  5900     "set the mask origin"
  5843 
  5901 
  5844 %{  /* NOCONTEXT */
  5902 %{  /* NOCONTEXT */
  5845 
  5903 
  5846     if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
  5904     if (ISCONNECTED) {
  5847 	XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY));
  5905         if (__bothSmallInteger(orgX, orgY) && __isExternalAddress(aGCid)) {
  5848 	RETURN ( self );
  5906 	    XSetTSOrigin(myDpy, _GCVal(aGCid), __intVal(orgX), __intVal(orgY));
       
  5907 	    RETURN ( self );
       
  5908 	}
  5849     }
  5909     }
  5850 %}.
  5910 %}.
  5851     self primitiveFailed
  5911     self primitiveFailed
  5852 !
  5912 !
  5853 
  5913 
  5858 
  5918 
  5859     Display *dpy = myDpy;
  5919     Display *dpy = myDpy;
  5860     GC gc;
  5920     GC gc;
  5861     Pixmap pixmap;
  5921     Pixmap pixmap;
  5862 
  5922 
  5863     if (__isExternalAddress(aGCId)) {
  5923     if (ISCONNECTED) {
  5864 	gc = _GCVal(aGCId);
  5924         if (__isExternalAddress(aGCId)) {
  5865 	if (__isExternalAddress(aPixmapId)) {
  5925 	    gc = _GCVal(aGCId);
  5866 	    pixmap = _PixmapVal(aPixmapId);
  5926 	    if (__isExternalAddress(aPixmapId)) {
  5867 	    XSetTile(dpy, gc, pixmap);
  5927 	        pixmap = _PixmapVal(aPixmapId);
  5868 	    XSetFillStyle(dpy, gc, FillTiled);
  5928 	        XSetTile(dpy, gc, pixmap);
  5869 	    RETURN ( self );
  5929 	        XSetFillStyle(dpy, gc, FillTiled);
  5870 	}
  5930 	        RETURN ( self );
  5871 	if (aPixmapId == nil) {
  5931 	    }
  5872 	    XSetFillStyle(dpy, gc, FillSolid);
  5932 	    if (aPixmapId == nil) {
  5873 	    RETURN ( self );
  5933 	        XSetFillStyle(dpy, gc, FillSolid);
       
  5934 	        RETURN ( self );
       
  5935 	    }
  5874 	}
  5936 	}
  5875     }
  5937     }
  5876 %}.
  5938 %}.
  5877     self primitiveFailed
  5939     self primitiveFailed
  5878 ! !
  5940 ! !
  5882 closeConnection
  5944 closeConnection
  5883     "close down the connection to the X-server"
  5945     "close down the connection to the X-server"
  5884 
  5946 
  5885 %{  /* NOCONTEXT */
  5947 %{  /* NOCONTEXT */
  5886 
  5948 
  5887     Display *dpy = myDpy;
       
  5888 
       
  5889     if (ISCONNECTED) {
  5949     if (ISCONNECTED) {
       
  5950         Display *dpy = myDpy;
       
  5951 
  5890         BEGIN_INTERRUPTSBLOCKED
  5952         BEGIN_INTERRUPTSBLOCKED
  5891         __INST(displayId) = nil;
  5953         __INST(displayId) = nil;
  5892         XCloseDisplay(myDpy);
  5954         XCloseDisplay(myDpy);
  5893         END_INTERRUPTSBLOCKED
  5955         END_INTERRUPTSBLOCKED
  5894     }
  5956     }
  6061 initializeScreenProperties
  6123 initializeScreenProperties
  6062     super initializeScreenProperties.
  6124     super initializeScreenProperties.
  6063 
  6125 
  6064 %{  /* NOCONTEXT */
  6126 %{  /* NOCONTEXT */
  6065 
  6127 
  6066     Display *dpy = myDpy;
  6128     Display *dpy;
  6067     int scr;
  6129     int scr;
  6068     Visual *visual;
  6130     Visual *visual;
  6069     XVisualInfo viproto;
  6131     XVisualInfo viproto;
  6070     XVisualInfo *vip;                   /* retured info */
  6132     XVisualInfo *vip;                   /* retured info */
  6071     int maxRGBDepth;
  6133     int maxRGBDepth;
  6077     char *type, *nm;
  6139     char *type, *nm;
  6078     int dummy;
  6140     int dummy;
  6079     int mask, shift, nBits;
  6141     int mask, shift, nBits;
  6080 
  6142 
  6081     if (ISCONNECTED) {
  6143     if (ISCONNECTED) {
       
  6144         dpy = myDpy;
       
  6145 
  6082 	__INST(altModifierMask) = __MKSMALLINT(Mod2Mask);
  6146 	__INST(altModifierMask) = __MKSMALLINT(Mod2Mask);
  6083 	__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask);
  6147 	__INST(metaModifierMask) = __MKSMALLINT(Mod1Mask);
  6084 
  6148 
  6085 	BEGIN_INTERRUPTSBLOCKED
  6149 	BEGIN_INTERRUPTSBLOCKED
  6086 
  6150 
  6393      We return an array of arrays of keycodes"
  6457      We return an array of arrays of keycodes"
  6394 
  6458 
  6395     |modifierKeyMap maxKeyPerMod ret nextKey|
  6459     |modifierKeyMap maxKeyPerMod ret nextKey|
  6396 
  6460 
  6397 %{
  6461 %{
  6398     Display *dpy = myDpy;
       
  6399     XModifierKeymap *modmap;
  6462     XModifierKeymap *modmap;
  6400     OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT();
  6463     OBJ __BYTEARRAY_UNINITIALIZED_NEW_INT();
  6401 
  6464 
  6402     if (ISCONNECTED) {
  6465     if (ISCONNECTED) {
       
  6466         Display *dpy = myDpy;
       
  6467 
  6403 	if ((modmap = XGetModifierMapping(myDpy)) != 0) {
  6468 	if ((modmap = XGetModifierMapping(myDpy)) != 0) {
  6404 	   maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
  6469 	   maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
  6405 	   modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8);
  6470 	   modifierKeyMap = __BYTEARRAY_UNINITIALIZED_NEW_INT(modmap->max_keypermod * 8);
  6406 	   if (modifierKeyMap != nil) {
  6471 	   if (modifierKeyMap != nil) {
  6407 		maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
  6472 		maxKeyPerMod = __MKSMALLINT(modmap->max_keypermod);
  6443     "Get a KeySymbol (a smalltalk symbol) from the keycode."
  6508     "Get a KeySymbol (a smalltalk symbol) from the keycode."
  6444 
  6509 
  6445     |str|
  6510     |str|
  6446 
  6511 
  6447 %{
  6512 %{
  6448     Display *dpy = myDpy;
       
  6449     KeySym keysym;
  6513     KeySym keysym;
  6450     char *keystring;
  6514     char *keystring;
  6451 
  6515 
  6452     if (ISCONNECTED && __isSmallInteger(code)) {
  6516     if (ISCONNECTED && __isSmallInteger(code)) {
       
  6517         Display *dpy = myDpy;
       
  6518 
  6453 	if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol &&
  6519 	if ((keysym = XKeycodeToKeysym(myDpy, __intVal(code), 0)) != NoSymbol &&
  6454 	    (keystring = XKeysymToString(keysym)) != 0) 
  6520 	    (keystring = XKeysymToString(keysym)) != 0) 
  6455 	    str = __MKSTRING(keystring);
  6521 	    str = __MKSTRING(keystring);
  6456     }
  6522     }
  6457 %}.
  6523 %}.
  6659      a one-bit in positions 0.. represent a pressed button.
  6725      a one-bit in positions 0.. represent a pressed button.
  6660      See the button1Mask/button2Mask/button3Mask,
  6726      See the button1Mask/button2Mask/button3Mask,
  6661      shiftMask/controlMask and modifierMask methods for the meaning of the bits."
  6727      shiftMask/controlMask and modifierMask methods for the meaning of the bits."
  6662 
  6728 
  6663 %{  /* NOCONTEXT*/
  6729 %{  /* NOCONTEXT*/
  6664     Display *dpy = myDpy;
       
  6665     Window w;
  6730     Window w;
  6666     int screen = __intVal(__INST(screen));
  6731     int screen = __intVal(__INST(screen));
  6667     Window rootRet, childRet;
  6732     Window rootRet, childRet;
  6668     int rootX, rootY, winX, winY;
  6733     int rootX, rootY, winX, winY;
  6669     unsigned int mask;
  6734     unsigned int mask;
  6670 
  6735 
  6671     BEGIN_INTERRUPTSBLOCKED
  6736     if (ISCONNECTED) {
       
  6737         Display *dpy = myDpy;
       
  6738 
       
  6739         BEGIN_INTERRUPTSBLOCKED
  6672 #ifdef VIRTUAL_ROOT
  6740 #ifdef VIRTUAL_ROOT
  6673     w = getRootWindow(myDpy, screen);
  6741         w = getRootWindow(myDpy, screen);
  6674 #else
  6742 #else
  6675     w = RootWindow(dpy, screen);
  6743         w = RootWindow(dpy, screen);
  6676 #endif
  6744 #endif
  6677     XQueryPointer(dpy, w, &rootRet, &childRet,
  6745         XQueryPointer(dpy, w, &rootRet, &childRet,
  6678 			  &rootX, &rootY,
  6746 			      &rootX, &rootY,
  6679 			  &winX, &winY,
  6747 			      &winX, &winY,
  6680 			  &mask);
  6748 			      &mask);
  6681     END_INTERRUPTSBLOCKED
  6749         END_INTERRUPTSBLOCKED
  6682     RETURN (__MKSMALLINT(mask));
  6750         RETURN (__MKSMALLINT(mask));
  6683 %}
  6751     }
       
  6752 %}.
       
  6753     self primitiveFailed
  6684 
  6754 
  6685     "
  6755     "
  6686      Display buttonStates     
  6756      Display buttonStates     
  6687     "
  6757     "
  6688 
  6758 
  6724     "return the current pointer position in root-window coordinates"
  6794     "return the current pointer position in root-window coordinates"
  6725 
  6795 
  6726     |xpos ypos|
  6796     |xpos ypos|
  6727 
  6797 
  6728 %{
  6798 %{
  6729     Display *dpy = myDpy;
       
  6730     Window w;
  6799     Window w;
  6731     int screen = __intVal(__INST(screen));
  6800     int screen = __intVal(__INST(screen));
  6732     Window rootRet, childRet;
  6801     Window rootRet, childRet;
  6733     int rootX, rootY, winX, winY;
  6802     int rootX, rootY, winX, winY;
  6734     unsigned int mask;
  6803     unsigned int mask;
  6735 
  6804 
  6736     BEGIN_INTERRUPTSBLOCKED
  6805     if (ISCONNECTED) {
       
  6806         Display *dpy = myDpy;
       
  6807 
       
  6808         BEGIN_INTERRUPTSBLOCKED
  6737 #ifdef VIRTUAL_ROOT
  6809 #ifdef VIRTUAL_ROOT
  6738     w = getRootWindow(myDpy, screen);
  6810         w = getRootWindow(myDpy, screen);
  6739 #else
  6811 #else
  6740     w = RootWindow(dpy, screen);
  6812         w = RootWindow(dpy, screen);
  6741 #endif
  6813 #endif
  6742     XQueryPointer(dpy, w, &rootRet, &childRet,
  6814         XQueryPointer(dpy, w, &rootRet, &childRet,
  6743 			  &rootX, &rootY,
  6815 			      &rootX, &rootY,
  6744 			  &winX, &winY,
  6816 			      &winX, &winY,
  6745 			  &mask);
  6817 			      &mask);
  6746     xpos = __MKSMALLINT(rootX);
  6818         xpos = __MKSMALLINT(rootX);
  6747     ypos = __MKSMALLINT(rootY);
  6819         ypos = __MKSMALLINT(rootY);
  6748     END_INTERRUPTSBLOCKED
  6820         END_INTERRUPTSBLOCKED
       
  6821     }
  6749 %}
  6822 %}
  6750 .
  6823 .
  6751     ^ xpos @ ypos
  6824     ^ xpos @ ypos
  6752 !
  6825 !
  6753 
  6826 
  7025     "since XGetImage may allocate huge amount of stack space 
  7098     "since XGetImage may allocate huge amount of stack space 
  7026      (some implementations use alloca), this must run with unlimited stack."
  7099      (some implementations use alloca), this must run with unlimited stack."
  7027 
  7100 
  7028 %{  /* UNLIMITEDSTACK */
  7101 %{  /* UNLIMITEDSTACK */
  7029 
  7102 
  7030     Display *dpy = myDpy;
       
  7031     Window win;
  7103     Window win;
  7032     XImage *image = (XImage *)0;
  7104     XImage *image = (XImage *)0;
  7033     int pad, bytes_per_line, numBytes;
  7105     int pad, bytes_per_line, numBytes;
  7034 
  7106 
  7035     if (__isExternalAddress(aDrawableId)
  7107     if (ISCONNECTED
       
  7108      && __isExternalAddress(aDrawableId)
  7036      && __bothSmallInteger(srcx, srcy)
  7109      && __bothSmallInteger(srcx, srcy)
  7037      && __bothSmallInteger(w, h)
  7110      && __bothSmallInteger(w, h)
  7038      && __isArray(info)
  7111      && __isArray(info)
  7039      && __isByteArray(imageBits)) {
  7112      && __isByteArray(imageBits)) {
       
  7113         Display *dpy = myDpy;
       
  7114 
  7040 	win = _WindowVal(aDrawableId);
  7115 	win = _WindowVal(aDrawableId);
  7041 	image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy),
  7116 	image = XGetImage(dpy, win, __intVal(srcx), __intVal(srcy),
  7042 				    __intVal(w), __intVal(h),
  7117 				    __intVal(w), __intVal(h),
  7043 				    (unsigned)AllPlanes, ZPixmap);
  7118 				    (unsigned)AllPlanes, ZPixmap);
  7044 
  7119 
  7129 
  7204 
  7130     |val typeID cls|
  7205     |val typeID cls|
  7131 
  7206 
  7132     cls := ByteArray.
  7207     cls := ByteArray.
  7133 %{
  7208 %{
  7134     Display *dpy = myDpy;
       
  7135     Window window;
  7209     Window window;
  7136     Atom property;
  7210     Atom property;
  7137     char *cp, *cp2;
  7211     char *cp, *cp2;
  7138     Atom actual_type;
  7212     Atom actual_type;
  7139     int actual_format,i;
  7213     int actual_format,i;
  7140     unsigned long nitems, bytes_after, nread;
  7214     unsigned long nitems, bytes_after, nread;
  7141     unsigned char *data;
  7215     unsigned char *data;
  7142     int ok = 1;
  7216     int ok = 1;
  7143 #   define PROP_SIZE    2048
  7217 #   define PROP_SIZE    2048
  7144 
  7218 
  7145     if (__isAtomID(propertyID)) {
  7219     if (ISCONNECTED) {
  7146 	property = _AtomVal(propertyID);
  7220         Display *dpy = myDpy;
  7147 	if (__isExternalAddress(aWindowID)) {
  7221 
  7148 	    window = _WindowVal(aWindowID);
  7222         if (__isAtomID(propertyID)) {
  7149 	} else {
  7223 	    property = _AtomVal(propertyID);
  7150 	    window = DefaultRootWindow(dpy);
  7224 	    if (__isExternalAddress(aWindowID)) {
  7151 	}
  7225 	        window = _WindowVal(aWindowID);
  7152 
  7226 	    } else {
  7153 	nread = 0;
  7227 	        window = DefaultRootWindow(dpy);
  7154 	cp = 0;
  7228 	    }
       
  7229 
       
  7230 	    nread = 0;
       
  7231 	    cp = 0;
  7155 /*
  7232 /*
  7156 	fprintf(stderr, "getProperty: ");
  7233 	    fprintf(stderr, "getProperty: ");
  7157  */
  7234  */
  7158 	do {
  7235 	    do {
  7159 	    if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False,
  7236 	        if (XGetWindowProperty(dpy,window,property,nread/4,PROP_SIZE,False,
  7160 				   AnyPropertyType,&actual_type,&actual_format,
  7237 				       AnyPropertyType,&actual_type,&actual_format,
  7161 				   &nitems,&bytes_after,(unsigned char **)&data)
  7238 				       &nitems,&bytes_after,(unsigned char **)&data)
  7162 		!= Success) {
  7239 		    != Success) {
  7163 		    ok = 0;
  7240 		        ok = 0;
  7164 		    break;
  7241 		        break;
       
  7242 	        }
       
  7243 	        typeID = __MKATOMOBJ(actual_type);
       
  7244 	        if (! cp) {
       
  7245 		    cp = cp2 = (char *)malloc(nitems+1);
       
  7246 	        } else {
       
  7247 		    cp = (char *)realloc(cp, nread + nitems + 1);
       
  7248 		    cp2 = cp + nread;
       
  7249 	        }
       
  7250 	        if (! cp) {
       
  7251 		    XFree(data);
       
  7252 		    goto fail;
       
  7253 	        }
       
  7254     
       
  7255 	        nread += nitems;
       
  7256 	        bcopy(data, cp2, nitems);
       
  7257 	        XFree(data);
       
  7258     /*
       
  7259 	        fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after);
       
  7260      */
       
  7261 	    } while (bytes_after > 0);
       
  7262     /*
       
  7263 	    fprintf(stderr, "\n");
       
  7264      */
       
  7265     
       
  7266 	    if (ok) {
       
  7267 	        if (actual_type == XA_STRING) {
       
  7268 		    cp[nread] = '\0';
       
  7269 		    val = __MKSTRING_L(cp, nread);
       
  7270 	        } else {
       
  7271 		    val = __new(nread + OHDR_SIZE);
       
  7272 		    val->o_class = cls;
       
  7273 		    bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread);
       
  7274 	        }
  7165 	    }
  7275 	    }
  7166 	    typeID = __MKATOMOBJ(actual_type);
  7276 	    if (cp)
  7167 	    if (! cp) {
  7277 	        free(cp);
  7168 		cp = cp2 = (char *)malloc(nitems+1);
  7278         }
  7169 	    } else {
       
  7170 		cp = (char *)realloc(cp, nread + nitems + 1);
       
  7171 		cp2 = cp + nread;
       
  7172 	    }
       
  7173 	    if (! cp) {
       
  7174 		XFree(data);
       
  7175 		goto fail;
       
  7176 	    }
       
  7177 
       
  7178 	    nread += nitems;
       
  7179 	    bcopy(data, cp2, nitems);
       
  7180 	    XFree(data);
       
  7181 /*
       
  7182 	    fprintf(stderr, "<nitems:%d bytes_after:%d>", nitems, bytes_after);
       
  7183  */
       
  7184 	} while (bytes_after > 0);
       
  7185 /*
       
  7186 	fprintf(stderr, "\n");
       
  7187  */
       
  7188 
       
  7189 	if (ok) {
       
  7190 	    if (actual_type == XA_STRING) {
       
  7191 		cp[nread] = '\0';
       
  7192 		val = __MKSTRING_L(cp, nread);
       
  7193 	    } else {
       
  7194 		val = __new(nread + OHDR_SIZE);
       
  7195 		val->o_class = cls;
       
  7196 		bcopy(cp, __ByteArrayInstPtr(val)->ba_element, nread);
       
  7197 	    }
       
  7198 	}
       
  7199 	if (cp)
       
  7200 	    free(cp);
       
  7201     }
  7279     }
  7202 fail: ;
  7280 fail: ;
  7203 %}.
  7281 %}.
  7204     typeID isNil ifTrue:[
  7282     typeID isNil ifTrue:[
  7205 	^ false
  7283 	^ false
  7226 
  7304 
  7227 getSelectionOwnerOf:selectionAtomID
  7305 getSelectionOwnerOf:selectionAtomID
  7228     "get the owner of a selection"
  7306     "get the owner of a selection"
  7229 
  7307 
  7230 %{  /* NOCONTEXT */
  7308 %{  /* NOCONTEXT */
  7231     Display *dpy = myDpy;
       
  7232     Atom selection;
  7309     Atom selection;
  7233     Window window;
  7310     Window window;
  7234 
  7311 
  7235     if (__isAtomID(selectionAtomID) && ISCONNECTED) {
  7312     if (__isAtomID(selectionAtomID) && ISCONNECTED) {
       
  7313         Display *dpy = myDpy;
       
  7314 
  7236 	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
  7315 	window = XGetSelectionOwner(dpy, _AtomVal(selectionAtomID));
  7237 	RETURN ((window == None) ? nil : __MKOBJ(window));
  7316 	RETURN ((window == None) ? nil : __MKOBJ(window));
  7238     }
  7317     }
  7239 %}.
  7318 %}.
  7240      self primitiveFailed.
  7319      self primitiveFailed.
  7282     "ask the server to send us the selection - the view with id aWindowID
  7361     "ask the server to send us the selection - the view with id aWindowID
  7283      will later receive a SelectionNotify event for it (once the Xserver replies
  7362      will later receive a SelectionNotify event for it (once the Xserver replies
  7284      with the selections value)."
  7363      with the selections value)."
  7285 
  7364 
  7286 %{  /* NOCONTEXT */
  7365 %{  /* NOCONTEXT */
  7287     Display *dpy = myDpy;
       
  7288     Atom sel_prop;
  7366     Atom sel_prop;
  7289     char *cp;
  7367     char *cp;
  7290 
  7368 
  7291     if (__isExternalAddress(aWindowId)
  7369     if (__isExternalAddress(aWindowId)
  7292      && ISCONNECTED
  7370      && ISCONNECTED
  7293      && __isSmallInteger(typeID)
  7371      && __isSmallInteger(typeID)
  7294      && __isAtomID(selectionID)) {
  7372      && __isAtomID(selectionID)) {
       
  7373         Display *dpy = myDpy;
       
  7374 
  7295 	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) {
  7375 	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) == None) {
  7296 	    /*
  7376 	    /*
  7297 	     * no owner of primary selection
  7377 	     * no owner of primary selection
  7298 	     */
  7378 	     */
  7299 	    RETURN (false);
  7379 	    RETURN (false);
  7356 
  7436 
  7357 sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID
  7437 sendSelectionNotifySelection:selectionID property:propertyID target:targetID from:windowID to:requestorID
  7358     "send a selectionNotify back from a SelectionRequest"
  7438     "send a selectionNotify back from a SelectionRequest"
  7359 
  7439 
  7360 %{  /* NOCONTEXT */
  7440 %{  /* NOCONTEXT */
  7361     Display *dpy = myDpy;
       
  7362 
  7441 
  7363     if (__isAtomID(propertyID)
  7442     if (__isAtomID(propertyID)
  7364      && __isExternalAddress(requestorID)
  7443      && __isExternalAddress(requestorID)
  7365      && ISCONNECTED
  7444      && ISCONNECTED
  7366      && __isAtomID(targetID)
  7445      && __isAtomID(targetID)
  7367      && __isAtomID(selectionID)) {
  7446      && __isAtomID(selectionID)) {
       
  7447         Display *dpy = myDpy;
  7368 	XEvent ev;
  7448 	XEvent ev;
  7369 	Window requestor = _WindowVal(requestorID);
  7449 	Window requestor = _WindowVal(requestorID);
  7370 	Atom property = _AtomVal(propertyID);
  7450 	Atom property = _AtomVal(propertyID);
  7371 	Atom target = _AtomVal(targetID);
  7451 	Atom target = _AtomVal(targetID);
  7372 	Atom selection = _AtomVal(selectionID);
  7452 	Atom selection = _AtomVal(selectionID);
  7425 
  7505 
  7426 setProperty:propertyID type:typeID value:anObject for:aWindowID
  7506 setProperty:propertyID type:typeID value:anObject for:aWindowID
  7427 
  7507 
  7428 %{  /* UNLIMITEDSTACK */
  7508 %{  /* UNLIMITEDSTACK */
  7429 
  7509 
  7430     Display *dpy = myDpy;
       
  7431     Atom prop, type;
  7510     Atom prop, type;
  7432     Window window;
  7511     Window window;
  7433     unsigned int value;
  7512     unsigned int value;
  7434 
  7513 
  7435     if (__isAtomID(propertyID)
  7514     if (__isAtomID(propertyID)
  7438      && (__isString(anObject) 
  7517      && (__isString(anObject) 
  7439 	 || __isSmallInteger(anObject) 
  7518 	 || __isSmallInteger(anObject) 
  7440 	 || __isSymbol(anObject) 
  7519 	 || __isSymbol(anObject) 
  7441 	 || __isByteArray(anObject)
  7520 	 || __isByteArray(anObject)
  7442 	 || __isWords(anObject))) { 
  7521 	 || __isWords(anObject))) { 
       
  7522 
       
  7523         Display *dpy = myDpy;
  7443 
  7524 
  7444 	prop = _AtomVal(propertyID);
  7525 	prop = _AtomVal(propertyID);
  7445 	type = _AtomVal(typeID);
  7526 	type = _AtomVal(typeID);
  7446 	if (__isExternalAddress(aWindowID)) {
  7527 	if (__isExternalAddress(aWindowID)) {
  7447 	    window = _WindowVal(aWindowID);
  7528 	    window = _WindowVal(aWindowID);
  7493 
  7574 
  7494 setSelectionOwner:aWindowId of:selectionID
  7575 setSelectionOwner:aWindowId of:selectionID
  7495     "set the owner of a selection; return false if failed"
  7576     "set the owner of a selection; return false if failed"
  7496 
  7577 
  7497 %{  /* NOCONTEXT */
  7578 %{  /* NOCONTEXT */
  7498     Display *dpy = myDpy;
       
  7499     Window win;
  7579     Window win;
  7500 
  7580 
  7501     if (__isExternalAddress(aWindowId)
  7581     if (__isExternalAddress(aWindowId)
  7502      && __isAtomID(selectionID)
  7582      && __isAtomID(selectionID)
  7503      && ISCONNECTED) {
  7583      && ISCONNECTED) {
       
  7584         Display *dpy = myDpy;
       
  7585 
  7504 	win = _WindowVal(aWindowId);
  7586 	win = _WindowVal(aWindowId);
  7505 	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
  7587 	XSetSelectionOwner(dpy, _AtomVal(selectionID), win, CurrentTime);
  7506 	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) {
  7588 	if (XGetSelectionOwner(dpy, _AtomVal(selectionID)) != win) {
  7507 	    RETURN (false);
  7589 	    RETURN (false);
  7508 	}
  7590 	}
  7537 
  7619 
  7538 %{  /* NOCONTEXT */
  7620 %{  /* NOCONTEXT */
  7539 
  7621 
  7540     int w, h;
  7622     int w, h;
  7541 
  7623 
  7542     if (__isExternalAddress(aWindowId)
  7624     if (ISCONNECTED) {
  7543      && __bothSmallInteger(x, y)
  7625         if (__isExternalAddress(aWindowId)
  7544      && __bothSmallInteger(width, height)) {
  7626          && __bothSmallInteger(x, y)
  7545 	w = __intVal(width);
  7627          && __bothSmallInteger(width, height)) {
  7546 	h = __intVal(height);
  7628 	    w = __intVal(width);
  7547 	/*
  7629 	    h = __intVal(height);
  7548 	 * need this check here: some servers simply dump core with bad args
  7630 	    /*
  7549 	 */
  7631 	     * need this check here: some servers simply dump core with bad args
  7550 	if ((w >= 0) && (h >= 0)) {
  7632 	     */
  7551 	    XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0);
  7633 	    if ((w >= 0) && (h >= 0)) {
  7552 	}
  7634 	        XClearArea(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y), w, h, 0);
  7553 	RETURN ( self );
  7635 	    }
       
  7636 	    RETURN ( self );
       
  7637 	}
  7554     }
  7638     }
  7555 %}
  7639 %}
  7556 .
  7640 .
  7557     self primitiveFailed
  7641     self primitiveFailed
  7558 !
  7642 !
  7560 clearWindow:aWindowId
  7644 clearWindow:aWindowId
  7561     "clear a window to viewbackground"
  7645     "clear a window to viewbackground"
  7562 
  7646 
  7563 %{  /* NOCONTEXT */
  7647 %{  /* NOCONTEXT */
  7564 
  7648 
  7565     if (__isExternalAddress(aWindowId)) {
  7649     if (ISCONNECTED) {
  7566 	XClearWindow(myDpy, _WindowVal(aWindowId));
  7650         if (__isExternalAddress(aWindowId)) {
  7567 	RETURN ( self );
  7651 	    XClearWindow(myDpy, _WindowVal(aWindowId));
       
  7652 	    RETURN ( self );
       
  7653 	}
  7568     }
  7654     }
  7569 %}
  7655 %}
  7570 .
  7656 .
  7571     self primitiveFailed
  7657     self primitiveFailed
  7572 !
  7658 !
  7577 %{  /* NOCONTEXT */
  7663 %{  /* NOCONTEXT */
  7578 
  7664 
  7579     XWindowChanges chg;
  7665     XWindowChanges chg;
  7580     int mask = CWSibling | CWStackMode;
  7666     int mask = CWSibling | CWStackMode;
  7581 
  7667 
  7582     if (__isExternalAddress(aWindowId)
  7668     if (ISCONNECTED) {
  7583      && __isExternalAddress(siblingId)) {
  7669         if (__isExternalAddress(aWindowId)
  7584 	if (modeSymbol == @symbol(above)) {
  7670          && __isExternalAddress(siblingId)) {
  7585 	    chg.stack_mode = Above;
  7671 	    if (modeSymbol == @symbol(above)) {
  7586 	} else if (modeSymbol == @symbol(below)) {
  7672 	        chg.stack_mode = Above;
  7587 	    chg.stack_mode = Below;
  7673 	    } else if (modeSymbol == @symbol(below)) {
  7588 	} else if (modeSymbol == @symbol(topIf)) {
  7674 	        chg.stack_mode = Below;
  7589 	    chg.stack_mode = TopIf;
  7675 	    } else if (modeSymbol == @symbol(topIf)) {
  7590 	} else if (modeSymbol == @symbol(bottomIf)) {
  7676 	        chg.stack_mode = TopIf;
  7591 	    chg.stack_mode = BottomIf;
  7677 	    } else if (modeSymbol == @symbol(bottomIf)) {
  7592 	} else if (modeSymbol == @symbol(opposite)) {
  7678 	        chg.stack_mode = BottomIf;
  7593 	    chg.stack_mode = Opposite;
  7679 	    } else if (modeSymbol == @symbol(opposite)) {
  7594 	} else {
  7680 	        chg.stack_mode = Opposite;
  7595 	    mask = CWSibling;
  7681 	    } else {
  7596 	}
  7682 	        mask = CWSibling;
  7597 
  7683 	    }
  7598 	chg.sibling = _WindowVal(siblingId);
  7684 
  7599 	XConfigureWindow(myDpy, _WindowVal(aWindowId),
  7685 	    chg.sibling = _WindowVal(siblingId);
  7600 				mask, &chg);
  7686 	    XConfigureWindow(myDpy, _WindowVal(aWindowId),
  7601 	RETURN ( self );
  7687 				    mask, &chg);
       
  7688 	    RETURN ( self );
       
  7689 	}
  7602     }
  7690     }
  7603 bad: ;
  7691 bad: ;
  7604 %}
  7692 %}
  7605 .
  7693 .
  7606     self primitiveFailed
  7694     self primitiveFailed
  7609 lowerWindow:aWindowId
  7697 lowerWindow:aWindowId
  7610     "bring a window to back"
  7698     "bring a window to back"
  7611 
  7699 
  7612 %{  /* NOCONTEXT */
  7700 %{  /* NOCONTEXT */
  7613 
  7701 
  7614     if (__isExternalAddress(aWindowId)) {
  7702     if (ISCONNECTED
       
  7703      && __isExternalAddress(aWindowId)) {
  7615 	XLowerWindow(myDpy, _WindowVal(aWindowId));
  7704 	XLowerWindow(myDpy, _WindowVal(aWindowId));
  7616 	RETURN ( self );
  7705 	RETURN ( self );
  7617     }
  7706     }
  7618 %}
  7707 %}
  7619 .
  7708 .
  7638     ].
  7727     ].
  7639 %{  
  7728 %{  
  7640 
  7729 
  7641     XWMHints wmhints;
  7730     XWMHints wmhints;
  7642     XSizeHints szhints;
  7731     XSizeHints szhints;
  7643     Display *dpy = myDpy;
       
  7644     Window win;
  7732     Window win;
  7645 
  7733 
  7646     if (__isExternalAddress(aWindowId)) {
  7734     if (ISCONNECTED
       
  7735      && __isExternalAddress(aWindowId)) {
       
  7736         Display *dpy = myDpy;
       
  7737 
  7647 	win = _WindowVal(aWindowId);
  7738 	win = _WindowVal(aWindowId);
  7648 
  7739 
  7649 	szhints.flags = 0;
  7740 	szhints.flags = 0;
  7650 	if (__bothSmallInteger(xPos, yPos)) {
  7741 	if (__bothSmallInteger(xPos, yPos)) {
  7651 	    szhints.x = __intVal(xPos);
  7742 	    szhints.x = __intVal(xPos);
  7715 mapWindow:aWindowId
  7806 mapWindow:aWindowId
  7716     "make a window visible"
  7807     "make a window visible"
  7717 
  7808 
  7718 %{  /* NOCONTEXT */
  7809 %{  /* NOCONTEXT */
  7719 
  7810 
  7720     if (__isExternalAddress(aWindowId)) {
  7811     if (ISCONNECTED
       
  7812      && __isExternalAddress(aWindowId)) {
  7721 	XMapWindow(myDpy, _WindowVal(aWindowId));
  7813 	XMapWindow(myDpy, _WindowVal(aWindowId));
  7722 	RETURN ( self );
  7814 	RETURN ( self );
  7723     }
  7815     }
  7724 %}
  7816 %}
  7725 .
  7817 .
  7731 
  7823 
  7732 %{  /* NOCONTEXT */
  7824 %{  /* NOCONTEXT */
  7733 
  7825 
  7734     int newWidth, newHeight;
  7826     int newWidth, newHeight;
  7735 
  7827 
  7736     if (__isExternalAddress(aWindowId)
  7828     if (ISCONNECTED
       
  7829      && __isExternalAddress(aWindowId)
  7737      && __bothSmallInteger(w, h)
  7830      && __bothSmallInteger(w, h)
  7738      && __bothSmallInteger(x, y)) {
  7831      && __bothSmallInteger(x, y)) {
  7739 	newWidth = __intVal(w);
  7832 	newWidth = __intVal(w);
  7740 	newHeight = __intVal(h);
  7833 	newHeight = __intVal(h);
  7741 	if (newWidth < 1) newWidth = 1;
  7834 	if (newWidth < 1) newWidth = 1;
  7753 moveWindow:aWindowId x:x y:y
  7846 moveWindow:aWindowId x:x y:y
  7754     "move a window"
  7847     "move a window"
  7755 
  7848 
  7756 %{  /* NOCONTEXT */
  7849 %{  /* NOCONTEXT */
  7757 
  7850 
  7758     if (__isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
  7851     if (ISCONNECTED
       
  7852      && __isExternalAddress(aWindowId) && __bothSmallInteger(x, y)) {
  7759 	XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y));
  7853 	XMoveWindow(myDpy, _WindowVal(aWindowId), __intVal(x), __intVal(y));
  7760 	RETURN ( self );
  7854 	RETURN ( self );
  7761     }
  7855     }
  7762 %}
  7856 %}
  7763 .
  7857 .
  7767 raiseWindow:aWindowId
  7861 raiseWindow:aWindowId
  7768     "bring a window to front"
  7862     "bring a window to front"
  7769 
  7863 
  7770 %{  /* NOCONTEXT */
  7864 %{  /* NOCONTEXT */
  7771 
  7865 
  7772     if (__isExternalAddress(aWindowId)) {
  7866     if (ISCONNECTED
       
  7867      && __isExternalAddress(aWindowId)) {
  7773 	XRaiseWindow(myDpy, _WindowVal(aWindowId));
  7868 	XRaiseWindow(myDpy, _WindowVal(aWindowId));
  7774 	RETURN ( self );
  7869 	RETURN ( self );
  7775     }
  7870     }
  7776 %}
  7871 %}
  7777 .
  7872 .
  7783 
  7878 
  7784 %{  /* NOCONTEXT */
  7879 %{  /* NOCONTEXT */
  7785 
  7880 
  7786     int newWidth, newHeight;
  7881     int newWidth, newHeight;
  7787 
  7882 
  7788     if (__isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
  7883     if (ISCONNECTED
       
  7884      && __isExternalAddress(aWindowId) && __bothSmallInteger(w, h)) {
  7789 	newWidth = __intVal(w);
  7885 	newWidth = __intVal(w);
  7790 	newHeight = __intVal(h);
  7886 	newHeight = __intVal(h);
  7791 	if (newWidth < 1) newWidth = 1;
  7887 	if (newWidth < 1) newWidth = 1;
  7792 	if (newHeight < 1) newHeight = 1;
  7888 	if (newHeight < 1) newHeight = 1;
  7793 	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
  7889 	XResizeWindow(myDpy, _WindowVal(aWindowId), newWidth, newHeight);
  7803 
  7899 
  7804 %{  /* NOCONTEXT */
  7900 %{  /* NOCONTEXT */
  7805 
  7901 
  7806     XSetWindowAttributes wa;
  7902     XSetWindowAttributes wa;
  7807 
  7903 
  7808     if (__isExternalAddress(aWindowId)) {
  7904     if (ISCONNECTED
       
  7905      && __isExternalAddress(aWindowId)) {
  7809 	if (__INST(ignoreBackingStore) != true) {
  7906 	if (__INST(ignoreBackingStore) != true) {
  7810 	    if (how == @symbol(always)) wa.backing_store = Always;
  7907 	    if (how == @symbol(always)) wa.backing_store = Always;
  7811 	    else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped;
  7908 	    else if (how == @symbol(whenMapped)) wa.backing_store = WhenMapped;
  7812 	    else if (how == true) wa.backing_store = Always;
  7909 	    else if (how == true) wa.backing_store = Always;
  7813 	    else wa.backing_store = 0;
  7910 	    else wa.backing_store = 0;
  7826 
  7923 
  7827 %{  /* NOCONTEXT */
  7924 %{  /* NOCONTEXT */
  7828 
  7925 
  7829     XSetWindowAttributes wa;
  7926     XSetWindowAttributes wa;
  7830 
  7927 
  7831     if (__isExternalAddress(aWindowId)) {
  7928     if (ISCONNECTED
       
  7929      && __isExternalAddress(aWindowId)) {
  7832 	if (how == @symbol(NorthWest)) {
  7930 	if (how == @symbol(NorthWest)) {
  7833 	    wa.bit_gravity = NorthWestGravity;
  7931 	    wa.bit_gravity = NorthWestGravity;
  7834 	} else if (how == @symbol(NorthEast)) {
  7932 	} else if (how == @symbol(NorthEast)) {
  7835 	    wa.bit_gravity = NorthEastGravity;
  7933 	    wa.bit_gravity = NorthEastGravity;
  7836 	} else if (how == @symbol(SouthWest)) {
  7934 	} else if (how == @symbol(SouthWest)) {
  7865 
  7963 
  7866 %{  /* NOCONTEXT */
  7964 %{  /* NOCONTEXT */
  7867 
  7965 
  7868     Display *dpy = myDpy;
  7966     Display *dpy = myDpy;
  7869 
  7967 
  7870     if (__isExternalAddress(aWindowId)
  7968     if (ISCONNECTED
       
  7969      && __isExternalAddress(aWindowId)
  7871      && __isExternalAddress(aCursorId)) {
  7970      && __isExternalAddress(aCursorId)) {
  7872 	XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId));
  7971 	XDefineCursor(dpy, _WindowVal(aWindowId), _CursorVal(aCursorId));
  7873 	RETURN ( self );
  7972 	RETURN ( self );
  7874     }
  7973     }
  7875 %}.
  7974 %}.
  7879 setIconName:aString in:aWindowId
  7978 setIconName:aString in:aWindowId
  7880     "define a windows iconname"
  7979     "define a windows iconname"
  7881 
  7980 
  7882 %{  /* NOCONTEXT */
  7981 %{  /* NOCONTEXT */
  7883 
  7982 
  7884     if (__isExternalAddress(aWindowId)
  7983     if (ISCONNECTED
       
  7984      && __isExternalAddress(aWindowId)
  7885      && (__isString(aString) || __isSymbol(aString))) {
  7985      && (__isString(aString) || __isSymbol(aString))) {
  7886 	XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
  7986 	XSetIconName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
  7887 	RETURN ( self );
  7987 	RETURN ( self );
  7888     }
  7988     }
  7889 %}.
  7989 %}.
  7895 
  7995 
  7896 %{  /* NOCONTEXT */
  7996 %{  /* NOCONTEXT */
  7897 
  7997 
  7898     XSetWindowAttributes wa;
  7998     XSetWindowAttributes wa;
  7899 
  7999 
  7900     if (__isExternalAddress(aWindowId)) {
  8000     if (ISCONNECTED
       
  8001      && __isExternalAddress(aWindowId)) {
  7901 	if (__INST(hasSaveUnder) == true) {
  8002 	if (__INST(hasSaveUnder) == true) {
  7902 	    wa.save_under = (yesOrNo == true) ? 1 : 0;
  8003 	    wa.save_under = (yesOrNo == true) ? 1 : 0;
  7903 	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa);
  8004 	    XChangeWindowAttributes(myDpy, _WindowVal(aWindowId), CWSaveUnder, &wa);
  7904 	}
  8005 	}
  7905 	RETURN ( self );
  8006 	RETURN ( self );
  7911 setTransient:aWindowId for:aMainWindowId
  8012 setTransient:aWindowId for:aMainWindowId
  7912     "set aWindowId to be a transient of aMainWindow"
  8013     "set aWindowId to be a transient of aMainWindow"
  7913 
  8014 
  7914 %{  /* NOCONTEXT */
  8015 %{  /* NOCONTEXT */
  7915 
  8016 
  7916     if (__isExternalAddress(aWindowId)) {
  8017     if (ISCONNECTED
       
  8018      && __isExternalAddress(aWindowId)) {
  7917 	Window w;
  8019 	Window w;
  7918 
  8020 
  7919 	if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
  8021 	if ((aMainWindowId == nil) || (aMainWindowId == __MKSMALLINT(0))) {
  7920 	    w = (Window) 0;
  8022 	    w = (Window) 0;
  7921 	} else {
  8023 	} else {
  7938      the view is filled whenever exposed. Do not confuse this with
  8040      the view is filled whenever exposed. Do not confuse this with
  7939      the background drawing color, which is used with opaque drawing."
  8041      the background drawing color, which is used with opaque drawing."
  7940 
  8042 
  7941 %{  /* NOCONTEXT */
  8043 %{  /* NOCONTEXT */
  7942 
  8044 
  7943     if (__isExternalAddress(aWindowId)
  8045     if (ISCONNECTED
       
  8046      && __isExternalAddress(aWindowId)
  7944      && __isSmallInteger(aColorIndex)) {
  8047      && __isSmallInteger(aColorIndex)) {
  7945 	XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
  8048 	XSetWindowBackground(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
  7946 	RETURN ( self );
  8049 	RETURN ( self );
  7947     }
  8050     }
  7948 %}.
  8051 %}.
  7955      Do not confuse this with the background drawing color, which is used 
  8058      Do not confuse this with the background drawing color, which is used 
  7956      with opaque drawing."
  8059      with opaque drawing."
  7957 
  8060 
  7958 %{  /* NOCONTEXT */
  8061 %{  /* NOCONTEXT */
  7959 
  8062 
  7960     if (__isExternalAddress(aWindowId)
  8063     if (ISCONNECTED
       
  8064      && __isExternalAddress(aWindowId)
  7961      && __isExternalAddress(aPixmapId)) {
  8065      && __isExternalAddress(aPixmapId)) {
  7962 	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
  8066 	XSetWindowBackgroundPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
  7963 	RETURN ( self );
  8067 	RETURN ( self );
  7964     }
  8068     }
  7965 %}.
  8069 %}.
  7969 setWindowBorderColor:aColorIndex in:aWindowId
  8073 setWindowBorderColor:aColorIndex in:aWindowId
  7970     "set the windows border color"
  8074     "set the windows border color"
  7971 
  8075 
  7972 %{  /* NOCONTEXT */
  8076 %{  /* NOCONTEXT */
  7973 
  8077 
  7974     if (__isExternalAddress(aWindowId)
  8078     if (ISCONNECTED
       
  8079      && __isExternalAddress(aWindowId)
  7975      && __isSmallInteger(aColorIndex)) {
  8080      && __isSmallInteger(aColorIndex)) {
  7976 	XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
  8081 	XSetWindowBorder(myDpy, _WindowVal(aWindowId), __intVal(aColorIndex));
  7977 	RETURN ( self );
  8082 	RETURN ( self );
  7978     }
  8083     }
  7979 %}.
  8084 %}.
  7983 setWindowBorderPixmap:aPixmapId in:aWindowId
  8088 setWindowBorderPixmap:aPixmapId in:aWindowId
  7984     "set the windows border pattern"
  8089     "set the windows border pattern"
  7985 
  8090 
  7986 %{  /* NOCONTEXT */
  8091 %{  /* NOCONTEXT */
  7987 
  8092 
  7988     if (__isExternalAddress(aWindowId)
  8093     if (ISCONNECTED
       
  8094      && __isExternalAddress(aWindowId)
  7989      && __isExternalAddress(aPixmapId)) {
  8095      && __isExternalAddress(aPixmapId)) {
  7990 	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
  8096 	XSetWindowBorderPixmap(myDpy, _WindowVal(aWindowId), _PixmapVal(aPixmapId));
  7991 	RETURN ( self );
  8097 	RETURN ( self );
  7992     }
  8098     }
  7993 %}
  8099 %}
  8001     hasShapeExtension ifFalse:[^ self].
  8107     hasShapeExtension ifFalse:[^ self].
  8002 
  8108 
  8003 %{  /* NOCONTEXT */
  8109 %{  /* NOCONTEXT */
  8004 
  8110 
  8005 #ifdef SHAPE
  8111 #ifdef SHAPE
  8006     if (__isExternalAddress(aWindowId)
  8112     if (ISCONNECTED
       
  8113      && __isExternalAddress(aWindowId)
  8007      && __isExternalAddress(aPixmapId)) {
  8114      && __isExternalAddress(aPixmapId)) {
  8008 	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding,
  8115 	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeBounding,
  8009 			  0, 0, _PixmapVal(aPixmapId), ShapeSet);
  8116 			  0, 0, _PixmapVal(aPixmapId), ShapeSet);
  8010 	RETURN ( self );
  8117 	RETURN ( self );
  8011     }
  8118     }
  8017 setWindowBorderWidth:aNumber in:aWindowId
  8124 setWindowBorderWidth:aNumber in:aWindowId
  8018     "set the windows border width"
  8125     "set the windows border width"
  8019 
  8126 
  8020 %{  /* NOCONTEXT */
  8127 %{  /* NOCONTEXT */
  8021 
  8128 
  8022     if (__isExternalAddress(aWindowId)
  8129     if (ISCONNECTED
       
  8130      && __isExternalAddress(aWindowId)
  8023      && __isSmallInteger(aNumber)) {
  8131      && __isSmallInteger(aNumber)) {
  8024 	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber));
  8132 	XSetWindowBorderWidth(myDpy, _WindowVal(aWindowId), __intVal(aNumber));
  8025 	RETURN ( self );
  8133 	RETURN ( self );
  8026     }
  8134     }
  8027 %}.
  8135 %}.
  8032     "define class and name of a window.
  8140     "define class and name of a window.
  8033      This may be used by the window manager to
  8141      This may be used by the window manager to
  8034      select client specific resources."
  8142      select client specific resources."
  8035 
  8143 
  8036 %{
  8144 %{
  8037     if (__isExternalAddress(aWindowId)) {
  8145     if (ISCONNECTED
       
  8146      && __isExternalAddress(aWindowId)) {
  8038 	XClassHint classhint;
  8147 	XClassHint classhint;
  8039 
  8148 
  8040 	classhint.res_class = classhint.res_name = 0;
  8149 	classhint.res_class = classhint.res_name = 0;
  8041 
  8150 
  8042 	if (__isString(wClass) || __isSymbol(wClass)) {
  8151 	if (__isString(wClass) || __isSymbol(wClass)) {
  8062 
  8171 
  8063 %{  /* NOCONTEXT */
  8172 %{  /* NOCONTEXT */
  8064 
  8173 
  8065     XSetWindowAttributes wa;
  8174     XSetWindowAttributes wa;
  8066 
  8175 
  8067     if (__isExternalAddress(aWindowId)) {
  8176     if (ISCONNECTED
       
  8177      && __isExternalAddress(aWindowId)) {
  8068 	if (how == @symbol(NorthWest)) {
  8178 	if (how == @symbol(NorthWest)) {
  8069 	    wa.win_gravity = NorthWestGravity;
  8179 	    wa.win_gravity = NorthWestGravity;
  8070 	} else if (how == @symbol(NorthEast)) {
  8180 	} else if (how == @symbol(NorthEast)) {
  8071 	    wa.win_gravity = NorthEastGravity;
  8181 	    wa.win_gravity = NorthEastGravity;
  8072 	} else if (how == @symbol(SouthWest)) {
  8182 	} else if (how == @symbol(SouthWest)) {
  8103 
  8213 
  8104     aForm notNil ifTrue:[
  8214     aForm notNil ifTrue:[
  8105 	iconId := aForm id
  8215 	iconId := aForm id
  8106     ].
  8216     ].
  8107 %{
  8217 %{
  8108     if (__isExternalAddress(iconId)
  8218     if (ISCONNECTED
       
  8219      && __isExternalAddress(iconId)
  8109      && __isExternalAddress(aWindowId)) {
  8220      && __isExternalAddress(aWindowId)) {
  8110 	XWMHints hints;
  8221 	XWMHints hints;
  8111 
  8222 
  8112 	hints.icon_pixmap = _PixmapVal(iconId);
  8223 	hints.icon_pixmap = _PixmapVal(iconId);
  8113 	hints.flags = IconPixmapHint;
  8224 	hints.flags = IconPixmapHint;
  8125 
  8236 
  8126     aView notNil ifTrue:[
  8237     aView notNil ifTrue:[
  8127 	iconWindowId := aView id
  8238 	iconWindowId := aView id
  8128     ].
  8239     ].
  8129 %{
  8240 %{
  8130     if (__isExternalAddress(iconWindowId)
  8241     if (ISCONNECTED
       
  8242      && __isExternalAddress(iconWindowId)
  8131      && __isExternalAddress(aWindowId)) {
  8243      && __isExternalAddress(aWindowId)) {
  8132 	XWMHints wmhints;
  8244 	XWMHints wmhints;
  8133 
  8245 
  8134 	wmhints.icon_window = _WindowVal(iconWindowId);
  8246 	wmhints.icon_window = _WindowVal(iconWindowId);
  8135 	wmhints.flags = IconWindowHint;
  8247 	wmhints.flags = IconWindowHint;
  8143 setWindowName:aString in:aWindowId
  8255 setWindowName:aString in:aWindowId
  8144     "define a windows name"
  8256     "define a windows name"
  8145 
  8257 
  8146 %{  /* NOCONTEXT */
  8258 %{  /* NOCONTEXT */
  8147 
  8259 
  8148     if (__isExternalAddress(aWindowId)
  8260     if (ISCONNECTED
       
  8261      && __isExternalAddress(aWindowId)
  8149      && (__isString(aString) || __isSymbol(aString))) {
  8262      && (__isString(aString) || __isSymbol(aString))) {
  8150 	XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
  8263 	XStoreName(myDpy, _WindowVal(aWindowId), (char *)_stringVal(aString));
  8151 	RETURN ( self );
  8264 	RETURN ( self );
  8152     }
  8265     }
  8153 %}.
  8266 %}.
  8160     hasShapeExtension ifFalse:[^ self].
  8273     hasShapeExtension ifFalse:[^ self].
  8161 
  8274 
  8162 %{  /* NOCONTEXT */
  8275 %{  /* NOCONTEXT */
  8163 
  8276 
  8164 #ifdef SHAPE
  8277 #ifdef SHAPE
  8165     if (__isExternalAddress(aWindowId)
  8278     if (ISCONNECTED
       
  8279      && __isExternalAddress(aWindowId)
  8166      && __isExternalAddress(aPixmapId)) {
  8280      && __isExternalAddress(aPixmapId)) {
  8167 	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip,
  8281 	XShapeCombineMask(myDpy, _WindowVal(aWindowId), ShapeClip,
  8168 			  0, 0,
  8282 			  0, 0,
  8169 			  _PixmapVal(aPixmapId), ShapeSet);
  8283 			  _PixmapVal(aPixmapId), ShapeSet);
  8170 	RETURN ( self );
  8284 	RETURN ( self );
  8177 unmapWindow:aWindowId
  8291 unmapWindow:aWindowId
  8178     "make a window invisible"
  8292     "make a window invisible"
  8179 
  8293 
  8180 %{  /* NOCONTEXT */
  8294 %{  /* NOCONTEXT */
  8181 
  8295 
  8182     if (__isExternalAddress(aWindowId)) {
  8296     if (ISCONNECTED) {
  8183 	XUnmapWindow(myDpy, _WindowVal(aWindowId));
  8297         if (__isExternalAddress(aWindowId)) {
  8184 	RETURN ( self );
  8298 	    XUnmapWindow(myDpy, _WindowVal(aWindowId));
       
  8299 	    RETURN ( self );
       
  8300 	}
  8185     }
  8301     }
  8186 %}
  8302 %}
  8187 .
  8303 .
  8188     self primitiveFailed
  8304     self primitiveFailed
  8189 ! !
  8305 ! !
  8190 
  8306 
  8191 !XWorkstation class methodsFor:'documentation'!
  8307 !XWorkstation class methodsFor:'documentation'!
  8192 
  8308 
  8193 version
  8309 version
  8194     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.189 1997-01-13 23:20:22 cg Exp $'
  8310     ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.190 1997-01-13 23:41:03 cg Exp $'
  8195 ! !
  8311 ! !
  8196 XWorkstation initialize!
  8312 XWorkstation initialize!