diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-09-04 16:59:32 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2011-09-04 16:59:32 +0000 |
commit | 92c2772596feaa261964cfaa831bc33f6f1a4e56 (patch) | |
tree | 6839fa279c3e4c73f421cda034e081223441e904 /app/cwm | |
parent | 9f77d95e5c03e4dda93084beb921fd19fd1ade3c (diff) |
Make flavours of maximisation additive.
i.e. horiz-max + vertmax = full maximisation. full - horiz = vertmax.
etc.
Martynas wrote something like this once, so I did okan, this version
seems to finally deal with the corner cases.
ok okan@.
Diffstat (limited to 'app/cwm')
-rw-r--r-- | app/cwm/calmwm.h | 12 | ||||
-rw-r--r-- | app/cwm/client.c | 160 |
2 files changed, 101 insertions, 71 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 053138ed7..c67e6c9fc 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -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. * - * $OpenBSD: calmwm.h,v 1.139 2011/09/03 09:42:33 okan Exp $ + * $OpenBSD: calmwm.h,v 1.140 2011/09/04 16:59:31 oga Exp $ */ #ifndef _CALMWM_H_ @@ -143,10 +143,12 @@ struct client_ctx { int xproto; #define CLIENT_HIDDEN 0x0001 #define CLIENT_IGNORE 0x0002 -#define CLIENT_MAXIMIZED 0x0004 -#define CLIENT_VMAXIMIZED 0x0008 -#define CLIENT_HMAXIMIZED 0x0010 -#define CLIENT_FREEZE 0x0020 +#define CLIENT_VMAXIMIZED 0x0004 +#define CLIENT_HMAXIMIZED 0x0008 +#define CLIENT_FREEZE 0x0010 + +#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) +#define CLIENT_MAXIMIZED (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED) int flags; int state; int active; diff --git a/app/cwm/client.c b/app/cwm/client.c index 23908c5db..89af2ea3f 100644 --- a/app/cwm/client.c +++ b/app/cwm/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. * - * $OpenBSD: client.c,v 1.88 2011/09/03 09:42:33 okan Exp $ + * $OpenBSD: client.c,v 1.89 2011/09/04 16:59:31 oga Exp $ */ #include <sys/param.h> @@ -281,39 +281,46 @@ client_maximize(struct client_ctx *cc) if (cc->flags & CLIENT_FREEZE) return; - if (cc->flags & CLIENT_MAXIMIZED) { + if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) { + cc->flags &= ~CLIENT_MAXIMIZED; cc->geom = cc->savegeom; cc->bwidth = Conf.bwidth; - cc->flags &= ~CLIENT_MAXIMIZED; - } else { - if (!(cc->flags & (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED))) - cc->savegeom = cc->geom; - if (HasXinerama) { - XineramaScreenInfo *xine; - /* - * pick screen that the middle of the window is on. - * that's probably more fair than if just the origin of - * a window is poking over a boundary - */ - xine = screen_find_xinerama(sc, - cc->geom.x + cc->geom.width / 2, - cc->geom.y + cc->geom.height / 2); - if (xine == NULL) - goto calc; - x_org = xine->x_org; - y_org = xine->y_org; - xmax = xine->width; - ymax = xine->height; - } -calc: - cc->geom.x = x_org + sc->gap.left; - cc->geom.y = y_org + sc->gap.top; - cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom); - cc->geom.width = xmax - (sc->gap.left + sc->gap.right); - cc->bwidth = 0; - cc->flags |= CLIENT_MAXIMIZED; + goto resize; + } + + if ((cc->flags & CLIENT_VMAXIMIZED) == 0) { + cc->savegeom.height = cc->geom.height; + cc->savegeom.y = cc->geom.y; } + if ((cc->flags & CLIENT_HMAXIMIZED) == 0) { + cc->savegeom.width = cc->geom.width; + cc->savegeom.x = cc->geom.x; + } + + if (HasXinerama) { + XineramaScreenInfo *xine; + /* * that's probably more fair than if just the origin of * a window is poking over a boundary + */ + xine = screen_find_xinerama(sc, + cc->geom.x + cc->geom.width / 2, + cc->geom.y + cc->geom.height / 2); + if (xine == NULL) + goto calc; + x_org = xine->x_org; + y_org = xine->y_org; + xmax = xine->width; + ymax = xine->height; + } +calc: + cc->geom.x = x_org + sc->gap.left; + cc->geom.y = y_org + sc->gap.top; + cc->geom.height = ymax - (sc->gap.top + sc->gap.bottom); + cc->geom.width = xmax - (sc->gap.left + sc->gap.right); + cc->bwidth = 0; + cc->flags |= CLIENT_MAXIMIZED; + +resize: client_resize(cc); } @@ -330,27 +337,38 @@ client_vertmaximize(struct client_ctx *cc) cc->geom.y = cc->savegeom.y; cc->geom.height = cc->savegeom.height; cc->bwidth = Conf.bwidth; + if (cc->flags & CLIENT_HMAXIMIZED) + cc->geom.width -= cc->bwidth * 2; cc->flags &= ~CLIENT_VMAXIMIZED; - } else { - if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_HMAXIMIZED))) - cc->savegeom = cc->geom; - if (HasXinerama) { - XineramaScreenInfo *xine; - xine = screen_find_xinerama(sc, - cc->geom.x + cc->geom.width / 2, - cc->geom.y + cc->geom.height / 2); - if (xine == NULL) - goto calc; - y_org = xine->y_org; - ymax = xine->height; - } -calc: - cc->geom.y = y_org + sc->gap.top; - cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top + - sc->gap.bottom); - cc->flags |= CLIENT_VMAXIMIZED; + goto resize; } + cc->savegeom.y = cc->geom.y; + cc->savegeom.height = cc->geom.height; + + /* if this will make us fully maximized then remove boundary */ + if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) { + cc->geom.width += Conf.bwidth * 2; + cc->bwidth = 0; + } + + if (HasXinerama) { + XineramaScreenInfo *xine; + xine = screen_find_xinerama(sc, + cc->geom.x + cc->geom.width / 2, + cc->geom.y + cc->geom.height / 2); + if (xine == NULL) + goto calc; + y_org = xine->y_org; + ymax = xine->height; + } +calc: + cc->geom.y = y_org + sc->gap.top; + cc->geom.height = ymax - (cc->bwidth * 2) - (sc->gap.top + + sc->gap.bottom); + cc->flags |= CLIENT_VMAXIMIZED; + +resize: client_resize(cc); } @@ -367,27 +385,37 @@ client_horizmaximize(struct client_ctx *cc) cc->geom.x = cc->savegeom.x; cc->geom.width = cc->savegeom.width; cc->bwidth = Conf.bwidth; + if (cc->flags & CLIENT_VMAXIMIZED) + cc->geom.height -= cc->bwidth * 2; cc->flags &= ~CLIENT_HMAXIMIZED; - } else { - if (!(cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED))) - cc->savegeom = cc->geom; - if (HasXinerama) { - XineramaScreenInfo *xine; - xine = screen_find_xinerama(sc, - 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 + sc->gap.left; - cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left + - sc->gap.right); - cc->flags |= CLIENT_HMAXIMIZED; + goto resize; + } + + cc->savegeom.x = cc->geom.x; + cc->savegeom.width = cc->geom.width; + + if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) { + cc->geom.height += cc->bwidth * 2; + cc->bwidth = 0; + } + + if (HasXinerama) { + XineramaScreenInfo *xine; + xine = screen_find_xinerama(sc, + 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 + sc->gap.left; + cc->geom.width = xmax - (cc->bwidth * 2) - (sc->gap.left + + sc->gap.right); + cc->flags |= CLIENT_HMAXIMIZED; +resize: client_resize(cc); } |