Mercurial > pidgin
diff console/libgnt/gntwidget.c @ 14292:c111a7e718d0
[gaim-migrate @ 16982]
Make sure new windows fit in the screen.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 22 Aug 2006 17:02:20 +0000 |
parents | a0b1ab181316 |
children | 6e2e9e84b99d |
line wrap: on
line diff
--- a/console/libgnt/gntwidget.c Tue Aug 22 16:43:19 2006 +0000 +++ b/console/libgnt/gntwidget.c Tue Aug 22 17:02:20 2006 +0000 @@ -331,6 +331,30 @@ widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow, widget->priv.y, widget->priv.x); + if (widget->window == NULL) /* The size is probably too large for the screen */ + { + int x = widget->priv.x, y = widget->priv.y; + int w = widget->priv.width + shadow, h = widget->priv.height + shadow; + int maxx, maxy; /* Max-X is cool */ + + getmaxyx(stdscr, maxy, maxx); + + if (x + w >= maxx) + x = MAX(0, maxx - w); + if (y + h >= maxy) + y = MAX(0, maxy - h); + + w = MIN(w, maxx); + h = MIN(h, maxy); + + widget->priv.x = x; + widget->priv.y = y; + widget->priv.width = w - shadow; + widget->priv.height = h - shadow; + + widget->window = newwin(widget->priv.height + shadow, widget->priv.width + shadow, + widget->priv.y, widget->priv.x); + } init_widget(widget); }