From eaca92db50a59aca797f8bf112ac664e94d277a2 Mon Sep 17 00:00:00 2001 From: "Carlos R. Mafra" Date: Wed, 16 Sep 2009 21:16:57 +0200 Subject: [PATCH] Simplify wMaximizeWindow() a little bit Let's avoid checking the existence of a border every time we want to adjust the widths. So we'll always subtract the correction factor, which is zero in case the window has no border. --- src/actions.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/actions.c b/src/actions.c index 85412e87..9c81d3da 100644 --- a/src/actions.c +++ b/src/actions.c @@ -303,10 +303,18 @@ void wMaximizeWindow(WWindow * wwin, int directions) int new_x, new_y; unsigned int new_width, new_height, half_scr_width; WArea usableArea, totalArea; + Bool has_border = 1; + int adj_size; if (!IS_RESIZABLE(wwin)) return; + if (!HAS_BORDER(wwin)) + has_border = 0; + + /* the size to adjust the geometry */ + adj_size = FRAME_BORDER_WIDTH * 2 * has_border; + /* save old coordinates before we change the current values */ save_old_geometry(wwin); @@ -342,19 +350,13 @@ void wMaximizeWindow(WWindow * wwin, int directions) } if (directions & MAX_HORIZONTAL) { - new_width = usableArea.x2 - usableArea.x1; - if (HAS_BORDER(wwin)) - new_width -= FRAME_BORDER_WIDTH * 2; + new_width = usableArea.x2 - usableArea.x1 - adj_size; new_x = usableArea.x1; } else if (directions & MAX_LEFTHALF) { - new_width = half_scr_width; - if (HAS_BORDER(wwin)) - new_width -= FRAME_BORDER_WIDTH * 2; + new_width = half_scr_width - adj_size; new_x = usableArea.x1; } else if (directions & MAX_RIGHTHALF) { - new_width = half_scr_width; - if (HAS_BORDER(wwin)) - new_width -= FRAME_BORDER_WIDTH * 2; + new_width = half_scr_width - adj_size; new_x = usableArea.x1 + half_scr_width; } else { new_x = wwin->frame_x; @@ -362,9 +364,7 @@ void wMaximizeWindow(WWindow * wwin, int directions) } if (directions & MAX_VERTICAL) { - new_height = usableArea.y2 - usableArea.y1; - if (HAS_BORDER(wwin)) - new_height -= FRAME_BORDER_WIDTH * 2; + new_height = usableArea.y2 - usableArea.y1 - adj_size; new_y = usableArea.y1; if (WFLAGP(wwin, full_maximize)) { new_y -= wwin->frame->top_width;