diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/manage.c | 55 |
2 files changed, 39 insertions, 21 deletions
@@ -1,3 +1,8 @@ +2006-04-10 Bernhard R. Link <brlink@debian.org> + + * src/manage.c (maximize_transient,maximize_normal): + avoid divide by zero when resize increment is 0. + 2006-03-07 Shawn Betts <sabetts@vcn.bc.ca> * src/main.c (clean_up): properly free rp_frame_numset 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)); |