From b55bcb3050cf603d7dd68a00f266cdd136d3c473 Mon Sep 17 00:00:00 2001 From: Peterino2 Date: Mon, 21 Sep 2026 09:58:51 -0700 Subject: [PATCH] more aggressive formatting changes --- src/EventPayload.zig | 35 +++++++++++++++++++++++++++++++---- src/api/windows.zig | 27 +++++++++++++++------------ src/linux/Bitmap.zig | 10 +++++++++- src/linux/Data.zig | 7 ++++++- src/linux/Popup.zig | 7 ++++++- src/linux/Text.zig | 5 ++++- 6 files changed, 71 insertions(+), 20 deletions(-) diff --git a/src/EventPayload.zig b/src/EventPayload.zig index b559d7a..27a27ff 100644 --- a/src/EventPayload.zig +++ b/src/EventPayload.zig @@ -2,7 +2,10 @@ const std = @import("std"); const c = @import("native"); const abi = @import("abi.zig"); -const Data = struct { ptr: ?*const anyopaque = null, size: u64 = 0 }; +const Data = struct { + ptr: ?*const anyopaque = null, + size: u64 = 0, +}; fn store(comptime T: type, allocator: std.mem.Allocator, value: T) !Data { const ptr = try allocator.create(T); @@ -25,7 +28,18 @@ fn result(allocator: std.mem.Allocator, source: c.z_request_result) !c.uhdk_requ c.UHDK_REQUEST_WATCH => try store(c.uhdk_watch_result, allocator, .{ .watch = source.value.watch }), else => .{}, }; - return .{ .tag = source.tag, .kind = source.kind, .status = source.status, .diagnostic = if (source.status != abi.OK and source.diagnostic.len == 0) abi.statusMessage(source.status) else try abi.copyText(allocator, source.diagnostic), .data = data.ptr, .data_size = data.size }; + return .{ + .tag = source.tag, + .kind = source.kind, + .status = source.status, + .diagnostic = if (source.status != abi.OK + and source.diagnostic.len == 0) + abi.statusMessage(source.status) + else + try abi.copyText(allocator, source.diagnostic), + .data = data.ptr, + .data_size = data.size, + }; } pub fn pack(allocator: std.mem.Allocator, source: c.z_event) !c.uhdk_event { @@ -35,7 +49,11 @@ pub fn pack(allocator: std.mem.Allocator, source: c.z_event) !c.uhdk_event { c.UHDK_EVENT_WINDOW_METRICS => try store(c.uhdk_window_metrics, allocator, source.data.metrics), c.UHDK_EVENT_PREFERENCES_CHANGED => try store(c.uhdk_preferences, allocator, source.data.preferences), c.UHDK_EVENT_KEY => try store(c.uhdk_key_event, allocator, source.data.key), - c.UHDK_EVENT_POINTER_ENTER, c.UHDK_EVENT_POINTER_LEAVE, c.UHDK_EVENT_POINTER_MOVE, c.UHDK_EVENT_POINTER_BUTTON => try store(c.uhdk_pointer_event, allocator, source.data.pointer), + c.UHDK_EVENT_POINTER_ENTER, + c.UHDK_EVENT_POINTER_LEAVE, + c.UHDK_EVENT_POINTER_MOVE, + c.UHDK_EVENT_POINTER_BUTTON, + => try store(c.uhdk_pointer_event, allocator, source.data.pointer), c.UHDK_EVENT_POINTER_MODE_CHANGED => try store(c.uhdk_pointer_mode_event, allocator, .{ .mode = source.data.pointer_mode }), c.UHDK_EVENT_SCROLL => try store(c.uhdk_scroll_event, allocator, source.data.scroll), c.UHDK_EVENT_TEXT_COMMIT, c.UHDK_EVENT_TEXT_PREEDIT => data: { @@ -55,5 +73,14 @@ pub fn pack(allocator: std.mem.Allocator, source: c.z_event) !c.uhdk_event { c.UHDK_EVENT_REQUEST_DONE => try store(c.uhdk_request_result, allocator, try result(allocator, source.data.request)), else => .{}, }; - return .{ .struct_size = @sizeOf(c.uhdk_event), .type = source.type, .time_ns = source.time_ns, .input_id = source.input_id, .cycle_id = source.cycle_id, .window = source.window, .data = data.ptr, .data_size = data.size }; + return .{ + .struct_size = @sizeOf(c.uhdk_event), + .type = source.type, + .time_ns = source.time_ns, + .input_id = source.input_id, + .cycle_id = source.cycle_id, + .window = source.window, + .data = data.ptr, + .data_size = data.size, + }; } diff --git a/src/api/windows.zig b/src/api/windows.zig index e651aa9..dc86306 100644 --- a/src/api/windows.zig +++ b/src/api/windows.zig @@ -12,18 +12,21 @@ pub fn queueCreate( if (handle == null or !abi.validDescriptor(c.z_window_desc, desc)) return abi.INVALID; if (out == null) return abi.INVALID; const d = desc.*; - if (!validStyle(&d.style) or - !abi.validText(d.title, true) or - !abi.finiteSize(d.content_size) or - d.content_size.width == 0 or - d.content_size.height == 0 or - !abi.finiteSize(d.min_size) or - !abi.finiteSize(d.max_size) or - d.flags & ~@as(u32, c.Z_WINDOW_OPENGL) != 0) return abi.INVALID; - if ((d.max_size.width != 0 and d.max_size.width < d.min_size.width) or - (d.max_size.height != 0 and d.max_size.height < d.min_size.height)) return abi.INVALID; - if (d.parent != null and (runtime.fromObjectHandle(d.parent).app != runtime.fromAppHandle(handle) or - !runtime.fromObjectHandle(d.parent).alive)) return abi.INVALID; + if (!validStyle(&d.style) + or !abi.validText(d.title, true) + or !abi.finiteSize(d.content_size) + or d.content_size.width == 0 + or d.content_size.height == 0 + or !abi.finiteSize(d.min_size) + or !abi.finiteSize(d.max_size) + or d.flags & ~@as(u32, c.Z_WINDOW_OPENGL) != 0) return abi.INVALID; + if ((d.max_size.width != 0 + and d.max_size.width < d.min_size.width) + or (d.max_size.height != 0 + and d.max_size.height < d.min_size.height)) return abi.INVALID; + if (d.parent != null + and (runtime.fromObjectHandle(d.parent).app != runtime.fromAppHandle(handle) + or !runtime.fromObjectHandle(d.parent).alive)) return abi.INVALID; const command = runtime.createAppCommand(handle, c.Z_WINDOW) catch |err| return runtime.applicationError(err); const object = runtime.createObject(runtime.fromAppHandle(handle), c.Z_KIND_WINDOW) catch { runtime.abandon(command); diff --git a/src/linux/Bitmap.zig b/src/linux/Bitmap.zig index bcad1e4..63fcd1f 100644 --- a/src/linux/Bitmap.zig +++ b/src/linux/Bitmap.zig @@ -7,7 +7,15 @@ fn word(offset: usize) u16 { } const count = word(4); const fallback = word(6); -const Glyph = struct { offset: usize, packed_size: usize, width: u8, height: u8, x: i8, y: i8, advance: u8 }; +const Glyph = struct { + offset: usize, + packed_size: usize, + width: u8, + height: u8, + x: i8, + y: i8, + advance: u8, +}; fn record(index: usize) Glyph { const offset = 8 + index * 12; return .{ diff --git a/src/linux/Data.zig b/src/linux/Data.zig index 00241f9..2e4d890 100644 --- a/src/linux/Data.zig +++ b/src/linux/Data.zig @@ -17,7 +17,12 @@ const Offer = struct { actions: u32 = 0, action: u32 = 0, }; -const Source = struct { next: ?*Source = null, proxy: ?*c.struct_wl_data_source, bytes: []u8, refs: usize = 1 }; +const Source = struct { + next: ?*Source = null, + proxy: ?*c.struct_wl_data_source, + bytes: []u8, + refs: usize = 1, +}; const Transfer = struct { next: ?*Transfer = null, fd: c_int, diff --git a/src/linux/Popup.zig b/src/linux/Popup.zig index 5855c26..8bdb6c8 100644 --- a/src/linux/Popup.zig +++ b/src/linux/Popup.zig @@ -10,7 +10,12 @@ const abi = @import("../abi.zig"); const Input = @import("Input.zig"); const Menu = @import("Menu.zig"); const Bitmap = @import("Bitmap.zig"); -const Buffer = struct { proxy: ?*c.struct_wl_buffer = null, mapping: ?*anyopaque = null, size: usize = 0, busy: bool = false }; +const Buffer = struct { + proxy: ?*c.struct_wl_buffer = null, + mapping: ?*anyopaque = null, + size: usize = 0, + busy: bool = false, +}; const Panel = struct { parent: ?*Panel, menu: *Resource, diff --git a/src/linux/Text.zig b/src/linux/Text.zig index cc28d13..761756c 100644 --- a/src/linux/Text.zig +++ b/src/linux/Text.zig @@ -146,7 +146,10 @@ fn done(_: ?*anyopaque, _: ?*c.struct_zwp_text_input_v3, serial: u32) callconv(. } const listener: c.struct_zwp_text_input_v3_listener = .{ .enter = enter, .leave = leave, .preedit_string = preedit, .commit_string = committed, .delete_surrounding_text = deleted, .done = done }; -pub fn crop(bytes: []const u8, start: usize, length: usize) ?struct { start: usize, end: usize } { +pub fn crop(bytes: []const u8, start: usize, length: usize) ?struct { + start: usize, + end: usize, +} { if (length > 4000 or std.mem.findScalar(u8, bytes, 0) != null) return null; var lo = start -| ((4000 - length) / 2); while (lo < start and !abi.boundary(bytes, lo)) lo += 1;