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@
This commit is contained in:
okan
2013-12-16 19:02:17 +00:00
parent f98f4615c0
commit 19fc7f666b
7 changed files with 78 additions and 36 deletions

View File

@ -228,6 +228,38 @@ client_freeze(struct client_ctx *cc)
cc->flags |= CLIENT_FREEZE;
}
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)
{
@ -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);
}