[hackers] [wmii] Make grabbox moves opaque in floating mode. Code needs cleanup. Comments welcome.

From: Kris Maglione <jg_AT_suckless.org>
Date: Sat Feb 10 21:15:06 2007

changeset: 1833:42bcccb70b9f
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 10 15:13:35 2007 -0500
summary: Make grabbox moves opaque in floating mode. Code needs cleanup. Comments welcome.

diff -r 17198918382f -r 42bcccb70b9f event.c
--- a/event.c Sat Feb 10 14:24:05 2007 -0500
+++ b/event.c Sat Feb 10 15:13:35 2007 -0500
@@ -51,13 +51,13 @@ buttonpress(XEvent *e) {
                 if((ev->state & def.mod) == def.mod) {
                         switch(ev->button) {
                         case Button1:
- do_mouse_resize(f->client, CENTER);
+ do_mouse_resize(f->client, False, CENTER);
                                 focus(f->client, True);
                                 frame_to_top(f);
                                 focus(f->client, True);
                                 break;
                         case Button3:
- do_mouse_resize(f->client,
+ do_mouse_resize(f->client, False,
                                                 quadofcoord(&f->client->rect, ev->x, ev->y));
                                 frame_to_top(f);
                                 focus(f->client, True);
@@ -70,9 +70,9 @@ buttonpress(XEvent *e) {
                                 if(frame_to_top(f))
                                         restack_view(f->view);
                                 if(ispointinrect(ev->x, ev->y, &f->grabbox.rect))
- do_mouse_resize(f->client, CENTER);
+ do_mouse_resize(f->client, True, CENTER);
                                 else if(!ispointinrect(ev->x, ev->y, &f->titlebar.rect))
- do_mouse_resize(f->client,
+ do_mouse_resize(f->client, False,
                                                 quadofcoord(&f->client->rect, ev->x, ev->y));
                                 if(f->client != sel_client())
                                         focus(f->client, True);
diff -r 17198918382f -r 42bcccb70b9f mouse.c
--- a/mouse.c Sat Feb 10 14:24:05 2007 -0500
+++ b/mouse.c Sat Feb 10 15:13:35 2007 -0500
@@ -311,7 +311,7 @@ do_managed_move(Client *c) {
 }
 
 void
-do_mouse_resize(Client *c, BlitzAlign align) {
+do_mouse_resize(Client *c, Bool grabbox, BlitzAlign align) {
         BlitzAlign grav;
         Window dummy;
         Cursor cur;
@@ -329,8 +329,13 @@ do_mouse_resize(Client *c, BlitzAlign al
         rects = floating ? rects_of_view(f->area->view, &num) : nil;
         snap = floating ? screen->rect.height / 66 : 0;
         cur = cursor[CurResize];
- if(align == CENTER)
- cur = cursor[CurInvisible];
+
+ if(align == CENTER) {
+ if(grabbox)
+ cur = cursor[CurMove];
+ else
+ cur = cursor[CurInvisible];
+ }
         
         if(!floating && (align == CENTER)) {
                 do_managed_move(c);
@@ -354,7 +359,7 @@ do_mouse_resize(Client *c, BlitzAlign al
                 if(align&WEST) dx -= pt_x;
                 XWarpPointer(blz.dpy, None, c->framewin, 0, 0, 0, 0, dx, dy);
         }
- else {
+ else if(!grabbox) {
                 hr_x = screen->rect.width / 2;
                 hr_y = screen->rect.height / 2;
                 XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
@@ -367,14 +372,25 @@ do_mouse_resize(Client *c, BlitzAlign al
         XQueryPointer(blz.dpy, blz.root, &dummy, &dummy, &i, &i, &pt_x, &pt_y, &di);
 
         XSync(blz.dpy, False);
- XGrabServer(blz.dpy);
-
- draw_xor_border(&frect);
+ if(!grabbox) {
+ XGrabServer(blz.dpy);
+ draw_xor_border(&frect);
+ }
         for(;;) {
                 XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
                 switch (ev.type) {
                 case ButtonRelease:
- draw_xor_border(&frect);
+ if(!grabbox) {
+ draw_xor_border(&frect);
+
+ XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
+ frect.width * rx, frect.height * ry,
+ &dx, &dy, &dummy);
+ if(dy > screen->brect.y)
+ dy = screen->brect.y - 1;
+ XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, dx, dy);
+ XUngrabServer(blz.dpy);
+ }
 
                         if(!floating)
                                 resize_column(c, &frect);
@@ -384,14 +400,6 @@ do_mouse_resize(Client *c, BlitzAlign al
                         if(rects)
                                 free(rects);
 
- XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
- frect.width * rx, frect.height * ry,
- &dx, &dy, &dummy);
- if(dy > screen->brect.y)
- dy = screen->brect.y - 1;
- XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, dx, dy);
-
- XUngrabServer(blz.dpy);
                         XUngrabPointer(blz.dpy, CurrentTime);
                         XSync(blz.dpy, False);
                         return;
@@ -400,7 +408,7 @@ do_mouse_resize(Client *c, BlitzAlign al
                         dx = ev.xmotion.x_root;
                         dy = ev.xmotion.y_root;
 
- if(align == CENTER) {
+ if(align == CENTER && !grabbox) {
                                 if(dx == hr_x && dy == hr_y)
                                         continue;
                                 XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
@@ -424,8 +432,12 @@ do_mouse_resize(Client *c, BlitzAlign al
 
                         match_sizehints(c, &frect, floating, grav);
 
- draw_xor_border(&ofrect);
- draw_xor_border(&frect);
+ if(grabbox)
+ resize_client(c, &frect);
+ else {
+ draw_xor_border(&ofrect);
+ draw_xor_border(&frect);
+ }
                         break;
                 case Expose:
                         (handler[Expose])(&ev);
diff -r 17198918382f -r 42bcccb70b9f wmii.h
--- a/wmii.h Sat Feb 10 14:24:05 2007 -0500
+++ b/wmii.h Sat Feb 10 15:13:35 2007 -0500
@@ -358,7 +358,7 @@ extern unsigned long mod_key_of_str(char
 extern unsigned long mod_key_of_str(char *val);
 
 /* mouse.c */
-extern void do_mouse_resize(Client *c,BlitzAlign align);
+extern void do_mouse_resize(Client *c, Bool grabbox, BlitzAlign align);
 extern void grab_mouse(Window w, unsigned long mod, unsigned int button);
 extern void ungrab_mouse(Window w, unsigned long mod, unsigned int button);
 extern BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
Received on Sat Feb 10 2007 - 21:15:06 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:09 UTC