4 * This event handling stuff was inspired on Tk.
9 #include "../src/config.h"
11 #include <sys/types.h>
21 #ifdef HAVE_SYS_SELECT_H
22 # include <sys/select.h>
27 #ifndef X_GETTIMEOFDAY
28 #define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
36 typedef struct TimerHandler
{
37 WMCallback
*callback
; /* procedure to call */
38 struct timeval when
; /* when to call the callback */
40 struct TimerHandler
*next
;
45 typedef struct IdleHandler
{
51 typedef struct InputHandler
{
52 WMInputProc
*callback
;
59 /* table to map event types to event masks */
60 static unsigned long eventMasks
[] = {
63 KeyPressMask
, /* KeyPress */
64 KeyReleaseMask
, /* KeyRelease */
65 ButtonPressMask
, /* ButtonPress */
66 ButtonReleaseMask
, /* ButtonRelease */
67 PointerMotionMask
|PointerMotionHintMask
|ButtonMotionMask
68 |Button1MotionMask
|Button2MotionMask
|Button3MotionMask
69 |Button4MotionMask
|Button5MotionMask
,
71 EnterWindowMask
, /* EnterNotify */
72 LeaveWindowMask
, /* LeaveNotify */
73 FocusChangeMask
, /* FocusIn */
74 FocusChangeMask
, /* FocusOut */
75 KeymapStateMask
, /* KeymapNotify */
76 ExposureMask
, /* Expose */
77 ExposureMask
, /* GraphicsExpose */
78 ExposureMask
, /* NoExpose */
79 VisibilityChangeMask
, /* VisibilityNotify */
80 SubstructureNotifyMask
, /* CreateNotify */
81 StructureNotifyMask
, /* DestroyNotify */
82 StructureNotifyMask
, /* UnmapNotify */
83 StructureNotifyMask
, /* MapNotify */
84 SubstructureRedirectMask
, /* MapRequest */
85 StructureNotifyMask
, /* ReparentNotify */
86 StructureNotifyMask
, /* ConfigureNotify */
87 SubstructureRedirectMask
, /* ConfigureRequest */
88 StructureNotifyMask
, /* GravityNotify */
89 ResizeRedirectMask
, /* ResizeRequest */
90 StructureNotifyMask
, /* CirculateNotify */
91 SubstructureRedirectMask
, /* CirculateRequest */
92 PropertyChangeMask
, /* PropertyNotify */
93 0, /* SelectionClear */
94 0, /* SelectionRequest */
95 0, /* SelectionNotify */
96 ColormapChangeMask
, /* ColormapNotify */
97 ClientMessageMask
, /* ClientMessage */
98 0, /* Mapping Notify */
103 /* queue of timer event handlers */
104 static TimerHandler
*timerHandler
=NULL
;
106 static WMBag
*idleHandler
=NULL
;
108 static WMBag
*inputHandler
=NULL
;
110 /* hook for other toolkits or wmaker process their events */
111 static WMEventHook
*extraEventHandler
=NULL
;
115 #define timerPending() (timerHandler)
120 rightNow(struct timeval
*tv
) {
124 /* is t1 after t2 ? */
125 #define IS_AFTER(t1, t2) (((t1).tv_sec > (t2).tv_sec) || \
126 (((t1).tv_sec == (t2).tv_sec) \
127 && ((t1).tv_usec > (t2).tv_usec)))
129 #define IS_ZERO(tv) (tv.tv_sec == 0 && tv.tv_usec == 0)
131 #define SET_ZERO(tv) tv.tv_sec = 0, tv.tv_usec = 0
134 addmillisecs(struct timeval
*tv
, int milliseconds
)
136 tv
->tv_usec
+= milliseconds
*1000;
138 tv
->tv_sec
+= tv
->tv_usec
/1000000;
139 tv
->tv_usec
= tv
->tv_usec
%1000000;
144 enqueueTimerHandler(TimerHandler
*handler
)
148 /* insert callback in queue, sorted by time left */
149 if (!timerHandler
|| !IS_AFTER(handler
->when
, timerHandler
->when
)) {
150 /* first in the queue */
151 handler
->next
= timerHandler
;
152 timerHandler
= handler
;
155 while (tmp
->next
&& IS_AFTER(handler
->when
, tmp
->next
->when
)) {
158 handler
->next
= tmp
->next
;
165 WMAddTimerHandler(int milliseconds
, WMCallback
*callback
, void *cdata
)
167 TimerHandler
*handler
;
169 handler
= malloc(sizeof(TimerHandler
));
173 rightNow(&handler
->when
);
174 addmillisecs(&handler
->when
, milliseconds
);
175 handler
->callback
= callback
;
176 handler
->clientData
= cdata
;
177 handler
->permanent
= False
;
179 enqueueTimerHandler(handler
);
186 WMAddEternalTimerHandler(int milliseconds
, WMCallback
*callback
, void *cdata
)
188 TimerHandler
*handler
= WMAddTimerHandler(milliseconds
, callback
, cdata
);
191 handler
->permanent
= True
;
199 WMDeleteTimerWithClientData(void *cdata
)
201 TimerHandler
*handler
, *tmp
;
203 if (!cdata
|| !timerHandler
)
207 if (tmp
->clientData
==cdata
) {
208 tmp
->permanent
= False
;
209 if (!IS_ZERO(tmp
->when
)) {
210 timerHandler
= tmp
->next
;
215 if (tmp
->next
->clientData
==cdata
) {
217 handler
->permanent
= False
;
218 if (IS_ZERO(handler
->when
))
220 tmp
->next
= handler
->next
;
232 WMDeleteTimerHandler(WMHandlerID handlerID
)
234 TimerHandler
*tmp
, *handler
=(TimerHandler
*)handlerID
;
236 if (!handler
|| !timerHandler
)
241 handler
->permanent
= False
;
243 if (IS_ZERO(handler
->when
))
247 timerHandler
= handler
->next
;
251 if (tmp
->next
==handler
) {
252 tmp
->next
=handler
->next
;
264 WMAddIdleHandler(WMCallback
*callback
, void *cdata
)
266 IdleHandler
*handler
;
268 handler
= malloc(sizeof(IdleHandler
));
272 handler
->callback
= callback
;
273 handler
->clientData
= cdata
;
274 /* add handler at end of queue */
276 idleHandler
= WMCreateBag(16);
278 WMPutInBag(idleHandler
, handler
);
285 WMDeleteIdleHandler(WMHandlerID handlerID
)
287 IdleHandler
*handler
= (IdleHandler
*)handlerID
;
290 if (!handler
|| !idleHandler
)
293 pos
= WMGetFirstInBag(idleHandler
, handler
);
294 if (pos
!= WBNotFound
) {
296 WMDeleteFromBag(idleHandler
, pos
);
303 WMAddInputHandler(int fd
, int condition
, WMInputProc
*proc
, void *clientData
)
305 InputHandler
*handler
;
307 handler
= wmalloc(sizeof(InputHandler
));
310 handler
->mask
= condition
;
311 handler
->callback
= proc
;
312 handler
->clientData
= clientData
;
315 inputHandler
= WMCreateBag(16);
316 WMPutInBag(inputHandler
, handler
);
324 WMDeleteInputHandler(WMHandlerID handlerID
)
326 InputHandler
*handler
= (InputHandler
*)handlerID
;
329 if (!handler
|| !inputHandler
)
332 pos
= WMGetFirstInBag(inputHandler
, handler
);
333 if (pos
!= WBNotFound
) {
335 WMDeleteFromBag(inputHandler
, pos
);
344 IdleHandler
*handler
;
349 if (!idleHandler
|| WMGetBagItemCount(idleHandler
)==0) {
350 W_FlushIdleNotificationQueue();
351 /* make sure an observer in queue didn't added an idle handler */
352 return (idleHandler
!=NULL
&& WMGetBagItemCount(idleHandler
)>0);
355 handlerCopy
= WMCreateBag(WMGetBagItemCount(idleHandler
));
356 WMAppendBag(handlerCopy
, idleHandler
);
358 for (handler
= WMBagFirst(handlerCopy
, &iter
);
360 handler
= WMBagNext(handlerCopy
, &iter
)) {
361 /* check if the handler still exist or was removed by a callback */
362 if (WMGetFirstInBag(idleHandler
, handler
) == WBNotFound
)
365 (*handler
->callback
)(handler
->clientData
);
366 WMDeleteIdleHandler(handler
);
369 WMFreeBag(handlerCopy
);
371 W_FlushIdleNotificationQueue();
373 /* this is not necesarrily False, because one handler can re-add itself */
374 return (WMGetBagItemCount(idleHandler
)>0);
382 TimerHandler
*handler
;
386 W_FlushASAPNotificationQueue();
392 handler
= timerHandler
;
393 while (handler
&& IS_AFTER(now
, handler
->when
)) {
394 SET_ZERO(handler
->when
);
395 (*handler
->callback
)(handler
->clientData
);
396 handler
= handler
->next
;
399 while (timerHandler
&& IS_ZERO(handler
->when
)) {
400 handler
= timerHandler
;
401 timerHandler
= timerHandler
->next
;
403 if (handler
->permanent
) {
404 rightNow(&handler
->when
);
405 addmillisecs(&handler
->when
, milliseconds
);
406 enqueueTimerHandler(handler
);
412 W_FlushASAPNotificationQueue();
418 delayUntilNextTimerEvent(struct timeval
*delay
)
423 /* The return value of this function is only valid if there _are_
431 if (IS_AFTER(now
, timerHandler
->when
)) {
435 delay
->tv_sec
= timerHandler
->when
.tv_sec
- now
.tv_sec
;
436 delay
->tv_usec
= timerHandler
->when
.tv_usec
- now
.tv_usec
;
437 if (delay
->tv_usec
< 0) {
438 delay
->tv_usec
+= 1000000;
448 * WMCreateEventHandler--
449 * Create an event handler and put it in the event handler list for the
450 * view. If the same callback and clientdata are already used in another
451 * handler, the masks are swapped.
455 WMCreateEventHandler(WMView
*view
, unsigned long mask
, WMEventProc
*eventProc
,
458 W_EventHandler
*handler
, *ptr
;
459 unsigned long eventMask
;
466 WM_ITERATE_BAG(view
->eventHandlers
, ptr
, iter
) {
467 if (ptr
->clientData
== clientData
&& ptr
->proc
== eventProc
) {
469 eventMask
|= ptr
->eventMask
;
473 handler
= wmalloc(sizeof(W_EventHandler
));
475 WMPutInBag(view
->eventHandlers
, handler
);
477 /* select events for window */
478 handler
->eventMask
= eventMask
;
479 handler
->proc
= eventProc
;
480 handler
->clientData
= clientData
;
485 * WMDeleteEventHandler--
486 * Delete event handler matching arguments from windows
487 * event handler list.
491 WMDeleteEventHandler(WMView
*view
, unsigned long mask
, WMEventProc
*eventProc
,
494 W_EventHandler
*handler
, *ptr
;
499 WM_ITERATE_BAG(view
->eventHandlers
, ptr
, iter
) {
500 if (ptr
->eventMask
== mask
&& ptr
->proc
== eventProc
501 && ptr
->clientData
== clientData
) {
510 WMRemoveFromBag(view
->eventHandlers
, handler
);
518 W_CleanUpEvents(WMView
*view
)
523 WM_ITERATE_BAG(view
->eventHandlers
, ptr
, iter
) {
531 getEventTime(WMScreen
*screen
, XEvent
*event
)
533 switch (event
->type
) {
536 return event
->xbutton
.time
;
539 return event
->xkey
.time
;
541 return event
->xmotion
.time
;
544 return event
->xcrossing
.time
;
546 return event
->xproperty
.time
;
548 return event
->xselectionclear
.time
;
549 case SelectionRequest
:
550 return event
->xselectionrequest
.time
;
551 case SelectionNotify
:
552 return event
->xselection
.time
;
554 return screen
->lastEventTime
;
560 W_CallDestroyHandlers(W_View
*view
)
564 W_EventHandler
*hPtr
;
566 event
.type
= DestroyNotify
;
567 event
.xdestroywindow
.window
= view
->window
;
568 event
.xdestroywindow
.event
= view
->window
;
570 WM_ITERATE_BAG(view
->eventHandlers
, hPtr
, iter
) {
571 if (hPtr
->eventMask
& StructureNotifyMask
) {
572 (*hPtr
->proc
)(&event
, hPtr
->clientData
);
580 WMSetViewNextResponder(WMView
*view
, WMView
*responder
)
582 /* set the widget to receive keyboard events that aren't handled
585 view
->nextResponder
= responder
;
590 WMRelayToNextResponder(WMView
*view
, XEvent
*event
)
592 unsigned long mask
= eventMasks
[event
->xany
.type
];
594 if (view
->nextResponder
) {
595 WMView
*next
= view
->nextResponder
;
596 W_EventHandler
*hPtr
;
599 WM_ITERATE_BAG(next
->eventHandlers
, hPtr
, iter
) {
600 if ((hPtr
->eventMask
& mask
)) {
601 (*hPtr
->proc
)(event
, hPtr
->clientData
);
609 WMHandleEvent(XEvent
*event
)
611 W_EventHandler
*hPtr
;
612 W_View
*view
, *vPtr
, *toplevel
;
617 if (event
->type
== MappingNotify
) {
618 XRefreshKeyboardMapping(&event
->xmapping
);
622 mask
= eventMasks
[event
->xany
.type
];
624 window
= event
->xany
.window
;
626 /* diferentiate SubstructureNotify with StructureNotify */
627 if (mask
== StructureNotifyMask
) {
628 if (event
->xmap
.event
!= event
->xmap
.window
) {
629 mask
= SubstructureNotifyMask
;
630 window
= event
->xmap
.event
;
633 view
= W_GetViewForXWindow(event
->xany
.display
, window
);
636 if (extraEventHandler
)
637 (extraEventHandler
)(event
);
642 view
->screen
->lastEventTime
= getEventTime(view
->screen
, event
);
644 toplevel
= W_TopLevelOfView(view
);
646 if (event
->type
== SelectionNotify
|| event
->type
== SelectionClear
647 || event
->type
== SelectionRequest
) {
648 /* handle selection related events */
649 W_HandleSelectionEvent(event
);
651 } else if (event
->type
== ClientMessage
) {
653 W_HandleDNDClientMessage(toplevel
, &event
->xclient
);
656 /* if it's a key event, redispatch it to the focused control */
657 if (mask
& (KeyPressMask
|KeyReleaseMask
)) {
658 W_View
*focused
= W_FocusedViewOfToplevel(toplevel
);
665 /* compress Motion events */
666 if (event
->type
== MotionNotify
&& !view
->flags
.dontCompressMotion
) {
667 while (XPending(event
->xmotion
.display
)) {
669 XPeekEvent(event
->xmotion
.display
, &ev
);
670 if (ev
.type
== MotionNotify
671 && event
->xmotion
.window
== ev
.xmotion
.window
672 && event
->xmotion
.subwindow
== ev
.xmotion
.subwindow
) {
674 XNextEvent(event
->xmotion
.display
, event
);
679 /* compress expose events */
680 if (event
->type
== Expose
&& !view
->flags
.dontCompressExpose
) {
681 while (XCheckTypedWindowEvent(event
->xexpose
.display
, view
->window
,
686 if (view
->screen
->modalLoop
&& toplevel
!=view
->screen
->modalView
687 && !toplevel
->flags
.worksWhenModal
) {
688 if (event
->type
== KeyPress
|| event
->type
== KeyRelease
689 || event
->type
== MotionNotify
|| event
->type
== ButtonPress
690 || event
->type
== ButtonRelease
691 || event
->type
== FocusIn
|| event
->type
== FocusOut
) {
696 /* do balloon stuffs */
697 if (event
->type
== EnterNotify
)
698 W_BalloonHandleEnterView(view
);
699 else if (event
->type
== LeaveNotify
)
700 W_BalloonHandleLeaveView(view
);
702 /* This is a hack. It will make the panel be secure while
703 * the event handlers are handled, as some event handler
704 * might destroy the widget. */
705 W_RetainView(toplevel
);
707 WM_ITERATE_BAG(view
->eventHandlers
, hPtr
, iter
) {
708 if ((hPtr
->eventMask
& mask
)) {
709 (*hPtr
->proc
)(event
, hPtr
->clientData
);
713 /* pass the event to the top level window of the widget */
714 /* TODO: change this to a responder chain */
715 if (view
->parent
!= NULL
) {
717 while (vPtr
->parent
!= NULL
)
720 WM_ITERATE_BAG(vPtr
->eventHandlers
, hPtr
, iter
) {
721 if (hPtr
->eventMask
& mask
) {
722 (*hPtr
->proc
)(event
, hPtr
->clientData
);
727 /* save button click info to track double-clicks */
728 if (view
->screen
->ignoreNextDoubleClick
) {
729 view
->screen
->ignoreNextDoubleClick
= 0;
731 if (event
->type
== ButtonPress
) {
732 view
->screen
->lastClickWindow
= event
->xbutton
.window
;
733 view
->screen
->lastClickTime
= event
->xbutton
.time
;
737 W_ReleaseView(toplevel
);
744 WMIsDoubleClick(XEvent
*event
)
748 if (event
->type
!= ButtonPress
)
751 view
= W_GetViewForXWindow(event
->xany
.display
, event
->xbutton
.window
);
756 if (view
->screen
->lastClickWindow
!= event
->xbutton
.window
)
759 if (event
->xbutton
.time
- view
->screen
->lastClickTime
760 < WINGsConfiguration
.doubleClickDelay
) {
761 view
->screen
->lastClickTime
= 0;
762 view
->screen
->lastClickWindow
= None
;
763 view
->screen
->ignoreNextDoubleClick
= 1;
771 W_WaitForEvent(Display
*dpy
, unsigned long xeventmask
)
773 #if defined(HAVE_POLL) && defined(HAVE_POLL_H) && !defined(HAVE_SELECT)
775 InputHandler
*handler
;
776 int count
, timeout
, nfds
, i
, retval
;
779 nfds
= WMGetBagItemCount(inputHandler
);
783 fds
= wmalloc(nfds
+1 * sizeof(struct pollfd
));
784 /* put this to the end of array to avoid using ranges from 1 to nfds+1 */
785 fds
[nfds
].fd
= ConnectionNumber(dpy
);
786 fds
[nfds
].events
= POLLIN
;
788 for (i
= 0; i
<nfds
; i
++) {
789 handler
= WMGetFromBag(inputHandler
, i
);
790 fds
[i
].fd
= handler
->fd
;
792 if (handler
->mask
& WIReadMask
)
793 fds
[i
].events
|= POLLIN
;
795 if (handler
->mask
& WIWriteMask
)
796 fds
[i
].events
|= POLLOUT
;
799 if (handler
->mask
& WIExceptMask
)
800 FD_SET(handler
->fd
, &eset
);
805 * Setup the select() timeout to the estimated time until the
806 * next timer expires.
808 if (timerPending()) {
810 delayUntilNextTimerEvent(&tv
);
811 timeout
= tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
821 if (XCheckMaskEvent(dpy
, xeventmask
, &ev
)) {
822 XPutBackEvent(dpy
, &ev
);
827 count
= poll(fds
, nfds
, timeout
);
829 if (count
>0 && nfds
>0) {
830 WMBag
*handlerCopy
= WMCreateBag(nfds
);
832 for (i
=0; i
<nfds
; i
++)
833 WMPutInBag(handlerCopy
, WMGetFromBag(inputHandler
, i
));
835 for (i
=0; i
<nfds
; i
++) {
838 handler
= WMGetFromBag(handlerCopy
, i
);
839 /* check if the handler still exist or was removed by a callback */
840 if (WMGetFirstInBag(inputHandler
, handler
) == WBNotFound
)
845 if ((handler
->mask
& WIReadMask
) &&
846 (fds
[i
].revents
& (POLLIN
|POLLRDNORM
|POLLRDBAND
|POLLPRI
)))
849 if ((handler
->mask
& WIWriteMask
) &&
850 (fds
[i
].revents
& (POLLOUT
| POLLWRBAND
)))
853 if ((handler
->mask
& WIExceptMask
) &&
854 (fds
[i
].revents
& (POLLHUP
| POLLNVAL
| POLLERR
)))
855 mask
|= WIExceptMask
;
857 if (mask
!=0 && handler
->callback
) {
858 (*handler
->callback
)(handler
->fd
, mask
,
859 handler
->clientData
);
863 WMFreeBag(handlerCopy
);
866 retval
= fds
[nfds
].revents
& (POLLIN
|POLLRDNORM
|POLLRDBAND
|POLLPRI
);
869 W_FlushASAPNotificationQueue();
872 #else /* not HAVE_POLL */
874 struct timeval timeout
;
875 struct timeval
*timeoutPtr
;
876 fd_set rset
, wset
, eset
;
879 InputHandler
*handler
;
885 FD_SET(ConnectionNumber(dpy
), &rset
);
886 maxfd
= ConnectionNumber(dpy
);
889 nfds
= WMGetBagItemCount(inputHandler
);
893 for (i
=0; i
<nfds
; i
++) {
894 handler
= WMGetFromBag(inputHandler
, i
);
895 if (handler
->mask
& WIReadMask
)
896 FD_SET(handler
->fd
, &rset
);
898 if (handler
->mask
& WIWriteMask
)
899 FD_SET(handler
->fd
, &wset
);
901 if (handler
->mask
& WIExceptMask
)
902 FD_SET(handler
->fd
, &eset
);
904 if (maxfd
< handler
->fd
)
910 * Setup the select() timeout to the estimated time until the
911 * next timer expires.
913 if (timerPending()) {
914 delayUntilNextTimerEvent(&timeout
);
915 timeoutPtr
= &timeout
;
917 timeoutPtr
= (struct timeval
*)0;
926 if (XCheckMaskEvent(dpy
, xeventmask
, &ev
)) {
927 XPutBackEvent(dpy
, &ev
);
932 count
= select(1 + maxfd
, &rset
, &wset
, &eset
, timeoutPtr
);
934 if (count
>0 && nfds
>0) {
935 WMBag
*handlerCopy
= WMCreateBag(nfds
);
937 for (i
=0; i
<nfds
; i
++)
938 WMPutInBag(handlerCopy
, WMGetFromBag(inputHandler
, i
));
940 for (i
=0; i
<nfds
; i
++) {
943 handler
= WMGetFromBag(handlerCopy
, i
);
944 /* check if the handler still exist or was removed by a callback */
945 if (WMGetFirstInBag(inputHandler
, handler
) == WBNotFound
)
950 if ((handler
->mask
& WIReadMask
) && FD_ISSET(handler
->fd
, &rset
))
953 if ((handler
->mask
& WIWriteMask
) && FD_ISSET(handler
->fd
, &wset
))
956 if ((handler
->mask
& WIExceptMask
) && FD_ISSET(handler
->fd
, &eset
))
957 mask
|= WIExceptMask
;
959 if (mask
!=0 && handler
->callback
) {
960 (*handler
->callback
)(handler
->fd
, mask
,
961 handler
->clientData
);
965 WMFreeBag(handlerCopy
);
968 W_FlushASAPNotificationQueue();
970 return FD_ISSET(ConnectionNumber(dpy
), &rset
);
971 #else /* not HAVE_SELECT, not HAVE_POLL */
972 Neither select nor poll
. You lose
.
973 #endif /* HAVE_SELECT */
974 #endif /* HAVE_POLL */
979 WMNextEvent(Display
*dpy
, XEvent
*event
)
981 /* Check any expired timers */
982 checkTimerHandlers();
984 while (XPending(dpy
) == 0) {
986 /* Do idle and timer stuff while there are no timer or X events */
987 while (XPending(dpy
) == 0 && checkIdleHandlers()) {
988 /* dispatch timer events */
989 checkTimerHandlers();
993 * Make sure that new events did not arrive while we were doing
994 * timer/idle stuff. Or we might block forever waiting for
995 * an event that already arrived.
997 /* wait for something to happen or a timer to expire */
998 W_WaitForEvent(dpy
, 0);
1000 /* Check any expired timers */
1001 checkTimerHandlers();
1004 XNextEvent(dpy
, event
);
1009 WMMaskEvent(Display
*dpy
, long mask
, XEvent
*event
)
1011 unsigned long milliseconds
;
1012 struct timeval timeout
;
1013 struct timeval
*timeoutOrInfty
;
1016 while (!XCheckMaskEvent(dpy
, mask
, event
)) {
1017 /* Do idle stuff while there are no timer or X events */
1018 while (checkIdleHandlers()) {
1019 if (XCheckMaskEvent(dpy
, mask
, event
))
1024 * Setup the select() timeout to the estimated time until the
1025 * next timer expires.
1027 if (timerPending()) {
1028 delayUntilNextTimerEvent(&timeout
);
1029 timeoutOrInfty
= &timeout
;
1031 timeoutOrInfty
= (struct timeval
*)0;
1034 if (XCheckMaskEvent(dpy
, mask
, event
))
1037 /* Wait for input on the X connection socket */
1039 FD_SET(ConnectionNumber(dpy
), &readset
);
1040 select(1 + ConnectionNumber(dpy
), &readset
, (fd_set
*)0, (fd_set
*)0,
1043 /* Check any expired timers */
1044 checkTimerHandlers();
1050 * Cant use this because XPending() will make W_WaitForEvent
1051 * return even if the event in the queue is not what we want,
1052 * and if we block until some new event arrives from the
1053 * server, other events already in the queue (like Expose)
1057 WMMaskEvent(Display
*dpy
, long mask
, XEvent
*event
)
1059 while (!XCheckMaskEvent(dpy
, mask
, event
)) {
1060 /* Do idle stuff while there are no timer or X events */
1061 while (checkIdleHandlers()) {
1062 if (XCheckMaskEvent(dpy
, mask
, event
))
1066 /* Wait for input on the X connection socket */
1067 W_WaitForEvent(dpy
, mask
);
1069 /* Check any expired timers */
1070 checkTimerHandlers();
1076 WMScreenPending(WMScreen
*scr
)
1078 if (XPending(scr
->display
))
1086 WMHookEventHandler(WMEventHook
*handler
)
1088 WMEventHook
*oldHandler
= extraEventHandler
;
1090 extraEventHandler
= handler
;