diff --git a/src/actions.c b/src/actions.c index 11f09e53..a92bd07a 100644 --- a/src/actions.c +++ b/src/actions.c @@ -498,8 +498,14 @@ wMaximizeWindow(WWindow *wwin, int directions) } wWindowConstrainSize(wwin, &new_width, &new_height); + + wWindowCropSize(wwin, usableArea.x2-usableArea.x1, + usableArea.y2-usableArea.y1, + &new_width, &new_height); + wWindowConfigure(wwin, new_x, new_y, new_width, new_height); + #ifdef GNOME_STUFF wGNOMEUpdateClientStateHint(wwin, False); #endif diff --git a/src/window.c b/src/window.c index 2d30da43..e3019c65 100644 --- a/src/window.c +++ b/src/window.c @@ -1850,6 +1850,9 @@ wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) maxAX = wwin->normal_hints->max_aspect.x; maxAY = wwin->normal_hints->max_aspect.y; } + + baseW = wwin->normal_hints->base_width; + baseH = wwin->normal_hints->base_height; } if (width < minW) @@ -1905,7 +1908,7 @@ wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) width = (((width - minW) / winc) * winc) + minW; } - if (baseW != 0) { + if (baseH != 0) { height = (((height - baseH) / hinc) * hinc) + baseH; } else { height = (((height - minH) / hinc) * hinc) + minH; @@ -1919,6 +1922,29 @@ wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight) } +void +wWindowCropSize(WWindow *wwin, int maxW, int maxH, + int *width, int *height) +{ + int baseW = 0, baseH = 0; + int winc = 1, hinc = 1; + + if (wwin->normal_hints) { + baseW = wwin->normal_hints->base_width; + baseH = wwin->normal_hints->base_height; + + winc = wwin->normal_hints->width_inc; + hinc = wwin->normal_hints->height_inc; + } + + if (*width > maxW) + *width = maxW - (maxW - baseW) % winc; + + if (*height > maxH) + *height = maxH - (maxH - baseH) % hinc; +} + + void wWindowChangeWorkspace(WWindow *wwin, int workspace) { diff --git a/src/window.h b/src/window.h index 9030b72c..6fd37152 100644 --- a/src/window.h +++ b/src/window.h @@ -352,6 +352,8 @@ void wWindowUnfocus(WWindow *wwin); void wWindowUpdateName(WWindow *wwin, char *newTitle); void wWindowConstrainSize(WWindow *wwin, int *nwidth, int *nheight); +void wWindowCropSize(WWindow *wwin, int maxw, int maxh, + int *nwidth, int *nheight); void wWindowConfigure(WWindow *wwin, int req_x, int req_y, int req_width, int req_height);