aboutsummaryrefslogtreecommitdiffstats
path: root/event.c
diff options
context:
space:
mode:
authorAnselm R. Garbe <garbeam@wmii.de>2006-07-14 22:33:38 +0200
committerAnselm R. Garbe <garbeam@wmii.de>2006-07-14 22:33:38 +0200
commit29355bd38284ed9aec8d3ffabde61db73947c9f9 (patch)
treee8c9d94e52b57df9c93bc58bdd5c37b9e3262e65 /event.c
parent91a1f6926e2594156219c1caaf4729c5d86498a5 (diff)
downloaddwm-29355bd38284ed9aec8d3ffabde61db73947c9f9.tar.gz
rearranged
Diffstat (limited to 'event.c')
-rw-r--r--event.c96
1 files changed, 86 insertions, 10 deletions
diff --git a/event.c b/event.c
index 61dcec5..b369ede 100644
--- a/event.c
+++ b/event.c
@@ -7,11 +7,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include "dwm.h"
+#define ButtonMask (ButtonPressMask | ButtonReleaseMask)
+#define MouseMask (ButtonMask | PointerMotionMask)
+
/* local functions */
static void buttonpress(XEvent *e);
static void configurerequest(XEvent *e);
@@ -19,7 +23,6 @@ static void destroynotify(XEvent *e);
static void enternotify(XEvent *e);
static void leavenotify(XEvent *e);
static void expose(XEvent *e);
-static void keymapnotify(XEvent *e);
static void maprequest(XEvent *e);
static void propertynotify(XEvent *e);
static void unmapnotify(XEvent *e);
@@ -32,21 +35,100 @@ void (*handler[LASTEvent]) (XEvent *) = {
[LeaveNotify] = leavenotify,
[Expose] = expose,
[KeyPress] = keypress,
- [KeymapNotify] = keymapnotify,
[MapRequest] = maprequest,
[PropertyNotify] = propertynotify,
[UnmapNotify] = unmapnotify
};
static void
+mresize(Client *c)
+{
+ XEvent ev;
+ int ocx, ocy;
+
+ ocx = c->x;
+ ocy = c->y;
+ if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurResize], CurrentTime) != GrabSuccess)
+ return;
+ XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w, c->h);
+ for(;;) {
+ XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+ switch(ev.type) {
+ default: break;
+ case Expose:
+ handler[Expose](&ev);
+ break;
+ case MotionNotify:
+ XFlush(dpy);
+ c->w = abs(ocx - ev.xmotion.x);
+ c->h = abs(ocy - ev.xmotion.y);
+ c->x = (ocx <= ev.xmotion.x) ? ocx : ocx - c->w;
+ c->y = (ocy <= ev.xmotion.y) ? ocy : ocy - c->h;
+ resize(c, True);
+ break;
+ case ButtonRelease:
+ XUngrabPointer(dpy, CurrentTime);
+ return;
+ }
+ }
+}
+
+static void
+mmove(Client *c)
+{
+ XEvent ev;
+ int x1, y1, ocx, ocy, di;
+ unsigned int dui;
+ Window dummy;
+
+ ocx = c->x;
+ ocy = c->y;
+ if(XGrabPointer(dpy, root, False, MouseMask, GrabModeAsync, GrabModeAsync,
+ None, cursor[CurMove], CurrentTime) != GrabSuccess)
+ return;
+ XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
+ for(;;) {
+ XMaskEvent(dpy, MouseMask | ExposureMask, &ev);
+ switch (ev.type) {
+ default: break;
+ case Expose:
+ handler[Expose](&ev);
+ break;
+ case MotionNotify:
+ XFlush(dpy);
+ c->x = ocx + (ev.xmotion.x - x1);
+ c->y = ocy + (ev.xmotion.y - y1);
+ resize(c, False);
+ break;
+ case ButtonRelease:
+ XUngrabPointer(dpy, CurrentTime);
+ return;
+ }
+ }
+}
+
+static void
buttonpress(XEvent *e)
{
+ int x;
+ Arg a;
XButtonPressedEvent *ev = &e->xbutton;
Client *c;
- if(barwin == ev->window)
- barclick(ev);
+ if(barwin == ev->window) {
+ x = (arrange == floating) ? textw("~") : 0;
+ for(a.i = 0; a.i < TLast; a.i++) {
+ x += textw(tags[a.i]);
+ if(ev->x < x) {
+ view(&a);
+ break;
+ }
+ }
+ }
else if((c = getclient(ev->window))) {
+ if(arrange == tiling && !c->floating)
+ return;
craise(c);
switch(ev->button) {
default:
@@ -150,12 +232,6 @@ expose(XEvent *e)
}
static void
-keymapnotify(XEvent *e)
-{
- update_keys();
-}
-
-static void
maprequest(XEvent *e)
{
XMapRequestEvent *ev = &e->xmaprequest;