# Auto-generated by gen_xcb_to_py.py - do not edit manually.

# Since many of the generated functions have many parameters, we disable the pylint warning about too many arguments.
# ruff: noqa: PLR0913

from __future__ import annotations

from ctypes import (
    POINTER,
    Array,
    Structure,
    _Pointer,
    c_char,
    c_int,
    c_int16,
    c_uint8,
    c_uint16,
    c_uint32,
)
from enum import IntEnum

from mss.linux.xcbhelpers import (
    LIB,
    XID,
    Connection,
    VoidCookie,
    array_from_xcb,
    initialize_xcb_typed_func,
    list_from_xcb,
)

RANDR_MAJOR_VERSION = 1
RANDR_MINOR_VERSION = 6
RENDER_MAJOR_VERSION = 0
RENDER_MINOR_VERSION = 11
SHM_MAJOR_VERSION = 1
SHM_MINOR_VERSION = 2
XFIXES_MAJOR_VERSION = 6
XFIXES_MINOR_VERSION = 0

# Enum classes


class RandrConnection(IntEnum):
    Connected = 0
    Disconnected = 1
    Unknown = 2


class RandrSetConfig(IntEnum):
    Success = 0
    InvalidConfigTime = 1
    InvalidTime = 2
    Failed = 3


class RenderPictType(IntEnum):
    Indexed = 0
    Direct = 1


class RenderSubPixel(IntEnum):
    Unknown = 0
    HorizontalRGB = 1
    HorizontalBGR = 2
    VerticalRGB = 3
    VerticalBGR = 4
    None_ = 5


class BackingStore(IntEnum):
    NotUseful = 0
    WhenMapped = 1
    Always = 2


class ImageFormat(IntEnum):
    XYBitmap = 0
    XYPixmap = 1
    ZPixmap = 2


class ImageOrder(IntEnum):
    LSBFirst = 0
    MSBFirst = 1


class VisualClass(IntEnum):
    StaticGray = 0
    GrayScale = 1
    StaticColor = 2
    PseudoColor = 3
    TrueColor = 4
    DirectColor = 5


# Generated ctypes structures


class Drawable(XID):
    pass


class Keycode(c_uint8):
    def __eq__(self, other: object) -> bool:
        if isinstance(other, Keycode):
            return self.value == other.value
        return NotImplemented

    def __hash__(self) -> int:
        return hash(self.value)


class Format(Structure):
    _fields_ = (
        ("depth", c_uint8),
        ("bits_per_pixel", c_uint8),
        ("scanline_pad", c_uint8),
        ("pad0", c_uint8 * 5),
    )


class Window(Drawable):
    pass


class Colormap(XID):
    pass


class Visualid(c_uint32):
    def __eq__(self, other: object) -> bool:
        if isinstance(other, Visualid):
            return self.value == other.value
        return NotImplemented

    def __hash__(self) -> int:
        return hash(self.value)


class Visualtype(Structure):
    _fields_ = (
        ("visual_id", Visualid),
        ("class_", c_uint8),
        ("bits_per_rgb_value", c_uint8),
        ("colormap_entries", c_uint16),
        ("red_mask", c_uint32),
        ("green_mask", c_uint32),
        ("blue_mask", c_uint32),
        ("pad0", c_uint8 * 4),
    )


class Depth(Structure):
    _fields_ = (
        ("depth", c_uint8),
        ("pad0", c_uint8 * 1),
        ("visuals_len", c_uint16),
        ("pad1", c_uint8 * 4),
    )


class DepthIterator(Structure):
    _fields_ = (("data", POINTER(Depth)), ("rem", c_int), ("index", c_int))


class Screen(Structure):
    _fields_ = (
        ("root", Window),
        ("default_colormap", Colormap),
        ("white_pixel", c_uint32),
        ("black_pixel", c_uint32),
        ("current_input_masks", c_uint32),
        ("width_in_pixels", c_uint16),
        ("height_in_pixels", c_uint16),
        ("width_in_millimeters", c_uint16),
        ("height_in_millimeters", c_uint16),
        ("min_installed_maps", c_uint16),
        ("max_installed_maps", c_uint16),
        ("root_visual", Visualid),
        ("backing_stores", c_uint8),
        ("save_unders", c_uint8),
        ("root_depth", c_uint8),
        ("allowed_depths_len", c_uint8),
    )


class ScreenIterator(Structure):
    _fields_ = (("data", POINTER(Screen)), ("rem", c_int), ("index", c_int))


class Setup(Structure):
    _fields_ = (
        ("status", c_uint8),
        ("pad0", c_uint8 * 1),
        ("protocol_major_version", c_uint16),
        ("protocol_minor_version", c_uint16),
        ("length", c_uint16),
        ("release_number", c_uint32),
        ("resource_id_base", c_uint32),
        ("resource_id_mask", c_uint32),
        ("motion_buffer_size", c_uint32),
        ("vendor_len", c_uint16),
        ("maximum_request_length", c_uint16),
        ("roots_len", c_uint8),
        ("pixmap_formats_len", c_uint8),
        ("image_byte_order", c_uint8),
        ("bitmap_format_bit_order", c_uint8),
        ("bitmap_format_scanline_unit", c_uint8),
        ("bitmap_format_scanline_pad", c_uint8),
        ("min_keycode", Keycode),
        ("max_keycode", Keycode),
        ("pad1", c_uint8 * 4),
    )


