summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2013-12-16 19:02:18 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2013-12-16 19:02:18 +0000
commit6607b5d582214cfff74e2f83b584112c17932cd6 (patch)
tree7c3e4a97f0701f4d291e6fb1851239bf83c68112
parent235d74776abb4df5a96170b419044ae120b931dc (diff)
Implement support for EWMH's _NET_WM_STATE_FULLSCREEN hint.
Since we already have a form of 'maximize', we need to differentiate between 'maximize' and the new 'fullscreen' mode. The 'maximize' mode will continue to honor gap but now *retains* the border, matching the 'vert/horz maximize' behaviour. The new 'fullscreen' mode supports and follows the _NET_WM_STATE_FULLSCREEN hint, allowing the client perform additional window modifications; in this mode, cwm(1) will *ignore* gap, remove borders and freeze(move/resize) the client. Additionally, 'fullscreen' mode will remember various combinations of previous states. * default keybinding changes: CM-f 'fullscreen', CM-m 'maximize' (re-map as desired). Positive feedback from a few, testing and ok sthen@
-rw-r--r--app/cwm/calmwm.h11
-rw-r--r--app/cwm/client.c62
-rw-r--r--app/cwm/conf.c7
-rw-r--r--app/cwm/cwm.18
-rw-r--r--app/cwm/cwmrc.512
-rw-r--r--app/cwm/kbfunc.c8
-rw-r--r--app/cwm/xutil.c20
7 files changed, 85 insertions, 43 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index e765537e2..3ddb098fe 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.236 2013/12/13 22:39:13 okan Exp $
+ * $OpenBSD: calmwm.h,v 1.237 2013/12/16 19:02:17 okan Exp $
*/
#ifndef _CALMWM_H_
@@ -138,7 +138,7 @@ struct client_ctx {
Window win;
Colormap colormap;
u_int bwidth; /* border width */
- struct geom geom, savegeom;
+ struct geom geom, savegeom, fullgeom;
struct {
long flags; /* defined hints */
int basew; /* desired width */
@@ -167,6 +167,7 @@ struct client_ctx {
#define CLIENT_WM_DELETE_WINDOW 0x0100
#define CLIENT_WM_TAKE_FOCUS 0x0200
#define CLIENT_URGENCY 0x0400
+#define CLIENT_FULLSCREEN 0x0800
#define CLIENT_HIGHLIGHT (CLIENT_GROUP | CLIENT_UNGROUP)
#define CLIENT_MAXFLAGS (CLIENT_VMAXIMIZED | CLIENT_HMAXIMIZED)
@@ -355,9 +356,10 @@ enum {
_NET_WM_DESKTOP,
_NET_CLOSE_WINDOW,
_NET_WM_STATE,
-#define _NET_WM_STATES_NITEMS 3
+#define _NET_WM_STATES_NITEMS 4
_NET_WM_STATE_MAXIMIZED_VERT,
_NET_WM_STATE_MAXIMIZED_HORZ,
+ _NET_WM_STATE_FULLSCREEN,
_NET_WM_STATE_DEMANDS_ATTENTION,
EWMH_NITEMS
};
@@ -380,6 +382,7 @@ void client_delete(struct client_ctx *);
void client_draw_border(struct client_ctx *);
struct client_ctx *client_find(Window);
void client_freeze(struct client_ctx *);
+void client_fullscreen(struct client_ctx *);
long client_get_wm_state(struct client_ctx *);
void client_getsizehints(struct client_ctx *);
void client_hide(struct client_ctx *);
@@ -445,6 +448,8 @@ void kbfunc_client_cyclegroup(struct client_ctx *,
union arg *);
void kbfunc_client_delete(struct client_ctx *, union arg *);
void kbfunc_client_freeze(struct client_ctx *, union arg *);
+void kbfunc_client_fullscreen(struct client_ctx *,
+ union arg *);
void kbfunc_client_group(struct client_ctx *, union arg *);
void kbfunc_client_grouponly(struct client_ctx *,
union arg *);
diff --git a/app/cwm/client.c b/app/cwm/client.c
index a8e6934b7..df01ce776 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.163 2013/12/13 22:39:13 okan Exp $
+ * $OpenBSD: client.c,v 1.164 2013/12/16 19:02:17 okan Exp $
*/
#include <sys/param.h>
@@ -229,6 +229,38 @@ client_freeze(struct client_ctx *cc)
}
void
+client_fullscreen(struct client_ctx *cc)
+{
+ struct screen_ctx *sc = cc->sc;
+ struct geom xine;
+
+ if ((cc->flags & CLIENT_FREEZE) &&
+ !(cc->flags & CLIENT_FULLSCREEN))
+ return;
+
+ if ((cc->flags & CLIENT_FULLSCREEN)) {
+ cc->bwidth = Conf.bwidth;
+ cc->geom = cc->fullgeom;
+ cc->flags &= ~(CLIENT_FULLSCREEN | CLIENT_FREEZE);
+ goto resize;
+ }
+
+ cc->fullgeom = cc->geom;
+
+ xine = screen_find_xinerama(sc,
+ cc->geom.x + cc->geom.w / 2,
+ cc->geom.y + cc->geom.h / 2, CWM_NOGAP);
+
+ cc->bwidth = 0;
+ cc->geom = xine;
+ cc->flags |= (CLIENT_FULLSCREEN | CLIENT_FREEZE);
+
+resize:
+ client_resize(cc, 0);
+ xu_ewmh_set_net_wm_state(cc);
+}
+
+void
client_maximize(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
@@ -238,9 +270,8 @@ client_maximize(struct client_ctx *cc)
return;
if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_MAXIMIZED) {
- cc->flags &= ~CLIENT_MAXIMIZED;
cc->geom = cc->savegeom;
- cc->bwidth = Conf.bwidth;
+ cc->flags &= ~CLIENT_MAXIMIZED;
goto resize;
}
@@ -263,8 +294,10 @@ client_maximize(struct client_ctx *cc)
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
- cc->geom = xine;
- cc->bwidth = 0;
+ cc->geom.x = xine.x;
+ cc->geom.y = xine.y;
+ cc->geom.w = xine.w - (cc->bwidth * 2);
+ cc->geom.h = xine.h - (cc->bwidth * 2);
cc->flags |= CLIENT_MAXIMIZED;
resize:
@@ -284,9 +317,6 @@ client_vmaximize(struct client_ctx *cc)
if (cc->flags & CLIENT_VMAXIMIZED) {
cc->geom.y = cc->savegeom.y;
cc->geom.h = cc->savegeom.h;
- cc->bwidth = Conf.bwidth;
- if (cc->flags & CLIENT_HMAXIMIZED)
- cc->geom.w -= cc->bwidth * 2;
cc->flags &= ~CLIENT_VMAXIMIZED;
goto resize;
}
@@ -294,12 +324,6 @@ client_vmaximize(struct client_ctx *cc)
cc->savegeom.y = cc->geom.y;
cc->savegeom.h = cc->geom.h;
- /* if this will make us fully maximized then remove boundary */
- if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_HMAXIMIZED) {
- cc->geom.w += cc->bwidth * 2;
- cc->bwidth = 0;
- }
-
xine = screen_find_xinerama(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
@@ -325,9 +349,6 @@ client_hmaximize(struct client_ctx *cc)
if (cc->flags & CLIENT_HMAXIMIZED) {
cc->geom.x = cc->savegeom.x;
cc->geom.w = cc->savegeom.w;
- cc->bwidth = Conf.bwidth;
- if (cc->flags & CLIENT_VMAXIMIZED)
- cc->geom.h -= cc->bwidth * 2;
cc->flags &= ~CLIENT_HMAXIMIZED;
goto resize;
}
@@ -335,12 +356,6 @@ client_hmaximize(struct client_ctx *cc)
cc->savegeom.x = cc->geom.x;
cc->savegeom.w = cc->geom.w;
- /* if this will make us fully maximized then remove boundary */
- if ((cc->flags & CLIENT_MAXFLAGS) == CLIENT_VMAXIMIZED) {
- cc->geom.h += cc->bwidth * 2;
- cc->bwidth = 0;
- }
-
xine = screen_find_xinerama(sc,
cc->geom.x + cc->geom.w / 2,
cc->geom.y + cc->geom.h / 2, CWM_GAP);
@@ -359,7 +374,6 @@ client_resize(struct client_ctx *cc, int reset)
{
if (reset) {
cc->flags &= ~CLIENT_MAXIMIZED;
- cc->bwidth = Conf.bwidth;
xu_ewmh_set_net_wm_state(cc);
}
diff --git a/app/cwm/conf.c b/app/cwm/conf.c
index feaafa887..d65742fd5 100644
--- a/app/cwm/conf.c
+++ b/app/cwm/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.
*
- * $OpenBSD: conf.c,v 1.151 2013/12/13 14:40:52 okan Exp $
+ * $OpenBSD: conf.c,v 1.152 2013/12/16 19:02:17 okan Exp $
*/
#include <sys/param.h>
@@ -178,7 +178,8 @@ static struct {
{ "M-Right", "cyclegroup" },
{ "M-Left", "rcyclegroup" },
{ "CM-g", "grouptoggle" },
- { "CM-f", "maximize" },
+ { "CM-f", "fullscreen" },
+ { "CM-m", "maximize" },
{ "CM-equal", "vmaximize" },
{ "CMS-equal", "hmaximize" },
{ "CMS-f", "freeze" },
@@ -376,6 +377,7 @@ static struct {
{ "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT,
{.i = CWM_RCYCLE|CWM_INGROUP} },
{ "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}},
+ { "fullscreen", kbfunc_client_fullscreen, KBFLAG_NEEDCLIENT, {0} },
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} },
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} },
{ "hmaximize", kbfunc_client_hmaximize, KBFLAG_NEEDCLIENT, {0} },
@@ -688,6 +690,7 @@ static char *ewmhints[] = {
"_NET_WM_STATE",
"_NET_WM_STATE_MAXIMIZED_VERT",
"_NET_WM_STATE_MAXIMIZED_HORZ",
+ "_NET_WM_STATE_FULLSCREEN",
"_NET_WM_STATE_DEMANDS_ATTENTION",
};
diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1
index d209efd85..fe2818736 100644
--- a/app/cwm/cwm.1
+++ b/app/cwm/cwm.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwm.1,v 1.48 2012/10/31 19:30:19 okan Exp $
+.\" $OpenBSD: cwm.1,v 1.49 2013/12/16 19:02:17 okan 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: October 31 2012 $
+.Dd $Mdocdate: December 16 2013 $
.Dt CWM 1
.Os
.Sh NAME
@@ -91,7 +91,9 @@ Reverse cycle through active groups.
.It Ic CMS-f
Toggle freezing geometry of current window.
.It Ic CM-f
-Toggle full-screen size of current window.
+Toggle full-screen mode of current window.
+.It Ic CM-m
+Toggle maximization of current window.
.It Ic CM-=
Toggle vertical maximization of current window.
.It Ic CMS-=
diff --git a/app/cwm/cwmrc.5 b/app/cwm/cwmrc.5
index 24f4ab058..515283eff 100644
--- a/app/cwm/cwmrc.5
+++ b/app/cwm/cwmrc.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cwmrc.5,v 1.56 2013/12/13 14:40:52 okan Exp $
+.\" $OpenBSD: cwmrc.5,v 1.57 2013/12/16 19:02:17 okan 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: December 13 2013 $
+.Dd $Mdocdate: December 16 2013 $
.Dt CWMRC 5
.Os
.Sh NAME
@@ -341,12 +341,14 @@ Raise current window.
Label current window.
.It freeze
Freeze current window geometry.
+.It fullscreen
+Full-screen current window (gap + border removed).
.It maximize
-Maximize current window full-screen.
+Maximize current window (gap + border honored).
.It vmaximize
-Maximize current window vertically.
+Vertically maximize current window (gap + border honored).
.It hmaximize
-Maximize current window horizontally.
+Horizontally maximize current window (gap + border honored).
.It moveup
Move window
.Ar moveamount
diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c
index ae3ba713a..749544f92 100644
--- a/app/cwm/kbfunc.c
+++ b/app/cwm/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.
*
- * $OpenBSD: kbfunc.c,v 1.84 2013/12/13 22:39:13 okan Exp $
+ * $OpenBSD: kbfunc.c,v 1.85 2013/12/16 19:02:17 okan Exp $
*/
#include <sys/param.h>
@@ -448,6 +448,12 @@ kbfunc_client_movetogroup(struct client_ctx *cc, union arg *arg)
}
void
+kbfunc_client_fullscreen(struct client_ctx *cc, union arg *arg)
+{
+ client_fullscreen(cc);
+}
+
+void
kbfunc_client_maximize(struct client_ctx *cc, union arg *arg)
{
client_maximize(cc);
diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c
index 303346349..6b07c0414 100644
--- a/app/cwm/xutil.c
+++ b/app/cwm/xutil.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: xutil.c,v 1.80 2013/12/13 14:40:52 okan Exp $
+ * $OpenBSD: xutil.c,v 1.81 2013/12/16 19:02:17 okan Exp $
*/
#include <sys/param.h>
@@ -333,6 +333,9 @@ xu_ewmh_handle_net_wm_state_msg(struct client_ctx *cc, int action,
{ _NET_WM_STATE_MAXIMIZED_HORZ,
CLIENT_HMAXIMIZED,
client_hmaximize },
+ { _NET_WM_STATE_FULLSCREEN,
+ CLIENT_FULLSCREEN,
+ client_fullscreen },
{ _NET_WM_STATE_DEMANDS_ATTENTION,
CLIENT_URGENCY,
client_urgency },
@@ -369,6 +372,8 @@ xu_ewmh_restore_net_wm_state(struct client_ctx *cc)
client_hmaximize(cc);
if (atoms[i] == ewmh[_NET_WM_STATE_MAXIMIZED_VERT])
client_vmaximize(cc);
+ if (atoms[i] == ewmh[_NET_WM_STATE_FULLSCREEN])
+ client_fullscreen(cc);
if (atoms[i] == ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
client_urgency(cc);
}
@@ -386,14 +391,19 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
for (i = j = 0; i < n; i++) {
if (oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_VERT] &&
+ oatoms[i] != ewmh[_NET_WM_STATE_FULLSCREEN] &&
oatoms[i] != ewmh[_NET_WM_STATE_DEMANDS_ATTENTION])
atoms[j++] = oatoms[i];
}
free(oatoms);
- if (cc->flags & CLIENT_HMAXIMIZED)
- atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
- if (cc->flags & CLIENT_VMAXIMIZED)
- atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT];
+ if (cc->flags & CLIENT_FULLSCREEN)
+ atoms[j++] = ewmh[_NET_WM_STATE_FULLSCREEN];
+ else {
+ if (cc->flags & CLIENT_HMAXIMIZED)
+ atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_HORZ];
+ if (cc->flags & CLIENT_VMAXIMIZED)
+ atoms[j++] = ewmh[_NET_WM_STATE_MAXIMIZED_VERT];
+ }
if (cc->flags & CLIENT_URGENCY)
atoms[j++] = ewmh[_NET_WM_STATE_DEMANDS_ATTENTION];
if (j > 0)