Skip to content

Commit

Permalink
feat(#4): add inner, outer and smart gaps (#8)
Browse files Browse the repository at this point in the history
* gaps: add inner, outer and smart gaps

* gaps: tests inner, outer and smart gaps

* gaps: apply gaps in monocle mode

* gaps: man and readme

* gaps: man and readme

* gaps: --smart-gaps is a boolean

* gaps: vim-style smart-gaps cli options

---------

Co-authored-by: Alexander Courtis <[email protected]>
  • Loading branch information
kyechou and alex-courtis authored Apr 25, 2024
1 parent e665712 commit be87ee1
Show file tree
Hide file tree
Showing 18 changed files with 892 additions and 247 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Tiling window manager for the [river](https://github.com/riverwm/river) wayland
- Monocle with alternate borders
- Layout toggling
- Dwindling, diminishing and even stacks
- Inner, outer and smart gaps

| Layout | Symbol | Master | Stack | Directions |
|---------|-----------|--------|--------|-------------|
Expand Down Expand Up @@ -34,6 +35,7 @@ Tiling window manager for the [river](https://github.com/riverwm/river) wayland
* [Even](#even)
* [Diminish](#diminish)
* [Dwindle](#dwindle)
- [GAPS](#gaps)
- [INSTALL](#install)
* [Package Manager](#package-manager)
* [From Source](#from-source)
Expand All @@ -45,6 +47,7 @@ Tiling window manager for the [river](https://github.com/riverwm/river) wayland
- [FAQ](#faq)
* [Name Does Not Always Update](#name-does-not-always-update)
* [Borders Are Not Shown](#borders-are-not-shown)
* [Random Pixels In Gaps When Using Fractional Scaling](#random-pixels-in-gaps-when-using-fractional-scaling)
- [ISSUES](#issues)
* [Problems](#problems)
* [Ideas](#ideas)
Expand Down Expand Up @@ -96,6 +99,9 @@ wideriver \
--ratio-master 0.50 \
--count-wide-left 0 \
--ratio-wide 0.35 \
--no-smart-gaps \
--inner-gaps 0 \
--outer-gaps 0 \
--border-width 2 \
--border-width-monocle 0 \
--border-color-focused "0x93a1a1" \
Expand Down Expand Up @@ -306,6 +312,32 @@ Arranged in a dwindling manner alternating in both stack directions.

Each view occupies half the available / remaining area.

## GAPS

Gaps, in pixels, between windows may be injected. They are off by default.

`--inner-gaps` (`i`) are between windows.

`--outer-gaps` (`o`) are between the edge of the screen and windows.

`--smart-gaps` automatically hides the gaps when there is only one view or monocle layout.

----------------------------------------------------------
| o o o o o o o o o o o o |
| ---------------------- ----------------------- |
| o | | i | | o |
| | | | | |
| o | | i | | o |
| | | ----------------------- |
| o | | i i i i i i i o |
| | | ----------------------- |
| o | | i | | o |
| | | | | |
| o | | i | | o |
| ---------------------- ----------------------- |
| o o o o o o o o o o o o |
----------------------------------------------------------

## INSTALL

### Package Manager
Expand Down Expand Up @@ -344,6 +376,10 @@ Should install under `/usr/local`
--count-wide-left count 0 0 <= count
--ratio-wide ratio 0.35 0.1 <= ratio <= 0.9

--(no-)smart-gaps
--inner-gaps pixels 0 0 <= gap size
--outer-gaps pixels 0 0 <= gap size

--border-width pixels 2 0 <= width
--border-width-monocle pixels 0 0 <= width

Expand Down Expand Up @@ -388,6 +424,15 @@ Initial number of views in the wide layout’s left stack area, default `1`, min
`--ratio-wide` *ratio*
Initial proportion of the width the wide layout’s master area occupies, default `0.35`, minimum `0.1`, maximum `0.9`. The default value is best suited to ultrawide monitors, a value of `0.5` may be more useful for 16:9 monitors.

`--(no-)smart-gaps`
Automatically hides the gaps when there is only one view or monocle layout.

`--inner-gaps` *pixels*
Inner gaps width, default `0`, minimum `0`.

`--outer-gaps` *pixels*
Outer gaps width, default `0`, minimum `0`.

`--border-width` *pixels*
Border width for all layouts except monocle, default `2`, minimum `0`.

Expand Down Expand Up @@ -457,6 +502,14 @@ You can still use client side decorations for specific applications e.g.:
riverctl rule-add -app-id audacity csd
```

### Random Pixels In Gaps When Using Fractional Scaling

This is a known river and wlroots issue: https://codeberg.org/river/river/issues/816

Workaround: set a river background colour other than default black `0x000000`

`riverctl background-color "0x010101"` is sufficiently close.

## ISSUES

### Problems
Expand Down
29 changes: 29 additions & 0 deletions doc/templ/20.man.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Tiling window manager for the [river](https://github.com/riverwm/river) wayland
* Monocle with alternate borders
* Layout toggling
* Dwindling, diminishing and even stacks
* Inner, outer and smart gaps

| Layout | Symbol | Master | Stack | Directions |
|---------|-----------|--------|--------|--------------|
Expand Down Expand Up @@ -260,4 +261,32 @@ Arranged in a dwindling manner alternating in both stack directions.

Each view occupies half the available / remaining area.

## GAPS

Gaps, in pixels, between windows may be injected. They are off by default.

`--inner-gaps` (`i`) are between windows.

`--outer-gaps` (`o`) are between the edge of the screen and windows.

`--smart-gaps` automatically hides the gaps when there is only one view or monocle layout.

```
----------------------------------------------------------
| o o o o o o o o o o o o |
| ---------------------- ----------------------- |
| o | | i | | o |
| | | | | |
| o | | i | | o |
| | | ----------------------- |
| o | | i i i i i i i o |
| | | ----------------------- |
| o | | i | | o |
| | | | | |
| o | | i | | o |
| ---------------------- ----------------------- |
| o o o o o o o o o o o o |
----------------------------------------------------------
```

[//]: # vim: set filetype=markdown ts=4 sw=4 et :
17 changes: 17 additions & 0 deletions doc/templ/40.man.readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ You may wish to set this to 0 for a more natural or intuitive feel when launchin
: Initial proportion of the width the wide layout's master area occupies, default `0.35`, minimum `0.1`, maximum `0.9`.
The default value is best suited to ultrawide monitors, a value of `0.5` may be more useful for 16:9 monitors.

`--(no-)smart-gaps`
: Automatically hides the gaps when there is only one view or monocle layout.

`--inner-gaps` *pixels*
: Inner gaps width, default `0`, minimum `0`.

`--outer-gaps` *pixels*
: Outer gaps width, default `0`, minimum `0`.

`--border-width` *pixels*
: Border width for all layouts except monocle, default `2`, minimum `0`.

Expand Down Expand Up @@ -103,6 +112,14 @@ You can still use client side decorations for specific applications e.g.:
riverctl rule-add -app-id audacity csd
```

### Random Pixels In Gaps When Using Fractional Scaling

This is a known river and wlroots issue: https://codeberg.org/river/river/issues/816

Workaround: set a river background colour other than default black `0x000000`

`riverctl background-color "0x010101"` is sufficiently close.

## ISSUES

### Problems
Expand Down
2 changes: 2 additions & 0 deletions inc/arrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void arrange_wide(const struct Demand *demand,

// append many new Box to views with full usable area
void arrange_monocle(const struct Demand *demand,
const struct Tag* const tag,
struct SList **views);

// recursively append new Box to views as per stack
Expand All @@ -58,6 +59,7 @@ void arrange_views(const struct Demand *demand,
const enum Cardinal dir_next,
const uint32_t num_total,
const uint32_t num_remaining,
const uint32_t inner_gap,
const struct Box box_total,
const struct Box box_remaining,
struct SList **views);
Expand Down
14 changes: 14 additions & 0 deletions inc/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#define RATIO_MASTER_DEFAULT 0.5
#define RATIO_WIDE_DEFAULT 0.35

#define SMART_GAPS_DEFAULT false

#define INNER_GAPS_MIN 0
#define INNER_GAPS_DEFAULT 0

#define OUTER_GAPS_MIN 0
#define OUTER_GAPS_DEFAULT 0

#define BORDER_WIDTH_MIN 0
#define BORDER_WIDTH_DEFAULT 2

Expand All @@ -41,6 +49,9 @@ struct Cfg {
double ratio_master;
uint32_t count_wide_left;
double ratio_wide;
bool smart_gaps;
uint32_t inner_gaps;
uint32_t outer_gaps;
size_t border_width;
size_t border_width_monocle;
char border_color_focused[11];
Expand All @@ -56,6 +67,9 @@ bool cfg_set_count_master(const char *s);
bool cfg_set_ratio_master(const char *s);
bool cfg_set_count_wide_left(const char *s);
bool cfg_set_ratio_wide(const char *s);
void cfg_set_smart_gaps(bool smart_gaps);
bool cfg_set_inner_gaps(const char *s);
bool cfg_set_outer_gaps(const char *s);
bool cfg_set_border_width(const char *s);
bool cfg_set_border_width_monocle(const char *s);

Expand Down
4 changes: 4 additions & 0 deletions inc/tag.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef TAG_H
#define TAG_H

#include <stdbool.h>
#include <stdint.h>

#include "enum.h"
Expand All @@ -15,6 +16,9 @@ struct Tag {
double ratio_master;
uint32_t count_wide_left;
double ratio_wide;
bool smart_gaps;
uint32_t inner_gaps;
uint32_t outer_gaps;
};

struct Tag *tag_init(const uint32_t mask);
Expand Down
Loading

0 comments on commit be87ee1

Please sign in to comment.