class SetupIterator(Structure):
    _fields_ = (("data", POINTER(Setup)), ("rem", c_int), ("index", c_int))


class Pixmap(Drawable):
    pass


class GetGeometryReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("depth", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("root", Window),
        ("x", c_int16),
        ("y", c_int16),
        ("width", c_uint16),
        ("height", c_uint16),
        ("border_width", c_uint16),
        ("pad0", c_uint8 * 10),
    )


class GetImageReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("depth", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("visual", Visualid),
        ("pad0", c_uint8 * 20),
    )


class Atom(XID):
    pass


class GetPropertyReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("format_", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("type_", Atom),
        ("bytes_after", c_uint32),
        ("value_len", c_uint32),
        ("pad0", c_uint8 * 12),
    )


class RandrQueryVersionReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("major_version", c_uint32),
        ("minor_version", c_uint32),
        ("pad1", c_uint8 * 16),
    )


class Timestamp(c_uint32):
    def __eq__(self, other: object) -> bool:
        if isinstance(other, Timestamp):
            return self.value == other.value
        return NotImplemented

    def __hash__(self) -> int:
        return hash(self.value)


class RandrCrtc(XID):
    pass


class RandrOutput(XID):
    pass


class RandrModeInfo(Structure):
    _fields_ = (
        ("id_", c_uint32),
        ("width", c_uint16),
        ("height", c_uint16),
        ("dot_clock", c_uint32),
        ("hsync_start", c_uint16),
        ("hsync_end", c_uint16),
        ("htotal", c_uint16),
        ("hskew", c_uint16),
        ("vsync_start", c_uint16),
        ("vsync_end", c_uint16),
        ("vtotal", c_uint16),
        ("name_len", c_uint16),
        ("mode_flags", c_uint32),
    )


class RandrGetScreenResourcesReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("timestamp", Timestamp),
        ("config_timestamp", Timestamp),
        ("num_crtcs", c_uint16),
        ("num_outputs", c_uint16),
        ("num_modes", c_uint16),
        ("names_len", c_uint16),
        ("pad1", c_uint8 * 8),
    )


class RandrGetScreenResourcesCurrentReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("timestamp", Timestamp),
        ("config_timestamp", Timestamp),
        ("num_crtcs", c_uint16),
        ("num_outputs", c_uint16),
        ("num_modes", c_uint16),
        ("names_len", c_uint16),
        ("pad1", c_uint8 * 8),
    )


class RandrMode(XID):
    pass


class RandrGetCrtcInfoReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("status", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("timestamp", Timestamp),
        ("x", c_int16),
        ("y", c_int16),
        ("width", c_uint16),
        ("height", c_uint16),
        ("mode", RandrMode),
        ("rotation", c_uint16),
        ("rotations", c_uint16),
        ("num_outputs", c_uint16),
        ("num_possible_outputs", c_uint16),
    )


class RandrGetOutputInfoReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("status", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("timestamp", Timestamp),
        ("crtc", RandrCrtc),
        ("mm_width", c_uint32),
        ("mm_height", c_uint32),
        ("connection", c_uint8),
        ("subpixel_order", c_uint8),
        ("num_crtcs", c_uint16),
        ("num_modes", c_uint16),
        ("num_preferred", c_uint16),
        ("num_clones", c_uint16),
        ("name_len", c_uint16),
    )


class RandrGetOutputPrimaryReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("output", RandrOutput),
    )


class RandrGetOutputPropertyReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("format_", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("type_", Atom),
        ("bytes_after", c_uint32),
        ("num_items", c_uint32),
        ("pad0", c_uint8 * 12),
    )


class RandrMonitorInfo(Structure):
    _fields_ = (
        ("name", Atom),
        ("primary", c_uint8),
        ("automatic", c_uint8),
        ("nOutput", c_uint16),
        ("x", c_int16),
        ("y", c_int16),
        ("width", c_uint16),
        ("height", c_uint16),
        ("width_in_millimeters", c_uint32),
        ("height_in_millimeters", c_uint32),
    )


class RandrMonitorInfoIterator(Structure):
    _fields_ = (("data", POINTER(RandrMonitorInfo)), ("rem", c_int), ("index", c_int))


class RandrGetMonitorsReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("timestamp", Timestamp),
        ("nMonitors", c_uint32),
        ("nOutputs", c_uint32),
        ("pad1", c_uint8 * 12),
    )


class RenderQueryVersionReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("major_version", c_uint32),
        ("minor_version", c_uint32),
        ("pad1", c_uint8 * 16),
    )


class RenderPictformat(XID):
    pass


