[hackers] [wmii] Fix a bunch of bugs. No more Xored moves/resizes.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri, 01 Jun 2007 01:09:28 -0000

changeset: 2092:b3e7bd11d96d
user: Kris Maglione <jg_AT_suckless.org>
date: Tue Apr 17 21:34:36 2007 -0400
summary: Fix a bunch of bugs. No more Xored moves/resizes.

diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/area.c
--- a/cmd/wmii/area.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/area.c Tue Apr 17 21:34:36 2007 -0400
@@ -39,7 +39,7 @@ create_area(View *v, Area *pos, uint w)
         colnum = max((areanum - 1), 0);
         if(w == 0) {
                 if(colnum) {
- w = newcolw_of_view(v, max(i-1, 0));
+ w = newcolw(v, max(i-1, 0));
                         if (w == 0)
                                 w = Dx(screen->rect) / (colnum + 1);
                 }
@@ -432,11 +432,11 @@ select_area(Area *a, char *arg) {
         f = a->sel;
         if(!strcmp(arg, "toggle")) {
                 if(!a->floating)
- a = v->area;
+ ap = v->area;
                 else if(v->revert)
- a = v->revert;
- else
- a = v->area->next;
+ ap = v->revert;
+ else
+ ap = v->area->next;
         }
         else if(!strcmp(arg, "left")) {
                 if(a->floating)
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/client.c
--- a/cmd/wmii/client.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/client.c Tue Apr 17 21:34:36 2007 -0400
@@ -49,22 +49,17 @@ create_client(XWindow w, XWindowAttribut
         XAddToSaveSet(display, w);
 
         fwa.override_redirect = True;
- fwa.background_pixmap = ParentRelative;
- fwa.backing_store = Always;
         fwa.event_mask =
                   SubstructureRedirectMask
                 | SubstructureNotifyMask
                 | ExposureMask
                 | EnterWindowMask
                 | PointerMotionMask
- | KeyPressMask
                 | ButtonPressMask
                 | ButtonReleaseMask;
         c->framewin = createwindow(&scr.root, c->rect, scr.depth, InputOutput, &fwa,
                   CWOverrideRedirect
- | CWEventMask
- | CWBackPixmap
- | CWBackingStore);
+ | CWEventMask);
         c->framewin->aux = c;
         c->win.aux = c;
         sethandler(c->framewin, &framehandler);
@@ -94,15 +89,15 @@ destroy_client(Client *c) {
         Client **tc;
         XEvent ev;
 
- XGrabServer(display);
- /* In case the client is already unmapped */
- XSetErrorHandler(dummy_error_handler);
-
         for(tc=&client; *tc; tc=&(*tc)->next)
                 if(*tc == c) {
                         *tc = c->next;
                         break;
                 }
+
+ XGrabServer(display);
+ /* In case the client is already unmapped */
+ XSetErrorHandler(dummy_error_handler);
 
         dummy = nil;
         update_client_views(c, &dummy);
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/fns.h Tue Apr 17 21:34:36 2007 -0400
@@ -140,7 +140,7 @@ uchar *view_index(View*);
 uchar *view_index(View*);
 void destroy_view(View*);
 void update_views();
-uint newcolw_of_view(View*, int i);
+uint newcolw(View*, int i);
 
 /* wm.c */
 int wmii_error_handler(Display*, XErrorEvent *error);
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/frame.c Tue Apr 17 21:34:36 2007 -0400
@@ -50,6 +50,8 @@ remove_frame(Frame *f) {
                         f->sprev->snext = f->snext;
                 if(f->snext)
                         f->snext->sprev = f->sprev;
+ if(f == a->stack)
+ a->stack = f->snext;
         }
         f->anext = f->aprev = f->snext = f->sprev = nil;
 }
@@ -81,6 +83,27 @@ insert_frame(Frame *pos, Frame *f, Bool
                 if(f->snext)
                         f->snext->sprev = f;
         }
+}
+
+Bool
+frame_to_top(Frame *f) {
+ Area *a;
+
+ a = f->area;
+ if(!a->floating || f == a->stack)
+ return False;
+
+ if(f->sprev)
+ f->sprev = f->snext;
+ if(f->snext)
+ f->snext = f->sprev;
+
+ f->snext = a->stack;
+ a->stack = f;
+ if(f->snext)
+ f->snext->sprev = f;
+
+ return True;
 }
 
 Rectangle
@@ -273,27 +296,6 @@ set_frame_cursor(Frame *f, Point pt) {
                 set_cursor(f->client, cursor[CurNormal]);
 }
 
-Bool
-frame_to_top(Frame *f) {
- Area *a;
-
- a = f->area;
- if(!a->floating || f == a->stack)
- return False;
-
- if(f->sprev)
- f->sprev = f->snext;
- if(f->snext)
- f->snext = f->sprev;
-
- f->snext = a->stack;
- a->stack = f;
- if(f->snext)
- f->snext->sprev = f;
-
- return True;
-}
-
 void
 swap_frames(Frame *fa, Frame *fb) {
         Rectangle trect;
@@ -384,9 +386,10 @@ draw_frame(Frame *f) {
                                 col = &def.focuscolor;
                                 break;
                         }
+ fr = f->client->framewin->r;
+ fr = rectsubpt(fr, fr.min);
 
         /* background */
- fr = rectsubpt(f->rect, f->rect.min);
         r = fr;
         fill(screen->ibuf, r, col->bg);
         border(screen->ibuf, r, 1, col->border);
@@ -430,23 +433,21 @@ Rectangle
 Rectangle
 constrain(Rectangle r) {
         Rectangle sr;
- int barheight;
+ Point p;
 
         sr = screen->rect;
- barheight = Dy(screen->brect);
- sr.max.y -= barheight;
+ sr.max.y = screen->brect.min.y;
 
         if(Dx(r) > Dx(sr))
                 r.max.x = r.min.x + Dx(sr);
         if(Dy(r) > Dy(sr))
                 r.max.y = r.min.y + Dy(sr);
- if(r.min.x > sr.max.x - barheight)
- rectsubpt(r, Pt(sr.min.x - sr.max.x + barheight, 0));
- if(r.min.y > sr.max.y - barheight)
- rectsubpt(r, Pt(0, sr.min.y - sr.max.y + barheight));
- if(r.max.x < barheight)
- rectaddpt(r, Pt(barheight - sr.max.x, 0));
- if(r.max.y < barheight)
- rectaddpt(r, Pt(0, barheight - sr.max.y));
- return r;
-}
+
+ sr = insetrect(sr, Dy(screen->brect));
+ p = ZP;
+ p.x -= min(r.max.x - sr.min.x, 0);
+ p.x -= max(r.min.x - sr.max.x, 0);
+ p.y -= min(r.max.y - sr.min.y, 0);
+ p.y -= max(r.min.y - sr.max.y, 0);
+ return rectaddpt(r, p);
+}
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/geom.c
--- a/cmd/wmii/geom.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/geom.c Tue Apr 17 21:34:36 2007 -0400
@@ -14,9 +14,10 @@ ptinrect(Point pt, Rectangle r) {
 
 Align
 quadrant(Rectangle r, Point pt) {
- Align ret = 0;
+ Align ret;
 
         pt = subpt(pt, r.min);
+ ret = 0;
 
         if(pt.x >= Dx(r) * .5)
                 ret |= EAST;
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/mouse.c Tue Apr 17 21:34:36 2007 -0400
@@ -54,7 +54,7 @@ framerect(Framewin *f) {
         p.x -= max(r.max.x - screen->rect.max.x, 0);
         p.y -= min(r.min.y, 0);
         p.y -= max(r.max.y - screen->brect.min.y, 0);
- return rectaddpt(r, p);;
+ return rectaddpt(r, p);
 }
 
 static void
@@ -455,28 +455,6 @@ done:
 }
 
 static void
-xorborder(Rectangle r) {
- Rectangle r2;
- ulong col;
-
- col = def.focuscolor.bg;
-
- r2 = insetrect(r, 4);
-
- if(Dy(r) > 4 && Dx(r) > 2)
- drawline(&xor,
- Pt(r2.min.x, r2.min.y + Dy(r2)/2),
- Pt(r2.max.x, r2.min.y + Dy(r2)/2),
- CapNotLast, 1, col);
- if(Dx(r) > 4 && Dy(r) > 2)
- drawline(&xor,
- Pt(r2.min.x + Dx(r2)/2, r.min.y),
- Pt(r2.min.x + Dx(r2)/2, r.max.y),
- CapNotLast, 1, col);
- border(&xor, r, 4, col);
-}
-
-static void
 rect_morph_xy(Rectangle *r, Point d, Align *mask) {
         int n;
 
@@ -600,7 +578,7 @@ do_mouse_resize(Client *c, Bool opaque,
 do_mouse_resize(Client *c, Bool opaque, Align align) {
         XEvent ev;
         Rectangle *rects;
- Rectangle ofrect, frect, origin;
+ Rectangle frect, origin;
         Align grav;
         Cursor cur;
         Point d, pt, hr;
@@ -624,7 +602,7 @@ do_mouse_resize(Client *c, Bool opaque,
 
         cur = cursor_of_quad(align);
         if((align==CENTER) && !opaque)
- cur = cursor[CurInvisible];
+ cur = cursor[CurSizing];
 
         pt = querypointer(c->framewin);
         rx = (float)pt.x / Dx(frect);
@@ -635,15 +613,18 @@ do_mouse_resize(Client *c, Bool opaque,
 
         pt = querypointer(&scr.root);
 
+ hr = subpt(frect.max, frect.min);
+ hr = divpt(hr, Pt(2, 2));
+
         if(align != CENTER) {
- d = subpt(frect.max, frect.min);
- hr = d = divpt(d, Pt(2, 2));
+ d = hr;
+
                 if(align&NORTH) d.y -= hr.y;
                 if(align&SOUTH) d.y += hr.y;
                 if(align&EAST) d.x += hr.x;
                 if(align&WEST) d.x -= hr.x;
 
- pt = translate(c->framewin, &scr.root, d);
+ pt = addpt(d, f->rect.min);
                 warppointer(pt);
         }
         else if(f->client->fullscreen) {
@@ -655,19 +636,17 @@ do_mouse_resize(Client *c, Bool opaque,
                                 / Dx(screen->rect);
                 hry = (double)(Dy(screen->rect) + Dy(frect) - 3 * labelh(def.font))
                                 / Dy(screen->rect);
- pt = frect.max;
- pt.x = (pt.x - labelh(def.font)) / hrx;
- pt.y = (pt.y - labelh(def.font)) / hry;
- warppointer(pt);
+
+ pt.x = frect.max.x - labelh(def.font);
+ pt.y = frect.max.y - labelh(def.font);
+ d.x = pt.x / hrx;
+ d.y = pt.y / hry;
+
+ warppointer(d);
                 flushevents(PointerMotionMask, False);
         }
 
- XSync(display, False);
- if(!opaque) {
- XGrabServer(display);
- xorborder(frect);
- }else
- unmap_client(c, IconicState);
+ unmap_client(c, IconicState);
 
         for(;;) {
                 XMaskEvent(display, MouseMask | ExposureMask, &ev);
@@ -678,7 +657,6 @@ do_mouse_resize(Client *c, Bool opaque,
                         dispatch_event(&ev);
                         break;
                 case MotionNotify:
- ofrect = frect;
                         d.x = ev.xmotion.x_root;
                         d.y = ev.xmotion.y_root;
 
@@ -698,18 +676,9 @@ do_mouse_resize(Client *c, Bool opaque,
                         apply_sizehints(c, &frect, floating, True, grav);
                         frect = constrain(frect);
 
- if(opaque) {
- movewin(c->framewin, frect.min);
- XSync(display, False);
- }else {
- xorborder(ofrect);
- xorborder(frect);
- }
+ reshapewin(c->framewin, frect);
                         break;
                 case ButtonRelease:
- if(!opaque)
- xorborder(frect);
-
                         resize_client(c, &frect);
 
                         if(!opaque) {
@@ -718,9 +687,9 @@ do_mouse_resize(Client *c, Bool opaque,
                                 if(pt.y > screen->brect.min.y)
                                         pt.y = screen->brect.min.y - 1;
                                 warppointer(pt);
- XUngrabServer(display);
- }else
- map_client(c);
+ }
+
+ map_client(c);
 
                         free(rects);
                         XUngrabPointer(display, CurrentTime);
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/view.c
--- a/cmd/wmii/view.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/view.c Tue Apr 17 21:34:36 2007 -0400
@@ -482,7 +482,7 @@ update_views() {
 }
 
 uint
-newcolw_of_view(View *v, int num) {
+newcolw(View *v, int num) {
         regmatch_t regm;
         Rule *r;
         uint n;
diff -r 03a3b69ded14 -r b3e7bd11d96d cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Tue Apr 17 14:41:22 2007 -0400
+++ b/cmd/wmii/x11.c Tue Apr 17 21:34:36 2007 -0400
@@ -48,8 +48,8 @@ subpt(Point p, Point q) {
 
 Point
 divpt(Point p, Point q) {
- p.x *= q.x;
- p.y *= q.y;
+ p.x /= q.x;
+ p.y /= q.y;
         return p;
 }
 
@@ -177,7 +177,7 @@ movewin(Window *w, Point pt) {
 
         assert(w->type == WWindow);
         r = rectsubpt(w->r, w->r.min);
- r = rectaddpt(w->r, pt);
+ r = rectaddpt(r, pt);
         reshapewin(w, r);
 }
 
Received on Fri Jun 01 2007 - 03:09:27 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:57 UTC