summaryrefslogtreecommitdiffstats
path: root/event.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--event.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/event.c b/event.c
index b8a16a7..4e240e2 100644
--- a/event.c
+++ b/event.c
@@ -1,6 +1,5 @@
1/* See LICENSE file for copyright and license details. */ 1/* See LICENSE file for copyright and license details. */
2#include "dwm.h" 2#include "dwm.h"
3#include <stdio.h>
4#include <stdlib.h> 3#include <stdlib.h>
5#include <X11/keysym.h> 4#include <X11/keysym.h>
6#include <X11/Xatom.h> 5#include <X11/Xatom.h>
@@ -15,8 +14,6 @@ typedef struct {
15 const char *arg; 14 const char *arg;
16} Key; 15} Key;
17 16
18KEYS
19
20#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) 17#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
21#define MOUSEMASK (BUTTONMASK | PointerMotionMask) 18#define MOUSEMASK (BUTTONMASK | PointerMotionMask)
22 19
@@ -112,29 +109,26 @@ resizemouse(Client *c) {
112 109
113static void 110static void
114buttonpress(XEvent *e) { 111buttonpress(XEvent *e) {
115 static char buf[32];
116 unsigned int i, x; 112 unsigned int i, x;
117 Client *c; 113 Client *c;
118 XButtonPressedEvent *ev = &e->xbutton; 114 XButtonPressedEvent *ev = &e->xbutton;
119 115
120 buf[0] = 0;
121 if(barwin == ev->window) { 116 if(barwin == ev->window) {
122 x = 0; 117 x = 0;
123 for(i = 0; i < ntags; i++) { 118 for(i = 0; i < ntags; i++) {
124 x += textw(tags[i]); 119 x += textw(tags[i]);
125 if(ev->x < x) { 120 if(ev->x < x) {
126 snprintf(buf, sizeof buf, "%d", i);
127 if(ev->button == Button1) { 121 if(ev->button == Button1) {
128 if(ev->state & MODKEY) 122 if(ev->state & MODKEY)
129 tag(buf); 123 tag(tags[i]);
130 else 124 else
131 view(buf); 125 view(tags[i]);
132 } 126 }
133 else if(ev->button == Button3) { 127 else if(ev->button == Button3) {
134 if(ev->state & MODKEY) 128 if(ev->state & MODKEY)
135 toggletag(buf); 129 toggletag(tags[i]);
136 else 130 else
137 toggleview(buf); 131 toggleview(tags[i]);
138 } 132 }
139 return; 133 return;
140 } 134 }
@@ -257,7 +251,8 @@ expose(XEvent *e) {
257 251
258static void 252static void
259keypress(XEvent *e) { 253keypress(XEvent *e) {
260 static unsigned int len = sizeof key / sizeof key[0]; 254 KEYS
255 unsigned int len = sizeof key / sizeof key[0];
261 unsigned int i; 256 unsigned int i;
262 KeySym keysym; 257 KeySym keysym;
263 XKeyEvent *ev = &e->xkey; 258 XKeyEvent *ev = &e->xkey;
@@ -362,7 +357,8 @@ void (*handler[LASTEvent]) (XEvent *) = {
362 357
363void 358void
364grabkeys(void) { 359grabkeys(void) {
365 static unsigned int len = sizeof key / sizeof key[0]; 360 KEYS
361 unsigned int len = sizeof key / sizeof key[0];
366 unsigned int i; 362 unsigned int i;
367 KeyCode code; 363 KeyCode code;
368 364