class RenderDirectformat(Structure):
    _fields_ = (
        ("red_shift", c_uint16),
        ("red_mask", c_uint16),
        ("green_shift", c_uint16),
        ("green_mask", c_uint16),
        ("blue_shift", c_uint16),
        ("blue_mask", c_uint16),
        ("alpha_shift", c_uint16),
        ("alpha_mask", c_uint16),
    )


class RenderPictforminfo(Structure):
    _fields_ = (
        ("id_", RenderPictformat),
        ("type_", c_uint8),
        ("depth", c_uint8),
        ("pad0", c_uint8 * 2),
        ("direct", RenderDirectformat),
        ("colormap", Colormap),
    )


class RenderPictvisual(Structure):
    _fields_ = (
        ("visual", Visualid),
        ("format_", RenderPictformat),
    )


class RenderPictdepth(Structure):
    _fields_ = (
        ("depth", c_uint8),
        ("pad0", c_uint8 * 1),
        ("num_visuals", c_uint16),
        ("pad1", c_uint8 * 4),
    )


class RenderPictdepthIterator(Structure):
    _fields_ = (("data", POINTER(RenderPictdepth)), ("rem", c_int), ("index", c_int))


class RenderPictscreen(Structure):
    _fields_ = (
        ("num_depths", c_uint32),
        ("fallback", RenderPictformat),
    )


class RenderPictscreenIterator(Structure):
    _fields_ = (("data", POINTER(RenderPictscreen)), ("rem", c_int), ("index", c_int))


class RenderQueryPictFormatsReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("num_formats", c_uint32),
        ("num_screens", c_uint32),
        ("num_depths", c_uint32),
        ("num_visuals", c_uint32),
        ("num_subpixel", c_uint32),
        ("pad1", c_uint8 * 4),
    )


class ShmQueryVersionReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("shared_pixmaps", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("major_version", c_uint16),
        ("minor_version", c_uint16),
        ("uid", c_uint16),
        ("gid", c_uint16),
        ("pixmap_format", c_uint8),
        ("pad0", c_uint8 * 15),
    )


class ShmSeg(XID):
    pass


class ShmGetImageReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("depth", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("visual", Visualid),
        ("size", c_uint32),
        ("pad0", c_uint8 * 16),
    )


class ShmCreateSegmentReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("nfd", c_uint8),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("pad0", c_uint8 * 24),
    )


class XfixesQueryVersionReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("major_version", c_uint32),
        ("minor_version", c_uint32),
        ("pad1", c_uint8 * 16),
    )


class XfixesGetCursorImageReply(Structure):
    _fields_ = (
        ("response_type", c_uint8),
        ("pad0", c_uint8 * 1),
        ("sequence", c_uint16),
        ("length", c_uint32),
        ("x", c_int16),
        ("y", c_int16),
        ("width", c_uint16),
        ("height", c_uint16),
        ("xhot", c_uint16),
        ("yhot", c_uint16),
        ("cursor_serial", c_uint32),
        ("pad1", c_uint8 * 8),
    )


def depth_visuals(r: Depth) -> Array[Visualtype]:
    return array_from_xcb(LIB.xcb.xcb_depth_visuals, LIB.xcb.xcb_depth_visuals_length, r)


def screen_allowed_depths(r: Screen) -> list[Depth]:
    return list_from_xcb(LIB.xcb.xcb_screen_allowed_depths_iterator, LIB.xcb.xcb_depth_next, r)


def setup_vendor(r: Setup) -> Array[c_char]:
    return array_from_xcb(LIB.xcb.xcb_setup_vendor, LIB.xcb.xcb_setup_vendor_length, r)


def setup_pixmap_formats(r: Setup) -> Array[Format]:
    return array_from_xcb(LIB.xcb.xcb_setup_pixmap_formats, LIB.xcb.xcb_setup_pixmap_formats_length, r)


def setup_roots(r: Setup) -> list[Screen]:
    return list_from_xcb(LIB.xcb.xcb_setup_roots_iterator, LIB.xcb.xcb_screen_next, r)


def get_image_data(r: GetImageReply) -> Array[c_uint8]:
    return array_from_xcb(LIB.xcb.xcb_get_image_data, LIB.xcb.xcb_get_image_data_length, r)


def get_property_value(r: GetPropertyReply) -> Array[c_char]:
    return array_from_xcb(LIB.xcb.xcb_get_property_value, LIB.xcb.xcb_get_property_value_length, r)


def randr_get_screen_resources_crtcs(r: RandrGetScreenResourcesReply) -> Array[RandrCrtc]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_crtcs, LIB.randr.xcb_randr_get_screen_resources_crtcs_length, r
    )


def randr_get_screen_resources_outputs(r: RandrGetScreenResourcesReply) -> Array[RandrOutput]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_outputs, LIB.randr.xcb_randr_get_screen_resources_outputs_length, r
    )


def randr_get_screen_resources_modes(r: RandrGetScreenResourcesReply) -> Array[RandrModeInfo]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_modes, LIB.randr.xcb_randr_get_screen_resources_modes_length, r
    )


