91cc7782f7
to drawimage() and cleanupimage() we don't need to call cleanupimage() as it is already called in cleanup() we don't need to call drawimage() because X11 events should handle that for us anyway
46 lines
847 B
C
46 lines
847 B
C
void
|
|
eventloop(void)
|
|
{
|
|
XEvent ev;
|
|
|
|
while (!XNextEvent(dpy, &ev)) {
|
|
if (XFilterEvent(&ev, win))
|
|
continue;
|
|
switch(ev.type) {
|
|
case DestroyNotify:
|
|
if (ev.xdestroywindow.window != win)
|
|
break;
|
|
cleanup();
|
|
exit(1);
|
|
case ButtonPress:
|
|
buttonpress(&ev);
|
|
break;
|
|
case Expose:
|
|
if (ev.xexpose.count == 0)
|
|
drw_map(drw, win, 0, 0, mw, mh);
|
|
break;
|
|
case FocusIn:
|
|
/* regrab focus from parent window */
|
|
if (ev.xfocus.window != win)
|
|
grabfocus();
|
|
break;
|
|
case KeyPress:
|
|
keypress(&ev);
|
|
break;
|
|
case SelectionNotify:
|
|
if (ev.xselection.property == utf8)
|
|
pastesel();
|
|
break;
|
|
case VisibilityNotify:
|
|
if (ev.xvisibility.state != VisibilityUnobscured)
|
|
XRaiseWindow(dpy, win);
|
|
break;
|
|
}
|
|
|
|
/* redraw image on X11 event */
|
|
#if USEIMAGE
|
|
drawimage();
|
|
#endif
|
|
}
|
|
}
|