river: run 0.15 zig fmt

This commit is contained in:
Isaac Freund
2025-08-22 15:11:50 +02:00
parent d72408df18
commit 88a8c45ac0
21 changed files with 48 additions and 48 deletions

View File

@ -84,7 +84,7 @@ fn handleRequest(control_v1: *zriver.ControlV1, request: zriver.ControlV1.Reques
};
},
.run_command => |run_command| {
const seat: *Seat = @alignCast(@ptrCast(wlr.Seat.Client.fromWlSeat(run_command.seat).?.seat.data));
const seat: *Seat = @ptrCast(@alignCast(wlr.Seat.Client.fromWlSeat(run_command.seat).?.seat.data));
const callback = zriver.CommandCallbackV1.create(
control_v1.getClient(),

View File

@ -362,7 +362,7 @@ fn clearFocus(cursor: *Cursor) void {
/// Axis event is a scroll wheel or similiar
fn handleAxis(listener: *wl.Listener(*wlr.Pointer.event.Axis), event: *wlr.Pointer.event.Axis) void {
const cursor: *Cursor = @fieldParentPtr("axis", listener);
const device: *InputDevice = @alignCast(@ptrCast(event.device.data));
const device: *InputDevice = @ptrCast(@alignCast(event.device.data));
cursor.seat.handleActivity();
cursor.unhide();
@ -482,7 +482,7 @@ fn updateKeyboardFocus(cursor: Cursor, result: Root.AtResult) void {
/// Requires a call to Root.applyPending()
fn updateOutputFocus(cursor: Cursor, lx: f64, ly: f64) void {
if (server.root.output_layout.outputAt(lx, ly)) |wlr_output| {
const output: *Output = @alignCast(@ptrCast(wlr_output.data));
const output: *Output = @ptrCast(@alignCast(wlr_output.data));
cursor.seat.focusOutput(output);
}
}
@ -659,7 +659,7 @@ fn handleTabletToolAxis(
_: *wl.Listener(*wlr.Tablet.event.Axis),
event: *wlr.Tablet.event.Axis,
) void {
const device: *InputDevice = @alignCast(@ptrCast(event.device.data));
const device: *InputDevice = @ptrCast(@alignCast(event.device.data));
const tablet: *Tablet = @fieldParentPtr("device", device);
device.seat.handleActivity();
@ -673,7 +673,7 @@ fn handleTabletToolProximity(
_: *wl.Listener(*wlr.Tablet.event.Proximity),
event: *wlr.Tablet.event.Proximity,
) void {
const device: *InputDevice = @alignCast(@ptrCast(event.device.data));
const device: *InputDevice = @ptrCast(@alignCast(event.device.data));
const tablet: *Tablet = @fieldParentPtr("device", device);
device.seat.handleActivity();
@ -687,7 +687,7 @@ fn handleTabletToolTip(
_: *wl.Listener(*wlr.Tablet.event.Tip),
event: *wlr.Tablet.event.Tip,
) void {
const device: *InputDevice = @alignCast(@ptrCast(event.device.data));
const device: *InputDevice = @ptrCast(@alignCast(event.device.data));
const tablet: *Tablet = @fieldParentPtr("device", device);
device.seat.handleActivity();
@ -701,7 +701,7 @@ fn handleTabletToolButton(
_: *wl.Listener(*wlr.Tablet.event.Button),
event: *wlr.Tablet.event.Button,
) void {
const device: *InputDevice = @alignCast(@ptrCast(event.device.data));
const device: *InputDevice = @ptrCast(@alignCast(event.device.data));
const tablet: *Tablet = @fieldParentPtr("device", device);
device.seat.handleActivity();
@ -1292,7 +1292,7 @@ fn warp(cursor: *Cursor) void {
fn updateDragIcons(cursor: *Cursor) void {
var it = server.root.drag_icons.children.iterator(.forward);
while (it.next()) |node| {
const icon: *DragIcon = @alignCast(@ptrCast(node.data));
const icon: *DragIcon = @ptrCast(@alignCast(node.data));
if (icon.wlr_drag_icon.drag.seat == cursor.seat.wlr_seat) {
icon.updatePosition(cursor);

View File

@ -89,7 +89,7 @@ fn handleForeignActivate(
) void {
const handle: *ForeignToplevelHandle = @fieldParentPtr("foreign_activate", listener);
const view: *View = @fieldParentPtr("foreign_toplevel_handle", handle);
const seat: *Seat = @alignCast(@ptrCast(event.seat.data));
const seat: *Seat = @ptrCast(@alignCast(event.seat.data));
seat.focus(view);
server.root.applyPending();

View File

@ -216,7 +216,7 @@ const NoKeymapVirtKeyboard = struct {
handleDestroy(&no_keymap.destroy, &virtual_keyboard.keyboard.base);
const seat: *Seat = @alignCast(@ptrCast(virtual_keyboard.seat.data));
const seat: *Seat = @ptrCast(@alignCast(virtual_keyboard.seat.data));
seat.addDevice(&virtual_keyboard.keyboard.base, true);
}
};
@ -232,7 +232,7 @@ fn handleNewConstraint(
}
fn handleNewInputMethod(_: *wl.Listener(*wlr.InputMethodV2), input_method: *wlr.InputMethodV2) void {
const seat: *Seat = @alignCast(@ptrCast(input_method.seat.data));
const seat: *Seat = @ptrCast(@alignCast(input_method.seat.data));
log.debug("new input method on seat {s}", .{seat.wlr_seat.name});

View File

@ -43,7 +43,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit)
new_popup: wl.Listener(*wlr.XdgPopup) = wl.Listener(*wlr.XdgPopup).init(handleNewPopup),
pub fn create(wlr_layer_surface: *wlr.LayerSurfaceV1) error{OutOfMemory}!void {
const output: *Output = @alignCast(@ptrCast(wlr_layer_surface.output.?.data));
const output: *Output = @ptrCast(@alignCast(wlr_layer_surface.output.?.data));
const layer_surface = try util.gpa.create(LayerSurface);
errdefer util.gpa.destroy(layer_surface);
@ -157,7 +157,7 @@ fn handleKeyboardInteractiveExclusive(output: *Output, consider: ?*LayerSurface)
var it = tree.children.iterator(.reverse);
while (it.next()) |node| {
assert(node.type == .tree);
if (@as(?*SceneNodeData, @alignCast(@ptrCast(node.data)))) |node_data| {
if (@as(?*SceneNodeData, @ptrCast(@alignCast(node.data)))) |node_data| {
const layer_surface = node_data.data.layer_surface;
const wlr_layer_surface = layer_surface.wlr_layer_surface;
if (wlr_layer_surface.surface.mapped and

View File

@ -68,7 +68,7 @@ fn handleRequest(
.get_layout => |req| {
// Ignore if the output is inert
const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return;
const output: *Output = @alignCast(@ptrCast(wlr_output.data));
const output: *Output = @ptrCast(@alignCast(wlr_output.data));
log.debug("bind layout '{s}' on output '{s}'", .{ req.namespace, output.wlr_output.name });

View File

@ -264,7 +264,7 @@ pub fn updateLockSurfaceSize(manager: *LockManager, output: *Output) void {
var it = lock.surfaces.iterator(.forward);
while (it.next()) |wlr_lock_surface| {
const lock_surface: *LockSurface = @alignCast(@ptrCast(wlr_lock_surface.data));
const lock_surface: *LockSurface = @ptrCast(@alignCast(wlr_lock_surface.data));
if (output == lock_surface.getOutput()) {
lock_surface.configure();
}

View File

@ -65,7 +65,7 @@ pub fn destroy(lock_surface: *LockSurface) void {
var surface_it = lock_surface.lock.surfaces.iterator(.forward);
const new_focus: Seat.FocusTarget = while (surface_it.next()) |surface| {
if (surface != lock_surface.wlr_lock_surface)
break .{ .lock_surface = @alignCast(@ptrCast(surface.data)) };
break .{ .lock_surface = @ptrCast(@alignCast(surface.data)) };
} else .none;
var seat_it = server.input_manager.seats.iterator(.forward);
@ -91,7 +91,7 @@ pub fn destroy(lock_surface: *LockSurface) void {
}
pub fn getOutput(lock_surface: *LockSurface) *Output {
return @alignCast(@ptrCast(lock_surface.wlr_lock_surface.output.data));
return @ptrCast(@alignCast(lock_surface.wlr_lock_surface.output.data));
}
pub fn configure(lock_surface: *LockSurface) void {

View File

@ -363,7 +363,7 @@ fn sendLayerConfigures(
var it = tree.children.safeIterator(.forward);
while (it.next()) |node| {
assert(node.type == .tree);
if (@as(?*SceneNodeData, @alignCast(@ptrCast(node.data)))) |node_data| {
if (@as(?*SceneNodeData, @ptrCast(@alignCast(node.data)))) |node_data| {
const layer_surface = node_data.data.layer_surface;
if (!layer_surface.wlr_layer_surface.initialized) continue;

View File

@ -47,7 +47,7 @@ commit: wl.Listener(*wlr.Surface) = wl.Listener(*wlr.Surface).init(handleCommit)
node_destroy: wl.Listener(void) = wl.Listener(void).init(handleNodeDestroy),
pub fn create(wlr_constraint: *wlr.PointerConstraintV1) error{OutOfMemory}!void {
const seat: *Seat = @alignCast(@ptrCast(wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(wlr_constraint.seat.data));
const constraint = try util.gpa.create(PointerConstraint);
errdefer util.gpa.destroy(constraint);
@ -70,7 +70,7 @@ pub fn create(wlr_constraint: *wlr.PointerConstraintV1) error{OutOfMemory}!void
}
pub fn maybeActivate(constraint: *PointerConstraint) void {
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
assert(seat.cursor.constraint == constraint);
@ -102,7 +102,7 @@ pub fn maybeActivate(constraint: *PointerConstraint) void {
/// Called when the cursor position or content in the scene graph changes
pub fn updateState(constraint: *PointerConstraint) void {
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
constraint.maybeActivate();
@ -154,7 +154,7 @@ pub fn confine(constraint: *PointerConstraint, dx: *f64, dy: *f64) void {
}
pub fn deactivate(constraint: *PointerConstraint) void {
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
assert(seat.cursor.constraint == constraint);
assert(constraint.state == .active);
@ -167,7 +167,7 @@ pub fn deactivate(constraint: *PointerConstraint) void {
}
fn warpToHintIfSet(constraint: *PointerConstraint) void {
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
if (constraint.wlr_constraint.current.cursor_hint.enabled) {
var lx: i32 = undefined;
@ -190,7 +190,7 @@ fn handleNodeDestroy(listener: *wl.Listener(void)) void {
fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), _: *wlr.PointerConstraintV1) void {
const constraint: *PointerConstraint = @fieldParentPtr("destroy", listener);
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
if (constraint.state == .active) {
// We can't simply call deactivate() here as it calls sendDeactivated(),
@ -215,7 +215,7 @@ fn handleDestroy(listener: *wl.Listener(*wlr.PointerConstraintV1), _: *wlr.Point
// the surface changes.
fn handleCommit(listener: *wl.Listener(*wlr.Surface), _: *wlr.Surface) void {
const constraint: *PointerConstraint = @fieldParentPtr("commit", listener);
const seat: *Seat = @alignCast(@ptrCast(constraint.wlr_constraint.seat.data));
const seat: *Seat = @ptrCast(@alignCast(constraint.wlr_constraint.seat.data));
switch (constraint.state) {
.active => |state| {

View File

@ -330,7 +330,7 @@ pub fn deactivateOutput(root: *Root, output: *Output) void {
var it = tree.children.safeIterator(.forward);
while (it.next()) |scene_node| {
assert(scene_node.type == .tree);
if (@as(?*SceneNodeData, @alignCast(@ptrCast(scene_node.data)))) |node_data| {
if (@as(?*SceneNodeData, @ptrCast(@alignCast(scene_node.data)))) |node_data| {
node_data.data.layer_surface.wlr_layer_surface.destroy();
}
}
@ -798,7 +798,7 @@ fn processOutputConfig(
var it = config.heads.iterator(.forward);
while (it.next()) |head| {
const wlr_output = head.state.output;
const output: *Output = @alignCast(@ptrCast(wlr_output.data));
const output: *Output = @ptrCast(@alignCast(wlr_output.data));
var proposed_state = wlr.Output.State.init();
head.state.apply(&proposed_state);
@ -837,7 +837,7 @@ fn handlePowerManagerSetMode(
event: *wlr.OutputPowerManagerV1.event.SetMode,
) void {
// The output may have been destroyed, in which case there is nothing to do
const output: *Output = @alignCast(@ptrCast(event.output.data orelse return));
const output: *Output = @ptrCast(@alignCast(event.output.data orelse return));
std.log.debug("client requested dpms {s} for output {s}", .{
@tagName(event.mode),

View File

@ -54,7 +54,7 @@ pub fn attach(node: *wlr.SceneNode, data: Data) error{OutOfMemory}!void {
pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData {
var n = node;
while (true) {
if (@as(?*SceneNodeData, @alignCast(@ptrCast(n.data)))) |scene_node_data| {
if (@as(?*SceneNodeData, @ptrCast(@alignCast(n.data)))) |scene_node_data| {
return scene_node_data;
}
if (n.parent) |parent_tree| {
@ -66,7 +66,7 @@ pub fn fromNode(node: *wlr.SceneNode) ?*SceneNodeData {
}
pub fn fromSurface(surface: *wlr.Surface) ?*SceneNodeData {
if (@as(?*wlr.SceneNode, @alignCast(@ptrCast(surface.getRootSurface().data)))) |node| {
if (@as(?*wlr.SceneNode, @ptrCast(@alignCast(surface.getRootSurface().data)))) |node| {
return fromNode(node);
}
return null;

View File

@ -299,7 +299,7 @@ pub fn setFocusRaw(seat: *Seat, new_focus: FocusTarget) void {
if (seat.cursor.constraint) |constraint| {
assert(constraint.wlr_constraint == wlr_constraint);
} else {
seat.cursor.constraint = @alignCast(@ptrCast(wlr_constraint.data));
seat.cursor.constraint = @ptrCast(@alignCast(wlr_constraint.data));
assert(seat.cursor.constraint != null);
}
}
@ -329,7 +329,7 @@ pub fn keyboardEnterOrLeave(seat: *Seat, target_surface: ?*wlr.Surface) void {
fn keyboardNotifyEnter(seat: *Seat, wlr_surface: *wlr.Surface) void {
if (seat.wlr_seat.getKeyboard()) |wlr_keyboard| {
const keyboard: *Keyboard = @alignCast(@ptrCast(wlr_keyboard.data));
const keyboard: *Keyboard = @ptrCast(@alignCast(wlr_keyboard.data));
var buffer: [Keyboard.Pressed.capacity]u32 = undefined;
var keycodes: std.ArrayList(u32) = .initBuffer(&buffer);

View File

@ -510,7 +510,7 @@ fn handleRequestSetCursorShape(
_: *wl.Listener(*wlr.CursorShapeManagerV1.event.RequestSetShape),
event: *wlr.CursorShapeManagerV1.event.RequestSetShape,
) void {
const seat: *Seat = @alignCast(@ptrCast(event.seat_client.seat.data));
const seat: *Seat = @ptrCast(@alignCast(event.seat_client.seat.data));
if (event.tablet_tool) |wp_tool| {
assert(event.device_type == .tablet_tool);

View File

@ -69,7 +69,7 @@ fn handleRequest(
.get_river_output_status => |req| {
// ignore if the output is inert
const wlr_output = wlr.Output.fromWlOutput(req.output) orelse return;
const output: *Output = @alignCast(@ptrCast(wlr_output.data));
const output: *Output = @ptrCast(@alignCast(wlr_output.data));
const resource = zriver.OutputStatusV1.create(
status_manager_v1.getClient(),
@ -86,7 +86,7 @@ fn handleRequest(
.get_river_seat_status => |req| {
// ignore if the seat is inert
const wlr_seat = wlr.Seat.Client.fromWlSeat(req.seat) orelse return;
const seat: *Seat = @alignCast(@ptrCast(wlr_seat.seat.data));
const seat: *Seat = @ptrCast(@alignCast(wlr_seat.seat.data));
const seat_status = zriver.SeatStatusV1.create(
status_manager_v1.getClient(),

View File

@ -59,7 +59,7 @@ set_cursor: wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor) =
wl.Listener(*wlr.TabletV2TabletTool.event.SetCursor).init(handleSetCursor),
pub fn get(wlr_seat: *wlr.Seat, wlr_tool: *wlr.TabletTool) error{OutOfMemory}!*TabletTool {
if (@as(?*TabletTool, @alignCast(@ptrCast(wlr_tool.data)))) |tool| {
if (@as(?*TabletTool, @ptrCast(@alignCast(wlr_tool.data)))) |tool| {
return tool;
} else {
return TabletTool.create(wlr_seat, wlr_tool);

View File

@ -43,7 +43,7 @@ destroy: wl.Listener(*wlr.TextInputV3) =
wl.Listener(*wlr.TextInputV3).init(handleDestroy),
pub fn create(wlr_text_input: *wlr.TextInputV3) !void {
const seat: *Seat = @alignCast(@ptrCast(wlr_text_input.seat.data));
const seat: *Seat = @ptrCast(@alignCast(wlr_text_input.seat.data));
const text_input = try util.gpa.create(TextInput);
@ -64,7 +64,7 @@ pub fn create(wlr_text_input: *wlr.TextInputV3) !void {
fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void {
const text_input: *TextInput = @fieldParentPtr("enable", listener);
const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data));
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
if (text_input.wlr_text_input.focused_surface == null) {
log.err("client requested to enable text input without focus, ignoring request", .{});
@ -91,7 +91,7 @@ fn handleEnable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v
fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void {
const text_input: *TextInput = @fieldParentPtr("commit", listener);
const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data));
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
if (seat.relay.text_input != text_input) {
log.err("inactive text input tried to commit an update, client bug?", .{});
@ -105,7 +105,7 @@ fn handleCommit(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) v
fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void {
const text_input: *TextInput = @fieldParentPtr("disable", listener);
const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data));
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
if (seat.relay.text_input == text_input) {
seat.relay.disableTextInput();
@ -114,7 +114,7 @@ fn handleDisable(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3)
fn handleDestroy(listener: *wl.Listener(*wlr.TextInputV3), _: *wlr.TextInputV3) void {
const text_input: *TextInput = @fieldParentPtr("destroy", listener);
const seat: *Seat = @alignCast(@ptrCast(text_input.wlr_text_input.seat.data));
const seat: *Seat = @ptrCast(@alignCast(text_input.wlr_text_input.seat.data));
if (seat.relay.text_input == text_input) {
seat.relay.disableTextInput();

View File

@ -595,7 +595,7 @@ pub fn allowTearing(view: *View) bool {
.window_hint => {
if (server.config.allow_tearing) {
if (view.rootSurface()) |root_surface| {
return server.tearing_control_manager.hintFromSurface(root_surface) == .@"async";
return server.tearing_control_manager.hintFromSurface(root_surface) == .async;
}
}
return false;

View File

@ -34,7 +34,7 @@ request_mode: wl.Listener(*wlr.XdgToplevelDecorationV1) =
wl.Listener(*wlr.XdgToplevelDecorationV1).init(handleRequestMode),
pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void {
const toplevel: *XdgToplevel = @alignCast(@ptrCast(wlr_decoration.toplevel.base.data));
const toplevel: *XdgToplevel = @ptrCast(@alignCast(wlr_decoration.toplevel.base.data));
toplevel.decoration = .{ .wlr_decoration = wlr_decoration };
const decoration = &toplevel.decoration.?;
@ -48,7 +48,7 @@ pub fn init(wlr_decoration: *wlr.XdgToplevelDecorationV1) void {
}
pub fn deinit(decoration: *XdgDecoration) void {
const toplevel: *XdgToplevel = @alignCast(@ptrCast(decoration.wlr_decoration.toplevel.base.data));
const toplevel: *XdgToplevel = @ptrCast(@alignCast(decoration.wlr_decoration.toplevel.base.data));
decoration.destroy.link.remove();
decoration.request_mode.link.remove();
@ -72,7 +72,7 @@ fn handleRequestMode(
) void {
const decoration: *XdgDecoration = @fieldParentPtr("request_mode", listener);
const toplevel: *XdgToplevel = @alignCast(@ptrCast(decoration.wlr_decoration.toplevel.base.data));
const toplevel: *XdgToplevel = @ptrCast(@alignCast(decoration.wlr_decoration.toplevel.base.data));
const view = toplevel.view;
const ssd = server.config.rules.ssd.match(toplevel.view) orelse

View File

@ -423,7 +423,7 @@ fn handleRequestMove(
event: *wlr.XdgToplevel.event.Move,
) void {
const toplevel: *XdgToplevel = @fieldParentPtr("request_move", listener);
const seat: *Seat = @alignCast(@ptrCast(event.seat.seat.data));
const seat: *Seat = @ptrCast(@alignCast(event.seat.seat.data));
const view = toplevel.view;
if (view.pending.fullscreen) return;
@ -446,7 +446,7 @@ fn handleRequestMove(
fn handleRequestResize(listener: *wl.Listener(*wlr.XdgToplevel.event.Resize), event: *wlr.XdgToplevel.event.Resize) void {
const toplevel: *XdgToplevel = @fieldParentPtr("request_resize", listener);
const seat: *Seat = @alignCast(@ptrCast(event.seat.seat.data));
const seat: *Seat = @ptrCast(@alignCast(event.seat.seat.data));
const view = toplevel.view;
if (view.pending.fullscreen) return;

View File

@ -121,7 +121,7 @@ fn getOutput(seat: *Seat, str: []const u8) !?*Output {
@floatFromInt(focus_box.x + @divTrunc(focus_box.width, 2)),
@floatFromInt(focus_box.y + @divTrunc(focus_box.height, 2)),
) orelse return null;
return @alignCast(@ptrCast(wlr_output.data));
return @ptrCast(@alignCast(wlr_output.data));
} else {
// Check if an output matches by name
var it = server.root.active_outputs.iterator(.forward);