def randr_get_screen_resources_names(r: RandrGetScreenResourcesReply) -> Array[c_uint8]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_names, LIB.randr.xcb_randr_get_screen_resources_names_length, r
    )


def randr_get_screen_resources_current_crtcs(r: RandrGetScreenResourcesCurrentReply) -> Array[RandrCrtc]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_current_crtcs,
        LIB.randr.xcb_randr_get_screen_resources_current_crtcs_length,
        r,
    )


def randr_get_screen_resources_current_outputs(r: RandrGetScreenResourcesCurrentReply) -> Array[RandrOutput]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_current_outputs,
        LIB.randr.xcb_randr_get_screen_resources_current_outputs_length,
        r,
    )


def randr_get_screen_resources_current_modes(r: RandrGetScreenResourcesCurrentReply) -> Array[RandrModeInfo]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_current_modes,
        LIB.randr.xcb_randr_get_screen_resources_current_modes_length,
        r,
    )


def randr_get_screen_resources_current_names(r: RandrGetScreenResourcesCurrentReply) -> Array[c_uint8]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_screen_resources_current_names,
        LIB.randr.xcb_randr_get_screen_resources_current_names_length,
        r,
    )


def randr_get_crtc_info_outputs(r: RandrGetCrtcInfoReply) -> Array[RandrOutput]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_crtc_info_outputs, LIB.randr.xcb_randr_get_crtc_info_outputs_length, r
    )


def randr_get_crtc_info_possible(r: RandrGetCrtcInfoReply) -> Array[RandrOutput]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_crtc_info_possible, LIB.randr.xcb_randr_get_crtc_info_possible_length, r
    )


def randr_get_output_info_crtcs(r: RandrGetOutputInfoReply) -> Array[RandrCrtc]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_output_info_crtcs, LIB.randr.xcb_randr_get_output_info_crtcs_length, r
    )


def randr_get_output_info_modes(r: RandrGetOutputInfoReply) -> Array[RandrMode]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_output_info_modes, LIB.randr.xcb_randr_get_output_info_modes_length, r
    )


def randr_get_output_info_clones(r: RandrGetOutputInfoReply) -> Array[RandrOutput]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_output_info_clones, LIB.randr.xcb_randr_get_output_info_clones_length, r
    )


def randr_get_output_info_name(r: RandrGetOutputInfoReply) -> Array[c_uint8]:
    return array_from_xcb(LIB.randr.xcb_randr_get_output_info_name, LIB.randr.xcb_randr_get_output_info_name_length, r)


def randr_get_output_property_data(r: RandrGetOutputPropertyReply) -> Array[c_uint8]:
    return array_from_xcb(
        LIB.randr.xcb_randr_get_output_property_data, LIB.randr.xcb_randr_get_output_property_data_length, r
    )


def randr_monitor_info_outputs(r: RandrMonitorInfo) -> Array[RandrOutput]:
    return array_from_xcb(LIB.randr.xcb_randr_monitor_info_outputs, LIB.randr.xcb_randr_monitor_info_outputs_length, r)


def randr_get_monitors_monitors(r: RandrGetMonitorsReply) -> list[RandrMonitorInfo]:
    return list_from_xcb(LIB.randr.xcb_randr_get_monitors_monitors_iterator, LIB.randr.xcb_randr_monitor_info_next, r)


def render_pictdepth_visuals(r: RenderPictdepth) -> Array[RenderPictvisual]:
    return array_from_xcb(LIB.render.xcb_render_pictdepth_visuals, LIB.render.xcb_render_pictdepth_visuals_length, r)


def render_pictscreen_depths(r: RenderPictscreen) -> list[RenderPictdepth]:
    return list_from_xcb(LIB.render.xcb_render_pictscreen_depths_iterator, LIB.render.xcb_render_pictdepth_next, r)


def render_query_pict_formats_formats(r: RenderQueryPictFormatsReply) -> Array[RenderPictforminfo]:
    return array_from_xcb(
        LIB.render.xcb_render_query_pict_formats_formats, LIB.render.xcb_render_query_pict_formats_formats_length, r
    )


def render_query_pict_formats_screens(r: RenderQueryPictFormatsReply) -> list[RenderPictscreen]:
    return list_from_xcb(
        LIB.render.xcb_render_query_pict_formats_screens_iterator, LIB.render.xcb_render_pictscreen_next, r
    )


def render_query_pict_formats_subpixels(r: RenderQueryPictFormatsReply) -> Array[c_uint32]:
    return array_from_xcb(
        LIB.render.xcb_render_query_pict_formats_subpixels, LIB.render.xcb_render_query_pict_formats_subpixels_length, r
    )


def xfixes_get_cursor_image_cursor_image(r: XfixesGetCursorImageReply) -> Array[c_uint32]:
    return array_from_xcb(
        LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image,
        LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image_length,
        r,
    )


def shm_create_segment_reply_fds(c: Connection | _Pointer[Connection], r: ShmCreateSegmentReply) -> _Pointer[c_int]:
    return LIB.shm.xcb_shm_create_segment_reply_fds(c, r)


