Skip to content

Commit

Permalink
river-layout: create and implement protocol
Browse files Browse the repository at this point in the history
Replace the current layout mechanism based on passing args to a child
process and parsing it's stdout with a new wayland protocol. This much
more robust and allows for more featureful layout generators.

Co-authored-by: Isaac Freund <[email protected]>
  • Loading branch information
Leon-Plickat and ifreund committed Apr 20, 2021
1 parent df3e993 commit f72656b
Show file tree
Hide file tree
Showing 26 changed files with 1,263 additions and 655 deletions.
10 changes: 9 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub fn build(b: *zbs.Builder) !void {
scanner.addProtocolPath("protocol/river-control-unstable-v1.xml");
scanner.addProtocolPath("protocol/river-options-unstable-v1.xml");
scanner.addProtocolPath("protocol/river-status-unstable-v1.xml");
scanner.addProtocolPath("protocol/river-layout-v1.xml");
scanner.addProtocolPath("protocol/wlr-layer-shell-unstable-v1.xml");
scanner.addProtocolPath("protocol/wlr-output-power-management-unstable-v1.xml");

Expand Down Expand Up @@ -100,6 +101,14 @@ pub fn build(b: *zbs.Builder) !void {
const rivertile = b.addExecutable("rivertile", "rivertile/main.zig");
rivertile.setTarget(target);
rivertile.setBuildMode(mode);

rivertile.step.dependOn(&scanner.step);
rivertile.addPackage(scanner.getPkg());
rivertile.linkLibC();
rivertile.linkSystemLibrary("wayland-client");

scanner.addCSource(rivertile);

rivertile.install();
}

Expand Down Expand Up @@ -195,7 +204,6 @@ const ScdocStep = struct {
"doc/river.1.scd",
"doc/riverctl.1.scd",
"doc/rivertile.1.scd",
"doc/river-layouts.7.scd",
};

builder: *zbs.Builder,
Expand Down
86 changes: 0 additions & 86 deletions doc/river-layouts.7.scd

This file was deleted.

53 changes: 23 additions & 30 deletions doc/riverctl.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -38,29 +38,6 @@ over the Wayland protocol.
*focus-view* *next*|*previous*
Focus the next or previous view in the stack.

*layout* *full*|_command_
Provide a command which river will use for generating the layout
of non-floating windows on the currently focused output. See
*river-layouts*(7) for details on the expected formatting of the
output of layout commands. Alternatively, “full” can be given
instead of a command to cause river to use its single internal layout,
in which windows span the entire width and height of the output.

*mod-main-count* _integer_
Increase or decrease the number of "main" views which is relayed to the
layout generator. _integer_ can be positive or negative. Exactly how
"main" views are display, or if they are even displayed differently
from other views, is left to the layout generator.

*mod-main-factor* _float_
Increase or decrease the "main factor" relayed to layout
generators. _float_ is a positive or negative floating point number
(such as 0.05). This value is added to the current main factor which
is then clamped to the range [0.0, 1.0]. The layout generator is
free to interpret this value as it sees fit, or ignore it entirely.
*rivertile*(1) uses this to determine what percentage of the screen
the "main" area will occupy.

*move* *up*|*down*|*left*|*right* _delta_
Move the focused view in the specified direction by _delta_ logical
pixels. The view will be set to floating.
Expand Down Expand Up @@ -264,16 +241,10 @@ A complete list may be found in _/usr/include/linux/input-event-codes.h_
Setting _step-size_ to 1.0 disables transitions fully regardless of
the value of _delta-t_.

*outer-padding* _pixels_
Set the padding around the edge of the screen to _pixels_.

*set-repeat* _rate_ _delay_
Set the keyboard repeat rate to _rate_ key repeats per second and
repeat delay to _delay_ milliseconds.

*view-padding* _pixels_
Set the padding around the edge of each view to _pixels_.

*xcursor-theme* _theme_name_ [_size_]
Set the xcursor theme to _theme_name_ and optionally set the _size_.
The theme of the default seat determines the default for Xwayland
Expand Down Expand Up @@ -309,6 +280,28 @@ River declares certain default options for all outputs.
Changing this option changes the title of the wayland and X11 backend
outputs.

*layout* (string)
The layout namespace used to determine which layout should arrange this
output. If set to null or no layout with this namespace exists for this
output, the output will enter floating mode. Defaults to null.

*main_amount* (uint, optional hint for layouts)
An arbitrary positive integer indicating the amount of main views. Defaults
to 1.

*main_factor* (float, optional hint for layouts)
A floating point numger indicating the relative size of the area reserved
for main views. Note that layouts commonly expect values between 0.1 and 0.9.
Defaults to 0.6.

*view_padding* (uint, optional hint for layouts)
A positive integer indicating the padding in of pixels between / around
views. Defaults to 10.

*outer_padding* (uint, optional hint for layouts)
A positive integer indicating the padding in of pixels around the layut.
Defaults to 10.

# EXAMPLES

Bind bemenu-run to Super+P in normal mode:
Expand All @@ -325,4 +318,4 @@ source contributors. For more information about river's development, see

# SEE ALSO

*river*(1), *river-layouts*(7), *rivertile*(1)
*river*(1), *rivertile*(1)
32 changes: 10 additions & 22 deletions doc/rivertile.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,19 @@ rivertile - Tiled layout generator for river

# SYNOPSIS

*rivertile* *left*|*right*|*top*|*bottom* [args passed by river]
*rivertile*

# DESCRIPTION

*rivertile* is a layout generator for river. It produces tiled layouts with
split main/secondary stacks in four configurable orientations.
*rivertile* is a layout client for river. It provides four tiled layouts per
output with split main/secondary stacks with the main area in different
positions.

# OPTIONS
The namespaces of the four layouts are "tile-top", "tile-right", "tile-bottom"
and "tile-left", corresponding to the position of the main area.

*left*
Place the main stack on the left side of the output.

*right*
Place the main stack on the right side of the output.

*top*
Place the main stack at the top of the output.

*bottom*
Place the main stack at the bottom of the output.

# EXAMPLE

Set river's layout to *rivertile*'s *left* layout using riverctl

riverctl layout rivertile left
*rivertile* uses the *main_amount*, *main_factor*, *view_padding* and
*outer_padding* options.

# AUTHORS

Expand All @@ -41,4 +28,5 @@ source contributors. For more information about river's development, see

# SEE ALSO

*river-layouts*(7), *river*(1), *riverctl*(1)
*river*(1), *riverctl*(1)

32 changes: 14 additions & 18 deletions example/init
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ riverctl map normal $mod+Shift Comma send-to-output previous
# Mod+Return to bump the focused view to the top of the layout stack
riverctl map normal $mod Return zoom

# Mod+H and Mod+L to decrease/increase the main factor by 5%
# If using rivertile(1) this determines the width of the main stack.
riverctl map normal $mod H mod-main-factor -0.05
riverctl map normal $mod L mod-main-factor +0.05

# Mod+Shift+H and Mod+Shift+L to increment/decrement the number of
# main views in the layout
riverctl map normal $mod+Shift H mod-main-count +1
riverctl map normal $mod+Shift L mod-main-count -1

# Mod+Alt+{H,J,K,L} to move views
riverctl map normal $mod+Mod1 H move left 100
riverctl map normal $mod+Mod1 J move down 100
Expand Down Expand Up @@ -103,13 +93,10 @@ riverctl map normal $mod Space toggle-float
riverctl map normal $mod F toggle-fullscreen

# Mod+{Up,Right,Down,Left} to change layout orientation
riverctl map normal $mod Up layout rivertile top
riverctl map normal $mod Right layout rivertile right
riverctl map normal $mod Down layout rivertile bottom
riverctl map normal $mod Left layout rivertile left

# Mod+S to change to Full layout
riverctl map normal $mod S layout full
riverctl map normal $mod Up spawn riverctl set-option -focused-output layout tile-up
riverctl map normal $mod Right spawn riverctl set-option -focused-output layout tile-right
riverctl map normal $mod Down spawn riverctl set-option -focused-output layout tile-down
riverctl map normal $mod Left spawn riverctl set-option -focused-output layout tile-left

# Declare a passthrough mode. This mode has only a single mapping to return to
# normal mode. This makes it useful for testing a nested wayland compositor
Expand Down Expand Up @@ -148,7 +135,16 @@ done
riverctl set-repeat 50 300

# Set the layout on startup
riverctl layout rivertile left
riverctl spawn rivertile
riverctl set-option -focused-output layout tile-left

# Mod+Alt+{1..9} to set main amount
# Mod+Alt+Ctrl+{1..9} to set main factor
#for i in $(seq 1 9)
#do
# riverctl map normal $mod+mod1 spawn riverctl set-option -focused-output main_amount "${i}"
# riverctl map normal $mod+Control+mod1 spawn riverctl set-option -focused-output main_factor "0.${i}"
#done

# Set app-ids of views which should float
riverctl float-filter-add "float"
Expand Down
Loading

0 comments on commit f72656b

Please sign in to comment.