Fix a bunch of bugs. No more Xored moves/resizes.

This commit is contained in:
Kris Maglione 2007-04-17 21:34:36 -04:00
parent 4850457d6d
commit 957fa03c4e
8 changed files with 72 additions and 106 deletions

View File

@ -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;
ap = v->revert;
else
a = v->area->next;
ap = v->area->next;
}
else if(!strcmp(arg, "left")) {
if(a->floating)

View File

@ -49,22 +49,17 @@ create_client(XWindow w, XWindowAttributes *wa) {
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,16 +89,16 @@ 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);

View File

@ -140,7 +140,7 @@ void restack_view(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);

View File

@ -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;
}
@ -83,6 +85,27 @@ insert_frame(Frame *pos, Frame *f, Bool before) {
}
}
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
frame2client(Frame *f, Rectangle r) {
if(f->area->floating) {
@ -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 @@ draw_frames() {
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);
}

View File

@ -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;

View File

@ -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
@ -454,28 +454,6 @@ done:
destroywindow(cwin);
}
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 @@ void
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, Align align) {
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, Align align) {
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, Align align) {
/ 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, Align align) {
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, Align align) {
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, Align align) {
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);

View File

@ -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;

View File

@ -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);
}