def get_geometry(c: Connection, drawable: Drawable) -> GetGeometryReply:
    return LIB.xcb.xcb_get_geometry(c, drawable).reply(c)


def get_image(
    c: Connection,
    format_: c_uint8 | int,
    drawable: Drawable,
    x: c_int16 | int,
    y: c_int16 | int,
    width: c_uint16 | int,
    height: c_uint16 | int,
    plane_mask: c_uint32 | int,
) -> GetImageReply:
    return LIB.xcb.xcb_get_image(c, format_, drawable, x, y, width, height, plane_mask).reply(c)


def get_property(
    c: Connection,
    delete: c_uint8 | int,
    window: Window,
    property_: Atom,
    type_: Atom,
    long_offset: c_uint32 | int,
    long_length: c_uint32 | int,
) -> GetPropertyReply:
    return LIB.xcb.xcb_get_property(c, delete, window, property_, type_, long_offset, long_length).reply(c)


def no_operation(c: Connection) -> None:
    return LIB.xcb.xcb_no_operation_checked(c).check(c)


def randr_query_version(
    c: Connection, major_version: c_uint32 | int, minor_version: c_uint32 | int
) -> RandrQueryVersionReply:
    return LIB.randr.xcb_randr_query_version(c, major_version, minor_version).reply(c)


def randr_get_screen_resources(c: Connection, window: Window) -> RandrGetScreenResourcesReply:
    return LIB.randr.xcb_randr_get_screen_resources(c, window).reply(c)


def randr_get_screen_resources_current(c: Connection, window: Window) -> RandrGetScreenResourcesCurrentReply:
    return LIB.randr.xcb_randr_get_screen_resources_current(c, window).reply(c)


def randr_get_crtc_info(c: Connection, crtc: RandrCrtc, config_timestamp: Timestamp) -> RandrGetCrtcInfoReply:
    return LIB.randr.xcb_randr_get_crtc_info(c, crtc, config_timestamp).reply(c)


def randr_get_output_info(c: Connection, output: RandrOutput, config_timestamp: Timestamp) -> RandrGetOutputInfoReply:
    return LIB.randr.xcb_randr_get_output_info(c, output, config_timestamp).reply(c)


def randr_get_output_primary(c: Connection, window: Window) -> RandrGetOutputPrimaryReply:
    return LIB.randr.xcb_randr_get_output_primary(c, window).reply(c)


def randr_get_output_property(
    c: Connection,
    output: RandrOutput,
    property_: Atom,
    type_: Atom,
    long_offset: c_uint32 | int,
    long_length: c_uint32 | int,
    delete: c_uint8 | int,
    pending: c_uint8 | int,
) -> RandrGetOutputPropertyReply:
    return LIB.randr.xcb_randr_get_output_property(
        c, output, property_, type_, long_offset, long_length, delete, pending
    ).reply(c)


def randr_get_monitors(c: Connection, window: Window, get_active: c_uint8 | int) -> RandrGetMonitorsReply:
    return LIB.randr.xcb_randr_get_monitors(c, window, get_active).reply(c)


def render_query_version(
    c: Connection, client_major_version: c_uint32 | int, client_minor_version: c_uint32 | int
) -> RenderQueryVersionReply:
    return LIB.render.xcb_render_query_version(c, client_major_version, client_minor_version).reply(c)


def render_query_pict_formats(c: Connection) -> RenderQueryPictFormatsReply:
    return LIB.render.xcb_render_query_pict_formats(c).reply(c)


def shm_query_version(c: Connection) -> ShmQueryVersionReply:
    return LIB.shm.xcb_shm_query_version(c).reply(c)


def shm_get_image(
    c: Connection,
    drawable: Drawable,
    x: c_int16 | int,
    y: c_int16 | int,
    width: c_uint16 | int,
    height: c_uint16 | int,
    plane_mask: c_uint32 | int,
    format_: c_uint8 | int,
    shmseg: ShmSeg,
    offset: c_uint32 | int,
) -> ShmGetImageReply:
    return LIB.shm.xcb_shm_get_image(c, drawable, x, y, width, height, plane_mask, format_, shmseg, offset).reply(c)


def shm_attach_fd(c: Connection, shmseg: ShmSeg, shm_fd: c_int | int, read_only: c_uint8 | int) -> None:
    return LIB.shm.xcb_shm_attach_fd_checked(c, shmseg, shm_fd, read_only).check(c)


def shm_create_segment(
    c: Connection, shmseg: ShmSeg, size: c_uint32 | int, read_only: c_uint8 | int
) -> ShmCreateSegmentReply:
    return LIB.shm.xcb_shm_create_segment(c, shmseg, size, read_only).reply(c)


def shm_detach(c: Connection, shmseg: ShmSeg) -> None:
    return LIB.shm.xcb_shm_detach_checked(c, shmseg).check(c)


