github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/internal/xcb/libxcb.go (about) 1 //go:build linux && !android 2 3 package xcb 4 5 /* 6 7 #cgo CFLAGS: -I${SRCDIR}/include 8 #cgo LDFLAGS: -ldl 9 10 #include <dlfcn.h> 11 #include <X11/Xlib-xcb.h> 12 #include <xcb/randr.h> 13 #include <xcb/xinput.h> 14 #include <xcb/xcb_icccm.h> 15 #include <xcb/xcb_image.h> 16 #include <X11/Xcursor/Xcursor.h> 17 #include <xcb/xkb.h> 18 19 // libX11 20 Status gamen_XInitThreads(void *fp) { 21 typedef Status (*proc_XInitThreads)(void); 22 return ((proc_XInitThreads)fp)(); 23 } 24 Display *gamen_XOpenDisplay(void *fp, const char* display_name) { 25 typedef Display *(*proc_XOpenDisplay)(const char* display_name); 26 return ((proc_XOpenDisplay)fp)(display_name); 27 } 28 int gamen_XCloseDisplay(void *fp, Display* dpy) { 29 typedef int (*proc_XCloseDisplay)(Display* dpy); 30 return ((proc_XCloseDisplay)fp)(dpy); 31 } 32 33 // libX11-xcb 34 xcb_connection_t *gamen_XGetXCBConnection(void *fp, Display *dpy) { 35 typedef xcb_connection_t *(*proc_XGetXCBConnection)(Display *dpy); 36 return ((proc_XGetXCBConnection)fp)(dpy); 37 } 38 void gamen_XSetEventQueueOwner(void *fp, Display *dpy, enum XEventQueueOwner owner) { 39 typedef void (*proc_XSetEventQueueOwner)(Display *dpy, enum XEventQueueOwner owner); 40 ((proc_XSetEventQueueOwner)fp)(dpy, owner); 41 } 42 43 // libXcursor 44 Cursor gamen_XcursorLibraryLoadCursor(void *fp, Display *dpy, const char *file) { 45 typedef Cursor (*proc_XcursorLibraryLoadCursor)(Display *dpy, const char *file); 46 return ((proc_XcursorLibraryLoadCursor)fp)(dpy, file); 47 } 48 49 // libxcb 50 const struct xcb_setup_t *gamen_xcb_get_setup(void *fp, xcb_connection_t *c) { 51 typedef const struct xcb_setup_t *(*proc_xcb_get_setup)(xcb_connection_t *c); 52 return ((proc_xcb_get_setup)fp)(c); 53 } 54 xcb_screen_iterator_t gamen_xcb_setup_roots_iterator(void *fp, const xcb_setup_t *R) { 55 typedef xcb_screen_iterator_t (*proc_xcb_setup_roots_iterator)(const xcb_setup_t *R); 56 return ((proc_xcb_setup_roots_iterator)fp)(R); 57 } 58 void gamen_xcb_screen_next(void *fp, xcb_screen_iterator_t *i) { 59 typedef void (*proc_xcb_screen_next)(xcb_screen_iterator_t *i); 60 ((proc_xcb_screen_next)fp)(i); 61 } 62 const struct xcb_query_extension_reply_t *gamen_xcb_get_extension_data(void *fp, xcb_connection_t *c, xcb_extension_t *ext) { 63 typedef const struct xcb_query_extension_reply_t *(*proc_xcb_get_extension_data)(xcb_connection_t *c, xcb_extension_t *ext); 64 return ((proc_xcb_get_extension_data)fp)(c, ext); 65 } 66 xcb_intern_atom_cookie_t gamen_xcb_intern_atom(void *fp, xcb_connection_t *c, uint8_t only_if_exists, uint16_t name_len, const char *name) { 67 typedef xcb_intern_atom_cookie_t (*proc_xcb_intern_atom)(xcb_connection_t *c, uint8_t only_if_exists, uint16_t name_len, const char *name); 68 return ((proc_xcb_intern_atom)fp)(c, only_if_exists, name_len, name); 69 } 70 xcb_intern_atom_reply_t *gamen_xcb_intern_atom_reply(void *fp, xcb_connection_t *c, xcb_intern_atom_cookie_t cookie, xcb_generic_error_t **e) { 71 typedef xcb_intern_atom_reply_t *(*proc_xcb_intern_atom_reply)(xcb_connection_t *c, xcb_intern_atom_cookie_t cookie, xcb_generic_error_t **e); 72 return ((proc_xcb_intern_atom_reply)fp)(c, cookie, e); 73 } 74 xcb_generic_event_t *gamen_xcb_poll_for_event(void *fp, xcb_connection_t *c) { 75 typedef xcb_generic_event_t *(*proc_xcb_poll_for_event)(xcb_connection_t *c); 76 return ((proc_xcb_poll_for_event)fp)(c); 77 } 78 int gamen_xcb_get_file_descriptor(void *fp, xcb_connection_t *c) { 79 typedef int (*proc_xcb_get_file_descriptor)(xcb_connection_t *c); 80 return ((proc_xcb_get_file_descriptor)fp)(c); 81 } 82 uint32_t gamen_xcb_generate_id(void *fp, xcb_connection_t *c) { 83 typedef uint32_t (*proc_xcb_generate_id)(xcb_connection_t *c); 84 return ((proc_xcb_generate_id)fp)(c); 85 } 86 xcb_void_cookie_t gamen_xcb_create_window_checked(void *fp, xcb_connection_t *c, uint8_t depth, xcb_window_t wid, xcb_window_t parent, int16_t x, int16_t y, uint16_t width, uint16_t height, uint16_t border_width, uint16_t _class, xcb_visualid_t visual, uint32_t value_mask, const void *value_list) { 87 typedef xcb_void_cookie_t (*proc_gamen_xcb_create_window_checked)(xcb_connection_t *c, uint8_t depth, xcb_window_t wid, xcb_window_t parent, int16_t x, int16_t y, uint16_t width, uint16_t height, uint16_t border_width, uint16_t _class, xcb_visualid_t visual, uint32_t value_mask, const void *value_list); 88 return ((proc_gamen_xcb_create_window_checked)fp)(c, depth, wid, parent, x, y, width, height, border_width, _class, visual, value_mask, value_list); 89 } 90 xcb_generic_error_t *gamen_xcb_request_check(void *fp, xcb_connection_t *c, xcb_void_cookie_t cookie) { 91 typedef xcb_generic_error_t *(*proc_xcb_request_check)(xcb_connection_t *c, xcb_void_cookie_t cookie); 92 return ((proc_xcb_request_check)fp)(c, cookie); 93 } 94 xcb_void_cookie_t gamen_xcb_change_property(void *fp, xcb_connection_t *c, uint8_t mode, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, uint8_t format, uint32_t data_len, const void *data) { 95 typedef xcb_void_cookie_t (*proc_xcb_change_property)(xcb_connection_t *c, uint8_t mode, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, uint8_t format, uint32_t data_len, const void *data); 96 return ((proc_xcb_change_property)fp)(c, mode, window, property, type, format, data_len, data); 97 } 98 xcb_void_cookie_t gamen_xcb_map_window_checked(void *fp, xcb_connection_t *c, xcb_window_t window) { 99 typedef xcb_void_cookie_t (*proc_xcb_map_window_checked)(xcb_connection_t *c, xcb_window_t window); 100 return ((proc_xcb_map_window_checked)fp)(c, window); 101 } 102 xcb_void_cookie_t gamen_xcb_destroy_window(void *fp, xcb_connection_t *c, xcb_window_t window) { 103 typedef xcb_void_cookie_t (*proc_xcb_destroy_window)(xcb_connection_t *c, xcb_window_t window); 104 return ((proc_xcb_destroy_window)fp)(c, window); 105 } 106 int gamen_xcb_flush(void *fp, xcb_connection_t *c) { 107 typedef int (*proc_xcb_flush)(xcb_connection_t *c); 108 return ((proc_xcb_flush)fp)(c); 109 } 110 xcb_get_geometry_reply_t *gamen_xcb_get_geometry_reply(void *fp1, void *fp2, xcb_connection_t *c, xcb_drawable_t drawable) { 111 typedef xcb_get_geometry_cookie_t (*proc_xcb_get_geometry_unchecked)(xcb_connection_t *c, xcb_drawable_t drawable); 112 typedef xcb_get_geometry_reply_t *(*proc_xcb_get_geometry_reply)(xcb_connection_t *c, xcb_get_geometry_cookie_t cookie, xcb_generic_error_t **e); 113 return ((proc_xcb_get_geometry_reply)fp2)(c, ((proc_xcb_get_geometry_unchecked)fp1)(c, drawable), NULL); 114 } 115 xcb_void_cookie_t gamen_xcb_configure_window(void *fp, xcb_connection_t *c, xcb_window_t window, uint16_t value_mask, const void *value_list) { 116 typedef xcb_void_cookie_t (*proc_xcb_configure_window)(xcb_connection_t *c, xcb_window_t window, uint16_t value_mask, const void *value_list); 117 return ((proc_xcb_configure_window)fp)(c, window, value_mask, value_list); 118 } 119 xcb_get_property_reply_t *gamen_xcb_get_property_reply(void *fp1, void *fp2, xcb_connection_t *c, uint8_t _delete, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, uint32_t long_offset, uint32_t long_length) { 120 typedef xcb_get_property_cookie_t (*proc_xcb_get_property_unchecked)(xcb_connection_t *c, uint8_t _delete, xcb_window_t window, xcb_atom_t property, xcb_atom_t type, uint32_t long_offset, uint32_t long_length); 121 typedef xcb_get_property_reply_t *(*proc_xcb_get_property_reply)(xcb_connection_t *c, xcb_get_property_cookie_t cookie, xcb_generic_error_t **e); 122 return ((proc_xcb_get_property_reply)fp2)(c, ((proc_xcb_get_property_unchecked)fp1)(c, _delete, window, property, type, long_offset, long_length), NULL); 123 } 124 void *gamen_xcb_get_property_value(void *fp, const xcb_get_property_reply_t *R) { 125 typedef void *(*proc_xcb_get_property_value)(const xcb_get_property_reply_t *R); 126 return ((proc_xcb_get_property_value)fp)(R); 127 } 128 int gamen_xcb_get_property_value_length(void *fp, const xcb_get_property_reply_t *R) { 129 typedef int (*proc_xcb_get_property_value_length)(const xcb_get_property_reply_t *R); 130 return ((proc_xcb_get_property_value_length)fp)(R); 131 } 132 xcb_void_cookie_t gamen_xcb_send_event(void *fp, xcb_connection_t *c, uint8_t propagate, xcb_window_t destination, uint32_t event_mask, const char *event) { 133 typedef xcb_void_cookie_t (*proc_xcb_send_event)(xcb_connection_t *c, uint8_t propagate, xcb_window_t destination, uint32_t event_mask, const char *event); 134 return ((proc_xcb_send_event)fp)(c, propagate, destination, event_mask, event); 135 } 136 xcb_void_cookie_t gamen_xcb_change_window_attributes(void *fp, xcb_connection_t *c, xcb_window_t window, uint32_t value_mask, const void *value_list) { 137 typedef xcb_void_cookie_t (*proc_xcb_change_window_attributes)(xcb_connection_t *c, xcb_window_t window, uint32_t value_mask, const void *value_list); 138 return ((proc_xcb_change_window_attributes)fp)(c, window, value_mask, value_list); 139 } 140 xcb_translate_coordinates_reply_t *gamen_xcb_translate_coordinates_reply(void *fp1, void *fp2, xcb_connection_t *c, xcb_window_t src_window, xcb_window_t dst_window, int16_t src_x, int16_t src_y) { 141 typedef xcb_translate_coordinates_cookie_t (*proc_xcb_translate_coordinates_unchecked)(xcb_connection_t *c, xcb_window_t src_window, xcb_window_t dst_window, int16_t src_x, int16_t src_y); 142 typedef xcb_translate_coordinates_reply_t *(*proc_xcb_translate_coordinates_reply)(xcb_connection_t *c, xcb_translate_coordinates_cookie_t cookie, xcb_generic_error_t **e); 143 return ((proc_xcb_translate_coordinates_reply)fp2)(c, ((proc_xcb_translate_coordinates_unchecked)fp1)(c, src_window, dst_window, src_x, src_y), NULL); 144 } 145 xcb_void_cookie_t gamen_xcb_ungrab_pointer(void *fp, xcb_connection_t *c, xcb_timestamp_t time) { 146 typedef xcb_void_cookie_t (*proc_xcb_ungrab_pointer)(xcb_connection_t *c, xcb_timestamp_t time); 147 return ((proc_xcb_ungrab_pointer)fp)(c, time); 148 } 149 xcb_void_cookie_t gamen_xcb_free_pixmap(void *fp, xcb_connection_t *c, xcb_pixmap_t pixmap) { 150 typedef xcb_void_cookie_t (*proc_xcb_free_pixmap)(xcb_connection_t *c, xcb_pixmap_t pixmap); 151 return ((proc_xcb_free_pixmap)fp)(c, pixmap); 152 } 153 xcb_void_cookie_t gamen_xcb_create_cursor(void *fp, xcb_connection_t *c, xcb_cursor_t cid, xcb_pixmap_t source, xcb_pixmap_t mask, uint16_t fore_red, uint16_t fore_green, uint16_t fore_blue, uint16_t back_red, uint16_t back_green, uint16_t back_blue, uint16_t x, uint16_t y) { 154 typedef xcb_void_cookie_t (*proc_xcb_create_cursor)(xcb_connection_t *c, xcb_cursor_t cid, xcb_pixmap_t source, xcb_pixmap_t mask, uint16_t fore_red, uint16_t fore_green, uint16_t fore_blue, uint16_t back_red, uint16_t back_green, uint16_t back_blue, uint16_t x, uint16_t y); 155 return ((proc_xcb_create_cursor)fp)(c, cid, source, mask, fore_red, fore_green, fore_blue, back_red, back_green, back_blue, x, y); 156 } 157 xcb_void_cookie_t gamen_xcb_free_cursor(void *fp, xcb_connection_t *c, xcb_cursor_t cursor) { 158 typedef xcb_void_cookie_t (*proc_xcb_free_cursor)(xcb_connection_t *c, xcb_cursor_t cursor); 159 return ((proc_xcb_free_cursor)fp)(c, cursor); 160 } 161 162 // libxcb-randr 163 xcb_randr_query_version_reply_t *gamen_xcb_randr_query_version_reply(void *fp1, void *fp2, xcb_connection_t *c, uint32_t major_version, uint32_t minor_version) { 164 typedef xcb_randr_query_version_cookie_t (*proc_xcb_randr_query_version_unchecked)(xcb_connection_t *c, uint32_t major_version, uint32_t minor_version); 165 typedef xcb_randr_query_version_reply_t *(*proc_xcb_randr_query_version_reply)(xcb_connection_t *c, xcb_randr_query_version_cookie_t cookie, xcb_generic_error_t **e); 166 return ((proc_xcb_randr_query_version_reply)fp2)(c, ((proc_xcb_randr_query_version_unchecked)fp1)(c, major_version, minor_version), NULL); 167 } 168 xcb_void_cookie_t gamen_xcb_randr_select_input(void *fp, xcb_connection_t *c, xcb_window_t window, uint16_t enable) { 169 typedef xcb_void_cookie_t (*proc_xcb_randr_select_input)(xcb_connection_t *c, xcb_window_t window, uint16_t enable); 170 return ((proc_xcb_randr_select_input)fp)(c, window, enable); 171 } 172 173 // libxcb-xinput 174 xcb_input_xi_query_version_reply_t *gamen_xcb_input_xi_query_version_reply(void *fp1, void *fp2, xcb_connection_t *c, uint16_t major_version, uint16_t minor_version) { 175 typedef xcb_input_xi_query_version_cookie_t (*proc_xcb_input_xi_query_version_unchecked)(xcb_connection_t *c, uint16_t major_version, uint16_t minor_version); 176 typedef xcb_input_xi_query_version_reply_t *(*proc_xcb_input_xi_query_version_reply)(xcb_connection_t *c, xcb_input_xi_query_version_cookie_t cookie, xcb_generic_error_t **e); 177 return ((proc_xcb_input_xi_query_version_reply)fp2)(c, ((proc_xcb_input_xi_query_version_unchecked)fp1)(c, major_version, minor_version), NULL); 178 } 179 xcb_input_xi_query_device_reply_t *gamen_xcb_input_xi_query_device_reply(void *fp1, void *fp2, xcb_connection_t *c, xcb_input_device_id_t deviceid) { 180 typedef xcb_input_xi_query_device_cookie_t (*proc_xcb_input_xi_query_device_unchecked)(xcb_connection_t *c, xcb_input_device_id_t deviceid); 181 typedef xcb_input_xi_query_device_reply_t *(*proc_xcb_input_xi_query_device_reply)(xcb_connection_t *c, xcb_input_xi_query_device_cookie_t cookie, xcb_generic_error_t **e); 182 return ((proc_xcb_input_xi_query_device_reply)fp2)(c, ((proc_xcb_input_xi_query_device_unchecked)fp1)(c, deviceid), NULL); 183 } 184 xcb_input_xi_device_info_iterator_t gamen_xcb_input_xi_query_device_infos_iterator(void *fp, const xcb_input_xi_query_device_reply_t *R) { 185 typedef xcb_input_xi_device_info_iterator_t (*proc_xcb_input_xi_query_device_infos_iterator)(const xcb_input_xi_query_device_reply_t *R); 186 return ((proc_xcb_input_xi_query_device_infos_iterator)fp)(R); 187 } 188 void gamen_xcb_input_xi_device_info_next(void *fp, xcb_input_xi_device_info_iterator_t *i) { 189 typedef void (*proc_xcb_input_xi_device_info_next)(xcb_input_xi_device_info_iterator_t *i); 190 return ((proc_xcb_input_xi_device_info_next)fp)(i); 191 } 192 xcb_input_device_class_iterator_t gamen_xcb_input_xi_device_info_classes_iterator(void *fp, const xcb_input_xi_device_info_t *R) { 193 typedef xcb_input_device_class_iterator_t (*proc_xcb_input_xi_device_info_classes_iterator)(const xcb_input_xi_device_info_t *R); 194 return ((proc_xcb_input_xi_device_info_classes_iterator)fp)(R); 195 } 196 void gamen_xcb_input_device_class_next(void *fp, xcb_input_device_class_iterator_t *i) { 197 typedef void (*proc_xcb_input_device_class_next)(xcb_input_device_class_iterator_t *i); 198 return ((proc_xcb_input_device_class_next)fp)(i); 199 } 200 xcb_void_cookie_t gamen_xcb_input_xi_select_events(void *fp, xcb_connection_t *c, xcb_window_t window, uint16_t num_mask, const xcb_input_event_mask_t *masks) { 201 typedef xcb_void_cookie_t (*proc_xcb_input_xi_select_events)(xcb_connection_t *c, xcb_window_t window, uint16_t num_mask, const xcb_input_event_mask_t *masks); 202 return ((proc_xcb_input_xi_select_events)fp)(c, window, num_mask, masks); 203 } 204 int gamen_xcb_input_button_press_valuator_mask_length(void *fp, const xcb_input_button_press_event_t *R) { 205 typedef int (*proc_xcb_input_button_press_valuator_mask_length)(const xcb_input_button_press_event_t *R); 206 return ((proc_xcb_input_button_press_valuator_mask_length)fp)(R); 207 } 208 uint32_t *gamen_xcb_input_button_press_valuator_mask(void *fp, const xcb_input_button_press_event_t *R) { 209 typedef uint32_t *(*proc_xcb_input_button_press_valuator_mask)(const xcb_input_button_press_event_t *R); 210 return ((proc_xcb_input_button_press_valuator_mask)fp)(R); 211 } 212 xcb_input_fp3232_t *gamen_xcb_input_button_press_axisvalues(void *fp, const xcb_input_button_press_event_t *R) { 213 typedef xcb_input_fp3232_t *(*proc_xcb_input_button_press_axisvalues)(const xcb_input_button_press_event_t *R); 214 return ((proc_xcb_input_button_press_axisvalues)fp)(R); 215 } 216 int gamen_xcb_input_button_press_axisvalues_length(void *fp, const xcb_input_button_press_event_t *R) { 217 typedef int (*proc_xcb_input_button_press_axisvalues_length)(const xcb_input_button_press_event_t *R); 218 return ((proc_xcb_input_button_press_axisvalues_length)fp)(R); 219 } 220 221 // libxcb-icccm 222 uint8_t gamen_xcb_icccm_get_wm_normal_hints_reply(void *fp1, void *fp2, xcb_connection_t *c, xcb_window_t window, xcb_size_hints_t *hints) { 223 typedef xcb_get_property_cookie_t (*proc_xcb_icccm_get_wm_normal_hints_unchecked)(xcb_connection_t *c, xcb_window_t window); 224 typedef uint8_t (*proc_xcb_icccm_get_wm_normal_hints_reply)(xcb_connection_t *c, xcb_get_property_cookie_t cookie, xcb_size_hints_t *hints, xcb_generic_error_t **e); 225 return ((proc_xcb_icccm_get_wm_normal_hints_reply)fp2)(c, ((proc_xcb_icccm_get_wm_normal_hints_unchecked)fp1)(c, window), hints, NULL); 226 } 227 void gamen_xcb_icccm_size_hints_set_min_size(void *fp, xcb_size_hints_t *hints, int32_t min_width, int32_t min_height) { 228 typedef void (*proc_xcb_icccm_size_hints_set_min_size)(xcb_size_hints_t *hints, int32_t min_width, int32_t min_height); 229 return ((proc_xcb_icccm_size_hints_set_min_size)fp)(hints, min_width, min_height); 230 } 231 void gamen_xcb_icccm_size_hints_set_max_size(void *fp, xcb_size_hints_t *hints, int32_t max_width, int32_t max_height) { 232 typedef void (*proc_xcb_icccm_size_hints_set_max_size)(xcb_size_hints_t *hints, int32_t max_width, int32_t max_height); 233 return ((proc_xcb_icccm_size_hints_set_max_size)fp)(hints, max_width, max_height); 234 } 235 xcb_void_cookie_t gamen_xcb_icccm_set_wm_normal_hints(void *fp, xcb_connection_t *c, xcb_window_t window, xcb_size_hints_t *hints) { 236 typedef xcb_void_cookie_t (*proc_xcb_icccm_set_wm_normal_hints)(xcb_connection_t *c, xcb_window_t window, xcb_size_hints_t *hints); 237 return ((proc_xcb_icccm_set_wm_normal_hints)fp)(c, window, hints); 238 } 239 uint8_t gamen_xcb_icccm_get_wm_hints_reply(void *fp1, void *fp2, xcb_connection_t *c, xcb_window_t window, xcb_icccm_wm_hints_t *hints) { 240 typedef xcb_get_property_cookie_t (*proc_xcb_icccm_get_wm_hints_unchecked)(xcb_connection_t *c, xcb_window_t window); 241 typedef uint8_t (*proc_xcb_icccm_get_wm_hints_reply)(xcb_connection_t *c, xcb_get_property_cookie_t cookie, xcb_icccm_wm_hints_t *hints, xcb_generic_error_t **e); 242 return ((proc_xcb_icccm_get_wm_hints_reply)fp2)(c, ((proc_xcb_icccm_get_wm_hints_unchecked)fp1)(c, window), hints, NULL); 243 } 244 void gamen_xcb_icccm_wm_hints_set_iconic(void *fp, xcb_icccm_wm_hints_t *hints) { 245 typedef void (*proc_xcb_icccm_wm_hints_set_iconic)(xcb_icccm_wm_hints_t *hints); 246 return ((proc_xcb_icccm_wm_hints_set_iconic)fp)(hints); 247 } 248 xcb_void_cookie_t gamen_xcb_icccm_set_wm_hints(void *fp, xcb_connection_t *c, xcb_window_t window, xcb_icccm_wm_hints_t *hints) { 249 typedef xcb_void_cookie_t (*proc_xcb_icccm_set_wm_hints)(xcb_connection_t *c, xcb_window_t window, xcb_icccm_wm_hints_t *hints); 250 return ((proc_xcb_icccm_set_wm_hints)fp)(c, window, hints); 251 } 252 253 // libxcb-image 254 xcb_pixmap_t gamen_xcb_create_pixmap_from_bitmap_data(void *fp, xcb_connection_t *display, xcb_drawable_t d, uint8_t *data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t *gcp) { 255 typedef xcb_pixmap_t (*proc_xcb_create_pixmap_from_bitmap_data)(xcb_connection_t *display, xcb_drawable_t d, uint8_t *data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t *gcp); 256 return ((proc_xcb_create_pixmap_from_bitmap_data)fp)(display, d, data, width, height, depth, fg, bg, gcp); 257 } 258 259 // libxcb-xkb 260 xcb_xkb_use_extension_reply_t *gamen_xcb_xkb_use_extension_reply(void *fp1, void *fp2, xcb_connection_t *c, uint16_t wantedMajor, uint16_t wantedMinor) { 261 typedef xcb_xkb_use_extension_cookie_t (*proc_xcb_xkb_use_extension_unchecked)(xcb_connection_t *c, uint16_t wantedMajor, uint16_t wantedMinor); 262 typedef xcb_xkb_use_extension_reply_t *(*proc_xcb_xkb_use_extension_reply)(xcb_connection_t *c, xcb_xkb_use_extension_cookie_t cookie, xcb_generic_error_t **e); 263 return ((proc_xcb_xkb_use_extension_reply)fp2)(c, ((proc_xcb_xkb_use_extension_unchecked)fp1)(c, wantedMajor, wantedMinor), NULL); 264 } 265 266 */ 267 import "C" 268 import ( 269 "errors" 270 "unsafe" 271 ) 272 273 type xcb_library struct { 274 libX11Handle unsafe.Pointer 275 libX11xcbHandle unsafe.Pointer 276 libXcursor unsafe.Pointer 277 libxcbHandle unsafe.Pointer 278 libxcbRandrHandle unsafe.Pointer 279 libxcbXinputHandle unsafe.Pointer 280 libxcbIcccmHandle unsafe.Pointer 281 libxcbImageHandle unsafe.Pointer 282 libxcbXkbHandle unsafe.Pointer 283 284 // libX11 285 XInitThreads_handle unsafe.Pointer 286 XOpenDisplay_handle unsafe.Pointer 287 XCloseDisplay_handle unsafe.Pointer 288 289 // libX11-xcb 290 XGetXCBConnection_handle unsafe.Pointer 291 XSetEventQueueOwner_handle unsafe.Pointer 292 293 // libXcursor 294 XcursorLibraryLoadCursor_handle unsafe.Pointer 295 296 // libxcb 297 xcb_get_setup_handle unsafe.Pointer 298 xcb_setup_roots_iterator_handle unsafe.Pointer 299 xcb_screen_next_handle unsafe.Pointer 300 xcb_get_extension_data_handle unsafe.Pointer 301 xcb_intern_atom_handle unsafe.Pointer 302 xcb_intern_atom_reply_handle unsafe.Pointer 303 xcb_poll_for_event_handle unsafe.Pointer 304 xcb_get_file_descriptor_handle unsafe.Pointer 305 xcb_generate_id_handle unsafe.Pointer 306 xcb_create_window_checked_handle unsafe.Pointer 307 xcb_request_check_handle unsafe.Pointer 308 xcb_change_property_handle unsafe.Pointer 309 xcb_map_window_checked_handle unsafe.Pointer 310 xcb_destroy_window_handle unsafe.Pointer 311 xcb_flush_handle unsafe.Pointer 312 xcb_get_geometry_unchecked_handle unsafe.Pointer 313 xcb_get_geometry_reply_handle unsafe.Pointer 314 xcb_configure_window_handle unsafe.Pointer 315 xcb_get_property_unchecked_handle unsafe.Pointer 316 xcb_get_property_reply_handle unsafe.Pointer 317 xcb_get_property_value_handle unsafe.Pointer 318 xcb_get_property_value_length_handle unsafe.Pointer 319 xcb_send_event_handle unsafe.Pointer 320 xcb_change_window_attributes_handle unsafe.Pointer 321 xcb_translate_coordinates_unchecked_handle unsafe.Pointer 322 xcb_translate_coordinates_reply_handle unsafe.Pointer 323 xcb_ungrab_pointer_handle unsafe.Pointer 324 xcb_free_pixmap_handle unsafe.Pointer 325 xcb_create_cursor_handle unsafe.Pointer 326 xcb_free_cursor_handle unsafe.Pointer 327 328 // libxcb-randr 329 xcb_randr_id unsafe.Pointer 330 xcb_randr_query_version_unchecked_handle unsafe.Pointer 331 xcb_randr_query_version_reply_handle unsafe.Pointer 332 xcb_randr_select_input_handle unsafe.Pointer 333 334 // libxcb-xinput 335 xcb_input_id unsafe.Pointer 336 xcb_input_xi_query_version_unchecked_handle unsafe.Pointer 337 xcb_input_xi_query_version_reply_handle unsafe.Pointer 338 xcb_input_xi_query_device_unchecked_handle unsafe.Pointer 339 xcb_input_xi_query_device_reply_handle unsafe.Pointer 340 xcb_input_xi_query_device_infos_iterator_handle unsafe.Pointer 341 xcb_input_xi_device_info_next_handle unsafe.Pointer 342 xcb_input_xi_device_info_classes_iterator_handle unsafe.Pointer 343 xcb_input_device_class_next_handle unsafe.Pointer 344 xcb_input_xi_select_events_handle unsafe.Pointer 345 xcb_input_button_press_valuator_mask_length_handle unsafe.Pointer 346 xcb_input_button_press_valuator_mask_handle unsafe.Pointer 347 xcb_input_button_press_axisvalues_handle unsafe.Pointer 348 xcb_input_button_press_axisvalues_length_handle unsafe.Pointer 349 350 // libxcb-icccm 351 xcb_icccm_get_wm_normal_hints_unchecked_handle unsafe.Pointer 352 xcb_icccm_get_wm_normal_hints_reply_handle unsafe.Pointer 353 xcb_icccm_size_hints_set_min_size_handle unsafe.Pointer 354 xcb_icccm_size_hints_set_max_size_handle unsafe.Pointer 355 xcb_icccm_set_wm_normal_hints_handle unsafe.Pointer 356 xcb_icccm_get_wm_hints_unchecked_handle unsafe.Pointer 357 xcb_icccm_get_wm_hints_reply_handle unsafe.Pointer 358 xcb_icccm_wm_hints_set_iconic_handle unsafe.Pointer 359 xcb_icccm_set_wm_hints_handle unsafe.Pointer 360 361 // libxcb-image 362 xcb_create_pixmap_from_bitmap_data_handle unsafe.Pointer 363 364 // libxcb-xkb 365 xcb_xkb_id unsafe.Pointer 366 xcb_xkb_use_extension_unchecked_handle unsafe.Pointer 367 xcb_xkb_use_extension_reply_handle unsafe.Pointer 368 } 369 370 func loadSym(handle unsafe.Pointer, symbol *C.char) (unsafe.Pointer, error) { 371 C.dlerror() 372 fp := C.dlsym(handle, symbol) 373 if fp == nil { 374 err := C.dlerror() 375 if err != nil { 376 return nil, errors.New(C.GoString(err)) 377 } 378 } 379 return fp, nil 380 } 381 382 func open_xcb_library() (*xcb_library, error) { 383 C.dlerror() 384 385 l := &xcb_library{} 386 387 l.libX11Handle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libX11.so.6\x00"))[0])), C.RTLD_LAZY) 388 if l.libX11Handle == nil { 389 err := C.dlerror() 390 if err != nil { 391 l.close() 392 return nil, errors.New(C.GoString(err)) 393 } 394 } 395 l.libXcursor = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libXcursor.so.1\x00"))[0])), C.RTLD_LAZY) 396 if l.libX11xcbHandle == nil { 397 err := C.dlerror() 398 if err != nil { 399 l.close() 400 return nil, errors.New(C.GoString(err)) 401 } 402 } 403 l.libX11xcbHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libX11-xcb.so.1\x00"))[0])), C.RTLD_LAZY) 404 if l.libX11xcbHandle == nil { 405 err := C.dlerror() 406 if err != nil { 407 l.close() 408 return nil, errors.New(C.GoString(err)) 409 } 410 } 411 l.libxcbHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb.so.1\x00"))[0])), C.RTLD_LAZY) 412 if l.libxcbHandle == nil { 413 err := C.dlerror() 414 if err != nil { 415 l.close() 416 return nil, errors.New(C.GoString(err)) 417 } 418 } 419 l.libxcbRandrHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb-randr.so.0\x00"))[0])), C.RTLD_LAZY) 420 if l.libxcbRandrHandle == nil { 421 err := C.dlerror() 422 if err != nil { 423 l.close() 424 return nil, errors.New(C.GoString(err)) 425 } 426 } 427 l.libxcbXinputHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb-xinput.so.0\x00"))[0])), C.RTLD_LAZY) 428 if l.libxcbXinputHandle == nil { 429 err := C.dlerror() 430 if err != nil { 431 l.close() 432 return nil, errors.New(C.GoString(err)) 433 } 434 } 435 l.libxcbIcccmHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb-icccm.so.4\x00"))[0])), C.RTLD_LAZY) 436 if l.libxcbIcccmHandle == nil { 437 err := C.dlerror() 438 if err != nil { 439 l.close() 440 return nil, errors.New(C.GoString(err)) 441 } 442 } 443 l.libxcbImageHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb-image.so.0\x00"))[0])), C.RTLD_LAZY) 444 if l.libxcbImageHandle == nil { 445 err := C.dlerror() 446 if err != nil { 447 l.close() 448 return nil, errors.New(C.GoString(err)) 449 } 450 } 451 l.libxcbXkbHandle = C.dlopen((*C.char)(unsafe.Pointer(&([]byte("libxcb-xkb.so.1\x00"))[0])), C.RTLD_LAZY) 452 if l.libxcbXkbHandle == nil { 453 err := C.dlerror() 454 if err != nil { 455 l.close() 456 return nil, errors.New(C.GoString(err)) 457 } 458 } 459 460 var err error 461 462 // libX11 463 l.XInitThreads_handle, err = loadSym(l.libX11Handle, (*C.char)(unsafe.Pointer(&([]byte("XInitThreads\x00"))[0]))) 464 if err != nil { 465 l.close() 466 return nil, err 467 } 468 l.XOpenDisplay_handle, err = loadSym(l.libX11Handle, (*C.char)(unsafe.Pointer(&([]byte("XOpenDisplay\x00"))[0]))) 469 if err != nil { 470 l.close() 471 return nil, err 472 } 473 l.XCloseDisplay_handle, err = loadSym(l.libX11Handle, (*C.char)(unsafe.Pointer(&([]byte("XCloseDisplay\x00"))[0]))) 474 if err != nil { 475 l.close() 476 return nil, err 477 } 478 479 // libX11-xcb 480 l.XGetXCBConnection_handle, err = loadSym(l.libX11xcbHandle, (*C.char)(unsafe.Pointer(&([]byte("XGetXCBConnection\x00"))[0]))) 481 if err != nil { 482 l.close() 483 return nil, err 484 } 485 l.XSetEventQueueOwner_handle, err = loadSym(l.libX11xcbHandle, (*C.char)(unsafe.Pointer(&([]byte("XSetEventQueueOwner\x00"))[0]))) 486 if err != nil { 487 l.close() 488 return nil, err 489 } 490 491 // libXcursor 492 l.XcursorLibraryLoadCursor_handle, err = loadSym(l.libXcursor, (*C.char)(unsafe.Pointer(&([]byte("XcursorLibraryLoadCursor\x00"))[0]))) 493 if err != nil { 494 l.close() 495 return nil, err 496 } 497 498 // libxcb 499 l.xcb_get_setup_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_setup\x00"))[0]))) 500 if err != nil { 501 l.close() 502 return nil, err 503 } 504 l.xcb_setup_roots_iterator_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_setup_roots_iterator\x00"))[0]))) 505 if err != nil { 506 l.close() 507 return nil, err 508 } 509 l.xcb_screen_next_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_screen_next\x00"))[0]))) 510 if err != nil { 511 l.close() 512 return nil, err 513 } 514 l.xcb_get_extension_data_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_extension_data\x00"))[0]))) 515 if err != nil { 516 l.close() 517 return nil, err 518 } 519 l.xcb_intern_atom_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_intern_atom\x00"))[0]))) 520 if err != nil { 521 l.close() 522 return nil, err 523 } 524 l.xcb_intern_atom_reply_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_intern_atom_reply\x00"))[0]))) 525 if err != nil { 526 l.close() 527 return nil, err 528 } 529 l.xcb_poll_for_event_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_poll_for_event\x00"))[0]))) 530 if err != nil { 531 l.close() 532 return nil, err 533 } 534 l.xcb_get_file_descriptor_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_file_descriptor\x00"))[0]))) 535 if err != nil { 536 l.close() 537 return nil, err 538 } 539 l.xcb_generate_id_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_generate_id\x00"))[0]))) 540 if err != nil { 541 l.close() 542 return nil, err 543 } 544 l.xcb_create_window_checked_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_create_window_checked\x00"))[0]))) 545 if err != nil { 546 l.close() 547 return nil, err 548 } 549 l.xcb_request_check_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_request_check\x00"))[0]))) 550 if err != nil { 551 l.close() 552 return nil, err 553 } 554 l.xcb_change_property_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_change_property\x00"))[0]))) 555 if err != nil { 556 l.close() 557 return nil, err 558 } 559 l.xcb_map_window_checked_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_map_window_checked\x00"))[0]))) 560 if err != nil { 561 l.close() 562 return nil, err 563 } 564 l.xcb_destroy_window_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_destroy_window\x00"))[0]))) 565 if err != nil { 566 l.close() 567 return nil, err 568 } 569 l.xcb_flush_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_flush\x00"))[0]))) 570 if err != nil { 571 l.close() 572 return nil, err 573 } 574 l.xcb_get_geometry_unchecked_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_geometry_unchecked\x00"))[0]))) 575 if err != nil { 576 l.close() 577 return nil, err 578 } 579 l.xcb_get_geometry_reply_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_geometry_reply\x00"))[0]))) 580 if err != nil { 581 l.close() 582 return nil, err 583 } 584 l.xcb_configure_window_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_configure_window\x00"))[0]))) 585 if err != nil { 586 l.close() 587 return nil, err 588 } 589 l.xcb_get_property_unchecked_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_property_unchecked\x00"))[0]))) 590 if err != nil { 591 l.close() 592 return nil, err 593 } 594 l.xcb_get_property_reply_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_property_reply\x00"))[0]))) 595 if err != nil { 596 l.close() 597 return nil, err 598 } 599 l.xcb_get_property_value_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_property_value\x00"))[0]))) 600 if err != nil { 601 l.close() 602 return nil, err 603 } 604 l.xcb_get_property_value_length_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_get_property_value_length\x00"))[0]))) 605 if err != nil { 606 l.close() 607 return nil, err 608 } 609 l.xcb_send_event_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_send_event\x00"))[0]))) 610 if err != nil { 611 l.close() 612 return nil, err 613 } 614 l.xcb_change_window_attributes_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_change_window_attributes\x00"))[0]))) 615 if err != nil { 616 l.close() 617 return nil, err 618 } 619 l.xcb_translate_coordinates_unchecked_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_translate_coordinates_unchecked\x00"))[0]))) 620 if err != nil { 621 l.close() 622 return nil, err 623 } 624 l.xcb_translate_coordinates_reply_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_translate_coordinates_reply\x00"))[0]))) 625 if err != nil { 626 l.close() 627 return nil, err 628 } 629 l.xcb_ungrab_pointer_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_ungrab_pointer\x00"))[0]))) 630 if err != nil { 631 l.close() 632 return nil, err 633 } 634 l.xcb_free_pixmap_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_free_pixmap\x00"))[0]))) 635 if err != nil { 636 l.close() 637 return nil, err 638 } 639 l.xcb_create_cursor_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_create_cursor\x00"))[0]))) 640 if err != nil { 641 l.close() 642 return nil, err 643 } 644 l.xcb_free_cursor_handle, err = loadSym(l.libxcbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_free_cursor\x00"))[0]))) 645 if err != nil { 646 l.close() 647 return nil, err 648 } 649 650 // libxcb-randr 651 l.xcb_randr_id, err = loadSym(l.libxcbRandrHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_randr_id\x00"))[0]))) 652 if err != nil { 653 l.close() 654 return nil, err 655 } 656 l.xcb_randr_query_version_unchecked_handle, err = loadSym(l.libxcbRandrHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_randr_query_version_unchecked\x00"))[0]))) 657 if err != nil { 658 l.close() 659 return nil, err 660 } 661 l.xcb_randr_query_version_reply_handle, err = loadSym(l.libxcbRandrHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_randr_query_version_reply\x00"))[0]))) 662 if err != nil { 663 l.close() 664 return nil, err 665 } 666 l.xcb_randr_select_input_handle, err = loadSym(l.libxcbRandrHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_randr_select_input\x00"))[0]))) 667 if err != nil { 668 l.close() 669 return nil, err 670 } 671 672 // libxcb-xinput 673 l.xcb_input_id, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_id\x00"))[0]))) 674 if err != nil { 675 l.close() 676 return nil, err 677 } 678 l.xcb_input_xi_query_version_unchecked_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_query_version_unchecked\x00"))[0]))) 679 if err != nil { 680 l.close() 681 return nil, err 682 } 683 l.xcb_input_xi_query_version_reply_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_query_version_reply\x00"))[0]))) 684 if err != nil { 685 l.close() 686 return nil, err 687 } 688 l.xcb_input_xi_query_device_unchecked_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_query_device_unchecked\x00"))[0]))) 689 if err != nil { 690 l.close() 691 return nil, err 692 } 693 l.xcb_input_xi_query_device_reply_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_query_device_reply\x00"))[0]))) 694 if err != nil { 695 l.close() 696 return nil, err 697 } 698 l.xcb_input_xi_query_device_infos_iterator_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_query_device_infos_iterator\x00"))[0]))) 699 if err != nil { 700 l.close() 701 return nil, err 702 } 703 l.xcb_input_xi_device_info_next_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_device_info_next\x00"))[0]))) 704 if err != nil { 705 l.close() 706 return nil, err 707 } 708 l.xcb_input_xi_device_info_classes_iterator_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_device_info_classes_iterator\x00"))[0]))) 709 if err != nil { 710 l.close() 711 return nil, err 712 } 713 l.xcb_input_device_class_next_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_device_class_next\x00"))[0]))) 714 if err != nil { 715 l.close() 716 return nil, err 717 } 718 l.xcb_input_xi_select_events_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_xi_select_events\x00"))[0]))) 719 if err != nil { 720 l.close() 721 return nil, err 722 } 723 l.xcb_input_button_press_valuator_mask_length_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_button_press_valuator_mask_length\x00"))[0]))) 724 if err != nil { 725 l.close() 726 return nil, err 727 } 728 l.xcb_input_button_press_valuator_mask_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_button_press_valuator_mask\x00"))[0]))) 729 if err != nil { 730 l.close() 731 return nil, err 732 } 733 l.xcb_input_button_press_axisvalues_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_button_press_axisvalues\x00"))[0]))) 734 if err != nil { 735 l.close() 736 return nil, err 737 } 738 l.xcb_input_button_press_axisvalues_length_handle, err = loadSym(l.libxcbXinputHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_input_button_press_axisvalues_length\x00"))[0]))) 739 if err != nil { 740 l.close() 741 return nil, err 742 } 743 744 // libxcb-icccm 745 l.xcb_icccm_get_wm_normal_hints_unchecked_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_get_wm_normal_hints_unchecked\x00"))[0]))) 746 if err != nil { 747 l.close() 748 return nil, err 749 } 750 l.xcb_icccm_get_wm_normal_hints_reply_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_get_wm_normal_hints_reply\x00"))[0]))) 751 if err != nil { 752 l.close() 753 return nil, err 754 } 755 l.xcb_icccm_size_hints_set_min_size_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_size_hints_set_min_size\x00"))[0]))) 756 if err != nil { 757 l.close() 758 return nil, err 759 } 760 l.xcb_icccm_size_hints_set_max_size_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_size_hints_set_max_size\x00"))[0]))) 761 if err != nil { 762 l.close() 763 return nil, err 764 } 765 l.xcb_icccm_set_wm_normal_hints_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_set_wm_normal_hints\x00"))[0]))) 766 if err != nil { 767 l.close() 768 return nil, err 769 } 770 l.xcb_icccm_get_wm_hints_unchecked_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_get_wm_hints_unchecked\x00"))[0]))) 771 if err != nil { 772 l.close() 773 return nil, err 774 } 775 l.xcb_icccm_get_wm_hints_reply_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_get_wm_hints_reply\x00"))[0]))) 776 if err != nil { 777 l.close() 778 return nil, err 779 } 780 l.xcb_icccm_wm_hints_set_iconic_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_wm_hints_set_iconic\x00"))[0]))) 781 if err != nil { 782 l.close() 783 return nil, err 784 } 785 l.xcb_icccm_set_wm_hints_handle, err = loadSym(l.libxcbIcccmHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_icccm_set_wm_hints\x00"))[0]))) 786 if err != nil { 787 l.close() 788 return nil, err 789 } 790 791 // libxcb-image 792 l.xcb_create_pixmap_from_bitmap_data_handle, err = loadSym(l.libxcbImageHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_create_pixmap_from_bitmap_data\x00"))[0]))) 793 if err != nil { 794 l.close() 795 return nil, err 796 } 797 798 // libxcb-xkb 799 l.xcb_xkb_id, err = loadSym(l.libxcbXkbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_xkb_id\x00"))[0]))) 800 if err != nil { 801 l.close() 802 return nil, err 803 } 804 l.xcb_xkb_use_extension_unchecked_handle, err = loadSym(l.libxcbXkbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_xkb_use_extension_unchecked\x00"))[0]))) 805 if err != nil { 806 l.close() 807 return nil, err 808 } 809 l.xcb_xkb_use_extension_reply_handle, err = loadSym(l.libxcbXkbHandle, (*C.char)(unsafe.Pointer(&([]byte("xcb_xkb_use_extension_reply\x00"))[0]))) 810 if err != nil { 811 l.close() 812 return nil, err 813 } 814 815 return l, nil 816 } 817 818 func (l *xcb_library) close() { 819 if l.libxcbXkbHandle != nil { 820 C.dlclose(l.libxcbXkbHandle) 821 l.libxcbXkbHandle = nil 822 } 823 if l.libxcbImageHandle != nil { 824 C.dlclose(l.libxcbImageHandle) 825 l.libxcbImageHandle = nil 826 } 827 if l.libxcbIcccmHandle != nil { 828 C.dlclose(l.libxcbIcccmHandle) 829 l.libxcbIcccmHandle = nil 830 } 831 if l.libxcbXinputHandle != nil { 832 C.dlclose(l.libxcbXinputHandle) 833 l.libxcbXinputHandle = nil 834 } 835 if l.libxcbRandrHandle != nil { 836 C.dlclose(l.libxcbRandrHandle) 837 l.libxcbRandrHandle = nil 838 } 839 if l.libxcbHandle != nil { 840 C.dlclose(l.libxcbHandle) 841 l.libxcbHandle = nil 842 } 843 if l.libXcursor != nil { 844 C.dlclose(l.libXcursor) 845 l.libXcursor = nil 846 } 847 if l.libX11xcbHandle != nil { 848 C.dlclose(l.libX11xcbHandle) 849 l.libX11xcbHandle = nil 850 } 851 if l.libX11Handle != nil { 852 C.dlclose(l.libX11Handle) 853 l.libX11Handle = nil 854 } 855 } 856 857 // libX11 858 func (l *xcb_library) XInitThreads() C.Status { 859 return C.gamen_XInitThreads(l.XInitThreads_handle) 860 } 861 func (l *xcb_library) XOpenDisplay(display_name *C.char) *C.Display { 862 return C.gamen_XOpenDisplay(l.XOpenDisplay_handle, display_name) 863 } 864 func (l *xcb_library) XCloseDisplay(dpy *C.Display) C.int { 865 return C.gamen_XCloseDisplay(l.XCloseDisplay_handle, dpy) 866 } 867 868 // libX11-xcb 869 func (l *xcb_library) XGetXCBConnection(dpy *C.Display) *C.xcb_connection_t { 870 return C.gamen_XGetXCBConnection(l.XGetXCBConnection_handle, dpy) 871 } 872 func (l *xcb_library) XSetEventQueueOwner(dpy *C.Display, owner C.enum_XEventQueueOwner) { 873 C.gamen_XSetEventQueueOwner(l.XSetEventQueueOwner_handle, dpy, owner) 874 } 875 876 // libXcursor 877 func (l *xcb_library) XcursorLibraryLoadCursor(dpy *C.Display, file *C.char) C.Cursor { 878 return C.gamen_XcursorLibraryLoadCursor(l.XcursorLibraryLoadCursor_handle, dpy, file) 879 } 880 881 // libxcb 882 func (l *xcb_library) xcb_get_setup(c *C.xcb_connection_t) *C.struct_xcb_setup_t { 883 return C.gamen_xcb_get_setup(l.xcb_get_setup_handle, c) 884 } 885 func (l *xcb_library) xcb_setup_roots_iterator(R *C.xcb_setup_t) C.xcb_screen_iterator_t { 886 return C.gamen_xcb_setup_roots_iterator(l.xcb_setup_roots_iterator_handle, R) 887 } 888 func (l *xcb_library) xcb_screen_next(i *C.xcb_screen_iterator_t) { 889 C.gamen_xcb_screen_next(l.xcb_screen_next_handle, i) 890 } 891 func (l *xcb_library) xcb_get_extension_data(c *C.xcb_connection_t, ext *C.xcb_extension_t) *C.struct_xcb_query_extension_reply_t { 892 return C.gamen_xcb_get_extension_data(l.xcb_get_extension_data_handle, c, ext) 893 } 894 func (l *xcb_library) xcb_intern_atom(c *C.xcb_connection_t, only_if_exists C.uint8_t, name_len C.uint16_t, name *C.char) C.xcb_intern_atom_cookie_t { 895 return C.gamen_xcb_intern_atom(l.xcb_intern_atom_handle, c, only_if_exists, name_len, name) 896 } 897 func (l *xcb_library) xcb_intern_atom_reply(c *C.xcb_connection_t, cookie C.xcb_intern_atom_cookie_t, e **C.xcb_generic_error_t) *C.xcb_intern_atom_reply_t { 898 return C.gamen_xcb_intern_atom_reply(l.xcb_intern_atom_reply_handle, c, cookie, e) 899 } 900 func (l *xcb_library) xcb_poll_for_event(c *C.xcb_connection_t) *C.xcb_generic_event_t { 901 return C.gamen_xcb_poll_for_event(l.xcb_poll_for_event_handle, c) 902 } 903 func (l *xcb_library) xcb_get_file_descriptor(c *C.xcb_connection_t) C.int { 904 return C.gamen_xcb_get_file_descriptor(l.xcb_get_file_descriptor_handle, c) 905 } 906 func (l *xcb_library) xcb_generate_id(c *C.xcb_connection_t) C.uint32_t { 907 return C.gamen_xcb_generate_id(l.xcb_generate_id_handle, c) 908 } 909 func (l *xcb_library) xcb_create_window_checked(c *C.xcb_connection_t, depth C.uint8_t, wid C.xcb_window_t, parent C.xcb_window_t, x C.int16_t, y C.int16_t, width C.uint16_t, height C.uint16_t, border_width C.uint16_t, _class C.uint16_t, visual C.xcb_visualid_t, value_mask C.uint32_t, value_list unsafe.Pointer) C.xcb_void_cookie_t { 910 return C.gamen_xcb_create_window_checked(l.xcb_create_window_checked_handle, c, depth, wid, parent, x, y, width, height, border_width, _class, visual, value_mask, value_list) 911 } 912 func (l *xcb_library) xcb_request_check(c *C.xcb_connection_t, cookie C.xcb_void_cookie_t) *C.xcb_generic_error_t { 913 return C.gamen_xcb_request_check(l.xcb_request_check_handle, c, cookie) 914 } 915 func (l *xcb_library) xcb_change_property(c *C.xcb_connection_t, mode C.uint8_t, window C.xcb_window_t, property C.xcb_atom_t, type_ C.xcb_atom_t, format C.uint8_t, data_len C.uint32_t, data unsafe.Pointer) C.xcb_void_cookie_t { 916 return C.gamen_xcb_change_property(l.xcb_change_property_handle, c, mode, window, property, type_, format, data_len, data) 917 } 918 func (l *xcb_library) xcb_map_window_checked(c *C.xcb_connection_t, window C.xcb_window_t) C.xcb_void_cookie_t { 919 return C.gamen_xcb_map_window_checked(l.xcb_map_window_checked_handle, c, window) 920 } 921 func (l *xcb_library) xcb_destroy_window(c *C.xcb_connection_t, window C.xcb_window_t) C.xcb_void_cookie_t { 922 return C.gamen_xcb_destroy_window(l.xcb_destroy_window_handle, c, window) 923 } 924 func (l *xcb_library) xcb_flush(c *C.xcb_connection_t) C.int { 925 return C.gamen_xcb_flush(l.xcb_flush_handle, c) 926 } 927 func (l *xcb_library) xcb_get_geometry_reply(c *C.xcb_connection_t, drawable C.xcb_drawable_t) *C.xcb_get_geometry_reply_t { 928 return C.gamen_xcb_get_geometry_reply(l.xcb_get_geometry_unchecked_handle, l.xcb_get_geometry_reply_handle, c, drawable) 929 } 930 func (l *xcb_library) xcb_configure_window(c *C.xcb_connection_t, window C.xcb_window_t, value_mask C.uint16_t, value_list unsafe.Pointer) C.xcb_void_cookie_t { 931 return C.gamen_xcb_configure_window(l.xcb_configure_window_handle, c, window, value_mask, value_list) 932 } 933 func (l *xcb_library) xcb_get_property_reply(c *C.xcb_connection_t, _delete C.uint8_t, window C.xcb_window_t, property C.xcb_atom_t, type_ C.xcb_atom_t, long_offset C.uint32_t, long_length C.uint32_t) *C.xcb_get_property_reply_t { 934 return C.gamen_xcb_get_property_reply(l.xcb_get_property_unchecked_handle, l.xcb_get_property_reply_handle, c, _delete, window, property, type_, long_offset, long_length) 935 } 936 func (l *xcb_library) xcb_get_property_value(R *C.xcb_get_property_reply_t) unsafe.Pointer { 937 return C.gamen_xcb_get_property_value(l.xcb_get_property_value_handle, R) 938 } 939 func (l *xcb_library) xcb_get_property_value_length(R *C.xcb_get_property_reply_t) C.int { 940 return C.gamen_xcb_get_property_value_length(l.xcb_get_property_value_length_handle, R) 941 } 942 func (l *xcb_library) xcb_send_event(c *C.xcb_connection_t, propagate C.uint8_t, destination C.xcb_window_t, event_mask C.uint32_t, event *C.char) C.xcb_void_cookie_t { 943 return C.gamen_xcb_send_event(l.xcb_send_event_handle, c, propagate, destination, event_mask, event) 944 } 945 func (l *xcb_library) xcb_change_window_attributes(c *C.xcb_connection_t, window C.xcb_window_t, value_mask C.uint32_t, value_list unsafe.Pointer) C.xcb_void_cookie_t { 946 return C.gamen_xcb_change_window_attributes(l.xcb_change_window_attributes_handle, c, window, value_mask, value_list) 947 } 948 func (l *xcb_library) xcb_translate_coordinates_reply(c *C.xcb_connection_t, src_window C.xcb_window_t, dst_window C.xcb_window_t, src_x C.int16_t, src_y C.int16_t) *C.xcb_translate_coordinates_reply_t { 949 return C.gamen_xcb_translate_coordinates_reply(l.xcb_translate_coordinates_unchecked_handle, l.xcb_translate_coordinates_reply_handle, c, src_window, dst_window, src_x, src_y) 950 } 951 func (l *xcb_library) xcb_ungrab_pointer(c *C.xcb_connection_t, time C.xcb_timestamp_t) C.xcb_void_cookie_t { 952 return C.gamen_xcb_ungrab_pointer(l.xcb_ungrab_pointer_handle, c, time) 953 } 954 func (l *xcb_library) xcb_free_pixmap(c *C.xcb_connection_t, pixmap C.xcb_pixmap_t) C.xcb_void_cookie_t { 955 return C.gamen_xcb_free_pixmap(l.xcb_free_pixmap_handle, c, pixmap) 956 } 957 func (l *xcb_library) xcb_create_cursor(c *C.xcb_connection_t, cid C.xcb_cursor_t, source C.xcb_pixmap_t, mask C.xcb_pixmap_t, fore_red C.uint16_t, fore_green C.uint16_t, fore_blue C.uint16_t, back_red C.uint16_t, back_green C.uint16_t, back_blue C.uint16_t, x C.uint16_t, y C.uint16_t) C.xcb_void_cookie_t { 958 return C.gamen_xcb_create_cursor(l.xcb_create_cursor_handle, c, cid, source, mask, fore_red, fore_green, fore_blue, back_red, back_green, back_blue, x, y) 959 } 960 func (l *xcb_library) xcb_free_cursor(c *C.xcb_connection_t, cursor C.xcb_cursor_t) C.xcb_void_cookie_t { 961 return C.gamen_xcb_free_cursor(l.xcb_free_cursor_handle, c, cursor) 962 } 963 964 // libxcb-randr 965 func (l *xcb_library) xcb_randr_query_version_reply(c *C.xcb_connection_t, major_version C.uint32_t, minor_version C.uint32_t) *C.xcb_randr_query_version_reply_t { 966 return C.gamen_xcb_randr_query_version_reply(l.xcb_randr_query_version_unchecked_handle, l.xcb_randr_query_version_reply_handle, c, major_version, minor_version) 967 } 968 func (l *xcb_library) xcb_randr_select_input(c *C.xcb_connection_t, window C.xcb_window_t, enable C.uint16_t) C.xcb_void_cookie_t { 969 return C.gamen_xcb_randr_select_input(l.xcb_randr_select_input_handle, c, window, enable) 970 } 971 972 // libxcb-xinput 973 func (l *xcb_library) xcb_input_xi_query_version_reply(c *C.xcb_connection_t, major_version C.uint16_t, minor_version C.uint16_t) *C.xcb_input_xi_query_version_reply_t { 974 return C.gamen_xcb_input_xi_query_version_reply(l.xcb_input_xi_query_version_unchecked_handle, l.xcb_input_xi_query_version_reply_handle, c, major_version, minor_version) 975 } 976 func (l *xcb_library) xcb_input_xi_query_device_reply(c *C.xcb_connection_t, deviceid C.xcb_input_device_id_t) *C.xcb_input_xi_query_device_reply_t { 977 return C.gamen_xcb_input_xi_query_device_reply(l.xcb_input_xi_query_device_unchecked_handle, l.xcb_input_xi_query_device_reply_handle, c, deviceid) 978 } 979 func (l *xcb_library) xcb_input_xi_query_device_infos_iterator(R *C.xcb_input_xi_query_device_reply_t) C.xcb_input_xi_device_info_iterator_t { 980 return C.gamen_xcb_input_xi_query_device_infos_iterator(l.xcb_input_xi_query_device_infos_iterator_handle, R) 981 } 982 func (l *xcb_library) xcb_input_xi_device_info_next(i *C.xcb_input_xi_device_info_iterator_t) { 983 C.gamen_xcb_input_xi_device_info_next(l.xcb_input_xi_device_info_next_handle, i) 984 } 985 func (l *xcb_library) xcb_input_xi_device_info_classes_iterator(R *C.xcb_input_xi_device_info_t) C.xcb_input_device_class_iterator_t { 986 return C.gamen_xcb_input_xi_device_info_classes_iterator(l.xcb_input_xi_device_info_classes_iterator_handle, R) 987 } 988 func (l *xcb_library) xcb_input_device_class_next(i *C.xcb_input_device_class_iterator_t) { 989 C.gamen_xcb_input_device_class_next(l.xcb_input_device_class_next_handle, i) 990 } 991 func (l *xcb_library) xcb_input_xi_select_events(c *C.xcb_connection_t, window C.xcb_window_t, num_mask C.uint16_t, masks *C.xcb_input_event_mask_t) C.xcb_void_cookie_t { 992 return C.gamen_xcb_input_xi_select_events(l.xcb_input_xi_select_events_handle, c, window, num_mask, masks) 993 } 994 func (l *xcb_library) xcb_input_button_press_valuator_mask_length(R *C.xcb_input_button_press_event_t) C.int { 995 return C.gamen_xcb_input_button_press_valuator_mask_length(l.xcb_input_button_press_valuator_mask_length_handle, R) 996 } 997 func (l *xcb_library) xcb_input_button_press_valuator_mask(R *C.xcb_input_button_press_event_t) *C.uint32_t { 998 return C.gamen_xcb_input_button_press_valuator_mask(l.xcb_input_button_press_valuator_mask_handle, R) 999 } 1000 func (l *xcb_library) xcb_input_button_press_axisvalues(R *C.xcb_input_button_press_event_t) *C.xcb_input_fp3232_t { 1001 return C.gamen_xcb_input_button_press_axisvalues(l.xcb_input_button_press_axisvalues_handle, R) 1002 } 1003 func (l *xcb_library) xcb_input_button_press_axisvalues_length(R *C.xcb_input_button_press_event_t) C.int { 1004 return C.gamen_xcb_input_button_press_axisvalues_length(l.xcb_input_button_press_axisvalues_length_handle, R) 1005 } 1006 1007 // libxcb-icccm 1008 func (l *xcb_library) xcb_icccm_get_wm_normal_hints_reply(c *C.xcb_connection_t, window C.xcb_window_t, hints *C.xcb_size_hints_t) C.uint8_t { 1009 return C.gamen_xcb_icccm_get_wm_normal_hints_reply(l.xcb_icccm_get_wm_normal_hints_unchecked_handle, l.xcb_icccm_get_wm_normal_hints_reply_handle, c, window, hints) 1010 } 1011 func (l *xcb_library) xcb_icccm_size_hints_set_min_size(hints *C.xcb_size_hints_t, min_width C.int32_t, min_height C.int32_t) { 1012 C.gamen_xcb_icccm_size_hints_set_min_size(l.xcb_icccm_size_hints_set_min_size_handle, hints, min_width, min_height) 1013 } 1014 func (l *xcb_library) xcb_icccm_size_hints_set_max_size(hints *C.xcb_size_hints_t, max_width C.int32_t, max_height C.int32_t) { 1015 C.gamen_xcb_icccm_size_hints_set_max_size(l.xcb_icccm_size_hints_set_max_size_handle, hints, max_width, max_height) 1016 } 1017 func (l *xcb_library) xcb_icccm_set_wm_normal_hints(c *C.xcb_connection_t, window C.xcb_window_t, hints *C.xcb_size_hints_t) C.xcb_void_cookie_t { 1018 return C.gamen_xcb_icccm_set_wm_normal_hints(l.xcb_icccm_set_wm_normal_hints_handle, c, window, hints) 1019 } 1020 func (l *xcb_library) xcb_icccm_get_wm_hints_reply(c *C.xcb_connection_t, window C.xcb_window_t, hints *C.xcb_icccm_wm_hints_t) C.uint8_t { 1021 return C.gamen_xcb_icccm_get_wm_hints_reply(l.xcb_icccm_get_wm_hints_unchecked_handle, l.xcb_icccm_get_wm_hints_reply_handle, c, window, hints) 1022 } 1023 func (l *xcb_library) xcb_icccm_wm_hints_set_iconic(hints *C.xcb_icccm_wm_hints_t) { 1024 C.gamen_xcb_icccm_wm_hints_set_iconic(l.xcb_icccm_wm_hints_set_iconic_handle, hints) 1025 } 1026 func (l *xcb_library) xcb_icccm_set_wm_hints(c *C.xcb_connection_t, window C.xcb_window_t, hints *C.xcb_icccm_wm_hints_t) C.xcb_void_cookie_t { 1027 return C.gamen_xcb_icccm_set_wm_hints(l.xcb_icccm_set_wm_hints_handle, c, window, hints) 1028 } 1029 1030 // libxcb-image 1031 func (l *xcb_library) xcb_create_pixmap_from_bitmap_data(display *C.xcb_connection_t, d C.xcb_drawable_t, data *C.uint8_t, width C.uint32_t, height C.uint32_t, depth C.uint32_t, fg C.uint32_t, bg C.uint32_t, gcp *C.xcb_gcontext_t) C.xcb_pixmap_t { 1032 return C.gamen_xcb_create_pixmap_from_bitmap_data(l.xcb_create_pixmap_from_bitmap_data_handle, display, d, data, width, height, depth, fg, bg, gcp) 1033 } 1034 1035 // libxcb-xkb 1036 func (l *xcb_library) xcb_xkb_use_extension_reply(c *C.xcb_connection_t, wantedMajor C.uint16_t, wantedMinor C.uint16_t) *C.xcb_xkb_use_extension_reply_t { 1037 return C.gamen_xcb_xkb_use_extension_reply(l.xcb_xkb_use_extension_unchecked_handle, l.xcb_xkb_use_extension_reply_handle, c, wantedMajor, wantedMinor) 1038 }