spmenu/libs/event.c

62 lines
1.2 KiB
C
Raw Normal View History

void
eventloop(void)
{
XEvent ev;
2023-03-25 15:29:51 +01:00
#if USEIMAGE
int noimg = 0;
2023-03-25 15:29:51 +01:00
#endif
while (!XNextEvent(dpy, &ev)) {
2023-04-01 00:10:21 +02:00
if (XFilterEvent(&ev, None))
continue;
switch(ev.type) {
case DestroyNotify:
if (ev.xdestroywindow.window != win)
break;
cleanup();
exit(1);
case ButtonPress:
buttonpress(&ev);
2023-03-25 15:29:51 +01:00
#if USEIMAGE
noimg = 0;
2023-03-25 15:29:51 +01:00
#endif
break;
case MotionNotify:
motionevent(&ev.xbutton);
2023-03-25 15:29:51 +01:00
#if USEIMAGE
noimg = 0;
#endif
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;
2023-03-31 12:42:15 +02:00
case KeyPress: // read key array and call functions
keypress(&ev);
break;
2023-03-31 12:42:15 +02:00
case SelectionNotify: // paste selection
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
if (!noimg) {
drawimage();
} else {
noimg = 0; // draw it next time
}
#endif
}
}