equal
deleted
inserted
replaced
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> |
1 /* (C)opyright MMVI-MMVII Anselm R. Garbe <garbeam at gmail dot com> |
2 * See LICENSE file for license details. |
2 * See LICENSE file for license details. |
3 */ |
3 */ |
4 #include "dwm.h" |
4 #include "dwm.h" |
|
5 #include <stdio.h> |
5 #include <stdlib.h> |
6 #include <stdlib.h> |
6 #include <X11/keysym.h> |
7 #include <X11/keysym.h> |
7 #include <X11/Xatom.h> |
8 #include <X11/Xatom.h> |
8 |
9 |
9 /* static */ |
10 /* static */ |
10 |
11 |
11 typedef struct { |
12 typedef struct { |
12 unsigned long mod; |
13 unsigned long mod; |
13 KeySym keysym; |
14 KeySym keysym; |
14 void (*func)(Arg arg); |
15 void (*func)(const char *arg); |
15 Arg arg; |
16 const char *arg; |
16 } Key; |
17 } Key; |
17 |
18 |
18 KEYS |
19 KEYS |
19 |
20 |
20 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) |
21 #define CLEANMASK(mask) (mask & ~(numlockmask | LockMask)) |
110 } |
111 } |
111 } |
112 } |
112 |
113 |
113 static void |
114 static void |
114 buttonpress(XEvent *e) { |
115 buttonpress(XEvent *e) { |
115 int x; |
116 static char arg[8]; |
116 Arg a; |
117 int i, x; |
117 Client *c; |
118 Client *c; |
118 XButtonPressedEvent *ev = &e->xbutton; |
119 XButtonPressedEvent *ev = &e->xbutton; |
119 |
120 |
|
121 arg[0] = 0; |
120 if(barwin == ev->window) { |
122 if(barwin == ev->window) { |
121 x = 0; |
123 x = 0; |
122 for(a.i = 0; a.i < ntags; a.i++) { |
124 for(i = 0; i < ntags; i++) { |
123 x += textw(tags[a.i]); |
125 x += textw(tags[i]); |
124 if(ev->x < x) { |
126 if(ev->x < x) { |
|
127 snprintf(arg, sizeof arg, "%d", i); |
125 if(ev->button == Button1) { |
128 if(ev->button == Button1) { |
126 if(ev->state & MODKEY) |
129 if(ev->state & MODKEY) |
127 tag(a); |
130 tag(arg); |
128 else |
131 else |
129 view(a); |
132 view(arg); |
130 } |
133 } |
131 else if(ev->button == Button3) { |
134 else if(ev->button == Button3) { |
132 if(ev->state & MODKEY) |
135 if(ev->state & MODKEY) |
133 toggletag(a); |
136 toggletag(arg); |
134 else |
137 else |
135 toggleview(a); |
138 toggleview(arg); |
136 } |
139 } |
137 return; |
140 return; |
138 } |
141 } |
139 } |
142 } |
140 if(ev->x < x + blw) |
143 if(ev->x < x + blw) |
141 switch(ev->button) { |
144 switch(ev->button) { |
142 case Button1: |
145 case Button1: |
143 a.i = -1; |
146 setlayout("-1"); |
144 setlayout(a); |
|
145 break; |
147 break; |
146 } |
148 } |
147 } |
149 } |
148 else if((c = getclient(ev->window))) { |
150 else if((c = getclient(ev->window))) { |
149 focus(c); |
151 focus(c); |
152 if(ev->button == Button1 && (lt->arrange == versatile || c->isversatile)) { |
154 if(ev->button == Button1 && (lt->arrange == versatile || c->isversatile)) { |
153 restack(); |
155 restack(); |
154 movemouse(c); |
156 movemouse(c); |
155 } |
157 } |
156 else if(ev->button == Button2) |
158 else if(ev->button == Button2) |
157 zoom(a); |
159 zoom(NULL); |
158 else if(ev->button == Button3 |
160 else if(ev->button == Button3 |
159 && (lt->arrange == versatile || c->isversatile) && !c->isfixed) |
161 && (lt->arrange == versatile || c->isversatile) && !c->isfixed) |
160 { |
162 { |
161 restack(); |
163 restack(); |
162 resizemouse(c); |
164 resizemouse(c); |