summaryrefslogtreecommitdiffstats
path: root/tools/aewm-drakx/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/aewm-drakx/events.c')
-rw-r--r--tools/aewm-drakx/events.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/tools/aewm-drakx/events.c b/tools/aewm-drakx/events.c
new file mode 100644
index 000000000..4a6ba53a4
--- /dev/null
+++ b/tools/aewm-drakx/events.c
@@ -0,0 +1,105 @@
+/* aewm - a minimalistic X11 window manager. ------- vim:sw=4:et
+ * Copyright (c) 1998-2001 Decklin Foster <decklin@red-bean.com>
+ * Free software! Please see README for details and license. */
+
+#include "aewm.h"
+
+
+static void handle_configure_request(XConfigureRequestEvent *e)
+{
+ XWindowChanges wc;
+
+ wc.x = e->x;
+ wc.y = e->y;
+ wc.width = e->width;
+ wc.height = e->height;
+ wc.sibling = e->above;
+ wc.stack_mode = e->detail;
+ XConfigureWindow(dpy, e->window, e->value_mask, &wc);
+}
+
+static void handle_map_request(XMapRequestEvent *e)
+{
+ Client *c = find_client(e->window);
+
+ if (c) {
+ XMapWindow(dpy, c->window);
+ set_wm_state(c, NormalState);
+ } else {
+ make_new_client(e->window);
+ }
+}
+
+static void handle_destroy_event(XDestroyWindowEvent *e)
+{
+ Client *c = find_client(e->window);
+
+ if (c) remove_client(c);
+}
+
+
+#ifdef DEBUG
+#define SHOW_EV(name, memb) \
+ case name: s = #name; w = e.memb.window; break;
+#define SHOW(name) \
+ case name: return #name;
+
+void show_event(XEvent e)
+{
+ char *s = 0, buf[20];
+ char *dd = 0;
+ Window w = 0;
+ Client *c;
+
+ switch (e.type) {
+ SHOW_EV(ButtonPress, xbutton)
+ SHOW_EV(ButtonRelease, xbutton)
+ SHOW_EV(ClientMessage, xclient)
+ SHOW_EV(ColormapNotify, xcolormap)
+ SHOW_EV(ConfigureNotify, xconfigure)
+ SHOW_EV(ConfigureRequest, xconfigurerequest)
+ SHOW_EV(CreateNotify, xcreatewindow)
+ SHOW_EV(DestroyNotify, xdestroywindow)
+ SHOW_EV(EnterNotify, xcrossing)
+ SHOW_EV(Expose, xexpose)
+ SHOW_EV(MapNotify, xmap)
+ SHOW_EV(MapRequest, xmaprequest)
+ SHOW_EV(MappingNotify, xmapping)
+ SHOW_EV(MotionNotify, xmotion)
+ SHOW_EV(PropertyNotify, xproperty)
+ SHOW_EV(ReparentNotify, xreparent)
+ SHOW_EV(ResizeRequest, xresizerequest)
+ SHOW_EV(UnmapNotify, xunmap)
+ default:
+ break;
+ }
+
+ c = find_client(w);
+
+ if (c) XFetchName(dpy, c->window, &dd);
+
+ snprintf(buf, sizeof buf, dd ? dd : "");
+ err("%#-10lx: %-20s: %s", w, buf, s);
+}
+#endif
+
+
+void do_event_loop(void)
+{
+ XEvent ev;
+
+ for (;;) {
+ XNextEvent(dpy, &ev);
+#ifdef DEBUG
+ show_event(ev);
+#endif
+ switch (ev.type) {
+ case ConfigureRequest:
+ handle_configure_request(&ev.xconfigurerequest); break;
+ case MapRequest:
+ handle_map_request(&ev.xmaprequest); break;
+ case DestroyNotify:
+ handle_destroy_event(&ev.xdestroywindow); break;
+ }
+ }
+}