code: update to wlroots 0.11.0
This commit is contained in:
parent
be29b0ef95
commit
0ebb5ccc17
@ -26,7 +26,7 @@ installed:
|
||||
- [zig](https://github.com/ziglang/zig) 0.6.0
|
||||
- wayland
|
||||
- wayland-protocols
|
||||
- [wlroots](https://github.com/swaywm/wlroots) 0.10.1
|
||||
- [wlroots](https://github.com/swaywm/wlroots) 0.11.0
|
||||
- xkbcommon
|
||||
- pixman
|
||||
- pkg-config
|
||||
|
@ -130,7 +130,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, size: ?u32) !void {
|
||||
var it = server.root.outputs.first;
|
||||
while (it) |node| : (it = node.next) {
|
||||
const wlr_output = node.data.wlr_output;
|
||||
if (c.wlr_xcursor_manager_load(self.wlr_xcursor_manager, wlr_output.scale) != 0)
|
||||
if (!c.wlr_xcursor_manager_load(self.wlr_xcursor_manager, wlr_output.scale))
|
||||
log.err(.cursor, "failed to load xcursor theme '{}' at scale {}", .{ theme, wlr_output.scale });
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ pub fn setTheme(self: *Self, theme: ?[*:0]const u8, size: ?u32) !void {
|
||||
if (theme) |t| if (c.setenv("XCURSOR_THEME", t, 1) < 0) return error.OutOfMemory;
|
||||
|
||||
if (build_options.xwayland) {
|
||||
if (c.wlr_xcursor_manager_load(self.wlr_xcursor_manager, 1) == 0) {
|
||||
if (c.wlr_xcursor_manager_load(self.wlr_xcursor_manager, 1)) {
|
||||
const wlr_xcursor = c.wlr_xcursor_manager_get_xcursor(self.wlr_xcursor_manager, "left_ptr", 1).?;
|
||||
const image: *c.wlr_xcursor_image = wlr_xcursor.*.images[0];
|
||||
c.wlr_xwayland_set_cursor(
|
||||
|
@ -46,18 +46,17 @@ pub fn init(self: *Self, seat: *Seat, wlr_input_device: *c.wlr_input_device) !vo
|
||||
.variant = null,
|
||||
.options = null,
|
||||
};
|
||||
const context = c.xkb_context_new(.XKB_CONTEXT_NO_FLAGS) orelse return error.CreateXkbContextError;
|
||||
const context = c.xkb_context_new(.XKB_CONTEXT_NO_FLAGS) orelse return error.XkbContextFailed;
|
||||
defer c.xkb_context_unref(context);
|
||||
|
||||
const keymap = c.xkb_keymap_new_from_names(
|
||||
context,
|
||||
&rules,
|
||||
.XKB_KEYMAP_COMPILE_NO_FLAGS,
|
||||
) orelse return error.CreateXkbKeymapError;
|
||||
) orelse return error.XkbKeymapFailed;
|
||||
defer c.xkb_keymap_unref(keymap);
|
||||
|
||||
// TODO: handle failure after https://github.com/swaywm/wlroots/pull/2081
|
||||
c.wlr_keyboard_set_keymap(self.wlr_keyboard, keymap);
|
||||
if (!c.wlr_keyboard_set_keymap(self.wlr_keyboard, keymap)) return error.SetKeymapFailed;
|
||||
c.wlr_keyboard_set_repeat_info(self.wlr_keyboard, 25, 600);
|
||||
|
||||
// Setup listeners for keyboard events
|
||||
|
@ -294,8 +294,9 @@ fn addKeyboard(self: *Self, device: *c.wlr_input_device) !void {
|
||||
const node = try self.keyboards.allocateNode(util.gpa);
|
||||
node.data.init(self, device) catch |err| {
|
||||
switch (err) {
|
||||
error.CreateXkbContextError => log.err(.keyboard, "Failed to create XKB context", .{}),
|
||||
error.CreateXkbKeymapError => log.err(.keyboard, "Failed to create XKB keymap", .{}),
|
||||
error.XkbContextFailed => log.err(.keyboard, "Failed to create XKB context", .{}),
|
||||
error.XkbKeymapFailed => log.err(.keyboard, "Failed to create XKB keymap", .{}),
|
||||
error.SetKeymapFailed => log.err(.keyboard, "Failed to set wlr keyboard keymap", .{}),
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
@ -84,9 +84,8 @@ pub fn init(self: *Self) !void {
|
||||
// The renderer is responsible for defining the various pixel formats it
|
||||
// supports for shared memory, this configures that for clients.
|
||||
const wlr_renderer = c.river_wlr_backend_get_renderer(self.wlr_backend).?;
|
||||
// TODO: Handle failure after https://github.com/swaywm/wlroots/pull/2080
|
||||
c.wlr_renderer_init_wl_display(wlr_renderer, self.wl_display); // orelse
|
||||
// return error.CantInitWlDisplay;
|
||||
if (!c.wlr_renderer_init_wl_display(wlr_renderer, self.wl_display)) return error.DisplayInitFailed;
|
||||
|
||||
self.listen_new_output.notify = handleNewOutput;
|
||||
c.wl_signal_add(&self.wlr_backend.events.new_output, &self.listen_new_output);
|
||||
|
||||
@ -149,7 +148,7 @@ pub fn start(self: Self) !void {
|
||||
if (!c.river_wlr_backend_start(self.wlr_backend)) return error.StartBackendError;
|
||||
if (c.setenv("WAYLAND_DISPLAY", socket, 1) < 0) return error.SetenvError;
|
||||
if (build_options.xwayland) {
|
||||
if (c.setenv("DISPLAY", &self.wlr_xwayland.display_name, 1) < 0) return error.SetenvError;
|
||||
if (c.setenv("DISPLAY", self.wlr_xwayland.display_name, 1) < 0) return error.SetenvError;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ const State = struct {
|
||||
};
|
||||
|
||||
const SavedBuffer = struct {
|
||||
wlr_buffer: *c.wlr_buffer,
|
||||
wlr_client_buffer: *c.wlr_client_buffer,
|
||||
box: Box,
|
||||
transform: c.wl_output_transform,
|
||||
};
|
||||
@ -127,7 +127,7 @@ pub fn init(self: *Self, output: *Output, tags: u32, surface: var) void {
|
||||
}
|
||||
|
||||
pub fn deinit(self: Self) void {
|
||||
for (self.saved_buffers.items) |buffer| c.wlr_buffer_unref(buffer.wlr_buffer);
|
||||
for (self.saved_buffers.items) |buffer| c.wlr_buffer_unlock(&buffer.wlr_client_buffer.*.base);
|
||||
self.saved_buffers.deinit();
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ pub fn sendFrameDone(self: Self) void {
|
||||
}
|
||||
|
||||
pub fn dropSavedBuffers(self: *Self) void {
|
||||
for (self.saved_buffers.items) |buffer| c.wlr_buffer_unref(buffer.wlr_buffer);
|
||||
for (self.saved_buffers.items) |buffer| c.wlr_buffer_unlock(&buffer.wlr_client_buffer.*.base);
|
||||
self.saved_buffers.items.len = 0;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ fn saveBuffersIterator(
|
||||
if (wlr_surface) |surface| {
|
||||
if (c.wlr_surface_has_buffer(surface)) {
|
||||
saved_buffers.append(.{
|
||||
.wlr_buffer = surface.buffer,
|
||||
.wlr_client_buffer = surface.buffer,
|
||||
.box = Box{
|
||||
.x = surface_x,
|
||||
.y = surface_y,
|
||||
@ -185,7 +185,7 @@ fn saveBuffersIterator(
|
||||
},
|
||||
.transform = surface.current.transform,
|
||||
}) catch return;
|
||||
_ = c.wlr_buffer_ref(surface.buffer);
|
||||
_ = c.wlr_buffer_lock(&surface.buffer.*.base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ fn renderView(output: Output, view: *View, now: *c.timespec) void {
|
||||
for (view.saved_buffers.items) |saved_buffer|
|
||||
renderTexture(
|
||||
output,
|
||||
saved_buffer.wlr_buffer.texture,
|
||||
saved_buffer.wlr_client_buffer.texture,
|
||||
.{
|
||||
.x = saved_buffer.box.x + view.current.box.x - view.saved_surface_box.x,
|
||||
.y = saved_buffer.box.y + view.current.box.y - view.saved_surface_box.y,
|
||||
|
Loading…
Reference in New Issue
Block a user