detect 0-width/height area in getBitsFromScreen
authorclaus
Sun, 07 Aug 1994 21:30:51 +0200
changeset 55 da381ce5928d
parent 54 29a6b2f8e042
child 56 cc69f5a6a51d
detect 0-width/height area in getBitsFromScreen
XWorkstat.st
XWorkstation.st
--- a/XWorkstat.st	Fri Aug 05 03:16:44 1994 +0200
+++ b/XWorkstat.st	Sun Aug 07 21:30:51 1994 +0200
@@ -34,7 +34,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.17 1994-08-05 01:16:32 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.18 1994-08-07 19:30:51 claus Exp $
 '!
 
 !XWorkstation class methodsFor:'documentation'!
@@ -55,7 +55,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.17 1994-08-05 01:16:32 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/XWorkstat.st,v 1.18 1994-08-07 19:30:51 claus Exp $
 "
 !
 
@@ -257,7 +257,7 @@
         if (needUnblock) {              \
             UNBLOCKINTERRUPTS();        \
         }                               \
-        __thisContext__ = 0;		\
+        __thisContext__ = 0;            \
     }
 
 #endif
@@ -1132,8 +1132,8 @@
         unsigned int numChildren;
 
         if (XQueryTree(myDpy, root, 
-		       &rootReturn, &parentReturn, 
-		       &children, &numChildren)) {
+                       &rootReturn, &parentReturn, 
+                       &children, &numChildren)) {
             vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True );
             if (vRootAtom != None) {
                 for (i=0; i < numChildren; i++) {
@@ -1146,9 +1146,9 @@
                         if (XGetWindowProperty(myDpy, children[i], vRootAtom, 
                                                  0L, 1L, False, XA_WINDOW,
                                                  &actual_type, &actual_format, 
-					         &nitems, &bytesafter,
+                                                 &nitems, &bytesafter,
                                                  (unsigned char**) &newRoot
-			                       ) == Success && newRoot) {
+                                               ) == Success && newRoot) {
                             root = *newRoot;
                             break;
                         }
@@ -2280,16 +2280,16 @@
         END_INTERRUPTSBLOCKED
         switch(result) {
             case AlreadyGrabbed: 
-                printf("AlreadyGrabbed\n");
+                printf("grab keyboard: AlreadyGrabbed\n");
                 RETURN (false);
             case GrabNotViewable: 
-                printf("GrabNotViewable\n");
+                printf("grab keyboard: GrabNotViewable\n");
                 RETURN (false);
             case GrabInvalidTime: 
-                printf("InvalidTime\n");
+                printf("grab keyboard: InvalidTime\n");
                 RETURN (false);
             case GrabFrozen: 
-                printf("Frozen\n");
+                printf("grab keyboard: Frozen\n");
                 RETURN (false);
         }
 
@@ -2362,16 +2362,16 @@
 
         switch (result) {
             case AlreadyGrabbed: 
-                printf("AlreadyGrabbed\n");
+                printf("grab pointer: AlreadyGrabbed\n");
                 RETURN (false);
             case GrabNotViewable: 
-                printf("GrabNotViewable\n");
+                printf("grab pointer: GrabNotViewable\n");
                 RETURN (false);
             case GrabInvalidTime: 
-                printf("InvalidTime\n");
+                printf("grab pointer: InvalidTime\n");
                 RETURN (false);
             case GrabFrozen: 
-                printf("Frozen\n");
+                printf("grab pointer: Frozen\n");
                 RETURN (false);
         }
 
@@ -2610,7 +2610,7 @@
         ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
         if (ok) {
             ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
-	}
+        }
         END_INTERRUPTSBLOCKED
         if (! ok) {
             RETURN ( nil );
@@ -2710,10 +2710,10 @@
     if (__isString(colorName) || __isSymbol(colorName)) {
         BEGIN_INTERRUPTSBLOCKED
         if (XParseColor(dpy, DefaultColormap(dpy, screen), 
-			     (char *)_stringVal(colorName), &color)) {
+                             (char *)_stringVal(colorName), &color)) {
             /* 
-	     * scale to 0..100 and round to the first decimal
-	     */
+             * scale to 0..100 and round to the first decimal
+             */
             fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
             fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
             fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
@@ -3024,8 +3024,8 @@
 
     if (_isSmallInteger(aWindowId)
      && _isSmallInteger(aMainWindowId)) {
-	XSetTransientForHint(myDpy, _WindowVal(aWindowId),
-				    _WindowVal(aMainWindowId));
+        XSetTransientForHint(myDpy, _WindowVal(aWindowId),
+                                    _WindowVal(aMainWindowId));
         RETURN ( self );
     }
 %}
@@ -3658,6 +3658,11 @@
 
      |info|
 
+     ((w <= 0) or:[h <= 0]) ifTrue:[
+        self primitiveFailed.
+        ^ nil
+     ].
+
      info := Array with:nil "depth"
                    with:nil "bit order"
                    with:nil "bytes_per_line".
@@ -4591,24 +4596,24 @@
     __ev__.type = 0;
 
     if (_isSmallInteger(eventMask)) {
-	evMask = _intVal(eventMask);
+        evMask = _intVal(eventMask);
     } else {
-	evMask = ~0;
+        evMask = ~0;
     }
 
     if (_isSmallInteger(aViewIdOrNil)) {
         wWanted = _WindowVal(aViewIdOrNil);
         if (XCheckWindowEvent(dpy, wWanted, evMask, &__ev__)) {
-	    RETURN ( true );
-	}
+            RETURN ( true );
+        }
     } else {
-	if (evMask == ~0) {
-	    XNextEvent(dpy, &__ev__);
-	    RETURN (true);
-	}
+        if (evMask == ~0) {
+            XNextEvent(dpy, &__ev__);
+            RETURN (true);
+        }
         if (XCheckMaskEvent(dpy, evMask, &__ev__)) {
-	   RETURN (true);
-	}
+           RETURN (true);
+        }
     }
 %}.
     ^ false
