LCOV - code coverage report
Current view: top level - xenolith/platform/linux - XLPlatformLinuxXkb.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 3 100.0 %
Date: 2024-05-12 00:16:13 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /**
       2             :  Copyright (c) 2023 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             : #ifndef XENOLITH_PLATFORM_LINUX_XLPLATFORMLINUXXKB_H_
      24             : #define XENOLITH_PLATFORM_LINUX_XLPLATFORMLINUXXKB_H_
      25             : 
      26             : #include "XLCommon.h"
      27             : #include "SPDso.h"
      28             : 
      29             : #if LINUX
      30             : 
      31             : #include <xkbcommon/xkbcommon.h>
      32             : #include <xkbcommon/xkbcommon-x11.h>
      33             : #include <xkbcommon/xkbcommon-compose.h>
      34             : #include <xkbcommon/xkbcommon-names.h>
      35             : 
      36             : namespace STAPPLER_VERSIONIZED stappler::xenolith::platform {
      37             : 
      38             : class XkbLibrary : public Ref {
      39             : public:
      40             :         static XkbLibrary *getInstance();
      41             : 
      42          25 :         XkbLibrary() { }
      43             : 
      44             :         virtual ~XkbLibrary();
      45             : 
      46             :         bool init();
      47             :         void close();
      48             : 
      49          25 :         bool hasX11() const { return _x11 ? true : false; }
      50             : 
      51          50 :         struct xkb_context *getContext() const { return _context; }
      52             : 
      53             :         struct xkb_context * (* xkb_context_new) (enum xkb_context_flags flags) = nullptr;
      54             :         struct xkb_context * (* xkb_context_ref) (struct xkb_context *context) = nullptr;
      55             :         void (* xkb_context_unref)  (struct xkb_context *context) = nullptr;
      56             :         void (* xkb_keymap_unref) (struct xkb_keymap *keymap) = nullptr;
      57             :         void (* xkb_state_unref) (struct xkb_state *state) = nullptr;
      58             :         struct xkb_keymap* (*xkb_keymap_new_from_string)(struct xkb_context *context, const char *string,
      59             :                         enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags) = nullptr;
      60             :         struct xkb_state * (* xkb_state_new) (struct xkb_keymap *keymap) = nullptr;
      61             :         enum xkb_state_component (* xkb_state_update_mask) (struct xkb_state *, xkb_mod_mask_t depressed_mods,
      62             :                         xkb_mod_mask_t latched_mods, xkb_mod_mask_t locked_mods, xkb_layout_index_t depressed_layout,
      63             :                         xkb_layout_index_t latched_layout, xkb_layout_index_t locked_layout) = nullptr;
      64             :         int (* xkb_state_key_get_utf8) (struct xkb_state *state, xkb_keycode_t key, char *buffer, size_t size) = nullptr;
      65             :         uint32_t (* xkb_state_key_get_utf32) (struct xkb_state *state, xkb_keycode_t key) = nullptr;
      66             :         xkb_keysym_t (* xkb_state_key_get_one_sym) (struct xkb_state *state, xkb_keycode_t key) = nullptr;
      67             :         int (* xkb_state_mod_index_is_active) (struct xkb_state *state, xkb_mod_index_t idx, enum xkb_state_component type) = nullptr;
      68             :         int (* xkb_state_key_get_syms)(struct xkb_state *state, xkb_keycode_t key, const xkb_keysym_t **syms_out) = nullptr;
      69             :         struct xkb_keymap * (* xkb_state_get_keymap) (struct xkb_state *state) = nullptr;
      70             :         void (* xkb_keymap_key_for_each) (struct xkb_keymap *keymap, xkb_keymap_key_iter_t iter, void *data) = nullptr;
      71             :         const char * (* xkb_keymap_key_get_name) (struct xkb_keymap *keymap, xkb_keycode_t key) = nullptr;
      72             :         xkb_mod_index_t (* xkb_keymap_mod_get_index) (struct xkb_keymap *keymap, const char *name) = nullptr;
      73             :         int (* xkb_keymap_key_repeats) (struct xkb_keymap *keymap, xkb_keycode_t key) = nullptr;
      74             :         uint32_t (* xkb_keysym_to_utf32) (xkb_keysym_t keysym) = nullptr;
      75             : 
      76             :         struct xkb_compose_table * (* xkb_compose_table_new_from_locale) (struct xkb_context *context,
      77             :                         const char *locale, enum xkb_compose_compile_flags flags) = nullptr;
      78             :         void (* xkb_compose_table_unref) (struct xkb_compose_table *table) = nullptr;
      79             :         struct xkb_compose_state* (* xkb_compose_state_new)(struct xkb_compose_table *table, enum xkb_compose_state_flags flags) = nullptr;
      80             :         enum xkb_compose_feed_result (* xkb_compose_state_feed) (struct xkb_compose_state *state, xkb_keysym_t keysym) = nullptr;
      81             :         void (* xkb_compose_state_reset) (struct xkb_compose_state *state) = nullptr;
      82             :         enum xkb_compose_status (* xkb_compose_state_get_status) (struct xkb_compose_state *state) = nullptr;
      83             :         xkb_keysym_t (* xkb_compose_state_get_one_sym) (struct xkb_compose_state *state) = nullptr;
      84             :         void (* xkb_compose_state_unref) (struct xkb_compose_state *state) = nullptr;
      85             : 
      86             :         int (* xkb_x11_setup_xkb_extension) (xcb_connection_t *connection, uint16_t major_xkb_version, uint16_t minor_xkb_version,
      87             :                         enum xkb_x11_setup_xkb_extension_flags flags, uint16_t *major_xkb_version_out, uint16_t *minor_xkb_version_out,
      88             :                         uint8_t *base_event_out, uint8_t *base_error_out) = nullptr;
      89             :         int32_t (* xkb_x11_get_core_keyboard_device_id) (xcb_connection_t *connection) = nullptr;
      90             :         struct xkb_keymap * (* xkb_x11_keymap_new_from_device) (struct xkb_context *context,
      91             :                         xcb_connection_t *connection, int32_t device_id, enum xkb_keymap_compile_flags flags) = nullptr;
      92             :         struct xkb_state * (* xkb_x11_state_new_from_device) (struct xkb_keymap *keymap,
      93             :                         xcb_connection_t *connection, int32_t device_id) = nullptr;
      94             : 
      95             : protected:
      96             :         bool open(Dso &);
      97             :         void openAux();
      98             : 
      99             :         Dso _handle;
     100             :         Dso _x11;
     101             :         struct xkb_context *_context = nullptr;
     102             : };
     103             : 
     104             : }
     105             : 
     106             : #endif
     107             : 
     108             : #endif /* XENOLITH_PLATFORM_LINUX_XLPLATFORMLINUXXKB_H_ */

Generated by: LCOV version 1.14