Commit graph

40 commits

Author SHA1 Message Date
Zhongheng Liu
b35962606d impl autoexec support for a single script file 2026-04-28 20:40:12 +02:00
Ben Buhse
fc60e3ac35
Clean up a couple of calls in main
Also add sighandler for SIGTERM
2026-03-22 12:07:44 -05:00
Ben Buhse
a1bd356943
Implement river-xkb-config-v1
This commit adds support for the river-xkb-config-v1 protocol. There's
a new keyboard_layout block in config that can take options from
xkeyboard-config(7).
2026-03-16 14:19:59 -05:00
Ben Buhse
678d0563ed
Add exit_river keybinding
Recently, river removed the hardcoded Ctrl+Alt Delete keybinding that
exits river and replaces it with a new `exit_session` request. This adds
support for that request via the new `exit_session` bind. We also added
3 hardcoded default keybinds to: exit river, reload the config, and
open foot. This way, if the config fails to load or is missing, you
should still be able to try reload. I guess you're still SOL if you have
at least one keybind and it's not reload_config, but you do what you can
do.
2026-03-06 09:21:07 -06:00
Ben Buhse
6e85e0cffe
Remove zwlr_layer_shell_v1 bind
We don't need it anymore because everything using it has been switched
to river_shell_surfaces
2026-03-05 20:37:21 -06:00
Ben Buhse
3150d1a842
Switch TagOverlay to use river_shell_surface_v1
This follows the same patterns that Wallpaper and Bar did and makes
TagOverlay use the same manage/render cycle as the rest of the WM.

We also switched to just use a poll timer like river-tag-overlay instead
of using the timerfd. I realized that the Zig stdlib doesn't actually
support timerfds for FreeBSD right now and I don't feel like adding them.
2026-03-05 20:36:19 -06:00
Ben Buhse
f10eecffc4
Try again when wl_display.flush() returns EAGAIN
This was causing us to exist when we probably shouldn't have been.
I think the main issue was all the syncNextCommit calls for the bar.

These changes have seeminglly fixed my crash
2026-02-27 13:39:08 -06:00
Ben Buhse
0e7d652d24
Add time_format config for custom strftime strings
This lets the user change to any time format they want in the bar.
As part of this, we also change the bar to re-draw every second (to
allow using seconds in the time format string).
2026-02-27 11:02:45 -06:00
Ben Buhse
a9473204ad
Convert Bar to use river-shell-surface
I want to implement more functionality to the bar, similar to what
machi has in its bar, but it seems a lot easier to just handle the bar
with the rest of the manage/render loop that rwm and beansprout use.

To do that, I had to convert the bar to use river-shell-surface instead
of zwlr-layer-shell.

In that process, I also removed support for zwlr-layer-shell exclusive
zones. It made calculating the usable area for the layout more annoying.
If someone *really* wants, I would consider adding it back, but the only
thing I can think of that requires exclusive area is a bar, and we don't
really support other bars, so I don't think it's needed.

I also switched a couple of places to use saturating subtraction on
unsigned ints.
2026-02-26 16:34:48 -06:00
Ben Buhse
b9d13583ab
Fix a number of typos in comments 2026-02-22 17:51:17 -06:00
Ben Buhse
8e6c28da7b
Fix some memory leaks 2026-02-22 17:38:28 -06:00
Ben Buhse
6b8350e7b6
Create initial window rules set up
At least tag rules seem to be working (but they're not frame perfect).

I might need to investigate more for float/no_float.

Rules are ANDed and only apply during window's first manage sequence,
so changing an appid/title doesn't affect anything.
2026-02-17 16:26:18 -06:00
Ben Buhse
9b0bac12ff
Fix text scaling in Bar
Before, we were missing the initial events from the wl_output, including
the scale. This meant that we weren't scaling the bar clock correctly.
To fix it, we just moved the wl_global binding into the .wl_output event

We also got rid of the hashmap of outputs in Globals and Context.
2026-02-16 19:09:33 -06:00
Ben Buhse
dbf32e793c
Finish wiring up the TagOverlay
We had to fix a couple of compile errors that weren't showing while it
wasn't wired up (since I never just tried to compile TagOverlay.zig on
its own). We also changed the lifecycle to re-create/destroy the surface
to show/hide it, similar to the way that river-tag-overlay actually did
it.

Finally, I added @branchHint(.cold) to a few places in the event loop
where, if we're in the branch, the wm is definitely exiting, so it's
fine if they're cold (should almost never happen).
2026-02-16 11:33:48 -06:00
Ben Buhse
5c427234d7
Add layer shell support and fix floating windows
Now, I actually save the river-layer-shell-v1 and keep track of the
non-exclusive area. The layout calculation uses the usable area instead
of the entire output's geometry.

