summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default_sxwmrc1
-rw-r--r--docs/CHANGELOG.md5
-rw-r--r--docs/sxwm-dev.md12
-rw-r--r--docs/sxwm.11
-rw-r--r--docs/sxwm.md1
-rw-r--r--src/extern.h1
-rw-r--r--src/parser.c1
-rw-r--r--src/sxwm.c50
8 files changed, 70 insertions, 2 deletions
diff --git a/default_sxwmrc b/default_sxwmrc
index 5cfc524..a6db36f 100644
--- a/default_sxwmrc
+++ b/default_sxwmrc
@@ -37,6 +37,7 @@ bind : mod + p : "dmenu_run"
call : mod + shift + q : close_window
call : mod + c : centre_window
call : mod + shift + e : quit
+call : mod + m : toggle_monocle
# Focus Movement:
call : mod + j : focus_next
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 4d35a93..201f9e5 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -3,12 +3,17 @@
All notable changes to this project will be documented in this file.
#### v1.7 (git)
+- **ADD**: Monocle layout
+- **ADD**: Developer documentation
- **ADD**: `_NET_FRAME_EXTENTS` support
- **ADD**: `start_fullscreen` which opens specified windows in fullscreen mode
- **ADD**: Proper EWMH fullscreening
- **ADD**: Switching to previous workspace
- **ADD**: Keeping floating windows on top
- **ADD**: Keyboard driven moving/resizing of windows
+- **CHANGE**: Move externs from `defs.h`->`extern.h`
+- **CHANGE**: Remove unused macros and headers
+- **CHANGE**: Logo
- **CHANGE**: Use `compile_flags.txt` instead of `.clangd`
- **CHANGE**: Remove backup binds
- **CHANGE**: General refactoring of code. Much better now
diff --git a/docs/sxwm-dev.md b/docs/sxwm-dev.md
index c5ae662..cd7e0f5 100644
--- a/docs/sxwm-dev.md
+++ b/docs/sxwm-dev.md
@@ -113,6 +113,7 @@
| [toggle_floating](#toggle_floating) | (void) | void | Toggle focused floating state. |
| [toggle_floating_global](#toggle_floating_global) | (void) | void | Toggle all clients floating on/off. |
| [toggle_fullscreen](#toggle_fullscreen) | (void) | void | Toggle fullscreen on focused. |
+| [toggle_monocle](#toggle_monocle) | (void) | void | Toggle monocle layout. |
| [toggle_scratchpad](#toggle_scratchpad) | (int n) | void | Map/unmap scratchpad n and focus. |
| [unswallow_window](#unswallow_window) | (Client *c) | void | Restore swallower and unlink relation. |
| [update_borders](#update_borders) | (void) | void | Paint borders and publish active window. |
@@ -878,7 +879,8 @@ Call change_workspace(previous_workspace).
```
Recompute struts, then for each monitor: build list of visible, non-
-floating, non-fullscreen clients on that monitor. Place master at left
+floating, non-fullscreen clients on that monitor. If monocle layout enabled, configure
+every window to take all the space then leave. Otherwise, places master at left
with width master_width[m], stack on right with gaps. Compute stack
heights using per-client custom_stack_height or auto-split; enforce
minimums and absorb rounding remainder at bottom. Configure windows,
@@ -913,6 +915,14 @@ current geometry) and raise them; otherwise leave state. Retile and repaint.
Toggle fullscreen on focused via apply_fullscreen.
+#### toggle_monocle
+
+```c
+(void) -> void
+```
+
+Enable/disable the monocle layout. Most of the logic is near the top of [tile](#tile)
+
#### toggle_scratchpad
```c
diff --git a/docs/sxwm.1 b/docs/sxwm.1
index 6604a0e..50cdfb7 100644
--- a/docs/sxwm.1
+++ b/docs/sxwm.1
@@ -138,6 +138,7 @@ stack_increase Increase the height of the focused stack window.
stack_decrease Decrease the height of the focused stack window.
switch_previous_workspace Switch to the previous workspace.
toggle_floating Toggles floating state of current window.
+toggle_monocle Toggles monocle layout.
.TE
.SS Example Bindings
diff --git a/docs/sxwm.md b/docs/sxwm.md
index 9b844d6..6dcdde2 100644
--- a/docs/sxwm.md
+++ b/docs/sxwm.md
@@ -104,6 +104,7 @@ workspace : modifier + ... + key : swap n
| `stack_decrease` | Decrease the height of the focused stack window. |
| `switch_previous_workspace` | Switch to the previous workspace. |
| `toggle_floating` | Toggles floating state of current window. |
+| `toggle_monocle` | Toggles the monocle layout. |
### Example Bindings
diff --git a/src/extern.h b/src/extern.h
index 3816c5f..5e0bf4c 100644
--- a/src/extern.h
+++ b/src/extern.h
@@ -31,3 +31,4 @@ extern void switch_previous_workspace(void);
extern void toggle_floating(void);
extern void toggle_floating_global(void);
extern void toggle_fullscreen(void);
+extern void toggle_monocle(void);
diff --git a/src/parser.c b/src/parser.c
index ea0e789..0c626f0 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -48,6 +48,7 @@ static const CommandEntry call_table[] = {
{"stack_decrease", resize_stack_sub},
{"switch_previous_workspace", switch_previous_workspace},
{"toggle_floating", toggle_floating},
+ {"toggle_monocle", toggle_monocle},
{NULL, NULL},
};
diff --git a/src/sxwm.c b/src/sxwm.c
index f029bb3..4f902de 100644
--- a/src/sxwm.c
+++ b/src/sxwm.c
@@ -117,6 +117,7 @@ void tile(void);
/* void toggle_floating(void); */
/* void toggle_floating_global(void); */
/* void toggle_fullscreen(void); */
+/* void toggle_monocle(void); */
void toggle_scratchpad(int n);
void unswallow_window(Client *c);
void update_borders(void);
@@ -191,10 +192,11 @@ int n_mons = 0;
int previous_workspace = 0;
int current_ws = 0;
int current_mon = 0;
+long last_motion_time = 0;
Bool global_floating = False;
Bool in_ws_switch = False;
Bool running = False;
-long last_motion_time = 0;
+Bool monocle = False;
Mask numlock_mask = 0;
Mask mode_switch_mask = 0;
@@ -2663,6 +2665,42 @@ void tile(void)
return;
}
+ if (monocle) {
+ for (Client *c = head; c; c = c->next) {
+ if (!c->mapped || c->fullscreen) {
+ continue;
+ }
+
+ int border_width = user_config.border_width;
+ int gaps = user_config.gaps;
+
+ int mon = c->mon;
+ int x = mons[mon].x + mons[mon].reserve_left + gaps;
+ int y = mons[mon].y + mons[mon].reserve_top + gaps;
+ int w = mons[mon].w - mons[mon].reserve_left - mons[mon].reserve_right - 2 * gaps;
+ int h = mons[mon].h - mons[mon].reserve_top - mons[mon].reserve_bottom - 2 * gaps;
+
+ XWindowChanges wc = {
+ .x = x,
+ .y = y,
+ .width = MAX(1, w - 2 * border_width),
+ .height = MAX(1, h - 2 * border_width),
+ .border_width = border_width
+ };
+ XConfigureWindow(dpy, c->win,
+ CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc);
+ XRaiseWindow(dpy, c->win);
+
+ c->x = wc.x;
+ c->y = wc.y;
+ c->w = wc.width;
+ c->h = wc.height;
+ }
+
+ update_borders();
+ return;
+ }
+
for (int m = 0; m < n_mons; m++) {
int mon_x = mons[m].x + mons[m].reserve_left;
int mon_y = mons[m].y + mons[m].reserve_top;
@@ -2912,6 +2950,16 @@ void toggle_fullscreen(void)
apply_fullscreen(focused, !focused->fullscreen);
}
+void toggle_monocle(void)
+{
+ monocle = !monocle;
+ tile();
+ update_borders();
+ if (focused) {
+ set_input_focus(focused, True, True);
+ }
+}
+
void toggle_scratchpad(int n)
{
if (n < 0 || n >= MAX_SCRATCHPADS || scratchpads[n].client == NULL) {