[hackers] [wmii] Fixed some bugs with managed moves/swaps. Some cleanup elsewhere.

From: Kris Maglione <jg_AT_suckless.org>
Date: Thu Apr 05 23:33:30 2007

changeset: 2057:2d8d76d19163
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Thu Apr 05 17:30:50 2007 -0400
summary: Fixed some bugs with managed moves/swaps. Some cleanup elsewhere.

diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/area.c
--- a/cmd/wmii/area.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/area.c Thu Apr 05 17:30:50 2007 -0400
@@ -158,6 +158,7 @@ attach_to_area(Area *a, Frame *f, Bool s
         focus_frame(f, False);
         resize_frame(f, &f->rect);
         restack_view(a->view);
+
         if(!a->floating)
                 arrange_column(a, False);
         else
diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/frame.c Thu Apr 05 17:30:50 2007 -0400
@@ -48,16 +48,20 @@ void
 void
 insert_frame(Frame *pos, Frame *f, Bool before) {
         Frame *ft, **p;
- Area *a = f->area;
+ Area *a;
+
+ a = f->area;
 
         if(before) {
                 for(ft=a->frame; ft; ft=ft->anext)
                         if(ft->anext == pos) break;
                 pos=ft;
         }
+
         p = &a->frame;
         if(pos)
                 p = &pos->anext;
+
         f->anext = *p;
         *p = f;
 
@@ -118,10 +122,11 @@ resize_frame(Frame *f, XRectangle *r) {
                 if(c->fullscreen) {
                         f->crect.width = screen->rect.width;
                         f->crect.height = screen->rect.height;
+
                         f->rect = f->crect;
- client2frame(&f->rect);
                         f->rect.x = -def.border;
                         f->rect.y = -labelh(&def.font);
+ client2frame(&f->rect);
                 }else
                         check_frame_constraints(&f->rect);
         }
diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/fs.c
--- a/cmd/wmii/fs.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/fs.c Thu Apr 05 17:30:50 2007 -0400
@@ -970,7 +970,8 @@ fs_freefid(Fid *f) {
 fs_freefid(Fid *f) {
         FileId *id, *tid;
 
- for(id=f->aux; id; id = tid) {
+ tid = f->aux;
+ while((id = tid)) {
                 tid = id->next;
                 free_file(id);
         }
diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/main.c Thu Apr 05 17:30:50 2007 -0400
@@ -268,6 +268,18 @@ init_screen(WMScreen *screen) {
                         &mask);
 }
 
+struct {
+ uchar rcode, ecode;
+} itab[] = {
+ { 0, BadWindow },
+ { X_SetInputFocus, BadMatch },
+ { X_PolyText8, BadDrawable },
+ { X_PolyFillRectangle, BadDrawable },
+ { X_PolySegment, BadDrawable },
+ { X_ConfigureWindow, BadMatch },
+ { X_GrabKey, BadAccess },
+};
+
 /*
  * There's no way to check accesses to destroyed windows, thus
  * those cases are ignored (especially on UnmapNotify's).
@@ -276,26 +288,18 @@ init_screen(WMScreen *screen) {
  */
 int
 wmii_error_handler(Display *dpy, XErrorEvent *error) {
+ int i;
+
         if(check_other_wm)
                 fatal("another window manager is already running");
 
- if(error->error_code == BadWindow
- ||(error->request_code == X_SetInputFocus
- && error->error_code == BadMatch)
- ||(error->request_code == X_PolyText8
- && error->error_code == BadDrawable)
- ||(error->request_code == X_PolyFillRectangle
- && error->error_code == BadDrawable)
- ||(error->request_code == X_PolySegment
- && error->error_code == BadDrawable)
- ||(error->request_code == X_ConfigureWindow
- && error->error_code == BadMatch)
- ||(error->request_code == X_GrabKey
- && error->error_code == BadAccess))
- return 0;
-
- fprintf(stderr, "wmii: fatal error: Xrequest code=%d, Xerror code=%d\n",
- error->request_code, error->error_code);
+ for(i = 0; i < nelem(itab); i++)
+ if((itab[i].rcode == 0 || itab[i].rcode == error->request_code)
+ &&(itab[i].ecode == 0 || itab[i].ecode == error->error_code))
+ return 0;
+
+ fprintf(stderr, "%s: fatal error: Xrequest code=%d, Xerror code=%d\n",
+ argv0, error->request_code, error->error_code);
         return x_error_handler(blz.dpy, error); /* calls exit() */
 }
 
@@ -407,7 +411,7 @@ spawn_command(const char *cmd) {
         default:
                 waitpid(pid, &status, 0);
                 /* if(status != 0)
- exit(1); /* Error already printed */
+ exit(1); */
                 break;
         }
 }
diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/mouse.c Thu Apr 05 17:30:50 2007 -0400
@@ -182,7 +182,8 @@ find_droppoint(Frame *frame, int x, int
 find_droppoint(Frame *frame, int x, int y, XRectangle *rect, Bool do_move) {
         View *v;
         Area *a, *a_prev;
- Frame *f, *f_close;
+ Frame *f, *f_prev;
+ Bool before;
 
         v = frame->view;
         rect->y = 0;
@@ -220,21 +221,22 @@ find_droppoint(Frame *frame, int x, int
         rect->x = a->rect.x;
         rect->width = a->rect.width;
 
- f_close = nil;
+ f_prev = nil;
         for(f = a->frame; f; f = f->anext) {
                 if(y < f->rect.y)
                         break;
                 if(y < r_south(&f->rect))
                         break;
- f_close = f;
+ f_prev = f;
         }
         if(f == nil)
- f = f_close;
+ f = f_prev;
         if(y < (f->rect.y + labelh(&def.font))) {
+ before = True;
                 rect->y = f->rect.y;
                 rect->height = 2;
- if(f_close) {
- rect->y = r_south(&f_close->rect);
+ if(f_prev) {
+ rect->y = r_south(&f_prev->rect);
                         rect->height = f->rect.y - rect->y;
                 }
                 if(do_move)
@@ -242,6 +244,7 @@ find_droppoint(Frame *frame, int x, int
                 return;
         }
         if(y > r_south(&f->rect) - labelh(&def.font)) {
+ before = False;
                 rect->y = r_south(&f->rect);
                 rect->height = (screen->rect.height - labelh(&def.font) - rect->y);
                 if(f->anext)
@@ -255,6 +258,7 @@ find_droppoint(Frame *frame, int x, int
         if(do_move) {
                 swap_frames(frame, f);
                 focus(frame->client, False);
+ focus_view(screen, f->view);
         }
         return;
 
@@ -264,7 +268,7 @@ do_move:
         if(a != frame->area)
                 send_to_area(a, frame);
         remove_frame(frame);
- insert_frame(f, frame, False);
+ insert_frame(f, frame, before);
         arrange_column(f->area, False);
         focus(frame->client, True);
 }
@@ -324,7 +328,7 @@ do_managed_move(Client *c) {
 }
 
 void
-do_mouse_resize(Client *c, Bool grabbox, BlitzAlign align) {
+do_mouse_resize(Client *c, Bool opaque, BlitzAlign align) {
         BlitzAlign grav;
         Window dummy;
         Cursor cur;
@@ -341,7 +345,7 @@ do_mouse_resize(Client *c, Bool grabbox,
         origin = frect = f->rect;
         cur = cursor_of_quad(align);
         if(floating) {
- rects = rects_of_view(f->area->view, &num, (grabbox ? c->frame : nil));
+ rects = rects_of_view(f->area->view, &num, (opaque ? c->frame : nil));
                 snap = screen->rect.height / 66;
         }else{
                 rects = nil;
@@ -349,7 +353,7 @@ do_mouse_resize(Client *c, Bool grabbox,
         }
 
         if(align == CENTER) {
- if(!grabbox)
+ if(!opaque)
                         cur = cursor[CurInvisible];
                 if(!floating) {
                         do_managed_move(c);
@@ -383,20 +387,39 @@ do_mouse_resize(Client *c, Bool grabbox,
                 if(align&SOUTH) dy += hr_y;
                 if(align&EAST) dx += hr_x;
                 if(align&WEST) dx -= hr_x;
- XTranslateCoordinates(blz.dpy, c->framewin, blz.root, dx, dy,
- &pt_x, &pt_y, &dummy);
- XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, pt_x, pt_y);
- }
- else if(!grabbox) {
+
+ XTranslateCoordinates(blz.dpy,
+ /* src_w */ c->framewin,
+ /* dst w */ blz.root,
+ /* src x,y */ dx, dy,
+ /* dest x,y */ &pt_x, &pt_y,
+ /* child */ &dummy
+ );
+ XWarpPointer(blz.dpy,
+ /* src_w */ None,
+ /* dest_w */ blz.root,
+ /* src_rect */ 0, 0, 0, 0,
+ /* target */ pt_x, pt_y
+ );
+ }
+ else if(f->client->fullscreen)
+ return;
+ else if(!opaque) {
                 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);
+
+ XWarpPointer(blz.dpy,
+ /* src_w */ None,
+ /* dest_w */ blz.root,
+ /* src_rect */ 0, 0, 0, 0,
+ /* target */ hr_x, hr_y
+ );
                 flushevents(PointerMotionMask, False);
         }
 
 
         XSync(blz.dpy, False);
- if(!grabbox) {
+ if(!opaque) {
                 XGrabServer(blz.dpy);
                 draw_xor_border(&frect);
         }else
@@ -406,7 +429,7 @@ do_mouse_resize(Client *c, Bool grabbox,
                 XMaskEvent(blz.dpy, MouseMask | ExposureMask, &ev);
                 switch (ev.type) {
                 case ButtonRelease:
- if(!grabbox)
+ if(!opaque)
                                 draw_xor_border(&frect);
 
                         if(!floating)
@@ -414,20 +437,29 @@ do_mouse_resize(Client *c, Bool grabbox,
                         else
                                 resize_client(c, &frect);
 
- if(!grabbox) {
+ if(!opaque) {
                                 if(align != CENTER)
- XTranslateCoordinates(blz.dpy, c->framewin, blz.root,
- (frect.width * rx), (frect.height * ry),
- &pt_x, &pt_y, &dummy);
+ XTranslateCoordinates(blz.dpy,
+ /* src_w */ c->framewin,
+ /* dst w */ blz.root,
+ /* src_x */ (frect.width * rx),
+ /* src_y */ (frect.height * ry),
+ /* dest x,y */ &pt_x, &pt_y,
+ /* child */ &dummy
+ );
                                 if(pt_y > screen->brect.y)
                                         pt_y = screen->brect.y - 1;
- XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, pt_x, pt_y);
+ XWarpPointer(blz.dpy,
+ /* src_w */ None,
+ /* dest_w */ blz.root,
+ /* src_rect */ 0, 0, 0, 0,
+ /* target */ pt_x, pt_y
+ );
                                 XUngrabServer(blz.dpy);
                         }else
                                 map_client(c);
 
- if(rects)
- free(rects);
+ free(rects);
 
                         XUngrabPointer(blz.dpy, CurrentTime);
                         XSync(blz.dpy, False);
@@ -437,10 +469,15 @@ do_mouse_resize(Client *c, Bool grabbox,
                         dx = ev.xmotion.x_root;
                         dy = ev.xmotion.y_root;
 
- if(align == CENTER && !grabbox) {
+ if(align == CENTER && !opaque) {
                                 if(dx == hr_x && dy == hr_y)
                                         continue;
- XWarpPointer(blz.dpy, None, blz.root, 0, 0, 0, 0, hr_x, hr_y);
+ XWarpPointer(blz.dpy,
+ /* src_w */ None,
+ /* dest_w */ blz.root,
+ /* src_rect */ 0, 0, 0, 0,
+ /* target */ hr_x, hr_y
+ );
                                 dx -= hr_x;
                                 dy -= hr_y;
                         }else{
@@ -462,7 +499,7 @@ do_mouse_resize(Client *c, Bool grabbox,
 
                         apply_sizehints(c, &frect, floating, True, grav);
 
- if(grabbox) {
+ if(opaque) {
                                 XMoveWindow(blz.dpy, c->framewin, frect.x, frect.y);
                                 XSync(blz.dpy, False);
                         } else {
diff -r 3987c159a919 -r 2d8d76d19163 cmd/wmii/view.c
--- a/cmd/wmii/view.c Thu Apr 05 14:15:15 2007 -0400
+++ b/cmd/wmii/view.c Thu Apr 05 17:30:50 2007 -0400
@@ -166,12 +166,12 @@ attach_to_view(View *v, Frame *f) {
 
 void
 restack_view(View *v) {
- Area *a;
- Frame *f;
- Client *c;
- uint n, i;
         static Window *wins = nil;
         static uint winssz = 0;
+ Area *a;
+ Frame *f;
+ Client *c;
+ uint n, i, fs;
         
         if(v != screen->sel)
                 return;
@@ -188,13 +188,14 @@ restack_view(View *v) {
                 wins = erealloc(wins, sizeof(Window) * winssz);
         }
 
- for(f=v->area->stack; f; f=f->snext)
+ fs = 0;
+ for(f=v->area->stack; f; f=f->snext) {
+ wins[n++] = f->client->framewin;
                 if(f->client->fullscreen)
- wins[n++] = f->client->framewin;
- wins[n++] = screen->barwin;
- for(f=v->area->stack; f; f=f->snext)
- if(!f->client->fullscreen)
- wins[n++] = f->client->framewin;
+ fs++;
+ }
+ if(fs == 0)
+ wins[n++] = screen->barwin;
         for(a=v->area->next; a; a=a->next) {
                 if(a->frame) {
                         wins[n++] = a->sel->client->framewin;
Received on Thu Apr 05 2007 - 23:33:30 UTC

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