From c93aabe260cae31e757caa99381b1e8a0e1efddc Mon Sep 17 00:00:00 2001 From: oga Date: Mon, 24 Aug 2009 23:54:41 +0000 Subject: Add a keybinding to allow horizontal maximisation of a window (CMS-enter). based on a diff by Thomas Pfaff; thanks! ok okan@ --- client.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'client.c') diff --git a/client.c b/client.c index d2e3ead..b343164 100644 --- a/client.c +++ b/client.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $Id: client.c,v 1.60 2009/08/24 23:49:04 okan Exp $ + * $Id: client.c,v 1.61 2009/08/24 23:54:41 oga Exp $ */ #include "headers.h" @@ -224,7 +224,7 @@ client_maximize(struct client_ctx *cc) if (cc->flags & CLIENT_MAXIMIZED) { cc->geom = cc->savegeom; } else { - if (!(cc->flags & CLIENT_VMAXIMIZED)) + if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED))) cc->savegeom = cc->geom; if (HasXinerama) { XineramaScreenInfo *xine; @@ -263,7 +263,7 @@ client_vertmaximize(struct client_ctx *cc) if (cc->flags & CLIENT_VMAXIMIZED) { cc->geom = cc->savegeom; } else { - if (!(cc->flags & CLIENT_MAXIMIZED)) + if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED))) cc->savegeom = cc->geom; if (HasXinerama) { XineramaScreenInfo *xine; @@ -285,10 +285,42 @@ calc: client_resize(cc); } +void +client_horizmaximize(struct client_ctx *cc) +{ + struct screen_ctx *sc = CCTOSC(cc); + int x_org = 0, xmax = sc->xmax; + + if (cc->flags & CLIENT_HMAXIMIZED) { + cc->geom = cc->savegeom; + } else { + if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED))) + cc->savegeom = cc->geom; + if (HasXinerama) { + XineramaScreenInfo *xine; + xine = screen_find_xinerama(CCTOSC(cc), + cc->geom.x + cc->geom.width / 2, + cc->geom.y + cc->geom.height / 2); + if (xine == NULL) + goto calc; + x_org = xine->x_org; + xmax = xine->width; + } +calc: + cc->geom.x = x_org + Conf.gap_left; + cc->geom.width = xmax - (cc->bwidth * 2) - (Conf.gap_left + + Conf.gap_right); + cc->flags |= CLIENT_DOHMAXIMIZE; + } + + client_resize(cc); +} + void client_resize(struct client_ctx *cc) { - cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED); + cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED | + CLIENT_HMAXIMIZED); if (cc->flags & CLIENT_DOMAXIMIZE) { cc->flags &= ~CLIENT_DOMAXIMIZE; @@ -296,6 +328,9 @@ client_resize(struct client_ctx *cc) } else if (cc->flags & CLIENT_DOVMAXIMIZE) { cc->flags &= ~CLIENT_DOVMAXIMIZE; cc->flags |= CLIENT_VMAXIMIZED; + } else if (cc->flags & CLIENT_DOHMAXIMIZE) { + cc->flags &= ~CLIENT_DOHMAXIMIZE; + cc->flags |= CLIENT_HMAXIMIZED; } XMoveResizeWindow(X_Dpy, cc->win, cc->geom.x, -- cgit v1.2.3-2-gb3c3