XWorkstation.st
changeset 3223 94dc28dc1f9c
parent 3222 0bb571e07c0e
child 3225 ea4d18da0983
--- a/XWorkstation.st	Fri Jul 07 11:41:35 2000 +0200
+++ b/XWorkstation.st	Fri Jul 07 15:03:34 2000 +0200
@@ -5493,6 +5493,39 @@
     ^ self eventsPending:(self eventMaskFor:anEventSymbol) for:aWindowIdOrNil withSync:false
 !
 
+eventPending:anEventMask for:aWindowIdOrNil withSync:doSync
+    "return true, if any of the masked events is pending"
+
+%{  /* UNLIMITEDSTACK */
+
+    XEvent ev;
+    Window win;
+    int thereIsOne;
+    OBJ rslt = false;
+
+    if (ISCONNECTED && __isSmallInteger(anEventMask)) {
+        Display *dpy = myDpy;
+
+        ENTER_XLIB();
+        if (doSync == true) {
+            XSync(dpy, 0);      /* make certain everything is flushed */
+        }
+        if (__isExternalAddress(aWindowIdOrNil)) {
+            win = _WindowVal(aWindowIdOrNil);
+            thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev);
+        } else {
+            thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev);
+        }
+        if (thereIsOne) {
+            XPutBackEvent(dpy, &ev);
+            rslt = true;
+        }
+        LEAVE_XLIB();
+    }
+    RETURN ( rslt );
+%}
+!
+
 eventPendingWithSync:doSync
     "return true, if any event is pending. 
      If doSync is true, do a sync output buffer (i.e. send all to the display and wait until its processed)
@@ -5553,39 +5586,6 @@
 %}
 !
 
-eventsPending:anEventMask for:aWindowIdOrNil withSync:doSync
-    "return true, if any of the masked events is pending"
-
-%{  /* UNLIMITEDSTACK */
-
-    XEvent ev;
-    Window win;
-    int thereIsOne;
-    OBJ rslt = false;
-
-    if (ISCONNECTED && __isSmallInteger(anEventMask)) {
-	Display *dpy = myDpy;
-
-	ENTER_XLIB();
-	if (doSync == true) {
-	    XSync(dpy, 0);      /* make certain everything is flushed */
-	}
-	if (__isExternalAddress(aWindowIdOrNil)) {
-	    win = _WindowVal(aWindowIdOrNil);
-	    thereIsOne = XCheckWindowEvent(dpy, win, __intVal(anEventMask), &ev);
-	} else {
-	    thereIsOne = XCheckMaskEvent(dpy, __intVal(anEventMask), &ev);
-	}
-	if (thereIsOne) {
-	    XPutBackEvent(dpy, &ev);
-	    rslt = true;
-	}
-	LEAVE_XLIB();
-    }
-    RETURN ( rslt );
-%}
-!
-
 exposeEventPendingFor:aWindowIdOrNil withSync:doSync
     "return true, if any expose event is pending for a specific view,
      or any view (if the arg is nil).
@@ -5627,6 +5627,17 @@
      otherwise only events for that specific view will be fetched.
      Returns true, if there was an event, false otherwise.
      This method may block - so you better check for pending events
+     before calling for it."
+
+    ^ self getEventFor:aViewIdOrNil withMask:eventMask into:eventBuffer
+!
+
+getEventFor:aViewIdOrNil withMask:eventMask into:anEventBuffer
+    "read next event - put into anEventBuffer. 
+     If aViewIdOrNil is nil, events for any view are fetched; 
+     otherwise only events for that specific view will be fetched.
+     Returns true, if there was an event, false otherwise.
+     This method may block - so you better check for pending events
      before calling for it.
 
      Sorry I had to split dispatch into this fetch method and an extra
@@ -5640,46 +5651,45 @@
     Display *dpy;
     Window win, wWanted;
     int evMask;
-    OBJ eB;
     XEvent *ev;
 
     if (! ISCONNECTED) {
-	RETURN (false);
+        RETURN (false);
     }
 
     dpy = myDpy;
 
-    eB = __INST(eventBuffer);
-    if (__isByteArray(eB)) {
-	ev = (XEvent *)(__ByteArrayInstPtr(eB)->ba_element);
+    if (__isByteArray(anEventBuffer)) {
+        ev = (XEvent *)(__ByteArrayInstPtr(anEventBuffer)->ba_element);
     } else {
-	printf("DISPLAY: no eventBuffer\n");
-	RETURN (false);
+        printf("DISPLAY: bad eventBuffer\n");
+        RETURN (false);
     }
     ev->type = 0;
 
     if (__isSmallInteger(eventMask)) {
-	evMask = __intVal(eventMask);
+        evMask = __intVal(eventMask);
     } else {
-	evMask = ~0;
+        evMask = ~0;
     }
 
     if (__isExternalAddress(aViewIdOrNil)) {
-	wWanted = _WindowVal(aViewIdOrNil);
-	if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
-	    RETURN ( true );
-	}
+        wWanted = _WindowVal(aViewIdOrNil);
+        if (XCheckWindowEvent(dpy, wWanted, evMask, ev)) {
+            RETURN ( true );
+        }
     } else {
-	if (evMask == ~0) {
-	    XNextEvent(dpy, ev);
-	    RETURN (true);
-	}
-	if (XCheckMaskEvent(dpy, evMask, ev)) {
-	   RETURN (true);
-	}
-    }
-%}.
-    ^ false
+        if (evMask == ~0) {
+            XNextEvent(dpy, ev);
+            RETURN (true);
+        }
+        if (XCheckMaskEvent(dpy, evMask, ev)) {
+           RETURN (true);
+        }
+    }
+    RETURN (false);
+%}.
+    ^ self primitiveFailed
 !
 
 handleAllEvents
@@ -10510,6 +10520,6 @@
 !XWorkstation class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.354 2000-07-07 09:41:35 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/XWorkstation.st,v 1.355 2000-07-07 13:03:34 cg Exp $'
 ! !
 XWorkstation initialize!