Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: fullscreen mode #20

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ one can have as many windows he wants.

---

*Monocle mode* (aka fullscreen)
*Monocle mode* (aka maximized)

-------------
| |
Expand All @@ -69,7 +69,7 @@ one can have as many windows he wants.
| |
-------------

`MONOCLE` layout presents one window at a time in fullscreen mode.
`MONOCLE` layout presents one window at a time in maximized mode.
Windows have no borders on this layout to save space.
See the `monocleborders` branch to give those windows borders.

Expand Down Expand Up @@ -117,7 +117,7 @@ desktop and urgent hints whenever needed. The user can use whatever tool or
panel suits him best (dzen2, conky, w/e), to process and display that information.

To disable the panel completely set `PANEL_HEIGHT` to zero `0`.
The `SHOW_PANELL` setting controls whether the panel is visible on startup,
The `SHOW_PANEL` setting controls whether the panel is visible on startup,
it does not control whether there is a panel or not.

[unix]: http://en.wikipedia.org/wiki/Unix_philosophy
Expand All @@ -138,7 +138,7 @@ Do not be limited by those examples.
Installation
------------

You need Xlib, then,
You need Xlib (there's an [xcb port](https://github.com/Cloudef/monsterwm-xcb)), then,
copy `config.def.h` as `config.h`
and edit to suit your needs.
Build and install.
Expand All @@ -159,11 +159,11 @@ Easiest way to apply a patch, is to `git merge` that branch.
Currently:

* [centerwindow] : center new floating windows on the screen and center any window with a shortcut
* [fibonacci] : adds fibonacci layout mode
* [fibonacci] : adds `fibonacci` layout mode
* [initlayouts] : define initial layouts for every desktop
* [monocleborders] : adds borders to the monocle layout
* [nmaster] : adds nmaster layout - multiple master windows for BSTACK and TILE layouts
* [rectangle] : draws only a rectangle when moving/resizing windows to keep resources low (ie through an ssh forwarded session)
* [nmaster] : adds `nmaster` layout - multiple master windows for BSTACK and TILE layouts
* [rectangle] : draws only a rectangle when moving/resizing windows to keep resources low (i.e. through an ssh forwarded session)
* [showhide] : adds a function to show and hide all windows on all desktops
* [uselessgaps] : adds gaps around every window on screen
* [warpcursor] : cursors follows and is placed in the center of the current window
Expand Down
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static Key keys[] = {
{ MOD1|SHIFT, XK_b, switch_mode, {.i = BSTACK}},
{ MOD1|SHIFT, XK_g, switch_mode, {.i = GRID}},
{ MOD1|SHIFT, XK_f, switch_mode, {.i = FLOAT}},
{ MOD1, XK_f, togglefullscreen, {NULL}},
{ MOD1|CONTROL, XK_r, quit, {.i = 0}}, /* quit with exit value 0 */
{ MOD1|CONTROL, XK_q, quit, {.i = 1}}, /* quit with exit value 1 */
{ MOD1|SHIFT, XK_Return, spawn, {.com = termcmd}},
Expand Down
20 changes: 12 additions & 8 deletions monsterwm.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ the stack clients are tiled on the side of master.
the stack clients are tiled beneath the master.
.TP
.B Grid mode
clients are tiled in a grid, equaly sharing and dividing the screen space
clients are tiled in a grid, equally sharing and dividing the screen space
.TP
.B Monocle mode
also known as fullscreen or max mode, where the clients take up the entire
also known as max mode, where the clients take up the entire
screen space. Other clients are hidden behind the current shown window.
On this layout, fullscreen clients don't need and don't have borders.
On this layout, maximized clients don't need and don't have borders.
You can change that behavior with the
.I monocleborders
patch, in the corresponding branch.
patch, in the corresponding branch. The state of the panel is preserved.

.TP
.B Floating mode
windows can move and be resized freely in the screen space, like on a stacking
Expand All @@ -48,7 +49,7 @@ prints version information to standard output, then exits.
.I monsterwm
does not provide a status bar. Consistent with the Unix philosophy,
.I monsterwm
provides information to the status bar or panel of choice via ouputing
provides information to the status bar or panel of choice via outputting
text with information about the state of the windows.
.P
the available settings in
Expand Down Expand Up @@ -141,8 +142,11 @@ Sets grid layout
.B Mod1\-Shift\-f
Sets float layout
.TP
.B Mod1\-f
Toggles fullscreen mode
.TP
.B Mod1\-Shift\-r
Quit with exit value 0 (usefull for restarts of the wm).
Quit with exit value 0 (useful for restarts of the wm).
.TP
.B Mod1\-Shift\-q
Quit with exit value 1 (differentiate quit from restart).
Expand Down Expand Up @@ -213,7 +217,7 @@ whether to focus the window the mouse just entered
whether to follow the window to the new desktop where it moved
.TP
.B CLICK_TO_FOCUS
whether an action on a window (eg clicking, or scrolling)
whether an action on a window (e.g. clicking, or scrolling)
will give the window focus. Disabling this gives the user
the ability to, for example, look up things on a web browser
but not lose focus from the terminal etc.
Expand All @@ -232,7 +236,7 @@ which desktop to focus by default
.TP
.B MINWSZ
the minimum window size allowed. Prevents over resizing with
the mouse or keyboard (eg resizing the master area)
the mouse or keyboard (e.g. resizing the master area)
.P
users can set
.B rules
Expand Down
35 changes: 31 additions & 4 deletions monsterwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static void rotate_filled(const Arg *arg);
static void spawn(const Arg *arg);
static void swap_master();
static void switch_mode(const Arg *arg);
static void togglefullscreen();
static void togglepanel();

#include "config.h"
Expand Down Expand Up @@ -127,15 +128,18 @@ typedef struct Client {
* masz - the size of the master area
* sasz - additional size of the first stack window area
* mode - the desktop's tiling layout mode
* pmod - the desktop's previous tiling layout mode (used for restoring from fullscreen)
* head - the start of the client list
* curr - the currently highlighted window
* prev - the client that previously had focus
* sbar - the visibility status of the panel/statusbar
* psbr - its visibility status before going into fullscreen mode
* isfs - whether the desktop is in fullscreen mode
*/
typedef struct {
int mode, masz, sasz;
int mode, pmod, masz, sasz;
Client *head, *curr, *prev;
Bool sbar;
Bool sbar, psbr, isfs;
} Desktop;

/* hidden function prototypes sorted alphabetically */
Expand Down Expand Up @@ -779,7 +783,7 @@ void mousemotion(const Arg *arg) {
}

/**
* monocle aka max aka fullscreen mode/layout
* monocle aka max(imized) mode/layout
* each window should cover all the available screen space
*/
void monocle(int x, int y, int w, int h, const Desktop *d) {
Expand Down Expand Up @@ -1026,7 +1030,7 @@ void setup(void) {

/* initialize mode and panel visibility for each desktop */
for (unsigned int d = 0; d < DESKTOPS; d++)
desktops[d] = (Desktop){ .mode = DEFAULT_MODE, .sbar = SHOW_PANEL };
desktops[d] = (Desktop){ .mode = DEFAULT_MODE, .sbar = SHOW_PANEL, .isfs = False };

/* get color for focused and unfocused client borders */
win_focus = getcolor(FOCUS, screen);
Expand Down Expand Up @@ -1166,6 +1170,10 @@ void swap_master(void) {
*/
void switch_mode(const Arg *arg) {
Desktop *d = &desktops[currdeskidx];
if (d->isfs) {
if (d->sbar != d->psbr) togglepanel();
d->isfs = False;
}
if (d->mode != arg->i) d->mode = arg->i;
else if (d->mode != FLOAT) for (Client *c = d->head; c; c = c->next) c->isfloat = False;
if (d->head) { tile(d); focus(d->curr, d); }
Expand All @@ -1182,6 +1190,25 @@ void tile(Desktop *d) {
ww, wh + (d->sbar ? 0:PANEL_HEIGHT), d);
}

/**
* toggle fullscreen mode.
* fullscreen mode is a monocle layout without a visible panel/bar, from which it is possible to recover to the previous layout and panel/bar visibility state
*/
void togglefullscreen(void) {
Desktop *d = &desktops[currdeskidx];
if (d->isfs) {
if (d->sbar != d->psbr) togglepanel();
switch_mode(&(Arg){.i = d->pmod});
}
else {
d->psbr = d->sbar;
if (d->sbar) togglepanel();
d->pmod = d->mode;
switch_mode(&(Arg){.i = MONOCLE});
d->isfs = True;
}
}

/**
* toggle visibility state of the panel/bar
*/
Expand Down