This diff adds a new command, hmaximize, that maximizes the current
window horizontally.  I find it useful when lines displayed by
commands are longer than my xterm; this way I can quickly maximize
horizontally and get the whole picture without lines wrapping.

Comments?

Index: calmwm.h
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.2
retrieving revision 1.2.14.4
diff -u -p -r1.2 -r1.2.14.4
--- calmwm.h    27 Jun 2009 08:20:23 -0000      1.2
+++ calmwm.h    20 Aug 2009 11:23:39 -0000      1.2.14.4
@@ -96,6 +96,8 @@ TAILQ_HEAD(screen_ctx_q, screen_ctx);
 #define CLIENT_MAXIMIZED       0x08
 #define CLIENT_DOVMAXIMIZE     0x10
 #define CLIENT_VMAXIMIZED      0x20
+#define CLIENT_DOHMAXIMIZE     0x40
+#define CLIENT_HMAXIMIZED      0x80
 
 #define CLIENT_HIGHLIGHT_GROUP         1
 #define CLIENT_HIGHLIGHT_UNGROUP       2
@@ -347,6 +349,7 @@ void                         client_ptrsave(struct 
client_ctx
 void                    client_draw_border(struct client_ctx *);
 void                    client_maximize(struct client_ctx *);
 void                    client_vertmaximize(struct client_ctx *);
+void                    client_horizmaximize(struct client_ctx *);
 void                    client_map(struct client_ctx *);
 void                    client_mtf(struct client_ctx *);
 struct client_ctx      *client_cycle(int);
@@ -434,6 +437,8 @@ void                         
kbfunc_client_movetogroup(struct
 void                    kbfunc_client_maximize(struct client_ctx *,
                             union arg *);
 void                    kbfunc_client_vmaximize(struct client_ctx *,
+                            union arg *);
+void                    kbfunc_client_hmaximize(struct client_ctx *,
                             union arg *);
 void                    kbfunc_reload(struct client_ctx *, union arg *);
 void                    kbfunc_quit_wm(struct client_ctx *, union arg *);
Index: client.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/client.c,v
retrieving revision 1.2
retrieving revision 1.2.12.5
diff -u -p -r1.2 -r1.2.12.5
--- client.c    27 Jun 2009 08:20:23 -0000      1.2
+++ client.c    20 Aug 2009 11:33:48 -0000      1.2.12.5
@@ -300,10 +300,43 @@ calc:
 }
 
 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))
+                       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)
 {
-       if (cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED))
-               cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED);
+       if (cc->flags & (CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED
+           | CLIENT_HMAXIMIZED))
+               cc->flags &= ~(CLIENT_MAXIMIZED | CLIENT_VMAXIMIZED
+                   | CLIENT_HMAXIMIZED);
 
        if (cc->flags & CLIENT_DOMAXIMIZE) {
                cc->flags &= ~CLIENT_DOMAXIMIZE;
@@ -311,6 +344,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,
Index: conf.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/conf.c,v
retrieving revision 1.2
retrieving revision 1.2.14.1
diff -u -p -r1.2 -r1.2.14.1
--- conf.c      27 Jun 2009 08:20:23 -0000      1.2
+++ conf.c      20 Aug 2009 11:18:02 -0000      1.2.14.1
@@ -338,6 +338,7 @@ static struct {
        { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
        { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
        { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
+       { "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} },
        { "reload", kbfunc_reload, 0, {0} },
        { "quit", kbfunc_quit_wm, 0, {0} },
        { "exec", kbfunc_exec, 0, {.i = CWM_EXEC_PROGRAM} },
Index: cwmrc.5
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.8.1
diff -u -p -r1.1.1.1 -r1.1.1.1.8.1
--- cwmrc.5     24 Jun 2009 12:35:33 -0000      1.1.1.1
+++ cwmrc.5     20 Aug 2009 11:45:14 -0000      1.1.1.1.8.1
@@ -292,6 +292,8 @@ Label current window.
 Maximize current window full-screen.
 .It vmaximize
 Maximize current window vertically.
+.It hmaximize
+Maximize current window horizontally.
 .It moveup
 Move window
 .Ar moveamount
Index: kbfunc.c
===================================================================
RCS file: /cvs/OpenBSD/xenocara/app/cwm/kbfunc.c,v
retrieving revision 1.1.1.1
retrieving revision 1.1.1.1.4.1
diff -u -p -r1.1.1.1 -r1.1.1.1.4.1
--- kbfunc.c    24 Jun 2009 12:35:33 -0000      1.1.1.1
+++ kbfunc.c    20 Aug 2009 11:18:02 -0000      1.1.1.1.4.1
@@ -482,6 +482,12 @@ kbfunc_client_vmaximize(struct client_ct
 }
 
 void
+kbfunc_client_hmaximize(struct client_ctx *cc, union arg *arg)
+{
+       client_horizmaximize(cc);
+}
+
+void
 kbfunc_quit_wm(struct client_ctx *cc, union arg *arg)
 {
        _xev_quit = 1;

Reply via email to