From a6f67d3f0d3777858492a1db444f1e59af13bd55 Mon Sep 17 00:00:00 2001 From: Szymon Nowakowski Date: Fri, 9 Jan 2026 16:08:48 +0100 Subject: [PATCH] X11 library (WIP) --- castle.code-workspace | 23 +- packages/x11/build.zig | 9 + packages/x11/build.zig.zon | 11 + packages/x11/src/root.zig | 2842 ++++++++++++++++++++++++++++++++++++ 4 files changed, 2880 insertions(+), 5 deletions(-) create mode 100644 packages/x11/build.zig create mode 100644 packages/x11/build.zig.zon create mode 100644 packages/x11/src/root.zig diff --git a/castle.code-workspace b/castle.code-workspace index ec6b34e..317d61f 100644 --- a/castle.code-workspace +++ b/castle.code-workspace @@ -1,10 +1,23 @@ { "folders": [ - { "path": "packages/js" }, - { "path": "packages/media" }, - { "path": "packages/myid" }, - { "path": "packages/sciter" }, - { "path": "packages/vecmath" }, + { + "path": "packages/js" + }, + { + "path": "packages/media" + }, + { + "path": "packages/myid" + }, + { + "path": "packages/sciter" + }, + { + "path": "packages/vecmath" + }, + { + "path": "packages/x11" + } ], "settings": { "files.exclude": { diff --git a/packages/x11/build.zig b/packages/x11/build.zig new file mode 100644 index 0000000..53e12ea --- /dev/null +++ b/packages/x11/build.zig @@ -0,0 +1,9 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const mod = b.addModule("x11", .{ + .root_source_file = b.path("src/root.zig"), + }); + + mod.linkSystemLibrary("X11", .{}); +} diff --git a/packages/x11/build.zig.zon b/packages/x11/build.zig.zon new file mode 100644 index 0000000..23baa78 --- /dev/null +++ b/packages/x11/build.zig.zon @@ -0,0 +1,11 @@ +.{ + .name = .x11, + .version = "0.0.0", + .minimum_zig_version = "0.15.2", + .paths = .{ + "src", + "build.zig", + "build.zig.zon", + }, + .fingerprint = 0x3220e772d0ef0e80, +} diff --git a/packages/x11/src/root.zig b/packages/x11/src/root.zig new file mode 100644 index 0000000..f54d8b9 --- /dev/null +++ b/packages/x11/src/root.zig @@ -0,0 +1,2842 @@ +const std = @import("std"); + +// --- MARK: X.h + +pub const XID = enum(u64) { + None = 0, + _, + + /// special Resource ID passed to KillClient + pub const AllTemporary: XID = @intFromEnum(0); + + pub inline fn asWindow(self: XID) Window { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asDrawable(self: XID) Drawable { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asFont(self: XID) Font { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asPixmap(self: XID) Pixmap { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asCursor(self: XID) Cursor { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asColormap(self: XID) Colormap { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asGContext(self: XID) GContext { + return @enumFromInt(@intFromEnum(self)); + } + + pub inline fn asKeySym(self: XID) KeySym { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Mask = enum(u64) { + None = 0, + _, +}; + +pub const Atom = enum(u64) { + None = 0, + _, + + /// special Atom, passed to GetProperty + pub const AnyPropertyType: Atom = @intFromEnum(0); +}; + +pub const VisualID = enum(u64) { + None = 0, + _, + + /// special VisualID passed to CreateWindow + pub const CopyFromParent: VisualID = @intFromEnum(0); +}; + +pub const Time = enum(u64) { + None = 0, + _, + + /// special Time + pub const CurrentTime: Time = @intFromEnum(0); +}; + +pub const Window = enum(u64) { + None = 0, + _, + + /// destination window in SendEvent + pub const PointerWindow: Window = @intFromEnum(0); + /// destination window in SendEvent + pub const InputFocus: Window = @intFromEnum(1); + /// focus window in SetInputFocus + pub const PointerRoot: Window = @intFromEnum(1); + + pub inline fn asXID(self: Window) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Drawable = enum(u64) { + None = 0, + _, + + pub inline fn asXID(self: Drawable) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Font = enum(u64) { + None = 0, + _, + + pub inline fn asXID(self: Font) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Pixmap = enum(u64) { + None = 0, + _, + + /// background pixmap in CreateWindow and ChangeWindowAttributes + pub const CopyFromParent: Pixmap = @intFromEnum(0); + /// border pixmap in CreateWindow and ChangeWindowAttributes + pub const ParentRelative: Pixmap = @intFromEnum(1); + + pub inline fn asXID(self: Pixmap) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Cursor = enum(u64) { + None = 0, + _, + + pub inline fn asXID(self: Cursor) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const Colormap = enum(u64) { + None = 0, + _, + + pub inline fn asXID(self: Colormap) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const GContext = enum(u64) { + None = 0, + _, + + pub inline fn asXID(self: GContext) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const KeySym = enum(u64) { + None = 0, + _, + + pub const NoSymbol: KeySym = @intFromEnum(0); + + pub inline fn asXID(self: KeySym) XID { + return @enumFromInt(@intFromEnum(self)); + } +}; + +pub const KeyCode = enum(u8) { + None = 0, + _, + + /// special Key Code, passed to GrabKey + pub const AnyKey: KeyCode = @intFromEnum(0); +}; + +/// Input Event Masks. Used as event-mask window attribute and as arguments to +/// Grab requests. Not to be confused with event names. +pub const EventMask = packed struct(i64) { + pub const no_event: EventMask = .{}; + + key_press: bool = false, + key_release: bool = false, + button_press: bool = false, + button_release: bool = false, + enter_window: bool = false, + leave_window: bool = false, + pointer_motion: bool = false, + pointer_motion_hint: bool = false, + button1_motion: bool = false, + button2_motion: bool = false, + button3_motion: bool = false, + button4_motion: bool = false, + button5_motion: bool = false, + button_motion: bool = false, + keymap_state: bool = false, + exposure: bool = false, + visibility_change: bool = false, + structure_notify: bool = false, + resize_redirect: bool = false, + substructure_notify: bool = false, + substructure_redirect: bool = false, + focus_change: bool = false, + property_change: bool = false, + colormap_change: bool = false, + owner_grab_button: bool = false, + + _pad25: u39 = 0, +}; + +/// Event names. Used in "type" field in XEvent structures. Not to be confused +/// with event masks above. They start from 2 because 0 and 1 are reserved in +/// the protocol for errors and replies. +pub const EventType = enum(i32) { + KeyPress = 2, + KeyRelease = 3, + ButtonPress = 4, + ButtonRelease = 5, + MotionNotify = 6, + EnterNotify = 7, + LeaveNotify = 8, + FocusIn = 9, + FocusOut = 10, + KeymapNotify = 11, + Expose = 12, + GraphicsExpose = 13, + NoExpose = 14, + VisibilityNotify = 15, + CreateNotify = 16, + DestroyNotify = 17, + UnmapNotify = 18, + MapNotify = 19, + MapRequest = 20, + ReparentNotify = 21, + ConfigureNotify = 22, + ConfigureRequest = 23, + GravityNotify = 24, + ResizeRequest = 25, + CirculateNotify = 26, + CirculateRequest = 27, + PropertyNotify = 28, + SelectionClear = 29, + SelectionRequest = 30, + SelectionNotify = 31, + ColormapNotify = 32, + ClientMessage = 33, + MappingNotify = 34, + GenericEvent = 35, + _, + + /// must be bigger than any event # + pub const LASTEvent: EventType = @intFromEnum(36); +}; + +pub const ShiftMask = @as(i32, 1) << @as(i32, 0); +pub const LockMask = @as(i32, 1) << @as(i32, 1); +pub const ControlMask = @as(i32, 1) << @as(i32, 2); +pub const Mod1Mask = @as(i32, 1) << @as(i32, 3); +pub const Mod2Mask = @as(i32, 1) << @as(i32, 4); +pub const Mod3Mask = @as(i32, 1) << @as(i32, 5); +pub const Mod4Mask = @as(i32, 1) << @as(i32, 6); +pub const Mod5Mask = @as(i32, 1) << @as(i32, 7); + +pub const ShiftMapIndex = @as(i32, 0); +pub const LockMapIndex = @as(i32, 1); +pub const ControlMapIndex = @as(i32, 2); +pub const Mod1MapIndex = @as(i32, 3); +pub const Mod2MapIndex = @as(i32, 4); +pub const Mod3MapIndex = @as(i32, 5); +pub const Mod4MapIndex = @as(i32, 6); +pub const Mod5MapIndex = @as(i32, 7); + +pub const Button1Mask = @as(i32, 1) << @as(i32, 8); +pub const Button2Mask = @as(i32, 1) << @as(i32, 9); +pub const Button3Mask = @as(i32, 1) << @as(i32, 10); +pub const Button4Mask = @as(i32, 1) << @as(i32, 11); +pub const Button5Mask = @as(i32, 1) << @as(i32, 12); +pub const AnyModifier = @as(i32, 1) << @as(i32, 15); + +pub const Button1 = @as(i32, 1); +pub const Button2 = @as(i32, 2); +pub const Button3 = @as(i32, 3); +pub const Button4 = @as(i32, 4); +pub const Button5 = @as(i32, 5); + +pub const NotifyNormal = @as(i32, 0); +pub const NotifyGrab = @as(i32, 1); +pub const NotifyUngrab = @as(i32, 2); +pub const NotifyWhileGrabbed = @as(i32, 3); +pub const NotifyHint = @as(i32, 1); + +pub const NotifyAncestor = @as(i32, 0); +pub const NotifyVirtual = @as(i32, 1); +pub const NotifyInferior = @as(i32, 2); +pub const NotifyNonlinear = @as(i32, 3); +pub const NotifyNonlinearVirtual = @as(i32, 4); +pub const NotifyPointer = @as(i32, 5); +pub const NotifyPointerRoot = @as(i32, 6); +pub const NotifyDetailNone = @as(i32, 7); + +pub const VisibilityUnobscured = @as(i32, 0); +pub const VisibilityPartiallyObscured = @as(i32, 1); +pub const VisibilityFullyObscured = @as(i32, 2); + +pub const PlaceOnTop = @as(i32, 0); +pub const PlaceOnBottom = @as(i32, 1); + +pub const Family = enum(i32) { + /// IPv4 + FamilyInternet = 0, + FamilyDECnet = 1, + FamilyChaos = 2, + /// authentication families not tied to a specific protocol + FamilyServerInterpreted = 5, + /// IPv6 + FamilyInternet6 = 6, + _, +}; + +pub const PropertyNewValue = @as(i32, 0); +pub const PropertyDelete = @as(i32, 1); + +pub const ColormapUninstalled = @as(i32, 0); +pub const ColormapInstalled = @as(i32, 1); + +pub const GrabModeSync = @as(i32, 0); +pub const GrabModeAsync = @as(i32, 1); + +pub const GrabSuccess = @as(i32, 0); +pub const AlreadyGrabbed = @as(i32, 1); +pub const GrabInvalidTime = @as(i32, 2); +pub const GrabNotViewable = @as(i32, 3); +pub const GrabFrozen = @as(i32, 4); + +pub const AsyncPointer = @as(i32, 0); +pub const SyncPointer = @as(i32, 1); +pub const ReplayPointer = @as(i32, 2); +pub const AsyncKeyboard = @as(i32, 3); +pub const SyncKeyboard = @as(i32, 4); +pub const ReplayKeyboard = @as(i32, 5); +pub const AsyncBoth = @as(i32, 6); +pub const SyncBoth = @as(i32, 7); + +pub const RevertToNone = @as(i32, 0); +pub const RevertToPointerRoot = @as(i32, 1); +pub const RevertToParent = @as(i32, 2); + +pub const Error = error{ + /// bad request code + BadRequest, + /// int parameter out of range + BadValue, + /// parameter not a Window + BadWindow, + /// parameter not a Pixmap + BadPixmap, + /// parameter not an Atom + BadAtom, + /// parameter not a Cursor + BadCursor, + /// parameter not a Font + BadFont, + /// parameter mismatch + BadMatch, + /// parameter not a Pixmap or Window + BadDrawable, + /// depending on context: + /// - key/button already grabbed + /// - attempt to free an illegal cmap entry + /// - attempt to store into a read-only color map entry. + /// - attempt to modify the access control list from other than the local + /// host. + BadAccess, + /// insufficient resources + BadAlloc, + /// no such colormap + BadColor, + /// parameter not a GC + BadGC, + /// choice not in range or already used + BadIDChoice, + /// font or color name doesn't exist + BadName, + /// Request length incorrect + BadLength, + /// server is defective + BadImplementation, + ExtensionError, + UnknownError, +}; + +pub const FirstExtensionError: Status = @enumFromInt(128); +pub const LastExtensionError: Status = @enumFromInt(255); + +pub fn resolveStatus(status: Status) Error!void { + return switch (status) { + 0 => {}, + 1 => error.BadRequest, + 2 => error.BadValue, + 3 => error.BadWindow, + 4 => error.BadPixmap, + 5 => error.BadAtom, + 6 => error.BadCursor, + 7 => error.BadFont, + 8 => error.BadMatch, + 9 => error.BadDrawable, + 10 => error.BadAccess, + 11 => error.BadAlloc, + 12 => error.BadColor, + 13 => error.BadGC, + 14 => error.BadIDChoice, + 15 => error.BadName, + 16 => error.BadLength, + 17 => error.BadImplementation, + FirstExtensionError...LastExtensionError => error.ExtensionError, + else => error.UnknownError, + }; +} + +pub const Class = enum(i32) { + CopyFromParent = 0, + InputOutput = 1, + InputOnly = 2, + _, +}; + +pub const CWBackPixmap = @as(i32, 1) << @as(i32, 0); +pub const CWBackPixel = @as(i32, 1) << @as(i32, 1); +pub const CWBorderPixmap = @as(i32, 1) << @as(i32, 2); +pub const CWBorderPixel = @as(i32, 1) << @as(i32, 3); +pub const CWBitGravity = @as(i32, 1) << @as(i32, 4); +pub const CWWinGravity = @as(i32, 1) << @as(i32, 5); +pub const CWBackingStore = @as(i32, 1) << @as(i32, 6); +pub const CWBackingPlanes = @as(i32, 1) << @as(i32, 7); +pub const CWBackingPixel = @as(i32, 1) << @as(i32, 8); +pub const CWOverrideRedirect = @as(i32, 1) << @as(i32, 9); +pub const CWSaveUnder = @as(i32, 1) << @as(i32, 10); +pub const CWEventMask = @as(i32, 1) << @as(i32, 11); +pub const CWDontPropagate = @as(i32, 1) << @as(i32, 12); +pub const CWColormap = @as(i32, 1) << @as(i32, 13); +pub const CWCursor = @as(i32, 1) << @as(i32, 14); + +pub const CWX = @as(i32, 1) << @as(i32, 0); +pub const CWY = @as(i32, 1) << @as(i32, 1); +pub const CWWidth = @as(i32, 1) << @as(i32, 2); +pub const CWHeight = @as(i32, 1) << @as(i32, 3); +pub const CWBorderWidth = @as(i32, 1) << @as(i32, 4); +pub const CWSibling = @as(i32, 1) << @as(i32, 5); +pub const CWStackMode = @as(i32, 1) << @as(i32, 6); + +pub const ForgetGravity = @as(i32, 0); +pub const NorthWestGravity = @as(i32, 1); +pub const NorthGravity = @as(i32, 2); +pub const NorthEastGravity = @as(i32, 3); +pub const WestGravity = @as(i32, 4); +pub const CenterGravity = @as(i32, 5); +pub const EastGravity = @as(i32, 6); +pub const SouthWestGravity = @as(i32, 7); +pub const SouthGravity = @as(i32, 8); +pub const SouthEastGravity = @as(i32, 9); +pub const StaticGravity = @as(i32, 10); + +pub const UnmapGravity = @as(i32, 0); + +pub const BackingStore = enum(i32) { + NotUseful = 0, + WhenMapped = 1, + Always = 2, + _, +}; + +pub const MapState = enum(i32) { + IsUnmapped = 0, + IsUnviewable = 1, + IsViewable = 2, + _, +}; + +pub const SetModeInsert = @as(i32, 0); +pub const SetModeDelete = @as(i32, 1); + +pub const DestroyAll = @as(i32, 0); +pub const RetainPermanent = @as(i32, 1); +pub const RetainTemporary = @as(i32, 2); + +pub const Above = @as(i32, 0); +pub const Below = @as(i32, 1); +pub const TopIf = @as(i32, 2); +pub const BottomIf = @as(i32, 3); +pub const Opposite = @as(i32, 4); + +pub const RaiseLowest = @as(i32, 0); +pub const LowerHighest = @as(i32, 1); + +pub const PropModeReplace = @as(i32, 0); +pub const PropModePrepend = @as(i32, 1); +pub const PropModeAppend = @as(i32, 2); + +pub const GXclear = @as(i32, 0x0); +pub const GXand = @as(i32, 0x1); +pub const GXandReverse = @as(i32, 0x2); +pub const GXcopy = @as(i32, 0x3); +pub const GXandInverted = @as(i32, 0x4); +pub const GXnoop = @as(i32, 0x5); +pub const GXxor = @as(i32, 0x6); +pub const GXor = @as(i32, 0x7); +pub const GXnor = @as(i32, 0x8); +pub const GXequiv = @as(i32, 0x9); +pub const GXinvert = @as(i32, 0xa); +pub const GXorReverse = @as(i32, 0xb); +pub const GXcopyInverted = @as(i32, 0xc); +pub const GXorInverted = @as(i32, 0xd); +pub const GXnand = @as(i32, 0xe); +pub const GXset = @as(i32, 0xf); + +pub const LineStyle = enum(i32) { + LineSolid = 0, + LineOnOffDash = 1, + LineDoubleDash = 2, + _, +}; + +pub const CapStyle = enum(i32) { + CapNotLast = 0, + CapButt = 1, + CapRound = 2, + CapProjecting = 3, + _, +}; + +pub const JoinStyle = enum(i32) { + JoinMiter = 0, + JoinRound = 1, + JoinBevel = 2, + _, +}; + +pub const FillStyle = enum(i32) { + FillSolid = 0, + FillTiled = 1, + FillStippled = 2, + FillOpaqueStippled = 3, + _, +}; + +pub const FillRule = enum(i32) { + EvenOddRule = 0, + WindingRule = 1, + _, +}; + +pub const SubwindowMode = enum(i32) { + ClipByChildren = 0, + IncludeInferiors = 1, + _, +}; + +pub const Unsorted = @as(i32, 0); +pub const YSorted = @as(i32, 1); +pub const YXSorted = @as(i32, 2); +pub const YXBanded = @as(i32, 3); + +pub const CoordModeOrigin = @as(i32, 0); +pub const CoordModePrevious = @as(i32, 1); + +pub const Complex = @as(i32, 0); +pub const Nonconvex = @as(i32, 1); +pub const Convex = @as(i32, 2); + +pub const ArcMode = enum(i32) { + ArcChord = 0, + ArcPieSlice = 1, + _, +}; + +pub const GCFunction = @as(i32, 1) << @as(i32, 0); +pub const GCPlaneMask = @as(i32, 1) << @as(i32, 1); +pub const GCForeground = @as(i32, 1) << @as(i32, 2); +pub const GCBackground = @as(i32, 1) << @as(i32, 3); +pub const GCLineWidth = @as(i32, 1) << @as(i32, 4); +pub const GCLineStyle = @as(i32, 1) << @as(i32, 5); +pub const GCCapStyle = @as(i32, 1) << @as(i32, 6); +pub const GCJoinStyle = @as(i32, 1) << @as(i32, 7); +pub const GCFillStyle = @as(i32, 1) << @as(i32, 8); +pub const GCFillRule = @as(i32, 1) << @as(i32, 9); +pub const GCTile = @as(i32, 1) << @as(i32, 10); +pub const GCStipple = @as(i32, 1) << @as(i32, 11); +pub const GCTileStipXOrigin = @as(i32, 1) << @as(i32, 12); +pub const GCTileStipYOrigin = @as(i32, 1) << @as(i32, 13); +pub const GCFont = @as(i32, 1) << @as(i32, 14); +pub const GCSubwindowMode = @as(i32, 1) << @as(i32, 15); +pub const GCGraphicsExposures = @as(i32, 1) << @as(i32, 16); +pub const GCClipXOrigin = @as(i32, 1) << @as(i32, 17); +pub const GCClipYOrigin = @as(i32, 1) << @as(i32, 18); +pub const GCClipMask = @as(i32, 1) << @as(i32, 19); +pub const GCDashOffset = @as(i32, 1) << @as(i32, 20); +pub const GCDashList = @as(i32, 1) << @as(i32, 21); +pub const GCArcMode = @as(i32, 1) << @as(i32, 22); + +pub const GCLastBit = @as(i32, 22); + +pub const FontLeftToRight = @as(i32, 0); +pub const FontRightToLeft = @as(i32, 1); + +pub const FontChange = @as(i32, 255); + +pub const ImageFormat = enum(i32) { + XYBitmap = 0, + XYPixmap = 1, + ZPixmap = 2, + _, +}; + +pub const AllocNone = @as(i32, 0); +pub const AllocAll = @as(i32, 1); + +pub const DoRed = @as(i32, 1) << @as(i32, 0); +pub const DoGreen = @as(i32, 1) << @as(i32, 1); +pub const DoBlue = @as(i32, 1) << @as(i32, 2); + +pub const CursorShape = @as(i32, 0); +pub const TileShape = @as(i32, 1); +pub const StippleShape = @as(i32, 2); + +pub const AutoRepeatMode = enum(i32) { + AutoRepeatModeOff = 0, + AutoRepeatModeOn = 1, + AutoRepeatModeDefault = 2, + _, +}; + +pub const LedModeOff = @as(i32, 0); +pub const LedModeOn = @as(i32, 1); + +pub const KBKeyClickPercent = @as(i64, 1) << @as(i32, 0); +pub const KBBellPercent = @as(i64, 1) << @as(i32, 1); +pub const KBBellPitch = @as(i64, 1) << @as(i32, 2); +pub const KBBellDuration = @as(i64, 1) << @as(i32, 3); +pub const KBLed = @as(i64, 1) << @as(i32, 4); +pub const KBLedMode = @as(i64, 1) << @as(i32, 5); +pub const KBKey = @as(i64, 1) << @as(i32, 6); +pub const KBAutoRepeatMode = @as(i64, 1) << @as(i32, 7); + +pub const MappingSuccess = @as(i32, 0); +pub const MappingBusy = @as(i32, 1); +pub const MappingFailed = @as(i32, 2); + +pub const MappingModifier = @as(i32, 0); +pub const MappingKeyboard = @as(i32, 1); +pub const MappingPointer = @as(i32, 2); + +pub const DontPreferBlanking = @as(i32, 0); +pub const PreferBlanking = @as(i32, 1); +pub const DefaultBlanking = @as(i32, 2); + +pub const DisableScreenSaver = @as(i32, 0); +pub const DisableScreenInterval = @as(i32, 0); + +pub const DontAllowExposures = @as(i32, 0); +pub const AllowExposures = @as(i32, 1); +pub const DefaultExposures = @as(i32, 2); + +pub const ScreenSaverReset = @as(i32, 0); +pub const ScreenSaverActive = @as(i32, 1); + +pub const HostInsert = @as(i32, 0); +pub const HostDelete = @as(i32, 1); + +pub const EnableAccess = @as(i32, 1); +pub const DisableAccess = @as(i32, 0); + +pub const StaticGray = @as(i32, 0); +pub const GrayScale = @as(i32, 1); +pub const StaticColor = @as(i32, 2); +pub const PseudoColor = @as(i32, 3); +pub const TrueColor = @as(i32, 4); +pub const DirectColor = @as(i32, 5); + +/// Byte or bit order +pub const BOrder = enum(i32) { + LSBFirst = 0, + MSBFirst = 1, + _, +}; + +// --- MARK: Xlib.h + +pub const WChar = u32; + +pub const Bool = enum(i32) { + False = 0, + True = 1, + _, + + pub fn fromBool(value: bool) Bool { + return @enumFromInt(@intFromBool(value)); + } + + pub fn toBool(self: Bool) bool { + return self != .false; + } +}; + +pub const Status = enum(i32) { _ }; + +pub const Mode = enum(i32) { + QueuedAlready = 0, + QueuedAfterReading = 1, + QueuedAfterFlush = 2, + _, +}; + +/// Extensions need a way to hang private data on some structures. +pub const XExtData = extern struct { + /// number returned by XRegisterExtension + number: i32 = 0, + /// next item on list of data for structure + next: ?*XExtData = null, + /// called to free private storage + free_private: ?*const fn (extension: *XExtData) callconv(.c) i32 = null, + /// data private to this extension. + private_data: ?*anyopaque = null, +}; + +/// This file contains structures used by the extension mechanism. +/// public to extension, cannot be changed +pub const XExtCodes = extern struct { + /// extension number + extension: i32 = 0, + /// major op-code assigned by server + major_opcode: i32 = 0, + /// first event number for the extension + first_event: i32 = 0, + /// first error number for the extension + first_error: i32 = 0, +}; + +/// Data structure for retrieving info about pixmap formats. +pub const XPixmapFormatValues = extern struct { + depth: i32 = 0, + bits_per_pixel: i32 = 0, + scanline_pad: i32 = 0, +}; + +/// Data structure for setting graphics context. +pub const XGCValues = extern struct { + /// logical operation + function: i32 = 0, + /// plane mask + plane_mask: u64 = 0, + /// foreground pixel + foreground: u64 = 0, + /// background pixel + background: u64 = 0, + /// line width + line_width: i32 = 0, + line_style: LineStyle = @enumFromInt(0), + cap_style: CapStyle = @enumFromInt(0), + join_style: JoinStyle = @enumFromInt(0), + fill_style: FillStyle = @enumFromInt(0), + fill_rule: FillRule = @enumFromInt(0), + arc_mode: ArcMode = @enumFromInt(0), + /// tile pixmap for tiling operations + tile: Pixmap = .None, + /// stipple 1 plane pixmap for stippling + stipple: Pixmap = .None, + /// offset for tile or stipple operations + ts_x_origin: i32 = 0, + /// offset for tile or stipple operations + ts_y_origin: i32 = 0, + /// default text font for text operations + font: Font = .None, + subwindow_mode: SubwindowMode = @enumFromInt(0), + /// boolean, should exposures be generated + graphics_exposures: Bool = .False, + /// origin for clipping + clip_x_origin: i32 = 0, + /// origin for clipping + clip_y_origin: i32 = 0, + /// bitmap clipping; other calls for rects + clip_mask: Pixmap = .None, + /// patterned/dashed line information + dash_offset: i32 = 0, + /// patterned/dashed line information + dashes: u8 = 0, +}; + +/// Graphics context. The contents of this structure are implementation +/// dependent. A GC should be treated as opaque by application code. +pub const GC = opaque {}; + +pub const _XGC = extern struct { + /// hook for extension to hang data + ext_data: ?*XExtData = null, + /// protocol ID for graphics context + gid: GContext = .None, + + // there is more to this structure, but it is private to Xlib +}; + +/// Visual structure; contains information about colormapping possible. +pub const Visual = extern struct { + /// hook for extension to hang data + ext_data: ?*XExtData = null, + /// visual id of this visual + visualid: VisualID = .None, + /// class of screen (monochrome, etc.) + class: i32 = 0, + /// mask values + red_mask: u64 = 0, + /// mask values + green_mask: u64 = 0, + /// mask values + blue_mask: u64 = 0, + /// log base 2 of distinct color values + bits_per_rgb: i32 = 0, + /// color map entries + map_entries: i32 = 0, +}; + +/// Depth structure; contains information for each possible depth. +pub const Depth = extern struct { + /// this depth (Z) of the depth + depth: i32 = 0, + /// number of Visual types at this depth + nvisuals: i32 = 0, + /// list of visuals possible at this depth + visuals: ?[*]Visual = null, + + pub inline fn getVisuals(self: Depth) []Visual { + return if (self.visuals) |x| x[0..@intCast(self.nvisuals)] else &.{}; + } + + pub inline fn setVisuals(self: *Depth, visuals: ?[]Visual) void { + if (visuals) |x| { + self.nvisuals = @intCast(x.len); + self.visuals = x.ptr; + } else { + self.nvisuals = 0; + self.visuals = null; + } + } +}; + +/// Information about the screen. The contents of this structure are +/// implementation dependent. A Screen should be treated as opaque by +/// application code. +pub const Screen = extern struct { + /// hook for extension to hang data + ext_data: ?*XExtData = null, + /// back pointer to display structure + display: ?*Display = null, + /// Root window id. + root: Window = .None, + /// width of screen + width: i32 = 0, + /// height of screen + height: i32 = 0, + /// width of screen in millimeters + mwidth: i32 = 0, + /// height of screen in millimeters + mheight: i32 = 0, + /// number of depths possible + ndepths: i32 = 0, + /// list of allowable depths on the screen + depths: ?[*]Depth = null, + /// bits per pixel + root_depth: i32 = 0, + /// root visual + root_visual: ?*Visual = null, + /// GC for the root root visual + default_gc: ?*GC = null, + /// default color map + cmap: Colormap = .None, + /// White and pixel value + white_pixel: u64 = 0, + /// Black pixel value + black_pixel: u64 = 0, + /// max color maps + max_maps: i32 = 0, + /// min color maps + min_maps: i32 = 0, + backing_store: BackingStore = 0, + save_unders: Bool = 0, + /// initial root input mask + root_input_mask: i64 = 0, + + pub inline fn getDepths(self: Screen) []Depth { + return if (self.depths) |x| x[0..@intCast(self.ndepths)] else &.{}; + } + + pub inline fn setDepths(self: *Screen, depths: ?[]Depth) void { + if (depths) |x| { + self.ndepths = @intCast(x.len); + self.depths = x.ptr; + } else { + self.ndepths = 0; + self.depths = null; + } + } +}; + +/// Format structure; describes ZFormat data the screen will understand. +pub const ScreenFormat = extern struct { + /// hook for extension to hang data + ext_data: ?*XExtData = null, + /// depth of this image format + depth: i32 = 0, + /// bits/pixel at this depth + bits_per_pixel: i32 = 0, + /// scanline must padded to this multiple + scanline_pad: i32 = 0, +}; + +/// Data structure for setting window attributes. +pub const XSetWindowAttributes = extern struct { + /// background or None or ParentRelative + background_pixmap: Pixmap = .None, + /// background pixel + background_pixel: u64 = 0, + /// border of the window + border_pixmap: Pixmap = .None, + /// border pixel value + border_pixel: u64 = 0, + /// one of bit gravity values + bit_gravity: i32 = 0, + /// one of the window gravity values + win_gravity: i32 = 0, + backing_store: BackingStore = 0, + /// planes to be preserved if possible + backing_planes: u64 = 0, + /// value to use in restoring planes + backing_pixel: u64 = 0, + /// should bits under be saved? (popups) + save_under: Bool = .False, + /// set of events that should be saved + event_mask: EventMask = .{}, + /// set of events that should not propagate + do_not_propagate_mask: EventMask = 0, + /// boolean value for override-redirect + override_redirect: Bool = .False, + /// color map to be associated with window + colormap: Colormap = .None, + /// cursor to be displayed (or None) + cursor: Cursor = .None, +}; + +pub const XWindowAttributes = extern struct { + /// location of window + x: i32 = 0, + /// location of window + y: i32 = 0, + /// width of window + width: i32 = 0, + /// height of window + height: i32 = 0, + /// border width of window + border_width: i32 = 0, + /// depth of window + depth: i32 = 0, + /// the associated visual structure + visual: ?*Visual = null, + /// root of screen containing window + root: Window = .None, + class: Class = @intFromEnum(0), + /// one of bit gravity values + bit_gravity: i32 = 0, + /// one of the window gravity values + win_gravity: i32 = 0, + backing_store: BackingStore = @intFromEnum(0), + /// planes to be preserved if possible + backing_planes: u64 = 0, + /// value to be used when restoring planes + backing_pixel: u64 = 0, + /// boolean, should bits under be saved? + save_under: Bool = .False, + /// color map to be associated with window + colormap: Colormap = .None, + /// boolean, is color map currently installed + map_installed: Bool = .False, + map_state: MapState = @intFromEnum(0), + /// set of events all people have interest in + all_event_masks: EventMask = .{}, + /// my event mask + your_event_mask: EventMask = .{}, + do_not_propagate_mask: EventMask = .{}, + /// boolean value for override-redirect + override_redirect: Bool = .False, + /// back pointer to correct screen + screen: ?*Screen = null, +}; + +/// Data structure for host setting; getting routines. +pub const XHostAddress = extern struct { + family: Family = @enumFromInt(0), + /// length of address, in bytes + length: i32 = 0, + /// pointer to where to find the bytes + address: ?[*]u8 = null, + + pub inline fn getAddress(self: XHostAddress) []u8 { + return if (self.address) |x| x[0..@intCast(self.length)] else &.{}; + } + + pub inline fn setAddress(self: *XHostAddress, address: ?[]u8) void { + if (address) |x| { + self.length = @intCast(x.len); + self.address = x.ptr; + } else { + self.length = 0; + self.address = null; + } + } +}; + +/// Data structure for ServerFamilyInterpreted addresses in host routines +pub const XServerInterpretedAddress = extern struct { + /// length of type string, in bytes + typelength: i32 = 0, + /// length of value string, in bytes + valuelength: i32 = 0, + /// pointer to where to find the type string + type: ?[*]u8 = null, + /// pointer to where to find the address + value: ?[*]u8 = null, + + pub inline fn getType(self: XServerInterpretedAddress) []u8 { + return if (self.type) |x| x[0..@intCast(self.typelength)] else &.{}; + } + + pub inline fn setType(self: *XServerInterpretedAddress, @"type": ?[]u8) void { + if (@"type") |x| { + self.typelength = @intCast(x.len); + self.type = x.ptr; + } else { + self.typelength = 0; + self.type = null; + } + } + + pub inline fn getValue(self: XServerInterpretedAddress) []u8 { + return if (self.value) |x| x[0..@intCast(self.valuelength)] else &.{}; + } + + pub inline fn setValue(self: *XServerInterpretedAddress, value: ?[]u8) void { + if (value) |x| { + self.valuelength = @intCast(x.len); + self.value = x.ptr; + } else { + self.valuelength = 0; + self.value = null; + } + } +}; + +/// Data structure for "image" data, used by image manipulation routines. +pub const XImage = extern struct { + /// size of image + width: i32 = 0, + /// size of image + height: i32 = 0, + /// number of pixels offset in X direction + xoffset: i32 = 0, + format: ImageFormat = 0, + /// pointer to image data + data: ?[*]u8 = null, + /// data byte order + byte_order: BOrder = @intFromEnum(0), + /// quant. of scanline 8, 16, 32 + bitmap_unit: i32 = 0, + bitmap_bit_order: BOrder = @intFromEnum(0), + /// 8, 16, 32 either XY or ZPixmap + bitmap_pad: i32 = 0, + /// depth of image + depth: i32 = 0, + /// accelerator to next line + bytes_per_line: i32 = 0, + /// bits per pixel (ZPixmap) + bits_per_pixel: i32 = 0, + /// bits in z arrangement + red_mask: u64 = 0, + /// bits in z arrangement + green_mask: u64 = 0, + /// bits in z arrangement + blue_mask: u64 = 0, + /// hook for the object routines to hang on + obdata: ?*anyopaque = null, + /// image manipulation routines + f: extern struct { + create_image: ?*const fn ( + display: ?*Display, + visual: ?*Visual, + depth: u32, + format: ImageFormat, + offset: i32, + data: ?[*]u8, + width: u32, + height: u32, + bitmap_pad: i32, + bytes_per_line: i32, + ) callconv(.c) ?*XImage = null, + destroy_image: ?*const fn (ximage: *XImage) callconv(.c) i32 = null, + get_pixel: ?*const fn (ximage: *XImage, x: i32, y: i32) callconv(.c) u64 = null, + put_pixel: ?*const fn (ximage: *XImage, x: i32, y: i32, pixel: u64) callconv(.c) i32 = null, + sub_image: ?*const fn (ximage: *XImage, x: i32, y: i32, subimage_width: u32, subimage_height: u32) callconv(.c) ?*XImage = null, + add_pixel: ?*const fn (ximage: *XImage, value: i64) callconv(.c) i32 = null, + } = .{}, +}; + +/// Data structure for XReconfigureWindow +pub const XWindowChanges = extern struct { + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + border_width: i32 = 0, + sibling: Window = .None, + stack_mode: i32 = 0, +}; + +/// Data structure used by color operations +pub const XColor = extern struct { + pixel: u64 = 0, + red: u16 = 0, + green: u16 = 0, + blue: u16 = 0, + flags: u8 = 0, + pad: u8 = 0, +}; + +/// Data structures for graphics operations. On most machines, this is congruent +/// with the wire protocol structures, so reformatting the data can be avoided +/// on these architectures. +pub const XSegment = extern struct { x1: i16 = 0, y1: i16 = 0, x2: i16 = 0, y2: i16 = 0 }; + +/// Data structures for graphics operations. On most machines, this is congruent +/// with the wire protocol structures, so reformatting the data can be avoided +/// on these architectures. +pub const XPoint = extern struct { x: i16 = 0, y: i16 = 0 }; + +/// Data structures for graphics operations. On most machines, this is congruent +/// with the wire protocol structures, so reformatting the data can be avoided +/// on these architectures. +pub const XRectangle = extern struct { x: i16 = 0, y: i16 = 0, width: u16 = 0, height: u16 = 0 }; + +/// Data structures for graphics operations. On most machines, this is congruent +/// with the wire protocol structures, so reformatting the data can be avoided +/// on these architectures. +pub const XArc = extern struct { x: i16 = 0, y: i16 = 0, width: u16 = 0, height: u16 = 0, angle1: i16 = 0, angle2: i16 = 0 }; + +/// Data structure for XChangeKeyboardControl +pub const XKeyboardControl = extern struct { + key_click_percent: i32 = 0, + bell_percent: i32 = 0, + bell_pitch: i32 = 0, + bell_duration: i32 = 0, + led: i32 = 0, + led_mode: i32 = 0, + key: i32 = 0, + auto_repeat_mode: AutoRepeatMode = 0, +}; + +/// Data structure for XGetKeyboardControl +pub const XKeyboardState = extern struct { + key_click_percent: i32 = 0, + bell_percent: i32 = 0, + bell_pitch: u32 = 0, + bell_duration: u32 = 0, + led_mask: u64 = 0, + global_auto_repeat: i32 = 0, + auto_repeats: [32]u8 = @splat(0), +}; + +/// Data structure for XGetMotionEvents. +pub const XTimeCoord = extern struct { + time: Time = @intFromEnum(0), + x: i16 = 0, + y: i16 = 0, +}; + +/// Data structure for X{Set,Get}ModifierMapping +pub const XModifierKeymap = extern struct { + /// The server's max # of keys per modifier + max_keypermod: i32 = 0, + /// An 8 by max_keypermod array of modifiers + modifiermap: ?[*]KeyCode = null, +}; + +/// Display datatype maintaining display specific data. The contents of this +/// structure are implementation dependent. A Display should be treated as +/// opaque by application code. +pub const Display = opaque { + + // --- MACROS --- + + pub inline fn connectionNumber(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.fd; + } + + pub inline fn rootWindow(self: *Display, screen: i32) Window { + return self.screenOfDisplay(screen).root; + } + + pub inline fn defaultScreen(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.default_screen; + } + + pub inline fn defaultRootWindow(self: *Display) Window { + return self.screenOfDisplay(self.defaultScreen()).root; + } + + pub inline fn defaultVisual(self: *Display, screen: i32) ?*Visual { + return self.screenOfDisplay(screen).root_visual; + } + + pub inline fn defaultGC(self: *Display, screen: i32) ?*GC { + return self.screenOfDisplay(screen).default_gc; + } + + pub inline fn blackPixel(self: *Display, screen: i32) u64 { + return self.screenOfDisplay(screen).black_pixel; + } + + pub inline fn whitePixel(self: *Display, screen: i32) u64 { + return self.screenOfDisplay(screen).white_pixel; + } + + pub const all_planes = ~@as(u64, 0); + + pub inline fn qLength(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.qlen; + } + + pub inline fn displayWidth(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).width; + } + + pub inline fn displayHeight(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).height; + } + + pub inline fn displayWidthMM(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).mwidth; + } + + pub inline fn displayHeightMM(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).mheight; + } + + pub inline fn displayPlanes(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).root_depth; + } + + pub inline fn displayCells(self: *Display, screen: i32) i32 { + return self.defaultVisual(screen).?.map_entries; + } + + pub inline fn screenCount(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.nscreens; + } + + pub inline fn serverVendor(self: *Display) ?[*:0]const u8 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.vendor; + } + + pub inline fn protocolVersion(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.proto_major_version; + } + + pub inline fn protocolRevision(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.proto_minor_version; + } + + pub inline fn vendorRelease(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.release; + } + + pub inline fn displayString(self: *Display) ?[*:0]const u8 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.display_name; + } + + pub inline fn defaultDepth(self: *Display, screen: i32) i32 { + return self.screenOfDisplay(screen).root_depth; + } + + pub inline fn defaultColormap(self: *Display, screen: i32) Colormap { + return self.screenOfDisplay(screen).cmap; + } + + pub inline fn bitmapUnit(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.bitmap_unit; + } + + pub inline fn bitmapBitOrder(self: *Display) BOrder { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.bitmap_bit_order; + } + + pub inline fn bitmapPad(self: *Display) i32 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.bitmap_pad; + } + + pub inline fn imageByteOrder(self: *Display) BOrder { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.byte_order; + } + + pub inline fn nextRequest(self: *Display) u64 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.request + 1; + } + + pub inline fn lastKnownRequestProcessed(self: *Display) u64 { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.last_request_read; + } + + // --- SCREEN MACROS --- + + pub inline fn screenOfDisplay(self: *Display, screen: i32) *Screen { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return &private.screens.?[@intCast(screen)]; + } + + pub inline fn defaultScreenOfDisplay(self: *Display) *Screen { + return self.screenOfDisplay(self.defaultScreen()); + } + + // --- ALLOC ID MACRO --- + + pub inline fn allocID(dpy: anytype) XID { + const private: *_XPrivDisplay = @ptrCast(@alignCast(self)); + return private.resource_alloc.?(private); + } + + // --- METHODS --- + + pub inline fn openDisplay(display_name: ?[*:0]const u8) ?*Display { + return XOpenDisplay(display_name); + } + + pub inline fn closeDisplay(self: *Display) i32 { + return XCloseDisplay(self); + } + + pub inline fn createSimpleWindow(self: *Display, parent: Window, x: i32, y: i32, width: u32, height: u32, border_width: u32, border: u64, background: u64) Window { + return XCreateSimpleWindow(self, parent, x, y, width, height, border_width, border, background); + } + + pub inline fn createWindow(self: *Display, parent: Window, x: i32, y: i32, width: u32, height: u32, border_width: u32, depth: i32, class: u32, visual: ?*Visual, valuemask: ValueMask(XSetWindowAttributes), attributes: *XSetWindowAttributes) Window { + return XCreateWindow(self, parent, x, y, width, height, border_width, depth, class, visual, valuemask, attributes); + } + + pub inline fn destroyWindow(self: *Display, w: Window) i32 { + return XDestroyWindow(self, w); + } + + pub inline fn destroySubwindows(self: *Display, w: Window) i32 { + return XDestroySubwindows(self, w); + } + + pub inline fn storeName(self: *Display, w: Window, window_name: ?[*:0]const u8) i32 { + return XStoreName(self, w, window_name); + } + + pub inline fn createGC(self: *Display, d: Drawable, valuemask: ValueMask(XGCValues), values: ?*XGCValues) ?*GC { + return XCreateGC(self, d, valuemask, values); + } + + pub inline fn freeGC(self: *Display, gc: ?*GC) i32 { + return XFreeGC(self, gc); + } + + pub inline fn internAtom(self: *Display, atom_name: ?[*:0]const u8, only_if_exists: bool) Atom { + return XInternAtom(self, atom_name, @enumFromInt(@intFromBool(only_if_exists))); + } + + pub inline fn setWMProtocols(self: *Display, w: Window, protocols: []Atom) Status { + return XSetWMProtocols(self, w, protocols.ptr, @intCast(protocols.len)); + } + + pub inline fn mapWindow(self: *Display, w: Window) i32 { + return XMapWindow(self, w); + } + + pub inline fn unmapWindow(self: *Display, w: Window) i32 { + return XUnmapWindow(self, w); + } + + pub inline fn nextEvent(self: *Display) XEvent { + var ret: XEvent = undefined; + _ = XNextEvent(self, &ret); + return ret; + } +}; + +pub const _XPrivate = opaque {}; +pub const _XrmHashBucketRec = opaque {}; + +pub const _XPrivDisplay = extern struct { + /// hook for extension to hang data + ext_data: ?*XExtData = null, + private1: ?*_XPrivate = null, + /// Network socket. + fd: i32 = 0, + private2: i32 = 0, + /// major version of server's X protocol + proto_major_version: i32 = 0, + /// minor version of servers X protocol + proto_minor_version: i32 = 0, + /// vendor of the server hardware + vendor: ?[*:0]const u8 = null, + private3: XID = .None, + private4: XID = .None, + private5: XID = .None, + private6: i32 = 0, + /// allocator function + resource_alloc: ?*const fn (display: ?*_XPrivDisplay) callconv(.c) XID = null, + /// screen byte order + byte_order: BOrder = 0, + /// padding and data requirements + bitmap_unit: i32 = 0, + /// padding requirements on bitmaps + bitmap_pad: i32 = 0, + bitmap_bit_order: BOrder = 0, + /// number of pixmap formats in list + nformats: i32 = 0, + /// pixmap format list + pixmap_format: ?[*]ScreenFormat = null, + private8: i32 = 0, + /// release of the server + release: i32 = 0, + private9: ?*_XPrivate = null, + private10: ?*_XPrivate = null, + /// Length of input event queue + qlen: i32 = 0, + /// seq number of last event read + last_request_read: u64 = 0, + /// sequence number of last request. + request: u64 = 0, + private11: ?*anyopaque = null, + private12: ?*anyopaque = null, + private13: ?*anyopaque = null, + private14: ?*anyopaque = null, + /// maximum number 32 bit words in request + max_request_size: u32 = 0, + db: ?*_XrmHashBucketRec = null, + private15: ?*const fn (?*Display) callconv(.c) i32 = null, + /// "host:display" string used on this connect + display_name: ?[*:0]const u8 = null, + /// default screen for operations + default_screen: i32 = 0, + /// number of screens on this server + nscreens: i32 = 0, + /// pointer to list of screens + screens: ?[*]Screen = null, + /// size of motion buffer + motion_buffer: u64 = 0, + private16: u64 = 0, + /// minimum defined keycode + min_keycode: i32 = 0, + /// maximum defined keycode + max_keycode: i32 = 0, + private17: ?*anyopaque = null, + private18: ?*anyopaque = null, + private19: i32 = 0, + /// contents of defaults from server + xdefaults: ?[*]u8 = null, + + // there is more to this structure, but it is private to Xlib + + pub inline fn getPixmapFormats(self: *const _XPrivDisplay) []Pixmap { + return if (self.pixmap_format) |x| x[0..@intCast(self.nformats)] else &.{}; + } + + pub inline fn getScreens(self: *const _XPrivDisplay) []Screen { + return if (self.screens) |x| x[0..@intCast(self.nscreens)] else &.{}; + } +}; + +// --- MARK: EVENTS + +pub const XKeyPressedEvent = extern struct { + type: EventType = .KeyPress, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + state: u32 = 0, + keycode: u32 = 0, + same_screen: i32 = 0, +}; + +pub const XKeyReleasedEvent = extern struct { + type: EventType = .KeyRelease, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + state: u32 = 0, + keycode: u32 = 0, + same_screen: i32 = 0, +}; + +pub const XButtonPressedEvent = extern struct { + type: EventType = .ButtonPress, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + state: u32 = 0, + button: u32 = 0, + same_screen: i32 = 0, +}; + +pub const XButtonReleasedEvent = extern struct { + type: EventType = .ButtonRelease, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + state: u32 = 0, + button: u32 = 0, + same_screen: i32 = 0, +}; + +pub const XPointerMovedEvent = extern struct { + type: EventType = .MotionNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + state: u32 = 0, + is_hint: u8 = 0, + same_screen: i32 = 0, +}; + +pub const XEnterWindowEvent = extern struct { + type: EventType = .EnterNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + mode: i32 = 0, + detail: i32 = 0, + same_screen: i32 = 0, + focus: i32 = 0, + state: u32 = 0, +}; + +pub const XLeaveWindowEvent = extern struct { + type: EventType = .LeaveNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + root: Window = .None, + subwindow: Window = .None, + time: Time = @import("std").mem.zeroes(Time), + x: i32 = 0, + y: i32 = 0, + x_root: i32 = 0, + y_root: i32 = 0, + mode: i32 = 0, + detail: i32 = 0, + same_screen: i32 = 0, + focus: i32 = 0, + state: u32 = 0, +}; + +pub const XFocusInEvent = extern struct { + type: EventType = .FocusIn, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + mode: i32 = 0, + detail: i32 = 0, +}; + +pub const XFocusOutEvent = extern struct { + type: EventType = .FocusOut, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + mode: i32 = 0, + detail: i32 = 0, +}; + +pub const XKeymapEvent = extern struct { + type: EventType = .KeymapNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + key_vector: [32]u8 = @import("std").mem.zeroes([32]u8), +}; + +pub const XExposeEvent = extern struct { + type: EventType = .Expose, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + count: i32 = 0, +}; + +pub const XGraphicsExposeEvent = extern struct { + type: EventType = .GraphicsExpose, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + drawable: Drawable = @import("std").mem.zeroes(Drawable), + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + count: i32 = 0, + major_code: i32 = 0, + minor_code: i32 = 0, +}; + +pub const XNoExposeEvent = extern struct { + type: EventType = .NoExpose, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + drawable: Drawable = @import("std").mem.zeroes(Drawable), + major_code: i32 = 0, + minor_code: i32 = 0, +}; + +pub const XVisibilityEvent = extern struct { + type: EventType = .VisibilityNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + state: i32 = 0, +}; + +pub const XCreateWindowEvent = extern struct { + type: EventType = .CreateNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + parent: Window = .None, + window: Window = .None, + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + border_width: i32 = 0, + override_redirect: i32 = 0, +}; + +pub const XDestroyWindowEvent = extern struct { + type: EventType = .DestroyNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, +}; + +pub const XUnmapEvent = extern struct { + type: EventType = .UnmapNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + from_configure: i32 = 0, +}; + +pub const XMapEvent = extern struct { + type: EventType = .MapNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + override_redirect: i32 = 0, +}; + +pub const XMapRequestEvent = extern struct { + type: EventType = .MapRequest, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + parent: Window = .None, + window: Window = .None, +}; + +pub const XReparentEvent = extern struct { + type: EventType = .ReparentNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + parent: Window = .None, + x: i32 = 0, + y: i32 = 0, + override_redirect: i32 = 0, +}; + +pub const XConfigureEvent = extern struct { + type: EventType = .ConfigureNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + border_width: i32 = 0, + above: Window = .None, + override_redirect: i32 = 0, +}; + +pub const XGravityEvent = extern struct { + type: EventType = .GravityNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + x: i32 = 0, + y: i32 = 0, +}; + +pub const XResizeRequestEvent = extern struct { + type: EventType = .ResizeRequest, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + width: i32 = 0, + height: i32 = 0, +}; + +pub const XConfigureRequestEvent = extern struct { + type: EventType = .ConfigureRequest, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + parent: Window = .None, + window: Window = .None, + x: i32 = 0, + y: i32 = 0, + width: i32 = 0, + height: i32 = 0, + border_width: i32 = 0, + above: Window = .None, + detail: i32 = 0, + value_mask: u64 = 0, +}; + +pub const XCirculateEvent = extern struct { + type: EventType = .CirculateNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + event: Window = .None, + window: Window = .None, + place: i32 = 0, +}; + +pub const XCirculateRequestEvent = extern struct { + type: EventType = .CirculateRequest, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + parent: Window = .None, + window: Window = .None, + place: i32 = 0, +}; + +pub const XPropertyEvent = extern struct { + type: EventType = .PropertyNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + atom: Atom = .None, + time: Time = @import("std").mem.zeroes(Time), + state: i32 = 0, +}; + +pub const XSelectionClearEvent = extern struct { + type: EventType = .SelectionClear, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + selection: Atom = .None, + time: Time = @import("std").mem.zeroes(Time), +}; + +pub const XSelectionRequestEvent = extern struct { + type: EventType = .SelectionRequest, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + owner: Window = .None, + requestor: Window = .None, + selection: Atom = .None, + target: Atom = .None, + property: Atom = .None, + time: Time = @import("std").mem.zeroes(Time), +}; + +pub const XSelectionEvent = extern struct { + type: EventType = .SelectionNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + requestor: Window = .None, + selection: Atom = .None, + target: Atom = .None, + property: Atom = .None, + time: Time = @import("std").mem.zeroes(Time), +}; + +pub const XColormapEvent = extern struct { + type: EventType = .ColormapNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + colormap: Colormap = .None, + new: i32 = 0, + state: i32 = 0, +}; + +pub const XClientMessageEvent = extern struct { + type: EventType = .ClientMessage, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + message_type: Atom = .None, + format: i32 = 0, + data: [20]u8 align(@alignOf(i64)) = @splat(0), + + pub inline fn getData(self: XClientMessageEvent, comptime T: type) T { + return self.getDataOffset(T, 0); + } + + pub inline fn getDataOffset(self: XClientMessageEvent, comptime T: type, byte_offset: usize) T { + const size = @sizeOf(T); + const capacity = @sizeOf(@TypeOf(self.data)); + std.debug.assert(byte_offset + size <= capacity); + return std.mem.bytesToValue(T, self.data[byte_offset .. byte_offset + size]); + } +}; + +pub const XMappingEvent = extern struct { + type: EventType = .MappingNotify, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, + request: i32 = 0, + first_keycode: i32 = 0, + count: i32 = 0, +}; + +pub const XErrorEvent = extern struct { + type: EventType = .EnterNotify, + display: ?*Display = null, + resourceid: XID = .None, + serial: u64 = 0, + error_code: u8 = 0, + request_code: u8 = 0, + minor_code: u8 = 0, +}; + +pub const XAnyEvent = extern struct { + type: EventType = @intFromEnum(0), + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + window: Window = .None, +}; + +pub const XGenericEvent = extern struct { + type: EventType = .GenericEvent, + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + extension: i32 = 0, + evtype: i32 = 0, +}; + +pub const XGenericEventCookie = extern struct { + type: EventType = @intFromEnum(0), + serial: u64 = 0, + send_event: i32 = 0, + display: ?*Display = null, + extension: i32 = 0, + evtype: i32 = 0, + cookie: u32 = 0, + data: ?*anyopaque = null, +}; + +pub const XEvent = extern union { + type: EventType, + xany: XAnyEvent, + xkey: XKeyEvent, + xbutton: XButtonEvent, + xmotion: XMotionEvent, + xcrossing: XCrossingEvent, + xfocus: XFocusChangeEvent, + xexpose: XExposeEvent, + xgraphicsexpose: XGraphicsExposeEvent, + xnoexpose: XNoExposeEvent, + xvisibility: XVisibilityEvent, + xcreatewindow: XCreateWindowEvent, + xdestroywindow: XDestroyWindowEvent, + xunmap: XUnmapEvent, + xmap: XMapEvent, + xmaprequest: XMapRequestEvent, + xreparent: XReparentEvent, + xconfigure: XConfigureEvent, + xgravity: XGravityEvent, + xresizerequest: XResizeRequestEvent, + xconfigurerequest: XConfigureRequestEvent, + xcirculate: XCirculateEvent, + xcirculaterequest: XCirculateRequestEvent, + xproperty: XPropertyEvent, + xselectionclear: XSelectionClearEvent, + xselectionrequest: XSelectionRequestEvent, + xselection: XSelectionEvent, + xcolormap: XColormapEvent, + xclient: XClientMessageEvent, + xmapping: XMappingEvent, + xerror: XErrorEvent, + xkeymap: XKeymapEvent, + xgeneric: XGenericEvent, + xcookie: XGenericEventCookie, + _pad: [24]i64, +}; + +// --- MARK: END OF EVENTS + +// --- MARK: TRANSLATE-C + +pub const XErrorHandler = ?*const fn (?*Display, [*c]XErrorEvent) callconv(.c) i32; +pub const XIOErrorHandler = ?*const fn (?*Display) callconv(.c) i32; +pub const XIOErrorExitHandler = ?*const fn (?*Display, ?*anyopaque) callconv(.c) void; +pub const XConnectionWatchProc = ?*const fn (?*Display, ?*anyopaque, i32, i32, [*c]?*anyopaque) callconv(.c) void; + +pub fn ValueMask(comptime T: type) type { + const fields = @typeInfo(T).@"struct".fields; + var mask_fields: [fields.len + 1]std.builtin.Type.StructField = undefined; + + for (fields, 0..) |field, i| { + mask_fields[i] = .{ + .name = field.name, + .type = bool, + .default_value_ptr = &false, + .is_comptime = false, + .alignment = 0, + }; + } + + const PaddingType = std.meta.Int(.unsigned, 64 - fields.len); + + mask_fields[fields.len] = .{ + .name = "_padding", + .type = PaddingType, + .default_value_ptr = &@as(PaddingType, 0), + .is_comptime = false, + .alignment = 0, + }; + + return @Type(.{ + .@"struct" = .{ + .layout = .@"packed", + .backing_integer = u64, + .fields = &mask_fields, + .decls = &.{}, + .is_tuple = false, + }, + }); +} + +pub const XCharStruct = extern struct { + lbearing: i16 = 0, + rbearing: i16 = 0, + width: i16 = 0, + ascent: i16 = 0, + descent: i16 = 0, + attributes: u16 = 0, +}; +pub const XFontProp = extern struct { + name: Atom = .None, + card32: u64 = 0, +}; +pub const XFontStruct = extern struct { + ext_data: ?*XExtData = null, + fid: Font = .None, + direction: u32 = 0, + min_char_or_byte2: u32 = 0, + max_char_or_byte2: u32 = 0, + min_byte1: u32 = 0, + max_byte1: u32 = 0, + all_chars_exist: i32 = 0, + default_char: u32 = 0, + n_properties: i32 = 0, + properties: [*c]XFontProp = @import("std").mem.zeroes([*c]XFontProp), + min_bounds: XCharStruct = @import("std").mem.zeroes(XCharStruct), + max_bounds: XCharStruct = @import("std").mem.zeroes(XCharStruct), + per_char: [*c]XCharStruct = @import("std").mem.zeroes([*c]XCharStruct), + ascent: i32 = 0, + descent: i32 = 0, +}; +pub const XTextItem = extern struct { + chars: [*c]u8 = @import("std").mem.zeroes([*c]u8), + nchars: i32 = 0, + delta: i32 = 0, + font: Font = .None, +}; +pub const XChar2b = extern struct { + byte1: u8 = 0, + byte2: u8 = 0, +}; +pub const XTextItem16 = extern struct { + chars: [*c]XChar2b = @import("std").mem.zeroes([*c]XChar2b), + nchars: i32 = 0, + delta: i32 = 0, + font: Font = .None, +}; +pub const XEDataObject = extern union { + display: ?*Display, + gc: ?*GC, + visual: [*c]Visual, + screen: [*c]Screen, + pixmap_format: [*c]ScreenFormat, + font: [*c]XFontStruct, +}; +pub const XFontSetExtents = extern struct { + max_ink_extent: XRectangle = @import("std").mem.zeroes(XRectangle), + max_logical_extent: XRectangle = @import("std").mem.zeroes(XRectangle), +}; +pub const struct__XOM = opaque {}; +pub const XOM = ?*struct__XOM; +pub const struct__XOC = opaque {}; +pub const XOC = ?*struct__XOC; +pub const XFontSet = ?*struct__XOC; +pub const XmbTextItem = extern struct { + chars: [*c]u8 = @import("std").mem.zeroes([*c]u8), + nchars: i32 = 0, + delta: i32 = 0, + font_set: XFontSet = @import("std").mem.zeroes(XFontSet), +}; +pub const XwcTextItem = extern struct { + chars: [*c]WChar = @import("std").mem.zeroes([*c]WChar), + nchars: i32 = 0, + delta: i32 = 0, + font_set: XFontSet = @import("std").mem.zeroes(XFontSet), +}; +pub const XOMCharSetList = extern struct { + charset_count: i32 = 0, + charset_list: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), +}; +pub const XOMOrientation_LTR_TTB: i32 = 0; +pub const XOMOrientation_RTL_TTB: i32 = 1; +pub const XOMOrientation_TTB_LTR: i32 = 2; +pub const XOMOrientation_TTB_RTL: i32 = 3; +pub const XOMOrientation_Context: i32 = 4; +pub const XOrientation = u32; +pub const XOMOrientation = extern struct { + num_orientation: i32 = 0, + orientation: [*c]XOrientation = @import("std").mem.zeroes([*c]XOrientation), +}; +pub const XOMFontInfo = extern struct { + num_font: i32 = 0, + font_struct_list: [*c][*c]XFontStruct = @import("std").mem.zeroes([*c][*c]XFontStruct), + font_name_list: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), +}; +pub const struct__XIM = opaque {}; +pub const XIM = ?*struct__XIM; +pub const struct__XIC = opaque {}; +pub const XIC = ?*struct__XIC; +pub const XIMProc = ?*const fn (XIM, ?*anyopaque, ?*anyopaque) callconv(.c) void; +pub const XICProc = ?*const fn (XIC, ?*anyopaque, ?*anyopaque) callconv(.c) i32; +pub const XIDProc = ?*const fn (?*Display, ?*anyopaque, ?*anyopaque) callconv(.c) void; +pub const XIMStyle = u64; +pub const XIMStyles = extern struct { + count_styles: u16 = 0, + supported_styles: [*c]XIMStyle = @import("std").mem.zeroes([*c]XIMStyle), +}; +pub const XVaNestedList = ?*anyopaque; +pub const XIMCallback = extern struct { + client_data: ?*anyopaque = null, + callback: XIMProc = @import("std").mem.zeroes(XIMProc), +}; +pub const XICCallback = extern struct { + client_data: ?*anyopaque = null, + callback: XICProc = @import("std").mem.zeroes(XICProc), +}; +pub const XIMFeedback = u64; +const union_unnamed_5 = extern union { + multi_byte: [*c]u8, + wide_char: [*c]WChar, +}; +pub const struct__XIMText = extern struct { + length: u16 = 0, + feedback: [*c]XIMFeedback = @import("std").mem.zeroes([*c]XIMFeedback), + encoding_is_wchar: i32 = 0, + string: union_unnamed_5 = @import("std").mem.zeroes(union_unnamed_5), +}; +pub const XIMText = struct__XIMText; +pub const XIMPreeditState = u64; +pub const struct__XIMPreeditStateNotifyCallbackStruct = extern struct { + state: XIMPreeditState = @import("std").mem.zeroes(XIMPreeditState), +}; +pub const XIMPreeditStateNotifyCallbackStruct = struct__XIMPreeditStateNotifyCallbackStruct; +pub const XIMResetState = u64; +pub const XIMStringConversionFeedback = u64; +const union_unnamed_6 = extern union { + mbs: [*c]u8, + wcs: [*c]WChar, +}; +pub const struct__XIMStringConversionText = extern struct { + length: u16 = 0, + feedback: [*c]XIMStringConversionFeedback = @import("std").mem.zeroes([*c]XIMStringConversionFeedback), + encoding_is_wchar: i32 = 0, + string: union_unnamed_6 = @import("std").mem.zeroes(union_unnamed_6), +}; +pub const XIMStringConversionText = struct__XIMStringConversionText; +pub const XIMStringConversionPosition = u16; +pub const XIMStringConversionType = u16; +pub const XIMStringConversionOperation = u16; +pub const XIMForwardChar: i32 = 0; +pub const XIMBackwardChar: i32 = 1; +pub const XIMForwardWord: i32 = 2; +pub const XIMBackwardWord: i32 = 3; +pub const XIMCaretUp: i32 = 4; +pub const XIMCaretDown: i32 = 5; +pub const XIMNextLine: i32 = 6; +pub const XIMPreviousLine: i32 = 7; +pub const XIMLineStart: i32 = 8; +pub const XIMLineEnd: i32 = 9; +pub const XIMAbsolutePosition: i32 = 10; +pub const XIMDontChange: i32 = 11; +pub const XIMCaretDirection = u32; +pub const struct__XIMStringConversionCallbackStruct = extern struct { + position: XIMStringConversionPosition = @import("std").mem.zeroes(XIMStringConversionPosition), + direction: XIMCaretDirection = @import("std").mem.zeroes(XIMCaretDirection), + operation: XIMStringConversionOperation = @import("std").mem.zeroes(XIMStringConversionOperation), + factor: u16 = 0, + text: [*c]XIMStringConversionText = @import("std").mem.zeroes([*c]XIMStringConversionText), +}; +pub const XIMStringConversionCallbackStruct = struct__XIMStringConversionCallbackStruct; +pub const struct__XIMPreeditDrawCallbackStruct = extern struct { + caret: i32 = 0, + chg_first: i32 = 0, + chg_length: i32 = 0, + text: [*c]XIMText = @import("std").mem.zeroes([*c]XIMText), +}; +pub const XIMPreeditDrawCallbackStruct = struct__XIMPreeditDrawCallbackStruct; +pub const XIMIsInvisible: i32 = 0; +pub const XIMIsPrimary: i32 = 1; +pub const XIMIsSecondary: i32 = 2; +pub const XIMCaretStyle = u32; +pub const struct__XIMPreeditCaretCallbackStruct = extern struct { + position: i32 = 0, + direction: XIMCaretDirection = @import("std").mem.zeroes(XIMCaretDirection), + style: XIMCaretStyle = @import("std").mem.zeroes(XIMCaretStyle), +}; +pub const XIMPreeditCaretCallbackStruct = struct__XIMPreeditCaretCallbackStruct; +pub const XIMTextType: i32 = 0; +pub const XIMBitmapType: i32 = 1; +pub const XIMStatusDataType = u32; +const union_unnamed_7 = extern union { + text: [*c]XIMText, + bitmap: Pixmap, +}; +pub const struct__XIMStatusDrawCallbackStruct = extern struct { + type: XIMStatusDataType = @import("std").mem.zeroes(XIMStatusDataType), + data: union_unnamed_7 = @import("std").mem.zeroes(union_unnamed_7), +}; +pub const XIMStatusDrawCallbackStruct = struct__XIMStatusDrawCallbackStruct; +pub const struct__XIMHotKeyTrigger = extern struct { + keysym: KeySym = @import("std").mem.zeroes(KeySym), + modifier: i32 = 0, + modifier_mask: i32 = 0, +}; +pub const XIMHotKeyTrigger = struct__XIMHotKeyTrigger; +pub const struct__XIMHotKeyTriggers = extern struct { + num_hot_key: i32 = 0, + key: [*c]XIMHotKeyTrigger = @import("std").mem.zeroes([*c]XIMHotKeyTrigger), +}; +pub const XIMHotKeyTriggers = struct__XIMHotKeyTriggers; +pub const XIMHotKeyState = u64; +pub const XIMValuesList = extern struct { + count_values: u16 = 0, + supported_values: [*c][*c]u8 = @import("std").mem.zeroes([*c][*c]u8), +}; + +pub inline fn DisplayOfScreen(s: anytype) @TypeOf(s.*.display) { + _ = &s; + return s.*.display; +} +pub inline fn RootWindowOfScreen(s: anytype) @TypeOf(s.*.root) { + _ = &s; + return s.*.root; +} +pub inline fn BlackPixelOfScreen(s: anytype) @TypeOf(s.*.black_pixel) { + _ = &s; + return s.*.black_pixel; +} +pub inline fn WhitePixelOfScreen(s: anytype) @TypeOf(s.*.white_pixel) { + _ = &s; + return s.*.white_pixel; +} +pub inline fn DefaultColormapOfScreen(s: anytype) @TypeOf(s.*.cmap) { + _ = &s; + return s.*.cmap; +} +pub inline fn DefaultDepthOfScreen(s: anytype) @TypeOf(s.*.root_depth) { + _ = &s; + return s.*.root_depth; +} +pub inline fn DefaultGCOfScreen(s: anytype) @TypeOf(s.*.default_gc) { + _ = &s; + return s.*.default_gc; +} +pub inline fn DefaultVisualOfScreen(s: anytype) @TypeOf(s.*.root_visual) { + _ = &s; + return s.*.root_visual; +} +pub inline fn WidthOfScreen(s: anytype) @TypeOf(s.*.width) { + _ = &s; + return s.*.width; +} +pub inline fn HeightOfScreen(s: anytype) @TypeOf(s.*.height) { + _ = &s; + return s.*.height; +} +pub inline fn WidthMMOfScreen(s: anytype) @TypeOf(s.*.mwidth) { + _ = &s; + return s.*.mwidth; +} +pub inline fn HeightMMOfScreen(s: anytype) @TypeOf(s.*.mheight) { + _ = &s; + return s.*.mheight; +} +pub inline fn PlanesOfScreen(s: anytype) @TypeOf(s.*.root_depth) { + _ = &s; + return s.*.root_depth; +} +pub inline fn CellsOfScreen(s: anytype) @TypeOf(DefaultVisualOfScreen(s).*.map_entries) { + _ = &s; + return DefaultVisualOfScreen(s).*.map_entries; +} +pub inline fn MinCmapsOfScreen(s: anytype) @TypeOf(s.*.min_maps) { + _ = &s; + return s.*.min_maps; +} +pub inline fn MaxCmapsOfScreen(s: anytype) @TypeOf(s.*.max_maps) { + _ = &s; + return s.*.max_maps; +} +pub inline fn DoesSaveUnders(s: anytype) @TypeOf(s.*.save_unders) { + _ = &s; + return s.*.save_unders; +} +pub inline fn DoesBackingStore(s: anytype) @TypeOf(s.*.backing_store) { + _ = &s; + return s.*.backing_store; +} +pub inline fn EventMaskOfScreen(s: anytype) @TypeOf(s.*.root_input_mask) { + _ = &s; + return s.*.root_input_mask; +} + +pub const XNRequiredCharSet = "requiredCharSet"; +pub const XNQueryOrientation = "queryOrientation"; +pub const XNBaseFontName = "baseFontName"; +pub const XNOMAutomatic = "omAutomatic"; +pub const XNMissingCharSet = "missingCharSet"; +pub const XNDefaultString = "defaultString"; +pub const XNOrientation = "orientation"; +pub const XNDirectionalDependentDrawing = "directionalDependentDrawing"; +pub const XNContextualDrawing = "contextualDrawing"; +pub const XNFontInfo = "fontInfo"; +pub const XIMPreeditArea = @as(i64, 0x0001); +pub const XIMPreeditCallbacks = @as(i64, 0x0002); +pub const XIMPreeditPosition = @as(i64, 0x0004); +pub const XIMPreeditNothing = @as(i64, 0x0008); +pub const XIMPreeditNone = @as(i64, 0x0010); +pub const XIMStatusArea = @as(i64, 0x0100); +pub const XIMStatusCallbacks = @as(i64, 0x0200); +pub const XIMStatusNothing = @as(i64, 0x0400); +pub const XIMStatusNone = @as(i64, 0x0800); +pub const XNVaNestedList = "XNVaNestedList"; +pub const XNQueryInputStyle = "queryInputStyle"; +pub const XNClientWindow = "clientWindow"; +pub const XNInputStyle = "inputStyle"; +pub const XNFocusWindow = "focusWindow"; +pub const XNResourceName = "resourceName"; +pub const XNResourceClass = "resourceClass"; +pub const XNGeometryCallback = "geometryCallback"; +pub const XNDestroyCallback = "destroyCallback"; +pub const XNFilterEvents = "filterEvents"; +pub const XNPreeditStartCallback = "preeditStartCallback"; +pub const XNPreeditDoneCallback = "preeditDoneCallback"; +pub const XNPreeditDrawCallback = "preeditDrawCallback"; +pub const XNPreeditCaretCallback = "preeditCaretCallback"; +pub const XNPreeditStateNotifyCallback = "preeditStateNotifyCallback"; +pub const XNPreeditAttributes = "preeditAttributes"; +pub const XNStatusStartCallback = "statusStartCallback"; +pub const XNStatusDoneCallback = "statusDoneCallback"; +pub const XNStatusDrawCallback = "statusDrawCallback"; +pub const XNStatusAttributes = "statusAttributes"; +pub const XNArea = "area"; +pub const XNAreaNeeded = "areaNeeded"; +pub const XNSpotLocation = "spotLocation"; +pub const XNColormap = "colorMap"; +pub const XNStdColormap = "stdColorMap"; +pub const XNForeground = "foreground"; +pub const XNBackground = "background"; +pub const XNBackgroundPixmap = "backgroundPixmap"; +pub const XNFontSet = "fontSet"; +pub const XNLineSpace = "lineSpace"; +pub const XNCursor = "cursor"; +pub const XNQueryIMValuesList = "queryIMValuesList"; +pub const XNQueryICValuesList = "queryICValuesList"; +pub const XNVisiblePosition = "visiblePosition"; +pub const XNR6PreeditCallback = "r6PreeditCallback"; +pub const XNStringConversionCallback = "stringConversionCallback"; +pub const XNStringConversion = "stringConversion"; +pub const XNResetState = "resetState"; +pub const XNHotKey = "hotKey"; +pub const XNHotKeyState = "hotKeyState"; +pub const XNPreeditState = "preeditState"; +pub const XNSeparatorofNestedList = "separatorofNestedList"; +pub const XBufferOverflow = -@as(i32, 1); +pub const XLookupNone = @as(i32, 1); +pub const XLookupChars = @as(i32, 2); +pub const XLookupKeySym = @as(i32, 3); +pub const XLookupBoth = @as(i32, 4); +pub const XIMReverse = @as(i64, 1); +pub const XIMUnderline = @as(i64, 1) << @as(i32, 1); +pub const XIMHighlight = @as(i64, 1) << @as(i32, 2); +pub const XIMPrimary = @as(i64, 1) << @as(i32, 5); +pub const XIMSecondary = @as(i64, 1) << @as(i32, 6); +pub const XIMTertiary = @as(i64, 1) << @as(i32, 7); +pub const XIMVisibleToForward = @as(i64, 1) << @as(i32, 8); +pub const XIMVisibleToBackword = @as(i64, 1) << @as(i32, 9); +pub const XIMVisibleToCenter = @as(i64, 1) << @as(i32, 10); +pub const XIMPreeditUnKnown = @as(i64, 0); +pub const XIMPreeditEnable = @as(i64, 1); +pub const XIMPreeditDisable = @as(i64, 1) << @as(i32, 1); +pub const XIMInitialState = @as(i64, 1); +pub const XIMPreserveState = @as(i64, 1) << @as(i32, 1); +pub const XIMStringConversionLeftEdge = @as(i32, 0x00000001); +pub const XIMStringConversionRightEdge = @as(i32, 0x00000002); +pub const XIMStringConversionTopEdge = @as(i32, 0x00000004); +pub const XIMStringConversionBottomEdge = @as(i32, 0x00000008); +pub const XIMStringConversionConcealed = @as(i32, 0x00000010); +pub const XIMStringConversionWrapped = @as(i32, 0x00000020); +pub const XIMStringConversionBuffer = @as(i32, 0x0001); +pub const XIMStringConversionLine = @as(i32, 0x0002); +pub const XIMStringConversionWord = @as(i32, 0x0003); +pub const XIMStringConversionChar = @as(i32, 0x0004); +pub const XIMStringConversionSubstitution = @as(i32, 0x0001); +pub const XIMStringConversionRetrieval = @as(i32, 0x0002); +pub const XIMHotKeyStateON = @as(i64, 0x0001); +pub const XIMHotKeyStateOFF = @as(i64, 0x0002); + +// --- MARK: EXTERN FUNCTIONS + +pub const import = struct { + pub extern fn XActivateScreenSaver(?*Display) i32; + pub extern fn XAddConnectionWatch(?*Display, XConnectionWatchProc, ?*anyopaque) i32; + pub extern fn XAddExtension(?*Display) [*c]XExtCodes; + pub extern fn XAddHost(?*Display, [*c]XHostAddress) i32; + pub extern fn XAddHosts(?*Display, [*c]XHostAddress, i32) i32; + pub extern fn XAddToExtensionList([*c][*c]XExtData, [*c]XExtData) i32; + pub extern fn XAddToSaveSet(?*Display, Window) i32; + pub extern fn XAllocColor(?*Display, Colormap, [*c]XColor) i32; + pub extern fn XAllocColorCells(?*Display, Colormap, i32, [*c]u64, u32, [*c]u64, u32) i32; + pub extern fn XAllocColorPlanes(?*Display, Colormap, i32, [*c]u64, i32, i32, i32, i32, [*c]u64, [*c]u64, [*c]u64) i32; + pub extern fn XAllocNamedColor(?*Display, Colormap, [*c]const u8, [*c]XColor, [*c]XColor) i32; + pub extern fn XAllowEvents(?*Display, i32, Time) i32; + pub extern fn XAllPlanes() u64; + pub extern fn XAutoRepeatOff(?*Display) i32; + pub extern fn XAutoRepeatOn(?*Display) i32; + pub extern fn XBaseFontNameListOfFontSet(XFontSet) [*c]u8; + pub extern fn XBell(?*Display, i32) i32; + pub extern fn XBitmapBitOrder(?*Display) i32; + pub extern fn XBitmapPad(?*Display) i32; + pub extern fn XBitmapUnit(?*Display) i32; + pub extern fn XBlackPixel(?*Display, i32) u64; + pub extern fn XBlackPixelOfScreen([*c]Screen) u64; + pub extern fn XCellsOfScreen([*c]Screen) i32; + pub extern fn XChangeActivePointerGrab(?*Display, u32, Cursor, Time) i32; + pub extern fn XChangeGC(?*Display, ?*GC, u64, [*c]XGCValues) i32; + pub extern fn XChangeKeyboardControl(?*Display, u64, [*c]XKeyboardControl) i32; + pub extern fn XChangeKeyboardMapping(?*Display, i32, i32, [*c]KeySym, i32) i32; + pub extern fn XChangePointerControl(?*Display, i32, i32, i32, i32, i32) i32; + pub extern fn XChangeProperty(?*Display, Window, Atom, Atom, i32, i32, [*c]const u8, i32) i32; + pub extern fn XChangeSaveSet(?*Display, Window, i32) i32; + pub extern fn XChangeWindowAttributes(?*Display, Window, u64, [*c]XSetWindowAttributes) i32; + pub extern fn XCheckIfEvent(?*Display, [*c]XEvent, ?*const fn (?*Display, [*c]XEvent, ?*anyopaque) callconv(.c) i32, ?*anyopaque) i32; + pub extern fn XCheckMaskEvent(?*Display, i64, [*c]XEvent) i32; + pub extern fn XCheckTypedEvent(?*Display, i32, [*c]XEvent) i32; + pub extern fn XCheckTypedWindowEvent(?*Display, Window, i32, [*c]XEvent) i32; + pub extern fn XCheckWindowEvent(?*Display, Window, i64, [*c]XEvent) i32; + pub extern fn XCirculateSubwindows(?*Display, Window, i32) i32; + pub extern fn XCirculateSubwindowsDown(?*Display, Window) i32; + pub extern fn XCirculateSubwindowsUp(?*Display, Window) i32; + pub extern fn XClearArea(?*Display, Window, i32, i32, u32, u32, i32) i32; + pub extern fn XClearWindow(?*Display, Window) i32; + pub extern fn XCloseDisplay(display: ?*Display) i32; + pub extern fn XCloseIM(XIM) i32; + pub extern fn XCloseOM(XOM) i32; + pub extern fn XConfigureWindow(?*Display, Window, u32, [*c]XWindowChanges) i32; + pub extern fn XConnectionNumber(?*Display) i32; + pub extern fn XContextDependentDrawing(XFontSet) i32; + pub extern fn XContextualDrawing(XFontSet) i32; + pub extern fn XConvertSelection(?*Display, Atom, Atom, Atom, Window, Time) i32; + pub extern fn XCopyArea(?*Display, Drawable, Drawable, ?*GC, i32, i32, u32, u32, i32, i32) i32; + pub extern fn XCopyColormapAndFree(?*Display, Colormap) Colormap; + pub extern fn XCopyGC(?*Display, ?*GC, u64, ?*GC) i32; + pub extern fn XCopyPlane(?*Display, Drawable, Drawable, ?*GC, i32, i32, u32, u32, i32, i32, u64) i32; + pub extern fn XCreateBitmapFromData(?*Display, Drawable, [*c]const u8, u32, u32) Pixmap; + pub extern fn XCreateColormap(?*Display, Window, [*c]Visual, i32) Colormap; + pub extern fn XCreateFontCursor(?*Display, u32) Cursor; + pub extern fn XCreateFontSet(?*Display, [*c]const u8, [*c][*c][*c]u8, [*c]i32, [*c][*c]u8) XFontSet; + pub extern fn XCreateGC(display: ?*Display, d: Drawable, valuemask: ValueMask(XGCValues), values: ?*XGCValues) ?*GC; + pub extern fn XCreateGlyphCursor(?*Display, Font, Font, u32, u32, [*c]const XColor, [*c]const XColor) Cursor; + pub extern fn XCreateIC(XIM, ...) XIC; + pub extern fn XCreateImage(?*Display, [*c]Visual, u32, i32, i32, [*c]u8, u32, u32, i32, i32) [*c]XImage; + pub extern fn XCreateOC(XOM, ...) XOC; + pub extern fn XCreatePixmap(?*Display, Drawable, u32, u32, u32) Pixmap; + pub extern fn XCreatePixmapCursor(?*Display, Pixmap, Pixmap, [*c]XColor, [*c]XColor, u32, u32) Cursor; + pub extern fn XCreatePixmapFromBitmapData(?*Display, Drawable, [*c]u8, u32, u32, u64, u64, u32) Pixmap; + pub extern fn XCreateSimpleWindow(display: ?*Display, parent: Window, x: i32, y: i32, width: u32, height: u32, border_width: u32, border: u64, background: u64) Window; + pub extern fn XCreateWindow(display: ?*Display, parent: Window, x: i32, y: i32, width: u32, height: u32, border_width: u32, depth: i32, class: u32, visual: ?*Visual, valuemask: ValueMask(XSetWindowAttributes), attributes: *XSetWindowAttributes) Window; + pub extern fn XDefaultColormap(?*Display, i32) Colormap; + pub extern fn XDefaultColormapOfScreen([*c]Screen) Colormap; + pub extern fn XDefaultDepth(?*Display, i32) i32; + pub extern fn XDefaultDepthOfScreen([*c]Screen) i32; + pub extern fn XDefaultGC(?*Display, i32) ?*GC; + pub extern fn XDefaultGCOfScreen([*c]Screen) ?*GC; + pub extern fn XDefaultRootWindow(?*Display) Window; + pub extern fn XDefaultScreen(?*Display) i32; + pub extern fn XDefaultScreenOfDisplay(?*Display) [*c]Screen; + pub extern fn XDefaultVisual(?*Display, i32) [*c]Visual; + pub extern fn XDefaultVisualOfScreen([*c]Screen) [*c]Visual; + pub extern fn XDefineCursor(?*Display, Window, Cursor) i32; + pub extern fn XDeleteModifiermapEntry([*c]XModifierKeymap, KeyCode, i32) [*c]XModifierKeymap; + pub extern fn XDeleteProperty(?*Display, Window, Atom) i32; + pub extern fn XDestroyIC(XIC) void; + pub extern fn XDestroyOC(XOC) void; + pub extern fn XDestroySubwindows(display: ?*Display, w: Window) i32; + pub extern fn XDestroyWindow(display: ?*Display, w: Window) i32; + pub extern fn XDirectionalDependentDrawing(XFontSet) i32; + pub extern fn XDisableAccessControl(?*Display) i32; + pub extern fn XDisplayCells(?*Display, i32) i32; + pub extern fn XDisplayHeight(?*Display, i32) i32; + pub extern fn XDisplayHeightMM(?*Display, i32) i32; + pub extern fn XDisplayKeycodes(?*Display, [*c]i32, [*c]i32) i32; + pub extern fn XDisplayMotionBufferSize(?*Display) u64; + pub extern fn XDisplayName([*c]const u8) [*c]u8; + pub extern fn XDisplayOfIM(XIM) ?*Display; + pub extern fn XDisplayOfOM(XOM) ?*Display; + pub extern fn XDisplayOfScreen([*c]Screen) ?*Display; + pub extern fn XDisplayPlanes(?*Display, i32) i32; + pub extern fn XDisplayString(?*Display) [*c]u8; + pub extern fn XDisplayWidth(?*Display, i32) i32; + pub extern fn XDisplayWidthMM(?*Display, i32) i32; + pub extern fn XDoesBackingStore([*c]Screen) i32; + pub extern fn XDoesSaveUnders([*c]Screen) i32; + pub extern fn XDrawArc(?*Display, Drawable, ?*GC, i32, i32, u32, u32, i32, i32) i32; + pub extern fn XDrawArcs(?*Display, Drawable, ?*GC, [*c]XArc, i32) i32; + pub extern fn XDrawImageString(?*Display, Drawable, ?*GC, i32, i32, [*c]const u8, i32) i32; + pub extern fn XDrawImageString16(?*Display, Drawable, ?*GC, i32, i32, [*c]const XChar2b, i32) i32; + pub extern fn XDrawLine(?*Display, Drawable, ?*GC, i32, i32, i32, i32) i32; + pub extern fn XDrawLines(?*Display, Drawable, ?*GC, [*c]XPoint, i32, i32) i32; + pub extern fn XDrawPoint(?*Display, Drawable, ?*GC, i32, i32) i32; + pub extern fn XDrawPoints(?*Display, Drawable, ?*GC, [*c]XPoint, i32, i32) i32; + pub extern fn XDrawRectangle(?*Display, Drawable, ?*GC, i32, i32, u32, u32) i32; + pub extern fn XDrawRectangles(?*Display, Drawable, ?*GC, [*c]XRectangle, i32) i32; + pub extern fn XDrawSegments(?*Display, Drawable, ?*GC, [*c]XSegment, i32) i32; + pub extern fn XDrawString(?*Display, Drawable, ?*GC, i32, i32, [*c]const u8, i32) i32; + pub extern fn XDrawString16(?*Display, Drawable, ?*GC, i32, i32, [*c]const XChar2b, i32) i32; + pub extern fn XDrawText(?*Display, Drawable, ?*GC, i32, i32, [*c]XTextItem, i32) i32; + pub extern fn XDrawText16(?*Display, Drawable, ?*GC, i32, i32, [*c]XTextItem16, i32) i32; + pub extern fn XEHeadOfExtensionList(XEDataObject) [*c][*c]XExtData; + pub extern fn XEnableAccessControl(?*Display) i32; + pub extern fn XEventMaskOfScreen([*c]Screen) i64; + pub extern fn XEventsQueued(?*Display, i32) i32; + pub extern fn XExtendedMaxRequestSize(?*Display) i64; + pub extern fn XExtentsOfFontSet(XFontSet) [*c]XFontSetExtents; + pub extern fn XFetchBuffer(?*Display, [*c]i32, i32) [*c]u8; + pub extern fn XFetchBytes(?*Display, [*c]i32) [*c]u8; + pub extern fn XFetchName(?*Display, Window, [*c][*c]u8) i32; + pub extern fn XFillArc(?*Display, Drawable, ?*GC, i32, i32, u32, u32, i32, i32) i32; + pub extern fn XFillArcs(?*Display, Drawable, ?*GC, [*c]XArc, i32) i32; + pub extern fn XFillPolygon(?*Display, Drawable, ?*GC, [*c]XPoint, i32, i32, i32) i32; + pub extern fn XFillRectangle(?*Display, Drawable, ?*GC, i32, i32, u32, u32) i32; + pub extern fn XFillRectangles(?*Display, Drawable, ?*GC, [*c]XRectangle, i32) i32; + pub extern fn XFilterEvent([*c]XEvent, Window) i32; + pub extern fn XFindOnExtensionList([*c][*c]XExtData, i32) [*c]XExtData; + pub extern fn XFlush(?*Display) i32; + pub extern fn XFlushGC(?*Display, ?*GC) void; + pub extern fn XFontsOfFontSet(XFontSet, [*c][*c][*c]XFontStruct, [*c][*c][*c]u8) i32; + pub extern fn XForceScreenSaver(?*Display, i32) i32; + pub extern fn XFree(?*anyopaque) i32; + pub extern fn XFreeColormap(?*Display, Colormap) i32; + pub extern fn XFreeColors(?*Display, Colormap, [*c]u64, i32, u64) i32; + pub extern fn XFreeCursor(?*Display, Cursor) i32; + pub extern fn XFreeEventData(?*Display, [*c]XGenericEventCookie) void; + pub extern fn XFreeExtensionList([*c][*c]u8) i32; + pub extern fn XFreeFont(?*Display, [*c]XFontStruct) i32; + pub extern fn XFreeFontInfo([*c][*c]u8, [*c]XFontStruct, i32) i32; + pub extern fn XFreeFontNames([*c][*c]u8) i32; + pub extern fn XFreeFontPath([*c][*c]u8) i32; + pub extern fn XFreeFontSet(?*Display, XFontSet) void; + pub extern fn XFreeGC(display: ?*Display, gc: ?*GC) i32; + pub extern fn XFreeModifiermap([*c]XModifierKeymap) i32; + pub extern fn XFreePixmap(?*Display, Pixmap) i32; + pub extern fn XFreeStringList([*c][*c]u8) void; + pub extern fn XFreeThreads() i32; + pub extern fn XGContextFromGC(?*GC) GContext; + pub extern fn XGeometry(?*Display, i32, [*c]const u8, [*c]const u8, u32, u32, u32, i32, i32, [*c]i32, [*c]i32, [*c]i32, [*c]i32) i32; + pub extern fn XGetAtomName(?*Display, Atom) [*c]u8; + pub extern fn XGetAtomNames(?*Display, [*c]Atom, i32, [*c][*c]u8) i32; + pub extern fn XGetCommand(?*Display, Window, [*c][*c][*c]u8, [*c]i32) i32; + pub extern fn XGetDefault(?*Display, [*c]const u8, [*c]const u8) [*c]u8; + pub extern fn XGetErrorDatabaseText(?*Display, [*c]const u8, [*c]const u8, [*c]const u8, [*c]u8, i32) i32; + pub extern fn XGetErrorText(?*Display, i32, [*c]u8, i32) i32; + pub extern fn XGetEventData(?*Display, [*c]XGenericEventCookie) i32; + pub extern fn XGetFontPath(?*Display, [*c]i32) [*c][*c]u8; + pub extern fn XGetFontProperty([*c]XFontStruct, Atom, [*c]u64) i32; + pub extern fn XGetGCValues(?*Display, ?*GC, u64, [*c]XGCValues) i32; + pub extern fn XGetGeometry(?*Display, Drawable, [*c]Window, [*c]i32, [*c]i32, [*c]u32, [*c]u32, [*c]u32, [*c]u32) i32; + pub extern fn XGetIconName(?*Display, Window, [*c][*c]u8) i32; + pub extern fn XGetICValues(XIC, ...) [*c]u8; + pub extern fn XGetImage(?*Display, Drawable, i32, i32, u32, u32, u64, i32) [*c]XImage; + pub extern fn XGetIMValues(XIM, ...) [*c]u8; + pub extern fn XGetInputFocus(?*Display, [*c]Window, [*c]i32) i32; + pub extern fn XGetKeyboardControl(?*Display, [*c]XKeyboardState) i32; + pub extern fn XGetKeyboardMapping(?*Display, KeyCode, i32, [*c]i32) [*c]KeySym; + pub extern fn XGetModifierMapping(?*Display) [*c]XModifierKeymap; + pub extern fn XGetMotionEvents(?*Display, Window, Time, Time, [*c]i32) [*c]XTimeCoord; + pub extern fn XGetOCValues(XOC, ...) [*c]u8; + pub extern fn XGetOMValues(XOM, ...) [*c]u8; + pub extern fn XGetPointerControl(?*Display, [*c]i32, [*c]i32, [*c]i32) i32; + pub extern fn XGetPointerMapping(?*Display, [*c]u8, i32) i32; + pub extern fn XGetScreenSaver(?*Display, [*c]i32, [*c]i32, [*c]i32, [*c]i32) i32; + pub extern fn XGetSelectionOwner(?*Display, Atom) Window; + pub extern fn XGetSubImage(?*Display, Drawable, i32, i32, u32, u32, u64, i32, [*c]XImage, i32, i32) [*c]XImage; + pub extern fn XGetTransientForHint(?*Display, Window, [*c]Window) i32; + pub extern fn XGetWindowAttributes(?*Display, Window, [*c]XWindowAttributes) i32; + pub extern fn XGetWindowProperty(?*Display, Window, Atom, i64, i64, i32, Atom, [*c]Atom, [*c]i32, [*c]u64, [*c]u64, [*c][*c]u8) i32; + pub extern fn XGetWMColormapWindows(?*Display, Window, [*c][*c]Window, [*c]i32) i32; + pub extern fn XGetWMProtocols(?*Display, Window, [*c][*c]Atom, [*c]i32) i32; + pub extern fn XGrabButton(?*Display, u32, u32, Window, i32, u32, i32, i32, Window, Cursor) i32; + pub extern fn XGrabKey(?*Display, i32, u32, Window, i32, i32, i32) i32; + pub extern fn XGrabKeyboard(?*Display, Window, i32, i32, i32, Time) i32; + pub extern fn XGrabPointer(?*Display, Window, i32, u32, i32, i32, Window, Cursor, Time) i32; + pub extern fn XGrabServer(?*Display) i32; + pub extern fn XHeightMMOfScreen([*c]Screen) i32; + pub extern fn XHeightOfScreen([*c]Screen) i32; + pub extern fn XIconifyWindow(?*Display, Window, i32) i32; + pub extern fn XIfEvent(?*Display, [*c]XEvent, ?*const fn (?*Display, [*c]XEvent, ?*anyopaque) callconv(.c) i32, ?*anyopaque) i32; + pub extern fn XImageByteOrder(?*Display) i32; + pub extern fn XIMOfIC(XIC) XIM; + pub extern fn XInitExtension(?*Display, [*c]const u8) [*c]XExtCodes; + pub extern fn XInitImage([*c]XImage) i32; + pub extern fn XInitThreads() i32; + pub extern fn XInsertModifiermapEntry([*c]XModifierKeymap, KeyCode, i32) [*c]XModifierKeymap; + pub extern fn XInstallColormap(?*Display, Colormap) i32; + pub extern fn XInternalConnectionNumbers(?*Display, [*c][*c]i32, [*c]i32) i32; + pub extern fn XInternAtom(display: ?*Display, atom_name: ?[*:0]const u8, only_if_exists: Bool) Atom; + pub extern fn XInternAtoms(?*Display, [*c][*c]u8, i32, i32, [*c]Atom) i32; + pub extern fn XKeycodeToKeysym(?*Display, KeyCode, i32) KeySym; + pub extern fn XKeysymToKeycode(?*Display, KeySym) KeyCode; + pub extern fn XKeysymToString(KeySym) [*c]u8; + pub extern fn XKillClient(?*Display, XID) i32; + pub extern fn XLastKnownRequestProcessed(?*Display) u64; + pub extern fn XListDepths(?*Display, i32, [*c]i32) [*c]i32; + pub extern fn XListExtensions(?*Display, [*c]i32) [*c][*c]u8; + pub extern fn XListFonts(?*Display, [*c]const u8, i32, [*c]i32) [*c][*c]u8; + pub extern fn XListFontsWithInfo(?*Display, [*c]const u8, i32, [*c]i32, [*c][*c]XFontStruct) [*c][*c]u8; + pub extern fn XListHosts(?*Display, [*c]i32, [*c]i32) [*c]XHostAddress; + pub extern fn XListInstalledColormaps(?*Display, Window, [*c]i32) [*c]Colormap; + pub extern fn XListPixmapFormats(?*Display, [*c]i32) [*c]XPixmapFormatValues; + pub extern fn XListProperties(?*Display, Window, [*c]i32) [*c]Atom; + pub extern fn XLoadFont(?*Display, [*c]const u8) Font; + pub extern fn XLoadQueryFont(?*Display, [*c]const u8) [*c]XFontStruct; + pub extern fn XLocaleOfFontSet(XFontSet) [*c]u8; + pub extern fn XLocaleOfIM(XIM) [*c]u8; + pub extern fn XLocaleOfOM(XOM) [*c]u8; + pub extern fn XLockDisplay(?*Display) void; + pub extern fn XLookupColor(?*Display, Colormap, [*c]const u8, [*c]XColor, [*c]XColor) i32; + pub extern fn XLookupKeysym([*c]XKeyEvent, i32) KeySym; + pub extern fn XLowerWindow(?*Display, Window) i32; + pub extern fn XMapRaised(?*Display, Window) i32; + pub extern fn XMapSubwindows(?*Display, Window) i32; + pub extern fn XMapWindow(display: ?*Display, w: Window) i32; + pub extern fn XMaskEvent(?*Display, i64, [*c]XEvent) i32; + pub extern fn XMaxCmapsOfScreen([*c]Screen) i32; + pub extern fn XMaxRequestSize(?*Display) i64; + pub extern fn XmbDrawImageString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const u8, i32) void; + pub extern fn XmbDrawString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const u8, i32) void; + pub extern fn XmbDrawText(?*Display, Drawable, ?*GC, i32, i32, [*c]XmbTextItem, i32) void; + pub extern fn XmbLookupString(XIC, [*c]XKeyPressedEvent, [*c]u8, i32, [*c]KeySym, [*c]i32) i32; + pub extern fn XmbResetIC(XIC) [*c]u8; + pub extern fn XmbTextEscapement(XFontSet, [*c]const u8, i32) i32; + pub extern fn XmbTextExtents(XFontSet, [*c]const u8, i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn XmbTextPerCharExtents(XFontSet, [*c]const u8, i32, [*c]XRectangle, [*c]XRectangle, i32, [*c]i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn XMinCmapsOfScreen([*c]Screen) i32; + pub extern fn XMoveResizeWindow(?*Display, Window, i32, i32, u32, u32) i32; + pub extern fn XMoveWindow(?*Display, Window, i32, i32) i32; + pub extern fn XNewModifiermap(i32) [*c]XModifierKeymap; + pub extern fn XNextEvent(display: ?*Display, event_return: ?*XEvent) i32; + pub extern fn XNextRequest(?*Display) u64; + pub extern fn XNoOp(?*Display) i32; + pub extern fn XOMOfOC(XOC) XOM; + pub extern fn XOpenDisplay(display_name: ?[*:0]const u8) ?*Display; + pub extern fn XOpenIM(?*Display, ?*_XrmHashBucketRec, [*c]u8, [*c]u8) XIM; + pub extern fn XOpenOM(?*Display, ?*_XrmHashBucketRec, [*c]const u8, [*c]const u8) XOM; + pub extern fn XParseColor(?*Display, Colormap, [*c]const u8, [*c]XColor) i32; + pub extern fn XParseGeometry([*c]const u8, [*c]i32, [*c]i32, [*c]u32, [*c]u32) i32; + pub extern fn XPeekEvent(?*Display, [*c]XEvent) i32; + pub extern fn XPeekIfEvent(?*Display, [*c]XEvent, ?*const fn (?*Display, [*c]XEvent, ?*anyopaque) callconv(.c) i32, ?*anyopaque) i32; + pub extern fn XPending(?*Display) i32; + pub extern fn XPlanesOfScreen([*c]Screen) i32; + pub extern fn XProcessInternalConnection(?*Display, i32) void; + pub extern fn XProtocolRevision(?*Display) i32; + pub extern fn XProtocolVersion(?*Display) i32; + pub extern fn XPutBackEvent(?*Display, [*c]XEvent) i32; + pub extern fn XPutImage(?*Display, Drawable, ?*GC, [*c]XImage, i32, i32, i32, i32, u32, u32) i32; + pub extern fn XQLength(?*Display) i32; + pub extern fn XQueryBestCursor(?*Display, Drawable, u32, u32, [*c]u32, [*c]u32) i32; + pub extern fn XQueryBestSize(?*Display, i32, Drawable, u32, u32, [*c]u32, [*c]u32) i32; + pub extern fn XQueryBestStipple(?*Display, Drawable, u32, u32, [*c]u32, [*c]u32) i32; + pub extern fn XQueryBestTile(?*Display, Drawable, u32, u32, [*c]u32, [*c]u32) i32; + pub extern fn XQueryColor(?*Display, Colormap, [*c]XColor) i32; + pub extern fn XQueryColors(?*Display, Colormap, [*c]XColor, i32) i32; + pub extern fn XQueryExtension(?*Display, [*c]const u8, [*c]i32, [*c]i32, [*c]i32) i32; + pub extern fn XQueryFont(?*Display, XID) [*c]XFontStruct; + pub extern fn XQueryKeymap(?*Display, [*c]u8) i32; + pub extern fn XQueryPointer(?*Display, Window, [*c]Window, [*c]Window, [*c]i32, [*c]i32, [*c]i32, [*c]i32, [*c]u32) i32; + pub extern fn XQueryTextExtents(?*Display, XID, [*c]const u8, i32, [*c]i32, [*c]i32, [*c]i32, [*c]XCharStruct) i32; + pub extern fn XQueryTextExtents16(?*Display, XID, [*c]const XChar2b, i32, [*c]i32, [*c]i32, [*c]i32, [*c]XCharStruct) i32; + pub extern fn XQueryTree(?*Display, Window, [*c]Window, [*c]Window, [*c][*c]Window, [*c]u32) i32; + pub extern fn XRaiseWindow(?*Display, Window) i32; + pub extern fn XReadBitmapFile(?*Display, Drawable, [*c]const u8, [*c]u32, [*c]u32, [*c]Pixmap, [*c]i32, [*c]i32) i32; + pub extern fn XReadBitmapFileData([*c]const u8, [*c]u32, [*c]u32, [*c][*c]u8, [*c]i32, [*c]i32) i32; + pub extern fn XRebindKeysym(?*Display, KeySym, [*c]KeySym, i32, [*c]const u8, i32) i32; + pub extern fn XRecolorCursor(?*Display, Cursor, [*c]XColor, [*c]XColor) i32; + pub extern fn XReconfigureWMWindow(?*Display, Window, i32, u32, [*c]XWindowChanges) i32; + pub extern fn XRefreshKeyboardMapping([*c]XMappingEvent) i32; + pub extern fn XRegisterIMInstantiateCallback(?*Display, ?*_XrmHashBucketRec, [*c]u8, [*c]u8, XIDProc, ?*anyopaque) i32; + pub extern fn XRemoveConnectionWatch(?*Display, XConnectionWatchProc, ?*anyopaque) void; + pub extern fn XRemoveFromSaveSet(?*Display, Window) i32; + pub extern fn XRemoveHost(?*Display, [*c]XHostAddress) i32; + pub extern fn XRemoveHosts(?*Display, [*c]XHostAddress, i32) i32; + pub extern fn XReparentWindow(?*Display, Window, Window, i32, i32) i32; + pub extern fn XResetScreenSaver(?*Display) i32; + pub extern fn XResizeWindow(?*Display, Window, u32, u32) i32; + pub extern fn XResourceManagerString(?*Display) [*c]u8; + pub extern fn XRestackWindows(?*Display, [*c]Window, i32) i32; + pub extern fn XrmInitialize() void; + pub extern fn XRootWindow(?*Display, i32) Window; + pub extern fn XRootWindowOfScreen([*c]Screen) Window; + pub extern fn XRotateBuffers(?*Display, i32) i32; + pub extern fn XRotateWindowProperties(?*Display, Window, [*c]Atom, i32, i32) i32; + pub extern fn XScreenCount(?*Display) i32; + pub extern fn XScreenNumberOfScreen([*c]Screen) i32; + pub extern fn XScreenOfDisplay(?*Display, i32) [*c]Screen; + pub extern fn XScreenResourceString([*c]Screen) [*c]u8; + pub extern fn XSelectInput(?*Display, Window, i64) i32; + pub extern fn XSendEvent(?*Display, Window, i32, i64, [*c]XEvent) i32; + pub extern fn XServerVendor(?*Display) [*c]u8; + pub extern fn XSetAccessControl(?*Display, i32) i32; + pub extern fn XSetAfterFunction(?*Display, ?*const fn (?*Display) callconv(.c) i32) ?*const fn (?*Display) callconv(.c) i32; + pub extern fn XSetArcMode(?*Display, ?*GC, i32) i32; + pub extern fn XSetAuthorization([*c]u8, i32, [*c]u8, i32) void; + pub extern fn XSetBackground(?*Display, ?*GC, u64) i32; + pub extern fn XSetClipMask(?*Display, ?*GC, Pixmap) i32; + pub extern fn XSetClipOrigin(?*Display, ?*GC, i32, i32) i32; + pub extern fn XSetClipRectangles(?*Display, ?*GC, i32, i32, [*c]XRectangle, i32, i32) i32; + pub extern fn XSetCloseDownMode(?*Display, i32) i32; + pub extern fn XSetCommand(?*Display, Window, [*c][*c]u8, i32) i32; + pub extern fn XSetDashes(?*Display, ?*GC, i32, [*c]const u8, i32) i32; + pub extern fn XSetErrorHandler(XErrorHandler) XErrorHandler; + pub extern fn XSetFillRule(?*Display, ?*GC, i32) i32; + pub extern fn XSetFillStyle(?*Display, ?*GC, i32) i32; + pub extern fn XSetFont(?*Display, ?*GC, Font) i32; + pub extern fn XSetFontPath(?*Display, [*c][*c]u8, i32) i32; + pub extern fn XSetForeground(?*Display, ?*GC, u64) i32; + pub extern fn XSetFunction(?*Display, ?*GC, i32) i32; + pub extern fn XSetGraphicsExposures(?*Display, ?*GC, i32) i32; + pub extern fn XSetICFocus(XIC) void; + pub extern fn XSetIconName(?*Display, Window, [*c]const u8) i32; + pub extern fn XSetICValues(XIC, ...) [*c]u8; + pub extern fn XSetIMValues(XIM, ...) [*c]u8; + pub extern fn XSetInputFocus(?*Display, Window, i32, Time) i32; + pub extern fn XSetIOErrorExitHandler(?*Display, XIOErrorExitHandler, ?*anyopaque) void; + pub extern fn XSetIOErrorHandler(XIOErrorHandler) XIOErrorHandler; + pub extern fn XSetLineAttributes(?*Display, ?*GC, u32, i32, i32, i32) i32; + pub extern fn XSetLocaleModifiers([*c]const u8) [*c]u8; + pub extern fn XSetModifierMapping(?*Display, [*c]XModifierKeymap) i32; + pub extern fn XSetOCValues(XOC, ...) [*c]u8; + pub extern fn XSetOMValues(XOM, ...) [*c]u8; + pub extern fn XSetPlaneMask(?*Display, ?*GC, u64) i32; + pub extern fn XSetPointerMapping(?*Display, [*c]const u8, i32) i32; + pub extern fn XSetScreenSaver(?*Display, i32, i32, i32, i32) i32; + pub extern fn XSetSelectionOwner(?*Display, Atom, Window, Time) i32; + pub extern fn XSetState(?*Display, ?*GC, u64, u64, i32, u64) i32; + pub extern fn XSetStipple(?*Display, ?*GC, Pixmap) i32; + pub extern fn XSetSubwindowMode(?*Display, ?*GC, i32) i32; + pub extern fn XSetTile(?*Display, ?*GC, Pixmap) i32; + pub extern fn XSetTransientForHint(?*Display, Window, Window) i32; + pub extern fn XSetTSOrigin(?*Display, ?*GC, i32, i32) i32; + pub extern fn XSetWindowBackground(?*Display, Window, u64) i32; + pub extern fn XSetWindowBackgroundPixmap(?*Display, Window, Pixmap) i32; + pub extern fn XSetWindowBorder(?*Display, Window, u64) i32; + pub extern fn XSetWindowBorderPixmap(?*Display, Window, Pixmap) i32; + pub extern fn XSetWindowBorderWidth(?*Display, Window, u32) i32; + pub extern fn XSetWindowColormap(?*Display, Window, Colormap) i32; + pub extern fn XSetWMColormapWindows(?*Display, Window, [*c]Window, i32) i32; + pub extern fn XSetWMProtocols(display: ?*Display, w: Window, protocols: ?[*]Atom, count: i32) Status; + pub extern fn XStoreBuffer(?*Display, [*c]const u8, i32, i32) i32; + pub extern fn XStoreBytes(?*Display, [*c]const u8, i32) i32; + pub extern fn XStoreColor(?*Display, Colormap, [*c]XColor) i32; + pub extern fn XStoreColors(?*Display, Colormap, [*c]XColor, i32) i32; + pub extern fn XStoreName(display: ?*Display, w: Window, window_name: ?[*:0]const u8) i32; + pub extern fn XStoreNamedColor(?*Display, Colormap, [*c]const u8, u64, i32) i32; + pub extern fn XStringToKeysym([*c]const u8) KeySym; + pub extern fn XSupportsLocale() i32; + pub extern fn XSync(?*Display, i32) i32; + pub extern fn XSynchronize(?*Display, i32) ?*const fn (?*Display) callconv(.c) i32; + pub extern fn XTextExtents([*c]XFontStruct, [*c]const u8, i32, [*c]i32, [*c]i32, [*c]i32, [*c]XCharStruct) i32; + pub extern fn XTextExtents16([*c]XFontStruct, [*c]const XChar2b, i32, [*c]i32, [*c]i32, [*c]i32, [*c]XCharStruct) i32; + pub extern fn XTextWidth([*c]XFontStruct, [*c]const u8, i32) i32; + pub extern fn XTextWidth16([*c]XFontStruct, [*c]const XChar2b, i32) i32; + pub extern fn XTranslateCoordinates(?*Display, Window, Window, i32, i32, [*c]i32, [*c]i32, [*c]Window) i32; + pub extern fn XUndefineCursor(?*Display, Window) i32; + pub extern fn XUngrabButton(?*Display, u32, u32, Window) i32; + pub extern fn XUngrabKey(?*Display, i32, u32, Window) i32; + pub extern fn XUngrabKeyboard(?*Display, Time) i32; + pub extern fn XUngrabPointer(?*Display, Time) i32; + pub extern fn XUngrabServer(?*Display) i32; + pub extern fn XUninstallColormap(?*Display, Colormap) i32; + pub extern fn XUnloadFont(?*Display, Font) i32; + pub extern fn XUnlockDisplay(?*Display) void; + pub extern fn XUnmapSubwindows(?*Display, Window) i32; + pub extern fn XUnmapWindow(display: ?*Display, w: Window) i32; + pub extern fn XUnregisterIMInstantiateCallback(?*Display, ?*_XrmHashBucketRec, [*c]u8, [*c]u8, XIDProc, ?*anyopaque) i32; + pub extern fn XUnsetICFocus(XIC) void; + pub extern fn Xutf8DrawImageString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const u8, i32) void; + pub extern fn Xutf8DrawString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const u8, i32) void; + pub extern fn Xutf8DrawText(?*Display, Drawable, ?*GC, i32, i32, [*c]XmbTextItem, i32) void; + pub extern fn Xutf8LookupString(XIC, [*c]XKeyPressedEvent, [*c]u8, i32, [*c]KeySym, [*c]i32) i32; + pub extern fn Xutf8ResetIC(XIC) [*c]u8; + pub extern fn Xutf8TextEscapement(XFontSet, [*c]const u8, i32) i32; + pub extern fn Xutf8TextExtents(XFontSet, [*c]const u8, i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn Xutf8TextPerCharExtents(XFontSet, [*c]const u8, i32, [*c]XRectangle, [*c]XRectangle, i32, [*c]i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn XVaCreateNestedList(i32, ...) XVaNestedList; + pub extern fn XVendorRelease(?*Display) i32; + pub extern fn XVisualIDFromVisual([*c]Visual) VisualID; + pub extern fn XWarpPointer(?*Display, Window, Window, i32, i32, u32, u32, i32, i32) i32; + pub extern fn XwcDrawImageString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const WChar, i32) void; + pub extern fn XwcDrawString(?*Display, Drawable, XFontSet, ?*GC, i32, i32, [*c]const WChar, i32) void; + pub extern fn XwcDrawText(?*Display, Drawable, ?*GC, i32, i32, [*c]XwcTextItem, i32) void; + pub extern fn XwcLookupString(XIC, [*c]XKeyPressedEvent, [*c]WChar, i32, [*c]KeySym, [*c]i32) i32; + pub extern fn XwcResetIC(XIC) [*c]WChar; + pub extern fn XwcTextEscapement(XFontSet, [*c]const WChar, i32) i32; + pub extern fn XwcTextExtents(XFontSet, [*c]const WChar, i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn XwcTextPerCharExtents(XFontSet, [*c]const WChar, i32, [*c]XRectangle, [*c]XRectangle, i32, [*c]i32, [*c]XRectangle, [*c]XRectangle) i32; + pub extern fn XWhitePixel(?*Display, i32) u64; + pub extern fn XWhitePixelOfScreen([*c]Screen) u64; + pub extern fn XWidthMMOfScreen([*c]Screen) i32; + pub extern fn XWidthOfScreen([*c]Screen) i32; + pub extern fn XWindowEvent(?*Display, Window, i64, [*c]XEvent) i32; + pub extern fn XWithdrawWindow(?*Display, Window, i32) i32; + pub extern fn XWriteBitmapFile(?*Display, [*c]const u8, Pixmap, u32, u32, i32, i32) i32; +};