build: update to wlroots 0.20

This commit is contained in:
Isaac Freund
2026-03-27 18:50:21 +01:00
parent bbdc47778d
commit 47b64bda73
11 changed files with 139 additions and 40 deletions

View File

@@ -28,7 +28,7 @@ sources:
tasks: tasks:
- install_deps: | - install_deps: |
cd wlroots cd wlroots
git checkout 0.19.0 git checkout 0.20.0
meson setup build --auto-features=enabled -Drenderers=gles2 \ meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dcolor-management=disabled -Dlibliftoff=disabled \ -Dcolor-management=disabled -Dlibliftoff=disabled \
-Dexamples=false -Dwerror=false -Db_ndebug=false \ -Dexamples=false -Dwerror=false -Db_ndebug=false \

View File

@@ -25,7 +25,7 @@ sources:
tasks: tasks:
- install_deps: | - install_deps: |
cd wlroots cd wlroots
git checkout 0.19.0 git checkout 0.20.0
meson setup build --auto-features=enabled -Drenderers=gles2 \ meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dcolor-management=disabled -Dlibliftoff=disabled \ -Dcolor-management=disabled -Dlibliftoff=disabled \
-Dexamples=false -Dwerror=false -Db_ndebug=false \ -Dexamples=false -Dwerror=false -Db_ndebug=false \

View File

@@ -31,7 +31,7 @@ sources:
tasks: tasks:
- install_deps: | - install_deps: |
cd wlroots cd wlroots
git checkout 0.19.0 git checkout 0.20.0
meson setup build --auto-features=enabled -Drenderers=gles2 \ meson setup build --auto-features=enabled -Drenderers=gles2 \
-Dallocators=gbm \ -Dallocators=gbm \
-Dcolor-management=disabled -Dlibliftoff=disabled \ -Dcolor-management=disabled -Dlibliftoff=disabled \

View File