I removed boundary clamping for the floating windows because it was a
bit janky when hitting the edges. I'll probably add it back at some
point. I also made windows default to 75% of the usable area instead of
keeping their tiled size so that maximized windows look decent when
floating for the first time. Finally, since I removed the clamping, I
added a center_float keybind to center a floating window. If you're
cycling through focused windows and one isn't on the screen, you can use
the center_float bind to get the window visible again.

Replaced all divTrunc with divFloor to be consistent. I think they
should all be positive, anyways, so they'd be the same, but I like just
having one.
2026-02-14 11:30:37 -06:00
Ben Buhse
6bf607b759
Change errdefers in create()/init() functions
They should use gpa.destroy() instead of foo.destroy() because (most) of
them have fields that may not be initialized by the first error, so
the foo.destroy() could crash.
2026-02-13 19:30:21 -06:00
Ben Buhse
5501ccbe26
Split main() up by adding parseArgs() and run()
parseArgs() contains all of the argument parsing logic in a single fn.

run() handles the event loop. To work with the bar, I had to re-write
the loop to use polling similar to the loop in `beanclock` instead of
just `while (true) dispatch`.
2026-02-13 11:10:42 -06:00
Ben Buhse
40088b4ab6
Add initial bar support
Right now it just renders a black bar at the top of the screen, nothing
useful is in it and it has no configuration.
2026-02-13 10:07:48 -06:00
Ben Buhse
95425aa73f
Rename utils.allocator to utils.gpa
it seems like `gpa` has become pretty much the universally agreed upon
name for your... gpa, so we're renaming.
2026-02-12 14:10:28 -06:00
Ben Buhse
0970702263
Add some unit tests for a few functions
Mostly only testing the easily-testable helpers in utils and Config
2026-02-11 16:14:29 -06:00
Ben Buhse
bb612c273e
Add REUSE licensing for non-code files
CC-BY-4.0 for documentation, CC0-1.0 for examples and .gitignore,
HPND for wlr-layer-shell protocol.

Also switch to GPL-3.0-only
2026-02-11 14:50:04 -06:00
Ben Buhse
296f875993
Implement libinput device configuration
We need to defer config application to the first manage_start event
using a should_manage flag so that all *_support events have arrived
before we try applying the configs

This commit also has two other fixes
- fixes a potential use-after-free by telling InputDevice when a
 LibinputDevice is .removed.
- fix logFn (removed "if (scope != .default) return;")

I used kwm to help figure out the manage pattern for the input config.
Link to kwm: https://github.com/kewuaa/kwm
2026-02-10 20:06:17 -06:00
Ben Buhse
72c1f33c28
Implement river-input-management-v1 and river-libinput-config-v1
Right now, the support is still incomplete (no way to set config) but
we get the devices and set them up and handle current/support events
for the river_libinput_device_v1 devices.
2026-02-09 12:55:47 -06:00
Ben Buhse
ec7474c9af
Implement some simple flags and runtime log-levels
I used flags.zig from Isaac Freund for parsing basic CLI arguments,
I don't need much else since most configuration is in Kdl.
e967499fb1/common/flags.zig

I also removed some of the duplicated bits for the exe_check step
since I realized I can just use the beansprout executable for all of it.
2026-02-08 16:25:30 -06:00
Ben Buhse
225ddf0a53
Fix buffer pool race condition, pixman transform, and pixel conversion
Mark reused buffers as busy before returning from nextBuffer (before,
they only got marked busy on init).

Re-attach wl_buffer listener after re-initializing a buffer. This lets
the re-inited buffer still get a released event.

Combine scale and translate matrices with multiply instead of overwriting

Use appendAssumeCapacity for pixel conversion loop (since we already
initialized the list with the correct size).
2026-02-08 10:51:33 -06:00
Ben Buhse
3c16929a6a
Complete wallpaper support with new config
Load wallpaper_image_path from config with tilde expansion (environment
variables are not supported)