--- a/XWorkstation.st	Fri Aug 05 03:16:44 1994 +0200
+++ b/XWorkstation.st	Sun Aug 07 21:30:51 1994 +0200
@@ -34,7 +34,7 @@
 COPYRIGHT (c) 1989 by Claus Gittinger
               All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.17 1994-08-05 01:16:32 claus Exp $
+$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.18 1994-08-07 19:30:51 claus Exp $
 '!
 
 !XWorkstation class methodsFor:'documentation'!
@@ -55,7 +55,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.17 1994-08-05 01:16:32 claus Exp $
+$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.18 1994-08-07 19:30:51 claus Exp $
 "
 !
 
@@ -257,7 +257,7 @@
         if (needUnblock) {              \
             UNBLOCKINTERRUPTS();        \
         }                               \
-        __thisContext__ = 0;		\
+        __thisContext__ = 0;            \
     }
 
 #endif
@@ -1132,8 +1132,8 @@
         unsigned int numChildren;
 
         if (XQueryTree(myDpy, root, 
-		       &rootReturn, &parentReturn, 
-		       &children, &numChildren)) {
+                       &rootReturn, &parentReturn, 
+                       &children, &numChildren)) {
             vRootAtom = XInternAtom(myDpy, "__SWM_VROOT", True );
             if (vRootAtom != None) {
                 for (i=0; i < numChildren; i++) {
@@ -1146,9 +1146,9 @@
                         if (XGetWindowProperty(myDpy, children[i], vRootAtom, 
                                                  0L, 1L, False, XA_WINDOW,
                                                  &actual_type, &actual_format, 
-					         &nitems, &bytesafter,
+                                                 &nitems, &bytesafter,
                                                  (unsigned char**) &newRoot
-			                       ) == Success && newRoot) {
+                                               ) == Success && newRoot) {
                             root = *newRoot;
                             break;
                         }
@@ -2280,16 +2280,16 @@
         END_INTERRUPTSBLOCKED
         switch(result) {
             case AlreadyGrabbed: 
-                printf("AlreadyGrabbed\n");
+                printf("grab keyboard: AlreadyGrabbed\n");
                 RETURN (false);
             case GrabNotViewable: 
-                printf("GrabNotViewable\n");
+                printf("grab keyboard: GrabNotViewable\n");
                 RETURN (false);
             case GrabInvalidTime: 
-                printf("InvalidTime\n");
+                printf("grab keyboard: InvalidTime\n");
                 RETURN (false);
             case GrabFrozen: 
-                printf("Frozen\n");
+                printf("grab keyboard: Frozen\n");
                 RETURN (false);
         }
 
@@ -2362,16 +2362,16 @@
 
         switch (result) {
             case AlreadyGrabbed: 
-                printf("AlreadyGrabbed\n");
+                printf("grab pointer: AlreadyGrabbed\n");
                 RETURN (false);
             case GrabNotViewable: 
-                printf("GrabNotViewable\n");
+                printf("grab pointer: GrabNotViewable\n");
                 RETURN (false);
             case GrabInvalidTime: 
-                printf("InvalidTime\n");
+                printf("grab pointer: InvalidTime\n");
                 RETURN (false);
             case GrabFrozen: 
-                printf("Frozen\n");
+                printf("grab pointer: Frozen\n");
                 RETURN (false);
         }
 
@@ -2610,7 +2610,7 @@
         ok = XParseColor(dpy, DefaultColormap(dpy, screen), colorname, &ecolor);
         if (ok) {
             ok = XAllocColor(dpy, DefaultColormap(dpy, screen), &ecolor);
-	}
+        }
         END_INTERRUPTSBLOCKED
         if (! ok) {
             RETURN ( nil );
@@ -2710,10 +2710,10 @@
     if (__isString(colorName) || __isSymbol(colorName)) {
         BEGIN_INTERRUPTSBLOCKED
         if (XParseColor(dpy, DefaultColormap(dpy, screen), 
-			     (char *)_stringVal(colorName), &color)) {
+                             (char *)_stringVal(colorName), &color)) {
             /* 
-	     * scale to 0..100 and round to the first decimal
-	     */
+             * scale to 0..100 and round to the first decimal
+             */
             fr = floor( ((((double)color.red) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
             fg = floor( ((((double)color.green) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
             fb = floor( ((((double)color.blue) * 1000.0) / 0xFFFF) + 0.5) / 10.0;
@@ -3024,8 +3024,8 @@
 
     if (_isSmallInteger(aWindowId)
      && _isSmallInteger(aMainWindowId)) {
-	XSetTransientForHint(myDpy, _WindowVal(aWindowId),
-				    _WindowVal(aMainWindowId));
+        XSetTransientForHint(myDpy, _WindowVal(aWindowId),
+                                    _WindowVal(aMainWindowId));
         RETURN ( self );
     }
 %}
@@ -3658,6 +3658,11 @@
 
      |info|
 
+     ((w <= 0) or:[h <= 0]) ifTrue:[
+        self primitiveFailed.
+        ^ nil
+     ].
+
      info := Array with:nil "depth"
                    with:nil "bit order"
                    with:nil "bytes_per_line".
@@ -4591,24 +4596,24 @@
     __ev__.type = 0;
 
     if (_isSmallInteger(eventMask)) {
-	evMask = _intVal(eventMask);
+        evMask = _intVal(eventMask);
     } else {
-	evMask = ~0;
+        evMask = ~0;
     }
 
     if (_isSmallInteger(aViewIdOrNil)) {
         wWanted = _WindowVal(aViewIdOrNil);
         if (XCheckWindowEvent(dpy, wWanted, evMask, &__ev__)) {
-	    RETURN ( true );
-	}
+            RETURN ( true );
+        }
     } else {
-	if (evMask == ~0) {
-	    XNextEvent(dpy, &__ev__);
-	    RETURN (true);
-	}
+        if (evMask == ~0) {
+            XNextEvent(dpy, &__ev__);
+            RETURN (true);
+        }
         if (XCheckMaskEvent(dpy, evMask, &__ev__)) {
-	   RETURN (true);
-	}
+           RETURN (true);
+        }
     }
 %}.
     ^ false