*
***********************************************************************/
-#define _GNU_SOURCE /* for ppoll */
#include <stdio.h>
#include <string.h>
-#include <signal.h>
-#include <poll.h>
-#include <errno.h>
#include "twm.h"
#include <X11/Xatom.h>
#include "add_window.h"
\f
-/***********************************************************************
- *
- * Procedures:
- * BlockSignalsAddToList required for every signal we handle
- * BlockSignals } signals must be blocked except in
- * UnBlockSignals } the relevant bit of the event loop
- *
- ***********************************************************************
- */
-
-static _Bool blocksignalslist_initialised;
-static sigset_t blocksignalslist;
-
-void
-BlockSignalsAddToList(sig)
- int sig;
-{
- if (!blocksignalslist_initialised++)
- sigemptyset(&blocksignalslist);
-
- sigaddset(&blocksignalslist, sig);
-}
-
-void
-BlockSignals()
-{
- sigprocmask(SIG_BLOCK, &blocksignalslist, NULL);
-}
-
/***********************************************************************
*
* Procedure:
void
HandleEvents()
{
- struct pollfd pfd;
- pfd.fd = ConnectionNumber(dpy);
- pfd.events = POLLIN|POLLPRI;
- sigset_t emptyset;
- sigemptyset(&emptyset);
-
while (TRUE)
{
if (enter_flag && !QLength(dpy)) {
InstallWindowColormaps(ColormapNotify, (TwmWindow *) NULL);
}
WindowMoved = FALSE;
- while (!XCheckMaskEvent(dpy, -1 /* wot no AllEventMask */, &Event)) {
- int r;
- r = ppoll(&pfd, 1, 0, &emptyset);
- if (r<0 && errno!=EINTR) {
- perror("vtwm: poll failed");
- exit(-1);
- }
- }
+ XNextEvent(dpy, &Event);
(void) DispatchEvent ();
}
}
extern void RedoDoorName(); /* djhjr - 2/28/99 */
extern void RedoListWindow(); /* djhjr - 3/1/99 */
-extern void BlockSignalsAddToList();
-extern void BlockSignals();
-extern void UnblockSignals();
-
extern event_proc EventHandler[];
extern Window DragWindow;
extern int origDragX;
/* djhjr - 6/22/01 */
#ifndef NO_SOUND_SUPPORT
#define sounddonehandler(sig) \
- BlockSignalsAddToList(sig); \
if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, PlaySoundDone)
#else
#define sounddonehandler(sig) \
- BlockSignalsAddToList(sig); \
if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done)
#endif
#define donehandler(sig) \
- BlockSignalsAddToList(sig); \
if (signal (sig, SIG_IGN) != SIG_IGN) (void) signal (sig, Done)
sounddonehandler (SIGINT);
#undef donehandler
/* djhjr - 7/31/98 */
- BlockSignalsAddToList(SIGUSR1);
signal (SIGUSR1, QueueRestartVtwm);
- BlockSignals();
-
Home = getenv("HOME");
if (Home == NULL)
Home = "./";