aewl

annotate event.c @ 11:ea9c08ec4b48

added gridsel to gridwm
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 13:21:57 +0200
parents 703255003abb
children 5cc5e55a132d
rev   line source
garbeam@5 1 /*
garbeam@5 2 * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
garbeam@5 3 * See LICENSE file for license details.
garbeam@5 4 */
garbeam@5 5
garbeam@5 6 #include <fcntl.h>
garbeam@5 7 #include <stdlib.h>
garbeam@5 8 #include <string.h>
garbeam@5 9 #include <X11/keysym.h>
garbeam@5 10
garbeam@5 11 #include "wm.h"
garbeam@5 12
garbeam@5 13 /* local functions */
garbeam@5 14 static void configurerequest(XEvent *e);
garbeam@5 15 static void destroynotify(XEvent *e);
garbeam@5 16 static void enternotify(XEvent *e);
garbeam@5 17 static void leavenotify(XEvent *e);
garbeam@5 18 static void expose(XEvent *e);
garbeam@5 19 static void keymapnotify(XEvent *e);
garbeam@5 20 static void maprequest(XEvent *e);
garbeam@5 21 static void propertynotify(XEvent *e);
garbeam@5 22 static void unmapnotify(XEvent *e);
garbeam@5 23
garbeam@5 24 void (*handler[LASTEvent]) (XEvent *) = {
garbeam@5 25 [ConfigureRequest] = configurerequest,
garbeam@5 26 [DestroyNotify] = destroynotify,
garbeam@5 27 [EnterNotify] = enternotify,
garbeam@5 28 [LeaveNotify] = leavenotify,
garbeam@5 29 [Expose] = expose,
garbeam@5 30 [KeyPress] = keypress,
garbeam@5 31 [KeymapNotify] = keymapnotify,
garbeam@5 32 [MapRequest] = maprequest,
garbeam@5 33 [PropertyNotify] = propertynotify,
garbeam@5 34 [UnmapNotify] = unmapnotify
garbeam@5 35 };
garbeam@5 36
garbeam@5 37 unsigned int
garbeam@5 38 flush_masked_events(long even_mask)
garbeam@5 39 {
garbeam@5 40 XEvent ev;
garbeam@5 41 unsigned int n = 0;
garbeam@5 42 while(XCheckMaskEvent(dpy, even_mask, &ev)) n++;
garbeam@5 43 return n;
garbeam@5 44 }
garbeam@5 45
garbeam@5 46 static void
garbeam@5 47 configurerequest(XEvent *e)
garbeam@5 48 {
garbeam@5 49 XConfigureRequestEvent *ev = &e->xconfigurerequest;
garbeam@5 50 XWindowChanges wc;
garbeam@5 51 Client *c;
garbeam@5 52
garbeam@9 53 c = getclient(ev->window);
garbeam@5 54 ev->value_mask &= ~CWSibling;
garbeam@5 55 if(c) {
garbeam@5 56 if(ev->value_mask & CWX)
garbeam@9 57 c->r[RFloat].x = ev->x;
garbeam@5 58 if(ev->value_mask & CWY)
garbeam@9 59 c->r[RFloat].y = ev->y;
garbeam@5 60 if(ev->value_mask & CWWidth)
garbeam@9 61 c->r[RFloat].width = ev->width;
garbeam@5 62 if(ev->value_mask & CWHeight)
garbeam@9 63 c->r[RFloat].height = ev->height;
garbeam@5 64 if(ev->value_mask & CWBorderWidth)
garbeam@5 65 c->border = ev->border_width;
garbeam@5 66 }
garbeam@5 67
garbeam@5 68 wc.x = ev->x;
garbeam@5 69 wc.y = ev->y;
garbeam@5 70 wc.width = ev->width;
garbeam@5 71 wc.height = ev->height;
garbeam@5 72 wc.border_width = 0;
garbeam@5 73 wc.sibling = None;
garbeam@5 74 wc.stack_mode = Above;
garbeam@5 75 ev->value_mask &= ~CWStackMode;
garbeam@5 76 ev->value_mask |= CWBorderWidth;
garbeam@5 77 XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
garbeam@5 78 XFlush(dpy);
garbeam@5 79 }
garbeam@5 80
garbeam@5 81 static void
garbeam@5 82 destroynotify(XEvent *e)
garbeam@5 83 {
garbeam@5 84 Client *c;
garbeam@5 85 XDestroyWindowEvent *ev = &e->xdestroywindow;
garbeam@5 86
garbeam@11 87 if((c = getclient(ev->window)))
garbeam@11 88 unmanage(c);
garbeam@5 89 }
garbeam@5 90
garbeam@5 91 static void
garbeam@5 92 enternotify(XEvent *e)
garbeam@5 93 {
garbeam@5 94 #if 0
garbeam@5 95 XCrossingEvent *ev = &e->xcrossing;
garbeam@5 96 Client *c;
garbeam@5 97
garbeam@5 98 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
garbeam@5 99 return;
garbeam@5 100
garbeam@5 101 if((c = client_of_win(ev->window))) {
garbeam@5 102 Frame *f = c->sel;
garbeam@5 103 Area *a = f->area;
garbeam@5 104 if(a->mode == Colmax)
garbeam@5 105 c = a->sel->client;
garbeam@5 106 focus(c, False);
garbeam@5 107 }
garbeam@5 108 else if(ev->window == root) {
garbeam@5 109 sel_screen = True;
garbeam@5 110 draw_frames();
garbeam@5 111 }
garbeam@5 112 #endif
garbeam@5 113 }
garbeam@5 114
garbeam@5 115 static void
garbeam@5 116 leavenotify(XEvent *e)
garbeam@5 117 {
garbeam@5 118 XCrossingEvent *ev = &e->xcrossing;
garbeam@5 119
garbeam@5 120 if((ev->window == root) && !ev->same_screen) {
garbeam@5 121 sel_screen = True;
garbeam@5 122 /*draw_frames();*/
garbeam@5 123 }
garbeam@5 124 }
garbeam@5 125
garbeam@5 126 static void
garbeam@5 127 expose(XEvent *e)
garbeam@5 128 {
garbeam@5 129 XExposeEvent *ev = &e->xexpose;
garbeam@5 130
garbeam@5 131 if(ev->count == 0) {
garbeam@5 132 if(ev->window == barwin)
garbeam@5 133 draw_bar();
garbeam@5 134 }
garbeam@5 135 }
garbeam@5 136
garbeam@5 137 static void
garbeam@5 138 keymapnotify(XEvent *e)
garbeam@5 139 {
garbeam@5 140 #if 0
garbeam@5 141 update_keys();
garbeam@5 142 #endif
garbeam@5 143 }
garbeam@5 144
garbeam@5 145 static void
garbeam@5 146 maprequest(XEvent *e)
garbeam@5 147 {
garbeam@5 148 XMapRequestEvent *ev = &e->xmaprequest;
garbeam@5 149 static XWindowAttributes wa;
garbeam@5 150
garbeam@5 151 if(!XGetWindowAttributes(dpy, ev->window, &wa))
garbeam@5 152 return;
garbeam@5 153
garbeam@5 154 if(wa.override_redirect) {
garbeam@5 155 XSelectInput(dpy, ev->window,
garbeam@5 156 (StructureNotifyMask | PropertyChangeMask));
garbeam@5 157 return;
garbeam@5 158 }
garbeam@5 159
garbeam@10 160 if(!getclient(ev->window))
garbeam@10 161 manage(ev->window, &wa);
garbeam@5 162 }
garbeam@5 163
garbeam@5 164 static void
garbeam@5 165 propertynotify(XEvent *e)
garbeam@5 166 {
garbeam@5 167 #if 0
garbeam@5 168 XPropertyEvent *ev = &e->xproperty;
garbeam@5 169 Client *c;
garbeam@5 170
garbeam@5 171 if(ev->state == PropertyDelete)
garbeam@5 172 return; /* ignore */
garbeam@5 173
garbeam@5 174 if((c = client_of_win(ev->window)))
garbeam@5 175 prop_client(c, ev);
garbeam@5 176 #endif
garbeam@5 177 }
garbeam@5 178
garbeam@5 179 static void
garbeam@5 180 unmapnotify(XEvent *e)
garbeam@5 181 {
garbeam@5 182 Client *c;
garbeam@5 183 XUnmapEvent *ev = &e->xunmap;
garbeam@5 184
garbeam@10 185 if((c = getclient(ev->window)))
garbeam@10 186 unmanage(c);
garbeam@5 187 }