def xfixes_query_version(
    c: Connection, client_major_version: c_uint32 | int, client_minor_version: c_uint32 | int
) -> XfixesQueryVersionReply:
    return LIB.xfixes.xcb_xfixes_query_version(c, client_major_version, client_minor_version).reply(c)


def xfixes_get_cursor_image(c: Connection) -> XfixesGetCursorImageReply:
    return LIB.xfixes.xcb_xfixes_get_cursor_image(c).reply(c)


def initialize() -> None:  # noqa: PLR0915
    LIB.xcb.xcb_depth_next.argtypes = (POINTER(DepthIterator),)
    LIB.xcb.xcb_depth_next.restype = None
    LIB.xcb.xcb_screen_next.argtypes = (POINTER(ScreenIterator),)
    LIB.xcb.xcb_screen_next.restype = None
    LIB.xcb.xcb_setup_next.argtypes = (POINTER(SetupIterator),)
    LIB.xcb.xcb_setup_next.restype = None
    LIB.randr.xcb_randr_monitor_info_next.argtypes = (POINTER(RandrMonitorInfoIterator),)
    LIB.randr.xcb_randr_monitor_info_next.restype = None
    LIB.render.xcb_render_pictdepth_next.argtypes = (POINTER(RenderPictdepthIterator),)
    LIB.render.xcb_render_pictdepth_next.restype = None
    LIB.render.xcb_render_pictscreen_next.argtypes = (POINTER(RenderPictscreenIterator),)
    LIB.render.xcb_render_pictscreen_next.restype = None
    LIB.xcb.xcb_depth_visuals.argtypes = (POINTER(Depth),)
    LIB.xcb.xcb_depth_visuals.restype = POINTER(Visualtype)
    LIB.xcb.xcb_depth_visuals_length.argtypes = (POINTER(Depth),)
    LIB.xcb.xcb_depth_visuals_length.restype = c_int
    LIB.xcb.xcb_screen_allowed_depths_iterator.argtypes = (POINTER(Screen),)
    LIB.xcb.xcb_screen_allowed_depths_iterator.restype = DepthIterator
    LIB.xcb.xcb_setup_vendor.argtypes = (POINTER(Setup),)
    LIB.xcb.xcb_setup_vendor.restype = POINTER(c_char)
    LIB.xcb.xcb_setup_vendor_length.argtypes = (POINTER(Setup),)
    LIB.xcb.xcb_setup_vendor_length.restype = c_int
    LIB.xcb.xcb_setup_pixmap_formats.argtypes = (POINTER(Setup),)
    LIB.xcb.xcb_setup_pixmap_formats.restype = POINTER(Format)
    LIB.xcb.xcb_setup_pixmap_formats_length.argtypes = (POINTER(Setup),)
    LIB.xcb.xcb_setup_pixmap_formats_length.restype = c_int
    LIB.xcb.xcb_setup_roots_iterator.argtypes = (POINTER(Setup),)
    LIB.xcb.xcb_setup_roots_iterator.restype = ScreenIterator
    LIB.xcb.xcb_get_image_data.argtypes = (POINTER(GetImageReply),)
    LIB.xcb.xcb_get_image_data.restype = POINTER(c_uint8)
    LIB.xcb.xcb_get_image_data_length.argtypes = (POINTER(GetImageReply),)
    LIB.xcb.xcb_get_image_data_length.restype = c_int
    LIB.xcb.xcb_get_property_value.argtypes = (POINTER(GetPropertyReply),)
    LIB.xcb.xcb_get_property_value.restype = POINTER(c_char)
    LIB.xcb.xcb_get_property_value_length.argtypes = (POINTER(GetPropertyReply),)
    LIB.xcb.xcb_get_property_value_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_crtcs.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_crtcs.restype = POINTER(RandrCrtc)
    LIB.randr.xcb_randr_get_screen_resources_crtcs_length.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_crtcs_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_outputs.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_outputs.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_get_screen_resources_outputs_length.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_outputs_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_modes.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_modes.restype = POINTER(RandrModeInfo)
    LIB.randr.xcb_randr_get_screen_resources_modes_length.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_modes_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_names.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_names.restype = POINTER(c_uint8)
    LIB.randr.xcb_randr_get_screen_resources_names_length.argtypes = (POINTER(RandrGetScreenResourcesReply),)
    LIB.randr.xcb_randr_get_screen_resources_names_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_current_crtcs.argtypes = (POINTER(RandrGetScreenResourcesCurrentReply),)
    LIB.randr.xcb_randr_get_screen_resources_current_crtcs.restype = POINTER(RandrCrtc)
    LIB.randr.xcb_randr_get_screen_resources_current_crtcs_length.argtypes = (
        POINTER(RandrGetScreenResourcesCurrentReply),
    )
    LIB.randr.xcb_randr_get_screen_resources_current_crtcs_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_current_outputs.argtypes = (POINTER(RandrGetScreenResourcesCurrentReply),)
    LIB.randr.xcb_randr_get_screen_resources_current_outputs.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_get_screen_resources_current_outputs_length.argtypes = (
        POINTER(RandrGetScreenResourcesCurrentReply),
    )
    LIB.randr.xcb_randr_get_screen_resources_current_outputs_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_current_modes.argtypes = (POINTER(RandrGetScreenResourcesCurrentReply),)
    LIB.randr.xcb_randr_get_screen_resources_current_modes.restype = POINTER(RandrModeInfo)
    LIB.randr.xcb_randr_get_screen_resources_current_modes_length.argtypes = (
        POINTER(RandrGetScreenResourcesCurrentReply),
    )
    LIB.randr.xcb_randr_get_screen_resources_current_modes_length.restype = c_int
    LIB.randr.xcb_randr_get_screen_resources_current_names.argtypes = (POINTER(RandrGetScreenResourcesCurrentReply),)
    LIB.randr.xcb_randr_get_screen_resources_current_names.restype = POINTER(c_uint8)
    LIB.randr.xcb_randr_get_screen_resources_current_names_length.argtypes = (
        POINTER(RandrGetScreenResourcesCurrentReply),
    )
    LIB.randr.xcb_randr_get_screen_resources_current_names_length.restype = c_int
    LIB.randr.xcb_randr_get_crtc_info_outputs.argtypes = (POINTER(RandrGetCrtcInfoReply),)
    LIB.randr.xcb_randr_get_crtc_info_outputs.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_get_crtc_info_outputs_length.argtypes = (POINTER(RandrGetCrtcInfoReply),)
    LIB.randr.xcb_randr_get_crtc_info_outputs_length.restype = c_int
    LIB.randr.xcb_randr_get_crtc_info_possible.argtypes = (POINTER(RandrGetCrtcInfoReply),)
    LIB.randr.xcb_randr_get_crtc_info_possible.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_get_crtc_info_possible_length.argtypes = (POINTER(RandrGetCrtcInfoReply),)
    LIB.randr.xcb_randr_get_crtc_info_possible_length.restype = c_int
    LIB.randr.xcb_randr_get_output_info_crtcs.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_crtcs.restype = POINTER(RandrCrtc)
    LIB.randr.xcb_randr_get_output_info_crtcs_length.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_crtcs_length.restype = c_int
    LIB.randr.xcb_randr_get_output_info_modes.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_modes.restype = POINTER(RandrMode)
    LIB.randr.xcb_randr_get_output_info_modes_length.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_modes_length.restype = c_int
    LIB.randr.xcb_randr_get_output_info_clones.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_clones.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_get_output_info_clones_length.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_clones_length.restype = c_int
    LIB.randr.xcb_randr_get_output_info_name.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_name.restype = POINTER(c_uint8)
    LIB.randr.xcb_randr_get_output_info_name_length.argtypes = (POINTER(RandrGetOutputInfoReply),)
    LIB.randr.xcb_randr_get_output_info_name_length.restype = c_int
    LIB.randr.xcb_randr_get_output_property_data.argtypes = (POINTER(RandrGetOutputPropertyReply),)
    LIB.randr.xcb_randr_get_output_property_data.restype = POINTER(c_uint8)
    LIB.randr.xcb_randr_get_output_property_data_length.argtypes = (POINTER(RandrGetOutputPropertyReply),)
    LIB.randr.xcb_randr_get_output_property_data_length.restype = c_int
    LIB.randr.xcb_randr_monitor_info_outputs.argtypes = (POINTER(RandrMonitorInfo),)
    LIB.randr.xcb_randr_monitor_info_outputs.restype = POINTER(RandrOutput)
    LIB.randr.xcb_randr_monitor_info_outputs_length.argtypes = (POINTER(RandrMonitorInfo),)
    LIB.randr.xcb_randr_monitor_info_outputs_length.restype = c_int
    LIB.randr.xcb_randr_get_monitors_monitors_iterator.argtypes = (POINTER(RandrGetMonitorsReply),)
    LIB.randr.xcb_randr_get_monitors_monitors_iterator.restype = RandrMonitorInfoIterator
    LIB.render.xcb_render_pictdepth_visuals.argtypes = (POINTER(RenderPictdepth),)
    LIB.render.xcb_render_pictdepth_visuals.restype = POINTER(RenderPictvisual)
    LIB.render.xcb_render_pictdepth_visuals_length.argtypes = (POINTER(RenderPictdepth),)
    LIB.render.xcb_render_pictdepth_visuals_length.restype = c_int
    LIB.render.xcb_render_pictscreen_depths_iterator.argtypes = (POINTER(RenderPictscreen),)
    LIB.render.xcb_render_pictscreen_depths_iterator.restype = RenderPictdepthIterator
    LIB.render.xcb_render_query_pict_formats_formats.argtypes = (POINTER(RenderQueryPictFormatsReply),)
    LIB.render.xcb_render_query_pict_formats_formats.restype = POINTER(RenderPictforminfo)
    LIB.render.xcb_render_query_pict_formats_formats_length.argtypes = (POINTER(RenderQueryPictFormatsReply),)
    LIB.render.xcb_render_query_pict_formats_formats_length.restype = c_int
    LIB.render.xcb_render_query_pict_formats_screens_iterator.argtypes = (POINTER(RenderQueryPictFormatsReply),)
    LIB.render.xcb_render_query_pict_formats_screens_iterator.restype = RenderPictscreenIterator
    LIB.render.xcb_render_query_pict_formats_subpixels.argtypes = (POINTER(RenderQueryPictFormatsReply),)
    LIB.render.xcb_render_query_pict_formats_subpixels.restype = POINTER(c_uint32)
    LIB.render.xcb_render_query_pict_formats_subpixels_length.argtypes = (POINTER(RenderQueryPictFormatsReply),)
    LIB.render.xcb_render_query_pict_formats_subpixels_length.restype = c_int
    LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image.argtypes = (POINTER(XfixesGetCursorImageReply),)
    LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image.restype = POINTER(c_uint32)
    LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image_length.argtypes = (POINTER(XfixesGetCursorImageReply),)
    LIB.xfixes.xcb_xfixes_get_cursor_image_cursor_image_length.restype = c_int
    LIB.shm.xcb_shm_create_segment_reply_fds.argtypes = (POINTER(Connection), POINTER(ShmCreateSegmentReply))
    LIB.shm.xcb_shm_create_segment_reply_fds.restype = POINTER(c_int)
    initialize_xcb_typed_func(LIB.xcb, "xcb_get_geometry", [POINTER(Connection), Drawable], GetGeometryReply)
    initialize_xcb_typed_func(
        LIB.xcb,
        "xcb_get_image",
        [POINTER(Connection), c_uint8, Drawable, c_int16, c_int16, c_uint16, c_uint16, c_uint32],
        GetImageReply,
    )
    initialize_xcb_typed_func(
        LIB.xcb,
        "xcb_get_property",
        [POINTER(Connection), c_uint8, Window, Atom, Atom, c_uint32, c_uint32],
        GetPropertyReply,
    )
    LIB.xcb.xcb_no_operation_checked.argtypes = (POINTER(Connection),)
    LIB.xcb.xcb_no_operation_checked.restype = VoidCookie
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_query_version", [POINTER(Connection), c_uint32, c_uint32], RandrQueryVersionReply
    )
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_get_screen_resources", [POINTER(Connection), Window], RandrGetScreenResourcesReply
    )
    initialize_xcb_typed_func(
        LIB.randr,
        "xcb_randr_get_screen_resources_current",
        [POINTER(Connection), Window],
        RandrGetScreenResourcesCurrentReply,
    )
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_get_crtc_info", [POINTER(Connection), RandrCrtc, Timestamp], RandrGetCrtcInfoReply
    )
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_get_output_info", [POINTER(Connection), RandrOutput, Timestamp], RandrGetOutputInfoReply
    )
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_get_output_primary", [POINTER(Connection), Window], RandrGetOutputPrimaryReply
    )
    initialize_xcb_typed_func(
        LIB.randr,
        "xcb_randr_get_output_property",
        [POINTER(Connection), RandrOutput, Atom, Atom, c_uint32, c_uint32, c_uint8, c_uint8],
        RandrGetOutputPropertyReply,
    )
    initialize_xcb_typed_func(
        LIB.randr, "xcb_randr_get_monitors", [POINTER(Connection), Window, c_uint8], RandrGetMonitorsReply
    )
    initialize_xcb_typed_func(
        LIB.render, "xcb_render_query_version", [POINTER(Connection), c_uint32, c_uint32], RenderQueryVersionReply
    )
    initialize_xcb_typed_func(
        LIB.render, "xcb_render_query_pict_formats", [POINTER(Connection)], RenderQueryPictFormatsReply
    )
    initialize_xcb_typed_func(LIB.shm, "xcb_shm_query_version", [POINTER(Connection)], ShmQueryVersionReply)
    initialize_xcb_typed_func(
        LIB.shm,
        "xcb_shm_get_image",
        [POINTER(Connection), Drawable, c_int16, c_int16, c_uint16, c_uint16, c_uint32, c_uint8, ShmSeg, c_uint32],
        ShmGetImageReply,
    )
    LIB.shm.xcb_shm_attach_fd_checked.argtypes = (POINTER(Connection), ShmSeg, c_int, c_uint8)
    LIB.shm.xcb_shm_attach_fd_checked.restype = VoidCookie
    initialize_xcb_typed_func(
        LIB.shm, "xcb_shm_create_segment", [POINTER(Connection), ShmSeg, c_uint32, c_uint8], ShmCreateSegmentReply
    )
    LIB.shm.xcb_shm_detach_checked.argtypes = (POINTER(Connection), ShmSeg)
    LIB.shm.xcb_shm_detach_checked.restype = VoidCookie
    initialize_xcb_typed_func(
        LIB.xfixes, "xcb_xfixes_query_version", [POINTER(Connection), c_uint32, c_uint32], XfixesQueryVersionReply
    )
    initialize_xcb_typed_func(
        LIB.xfixes, "xcb_xfixes_get_cursor_image", [POINTER(Connection)], XfixesGetCursorImageReply
    )
