xcffib
Advanced tools
| [build-system] | ||
| requires = ["setuptools >= 64"] | ||
| build-backend = "setuptools.build_meta" |
| # Copyright 2014 Tycho Andersen | ||
| # Copyright 2014 Sean Vig | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import shutil | ||
| import tempfile | ||
| from warnings import warn | ||
| from cffi import FFI | ||
| from cffi.error import PkgConfigError, VerificationError | ||
| from setuptools.errors import CCompilerError, ExecError, PlatformError | ||
| CONSTANTS = [ | ||
| ("X_PROTOCOL", 11), | ||
| ("X_PROTOCOL_REVISION", 0), | ||
| ("X_TCP_PORT", 6000), | ||
| ("XCB_NONE", 0), | ||
| ("XCB_COPY_FROM_PARENT", 0), | ||
| ("XCB_CURRENT_TIME", 0), | ||
| ("XCB_NO_SYMBOL", 0), | ||
| ("XCB_CONN_ERROR", 1), | ||
| ("XCB_CONN_CLOSED_EXT_NOTSUPPORTED", 2), | ||
| ("XCB_CONN_CLOSED_MEM_INSUFFICIENT", 3), | ||
| ("XCB_CONN_CLOSED_REQ_LEN_EXCEED", 4), | ||
| ("XCB_CONN_CLOSED_PARSE_ERR", 5), | ||
| ("XCB_CONN_CLOSED_INVALID_SCREEN", 6), | ||
| ("XCB_CONN_CLOSED_FDPASSING_FAILED", 7), | ||
| ("XCB_REQUEST_CHECKED", 1 << 0) | ||
| ] | ||
| # constants | ||
| CDEF = '\n'.join("#define %s %d" % (c, v) for c, v in CONSTANTS) | ||
| # types | ||
| CDEF += """ | ||
| // xcb.h | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t pad0; /**< Padding */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t length; /**< Length of the response */ | ||
| } xcb_generic_reply_t; | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t pad0; /**< Padding */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t pad[7]; /**< Padding */ | ||
| uint32_t full_sequence; /**< full sequence */ | ||
| } xcb_generic_event_t; | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t error_code; /**< Error code */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t resource_id; /** < Resource ID for requests with side effects only */ | ||
| uint16_t minor_code; /** < Minor opcode of the failed request */ | ||
| uint8_t major_code; /** < Major opcode of the failed request */ | ||
| uint8_t pad0; | ||
| uint32_t pad[5]; /**< Padding */ | ||
| uint32_t full_sequence; /**< full sequence */ | ||
| } xcb_generic_error_t; | ||
| typedef struct { | ||
| unsigned int sequence; /**< Sequence number */ | ||
| } xcb_void_cookie_t; | ||
| typedef struct xcb_auth_info_t { | ||
| int namelen; | ||
| char *name; | ||
| int datalen; | ||
| char *data; | ||
| } xcb_auth_info_t; | ||
| typedef ... xcb_connection_t; | ||
| // xproto.h | ||
| typedef uint32_t xcb_colormap_t; | ||
| typedef uint32_t xcb_drawable_t; | ||
| typedef uint32_t xcb_pixmap_t; | ||
| typedef uint32_t xcb_visualid_t; | ||
| typedef uint32_t xcb_window_t; | ||
| typedef struct xcb_query_extension_reply_t { | ||
| uint8_t response_type; | ||
| uint8_t pad0; | ||
| uint16_t sequence; | ||
| uint32_t length; | ||
| uint8_t present; | ||
| uint8_t major_opcode; | ||
| uint8_t first_event; | ||
| uint8_t first_error; | ||
| } xcb_query_extension_reply_t; | ||
| typedef struct xcb_setup_t { | ||
| uint8_t status; /**< */ | ||
| uint8_t pad0; /**< */ | ||
| uint16_t protocol_major_version; /**< */ | ||
| uint16_t protocol_minor_version; /**< */ | ||
| uint16_t length; /**< */ | ||
| uint32_t release_number; /**< */ | ||
| uint32_t resource_id_base; /**< */ | ||
| uint32_t resource_id_mask; /**< */ | ||
| uint32_t motion_buffer_size; /**< */ | ||
| uint16_t vendor_len; /**< */ | ||
| uint16_t maximum_request_length; /**< */ | ||
| uint8_t roots_len; /**< */ | ||
| uint8_t pixmap_formats_len; /**< */ | ||
| uint8_t image_byte_order; /**< */ | ||
| uint8_t bitmap_format_bit_order; /**< */ | ||
| uint8_t bitmap_format_scanline_unit; /**< */ | ||
| uint8_t bitmap_format_scanline_pad; /**< */ | ||
| uint8_t min_keycode; /**< */ | ||
| uint8_t max_keycode; /**< */ | ||
| uint8_t pad1[4]; /**< */ | ||
| } xcb_setup_t; | ||
| typedef struct xcb_visualtype_t { | ||
| xcb_visualid_t visual_id; /**< */ | ||
| uint8_t _class; /**< */ | ||
| uint8_t bits_per_rgb_value; /**< */ | ||
| uint16_t colormap_entries; /**< */ | ||
| uint32_t red_mask; /**< */ | ||
| uint32_t green_mask; /**< */ | ||
| uint32_t blue_mask; /**< */ | ||
| uint8_t pad0[4]; /**< */ | ||
| } xcb_visualtype_t; | ||
| typedef struct xcb_screen_t { | ||
| xcb_window_t root; /**< */ | ||
| xcb_colormap_t default_colormap; /**< */ | ||
| uint32_t white_pixel; /**< */ | ||
| uint32_t black_pixel; /**< */ | ||
| uint32_t current_input_masks; /**< */ | ||
| uint16_t width_in_pixels; /**< */ | ||
| uint16_t height_in_pixels; /**< */ | ||
| uint16_t width_in_millimeters; /**< */ | ||
| uint16_t height_in_millimeters; /**< */ | ||
| uint16_t min_installed_maps; /**< */ | ||
| uint16_t max_installed_maps; /**< */ | ||
| xcb_visualid_t root_visual; /**< */ | ||
| uint8_t backing_stores; /**< */ | ||
| uint8_t save_unders; /**< */ | ||
| uint8_t root_depth; /**< */ | ||
| uint8_t allowed_depths_len; /**< */ | ||
| } xcb_screen_t; | ||
| typedef struct xcb_screen_iterator_t { | ||
| xcb_screen_t *data; /**< */ | ||
| int rem; /**< */ | ||
| int index; /**< */ | ||
| } xcb_screen_iterator_t; | ||
| xcb_screen_iterator_t | ||
| xcb_setup_roots_iterator (const xcb_setup_t *R /**< */); | ||
| void | ||
| xcb_screen_next (xcb_screen_iterator_t *i /**< */); | ||
| // render.h | ||
| typedef uint32_t xcb_render_pictformat_t; | ||
| typedef struct xcb_render_directformat_t { | ||
| uint16_t red_shift; /**< */ | ||
| uint16_t red_mask; /**< */ | ||
| uint16_t green_shift; /**< */ | ||
| uint16_t green_mask; /**< */ | ||
| uint16_t blue_shift; /**< */ | ||
| uint16_t blue_mask; /**< */ | ||
| uint16_t alpha_shift; /**< */ | ||
| uint16_t alpha_mask; /**< */ | ||
| } xcb_render_directformat_t; | ||
| typedef struct xcb_render_pictforminfo_t { | ||
| xcb_render_pictformat_t id; /**< */ | ||
| uint8_t type; /**< */ | ||
| uint8_t depth; /**< */ | ||
| uint8_t pad0[2]; /**< */ | ||
| xcb_render_directformat_t direct; /**< */ | ||
| xcb_colormap_t colormap; /**< */ | ||
| } xcb_render_pictforminfo_t; | ||
| // xcbext.h | ||
| typedef struct xcb_extension_t { | ||
| const char *name; | ||
| int global_id; | ||
| } xcb_extension_t; | ||
| typedef struct { | ||
| size_t count; | ||
| xcb_extension_t *ext; | ||
| uint8_t opcode; | ||
| uint8_t isvoid; | ||
| } xcb_protocol_request_t; | ||
| // sys/uio.h | ||
| struct iovec | ||
| { | ||
| void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ | ||
| size_t iov_len; /* Must be size_t (1003.1g) */ | ||
| }; | ||
| // need to manually free some things that XCB allocates | ||
| void free(void *ptr); | ||
| """ | ||
| # connection manipulation, mostly generated with: | ||
| # grep -v '^[ \/\}#]' xcb.h | grep -v '^typedef' | grep -v '^extern' | ||
| CDEF += """ | ||
| int xcb_flush(xcb_connection_t *c); | ||
| uint32_t xcb_get_maximum_request_length(xcb_connection_t *c); | ||
| void xcb_prefetch_maximum_request_length(xcb_connection_t *c); | ||
| xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c); | ||
| xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c); | ||
| const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext); | ||
| const xcb_setup_t *xcb_get_setup(xcb_connection_t *c); | ||
| int xcb_get_file_descriptor(xcb_connection_t *c); | ||
| int xcb_connection_has_error(xcb_connection_t *c); | ||
| xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info); | ||
| void xcb_disconnect(xcb_connection_t *c); | ||
| int xcb_parse_display(const char *name, char **host, int *display, int *screen); | ||
| xcb_connection_t *xcb_connect(const char *displayname, int *screenp); | ||
| xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen); | ||
| uint32_t xcb_generate_id(xcb_connection_t *c); | ||
| xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie); | ||
| """ | ||
| CDEF += r""" | ||
| unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request); | ||
| void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e); | ||
| int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error); | ||
| void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence); | ||
| """ | ||
| def ffi_for_mode(mode): | ||
| ffi = FFI() | ||
| ffi.cdef(CDEF) | ||
| if mode == "api": | ||
| ffi.set_source_pkgconfig( | ||
| 'xcffib._xcffib', | ||
| ['xcb'], | ||
| r""" | ||
| #include "xcb/xcb.h" | ||
| #include "xcb/xproto.h" | ||
| #include "xcb/xcbext.h" | ||
| #include "xcb/render.h" | ||
| """) | ||
| else: | ||
| ffi.set_source( | ||
| 'xcffib._xcffib', | ||
| None) | ||
| return ffi | ||
| def build_ffi(): | ||
| """ | ||
| This will be called from setup() to return an FFI | ||
| which it will compile - work out here which type is | ||
| possible and return it. | ||
| """ | ||
| try: | ||
| ffi_api = ffi_for_mode("api") | ||
| file = ffi_api.compile(verbose=True, tmpdir=tempfile.gettempdir()) | ||
| shutil.copy(file, "xcffib") | ||
| return ffi_api | ||
| except (CCompilerError, ExecError, PlatformError, | ||
| PkgConfigError, VerificationError) as e: | ||
| warn("Falling back to precompiled python mode: {}".format(str(e))) | ||
| ffi_abi = ffi_for_mode("abi") | ||
| file = ffi_abi.compile(verbose=True, tmpdir=tempfile.gettempdir()) | ||
| shutil.copy(file, "xcffib") | ||
| return ffi_abi | ||
| if __name__ == "__main__": | ||
| build_ffi() |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: xcffib | ||
| Version: 1.6.2 | ||
| Version: 1.7.0 | ||
| Summary: xcffib is the XCB binding for python | ||
@@ -5,0 +5,0 @@ Home-page: http://github.com/tych0/xcffib |
+2
-1
@@ -46,3 +46,3 @@ #!/usr/bin/env python | ||
| version = "1.6.2" | ||
| version = "1.7.0" | ||
| dependencies = ["cffi>=1.1.0; python_implementation != 'PyPy'"] | ||
@@ -77,2 +77,3 @@ | ||
| ], | ||
| cffi_modules=["xcffib/ffi_build.py:build_ffi"] | ||
| ) |
| Metadata-Version: 2.1 | ||
| Name: xcffib | ||
| Version: 1.6.2 | ||
| Version: 1.7.0 | ||
| Summary: xcffib is the XCB binding for python | ||
@@ -5,0 +5,0 @@ Home-page: http://github.com/tych0/xcffib |
| LICENSE | ||
| MANIFEST.in | ||
| README.md | ||
| pyproject.toml | ||
| setup.py | ||
@@ -22,2 +23,3 @@ test/__init__.py | ||
| xcffib/ffi.py | ||
| xcffib/ffi_build.py | ||
| xcffib/ge.py | ||
@@ -24,0 +26,0 @@ xcffib/glx.py |
+2
-14
@@ -18,23 +18,11 @@ # Copyright 2014 Tycho Andersen | ||
| import ctypes.util | ||
| import functools | ||
| import io | ||
| import platform | ||
| import struct | ||
| import weakref | ||
| from .ffi import ffi | ||
| from .ffi import ffi, lib, cffi_mode # noqa: F401 | ||
| if platform.system() == "Darwin": | ||
| soname = "libxcb.dylib" | ||
| elif platform.system() == "Windows": | ||
| soname = "libxcb.dll" | ||
| else: | ||
| soname = ctypes.util.find_library("xcb") | ||
| if soname is None: | ||
| soname = "libxcb.so" | ||
| lib = ffi.dlopen(soname) | ||
| __xcb_proto_version__ = "1.17.0" | ||
| __version__ = "1.6.2" | ||
| __version__ = "1.7.0" | ||
@@ -41,0 +29,0 @@ X_PROTOCOL = lib.X_PROTOCOL |
+32
-244
@@ -1,246 +0,34 @@ | ||
| # Copyright 2014 Tycho Andersen | ||
| # Copyright 2014 Sean Vig | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import ctypes.util | ||
| import platform | ||
| from cffi import FFI | ||
| # Attempt api mode, then precompiled abi mode, then import time abi | ||
| cffi_mode = "(unknown)" | ||
| try: | ||
| # Note in ABI mode lib is already available, no dlopen() needed | ||
| from ._xcffib import ffi, lib | ||
| cffi_mode = "api" | ||
| except ImportError: | ||
| try: | ||
| # Note in ABI mode lib will be missing | ||
| from ._xcffib import ffi | ||
| cffi_mode = "abi" | ||
| except ImportError: | ||
| # This means that someone is trying to import the module *without* | ||
| # having run ffi_build.py. We could "just" build it for them via: | ||
| # ffi = ffi_for_mode("abi") | ||
| # but this is not an expected configuration, and it's hard to test, so | ||
| # let's not support it for now. | ||
| raise | ||
| CONSTANTS = [ | ||
| ("X_PROTOCOL", 11), | ||
| ("X_PROTOCOL_REVISION", 0), | ||
| ("X_TCP_PORT", 6000), | ||
| ("XCB_NONE", 0), | ||
| ("XCB_COPY_FROM_PARENT", 0), | ||
| ("XCB_CURRENT_TIME", 0), | ||
| ("XCB_NO_SYMBOL", 0), | ||
| ("XCB_CONN_ERROR", 1), | ||
| ("XCB_CONN_CLOSED_EXT_NOTSUPPORTED", 2), | ||
| ("XCB_CONN_CLOSED_MEM_INSUFFICIENT", 3), | ||
| ("XCB_CONN_CLOSED_REQ_LEN_EXCEED", 4), | ||
| ("XCB_CONN_CLOSED_PARSE_ERR", 5), | ||
| ("XCB_CONN_CLOSED_INVALID_SCREEN", 6), | ||
| ("XCB_CONN_CLOSED_FDPASSING_FAILED", 7), | ||
| ("XCB_REQUEST_CHECKED", 1 << 0) | ||
| ] | ||
| # constants | ||
| CDEF = '\n'.join("#define %s %d" % (c, v) for c, v in CONSTANTS) | ||
| # types | ||
| CDEF += """ | ||
| // xcb.h | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t pad0; /**< Padding */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t length; /**< Length of the response */ | ||
| } xcb_generic_reply_t; | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t pad0; /**< Padding */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t pad[7]; /**< Padding */ | ||
| uint32_t full_sequence; /**< full sequence */ | ||
| } xcb_generic_event_t; | ||
| typedef struct { | ||
| uint8_t response_type; /**< Type of the response */ | ||
| uint8_t error_code; /**< Error code */ | ||
| uint16_t sequence; /**< Sequence number */ | ||
| uint32_t resource_id; /** < Resource ID for requests with side effects only */ | ||
| uint16_t minor_code; /** < Minor opcode of the failed request */ | ||
| uint8_t major_code; /** < Major opcode of the failed request */ | ||
| uint8_t pad0; | ||
| uint32_t pad[5]; /**< Padding */ | ||
| uint32_t full_sequence; /**< full sequence */ | ||
| } xcb_generic_error_t; | ||
| typedef struct { | ||
| unsigned int sequence; /**< Sequence number */ | ||
| } xcb_void_cookie_t; | ||
| typedef struct xcb_auth_info_t { | ||
| int namelen; | ||
| char *name; | ||
| int datalen; | ||
| char *data; | ||
| } xcb_auth_info_t; | ||
| typedef ... xcb_connection_t; | ||
| // xproto.h | ||
| typedef uint32_t xcb_colormap_t; | ||
| typedef uint32_t xcb_drawable_t; | ||
| typedef uint32_t xcb_pixmap_t; | ||
| typedef uint32_t xcb_visualid_t; | ||
| typedef uint32_t xcb_window_t; | ||
| typedef struct xcb_query_extension_reply_t { | ||
| uint8_t response_type; | ||
| uint8_t pad0; | ||
| uint16_t sequence; | ||
| uint32_t length; | ||
| uint8_t present; | ||
| uint8_t major_opcode; | ||
| uint8_t first_event; | ||
| uint8_t first_error; | ||
| } xcb_query_extension_reply_t; | ||
| typedef struct xcb_setup_t { | ||
| uint8_t status; /**< */ | ||
| uint8_t pad0; /**< */ | ||
| uint16_t protocol_major_version; /**< */ | ||
| uint16_t protocol_minor_version; /**< */ | ||
| uint16_t length; /**< */ | ||
| uint32_t release_number; /**< */ | ||
| uint32_t resource_id_base; /**< */ | ||
| uint32_t resource_id_mask; /**< */ | ||
| uint32_t motion_buffer_size; /**< */ | ||
| uint16_t vendor_len; /**< */ | ||
| uint16_t maximum_request_length; /**< */ | ||
| uint8_t roots_len; /**< */ | ||
| uint8_t pixmap_formats_len; /**< */ | ||
| uint8_t image_byte_order; /**< */ | ||
| uint8_t bitmap_format_bit_order; /**< */ | ||
| uint8_t bitmap_format_scanline_unit; /**< */ | ||
| uint8_t bitmap_format_scanline_pad; /**< */ | ||
| uint8_t min_keycode; /**< */ | ||
| uint8_t max_keycode; /**< */ | ||
| uint8_t pad1[4]; /**< */ | ||
| } xcb_setup_t; | ||
| typedef struct xcb_visualtype_t { | ||
| xcb_visualid_t visual_id; /**< */ | ||
| uint8_t _class; /**< */ | ||
| uint8_t bits_per_rgb_value; /**< */ | ||
| uint16_t colormap_entries; /**< */ | ||
| uint32_t red_mask; /**< */ | ||
| uint32_t green_mask; /**< */ | ||
| uint32_t blue_mask; /**< */ | ||
| uint8_t pad0[4]; /**< */ | ||
| } xcb_visualtype_t; | ||
| typedef struct xcb_screen_t { | ||
| xcb_window_t root; /**< */ | ||
| xcb_colormap_t default_colormap; /**< */ | ||
| uint32_t white_pixel; /**< */ | ||
| uint32_t black_pixel; /**< */ | ||
| uint32_t current_input_masks; /**< */ | ||
| uint16_t width_in_pixels; /**< */ | ||
| uint16_t height_in_pixels; /**< */ | ||
| uint16_t width_in_millimeters; /**< */ | ||
| uint16_t height_in_millimeters; /**< */ | ||
| uint16_t min_installed_maps; /**< */ | ||
| uint16_t max_installed_maps; /**< */ | ||
| xcb_visualid_t root_visual; /**< */ | ||
| uint8_t backing_stores; /**< */ | ||
| uint8_t save_unders; /**< */ | ||
| uint8_t root_depth; /**< */ | ||
| uint8_t allowed_depths_len; /**< */ | ||
| } xcb_screen_t; | ||
| typedef struct xcb_screen_iterator_t { | ||
| xcb_screen_t *data; /**< */ | ||
| int rem; /**< */ | ||
| int index; /**< */ | ||
| } xcb_screen_iterator_t; | ||
| xcb_screen_iterator_t | ||
| xcb_setup_roots_iterator (const xcb_setup_t *R /**< */); | ||
| void | ||
| xcb_screen_next (xcb_screen_iterator_t *i /**< */); | ||
| // render.h | ||
| typedef uint32_t xcb_render_pictformat_t; | ||
| typedef struct xcb_render_directformat_t { | ||
| uint16_t red_shift; /**< */ | ||
| uint16_t red_mask; /**< */ | ||
| uint16_t green_shift; /**< */ | ||
| uint16_t green_mask; /**< */ | ||
| uint16_t blue_shift; /**< */ | ||
| uint16_t blue_mask; /**< */ | ||
| uint16_t alpha_shift; /**< */ | ||
| uint16_t alpha_mask; /**< */ | ||
| } xcb_render_directformat_t; | ||
| typedef struct xcb_render_pictforminfo_t { | ||
| xcb_render_pictformat_t id; /**< */ | ||
| uint8_t type; /**< */ | ||
| uint8_t depth; /**< */ | ||
| uint8_t pad0[2]; /**< */ | ||
| xcb_render_directformat_t direct; /**< */ | ||
| xcb_colormap_t colormap; /**< */ | ||
| } xcb_render_pictforminfo_t; | ||
| // xcbext.h | ||
| typedef struct xcb_extension_t { | ||
| const char *name; | ||
| int global_id; | ||
| } xcb_extension_t; | ||
| typedef struct { | ||
| size_t count; | ||
| xcb_extension_t *ext; | ||
| uint8_t opcode; | ||
| uint8_t isvoid; | ||
| } xcb_protocol_request_t; | ||
| // sys/uio.h | ||
| struct iovec | ||
| { | ||
| void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ | ||
| size_t iov_len; /* Must be size_t (1003.1g) */ | ||
| }; | ||
| // need to manually free some things that XCB allocates | ||
| void free(void *ptr); | ||
| """ | ||
| # connection manipulation, mostly generated with: | ||
| # grep -v '^[ \/\}#]' xcb.h | grep -v '^typedef' | grep -v '^extern' | ||
| CDEF += """ | ||
| int xcb_flush(xcb_connection_t *c); | ||
| uint32_t xcb_get_maximum_request_length(xcb_connection_t *c); | ||
| void xcb_prefetch_maximum_request_length(xcb_connection_t *c); | ||
| xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c); | ||
| xcb_generic_event_t *xcb_poll_for_event(xcb_connection_t *c); | ||
| const xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext); | ||
| const xcb_setup_t *xcb_get_setup(xcb_connection_t *c); | ||
| int xcb_get_file_descriptor(xcb_connection_t *c); | ||
| int xcb_connection_has_error(xcb_connection_t *c); | ||
| xcb_connection_t *xcb_connect_to_fd(int fd, xcb_auth_info_t *auth_info); | ||
| void xcb_disconnect(xcb_connection_t *c); | ||
| int xcb_parse_display(const char *name, char **host, int *display, int *screen); | ||
| xcb_connection_t *xcb_connect(const char *displayname, int *screenp); | ||
| xcb_connection_t *xcb_connect_to_display_with_auth_info(const char *display, xcb_auth_info_t *auth, int *screen); | ||
| uint32_t xcb_generate_id(xcb_connection_t *c); | ||
| xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t cookie); | ||
| """ | ||
| CDEF += """ | ||
| unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request); | ||
| void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e); | ||
| int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error); | ||
| void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence); | ||
| """ | ||
| ffi = FFI() | ||
| ffi.cdef(CDEF) | ||
| # Fall back to non api mode, inline at load time | ||
| # this would only happen if the precompiled _xcffib was missing | ||
| if cffi_mode != "api": | ||
| if platform.system() == "Darwin": | ||
| soname = "libxcb.dylib" | ||
| elif platform.system() == "Windows": | ||
| soname = "libxcb.dll" | ||
| else: | ||
| soname = ctypes.util.find_library("xcb") | ||
| if soname is None: | ||
| soname = "libxcb.so" | ||
| lib = ffi.dlopen(soname) # noqa |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
942894
0.26%59
3.51%20964
0.3%