@@ -53,7 +53,7 @@ distribution.
- [zig](https://ziglang.org/download/) 0.15 - [zig](https://ziglang.org/download/) 0.15
- wayland - wayland
- wayland-protocols - wayland-protocols
- [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.19 - [wlroots](https://gitlab.freedesktop.org/wlroots/wlroots) 0.20
- xkbcommon - xkbcommon
- libevdev - libevdev
- pixman - pixman

View File

@@ -98,6 +98,7 @@ pub fn build(b: *Build) !void {
scanner.addCustomProtocol(b.path("protocol/river-layout-v3.xml")); scanner.addCustomProtocol(b.path("protocol/river-layout-v3.xml"));
scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-layer-shell-unstable-v1.xml"));
scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml")); scanner.addCustomProtocol(b.path("protocol/wlr-output-power-management-unstable-v1.xml"));
scanner.addCustomProtocol(b.path("protocol/virtual-keyboard-unstable-v1.xml"));
// Some of these versions may be out of date with what wlroots implements. // Some of these versions may be out of date with what wlroots implements.
// This is not a problem in practice though as long as river successfully compiles. // This is not a problem in practice though as long as river successfully compiles.
@@ -126,6 +127,7 @@ pub fn build(b: *Build) !void {
scanner.generate("zwlr_layer_shell_v1", 4); scanner.generate("zwlr_layer_shell_v1", 4);
scanner.generate("zwlr_output_power_manager_v1", 1); scanner.generate("zwlr_output_power_manager_v1", 1);
scanner.generate("zwp_virtual_keyboard_manager_v1", 1);
const wayland = b.createModule(.{ .root_source_file = scanner.result }); const wayland = b.createModule(.{ .root_source_file = scanner.result });
@@ -141,7 +143,7 @@ pub fn build(b: *Build) !void {
// exposed to the wlroots module for @cImport() to work. This seems to be // exposed to the wlroots module for @cImport() to work. This seems to be
// the best way to do so with the current std.Build API. // the best way to do so with the current std.Build API.
wlroots.resolved_target = target; wlroots.resolved_target = target;
wlroots.linkSystemLibrary("wlroots-0.19", .{}); wlroots.linkSystemLibrary("wlroots-0.20", .{});
const flags = b.createModule(.{ .root_source_file = b.path("common/flags.zig") }); const flags = b.createModule(.{ .root_source_file = b.path("common/flags.zig") });
const globber = b.createModule(.{ .root_source_file = b.path("common/globber.zig") }); const globber = b.createModule(.{ .root_source_file = b.path("common/globber.zig") });
@@ -162,7 +164,7 @@ pub fn build(b: *Build) !void {
river.linkSystemLibrary("libevdev"); river.linkSystemLibrary("libevdev");
river.linkSystemLibrary("libinput"); river.linkSystemLibrary("libinput");
river.linkSystemLibrary("wayland-server"); river.linkSystemLibrary("wayland-server");
river.linkSystemLibrary("wlroots-0.19"); river.linkSystemLibrary("wlroots-0.20");
river.linkSystemLibrary("xkbcommon"); river.linkSystemLibrary("xkbcommon");
river.linkSystemLibrary("pixman-1"); river.linkSystemLibrary("pixman-1");

View File

@@ -17,8 +17,8 @@
.hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27", .hash = "wayland-0.4.0-lQa1khbMAQAsLS2eBR7M5lofyEGPIbu2iFDmoz8lPC27",
}, },
.wlroots = .{ .wlroots = .{
.url = "https://codeberg.org/ifreund/zig-wlroots/archive/v0.19.3.tar.gz", .url = "git+https://codeberg.org/ifreund/zig-wlroots?ref=master#6ffee8b21d24e0e4aadcf204f65ebe7ad3c3bacf",
.hash = "wlroots-0.19.3-jmOlcuL_AwBHhLCwpFsXbTizE3q9BugFmGX-XIxqcPMc", .hash = "wlroots-0.20.0-dev-jmOlclseBABjKSxVH4TVkN4Fm-moidbybTStGsujJU_m",
}, },
.xkbcommon = .{ .xkbcommon = .{
.url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz", .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz",

View File

@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="virtual_keyboard_unstable_v1">
<copyright>
Copyright © 2008-2011 Kristian Høgsberg
Copyright © 2010-2013 Intel Corporation
Copyright © 2012-2013 Collabora, Ltd.
Copyright © 2018 Purism SPC
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwp_virtual_keyboard_v1" version="1">
<description summary="virtual keyboard">
The virtual keyboard provides an application with requests which emulate
the behaviour of a physical keyboard.
This interface can be used by clients on its own to provide raw input
events, or it can accompany the input method protocol.
</description>
<request name="keymap">
<description summary="keyboard mapping">
Provide a file descriptor to the compositor which can be
memory-mapped to provide a keyboard mapping description.
Format carries a value from the keymap_format enumeration.
</description>
<arg name="format" type="uint" summary="keymap format"/>
<arg name="fd" type="fd" summary="keymap file descriptor"/>
<arg name="size" type="uint" summary="keymap size, in bytes"/>
</request>
<enum name="error">
<entry name="no_keymap" value="0" summary="No keymap was set"/>
</enum>
<request name="key">
<description summary="key event">
A key was pressed or released.
The time argument is a timestamp with millisecond granularity, with an
undefined base. All requests regarding a single object must share the
same clock.
Keymap must be set before issuing this request.
State carries a value from the key_state enumeration.
</description>
<arg name="time" type="uint" summary="timestamp with millisecond granularity"/>
<arg name="key" type="uint" summary="key that produced the event"/>
<arg name="state" type="uint" summary="physical state of the key"/>
</request>
<request name="modifiers">
<description summary="modifier and group state">
Notifies the compositor that the modifier and/or group state has
changed, and it should update state.
The client should use wl_keyboard.modifiers event to synchronize its
internal state with seat state.
Keymap must be set before issuing this request.
</description>
<arg name="mods_depressed" type="uint" summary="depressed modifiers"/>
<arg name="mods_latched" type="uint" summary="latched modifiers"/>
<arg name="mods_locked" type="uint" summary="locked modifiers"/>
<arg name="group" type="uint" summary="keyboard layout"/>
</request>
<request name="destroy" type="destructor" since="1">
<description summary="destroy the virtual keyboard keyboard object"/>
</request>
</interface>
<interface name="zwp_virtual_keyboard_manager_v1" version="1">
<description summary="virtual keyboard manager">
A virtual keyboard manager allows an application to provide keyboard
input events as if they came from a physical keyboard.
</description>
<enum name="error">
<entry name="unauthorized" value="0" summary="client not authorized to use the interface"/>
</enum>
<request name="create_virtual_keyboard">
<description summary="Create a new virtual keyboard">
Creates a new virtual keyboard associated to a seat.
If the compositor enables a keyboard to perform arbitrary actions, it
should present an error when an untrusted client requests a new
keyboard.
</description>
<arg name="seat" type="object" interface="wl_seat"/>
<arg name="id" type="new_id" interface="zwp_virtual_keyboard_v1"/>
</request>
</interface>
</protocol>

View File

@@ -307,10 +307,7 @@ pub fn setTheme(cursor: *Cursor, theme: ?[*:0]const u8, _size: ?u32) !void {
const wlr_xcursor = xcursor_manager.getXcursor("default", 1).?; const wlr_xcursor = xcursor_manager.getXcursor("default", 1).?;
const image = wlr_xcursor.images[0]; const image = wlr_xcursor.images[0];
xwayland.setCursor( xwayland.setCursor(
image.buffer, image.getBuffer(),
image.width * 4,
image.width,
image.height,
@intCast(image.hotspot_x), @intCast(image.hotspot_x),
@intCast(image.hotspot_y), @intCast(image.hotspot_y),
); );

View File

@@ -104,8 +104,8 @@ pub fn init(input_manager: *InputManager) !void {
input_manager.virtual_pointer_manager.events.new_virtual_pointer.add(&input_manager.new_virtual_pointer); input_manager.virtual_pointer_manager.events.new_virtual_pointer.add(&input_manager.new_virtual_pointer);
input_manager.virtual_keyboard_manager.events.new_virtual_keyboard.add(&input_manager.new_virtual_keyboard); input_manager.virtual_keyboard_manager.events.new_virtual_keyboard.add(&input_manager.new_virtual_keyboard);
input_manager.pointer_constraints.events.new_constraint.add(&input_manager.new_constraint); input_manager.pointer_constraints.events.new_constraint.add(&input_manager.new_constraint);
input_manager.input_method_manager.events.input_method.add(&input_manager.new_input_method); input_manager.input_method_manager.events.new_input_method.add(&input_manager.new_input_method);
input_manager.text_input_manager.events.text_input.add(&input_manager.new_text_input); input_manager.text_input_manager.events.new_text_input.add(&input_manager.new_text_input);
} }
pub fn deinit(input_manager: *InputManager) void { pub fn deinit(input_manager: *InputManager) void {

View File

@@ -46,12 +46,10 @@ input_popups: wl.list.Head(InputPopup, .link),
/// Always null if there is no input method. /// Always null if there is no input method.
text_input: ?*TextInput = null, text_input: ?*TextInput = null,
input_method_commit: wl.Listener(*wlr.InputMethodV2) = input_method_commit: wl.Listener(void) = .init(handleInputMethodCommit),
wl.Listener(*wlr.InputMethodV2).init(handleInputMethodCommit),
grab_keyboard: wl.Listener(*wlr.InputMethodV2.KeyboardGrab) = grab_keyboard: wl.Listener(*wlr.InputMethodV2.KeyboardGrab) =
wl.Listener(*wlr.InputMethodV2.KeyboardGrab).init(handleInputMethodGrabKeyboard), wl.Listener(*wlr.InputMethodV2.KeyboardGrab).init(handleInputMethodGrabKeyboard),
input_method_destroy: wl.Listener(*wlr.InputMethodV2) = input_method_destroy: wl.Listener(void) = .init(handleInputMethodDestroy),
wl.Listener(*wlr.InputMethodV2).init(handleInputMethodDestroy),
input_method_new_popup: wl.Listener(*wlr.InputPopupSurfaceV2) = input_method_new_popup: wl.Listener(*wlr.InputPopupSurfaceV2) =
wl.Listener(*wlr.InputPopupSurfaceV2).init(handleInputMethodNewPopup), wl.Listener(*wlr.InputPopupSurfaceV2).init(handleInputMethodNewPopup),
@@ -89,12 +87,9 @@ pub fn newInputMethod(relay: *InputRelay, input_method: *wlr.InputMethodV2) void
} }
} }
fn handleInputMethodCommit( fn handleInputMethodCommit(listener: *wl.Listener(void)) void {
listener: *wl.Listener(*wlr.InputMethodV2),
input_method: *wlr.InputMethodV2,
) void {
const relay: *InputRelay = @fieldParentPtr("input_method_commit", listener); const relay: *InputRelay = @fieldParentPtr("input_method_commit", listener);
assert(input_method == relay.input_method); const input_method = relay.input_method.?;
if (!input_method.client_active) return; if (!input_method.client_active) return;
const text_input = relay.text_input orelse return; const text_input = relay.text_input orelse return;
@@ -123,12 +118,8 @@ fn handleInputMethodCommit(
text_input.wlr_text_input.sendDone(); text_input.wlr_text_input.sendDone();
} }
fn handleInputMethodDestroy( fn handleInputMethodDestroy(listener: *wl.Listener(void)) void {
listener: *wl.Listener(*wlr.InputMethodV2),
input_method: *wlr.InputMethodV2,
) void {
const relay: *InputRelay = @fieldParentPtr("input_method_destroy", listener); const relay: *InputRelay = @fieldParentPtr("input_method_destroy", listener);
assert(input_method == relay.input_method);
relay.input_method_commit.link.remove(); relay.input_method_commit.link.remove();
relay.grab_keyboard.link.remove(); relay.grab_keyboard.link.remove();

View File

@@ -33,14 +33,10 @@ link: wl.list.Link,
wlr_text_input: *wlr.TextInputV3, wlr_text_input: *wlr.TextInputV3,
enable: wl.Listener(*wlr.TextInputV3) = enable: wl.Listener(void) = .init(handleEnable),
wl.Listener(*wlr.TextInputV3).init(handleEnable), commit: wl.Listener(void) = .init(handleCommit),
commit: wl.Listener(*wlr.TextInputV3) = disable: wl.Listener(void) = .init(handleDisable),
wl.Listener(*wlr.TextInputV3).init(handleCommit), destroy: wl.Listener(void) = .init(handleDestroy),
disable: wl.Listener(*wlr.TextInputV3) =
wl.Listener(*wlr.TextInputV3).init(handleDisable),
destroy: wl.Listener(*wlr.TextInputV3) =
wl.Listener(*wlr.TextInputV3).init(handleDestroy),
pub fn create(wlr_text_input: *wlr.TextInputV3) !void { pub fn create(wlr_text_input: *wlr.TextInputV3) !void {
const seat: *Seat = @ptrCast(@alignCast(wlr_text_input.seat.data)); const seat: *Seat = @ptrCast(@alignCast(wlr_text_input.seat.data));
@@ -62,7 +58,7 @@ pub fn create(wlr_text_input: *wlr.TextInputV3) !void {
wlr_text_input.events.destroy.add(&text_input.destroy); wlr_text_input.events.destroy.add(&text_input.destroy);
} }
fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { fn handleEnable(listener: *wl.Listener(void)) void {
const text_input: *TextInput = @fieldParentPtr("enable", listener); const text_input: *TextInput = @fieldParentPtr("enable", listener);
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data)); const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
@@ -89,7 +85,7 @@ fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v
} }
} }
fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { fn handleCommit(listener: *wl.Listener(void)) void {
const text_input: *TextInput = @fieldParentPtr("commit", listener); const text_input: *TextInput = @fieldParentPtr("commit", listener);
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data)); const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
@@ -103,7 +99,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v
} }
} }
fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { fn handleDisable(listener: *wl.Listener(void)) void {
const text_input: *TextInput = @fieldParentPtr("disable", listener); const text_input: *TextInput = @fieldParentPtr("disable", listener);
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data)); const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
@@ -112,7 +108,7 @@ fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3)
} }
} }
fn handleDestroy(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void { fn handleDestroy(listener: *wl.Listener(void)) void {
const text_input: *TextInput = @fieldParentPtr("destroy", listener); const text_input: *TextInput = @fieldParentPtr("destroy", listener);
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data)); const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));