aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroga2009-08-24 23:54:41 +0000
committeroga2009-08-24 23:54:41 +0000
commitc93aabe260cae31e757caa99381b1e8a0e1efddc (patch)
tree7c002e0038cb2dd16713ffa0e6af4ae2a5d0d5aa
parent796a52c20656342eabaf923d6141d83883689d15 (diff)
downloadcwm-c93aabe260cae31e757caa99381b1e8a0e1efddc.tar.gz
Add a keybinding to allow horizontal maximisation of a window (CMS-enter).
based on a diff by Thomas Pfaff; thanks! ok okan@
Diffstat (limited to '')
-rw-r--r--calmwm.h7
-rw-r--r--client.c43
-rw-r--r--conf.c4
-rw-r--r--cwm.16
-rw-r--r--cwmrc.56
-rw-r--r--kbfunc.c8
6 files changed, 63 insertions, 11 deletions
diff --git a/calmwm.h b/calmwm.h
index b908622..ac32b56 100644
--- a/calmwm.h
+++ b/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.
*
- * $Id: calmwm.h,v 1.96 2009/08/24 23:49:04 okan Exp $
+ * $Id: calmwm.h,v 1.97 2009/08/24 23:54:41 oga Exp $
*/
#ifndef _CALMWM_H_
@@ -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);
@@ -436,6 +439,8 @@ 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 *);
void kbfunc_moveresize(struct client_ctx *, union arg *);
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;
@@ -286,9 +286,41 @@ 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 | 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,
diff --git a/conf.c b/conf.c
index 91df027..aa6cc14 100644
--- a/conf.c
+++ b/conf.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: conf.c,v 1.66 2009/06/26 12:21:58 okan Exp $
+ * $Id: conf.c,v 1.67 2009/08/24 23:54:41 oga Exp $
*/
#include "headers.h"
@@ -135,6 +135,7 @@ conf_init(struct conf *c)
conf_bindname(c, "CM-g", "grouptoggle");
conf_bindname(c, "CM-f", "maximize");
conf_bindname(c, "CM-equal", "vmaximize");
+ conf_bindname(c, "CMS-equal", "hmaximize");
conf_bindname(c, "CMS-r", "reload");
conf_bindname(c, "CMS-q", "quit");
@@ -338,6 +339,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} },
diff --git a/cwm.1 b/cwm.1
index f7b7a9c..842d5e1 100644
--- a/cwm.1
+++ b/cwm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwm.1,v 1.42 2009/06/19 10:43:49 sobrado Exp $
+.\" $OpenBSD: cwm.1,v 1.43 2009/08/24 23:54:41 oga Exp $
.\"
.\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 19 2009 $
+.Dd $Mdocdate: August 24 2009 $
.Dt CWM 1
.Os
.Sh NAME
@@ -92,6 +92,8 @@ Reverse cycle through active groups.
Toggle full-screen size of current window.
.It Ic CM-=
Toggle vertical maximization of current window.
+.It Ic CMS-=
+Toggle horizontal maximization of current window.
.It Ic M-?
Spawn
.Dq exec program
diff --git a/cwmrc.5 b/cwmrc.5
index 25cf080..e1f0740 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwmrc.5,v 1.27 2009/08/08 17:27:51 okan Exp $
+.\" $OpenBSD: cwmrc.5,v 1.28 2009/08/24 23:54:41 oga Exp $
.\"
.\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 8 2009 $
+.Dd $Mdocdate: August 24 2009 $
.Dt CWMRC 5
.Os
.Sh NAME
@@ -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
diff --git a/kbfunc.c b/kbfunc.c
index 505828e..a276406 100644
--- a/kbfunc.c
+++ b/kbfunc.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: kbfunc.c,v 1.40 2009/06/20 00:55:42 okan Exp $
+ * $Id: kbfunc.c,v 1.41 2009/08/24 23:54:41 oga Exp $
*/
#include <paths.h>
@@ -482,6 +482,12 @@ kbfunc_client_vmaximize(struct client_ctx *cc, union arg *arg)
}
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;