wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit a6893551ea9fda1bd980fcbd989ae8cf24cbcaf2
parent 8b38c3cbd72d7cb5afd4b0b88005e5c23396b521
Author: Kris Maglione <jg@suckless.org>
Date:   Thu,  5 Apr 2007 17:30:50 -0400

Fixed some bugs with managed moves/swaps. Some cleanup elsewhere.

Diffstat:
cmd/wmii/area.c | 1+
cmd/wmii/frame.c | 9+++++++--
cmd/wmii/fs.c | 3++-
cmd/wmii/main.c | 38+++++++++++++++++++++-----------------
cmd/wmii/mouse.c | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
cmd/wmii/view.c | 19++++++++++---------
6 files changed, 105 insertions(+), 56 deletions(-)

diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c @@ -158,6 +158,7 @@ attach_to_area(Area *a, Frame *f, Bool send) { focus_frame(f, False); resize_frame(f, &f->rect); restack_view(a->view); + if(!a->floating) arrange_column(a, False); else diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -48,16 +48,20 @@ remove_frame(Frame *f) { 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 --git a/cmd/wmii/fs.c b/cmd/wmii/fs.c @@ -970,7 +970,8 @@ void 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 --git a/cmd/wmii/main.c b/cmd/wmii/main.c @@ -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; + 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, "wmii: fatal error: Xrequest code=%d, Xerror code=%d\n", - error->request_code, error->error_code); + 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 --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -182,7 +182,8 @@ static void 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 y, XRectangle *rect, Bool do_move) { 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 y, XRectangle *rect, Bool do_move) { 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 y, XRectangle *rect, Bool do_move) { 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, BlitzAlign align) { 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, BlitzAlign align) { } 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, BlitzAlign align) { 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); + + 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(!grabbox) { + 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, BlitzAlign align) { 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, BlitzAlign align) { 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, BlitzAlign align) { 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, BlitzAlign align) { 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 --git a/cmd/wmii/view.c b/cmd/wmii/view.c @@ -166,12 +166,12 @@ attach_to_view(View *v, Frame *f) { void restack_view(View *v) { + static Window *wins = nil; + static uint winssz = 0; Area *a; Frame *f; Client *c; - uint n, i; - static Window *wins = nil; - static uint winssz = 0; + 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;