wmii

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

commit 207aac30fe4ffd3e96f31f0e2d752a5ac66ea28e
parent f22d6445dd79e441b896ae28493a48577765ff7c
Author: Kris Maglione <bsdaemon@wmii.de>
Date:   Fri, 30 Jun 2006 20:16:49 -0400

Prevent floating windows from appearing off screen or covering the bar.


Diffstat:
cmd/wm/client.c | 27+++++++++++++++++++++------
cmd/wm/view.c | 2+-
2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -516,6 +516,7 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall) { Frame *f = c->sel; Bool floating = f->area->floating; + unsigned int max_height; BlitzAlign stickycorner = 0; if(f->rect.x != r->x && f->rect.x + f->rect.width == r->x + r->width) @@ -532,13 +533,27 @@ resize_client(Client *c, XRectangle *r, Bool ignore_xcall) if((f->area->mode != Colstack) || (f->area->sel == f)) match_sizehints(c, &c->sel->rect, floating, stickycorner); + max_height = screen->rect.height - height_of_bar(); if(!ignore_xcall) { - if(floating && - (c->rect.width >= screen->rect.width) && - (c->rect.height >= screen->rect.height)) - { - f->rect.x = -def.border; - f->rect.y = -height_of_bar(); + if(floating) { + if((c->rect.width == screen->rect.width) && + (c->rect.height == screen->rect.height)) { + f->rect.x = -def.border; + f->rect.y = -height_of_bar(); + }else{ + if(f->rect.height > max_height) + f->rect.height = max_height; + if(f->rect.width > screen->rect.width) + f->rect.width = screen->rect.width; + if(f->rect.x + f->rect.width > screen->rect.width) + f->rect.x = screen->rect.width - f->rect.width; + if(f->rect.y + f->rect.height > max_height) + f->rect.y = max_height - f->rect.height; + if(f->rect.x < 0) + f->rect.x = 0; + if(f->rect.y < 0) + f->rect.y = 0; + } } if(f->area->view == screen->sel) XMoveResizeWindow(blz.display, c->framewin, f->rect.x, diff --git a/cmd/wm/view.c b/cmd/wm/view.c @@ -296,7 +296,7 @@ view_index(View *v) { len = BUFFER_SIZE; buf_i = 0; - for((a = v->area), (a_i = 0); a; (a=a->next), (a_i++)) { + for((a = v->area), (a_i = 0); a && len > 0; (a=a->next), (a_i++)) { if(a->floating) n = snprintf(&buffer[buf_i], len, "# ~ %d %d\n", a->rect.width, a->rect.height);