LCOV - code coverage report
Current view: top level - xenolith/platform/linux - XLPlatformLinuxXcb.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 322 365 88.2 %
Date: 2024-05-12 00:16:13 Functions: 14 14 100.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2023-2024 Stappler LLC <admin@stappler.dev>
       3             : 
       4             :  Permission is hereby granted, free of charge, to any person obtaining a copy
       5             :  of this software and associated documentation files (the "Software"), to deal
       6             :  in the Software without restriction, including without limitation the rights
       7             :  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
       8             :  copies of the Software, and to permit persons to whom the Software is
       9             :  furnished to do so, subject to the following conditions:
      10             : 
      11             :  The above copyright notice and this permission notice shall be included in
      12             :  all copies or substantial portions of the Software.
      13             : 
      14             :  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      15             :  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      16             :  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
      17             :  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      18             :  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      19             :  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      20             :  THE SOFTWARE.
      21             :  **/
      22             : 
      23             : #include "XLPlatformLinuxXcb.h"
      24             : 
      25             : #if XL_LINK
      26             : extern "C" {
      27             : xcb_connection_t * xcb_connect(const char *displayname, int *screenp);
      28             : const struct xcb_setup_t * xcb_get_setup(xcb_connection_t *c);
      29             : xcb_screen_iterator_t xcb_setup_roots_iterator(const xcb_setup_t *R);
      30             : void xcb_screen_next(xcb_screen_iterator_t *i);
      31             : 
      32             : int xcb_connection_has_error(xcb_connection_t *c);
      33             : int xcb_get_file_descriptor(xcb_connection_t *c);
      34             : uint32_t xcb_generate_id(xcb_connection_t *c);
      35             : int xcb_flush(xcb_connection_t *c);
      36             : void xcb_disconnect(xcb_connection_t *c);
      37             : xcb_generic_event_t * xcb_poll_for_event(xcb_connection_t *c);
      38             : 
      39             : const struct xcb_query_extension_reply_t *xcb_get_extension_data(xcb_connection_t *c, xcb_extension_t *ext);
      40             : 
      41             : xcb_void_cookie_t xcb_map_window(xcb_connection_t *c, xcb_window_t window);
      42             : 
      43             : xcb_void_cookie_t xcb_create_window(xcb_connection_t *c, uint8_t depth, xcb_window_t wid,
      44             :         xcb_window_t parent, int16_t x, int16_t y, uint16_t width, uint16_t height, uint16_t border_width,
      45             :         uint16_t _class, xcb_visualid_t visual, uint32_t value_mask, const void *value_list);
      46             : 
      47             : xcb_void_cookie_t xcb_change_property(xcb_connection_t *c, uint8_t mode, xcb_window_t window,
      48             :                 xcb_atom_t property, xcb_atom_t type, uint8_t format, uint32_t data_len, const void *data);
      49             : 
      50             : xcb_intern_atom_cookie_t xcb_intern_atom(xcb_connection_t *c, uint8_t only_if_exists,
      51             :                 uint16_t name_len,const char *name);
      52             : 
      53             : xcb_intern_atom_reply_t * xcb_intern_atom_reply(xcb_connection_t *c, xcb_intern_atom_cookie_t cookie,
      54             :                 xcb_generic_error_t **e);
      55             : 
      56             : void * xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
      57             : 
      58             : xcb_get_modifier_mapping_cookie_t xcb_get_modifier_mapping_unchecked(xcb_connection_t *c);
      59             : xcb_get_modifier_mapping_reply_t * xcb_get_modifier_mapping_reply(xcb_connection_t *c,
      60             :                 xcb_get_modifier_mapping_cookie_t cookie, xcb_generic_error_t **e);
      61             : xcb_keycode_t * xcb_get_modifier_mapping_keycodes(const xcb_get_modifier_mapping_reply_t *);
      62             : 
      63             : xcb_get_keyboard_mapping_cookie_t xcb_get_keyboard_mapping (xcb_connection_t *c,
      64             :                 xcb_keycode_t first_keycode, uint8_t count);
      65             : xcb_get_keyboard_mapping_reply_t * xcb_get_keyboard_mapping_reply(xcb_connection_t *c,
      66             :                 xcb_get_keyboard_mapping_cookie_t cookie /**< */, xcb_generic_error_t **e);
      67             : 
      68             : extern xcb_extension_t xcb_randr_id;
      69             : 
      70             : xcb_randr_query_version_cookie_t xcb_randr_query_version(xcb_connection_t *c,
      71             :                 uint32_t major_version, uint32_t minor_version);
      72             : xcb_randr_query_version_reply_t * xcb_randr_query_version_reply(xcb_connection_t *c,
      73             :                 xcb_randr_query_version_cookie_t cookie, xcb_generic_error_t **e);
      74             : xcb_randr_get_screen_info_cookie_t xcb_randr_get_screen_info_unchecked(xcb_connection_t *c,
      75             :                 xcb_window_t window);
      76             : xcb_randr_get_screen_info_reply_t * xcb_randr_get_screen_info_reply(xcb_connection_t *c,
      77             :                 xcb_randr_get_screen_info_cookie_t cookie, xcb_generic_error_t **e);
      78             : 
      79             : xcb_randr_screen_size_t * xcb_randr_get_screen_info_sizes(const xcb_randr_get_screen_info_reply_t *);
      80             : int xcb_randr_get_screen_info_sizes_length(const xcb_randr_get_screen_info_reply_t *);
      81             : xcb_randr_screen_size_iterator_t xcb_randr_get_screen_info_sizes_iterator(const xcb_randr_get_screen_info_reply_t *);
      82             : 
      83             : int xcb_randr_get_screen_info_rates_length(const xcb_randr_get_screen_info_reply_t *);
      84             : xcb_randr_refresh_rates_iterator_t xcb_randr_get_screen_info_rates_iterator(const xcb_randr_get_screen_info_reply_t *);
      85             : void xcb_randr_refresh_rates_next(xcb_randr_refresh_rates_iterator_t *);
      86             : xcb_generic_iterator_t xcb_randr_refresh_rates_end(xcb_randr_refresh_rates_iterator_t);
      87             : uint16_t * xcb_randr_refresh_rates_rates(const xcb_randr_refresh_rates_t *);
      88             : int xcb_randr_refresh_rates_rates_length(const xcb_randr_refresh_rates_t *);
      89             : 
      90             : xcb_randr_get_screen_resources_cookie_t xcb_randr_get_screen_resources(
      91             :                 xcb_connection_t *c, xcb_window_t window);
      92             : xcb_randr_get_screen_resources_cookie_t xcb_randr_get_screen_resources_unchecked(
      93             :                 xcb_connection_t *c, xcb_window_t window);
      94             : xcb_randr_get_screen_resources_reply_t * xcb_randr_get_screen_resources_reply(
      95             :                 xcb_connection_t *c, xcb_randr_get_screen_resources_cookie_t cookie, xcb_generic_error_t **e);
      96             : xcb_randr_mode_info_t * xcb_randr_get_screen_resources_modes(const xcb_randr_get_screen_resources_reply_t *R);
      97             : int xcb_randr_get_screen_resources_modes_length(const xcb_randr_get_screen_resources_reply_t *R);
      98             : 
      99             : xcb_randr_get_screen_resources_current_cookie_t xcb_randr_get_screen_resources_current(
     100             :                 xcb_connection_t *c, xcb_window_t window);
     101             : xcb_randr_get_screen_resources_current_cookie_t xcb_randr_get_screen_resources_current_unchecked(
     102             :                 xcb_connection_t *c, xcb_window_t window);
     103             : xcb_randr_get_screen_resources_current_reply_t * xcb_randr_get_screen_resources_current_reply(
     104             :                 xcb_connection_t *c, xcb_randr_get_screen_resources_current_cookie_t cookie, xcb_generic_error_t **e);
     105             : xcb_randr_output_t* xcb_randr_get_screen_resources_current_outputs(const xcb_randr_get_screen_resources_current_reply_t *);
     106             : int xcb_randr_get_screen_resources_current_outputs_length(const xcb_randr_get_screen_resources_current_reply_t *);
     107             : xcb_randr_mode_info_t * xcb_randr_get_screen_resources_current_modes(
     108             :                 const xcb_randr_get_screen_resources_current_reply_t *);
     109             : int xcb_randr_get_screen_resources_current_modes_length(
     110             :                 const xcb_randr_get_screen_resources_current_reply_t *);
     111             : uint8_t* xcb_randr_get_screen_resources_current_names(const xcb_randr_get_screen_resources_current_reply_t *);
     112             : int xcb_randr_get_screen_resources_current_names_length(const xcb_randr_get_screen_resources_current_reply_t *);
     113             : xcb_randr_crtc_t* xcb_randr_get_screen_resources_current_crtcs(const xcb_randr_get_screen_resources_current_reply_t *);
     114             : int xcb_randr_get_screen_resources_current_crtcs_length(const xcb_randr_get_screen_resources_current_reply_t *);
     115             : 
     116             : xcb_randr_get_output_primary_cookie_t xcb_randr_get_output_primary(xcb_connection_t *, xcb_window_t);
     117             : xcb_randr_get_output_primary_cookie_t xcb_randr_get_output_primary_unchecked(xcb_connection_t *, xcb_window_t);
     118             : xcb_randr_get_output_primary_reply_t * xcb_randr_get_output_primary_reply(xcb_connection_t *,
     119             :                 xcb_randr_get_output_primary_cookie_t, xcb_generic_error_t **);
     120             : 
     121             : xcb_randr_get_output_info_cookie_t xcb_randr_get_output_info(xcb_connection_t *,
     122             :                 xcb_randr_output_t, xcb_timestamp_t);
     123             : xcb_randr_get_output_info_cookie_t xcb_randr_get_output_info_unchecked(xcb_connection_t *,
     124             :                 xcb_randr_output_t, xcb_timestamp_t);
     125             : xcb_randr_get_output_info_reply_t* xcb_randr_get_output_info_reply(xcb_connection_t *,
     126             :                 xcb_randr_get_output_info_cookie_t, xcb_generic_error_t **);
     127             : xcb_randr_crtc_t * xcb_randr_get_output_info_crtcs(const xcb_randr_get_output_info_reply_t *);
     128             : int xcb_randr_get_output_info_crtcs_length(const xcb_randr_get_output_info_reply_t *);
     129             : xcb_generic_iterator_t xcb_randr_get_output_info_crtcs_end(const xcb_randr_get_output_info_reply_t *);
     130             : xcb_randr_mode_t * xcb_randr_get_output_info_modes(const xcb_randr_get_output_info_reply_t *);
     131             : int xcb_randr_get_output_info_modes_length(const xcb_randr_get_output_info_reply_t *);
     132             : uint8_t * xcb_randr_get_output_info_name(const xcb_randr_get_output_info_reply_t *);
     133             : int xcb_randr_get_output_info_name_length(const xcb_randr_get_output_info_reply_t *);
     134             : 
     135             : xcb_randr_get_crtc_info_cookie_t xcb_randr_get_crtc_info(xcb_connection_t *, xcb_randr_crtc_t, xcb_timestamp_t);
     136             : xcb_randr_get_crtc_info_cookie_t xcb_randr_get_crtc_info_unchecked(xcb_connection_t *, xcb_randr_crtc_t, xcb_timestamp_t);
     137             : xcb_randr_get_crtc_info_reply_t* xcb_randr_get_crtc_info_reply(xcb_connection_t *,
     138             :                 xcb_randr_get_crtc_info_cookie_t, xcb_generic_error_t **);
     139             : xcb_randr_output_t* xcb_randr_get_crtc_info_outputs(const xcb_randr_get_crtc_info_reply_t *);
     140             : int xcb_randr_get_crtc_info_outputs_length(const xcb_randr_get_crtc_info_reply_t *);
     141             : xcb_randr_output_t* xcb_randr_get_crtc_info_possible(const xcb_randr_get_crtc_info_reply_t *);
     142             : int xcb_randr_get_crtc_info_possible_length(const xcb_randr_get_crtc_info_reply_t *);
     143             : 
     144             : xcb_key_symbols_t * xcb_key_symbols_alloc(xcb_connection_t *c);
     145             : void xcb_key_symbols_free(xcb_key_symbols_t *syms);
     146             : 
     147             : xcb_keysym_t xcb_key_symbols_get_keysym(xcb_key_symbols_t *syms, xcb_keycode_t keycode, int col);
     148             : xcb_keycode_t * xcb_key_symbols_get_keycode(xcb_key_symbols_t *syms, xcb_keysym_t keysym);
     149             : xcb_keysym_t xcb_key_press_lookup_keysym(xcb_key_symbols_t *syms, xcb_key_press_event_t *event, int col);
     150             : xcb_keysym_t xcb_key_release_lookup_keysym(xcb_key_symbols_t *syms, xcb_key_release_event_t *event, int col);
     151             : int xcb_refresh_keyboard_mapping(xcb_key_symbols_t *syms, xcb_mapping_notify_event_t *event);
     152             : 
     153             : int xcb_is_keypad_key(xcb_keysym_t keysym);
     154             : int xcb_is_private_keypad_key(xcb_keysym_t keysym);
     155             : int xcb_is_cursor_key(xcb_keysym_t keysym);
     156             : int xcb_is_pf_key(xcb_keysym_t keysym);
     157             : int xcb_is_function_key(xcb_keysym_t keysym);
     158             : int xcb_is_misc_function_key(xcb_keysym_t keysym);
     159             : int xcb_is_modifier_key(xcb_keysym_t keysym);
     160             : 
     161             : xcb_void_cookie_t xcb_xkb_select_events(xcb_connection_t *c, xcb_xkb_device_spec_t deviceSpec,
     162             :                 uint16_t affectWhich, uint16_t clear, uint16_t selectAll, uint16_t affectMap, uint16_t map, const void *details);
     163             : }
     164             : #endif
     165             : 
     166             : namespace STAPPLER_VERSIONIZED stappler::xenolith::platform {
     167             : 
     168             : static XcbLibrary *s_XcbLibrary = nullptr;
     169             : 
     170             : #ifndef XL_LINK
     171        1850 : SP_EXTERN_C void * xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e) {
     172        1850 :         return s_XcbLibrary->xcb_wait_for_reply(c, request, e);
     173             : }
     174             : #endif
     175             : 
     176         425 : XcbLibrary *XcbLibrary::getInstance() {
     177         425 :         return s_XcbLibrary;
     178             : }
     179             : 
     180          50 : XcbLibrary::~XcbLibrary() {
     181          25 :         close();
     182          50 : }
     183             : 
     184          25 : bool XcbLibrary::init() {
     185             : #ifndef XL_LINK
     186          25 :         _handle = Dso("libxcb.so");
     187          25 :         if (!_handle) {
     188           0 :                 return false;
     189             :         }
     190             : #endif
     191             : 
     192          25 :         if (open(_handle)) {
     193          25 :                 s_XcbLibrary = this;
     194          25 :                 openConnection(_pending);
     195          25 :                 return _pending.connection != nullptr;
     196             :         } else {
     197           0 :                 _handle = Dso();
     198             :         }
     199           0 :         return false;
     200             : }
     201             : 
     202          25 : bool XcbLibrary::open(Dso &handle) {
     203             : #if XL_LINK
     204             :         this->xcb_connect = &::xcb_connect;
     205             :         this->xcb_get_setup = &::xcb_get_setup;
     206             :         this->xcb_setup_roots_iterator = &::xcb_setup_roots_iterator;
     207             :         this->xcb_screen_next = &::xcb_screen_next;
     208             :         this->xcb_connection_has_error = &::xcb_connection_has_error;
     209             :         this->xcb_get_file_descriptor = &::xcb_get_file_descriptor;
     210             :         this->xcb_generate_id = &::xcb_generate_id;
     211             :         this->xcb_flush = &::xcb_flush;
     212             :         this->xcb_disconnect = &::xcb_disconnect;
     213             :         this->xcb_poll_for_event = &::xcb_poll_for_event;
     214             :         this->xcb_send_event = &::xcb_send_event;
     215             :         this->xcb_get_extension_data = &::xcb_get_extension_data;
     216             :         this->xcb_map_window = &::xcb_map_window;
     217             :         this->xcb_create_window = &::xcb_create_window;
     218             :         this->xcb_change_property = &::xcb_change_property;
     219             :         this->xcb_intern_atom = &::xcb_intern_atom;
     220             :         this->xcb_intern_atom_reply = &::xcb_intern_atom_reply;
     221             :         this->xcb_wait_for_reply = &::xcb_wait_for_reply;
     222             :         this->xcb_get_modifier_mapping_unchecked = &::xcb_get_modifier_mapping_unchecked;
     223             :         this->xcb_get_modifier_mapping_reply = &::xcb_get_modifier_mapping_reply;
     224             :         this->xcb_get_modifier_mapping_keycodes = &::xcb_get_modifier_mapping_keycodes;
     225             :         this->xcb_get_keyboard_mapping = &::xcb_get_keyboard_mapping;
     226             :         this->xcb_get_keyboard_mapping_reply = &::xcb_get_keyboard_mapping_reply;
     227             :         this->xcb_convert_selection = &::xcb_convert_selection;
     228             :         this->xcb_set_selection_owner = &::xcb_set_selection_owner;
     229             :         this->xcb_get_selection_owner = &::xcb_get_selection_owner;
     230             :         this->xcb_get_selection_owner_reply = &::xcb_get_selection_owner_reply;
     231             :         this->xcb_get_property_reply = &::xcb_get_property_reply;
     232             :         this->xcb_get_property = &::xcb_get_property;
     233             :         this->xcb_get_property_value = &::xcb_get_property_value;
     234             :         this->xcb_get_property_value_length = &::xcb_get_property_value_length;
     235             : #else
     236          25 :         this->xcb_connect = handle.sym<decltype(this->xcb_connect)>("xcb_connect");
     237          25 :         this->xcb_get_setup = handle.sym<decltype(this->xcb_get_setup)>("xcb_get_setup");
     238          25 :         this->xcb_setup_roots_iterator =
     239          25 :                         handle.sym<decltype(this->xcb_setup_roots_iterator)>("xcb_setup_roots_iterator");
     240          25 :         this->xcb_screen_next =
     241          25 :                         handle.sym<decltype(this->xcb_screen_next)>("xcb_screen_next");
     242          25 :         this->xcb_connection_has_error =
     243          25 :                         handle.sym<decltype(this->xcb_connection_has_error)>("xcb_connection_has_error");
     244          25 :         this->xcb_get_file_descriptor =
     245          25 :                         handle.sym<decltype(this->xcb_get_file_descriptor)>("xcb_get_file_descriptor");
     246          25 :         this->xcb_generate_id = handle.sym<decltype(this->xcb_generate_id)>("xcb_generate_id");
     247          25 :         this->xcb_flush = handle.sym<decltype(this->xcb_flush)>("xcb_flush");
     248          25 :         this->xcb_disconnect = handle.sym<decltype(this->xcb_disconnect)>("xcb_disconnect");
     249          25 :         this->xcb_poll_for_event = handle.sym<decltype(this->xcb_poll_for_event)>("xcb_poll_for_event");
     250          25 :         this->xcb_send_event = handle.sym<decltype(this->xcb_send_event)>("xcb_send_event");
     251          25 :         this->xcb_get_extension_data = handle.sym<decltype(this->xcb_get_extension_data)>("xcb_get_extension_data");
     252          25 :         this->xcb_map_window = handle.sym<decltype(this->xcb_map_window)>("xcb_map_window");
     253          25 :         this->xcb_create_window = handle.sym<decltype(this->xcb_create_window)>("xcb_create_window");
     254          25 :         this->xcb_change_property = handle.sym<decltype(this->xcb_change_property)>("xcb_change_property");
     255          25 :         this->xcb_intern_atom = handle.sym<decltype(this->xcb_intern_atom)>("xcb_intern_atom");
     256          25 :         this->xcb_intern_atom_reply = handle.sym<decltype(this->xcb_intern_atom_reply)>("xcb_intern_atom_reply");
     257          25 :         this->xcb_wait_for_reply = handle.sym<decltype(this->xcb_wait_for_reply)>("xcb_wait_for_reply");
     258          25 :         this->xcb_get_modifier_mapping_unchecked =
     259          25 :                         handle.sym<decltype(this->xcb_get_modifier_mapping_unchecked)>("xcb_get_modifier_mapping_unchecked");
     260          25 :         this->xcb_get_modifier_mapping_reply =
     261          25 :                         handle.sym<decltype(this->xcb_get_modifier_mapping_reply)>("xcb_get_modifier_mapping_reply");
     262          25 :         this->xcb_get_modifier_mapping_keycodes =
     263          25 :                         handle.sym<decltype(this->xcb_get_modifier_mapping_keycodes)>("xcb_get_modifier_mapping_keycodes");
     264          25 :         this->xcb_convert_selection =
     265          25 :                         handle.sym<decltype(this->xcb_convert_selection)>("xcb_convert_selection");
     266          25 :         this->xcb_set_selection_owner =
     267          25 :                         handle.sym<decltype(this->xcb_set_selection_owner)>("xcb_set_selection_owner");
     268          25 :         this->xcb_get_selection_owner =
     269          25 :                         handle.sym<decltype(this->xcb_get_selection_owner)>("xcb_get_selection_owner");
     270          25 :         this->xcb_get_selection_owner_reply =
     271          25 :                         handle.sym<decltype(this->xcb_get_selection_owner_reply)>("xcb_get_selection_owner_reply");
     272          25 :         this->xcb_get_property_value =
     273          25 :                         handle.sym<decltype(this->xcb_get_property_value)>("xcb_get_property_value");
     274          25 :         this->xcb_get_property_value_length =
     275          25 :                         handle.sym<decltype(this->xcb_get_property_value_length)>("xcb_get_property_value_length");
     276          25 :         this->xcb_get_keyboard_mapping =
     277          25 :                         handle.sym<decltype(this->xcb_get_keyboard_mapping)>("xcb_get_keyboard_mapping");
     278          25 :         this->xcb_get_keyboard_mapping_reply =
     279          25 :                         handle.sym<decltype(this->xcb_get_keyboard_mapping_reply)>("xcb_get_keyboard_mapping_reply");
     280          25 :         this->xcb_get_property_reply =
     281          25 :                         handle.sym<decltype(this->xcb_get_property_reply)>("xcb_get_property_reply");
     282          25 :         this->xcb_get_property =
     283          25 :                         handle.sym<decltype(this->xcb_get_property)>("xcb_get_property");
     284          25 :         this->xcb_get_property_value =
     285          25 :                         handle.sym<decltype(this->xcb_get_property_value)>("xcb_get_property_value");
     286          25 :         this->xcb_get_property_value_length =
     287          25 :                         handle.sym<decltype(this->xcb_get_property_value_length)>("xcb_get_property_value_length");
     288             : #endif
     289          25 :         if (this->xcb_connect
     290          25 :                         && this->xcb_get_setup
     291          25 :                         && this->xcb_setup_roots_iterator
     292          25 :                         && this->xcb_screen_next
     293          25 :                         && this->xcb_connection_has_error
     294          25 :                         && this->xcb_get_file_descriptor
     295          25 :                         && this->xcb_generate_id
     296          25 :                         && this->xcb_flush
     297          25 :                         && this->xcb_disconnect
     298          25 :                         && this->xcb_poll_for_event
     299          25 :                         && this->xcb_send_event
     300          25 :                         && this->xcb_get_extension_data
     301          25 :                         && this->xcb_map_window
     302          25 :                         && this->xcb_create_window
     303          25 :                         && this->xcb_change_property
     304          25 :                         && this->xcb_intern_atom
     305          25 :                         && this->xcb_intern_atom_reply
     306          25 :                         && this->xcb_wait_for_reply
     307          25 :                         && this->xcb_get_modifier_mapping_unchecked
     308          25 :                         && this->xcb_get_modifier_mapping_reply
     309          25 :                         && this->xcb_get_modifier_mapping_keycodes
     310          25 :                         && this->xcb_convert_selection
     311          25 :                         && this->xcb_set_selection_owner
     312          25 :                         && this->xcb_get_selection_owner
     313          25 :                         && this->xcb_get_selection_owner_reply
     314          25 :                         && this->xcb_get_keyboard_mapping
     315          25 :                         && this->xcb_get_keyboard_mapping_reply
     316          25 :                         && this->xcb_get_property_reply
     317          25 :                         && this->xcb_get_property
     318          25 :                         && this->xcb_get_property_value
     319          25 :                         && this->xcb_get_property_value_length) {
     320          25 :                 openAux();
     321          25 :                 return true;
     322             :         }
     323           0 :         return false;
     324             : }
     325             : 
     326          25 : void XcbLibrary::close() {
     327          25 :         if (_pending.connection) {
     328           0 :                 xcb_disconnect(_pending.connection);
     329             :         }
     330             : 
     331          25 :         if (s_XcbLibrary == this) {
     332          25 :                 s_XcbLibrary = nullptr;
     333             :         }
     334          25 : }
     335             : 
     336          50 : bool XcbLibrary::hasRandr() const {
     337             : #if XL_LINK
     338             :         return true;
     339             : #else
     340          50 :         return _randr ? true : false;
     341             : #endif
     342             : }
     343             : 
     344          50 : bool XcbLibrary::hasKeysyms() const {
     345             : #if XL_LINK
     346             :         return true;
     347             : #else
     348          50 :         return _keysyms ? true : false;
     349             : #endif
     350             : }
     351             : 
     352          25 : bool XcbLibrary::hasXkb() const {
     353             : #if XL_LINK
     354             :         return true;
     355             : #else
     356          25 :         return _xkb ? true : false;
     357             : #endif
     358             : }
     359             : 
     360          25 : XcbLibrary::ConnectionData XcbLibrary::acquireConnection() {
     361          25 :         if (_pending.connection) {
     362          25 :                 _current = _pending;
     363          25 :                 _pending = ConnectionData({-1, nullptr, nullptr, nullptr});
     364          25 :                 return _current;
     365             :         } else {
     366           0 :                 openConnection(_current);
     367           0 :                 return _current;
     368             :         }
     369             : }
     370             : 
     371         400 : XcbLibrary::ConnectionData XcbLibrary::getActiveConnection() const {
     372         400 :         if (_pending.connection) {
     373         400 :                 return _pending;
     374             :         } else {
     375           0 :                 return _current;
     376             :         }
     377             : }
     378             : 
     379          25 : void XcbLibrary::openAux() {
     380             : #if XL_LINK
     381             :         this->xcb_randr_id = &::xcb_randr_id;
     382             : 
     383             :         this->xcb_randr_query_version = &::xcb_randr_query_version;
     384             :         this->xcb_randr_query_version_reply = &::xcb_randr_query_version_reply;
     385             :         this->xcb_randr_get_screen_info_unchecked = &::xcb_randr_get_screen_info_unchecked;
     386             :         this->xcb_randr_get_screen_info_reply = &::xcb_randr_get_screen_info_reply;
     387             : 
     388             :         this->xcb_randr_get_screen_info_sizes = &::xcb_randr_get_screen_info_sizes;
     389             :         this->xcb_randr_get_screen_info_sizes_length = &::xcb_randr_get_screen_info_sizes_length;
     390             :         this->xcb_randr_get_screen_info_sizes_iterator = &::xcb_randr_get_screen_info_sizes_iterator;
     391             :         this->xcb_randr_get_screen_info_rates_length = &::xcb_randr_get_screen_info_rates_length;
     392             :         this->xcb_randr_get_screen_info_rates_iterator = &::xcb_randr_get_screen_info_rates_iterator;
     393             :         this->xcb_randr_refresh_rates_next = &::xcb_randr_refresh_rates_next;
     394             :         this->xcb_randr_refresh_rates_end = &::xcb_randr_refresh_rates_end;
     395             :         this->xcb_randr_refresh_rates_rates = &::xcb_randr_refresh_rates_rates;
     396             :         this->xcb_randr_refresh_rates_rates_length = &::xcb_randr_refresh_rates_rates_length;
     397             : 
     398             :         this->xcb_randr_get_screen_resources = &::xcb_randr_get_screen_resources;
     399             :         this->xcb_randr_get_screen_resources_unchecked = &::xcb_randr_get_screen_resources_unchecked;
     400             :         this->xcb_randr_get_screen_resources_reply = &::xcb_randr_get_screen_resources_reply;
     401             :         this->xcb_randr_get_screen_resources_modes = &::xcb_randr_get_screen_resources_modes;
     402             :         this->xcb_randr_get_screen_resources_modes_length = &::xcb_randr_get_screen_resources_modes_length;
     403             : 
     404             :         this->xcb_randr_get_screen_resources_current = &::xcb_randr_get_screen_resources_current;
     405             :         this->xcb_randr_get_screen_resources_current_unchecked = &::xcb_randr_get_screen_resources_current_unchecked;
     406             :         this->xcb_randr_get_screen_resources_current_reply = &::xcb_randr_get_screen_resources_current_reply;
     407             :         this->xcb_randr_get_screen_resources_current_outputs = &::xcb_randr_get_screen_resources_current_outputs;
     408             :         this->xcb_randr_get_screen_resources_current_outputs_length = &::xcb_randr_get_screen_resources_current_outputs_length;
     409             :         this->xcb_randr_get_screen_resources_current_modes = &::xcb_randr_get_screen_resources_current_modes;
     410             :         this->xcb_randr_get_screen_resources_current_modes_length = &::xcb_randr_get_screen_resources_current_modes_length;
     411             :         this->xcb_randr_get_screen_resources_current_names = &::xcb_randr_get_screen_resources_current_names;
     412             :         this->xcb_randr_get_screen_resources_current_names_length = &::xcb_randr_get_screen_resources_current_names_length;
     413             :         this->xcb_randr_get_screen_resources_current_crtcs = &::xcb_randr_get_screen_resources_current_crtcs;
     414             :         this->xcb_randr_get_screen_resources_current_crtcs_length = &::xcb_randr_get_screen_resources_current_crtcs_length;
     415             : 
     416             :         this->xcb_randr_get_output_primary = &::xcb_randr_get_output_primary;
     417             :         this->xcb_randr_get_output_primary_unchecked = &::xcb_randr_get_output_primary_unchecked;
     418             :         this->xcb_randr_get_output_primary_reply = &::xcb_randr_get_output_primary_reply;
     419             : 
     420             :         this->xcb_randr_get_output_info = &::xcb_randr_get_output_info;
     421             :         this->xcb_randr_get_output_info_unchecked = &::xcb_randr_get_output_info_unchecked;
     422             :         this->xcb_randr_get_output_info_reply = &::xcb_randr_get_output_info_reply;
     423             :         this->xcb_randr_get_output_info_crtcs = &::xcb_randr_get_output_info_crtcs;
     424             :         this->xcb_randr_get_output_info_crtcs_length = &::xcb_randr_get_output_info_crtcs_length;
     425             :         this->xcb_randr_get_output_info_crtcs_end = &::xcb_randr_get_output_info_crtcs_end;
     426             :         this->xcb_randr_get_output_info_modes = &::xcb_randr_get_output_info_modes;
     427             :         this->xcb_randr_get_output_info_modes_length = &::xcb_randr_get_output_info_modes_length;
     428             :         this->xcb_randr_get_output_info_name = &::xcb_randr_get_output_info_name;
     429             :         this->xcb_randr_get_output_info_name_length = &::xcb_randr_get_output_info_name_length;
     430             : 
     431             :         this->xcb_randr_get_crtc_info = &::xcb_randr_get_crtc_info;
     432             :         this->xcb_randr_get_crtc_info_unchecked = &::xcb_randr_get_crtc_info_unchecked;
     433             :         this->xcb_randr_get_crtc_info_reply = &::xcb_randr_get_crtc_info_reply;
     434             :         this->xcb_randr_get_crtc_info_outputs = &::xcb_randr_get_crtc_info_outputs;
     435             :         this->xcb_randr_get_crtc_info_outputs_length = &::xcb_randr_get_crtc_info_outputs_length;
     436             :         this->xcb_randr_get_crtc_info_possible = &::xcb_randr_get_crtc_info_possible;
     437             :         this->xcb_randr_get_crtc_info_possible_length = &::xcb_randr_get_crtc_info_possible_length;
     438             : 
     439             :         this->xcb_key_symbols_alloc = &::xcb_key_symbols_alloc;
     440             :         this->xcb_key_symbols_free = &::xcb_key_symbols_free;
     441             :         this->xcb_key_symbols_get_keysym = &::xcb_key_symbols_get_keysym;
     442             :         this->xcb_key_symbols_get_keycode = &::xcb_key_symbols_get_keycode;
     443             :         this->xcb_key_press_lookup_keysym = &::xcb_key_press_lookup_keysym;
     444             :         this->xcb_key_release_lookup_keysym = &::xcb_key_release_lookup_keysym;
     445             :         this->xcb_refresh_keyboard_mapping = &::xcb_refresh_keyboard_mapping;
     446             :         this->xcb_is_keypad_key = &::xcb_is_keypad_key;
     447             :         this->xcb_is_private_keypad_key = &::xcb_is_private_keypad_key;
     448             :         this->xcb_is_cursor_key = &::xcb_is_cursor_key;
     449             :         this->xcb_is_pf_key = &::xcb_is_pf_key;
     450             :         this->xcb_is_function_key = &::xcb_is_function_key;
     451             :         this->xcb_is_misc_function_key = &::xcb_is_misc_function_key;
     452             :         this->xcb_is_modifier_key = &::xcb_is_modifier_key;
     453             : 
     454             :         this->xcb_xkb_select_events = &::xcb_xkb_select_events;
     455             : #else
     456          25 :         if (auto randr = Dso("libxcb-randr.so")) {
     457          25 :                 this->xcb_randr_id =
     458          25 :                                 randr.sym<decltype(this->xcb_randr_id)>("xcb_randr_id");
     459             : 
     460          25 :                 this->xcb_randr_query_version =
     461          25 :                                 randr.sym<decltype(this->xcb_randr_query_version)>("xcb_randr_query_version");
     462          25 :                 this->xcb_randr_query_version_reply =
     463          25 :                                 randr.sym<decltype(this->xcb_randr_query_version_reply)>("xcb_randr_query_version_reply");
     464          25 :                 this->xcb_randr_get_screen_info_unchecked =
     465          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_unchecked)>("xcb_randr_get_screen_info_unchecked");
     466          25 :                 this->xcb_randr_get_screen_info_reply =
     467          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_reply)>("xcb_randr_get_screen_info_reply");
     468             : 
     469          25 :                 this->xcb_randr_get_screen_info_sizes =
     470          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_sizes)>("xcb_randr_get_screen_info_sizes");;
     471          25 :                 this->xcb_randr_get_screen_info_sizes_length =
     472          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_sizes_length)>("xcb_randr_get_screen_info_sizes_length");
     473          25 :                 this->xcb_randr_get_screen_info_sizes_iterator =
     474          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_sizes_iterator)>("xcb_randr_get_screen_info_sizes_iterator");
     475          25 :                 this->xcb_randr_get_screen_info_rates_length =
     476          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_rates_length)>("xcb_randr_get_screen_info_rates_length");
     477          25 :                 this->xcb_randr_get_screen_info_rates_iterator =
     478          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_info_rates_iterator)>("xcb_randr_get_screen_info_rates_iterator");
     479          25 :                 this->xcb_randr_refresh_rates_next =
     480          25 :                                 randr.sym<decltype(this->xcb_randr_refresh_rates_next)>("xcb_randr_refresh_rates_next");
     481          25 :                 this->xcb_randr_refresh_rates_end =
     482          25 :                                 randr.sym<decltype(this->xcb_randr_refresh_rates_end)>("xcb_randr_refresh_rates_end");
     483          25 :                 this->xcb_randr_refresh_rates_rates =
     484          25 :                                 randr.sym<decltype(this->xcb_randr_refresh_rates_rates)>("xcb_randr_refresh_rates_rates");
     485          25 :                 this->xcb_randr_refresh_rates_rates_length =
     486          25 :                                 randr.sym<decltype(this->xcb_randr_refresh_rates_rates_length)>("xcb_randr_refresh_rates_rates_length");
     487             : 
     488          25 :                 this->xcb_randr_get_screen_resources =
     489          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources)>("xcb_randr_get_screen_resources");
     490          25 :                 this->xcb_randr_get_screen_resources_unchecked =
     491          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_unchecked)>("xcb_randr_get_screen_resources_unchecked");
     492          25 :                 this->xcb_randr_get_screen_resources_reply =
     493          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_reply)>("xcb_randr_get_screen_resources_reply");
     494          25 :                 this->xcb_randr_get_screen_resources_modes =
     495          25 :                                         randr.sym<decltype(this->xcb_randr_get_screen_resources_modes)>("xcb_randr_get_screen_resources_modes");
     496          25 :                 this->xcb_randr_get_screen_resources_modes_length =
     497          25 :                                         randr.sym<decltype(this->xcb_randr_get_screen_resources_modes_length)>("xcb_randr_get_screen_resources_modes_length");
     498             : 
     499          25 :                 this->xcb_randr_get_screen_resources_current =
     500          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current)>("xcb_randr_get_screen_resources_current");
     501          25 :                 this->xcb_randr_get_screen_resources_current_unchecked =
     502          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_unchecked)>("xcb_randr_get_screen_resources_current_unchecked");
     503          25 :                 this->xcb_randr_get_screen_resources_current_reply =
     504          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_reply)>("xcb_randr_get_screen_resources_current_reply");
     505          25 :                 this->xcb_randr_get_screen_resources_current_outputs =
     506          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_outputs)>("xcb_randr_get_screen_resources_current_outputs");
     507          25 :                 this->xcb_randr_get_screen_resources_current_outputs_length =
     508          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_outputs_length)>("xcb_randr_get_screen_resources_current_outputs_length");
     509          25 :                 this->xcb_randr_get_screen_resources_current_modes =
     510          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_modes)>("xcb_randr_get_screen_resources_current_modes");
     511          25 :                 this->xcb_randr_get_screen_resources_current_modes_length =
     512          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_modes_length)>("xcb_randr_get_screen_resources_current_modes_length");
     513          25 :                 this->xcb_randr_get_screen_resources_current_names =
     514          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_names)>("xcb_randr_get_screen_resources_current_names");
     515          25 :                 this->xcb_randr_get_screen_resources_current_names_length =
     516          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_names_length)>("xcb_randr_get_screen_resources_current_names_length");
     517          25 :                 this->xcb_randr_get_screen_resources_current_crtcs =
     518          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_crtcs)>("xcb_randr_get_screen_resources_current_crtcs");
     519          25 :                 this->xcb_randr_get_screen_resources_current_crtcs_length =
     520          25 :                                 randr.sym<decltype(this->xcb_randr_get_screen_resources_current_crtcs_length)>("xcb_randr_get_screen_resources_current_crtcs_length");
     521             : 
     522          25 :                 this->xcb_randr_get_output_primary =
     523          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_primary)>("xcb_randr_get_output_primary");
     524          25 :                 this->xcb_randr_get_output_primary_unchecked =
     525          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_primary_unchecked)>("xcb_randr_get_output_primary_unchecked");
     526          25 :                 this->xcb_randr_get_output_primary_reply =
     527          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_primary_reply)>("xcb_randr_get_output_primary_reply");
     528             : 
     529          25 :                 this->xcb_randr_get_output_info =
     530          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info)>("xcb_randr_get_output_info");
     531          25 :                 this->xcb_randr_get_output_info_unchecked =
     532          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_unchecked)>("xcb_randr_get_output_info_unchecked");
     533          25 :                 this->xcb_randr_get_output_info_reply =
     534          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_reply)>("xcb_randr_get_output_info_reply");
     535          25 :                 this->xcb_randr_get_output_info_crtcs =
     536          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_crtcs)>("xcb_randr_get_output_info_crtcs");
     537          25 :                 this->xcb_randr_get_output_info_crtcs_length =
     538          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_crtcs_length)>("xcb_randr_get_output_info_crtcs_length");
     539          25 :                 this->xcb_randr_get_output_info_crtcs_end =
     540          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_crtcs_end)>("xcb_randr_get_output_info_crtcs_end");
     541          25 :                 this->xcb_randr_get_output_info_modes =
     542          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_modes)>("xcb_randr_get_output_info_modes");
     543          25 :                 this->xcb_randr_get_output_info_modes_length =
     544          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_modes_length)>("xcb_randr_get_output_info_modes_length");
     545          25 :                 this->xcb_randr_get_output_info_name =
     546          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_name)>("xcb_randr_get_output_info_name");
     547          25 :                 this->xcb_randr_get_output_info_name_length =
     548          25 :                                 randr.sym<decltype(this->xcb_randr_get_output_info_name_length)>("xcb_randr_get_output_info_name_length");
     549             : 
     550          25 :                 this->xcb_randr_get_crtc_info =
     551          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info)>("xcb_randr_get_crtc_info");
     552          25 :                 this->xcb_randr_get_crtc_info_unchecked =
     553          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_unchecked)>("xcb_randr_get_crtc_info_unchecked");
     554          25 :                 this->xcb_randr_get_crtc_info_reply =
     555          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_reply)>("xcb_randr_get_crtc_info_reply");
     556          25 :                 this->xcb_randr_get_crtc_info_outputs =
     557          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_outputs)>("xcb_randr_get_crtc_info_outputs");
     558          25 :                 this->xcb_randr_get_crtc_info_outputs_length =
     559          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_outputs_length)>("xcb_randr_get_crtc_info_outputs_length");
     560          25 :                 this->xcb_randr_get_crtc_info_possible =
     561          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_possible)>("xcb_randr_get_crtc_info_possible");
     562          25 :                 this->xcb_randr_get_crtc_info_possible_length =
     563          25 :                                 randr.sym<decltype(this->xcb_randr_get_crtc_info_possible_length)>("xcb_randr_get_crtc_info_possible_length");
     564             : 
     565          25 :                 if (this->xcb_randr_id
     566          25 :                                 &&this->xcb_randr_query_version
     567          25 :                                 && this->xcb_randr_query_version_reply
     568          25 :                                 && this->xcb_randr_get_screen_info_unchecked
     569          25 :                                 && this->xcb_randr_get_screen_info_reply
     570          25 :                                 && this->xcb_randr_get_screen_info_sizes
     571          25 :                                 && this->xcb_randr_get_screen_info_sizes_length
     572          25 :                                 && this->xcb_randr_get_screen_info_sizes_iterator
     573          25 :                                 && this->xcb_randr_get_screen_info_rates_length
     574          25 :                                 && this->xcb_randr_get_screen_info_rates_iterator
     575          25 :                                 && this->xcb_randr_refresh_rates_next
     576          25 :                                 && this->xcb_randr_refresh_rates_end
     577          25 :                                 && this->xcb_randr_refresh_rates_rates
     578          25 :                                 && this->xcb_randr_refresh_rates_rates_length
     579          25 :                                 && this->xcb_randr_get_screen_resources
     580          25 :                                 && this->xcb_randr_get_screen_resources_unchecked
     581          25 :                                 && this->xcb_randr_get_screen_resources_reply
     582          25 :                                 && this->xcb_randr_get_screen_resources_modes
     583          25 :                                 && this->xcb_randr_get_screen_resources_modes_length
     584          25 :                                 && this->xcb_randr_get_screen_resources_current
     585          25 :                                 && this->xcb_randr_get_screen_resources_current_unchecked
     586          25 :                                 && this->xcb_randr_get_screen_resources_current_reply
     587          25 :                                 && this->xcb_randr_get_screen_resources_current_outputs
     588          25 :                                 && this->xcb_randr_get_screen_resources_current_outputs_length
     589          25 :                                 && this->xcb_randr_get_screen_resources_current_modes
     590          25 :                                 && this->xcb_randr_get_screen_resources_current_modes_length
     591          25 :                                 && this->xcb_randr_get_screen_resources_current_names
     592          25 :                                 && this->xcb_randr_get_screen_resources_current_names_length
     593          25 :                                 && this->xcb_randr_get_screen_resources_current_crtcs
     594          25 :                                 && this->xcb_randr_get_screen_resources_current_crtcs_length
     595          25 :                                 && this->xcb_randr_get_output_primary
     596          25 :                                 && this->xcb_randr_get_output_primary_unchecked
     597          25 :                                 && this->xcb_randr_get_output_primary_reply
     598          25 :                                 && this->xcb_randr_get_output_info
     599          25 :                                 && this->xcb_randr_get_output_info_unchecked
     600          25 :                                 && this->xcb_randr_get_output_info_reply
     601          25 :                                 && this->xcb_randr_get_output_info_crtcs
     602          25 :                                 && this->xcb_randr_get_output_info_crtcs_length
     603          25 :                                 && this->xcb_randr_get_output_info_crtcs_end
     604          25 :                                 && this->xcb_randr_get_output_info_modes
     605          25 :                                 && this->xcb_randr_get_output_info_modes_length
     606          25 :                                 && this->xcb_randr_get_output_info_name
     607          25 :                                 && this->xcb_randr_get_output_info_name_length
     608          25 :                                 && this->xcb_randr_get_crtc_info
     609          25 :                                 && this->xcb_randr_get_crtc_info_unchecked
     610          25 :                                 && this->xcb_randr_get_crtc_info_reply
     611          25 :                                 && this->xcb_randr_get_crtc_info_outputs
     612          25 :                                 && this->xcb_randr_get_crtc_info_outputs_length
     613          25 :                                 && this->xcb_randr_get_crtc_info_possible
     614          25 :                                 && this->xcb_randr_get_crtc_info_possible_length) {
     615          25 :                         _randr = move(randr);
     616             :                 } else {
     617           0 :                         this->xcb_randr_query_version = nullptr;
     618           0 :                         this->xcb_randr_query_version_reply = nullptr;
     619           0 :                         this->xcb_randr_get_screen_info_unchecked = nullptr;
     620           0 :                         this->xcb_randr_get_screen_info_reply = nullptr;
     621           0 :                         this->xcb_randr_get_screen_info_sizes = nullptr;
     622           0 :                         this->xcb_randr_get_screen_info_sizes_length = nullptr;
     623           0 :                         this->xcb_randr_get_screen_info_sizes_iterator = nullptr;
     624           0 :                         this->xcb_randr_get_screen_info_rates_length = nullptr;
     625           0 :                         this->xcb_randr_get_screen_info_rates_iterator = nullptr;
     626           0 :                         this->xcb_randr_refresh_rates_next = nullptr;
     627           0 :                         this->xcb_randr_refresh_rates_rates = nullptr;
     628           0 :                         this->xcb_randr_refresh_rates_rates_length = nullptr;
     629           0 :                         this->xcb_randr_get_screen_resources = nullptr;
     630           0 :                         this->xcb_randr_get_screen_resources_unchecked = nullptr;
     631           0 :                         this->xcb_randr_get_screen_resources_reply = nullptr;
     632           0 :                         this->xcb_randr_get_screen_resources_modes = nullptr;
     633           0 :                         this->xcb_randr_get_screen_resources_modes_length = nullptr;
     634           0 :                         this->xcb_randr_get_screen_resources_current = nullptr;
     635           0 :                         this->xcb_randr_get_screen_resources_current_unchecked = nullptr;
     636           0 :                         this->xcb_randr_get_screen_resources_current_reply = nullptr;
     637             :                 }
     638          25 :         }
     639             : 
     640          25 :         if (auto keysyms = Dso("libxcb-keysyms.so")) {
     641          25 :                 this->xcb_key_symbols_alloc = keysyms.sym<decltype(xcb_key_symbols_alloc)>("xcb_key_symbols_alloc");
     642          25 :                 this->xcb_key_symbols_free = keysyms.sym<decltype(xcb_key_symbols_free)>("xcb_key_symbols_free");
     643          25 :                 this->xcb_key_symbols_get_keysym = keysyms.sym<decltype(xcb_key_symbols_get_keysym)>("xcb_key_symbols_get_keysym");
     644          25 :                 this->xcb_key_symbols_get_keycode = keysyms.sym<decltype(xcb_key_symbols_get_keycode)>("xcb_key_symbols_get_keycode");
     645          25 :                 this->xcb_key_press_lookup_keysym = keysyms.sym<decltype(xcb_key_press_lookup_keysym)>("xcb_key_press_lookup_keysym");
     646          25 :                 this->xcb_key_release_lookup_keysym = keysyms.sym<decltype(xcb_key_release_lookup_keysym)>("xcb_key_release_lookup_keysym");
     647          25 :                 this->xcb_refresh_keyboard_mapping = keysyms.sym<decltype(xcb_refresh_keyboard_mapping)>("xcb_refresh_keyboard_mapping");
     648          25 :                 this->xcb_is_keypad_key = keysyms.sym<decltype(xcb_is_keypad_key)>("xcb_is_keypad_key");
     649          25 :                 this->xcb_is_private_keypad_key = keysyms.sym<decltype(xcb_is_private_keypad_key)>("xcb_is_private_keypad_key");
     650          25 :                 this->xcb_is_cursor_key = keysyms.sym<decltype(xcb_is_cursor_key)>("xcb_is_cursor_key");
     651          25 :                 this->xcb_is_pf_key = keysyms.sym<decltype(xcb_is_pf_key)>("xcb_is_pf_key");
     652          25 :                 this->xcb_is_function_key = keysyms.sym<decltype(xcb_is_function_key)>("xcb_is_function_key");
     653          25 :                 this->xcb_is_misc_function_key = keysyms.sym<decltype(xcb_is_misc_function_key)>("xcb_is_misc_function_key");
     654          25 :                 this->xcb_is_modifier_key = keysyms.sym<decltype(xcb_is_modifier_key)>("xcb_is_modifier_key");
     655             : 
     656          25 :                 if (this->xcb_key_symbols_alloc
     657          25 :                                 && this->xcb_key_symbols_free
     658          25 :                                 && this->xcb_key_symbols_get_keysym
     659          25 :                                 && this->xcb_key_symbols_get_keycode
     660          25 :                                 && this->xcb_key_press_lookup_keysym
     661          25 :                                 && this->xcb_key_release_lookup_keysym
     662          25 :                                 && this->xcb_refresh_keyboard_mapping
     663          25 :                                 && this->xcb_is_keypad_key
     664          25 :                                 && this->xcb_is_private_keypad_key
     665          25 :                                 && this->xcb_is_cursor_key
     666          25 :                                 && this->xcb_is_pf_key
     667          25 :                                 && this->xcb_is_function_key
     668          25 :                                 && this->xcb_is_misc_function_key
     669          25 :                                 && this->xcb_is_modifier_key) {
     670          25 :                         _keysyms = move(keysyms);
     671             :                 } else {
     672           0 :                         this->xcb_key_symbols_alloc = nullptr;
     673           0 :                         this->xcb_key_symbols_free = nullptr;
     674           0 :                         this->xcb_key_symbols_get_keysym = nullptr;
     675           0 :                         this->xcb_key_symbols_get_keycode = nullptr;
     676           0 :                         this->xcb_key_press_lookup_keysym = nullptr;
     677           0 :                         this->xcb_key_release_lookup_keysym = nullptr;
     678           0 :                         this->xcb_refresh_keyboard_mapping = nullptr;
     679           0 :                         this->xcb_is_keypad_key = nullptr;
     680           0 :                         this->xcb_is_private_keypad_key = nullptr;
     681           0 :                         this->xcb_is_cursor_key = nullptr;
     682           0 :                         this->xcb_is_pf_key = nullptr;
     683           0 :                         this->xcb_is_function_key = nullptr;
     684           0 :                         this->xcb_is_misc_function_key = nullptr;
     685           0 :                         this->xcb_is_modifier_key = nullptr;
     686             :                 }
     687          25 :         }
     688             : 
     689          25 :         if (auto xkb = Dso("libxcb-xkb.so")) {
     690          25 :                 this->xcb_xkb_select_events = xkb.sym<decltype(xcb_xkb_select_events)>("xcb_xkb_select_events");
     691             : 
     692          25 :                 if (this->xcb_xkb_select_events) {
     693          25 :                         _xkb = move(xkb);
     694             :                 } else {
     695           0 :                         this->xcb_xkb_select_events = nullptr;
     696             :                 }
     697          25 :         }
     698             : #endif
     699          25 : }
     700             : 
     701          25 : void XcbLibrary::openConnection(ConnectionData &data) {
     702          25 :         data.setup = nullptr;
     703          25 :         data.screen = nullptr;
     704          25 :         data.connection = this->xcb_connect(NULL, &data.screen_nbr); // always not null
     705          25 :         int screen_nbr = data.screen_nbr;
     706          25 :         data.setup = this->xcb_get_setup(data.connection);
     707          25 :         auto iter = this->xcb_setup_roots_iterator(data.setup);
     708          25 :         for (; iter.rem; --screen_nbr, this->xcb_screen_next(&iter)) {
     709          25 :                 if (screen_nbr == 0) {
     710          25 :                         data.screen = iter.data;
     711          25 :                         break;
     712             :                 }
     713             :         }
     714          25 : }
     715             : 
     716             : }

Generated by: LCOV version 1.14