wmii

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

commit 18a9e0c421bb86a11fe628072659c11fc40a1910
parent b2d98ca9b2b2e17cce78e1228727e14c1f1e63f6
Author: Kris Maglione <jg@suckless.org>
Date:   Tue, 14 Oct 2008 02:13:28 -0400

Fix floating window constraints for Xinerama

Diffstat:
cmd/menu/main.c | 4++--
cmd/wmii/frame.c | 44++++++++++++++++++++++++++++++++------------
2 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/cmd/menu/main.c b/cmd/menu/main.c @@ -25,7 +25,7 @@ static char* (*find)(const char*, const char*); static void usage(void) { - fatal("usage: wimenu ...\n"); + fatal("usage: wimenu -i [-h <history>] [-a <address>]\n"); } static int @@ -271,7 +271,7 @@ main(int argc, char *argv[]) { if(histfile) { inbuf = Bopen(histfile, OREAD); if(!inbuf) - fatal("Can't open histfile %q: %r", histfile); + fatal("Can't open history file %q: %r", histfile); item = populate_list(inbuf, true); if(item) { link(item->prev, &hist); diff --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c @@ -637,22 +637,42 @@ frame_delta_h(void) { Rectangle constrain(Rectangle r) { - Rectangle sr; + WMScreen *s, *bestx, *besty; + Rectangle isect; Point p; + int i, nbestx, nbesty; - sr = screen->sel->floating->r; - - 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); + /* Find the screen that this intersects most with + * (or doesn't intersect least with), and then make + * sure that it overlaps that screen, in the opposite + * direction. + */ + SET(nbestx); + SET(nbesty); + SET(s); + + bestx = nil; + besty = nil; + for(i=0; i < nscreens; i++) { + s = &screens[i]; + isect = rect_intersection(r, s->r); + if(!bestx || Dx(isect) > nbestx && Dy(isect) > 0) { + bestx = s; + nbestx = Dx(isect); + } + if(!besty || Dy(isect) > nbesty && Dy(isect) > 0) { + besty = s; + nbesty = Dy(isect); + } + } - 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); + isect = insetrect(bestx->r, Dy(screen->brect)); + p.x -= min(r.max.x - isect.min.x, 0); + p.x -= max(r.min.x - isect.max.x, 0); + isect = insetrect(besty->r, Dy(screen->brect)); + p.y -= min(r.max.y - isect.min.y, 0); + p.y -= max(r.min.y - isect.max.y, 0); return rectaddpt(r, p); }