diff --git a/packages/xcb/sample/root.zig b/packages/xcb/sample/root.zig index e745dd7..76e71a6 100644 --- a/packages/xcb/sample/root.zig +++ b/packages/xcb/sample/root.zig @@ -30,24 +30,26 @@ pub fn main(init: std.process.Init) !void { 1, .INPUT_OUTPUT, screen.root_visual, - .{ - .BACK_PIXEL = true, - }, - &[_]u32{ - screen.black_pixel, - }, + .{ .BACK_PIXEL = true }, + &[_]u32{screen.black_pixel}, ); const wm_protocols_atom_cookie = connection.internAtom(true, "WM_PROTOCOLS"); const wm_delete_window_atom_cookie = connection.internAtom(false, "WM_DELETE_WINDOW"); - const wm_protocols_atom_reply = connection.internAtomReply(wm_protocols_atom_cookie, null) orelse return error.XcbInternAtom; - defer std.c.free(wm_protocols_atom_reply); - const wm_protocols_atom = wm_protocols_atom_reply.atom; + const wm_protocols_atom = blk: { + const reply = connection.internAtomReply(wm_protocols_atom_cookie, null) orelse return error.XcbInternAtom; + const ret = reply.atom; + std.c.free(reply); + break :blk ret; + }; - const wm_delete_window_atom_reply = connection.internAtomReply(wm_delete_window_atom_cookie, null) orelse return error.XcbInternAtom; - defer std.c.free(wm_delete_window_atom_reply); - const wm_delete_window_atom = wm_delete_window_atom_reply.atom; + const wm_delete_window_atom = blk: { + const reply = connection.internAtomReply(wm_delete_window_atom_cookie, null) orelse return error.XcbInternAtom; + const ret = reply.atom; + std.c.free(reply); + break :blk ret; + }; _ = connection.changeProperty( .REPLACE, @@ -70,7 +72,7 @@ pub fn main(init: std.process.Init) !void { switch (event.response_type & ~@as(u8, 0x80)) { xcb.CLIENT_MESSAGE => { const client_message_event = @as(*xcb.ClientMessageEvent, @ptrCast(event)); - if (client_message_event.data.data32[0] == @intFromEnum(wm_delete_window_atom_reply.atom)) { + if (client_message_event.data.data32[0] == @intFromEnum(wm_delete_window_atom)) { running = false; } }, diff --git a/packages/xcb/src/root.zig b/packages/xcb/src/root.zig index c9e4858..784297c 100644 --- a/packages/xcb/src/root.zig +++ b/packages/xcb/src/root.zig @@ -26,27 +26,27 @@ pub const Connection = opaque { return import.xcb_create_window(c, depth, wid, parent, x, y, width, height, border_width, _class, visual, value_mask, value_list); } - pub inline fn createWindowAuxChecked(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: [*c]const CreateWindowValueList) VoidCookie { + pub inline fn createWindowAuxChecked(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: *const CreateWindowValueList) VoidCookie { return import.xcb_create_window_aux_checked(c, depth, wid, parent, x, y, width, height, border_width, _class, visual, value_mask, value_list); } - pub inline fn createWindowAux(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: [*c]const CreateWindowValueList) VoidCookie { + pub inline fn createWindowAux(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: *const CreateWindowValueList) VoidCookie { return import.xcb_create_window_aux(c, depth, wid, parent, x, y, width, height, border_width, _class, visual, value_mask, value_list); } - pub inline fn changeWindowAttributesChecked(c: *Connection, window: Window, value_mask: u32, value_list: ?*const anyopaque) VoidCookie { + pub inline fn changeWindowAttributesChecked(c: *Connection, window: Window, value_mask: Cw, value_list: ?*const anyopaque) VoidCookie { return import.xcb_change_window_attributes_checked(c, window, value_mask, value_list); } - pub inline fn changeWindowAttributes(c: *Connection, window: Window, value_mask: u32, value_list: ?*const anyopaque) VoidCookie { + pub inline fn changeWindowAttributes(c: *Connection, window: Window, value_mask: Cw, value_list: ?*const anyopaque) VoidCookie { return import.xcb_change_window_attributes(c, window, value_mask, value_list); } - pub inline fn changeWindowAttributesAuxChecked(c: *Connection, window: Window, value_mask: u32, value_list: [*c]const ChangeWindowAttributesValueList) VoidCookie { + pub inline fn changeWindowAttributesAuxChecked(c: *Connection, window: Window, value_mask: Cw, value_list: *const ChangeWindowAttributesValueList) VoidCookie { return import.xcb_change_window_attributes_aux_checked(c, window, value_mask, value_list); } - pub inline fn changeWindowAttributesAux(c: *Connection, window: Window, value_mask: u32, value_list: [*c]const ChangeWindowAttributesValueList) VoidCookie { + pub inline fn changeWindowAttributesAux(c: *Connection, window: Window, value_mask: Cw, value_list: *const ChangeWindowAttributesValueList) VoidCookie { return import.xcb_change_window_attributes_aux(c, window, value_mask, value_list); } @@ -126,19 +126,19 @@ pub const Connection = opaque { return import.xcb_unmap_subwindows(c, window); } - pub inline fn configureWindowChecked(c: *Connection, window: Window, value_mask: u16, value_list: ?*const anyopaque) VoidCookie { + pub inline fn configureWindowChecked(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: ?*const anyopaque) VoidCookie { return import.xcb_configure_window_checked(c, window, value_mask, value_list); } - pub inline fn configureWindow(c: *Connection, window: Window, value_mask: u16, value_list: ?*const anyopaque) VoidCookie { + pub inline fn configureWindow(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: ?*const anyopaque) VoidCookie { return import.xcb_configure_window(c, window, value_mask, value_list); } - pub inline fn configureWindowAuxChecked(c: *Connection, window: Window, value_mask: u16, value_list: [*c]const ConfigureWindowValueList) VoidCookie { + pub inline fn configureWindowAuxChecked(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: *const ConfigureWindowValueList) VoidCookie { return import.xcb_configure_window_aux_checked(c, window, value_mask, value_list); } - pub inline fn configureWindowAux(c: *Connection, window: Window, value_mask: u16, value_list: [*c]const ConfigureWindowValueList) VoidCookie { + pub inline fn configureWindowAux(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: *const ConfigureWindowValueList) VoidCookie { return import.xcb_configure_window_aux(c, window, value_mask, value_list); } @@ -2496,7 +2496,7 @@ pub const SetMode = enum(c_uint) { _, }; -pub const ConfigWindow = packed struct(c_uint) { +pub const ConfigWindow = packed struct(u16) { X: bool = false, Y: bool = false, WIDTH: bool = false, @@ -2504,7 +2504,7 @@ pub const ConfigWindow = packed struct(c_uint) { BORDER_WIDTH: bool = false, SIBLING: bool = false, STACK_MODE: bool = false, - _pad7: u25 = 0, + _pad7: u9 = 0, }; pub const StackMode = enum(c_uint) { @@ -3958,10 +3958,10 @@ pub const import = struct { pub extern fn xcb_create_window(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: ?*const anyopaque) VoidCookie; pub extern fn xcb_create_window_aux_checked(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: *const CreateWindowValueList) VoidCookie; pub extern fn xcb_create_window_aux(c: *Connection, depth: u8, wid: Window, parent: Window, x: i16, y: i16, width: u16, height: u16, border_width: u16, _class: WindowClass, visual: Visualid, value_mask: Cw, value_list: *const CreateWindowValueList) VoidCookie; - pub extern fn xcb_change_window_attributes_checked(c: *Connection, window: Window, value_mask: u32, value_list: ?*const anyopaque) VoidCookie; - pub extern fn xcb_change_window_attributes(c: *Connection, window: Window, value_mask: u32, value_list: ?*const anyopaque) VoidCookie; - pub extern fn xcb_change_window_attributes_aux_checked(c: *Connection, window: Window, value_mask: u32, value_list: [*c]const ChangeWindowAttributesValueList) VoidCookie; - pub extern fn xcb_change_window_attributes_aux(c: *Connection, window: Window, value_mask: u32, value_list: [*c]const ChangeWindowAttributesValueList) VoidCookie; + pub extern fn xcb_change_window_attributes_checked(c: *Connection, window: Window, value_mask: Cw, value_list: ?*const anyopaque) VoidCookie; + pub extern fn xcb_change_window_attributes(c: *Connection, window: Window, value_mask: Cw, value_list: ?*const anyopaque) VoidCookie; + pub extern fn xcb_change_window_attributes_aux_checked(c: *Connection, window: Window, value_mask: Cw, value_list: *const ChangeWindowAttributesValueList) VoidCookie; + pub extern fn xcb_change_window_attributes_aux(c: *Connection, window: Window, value_mask: Cw, value_list: *const ChangeWindowAttributesValueList) VoidCookie; pub extern fn xcb_get_window_attributes(c: *Connection, window: Window) GetWindowAttributesCookie; pub extern fn xcb_get_window_attributes_unchecked(c: *Connection, window: Window) GetWindowAttributesCookie; pub extern fn xcb_get_window_attributes_reply(c: *Connection, cookie: GetWindowAttributesCookie, e: ?*?*GenericError) ?*GetWindowAttributesReply; @@ -3981,10 +3981,10 @@ pub const import = struct { pub extern fn xcb_unmap_window(c: *Connection, window: Window) VoidCookie; pub extern fn xcb_unmap_subwindows_checked(c: *Connection, window: Window) VoidCookie; pub extern fn xcb_unmap_subwindows(c: *Connection, window: Window) VoidCookie; - pub extern fn xcb_configure_window_checked(c: *Connection, window: Window, value_mask: u16, value_list: ?*const anyopaque) VoidCookie; - pub extern fn xcb_configure_window(c: *Connection, window: Window, value_mask: u16, value_list: ?*const anyopaque) VoidCookie; - pub extern fn xcb_configure_window_aux_checked(c: *Connection, window: Window, value_mask: u16, value_list: [*c]const ConfigureWindowValueList) VoidCookie; - pub extern fn xcb_configure_window_aux(c: *Connection, window: Window, value_mask: u16, value_list: [*c]const ConfigureWindowValueList) VoidCookie; + pub extern fn xcb_configure_window_checked(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: ?*const anyopaque) VoidCookie; + pub extern fn xcb_configure_window(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: ?*const anyopaque) VoidCookie; + pub extern fn xcb_configure_window_aux_checked(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: *const ConfigureWindowValueList) VoidCookie; + pub extern fn xcb_configure_window_aux(c: *Connection, window: Window, value_mask: ConfigWindow, value_list: *const ConfigureWindowValueList) VoidCookie; pub extern fn xcb_circulate_window_checked(c: *Connection, direction: u8, window: Window) VoidCookie; pub extern fn xcb_circulate_window(c: *Connection, direction: u8, window: Window) VoidCookie; pub extern fn xcb_get_geometry(c: *Connection, drawable: Drawable) GetGeometryCookie;