--- a/XWorkstation.st Mon Dec 13 18:10:47 1993 +0100
+++ b/XWorkstation.st Thu Dec 16 11:59:26 1993 +0100
@@ -36,7 +36,7 @@
this class provides the interface to X11
-$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.6 1993-12-11 01:35:51 claus Exp $
+$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.7 1993-12-16 10:59:26 claus Exp $
written spring/summer 89 by claus
'!
@@ -98,6 +98,12 @@
static unsigned lastRequestCode = 0;
static unsigned lastMinorCode = 0;
static unsigned lastResource = 0;
+/*
+ * trying to catch some persitant X-errors
+ */
+#ifdef DEBUG
+static unsigned lastColor = 0;
+#endif
__XErrorHandler__(dpy, event)
Display *dpy;
@@ -114,11 +120,65 @@
printf("x-error (%s) cought maj=%d (0x%x) min=%d (0x%x) resource=%x\n",
lastErrorMsg, event->request_code, event->request_code,
event->minor_code, event->minor_code, event->resourceid);
+#ifdef DEBUG
+ switch(event->request_code) {
+ case 88:
+ printf("lastColor = %d\n", lastColor);
+ break;
+ }
+#endif
errorInterrupt();
return 0;
}
/*
+ * added since RootWindow-macro is not suficient
+ * when virtual root-windows are involved (i.e. tvtwm)
+ */
+static Window
+getRootWindow(dpy, screen)
+ Display *dpy;
+{
+ Window root;
+ Atom vRootAtom = None;
+ int i;
+ Window rootReturn, parentReturn;
+ Window* children;
+ unsigned int numChildren;
+
+ root = RootWindow(dpy, screen);
+ /*
+ * on IRIS, this creates a badwindow error - why ?
+ * children contains a funny window (000034)
+ */
+#ifndef IRIS
+ if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
+ vRootAtom = XInternAtom(dpy, "__SWM_VROOT", True );
+ if (vRootAtom != None) {
+ for (i=0; i < numChildren; i++) {
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems, bytesafter;
+ Window* newRoot = (Window*) 0;
+
+ if (children[i]) {
+ if (XGetWindowProperty(dpy, children[i], vRootAtom,
+ 0L, 1L, False, XA_WINDOW,
+ &actual_type, &actual_format, &nitems, &bytesafter,
+ (unsigned char**) &newRoot) == Success && newRoot) {
+ root = *newRoot;
+ break;
+ }
+ }
+ }
+ if (children) XFree( children );
+ }
+ }
+#endif
+ return root;
+}
+
+/*
* some defines - tired of typing ...
*/
#ifdef hpux
@@ -625,11 +685,26 @@
y1 := aPoint y.
%{
int xpos, ypos;
- Window child_return;
+ Window w1, w2, child_return;
+ int screen = _intVal(_INST(screen));
+ Display *dpy = myDpy;
if (_isSmallInteger(windowId1) && _isSmallInteger(windowId2)
&& _isSmallInteger(x1) && _isSmallInteger(y1)) {
- XTranslateCoordinates(myDpy, _WindowVal(windowId1), _WindowVal(windowId2),
+ w1 = _WindowVal(windowId1);
+ w2 = _WindowVal(windowId2);
+#ifndef IRIS
+ if ((w1 == RootWindow(dpy, screen))
+ || (w2 == RootWindow(dpy, screen))) {
+ if (w1 == RootWindow(dpy, screen)) {
+ w1 = getRootWindow(dpy, screen);
+ }
+ if (w2 == RootWindow(dpy, screen)) {
+ w2 = getRootWindow(dpy, screen);
+ }
+ }
+#endif
+ XTranslateCoordinates(dpy, w1, w2,
_intVal(x1), _intVal(y1),
&xpos, &ypos, &child_return);
x2 = _MKSMALLINT(xpos);
@@ -1969,7 +2044,11 @@
int rootX, rootY, winX, winY;
unsigned int mask;
+#ifdef OLD
w = RootWindow(dpy, screen);
+#else
+ w = getRootWindow(myDpy, screen);
+#endif
XQueryPointer(dpy, w, &rootRet, &childRet,
&rootX, &rootY,
&winX, &winY,
@@ -2026,6 +2105,9 @@
if (_isSmallInteger(colorIndex)) {
color = (long) _intVal(colorIndex);
+#ifdef DEBUG
+ lastColor = color;
+#endif
XFreeColors(dpy, DefaultColormap(dpy, screen), &color, 1, 0L);
RETURN ( self );
}