diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/manage.c | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/src/manage.c b/src/manage.c index 364c6c9..5955137 100644 --- a/src/manage.c +++ b/src/manage.c @@ -649,17 +649,24 @@ maximize_transient (rp_window *win) int amount; int delta; - amount = maxx - win->width; - delta = amount % win->hints->width_inc; - amount -= delta; - if (amount < 0 && delta) amount -= win->hints->width_inc; - maxx = amount + win->width; + /* Avoid a divide by zero if width/height_inc is 0. */ + if (win->hints->width_inc) + { + amount = maxx - win->width; + delta = amount % win->hints->width_inc; + amount -= delta; + if (amount < 0 && delta) amount -= win->hints->width_inc; + maxx = amount + win->width; + } - amount = maxy - win->height; - delta = amount % win->hints->height_inc; - amount -= delta; - if (amount < 0 && delta) amount -= win->hints->height_inc; - maxy = amount + win->height; + if (win->hints->height_inc) + { + amount = maxy - win->height; + delta = amount % win->hints->height_inc; + amount -= delta; + if (amount < 0 && delta) amount -= win->hints->height_inc; + maxy = amount + win->height; + } } PRINT_DEBUG (("maxsize: %d %d\n", maxx, maxy)); @@ -733,17 +740,23 @@ maximize_normal (rp_window *win) int amount; int delta; - amount = maxx - win->width; - delta = amount % win->hints->width_inc; - if (amount < 0 && delta) amount -= win->hints->width_inc; - amount -= delta; - maxx = amount + win->width; - - amount = maxy - win->height; - delta = amount % win->hints->height_inc; - if (amount < 0 && delta) amount -= win->hints->height_inc; - amount -= delta; - maxy = amount + win->height; + if (win->hints->width_inc) + { + amount = maxx - win->width; + delta = amount % win->hints->width_inc; + if (amount < 0 && delta) amount -= win->hints->width_inc; + amount -= delta; + maxx = amount + win->width; + } + + if (win->hints->height_inc) + { + amount = maxy - win->height; + delta = amount % win->hints->height_inc; + if (amount < 0 && delta) amount -= win->hints->height_inc; + amount -= delta; + maxy = amount + win->height; + } } PRINT_DEBUG (("maxsize: %d %d\n", maxx, maxy)); |