On the way for this commit, I also had to:
- Fix wallpaper not rendering on startup by triggering init from
the .wl_output handler, since wl_output.done is lost during the
initial roundtrip
- Re-render wallpapers on config reload when the path changes
- Fix crash in deinitWallpaperLayerSurface when wl_surface is null
2026-02-07 19:11:10 -06:00
Ben Buhse
00835cea08
Fix crash when wallpaper_image_path is missing
This makes the WM run fine even if wallpaper_image fails to load for any
other reason. Right now, it's still just a black background. At some
point, I plan to add the ability to also just set a color as a
background but that's a fairly low priority.
2026-02-07 17:56:05 -06:00
Ben Buhse
e186a2d017
Implement wallpaper rendering with multi-output support
This actually renders a wallpaper for each output using the newly added
Buffer and BufferPool for shared-memory surfaces and creates a
wlr-layer-shell surface per output. Right now, each wallpaper
shares the same wallpaper (though scaled to each).

wl_output globals get added to a HashMap that is used by Output when it
gets an output event.

Fix null-safety in WindowManager when no seats/outputs exist and route
Window dimensions through pending_manage.
2026-02-07 17:27:24 -06:00
Ben Buhse
fb8817ebf9
Begin work to add wallpaper support to beansprout
Added pixman and zigimg dependencies
Set up in build.zig, added to both exe and exe_check

Add new protocols:
     river-layer-shell-v1
     wlr-layer-shell-unstable-v1
     xdg-shell (dep of wlr-layer-shell-unstable-v1)

Update Context.zig to hold wl_output, wl_shm, and a WallpaperImage
Also re-ordered all of its fields into alphabetical order
Context.create() now takes a Context.Options struct so that it takes
     one arg instead of many smaller args.

Added new WallpaperImage.zig, but it's not yet actually used
2026-02-06 16:37:33 -06:00
Ben Buhse
fd8b6d0d41
Implement configuration for keybindings
Keybinds go in a "keybinds" block and follow the format

<command> <modifiers> <keysym> <options>

But there's also a special "tag_bind" command that just takes modifiers
and one of set_output_tags, set_window_tags, toggle_output_tags, and
toggle_window_tags. It will automatically be used to loop through the
1-9 keys on tags 1<<0 to 1<<9, however, you can still implement those
commands individually if you want.
2026-01-30 20:33:16 -06:00
Ben Buhse
43e3d268c9
Implement initial config loading
Config goes in $XDG_CONFIG_HOME/beansprout/config.kdl or
$HOME/.config/beansprout/config.kdl

Config is in the kdl format. Right now, the supported options are

```zig
/// Width of window borders in pixels
border_width: u8 = 2,
/// Color of focused window's border in 0xRRGGBBAA or 0xRRGGBB form
border_color_focused: RiverColor = utils.parseRgbaComptime("0x89b4fa"),
/// Color of uffocused windows' borders in 0xRRGGBBAA or 0xRRGGBB form
border_color_unfocused: RiverColor = utils.parseRgbaComptime("0x1e1e2e"),

/// Where a new window should attach, top or bottom of the stack
attach_mode: AttachMode = .top,
/// Should focus change when the cursor moves onto a new window
focus_follows_pointer: bool = true,
/// Should the pointer warp to the center of newly-focused windows
pointer_warp_on_focus_change: bool = true,
```

I plan to add Keybinds shortly. If parsing the configuration fails,
the default config will be used and the WM will continue loading.
2026-01-27 14:54:27 -06:00
Ben Buhse
e1a0b89ced
Standardize panic messages and clean up code 2026-01-25 20:57:05 -06:00
Ben Buhse
137eac9364
Update comments; Check river.SeatV1 version; Prepend new windows 2026-01-24 18:23:13 -06:00
Ben Buhse
30231f1149
Refactor initialization and Context struct
I tried to make it a little bit easier to follow and get rid of the
need to call back to context.x.y.z (as much) [I hope]
2026-01-24 17:48:01 -06:00
Ben Buhse
578e2f449e
Add borders to windows; add navigation keybinds
Right now, colors are hardcoded in the Config in main.zig.

This commit also adds a couple of new keybinds for navigating between
windows. All keybinds are hardcoded as well right now.
2026-01-23 16:23:14 -06:00
Ben Buhse
2c18946703
Add river-xkb-bindings and implement Alt+T to open foot
This is the only keybind for now.
2026-01-19 14:32:46 -06:00
Ben Buhse
f65a9aaf12
Remove event_loop/Backend 2025-08-05 18:57:07 -05:00
Ben Buhse
bad5007670
Display a single window! 2025-08-03 09:31:27 -05:00
Ben Buhse
c87fa2d4af
Begin setting up infrastructure for the WM
Mostly just created the very basic Wayland connection needed, but I also
bind to the rwm protocol which is neat.
2025-05-06 21:47:22 -05:00
Ben Buhse
8eec239af6
initial commit 2025-05-03 21:07:26 -05:00