2023-05-14 00:21:16 +02:00
|
|
|
/* See LICENSE file for copyright and license details. */
|
2023-06-02 18:37:51 +02:00
|
|
|
void eventloop_x11(void) {
|
2023-05-08 23:00:45 +02:00
|
|
|
XEvent ev;
|
2023-03-08 18:20:27 +01:00
|
|
|
|
2023-05-08 23:00:45 +02:00
|
|
|
while (!XNextEvent(dpy, &ev)) {
|
|
|
|
if (XFilterEvent(&ev, None))
|
|
|
|
continue;
|
2023-05-07 01:41:30 +02:00
|
|
|
|
2023-05-08 23:00:45 +02: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:
|
2023-06-02 18:37:51 +02:00
|
|
|
buttonpress_x11(&ev);
|
2023-04-20 21:22:45 +02:00
|
|
|
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)
|
2023-06-23 03:49:23 +02:00
|
|
|
draw_map(draw, win, 0, 0, sp.mw, sp.mh);
|
2023-04-20 21:22:45 +02:00
|
|
|
break;
|
|
|
|
case FocusIn:
|
|
|
|
// regrab focus from parent window
|
|
|
|
if (ev.xfocus.window != win)
|
|
|
|
grabfocus();
|
|
|
|
break;
|
|
|
|
case KeyPress: // read key array and call functions
|
2023-06-02 18:37:51 +02:00
|
|
|
keypress_x11(&ev);
|
2023-04-20 21:22:45 +02:00
|
|
|
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-05-08 23:00:45 +02:00
|
|
|
}
|
|
|
|
}
|
2023-03-08 18:20:27 +01:00
|
|
|
}
|