2023-05-06 14:36:50 +02:00
|
|
|
void eventloop(void) {
|
2023-03-08 18:20:27 +01:00
|
|
|
XEvent ev;
|
2023-03-25 15:29:51 +01:00
|
|
|
#if USEIMAGE
|
2023-03-21 20:52:12 +01:00
|
|
|
int noimg = 0;
|
2023-03-25 15:29:51 +01:00
|
|
|
#endif
|
2023-03-08 18:20:27 +01:00
|
|
|
|
|
|
|
while (!XNextEvent(dpy, &ev)) {
|
2023-04-01 00:10:21 +02:00
|
|
|
if (XFilterEvent(&ev, None))
|
2023-03-08 18:20:27 +01:00
|
|
|
continue;
|
2023-05-07 01:41:30 +02:00
|
|
|
|
2023-03-08 18:20:27 +01:00
|
|
|
switch(ev.type) {
|
2023-04-20 21:22:45 +02:00
|
|
|
case DestroyNotify:
|
|
|
|
if (ev.xdestroywindow.window != win)
|
|
|
|
break;
|
|
|
|
cleanup();
|
|
|
|
exit(1);
|
|
|
|
case ButtonPress:
|
|
|
|
buttonpress(&ev);
|
|
|
|
#if USEIMAGE
|
|
|
|
noimg = 0;
|
|
|
|
#endif
|
|
|
|
break;
|
2023-04-21 17:59:10 +02:00
|
|
|
case MotionNotify: // currently does nothing
|
2023-04-20 21:22:45 +02:00
|
|
|
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: // read key array and call functions
|
2023-05-07 01:41:30 +02:00
|
|
|
if (listfile) {
|
|
|
|
readfile();
|
|
|
|
|
|
|
|
if (listchanged) {
|
|
|
|
match();
|
|
|
|
drawmenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-06 23:39:03 +02:00
|
|
|
if (incremental) {
|
|
|
|
puts(text);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2023-04-20 21:22:45 +02:00
|
|
|
keypress(&ev);
|
|
|
|
break;
|
|
|
|
case SelectionNotify: // paste selection
|
|
|
|
if (ev.xselection.property == utf8)
|
|
|
|
pastesel();
|
|
|
|
break;
|
|
|
|
case VisibilityNotify:
|
|
|
|
if (ev.xvisibility.state != VisibilityUnobscured)
|
|
|
|
XRaiseWindow(dpy, win);
|
|
|
|
break;
|
|
|
|
case KeyRelease:
|
|
|
|
getcapsstate();
|
|
|
|
drawmenu();
|
|
|
|
break;
|
2023-03-08 18:20:27 +01:00
|
|
|
}
|
|
|
|
|
2023-03-16 16:54:36 +01:00
|
|
|
// redraw image on X11 event
|
2023-03-08 18:20:27 +01:00
|
|
|
#if USEIMAGE
|
2023-03-21 20:52:12 +01:00
|
|
|
if (!noimg) {
|
|
|
|
drawimage();
|
|
|
|
} else {
|
|
|
|
noimg = 0; // draw it next time
|
|
|
|
}
|
2023-03-08 18:20:27 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|