2007-01-02 08:44:19 -06:00
|
|
|
/* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com>
|
2006-07-10 15:16:48 -05:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
2006-07-15 10:00:56 -05:00
|
|
|
#include "dwm.h"
|
2007-02-22 04:42:08 -06:00
|
|
|
#include <stdio.h>
|
2006-07-10 15:16:48 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <X11/keysym.h>
|
2006-07-11 09:14:22 -05:00
|
|
|
#include <X11/Xatom.h>
|
2006-07-10 15:16:48 -05:00
|
|
|
|
2006-08-01 06:59:13 -05:00
|
|
|
/* static */
|
2006-07-19 10:42:08 -05:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned long mod;
|
|
|
|
KeySym keysym;
|
2007-02-22 04:42:08 -06:00
|
|
|
void (*func)(const char *arg);
|
|
|
|
const char *arg;
|
2006-07-19 10:42:08 -05:00
|
|
|
} Key;
|
|
|
|
|
2006-08-01 06:59:13 -05:00
|
|
|
KEYS
|
2006-07-20 08:17:52 -05:00
|
|
|
|
2006-08-14 12:18:02 -05:00
|
|
|
#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
|
2006-10-16 09:50:03 -05:00
|
|
|
#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
|
2006-07-14 15:33:38 -05:00
|
|
|
|
2007-02-19 08:17:31 -06:00
|
|
|
static Client *
|
|
|
|
getclient(Window w) {
|
|
|
|
Client *c;
|
|
|
|
|
|
|
|
for(c = clients; c && c->win != w; c = c->next);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2006-07-15 10:19:19 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
movemouse(Client *c) {
|
2007-02-16 09:38:40 -06:00
|
|
|
int x1, y1, ocx, ocy, di, nx, ny;
|
2006-07-15 10:19:19 -05:00
|
|
|
unsigned int dui;
|
|
|
|
Window dummy;
|
2006-07-20 05:18:06 -05:00
|
|
|
XEvent ev;
|
2006-07-15 10:19:19 -05:00
|
|
|
|
2007-02-16 09:38:40 -06:00
|
|
|
ocx = nx = c->x;
|
2007-02-16 09:51:27 -06:00
|
|
|
ocy = ny = c->y;
|
2006-08-01 07:46:01 -05:00
|
|
|
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
2006-07-20 05:18:06 -05:00
|
|
|
None, cursor[CurMove], CurrentTime) != GrabSuccess)
|
2006-07-15 10:19:19 -05:00
|
|
|
return;
|
2006-09-22 07:00:54 -05:00
|
|
|
c->ismax = False;
|
2006-07-15 10:19:19 -05:00
|
|
|
XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
|
|
|
|
for(;;) {
|
2007-01-22 03:22:58 -06:00
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
|
2006-07-15 10:19:19 -05:00
|
|
|
switch (ev.type) {
|
2006-09-25 14:28:00 -05:00
|
|
|
case ButtonRelease:
|
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
|
|
|
return;
|
2007-01-22 03:22:58 -06:00
|
|
|
case ConfigureRequest:
|
2006-07-15 10:19:19 -05:00
|
|
|
case Expose:
|
2007-01-22 03:22:58 -06:00
|
|
|
case MapRequest:
|
|
|
|
handler[ev.type](&ev);
|
2006-07-15 10:19:19 -05:00
|
|
|
break;
|
|
|
|
case MotionNotify:
|
2006-07-15 11:51:44 -05:00
|
|
|
XSync(dpy, False);
|
2007-02-16 09:38:40 -06:00
|
|
|
nx = ocx + (ev.xmotion.x - x1);
|
|
|
|
ny = ocy + (ev.xmotion.y - y1);
|
|
|
|
if(abs(wax + nx) < SNAP)
|
|
|
|
nx = wax;
|
|
|
|
else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP)
|
|
|
|
nx = wax + waw - c->w - 2 * c->border;
|
|
|
|
if(abs(way - ny) < SNAP)
|
|
|
|
ny = way;
|
|
|
|
else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP)
|
|
|
|
ny = way + wah - c->h - 2 * c->border;
|
|
|
|
resize(c, nx, ny, c->w, c->h, False);
|
2006-07-15 10:19:19 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
resizemouse(Client *c) {
|
2006-07-15 10:19:19 -05:00
|
|
|
int ocx, ocy;
|
2006-08-14 01:43:19 -05:00
|
|
|
int nw, nh;
|
2006-07-20 05:18:06 -05:00
|
|
|
XEvent ev;
|
2006-07-15 10:19:19 -05:00
|
|
|
|
2006-07-20 00:26:23 -05:00
|
|
|
ocx = c->x;
|
|
|
|
ocy = c->y;
|
2006-08-01 07:46:01 -05:00
|
|
|
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
|
2006-10-06 04:50:15 -05:00
|
|
|
None, cursor[CurResize], CurrentTime) != GrabSuccess)
|
2006-07-15 10:19:19 -05:00
|
|
|
return;
|
2006-09-22 07:00:54 -05:00
|
|
|
c->ismax = False;
|
2007-01-22 03:22:58 -06:00
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
|
2006-07-15 10:19:19 -05:00
|
|
|
for(;;) {
|
2007-01-22 03:22:58 -06:00
|
|
|
XMaskEvent(dpy, MOUSEMASK | ExposureMask | SubstructureRedirectMask , &ev);
|
2006-07-15 10:19:19 -05:00
|
|
|
switch(ev.type) {
|
2006-09-25 14:28:00 -05:00
|
|
|
case ButtonRelease:
|
2007-02-12 03:19:52 -06:00
|
|
|
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0,
|
|
|
|
c->w + c->border - 1, c->h + c->border - 1);
|
2006-09-25 14:28:00 -05:00
|
|
|
XUngrabPointer(dpy, CurrentTime);
|
2007-02-12 03:21:26 -06:00
|
|
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
2006-09-25 14:28:00 -05:00
|
|
|
return;
|
2007-01-22 03:22:58 -06:00
|
|
|
case ConfigureRequest:
|
2006-07-15 10:19:19 -05:00
|
|
|
case Expose:
|
2007-01-22 03:22:58 -06:00
|
|
|
case MapRequest:
|
|
|
|
handler[ev.type](&ev);
|
2006-07-15 10:19:19 -05:00
|
|
|
break;
|
|
|
|
case MotionNotify:
|
2006-07-15 11:51:44 -05:00
|
|
|
XSync(dpy, False);
|
2007-02-16 09:38:40 -06:00
|
|
|
if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
|
|
|
|
nw = 1;
|
|
|
|
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)
|
|
|
|
nh = 1;
|
|
|
|
resize(c, c->x, c->y, nw, nh, True);
|
2006-07-15 10:19:19 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-14 15:33:38 -05:00
|
|
|
|
2006-07-11 14:24:10 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
buttonpress(XEvent *e) {
|
2007-02-22 05:00:02 -06:00
|
|
|
static char buf[32];
|
|
|
|
unsigned int i, x;
|
2006-07-11 14:24:10 -05:00
|
|
|
Client *c;
|
2006-07-20 05:18:06 -05:00
|
|
|
XButtonPressedEvent *ev = &e->xbutton;
|
2006-07-11 14:24:10 -05:00
|
|
|
|
2007-02-22 05:00:02 -06:00
|
|
|
buf[0] = 0;
|
2006-07-14 15:33:38 -05:00
|
|
|
if(barwin == ev->window) {
|
2006-08-25 08:48:44 -05:00
|
|
|
x = 0;
|
2007-02-22 04:42:08 -06:00
|
|
|
for(i = 0; i < ntags; i++) {
|
|
|
|
x += textw(tags[i]);
|
2006-08-25 08:48:44 -05:00
|
|
|
if(ev->x < x) {
|
2007-02-22 05:00:02 -06:00
|
|
|
snprintf(buf, sizeof buf, "%d", i);
|
2006-09-01 08:31:59 -05:00
|
|
|
if(ev->button == Button1) {
|
2006-09-01 03:32:50 -05:00
|
|
|
if(ev->state & MODKEY)
|
2007-02-22 05:00:02 -06:00
|
|
|
tag(buf);
|
2006-09-01 03:32:50 -05:00
|
|
|
else
|
2007-02-22 05:00:02 -06:00
|
|
|
view(buf);
|
2006-09-01 08:31:59 -05:00
|
|
|
}
|
|
|
|
else if(ev->button == Button3) {
|
2006-09-01 03:32:50 -05:00
|
|
|
if(ev->state & MODKEY)
|
2007-02-22 05:00:02 -06:00
|
|
|
toggletag(buf);
|
2006-09-01 03:32:50 -05:00
|
|
|
else
|
2007-02-22 05:00:02 -06:00
|
|
|
toggleview(buf);
|
2006-08-31 10:49:04 -05:00
|
|
|
}
|
2006-08-25 08:48:44 -05:00
|
|
|
return;
|
2006-07-14 15:33:38 -05:00
|
|
|
}
|
|
|
|
}
|
2007-02-19 09:40:36 -06:00
|
|
|
if(ev->x < x + blw)
|
2007-01-10 05:54:23 -06:00
|
|
|
switch(ev->button) {
|
|
|
|
case Button1:
|
2007-02-22 05:00:02 -06:00
|
|
|
setlayout(NULL);
|
2007-01-10 05:54:23 -06:00
|
|
|
break;
|
|
|
|
}
|
2006-07-14 15:33:38 -05:00
|
|
|
}
|
2006-07-14 03:34:07 -05:00
|
|
|
else if((c = getclient(ev->window))) {
|
2006-08-01 05:32:33 -05:00
|
|
|
focus(c);
|
2006-09-22 00:37:56 -05:00
|
|
|
if(CLEANMASK(ev->state) != MODKEY)
|
2006-08-21 02:03:14 -05:00
|
|
|
return;
|
2007-02-22 15:10:16 -06:00
|
|
|
if(ev->button == Button1 && (lt->arrange == floating || c->isfloating)) {
|
2006-09-25 01:21:51 -05:00
|
|
|
restack();
|
2006-09-01 08:31:59 -05:00
|
|
|
movemouse(c);
|
|
|
|
}
|
|
|
|
else if(ev->button == Button2)
|
2007-02-22 04:42:08 -06:00
|
|
|
zoom(NULL);
|
2007-02-14 02:09:18 -06:00
|
|
|
else if(ev->button == Button3
|
2007-02-22 15:10:16 -06:00
|
|
|
&& (lt->arrange == floating || c->isfloating) && !c->isfixed)
|
2007-02-13 15:53:58 -06:00
|
|
|
{
|
2006-09-25 01:21:51 -05:00
|
|
|
restack();
|
2006-09-01 08:31:59 -05:00
|
|
|
resizemouse(c);
|
2006-07-11 14:24:10 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-10 15:16:48 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
configurerequest(XEvent *e) {
|
2006-07-20 05:18:06 -05:00
|
|
|
Client *c;
|
2006-07-10 15:16:48 -05:00
|
|
|
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
|
|
|
XWindowChanges wc;
|
|
|
|
|
2006-07-11 14:24:10 -05:00
|
|
|
if((c = getclient(ev->window))) {
|
2006-09-25 13:38:30 -05:00
|
|
|
c->ismax = False;
|
2007-02-14 01:14:41 -06:00
|
|
|
if(ev->value_mask & CWBorderWidth)
|
|
|
|
c->border = ev->border_width;
|
2007-02-22 15:10:16 -06:00
|
|
|
if(c->isfixed || c->isfloating || (lt->arrange == floating)) {
|
2007-02-19 04:22:47 -06:00
|
|
|
if(ev->value_mask & CWX)
|
|
|
|
c->x = ev->x;
|
|
|
|
if(ev->value_mask & CWY)
|
|
|
|
c->y = ev->y;
|
|
|
|
if(ev->value_mask & CWWidth)
|
|
|
|
c->w = ev->width;
|
|
|
|
if(ev->value_mask & CWHeight)
|
|
|
|
c->h = ev->height;
|
2007-02-14 02:09:18 -06:00
|
|
|
if((ev->value_mask & (CWX | CWY))
|
|
|
|
&& !(ev->value_mask & (CWWidth | CWHeight)))
|
2007-02-13 15:53:58 -06:00
|
|
|
configure(c);
|
2007-02-19 04:34:12 -06:00
|
|
|
if(isvisible(c))
|
2007-02-19 04:22:47 -06:00
|
|
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
2006-09-29 05:38:27 -05:00
|
|
|
}
|
2007-02-13 15:53:58 -06:00
|
|
|
else
|
|
|
|
configure(c);
|
2006-08-02 09:32:05 -05:00
|
|
|
}
|
2007-02-13 07:59:58 -06:00
|
|
|
else {
|
|
|
|
wc.x = ev->x;
|
|
|
|
wc.y = ev->y;
|
|
|
|
wc.width = ev->width;
|
|
|
|
wc.height = ev->height;
|
|
|
|
wc.border_width = ev->border_width;
|
|
|
|
wc.sibling = ev->above;
|
|
|
|
wc.stack_mode = ev->detail;
|
|
|
|
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
|
|
|
}
|
2007-02-13 06:39:33 -06:00
|
|
|
XSync(dpy, False);
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
destroynotify(XEvent *e) {
|
2006-07-10 15:16:48 -05:00
|
|
|
Client *c;
|
|
|
|
XDestroyWindowEvent *ev = &e->xdestroywindow;
|
|
|
|
|
2006-07-11 06:21:57 -05:00
|
|
|
if((c = getclient(ev->window)))
|
|
|
|
unmanage(c);
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
enternotify(XEvent *e) {
|
2006-07-10 15:16:48 -05:00
|
|
|
Client *c;
|
2006-07-20 05:18:06 -05:00
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
2006-07-10 15:16:48 -05:00
|
|
|
|
2006-08-10 03:16:12 -05:00
|
|
|
if(ev->mode != NotifyNormal || ev->detail == NotifyInferior)
|
2006-07-10 15:16:48 -05:00
|
|
|
return;
|
2007-01-14 15:27:29 -06:00
|
|
|
if((c = getclient(ev->window)) && isvisible(c))
|
2006-07-11 09:14:22 -05:00
|
|
|
focus(c);
|
2006-08-10 04:26:32 -05:00
|
|
|
else if(ev->window == root) {
|
2007-01-23 10:12:15 -06:00
|
|
|
selscreen = True;
|
2007-01-22 03:22:58 -06:00
|
|
|
for(c = stack; c && !isvisible(c); c = c->snext);
|
|
|
|
focus(c);
|
2006-08-10 04:26:32 -05:00
|
|
|
}
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
expose(XEvent *e) {
|
2006-07-20 05:18:06 -05:00
|
|
|
XExposeEvent *ev = &e->xexpose;
|
2006-07-10 15:16:48 -05:00
|
|
|
|
|
|
|
if(ev->count == 0) {
|
2006-07-14 11:46:12 -05:00
|
|
|
if(barwin == ev->window)
|
2006-07-14 15:54:09 -05:00
|
|
|
drawstatus();
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-15 10:00:56 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
keypress(XEvent *e) {
|
2006-11-26 07:26:53 -06:00
|
|
|
static unsigned int len = sizeof key / sizeof key[0];
|
2006-11-27 10:49:58 -06:00
|
|
|
unsigned int i;
|
2006-07-15 10:00:56 -05:00
|
|
|
KeySym keysym;
|
2006-07-20 05:18:06 -05:00
|
|
|
XKeyEvent *ev = &e->xkey;
|
2006-07-15 10:00:56 -05:00
|
|
|
|
|
|
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
2007-02-14 02:09:18 -06:00
|
|
|
for(i = 0; i < len; i++)
|
2006-09-12 03:57:28 -05:00
|
|
|
if(keysym == key[i].keysym
|
2007-02-14 02:09:18 -06:00
|
|
|
&& CLEANMASK(key[i].mod) == CLEANMASK(ev->state))
|
2006-08-14 08:11:02 -05:00
|
|
|
{
|
2006-11-27 10:49:58 -06:00
|
|
|
if(key[i].func)
|
2007-02-22 00:59:13 -06:00
|
|
|
key[i].func(key[i].arg);
|
2006-07-15 10:00:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
leavenotify(XEvent *e) {
|
2006-07-15 10:00:56 -05:00
|
|
|
XCrossingEvent *ev = &e->xcrossing;
|
|
|
|
|
2007-01-18 04:11:40 -06:00
|
|
|
if((ev->window == root) && !ev->same_screen) {
|
2007-01-23 10:12:15 -06:00
|
|
|
selscreen = False;
|
2007-01-23 04:49:16 -06:00
|
|
|
focus(NULL);
|
2007-01-18 04:11:40 -06:00
|
|
|
}
|
2006-07-15 10:00:56 -05:00
|
|
|
}
|
|
|
|
|
2006-08-14 09:08:52 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
mappingnotify(XEvent *e) {
|
2006-08-14 09:08:52 -05:00
|
|
|
XMappingEvent *ev = &e->xmapping;
|
|
|
|
|
|
|
|
XRefreshKeyboardMapping(ev);
|
|
|
|
if(ev->request == MappingKeyboard)
|
|
|
|
grabkeys();
|
|
|
|
}
|
|
|
|
|
2006-07-10 15:16:48 -05:00
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
maprequest(XEvent *e) {
|
2006-07-10 15:16:48 -05:00
|
|
|
static XWindowAttributes wa;
|
2006-07-20 05:18:06 -05:00
|
|
|
XMapRequestEvent *ev = &e->xmaprequest;
|
2006-07-10 15:16:48 -05:00
|
|
|
|
|
|
|
if(!XGetWindowAttributes(dpy, ev->window, &wa))
|
|
|
|
return;
|
2007-02-12 09:41:46 -06:00
|
|
|
if(wa.override_redirect)
|
2006-07-10 15:16:48 -05:00
|
|
|
return;
|
2006-07-11 06:02:22 -05:00
|
|
|
if(!getclient(ev->window))
|
|
|
|
manage(ev->window, &wa);
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
propertynotify(XEvent *e) {
|
2006-07-10 15:16:48 -05:00
|
|
|
Client *c;
|
2006-07-20 05:18:06 -05:00
|
|
|
Window trans;
|
|
|
|
XPropertyEvent *ev = &e->xproperty;
|
2006-07-10 15:16:48 -05:00
|
|
|
|
|
|
|
if(ev->state == PropertyDelete)
|
|
|
|
return; /* ignore */
|
2006-07-11 09:14:22 -05:00
|
|
|
if((c = getclient(ev->window))) {
|
|
|
|
switch (ev->atom) {
|
|
|
|
default: break;
|
|
|
|
case XA_WM_TRANSIENT_FOR:
|
2006-07-13 14:42:17 -05:00
|
|
|
XGetTransientForHint(dpy, c->win, &trans);
|
2007-02-22 15:10:16 -06:00
|
|
|
if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
|
2007-02-19 09:40:36 -06:00
|
|
|
lt->arrange();
|
2006-07-11 09:14:22 -05:00
|
|
|
break;
|
|
|
|
case XA_WM_NORMAL_HINTS:
|
2007-01-01 12:10:31 -06:00
|
|
|
updatesizehints(c);
|
2006-07-11 09:14:22 -05:00
|
|
|
break;
|
|
|
|
}
|
2006-07-15 10:19:19 -05:00
|
|
|
if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
|
2006-09-11 03:00:56 -05:00
|
|
|
updatetitle(c);
|
2007-01-15 05:04:25 -06:00
|
|
|
if(c == sel)
|
|
|
|
drawstatus();
|
2006-07-11 09:14:22 -05:00
|
|
|
}
|
|
|
|
}
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-09-12 03:57:28 -05:00
|
|
|
unmapnotify(XEvent *e) {
|
2006-07-10 15:16:48 -05:00
|
|
|
Client *c;
|
|
|
|
XUnmapEvent *ev = &e->xunmap;
|
|
|
|
|
2006-07-11 06:02:22 -05:00
|
|
|
if((c = getclient(ev->window)))
|
|
|
|
unmanage(c);
|
2006-07-10 15:16:48 -05:00
|
|
|
}
|
2006-07-15 10:00:56 -05:00
|
|
|
|
2006-07-17 02:12:29 -05:00
|
|
|
/* extern */
|
2006-07-15 10:00:56 -05:00
|
|
|
|
|
|
|
void (*handler[LASTEvent]) (XEvent *) = {
|
|
|
|
[ButtonPress] = buttonpress,
|
|
|
|
[ConfigureRequest] = configurerequest,
|
|
|
|
[DestroyNotify] = destroynotify,
|
|
|
|
[EnterNotify] = enternotify,
|
|
|
|
[LeaveNotify] = leavenotify,
|
|
|
|
[Expose] = expose,
|
|
|
|
[KeyPress] = keypress,
|
2006-08-14 09:08:52 -05:00
|
|
|
[MappingNotify] = mappingnotify,
|
2006-07-15 10:00:56 -05:00
|
|
|
[MapRequest] = maprequest,
|
|
|
|
[PropertyNotify] = propertynotify,
|
|
|
|
[UnmapNotify] = unmapnotify
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2006-09-25 01:21:51 -05:00
|
|
|
grabkeys(void) {
|
2006-11-26 07:26:53 -06:00
|
|
|
static unsigned int len = sizeof key / sizeof key[0];
|
2006-07-15 10:00:56 -05:00
|
|
|
unsigned int i;
|
|
|
|
KeyCode code;
|
|
|
|
|
2006-08-14 09:08:52 -05:00
|
|
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
2006-07-15 10:00:56 -05:00
|
|
|
for(i = 0; i < len; i++) {
|
|
|
|
code = XKeysymToKeycode(dpy, key[i].keysym);
|
|
|
|
XGrabKey(dpy, code, key[i].mod, root, True,
|
|
|
|
GrabModeAsync, GrabModeAsync);
|
2006-08-02 04:13:32 -05:00
|
|
|
XGrabKey(dpy, code, key[i].mod | LockMask, root, True,
|
|
|
|
GrabModeAsync, GrabModeAsync);
|
2006-08-14 12:18:02 -05:00
|
|
|
XGrabKey(dpy, code, key[i].mod | numlockmask, root, True,
|
2006-08-01 06:59:13 -05:00
|
|
|
GrabModeAsync, GrabModeAsync);
|
2006-08-14 12:18:02 -05:00
|
|
|
XGrabKey(dpy, code, key[i].mod | numlockmask | LockMask, root, True,
|
2006-08-01 06:59:13 -05:00
|
|
|
GrabModeAsync, GrabModeAsync);
|
2006-07-15 10:00:56 -05:00
|
|
|
}
|
|
|
|
}
|