aewl
diff event.c @ 5:e5018cae273f
added several other stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Mon, 10 Jul 2006 22:16:48 +0200 |
parents | |
children | e0cefb3981c8 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/event.c Mon Jul 10 22:16:48 2006 +0200 1.3 @@ -0,0 +1,264 @@ 1.4 +/* 1.5 + * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> 1.6 + * See LICENSE file for license details. 1.7 + */ 1.8 + 1.9 +#include <fcntl.h> 1.10 +#include <stdlib.h> 1.11 +#include <string.h> 1.12 +#include <X11/keysym.h> 1.13 + 1.14 +#include "wm.h" 1.15 + 1.16 +/* local functions */ 1.17 +static void configurerequest(XEvent *e); 1.18 +static void destroynotify(XEvent *e); 1.19 +static void enternotify(XEvent *e); 1.20 +static void leavenotify(XEvent *e); 1.21 +static void expose(XEvent *e); 1.22 +static void keypress(XEvent *e); 1.23 +static void keymapnotify(XEvent *e); 1.24 +static void maprequest(XEvent *e); 1.25 +static void propertynotify(XEvent *e); 1.26 +static void unmapnotify(XEvent *e); 1.27 + 1.28 +void (*handler[LASTEvent]) (XEvent *) = { 1.29 + [ConfigureRequest] = configurerequest, 1.30 + [DestroyNotify] = destroynotify, 1.31 + [EnterNotify] = enternotify, 1.32 + [LeaveNotify] = leavenotify, 1.33 + [Expose] = expose, 1.34 + [KeyPress] = keypress, 1.35 + [KeymapNotify] = keymapnotify, 1.36 + [MapRequest] = maprequest, 1.37 + [PropertyNotify] = propertynotify, 1.38 + [UnmapNotify] = unmapnotify 1.39 +}; 1.40 + 1.41 +unsigned int 1.42 +flush_masked_events(long even_mask) 1.43 +{ 1.44 + XEvent ev; 1.45 + unsigned int n = 0; 1.46 + while(XCheckMaskEvent(dpy, even_mask, &ev)) n++; 1.47 + return n; 1.48 +} 1.49 + 1.50 +static void 1.51 +configurerequest(XEvent *e) 1.52 +{ 1.53 +#if 0 1.54 + XConfigureRequestEvent *ev = &e->xconfigurerequest; 1.55 + XWindowChanges wc; 1.56 + XRectangle *frect; 1.57 + Client *c; 1.58 + 1.59 + c = client_of_win(ev->window); 1.60 + ev->value_mask &= ~CWSibling; 1.61 + if(c) { 1.62 + gravitate_client(c, True); 1.63 + 1.64 + if(ev->value_mask & CWX) 1.65 + c->rect.x = ev->x; 1.66 + if(ev->value_mask & CWY) 1.67 + c->rect.y = ev->y; 1.68 + if(ev->value_mask & CWWidth) 1.69 + c->rect.width = ev->width; 1.70 + if(ev->value_mask & CWHeight) 1.71 + c->rect.height = ev->height; 1.72 + if(ev->value_mask & CWBorderWidth) 1.73 + c->border = ev->border_width; 1.74 + 1.75 + gravitate_client(c, False); 1.76 + 1.77 + if(c->frame) { 1.78 + if(c->sel->area->floating) 1.79 + frect=&c->sel->rect; 1.80 + else 1.81 + frect=&c->sel->revert; 1.82 + 1.83 + if(c->rect.width >= screen->rect.width && c->rect.height >= screen->rect.height) { 1.84 + frect->y = wc.y = -height_of_bar(); 1.85 + frect->x = wc.x = -def.border; 1.86 + } 1.87 + else { 1.88 + frect->y = wc.y = c->rect.y - height_of_bar(); 1.89 + frect->x = wc.x = c->rect.x - def.border; 1.90 + } 1.91 + frect->width = wc.width = c->rect.width + 2 * def.border; 1.92 + frect->height = wc.height = c->rect.height + def.border 1.93 + + height_of_bar(); 1.94 + wc.border_width = 1; 1.95 + wc.sibling = None; 1.96 + wc.stack_mode = ev->detail; 1.97 + if(c->sel->area->view != screen->sel) 1.98 + wc.x += 2 * screen->rect.width; 1.99 + if(c->sel->area->floating) { 1.100 + XConfigureWindow(dpy, c->framewin, ev->value_mask, &wc); 1.101 + configure_client(c); 1.102 + } 1.103 + } 1.104 + } 1.105 + 1.106 + wc.x = ev->x; 1.107 + wc.y = ev->y; 1.108 + wc.width = ev->width; 1.109 + wc.height = ev->height; 1.110 + 1.111 + if(c && c->frame) { 1.112 + wc.x = def.border; 1.113 + wc.y = height_of_bar(); 1.114 + wc.width = c->sel->rect.width - 2 * def.border; 1.115 + wc.height = c->sel->rect.height - def.border - height_of_bar(); 1.116 + } 1.117 + 1.118 + wc.border_width = 0; 1.119 + wc.sibling = None; 1.120 + wc.stack_mode = Above; 1.121 + ev->value_mask &= ~CWStackMode; 1.122 + ev->value_mask |= CWBorderWidth; 1.123 + XConfigureWindow(dpy, ev->window, ev->value_mask, &wc); 1.124 + 1.125 + XFlush(dpy); 1.126 +#endif 1.127 +} 1.128 + 1.129 +static void 1.130 +destroynotify(XEvent *e) 1.131 +{ 1.132 +#if 0 1.133 + Client *c; 1.134 + XDestroyWindowEvent *ev = &e->xdestroywindow; 1.135 + 1.136 + if((c = client_of_win(ev->window))) 1.137 + destroy_client(c); 1.138 +#endif 1.139 +} 1.140 + 1.141 +static void 1.142 +enternotify(XEvent *e) 1.143 +{ 1.144 +#if 0 1.145 + XCrossingEvent *ev = &e->xcrossing; 1.146 + Client *c; 1.147 + 1.148 + if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) 1.149 + return; 1.150 + 1.151 + if((c = client_of_win(ev->window))) { 1.152 + Frame *f = c->sel; 1.153 + Area *a = f->area; 1.154 + if(a->mode == Colmax) 1.155 + c = a->sel->client; 1.156 + focus(c, False); 1.157 + } 1.158 + else if(ev->window == root) { 1.159 + sel_screen = True; 1.160 + draw_frames(); 1.161 + } 1.162 +#endif 1.163 +} 1.164 + 1.165 +static void 1.166 +leavenotify(XEvent *e) 1.167 +{ 1.168 + XCrossingEvent *ev = &e->xcrossing; 1.169 + 1.170 + if((ev->window == root) && !ev->same_screen) { 1.171 + sel_screen = True; 1.172 + /*draw_frames();*/ 1.173 + } 1.174 +} 1.175 + 1.176 +static void 1.177 +expose(XEvent *e) 1.178 +{ 1.179 + XExposeEvent *ev = &e->xexpose; 1.180 + 1.181 + if(ev->count == 0) { 1.182 + if(ev->window == barwin) 1.183 + draw_bar(); 1.184 + } 1.185 +} 1.186 + 1.187 +static void 1.188 +keypress(XEvent *e) 1.189 +{ 1.190 +#if 0 1.191 + XKeyEvent *ev = &e->xkey; 1.192 + KeySym k = 0; 1.193 + char buf[32]; 1.194 + int n; 1.195 + static Frame *f; 1.196 + 1.197 + 1.198 + ev->state &= valid_mask; 1.199 + if((f = frame_of_win(ev->window))) { 1.200 + buf[0] = 0; 1.201 + n = XLookupString(ev, buf, sizeof(buf), &k, 0); 1.202 + if(IsFunctionKey(k) || IsKeypadKey(k) || IsMiscFunctionKey(k) 1.203 + || IsPFKey(k) || IsPrivateKeypadKey(k)) 1.204 + return; 1.205 + buf[n] = 0; 1.206 + blitz_kpress_input(&f->tagbar, ev->state, k, buf); 1.207 + } 1.208 + else 1.209 + key(root, ev->state, (KeyCode) ev->keycode); 1.210 +#endif 1.211 +} 1.212 + 1.213 +static void 1.214 +keymapnotify(XEvent *e) 1.215 +{ 1.216 +#if 0 1.217 + update_keys(); 1.218 +#endif 1.219 +} 1.220 + 1.221 +static void 1.222 +maprequest(XEvent *e) 1.223 +{ 1.224 +#if 0 1.225 + XMapRequestEvent *ev = &e->xmaprequest; 1.226 + static XWindowAttributes wa; 1.227 + 1.228 + if(!XGetWindowAttributes(dpy, ev->window, &wa)) 1.229 + return; 1.230 + 1.231 + if(wa.override_redirect) { 1.232 + XSelectInput(dpy, ev->window, 1.233 + (StructureNotifyMask | PropertyChangeMask)); 1.234 + return; 1.235 + } 1.236 + 1.237 + if(!client_of_win(ev->window)) 1.238 + manage_client(create_client(ev->window, &wa)); 1.239 +#endif 1.240 +} 1.241 + 1.242 +static void 1.243 +propertynotify(XEvent *e) 1.244 +{ 1.245 +#if 0 1.246 + XPropertyEvent *ev = &e->xproperty; 1.247 + Client *c; 1.248 + 1.249 + if(ev->state == PropertyDelete) 1.250 + return; /* ignore */ 1.251 + 1.252 + if((c = client_of_win(ev->window))) 1.253 + prop_client(c, ev); 1.254 +#endif 1.255 +} 1.256 + 1.257 +static void 1.258 +unmapnotify(XEvent *e) 1.259 +{ 1.260 +#if 0 1.261 + Client *c; 1.262 + XUnmapEvent *ev = &e->xunmap; 1.263 + 1.264 + if((c = client_of_win(ev->window))) 1.265 + destroy_client(c); 1.266 +#endif 1.267 +}