LCOV - code coverage report
Current view: top level - xenolith/platform/linux - XLPlatformLinuxWayland.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 261 0.0 %
Date: 2024-04-26 09:30:07 Functions: 0 78 0.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_XLPLATFORMLINUXWAYLAND_H_
      24             : #define XENOLITH_PLATFORM_LINUX_XLPLATFORMLINUXWAYLAND_H_
      25             : 
      26             : #include "XLCommon.h"
      27             : #include "XLCoreInput.h"
      28             : #include "SPDso.h"
      29             : 
      30             : #if LINUX
      31             : 
      32             : #include "linux/thirdparty/wayland-protocols/xdg-shell-client-protocol.h"
      33             : #include "linux/thirdparty/wayland-protocols/viewporter-client-protocol.h"
      34             : 
      35             : #include <wayland-client.h>
      36             : #include <wayland-cursor.h>
      37             : 
      38             : #include "XLPlatformLinuxXkb.h"
      39             : 
      40             : #define XL_WAYLAND_DEBUG 0
      41             : 
      42             : namespace STAPPLER_VERSIONIZED stappler::xenolith::platform {
      43             : 
      44             : class WaylandViewInterface;
      45             : 
      46             : struct WaylandShm;
      47             : struct WaylandSeat;
      48             : struct WaylandOutput;
      49             : struct WaylandDecoration;
      50             : 
      51             : struct XdgInterface;
      52             : struct ViewporterInterface;
      53             : 
      54             : class WaylandLibrary : public Ref {
      55             : public:
      56             :         struct ConnectionData {
      57             :                 struct wl_display *display = nullptr;
      58             :         };
      59             : 
      60             :         static WaylandLibrary *getInstance();
      61             : 
      62             :         static bool ownsProxy(wl_proxy *);
      63             :         static bool ownsProxy(wl_output *);
      64             :         static bool ownsProxy(wl_surface *);
      65             : 
      66             :         virtual ~WaylandLibrary();
      67             :         WaylandLibrary();
      68             : 
      69             :         bool init();
      70             :         void close();
      71             : 
      72             :         const struct wl_interface *wl_registry_interface = nullptr;
      73             :         const struct wl_interface *wl_compositor_interface = nullptr;
      74             :         const struct wl_interface *wl_output_interface = nullptr;
      75             :         const struct wl_interface *wl_seat_interface = nullptr;
      76             :         const struct wl_interface *wl_surface_interface = nullptr;
      77             :         const struct wl_interface *wl_region_interface = nullptr;
      78             :         const struct wl_interface *wl_callback_interface = nullptr;
      79             :         const struct wl_interface *wl_pointer_interface = nullptr;
      80             :         const struct wl_interface *wl_keyboard_interface = nullptr;
      81             :         const struct wl_interface *wl_touch_interface = nullptr;
      82             :         const struct wl_interface *wl_shm_interface = nullptr;
      83             :         const struct wl_interface *wl_subcompositor_interface = nullptr;
      84             :         const struct wl_interface *wl_subsurface_interface = nullptr;
      85             :         const struct wl_interface *wl_shm_pool_interface = nullptr;
      86             :         const struct wl_interface *wl_buffer_interface = nullptr;
      87             : 
      88             :         const struct wl_interface *wp_viewporter_interface = nullptr;
      89             :         const struct wl_interface *wp_viewport_interface = nullptr;
      90             : 
      91             :         const struct wl_interface *xdg_wm_base_interface = nullptr;
      92             :         const struct wl_interface *xdg_positioner_interface = nullptr;
      93             :         const struct wl_interface *xdg_surface_interface = nullptr;
      94             :         const struct wl_interface *xdg_toplevel_interface = nullptr;
      95             :         const struct wl_interface *xdg_popup_interface = nullptr;
      96             : 
      97             :         struct wl_display * (* wl_display_connect) (const char *name) = nullptr;
      98             :         int (* wl_display_get_fd) (struct wl_display *display) = nullptr;
      99             :         int (* wl_display_dispatch) (struct wl_display *display) = nullptr;
     100             :         int (* wl_display_dispatch_pending) (struct wl_display *display) = nullptr;
     101             :         int (* wl_display_prepare_read) (struct wl_display *display) = nullptr;
     102             :         int (* wl_display_flush) (struct wl_display *display) = nullptr;
     103             :         int (* wl_display_read_events) (struct wl_display *display) = nullptr;
     104             :         void (* wl_display_disconnect) (struct wl_display *display) = nullptr;
     105             : 
     106             :         struct wl_proxy* (* wl_proxy_marshal_flags) (struct wl_proxy *proxy, uint32_t opcode,
     107             :                         const struct wl_interface *interface, uint32_t version, uint32_t flags, ...) = nullptr;
     108             :         uint32_t (* wl_proxy_get_version) (struct wl_proxy *proxy) = nullptr;
     109             :         int (* wl_proxy_add_listener) (struct wl_proxy *proxy, void (**implementation)(void), void *data) = nullptr;
     110             :         void (* wl_proxy_set_user_data) (struct wl_proxy *proxy, void *user_data) = nullptr;
     111             :         void *(* wl_proxy_get_user_data) (struct wl_proxy *proxy) = nullptr;
     112             :         void (* wl_proxy_set_tag) (struct wl_proxy *proxy, const char * const *tag) = nullptr;
     113             :         const char * const *(* wl_proxy_get_tag) (struct wl_proxy *proxy) = nullptr;
     114             :         void (* wl_proxy_destroy) (struct wl_proxy *proxy) = nullptr;
     115             :         int (* wl_display_roundtrip) (struct wl_display *display) = nullptr;
     116             : 
     117             :         ViewporterInterface *viewporter = nullptr;
     118             :         XdgInterface *xdg = nullptr;
     119             : 
     120           0 :         struct wl_registry *wl_display_get_registry(struct wl_display *wl_display) {
     121             :                 struct wl_proxy *registry;
     122             : 
     123           0 :                 registry = wl_proxy_marshal_flags((struct wl_proxy*) wl_display, WL_DISPLAY_GET_REGISTRY,
     124           0 :                                 wl_registry_interface, wl_proxy_get_version((struct wl_proxy*) wl_display), 0, NULL);
     125             : 
     126           0 :                 return (struct wl_registry*) registry;
     127             :         }
     128             : 
     129           0 :         void* wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version) {
     130             :                 struct wl_proxy *id;
     131             : 
     132           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_registry, WL_REGISTRY_BIND, interface, version,
     133           0 :                                 0, name, interface->name, version, NULL);
     134             : 
     135           0 :                 return (void*) id;
     136             :         }
     137             : 
     138           0 :         int wl_registry_add_listener(struct wl_registry *wl_registry, const struct wl_registry_listener *listener, void *data) {
     139           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_registry, (void (**)(void)) listener, data);
     140             :         }
     141             : 
     142           0 :         void wl_registry_destroy(struct wl_registry *wl_registry) {
     143           0 :                 wl_proxy_destroy((struct wl_proxy*) wl_registry);
     144           0 :         }
     145             : 
     146           0 :         struct wl_shm_pool* wl_shm_create_pool(struct wl_shm *wl_shm, int32_t fd, int32_t size) {
     147             :                 struct wl_proxy *id;
     148             : 
     149           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_shm, WL_SHM_CREATE_POOL, wl_shm_pool_interface,
     150           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_shm), 0, NULL, fd, size);
     151             : 
     152           0 :                 return (struct wl_shm_pool*) id;
     153             :         }
     154             : 
     155           0 :         int wl_shm_add_listener(struct wl_shm *wl_shm, const struct wl_shm_listener *listener, void *data) {
     156           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_shm, (void (**)(void)) listener, data);
     157             :         }
     158             : 
     159           0 :         void wl_shm_set_user_data(struct wl_shm *wl_shm, void *user_data) {
     160           0 :                 wl_proxy_set_user_data((struct wl_proxy*) wl_shm, user_data);
     161           0 :         }
     162             : 
     163             :         void* wl_shm_get_user_data(struct wl_shm *wl_shm) {
     164             :                 return wl_proxy_get_user_data((struct wl_proxy*) wl_shm);
     165             :         }
     166             : 
     167           0 :         void wl_shm_destroy(struct wl_shm *wl_shm) {
     168           0 :                 wl_proxy_destroy((struct wl_proxy*) wl_shm);
     169           0 :         }
     170             : 
     171           0 :         void wl_shm_pool_destroy(struct wl_shm_pool *wl_shm_pool) {
     172           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_shm_pool, WL_SHM_POOL_DESTROY, NULL,
     173           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_shm_pool), WL_MARSHAL_FLAG_DESTROY);
     174           0 :         }
     175             : 
     176           0 :         struct wl_buffer* wl_shm_pool_create_buffer(struct wl_shm_pool *wl_shm_pool, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format) {
     177             :                 struct wl_proxy *id;
     178             : 
     179           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_shm_pool, WL_SHM_POOL_CREATE_BUFFER, wl_buffer_interface,
     180           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_shm_pool), 0, NULL, offset, width, height, stride, format);
     181             : 
     182           0 :                 return (struct wl_buffer*) id;
     183             :         }
     184             : 
     185           0 :         void wl_buffer_destroy(struct wl_buffer *wl_buffer) {
     186           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_buffer, WL_BUFFER_DESTROY, NULL,
     187           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_buffer), WL_MARSHAL_FLAG_DESTROY);
     188           0 :         }
     189             : 
     190           0 :         struct wl_surface *wl_compositor_create_surface(struct wl_compositor *wl_compositor) {
     191             :                 struct wl_proxy *id;
     192             : 
     193           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_compositor, WL_COMPOSITOR_CREATE_SURFACE, wl_surface_interface,
     194           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_compositor), 0, NULL);
     195             : 
     196           0 :                 return (struct wl_surface*) id;
     197             :         }
     198             : 
     199           0 :         struct wl_region* wl_compositor_create_region(struct wl_compositor *wl_compositor) {
     200             :                 struct wl_proxy *id;
     201             : 
     202           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_compositor, WL_COMPOSITOR_CREATE_REGION,
     203           0 :                                 wl_region_interface, wl_proxy_get_version((struct wl_proxy*) wl_compositor), 0, NULL);
     204             : 
     205           0 :                 return (struct wl_region*) id;
     206             :         }
     207             : 
     208           0 :         void wl_compositor_destroy(struct wl_compositor *wl_compositor) {
     209           0 :                 wl_proxy_destroy((struct wl_proxy *) wl_compositor);
     210           0 :         }
     211             : 
     212           0 :         void wl_region_add(struct wl_region *wl_region, int32_t x, int32_t y, int32_t width, int32_t height) {
     213           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_region, WL_REGION_ADD, NULL,
     214           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_region), 0, x, y, width, height);
     215           0 :         }
     216             : 
     217           0 :         void wl_region_destroy(struct wl_region *wl_region) {
     218           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_region, WL_REGION_DESTROY, NULL,
     219           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_region), WL_MARSHAL_FLAG_DESTROY);
     220           0 :         }
     221             : 
     222           0 :         int wl_surface_add_listener(struct wl_surface *wl_surface, const struct wl_surface_listener *listener, void *data) {
     223           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_surface, (void (**)(void)) listener, data);
     224             :         }
     225             : 
     226           0 :         void wl_surface_attach(struct wl_surface *wl_surface, struct wl_buffer *buffer, int32_t x, int32_t y) {
     227           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_ATTACH, NULL,
     228           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, buffer, x, y);
     229           0 :         }
     230             : 
     231           0 :         void wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale) {
     232           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_SET_BUFFER_SCALE, NULL,
     233           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, scale);
     234           0 :         }
     235             : 
     236           0 :         void wl_surface_commit(struct wl_surface *wl_surface) {
     237           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_COMMIT, NULL,
     238           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0);
     239           0 :         }
     240             : 
     241             :         void wl_surface_damage(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height) {
     242             :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_DAMAGE, NULL,
     243             :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, x, y, width, height);
     244             :         }
     245             : 
     246           0 :         void wl_surface_damage_buffer(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height) {
     247           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_DAMAGE_BUFFER, NULL,
     248           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, x, y, width, height);
     249           0 :         }
     250             : 
     251           0 :         void wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region) {
     252           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_SET_OPAQUE_REGION, NULL,
     253           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, region);
     254           0 :         }
     255             : 
     256           0 :         void wl_surface_set_user_data(struct wl_surface *wl_surface, void *user_data) {
     257           0 :                 wl_proxy_set_user_data((struct wl_proxy*) wl_surface, user_data);
     258           0 :         }
     259             : 
     260           0 :         void* wl_surface_get_user_data(struct wl_surface *wl_surface) {
     261           0 :                 return wl_proxy_get_user_data((struct wl_proxy*) wl_surface);
     262             :         }
     263             : 
     264           0 :         void wl_surface_destroy(struct wl_surface *wl_surface) {
     265           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_DESTROY, NULL,
     266           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), WL_MARSHAL_FLAG_DESTROY);
     267           0 :         }
     268             : 
     269           0 :         struct wl_subsurface* wl_subcompositor_get_subsurface(struct wl_subcompositor *wl_subcompositor, struct wl_surface *surface, struct wl_surface *parent) {
     270             :                 struct wl_proxy *id;
     271             : 
     272           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_subcompositor, WL_SUBCOMPOSITOR_GET_SUBSURFACE, wl_subsurface_interface,
     273           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subcompositor), 0, NULL, surface, parent);
     274             : 
     275           0 :                 return (struct wl_subsurface*) id;
     276             :         }
     277             : 
     278           0 :         void wl_subcompositor_destroy(struct wl_subcompositor *wl_subcompositor) {
     279           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subcompositor, WL_SUBCOMPOSITOR_DESTROY, NULL,
     280           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subcompositor), WL_MARSHAL_FLAG_DESTROY);
     281           0 :         }
     282             : 
     283           0 :         void wl_subsurface_set_position(struct wl_subsurface *wl_subsurface, int32_t x, int32_t y) {
     284           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_SET_POSITION, NULL,
     285           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), 0, x, y);
     286           0 :         }
     287             : 
     288             :         void wl_subsurface_place_above(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling) {
     289             :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_PLACE_ABOVE, NULL,
     290             :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), 0, sibling);
     291             :         }
     292             : 
     293           0 :         void wl_subsurface_place_below(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling) {
     294           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_PLACE_BELOW, NULL,
     295           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), 0, sibling);
     296           0 :         }
     297             : 
     298           0 :         void wl_subsurface_set_sync(struct wl_subsurface *wl_subsurface) {
     299           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_SET_SYNC, NULL,
     300           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), 0);
     301           0 :         }
     302             : 
     303             :         void wl_subsurface_set_desync(struct wl_subsurface *wl_subsurface) {
     304             :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_SET_DESYNC, NULL,
     305             :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), 0);
     306             :         }
     307             : 
     308           0 :         void wl_subsurface_destroy(struct wl_subsurface *wl_subsurface) {
     309           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_subsurface, WL_SUBSURFACE_DESTROY, NULL,
     310           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_subsurface), WL_MARSHAL_FLAG_DESTROY);
     311           0 :         }
     312             : 
     313           0 :         int wl_callback_add_listener(struct wl_callback *wl_callback, const struct wl_callback_listener *listener, void *data) {
     314           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_callback, (void (**)(void)) listener, data);
     315             :         }
     316             : 
     317           0 :         void wl_callback_destroy(struct wl_callback *wl_callback) {
     318           0 :                 wl_proxy_destroy((struct wl_proxy*) wl_callback);
     319           0 :         }
     320             : 
     321           0 :         int wl_output_add_listener(struct wl_output *wl_output, const struct wl_output_listener *listener, void *data) {
     322           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_output, (void (**)(void)) listener, data);
     323             :         }
     324             : 
     325           0 :         struct wl_callback* wl_surface_frame(struct wl_surface *wl_surface) {
     326             :                 struct wl_proxy *callback;
     327             : 
     328           0 :                 callback = wl_proxy_marshal_flags((struct wl_proxy*) wl_surface, WL_SURFACE_FRAME, wl_callback_interface,
     329           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_surface), 0, NULL);
     330             : 
     331           0 :                 return (struct wl_callback*) callback;
     332             :         }
     333             : 
     334           0 :         void wl_output_set_user_data(struct wl_output *wl_output, void *user_data) {
     335           0 :                 wl_proxy_set_user_data((struct wl_proxy*) wl_output, user_data);
     336           0 :         }
     337             : 
     338           0 :         void* wl_output_get_user_data(struct wl_output *wl_output) {
     339           0 :                 return wl_proxy_get_user_data((struct wl_proxy*) wl_output);
     340             :         }
     341             : 
     342           0 :         void wl_output_destroy(struct wl_output *wl_output) {
     343           0 :                 wl_proxy_destroy((struct wl_proxy*) wl_output);
     344           0 :         }
     345             : 
     346           0 :         int wl_seat_add_listener(struct wl_seat *wl_seat, const struct wl_seat_listener *listener, void *data) {
     347           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_seat, (void (**)(void)) listener, data);
     348             :         }
     349             : 
     350           0 :         void wl_seat_set_user_data(struct wl_seat *wl_seat, void *user_data) {
     351           0 :                 wl_proxy_set_user_data((struct wl_proxy*) wl_seat, user_data);
     352           0 :         }
     353             : 
     354             :         void* wl_seat_get_user_data(struct wl_seat *wl_seat) {
     355             :                 return wl_proxy_get_user_data((struct wl_proxy*) wl_seat);
     356             :         }
     357             : 
     358           0 :         struct wl_pointer *wl_seat_get_pointer(struct wl_seat *wl_seat) {
     359             :                 struct wl_proxy *id;
     360             : 
     361           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_seat, WL_SEAT_GET_POINTER, wl_pointer_interface,
     362           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_seat), 0, NULL);
     363             : 
     364           0 :                 return (struct wl_pointer*) id;
     365             :         }
     366             : 
     367           0 :         struct wl_keyboard *wl_seat_get_keyboard(struct wl_seat *wl_seat) {
     368             :                 struct wl_proxy *id;
     369             : 
     370           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_seat, WL_SEAT_GET_KEYBOARD, wl_keyboard_interface,
     371           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_seat), 0, NULL);
     372             : 
     373           0 :                 return (struct wl_keyboard*) id;
     374             :         }
     375             : 
     376           0 :         struct wl_touch *wl_seat_get_touch(struct wl_seat *wl_seat) {
     377             :                 struct wl_proxy *id;
     378             : 
     379           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wl_seat, WL_SEAT_GET_TOUCH, wl_touch_interface,
     380           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_seat), 0, NULL);
     381             : 
     382           0 :                 return (struct wl_touch*) id;
     383             :         }
     384             : 
     385           0 :         void wl_seat_destroy(struct wl_seat *wl_seat) {
     386           0 :                 wl_proxy_destroy((struct wl_proxy*) wl_seat);
     387           0 :         }
     388             : 
     389           0 :         int wl_pointer_add_listener(struct wl_pointer *wl_pointer, const struct wl_pointer_listener *listener, void *data) {
     390           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_pointer, (void (**)(void)) listener, data);
     391             :         }
     392             : 
     393           0 :         void wl_pointer_set_cursor(struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, int32_t hotspot_x, int32_t hotspot_y) {
     394           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_pointer, WL_POINTER_SET_CURSOR, NULL,
     395           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_pointer), 0, serial, surface, hotspot_x, hotspot_y);
     396           0 :         }
     397             : 
     398           0 :         void wl_pointer_release(struct wl_pointer *wl_pointer) {
     399           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_pointer, WL_POINTER_RELEASE, NULL,
     400           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_pointer), WL_MARSHAL_FLAG_DESTROY);
     401           0 :         }
     402             : 
     403           0 :         int wl_keyboard_add_listener(struct wl_keyboard *wl_keyboard, const struct wl_keyboard_listener *listener, void *data) {
     404           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_keyboard, (void (**)(void)) listener, data);
     405             :         }
     406             : 
     407           0 :         void wl_keyboard_release(struct wl_keyboard *wl_keyboard) {
     408           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_keyboard, WL_KEYBOARD_RELEASE, NULL,
     409           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_keyboard), WL_MARSHAL_FLAG_DESTROY);
     410           0 :         }
     411             : 
     412           0 :         int wl_touch_add_listener(struct wl_touch *wl_touch, const struct wl_touch_listener *listener, void *data) {
     413           0 :                 return wl_proxy_add_listener((struct wl_proxy*) wl_touch, (void (**)(void)) listener, data);
     414             :         }
     415             : 
     416           0 :         void wl_touch_release(struct wl_touch *wl_touch) {
     417           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wl_touch, WL_TOUCH_RELEASE, NULL,
     418           0 :                                 wl_proxy_get_version((struct wl_proxy*) wl_touch), WL_MARSHAL_FLAG_DESTROY);
     419           0 :         }
     420             : 
     421           0 :         struct wp_viewport* wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface) {
     422             :                 struct wl_proxy *id;
     423             : 
     424           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) wp_viewporter, WP_VIEWPORTER_GET_VIEWPORT, wp_viewport_interface,
     425           0 :                                 wl_proxy_get_version((struct wl_proxy*) wp_viewporter), 0, NULL, surface);
     426             : 
     427           0 :                 return (struct wp_viewport*) id;
     428             :         }
     429             : 
     430           0 :         void wp_viewporter_destroy(struct wp_viewporter *wp_viewporter) {
     431           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wp_viewporter, WP_VIEWPORTER_DESTROY, NULL,
     432           0 :                                 wl_proxy_get_version((struct wl_proxy*) wp_viewporter), WL_MARSHAL_FLAG_DESTROY);
     433           0 :         }
     434             : 
     435             :         void wp_viewport_set_source(struct wp_viewport *wp_viewport, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) {
     436             :                 wl_proxy_marshal_flags((struct wl_proxy*) wp_viewport, WP_VIEWPORT_SET_SOURCE, NULL,
     437             :                                 wl_proxy_get_version((struct wl_proxy*) wp_viewport), 0, x, y, width, height);
     438             :         }
     439             : 
     440           0 :         void wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height) {
     441           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wp_viewport, WP_VIEWPORT_SET_DESTINATION, NULL,
     442           0 :                                 wl_proxy_get_version((struct wl_proxy*) wp_viewport), 0, width, height);
     443           0 :         }
     444             : 
     445           0 :         void wp_viewport_destroy(struct wp_viewport *wp_viewport) {
     446           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) wp_viewport, WP_VIEWPORT_DESTROY, NULL,
     447           0 :                                 wl_proxy_get_version((struct wl_proxy*) wp_viewport), WL_MARSHAL_FLAG_DESTROY);
     448           0 :         }
     449             : 
     450           0 :         int xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base, const struct xdg_wm_base_listener *listener, void *data) {
     451           0 :                 return wl_proxy_add_listener((struct wl_proxy*) xdg_wm_base, (void (**)(void)) listener, data);
     452             :         }
     453             : 
     454           0 :         void xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial) {
     455           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_wm_base, XDG_WM_BASE_PONG, NULL,
     456           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_wm_base), 0, serial);
     457           0 :         }
     458             : 
     459           0 :         void xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial) {
     460           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_surface, XDG_SURFACE_ACK_CONFIGURE, NULL,
     461           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_surface), 0, serial);
     462           0 :         }
     463             : 
     464           0 :         struct xdg_surface* xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface) {
     465             :                 struct wl_proxy *id;
     466             : 
     467           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) xdg_wm_base,
     468           0 :                 XDG_WM_BASE_GET_XDG_SURFACE, xdg_surface_interface, wl_proxy_get_version((struct wl_proxy*) xdg_wm_base), 0, NULL, surface);
     469             : 
     470           0 :                 return (struct xdg_surface*) id;
     471             :         }
     472             : 
     473           0 :         int xdg_surface_add_listener(struct xdg_surface *xdg_surface, const struct xdg_surface_listener *listener, void *data) {
     474           0 :                 return wl_proxy_add_listener((struct wl_proxy*) xdg_surface, (void (**)(void)) listener, data);
     475             :         }
     476             : 
     477           0 :         struct xdg_toplevel* xdg_surface_get_toplevel(struct xdg_surface *xdg_surface) {
     478             :                 struct wl_proxy *id;
     479             : 
     480           0 :                 id = wl_proxy_marshal_flags((struct wl_proxy*) xdg_surface, XDG_SURFACE_GET_TOPLEVEL,
     481           0 :                                 xdg_toplevel_interface, wl_proxy_get_version((struct wl_proxy*) xdg_surface), 0, NULL);
     482             : 
     483           0 :                 return (struct xdg_toplevel*) id;
     484             :         }
     485             : 
     486           0 :         void xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height) {
     487           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_surface,
     488           0 :                 XDG_SURFACE_SET_WINDOW_GEOMETRY, NULL, wl_proxy_get_version((struct wl_proxy*) xdg_surface), 0, x, y, width, height);
     489           0 :         }
     490             : 
     491           0 :         void xdg_surface_destroy(struct xdg_surface *xdg_surface) {
     492           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_surface, XDG_SURFACE_DESTROY, NULL,
     493           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_surface), WL_MARSHAL_FLAG_DESTROY);
     494           0 :         }
     495             : 
     496           0 :         void xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title) {
     497           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_TITLE, NULL,
     498           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, title);
     499           0 :         }
     500             : 
     501           0 :         void xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id) {
     502           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_APP_ID, NULL,
     503           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, app_id);
     504           0 :         }
     505             : 
     506           0 :         int xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel, const struct xdg_toplevel_listener *listener, void *data) {
     507           0 :                 return wl_proxy_add_listener((struct wl_proxy*) xdg_toplevel, (void (**)(void)) listener, data);
     508             :         }
     509             : 
     510           0 :         void xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial) {
     511           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_MOVE, NULL,
     512           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, seat, serial);
     513           0 :         }
     514             : 
     515           0 :         void xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges) {
     516           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_RESIZE, NULL,
     517           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, seat, serial, edges);
     518           0 :         }
     519             : 
     520             :         void xdg_toplevel_set_max_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) {
     521             :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_MAX_SIZE, NULL,
     522             :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, width, height);
     523             :         }
     524             : 
     525           0 :         void xdg_toplevel_set_min_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) {
     526           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_MIN_SIZE, NULL,
     527           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, width, height);
     528           0 :         }
     529             : 
     530           0 :         void xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel) {
     531           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_MAXIMIZED, NULL,
     532           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0);
     533           0 :         }
     534             : 
     535           0 :         void xdg_toplevel_unset_maximized(struct xdg_toplevel *xdg_toplevel) {
     536           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_UNSET_MAXIMIZED, NULL,
     537           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0);
     538           0 :         }
     539             : 
     540             :         void xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output) {
     541             :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_FULLSCREEN, NULL,
     542             :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0, output);
     543             :         }
     544             : 
     545             :         void xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel) {
     546             :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_UNSET_FULLSCREEN, NULL,
     547             :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0);
     548             :         }
     549             : 
     550           0 :         void xdg_toplevel_set_minimized(struct xdg_toplevel *xdg_toplevel) {
     551           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_SET_MINIMIZED, NULL,
     552           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), 0);
     553           0 :         }
     554             : 
     555           0 :         void xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel) {
     556           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_toplevel, XDG_TOPLEVEL_DESTROY, NULL,
     557           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_toplevel), WL_MARSHAL_FLAG_DESTROY);
     558           0 :         }
     559             : 
     560           0 :         void xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base) {
     561           0 :                 wl_proxy_marshal_flags((struct wl_proxy*) xdg_wm_base, XDG_WM_BASE_DESTROY, NULL,
     562           0 :                                 wl_proxy_get_version((struct wl_proxy*) xdg_wm_base), WL_MARSHAL_FLAG_DESTROY);
     563           0 :         }
     564             : 
     565             :         wl_cursor_theme * (* wl_cursor_theme_load) (const char *name, int size, struct wl_shm *shm) = nullptr;
     566             :         void (* wl_cursor_theme_destroy) (wl_cursor_theme *theme) = nullptr;
     567             :         wl_cursor * (* wl_cursor_theme_get_cursor) (wl_cursor_theme *theme, const char *name) = nullptr;
     568             :         wl_buffer * (* wl_cursor_image_get_buffer) (wl_cursor_image *image) = nullptr;
     569             : 
     570             :         ConnectionData acquireConnection();
     571             :         ConnectionData getActiveConnection() const;
     572             : 
     573             :         bool hasWaylandCursor() const { return _cursor ? true : false; }
     574             : 
     575             : protected:
     576             :         bool open(Dso &);
     577             :         bool openWaylandCursor(Dso &);
     578             : 
     579             :         void openConnection(ConnectionData &data);
     580             : 
     581             :         Dso _handle;
     582             :         Dso _cursor;
     583             : 
     584             :         ConnectionData _pending;
     585             :         ConnectionData _current;
     586             : };
     587             : 
     588             : struct WaylandDisplay : Ref {
     589             :         virtual ~WaylandDisplay();
     590             : 
     591             :         bool init(const Rc<WaylandLibrary> &);
     592             : 
     593             :         wl_surface *createSurface(WaylandViewInterface *);
     594             :         void destroySurface(wl_surface *);
     595             : 
     596             :         wl_surface *createDecorationSurface(WaylandDecoration *);
     597             :         void destroyDecorationSurface(wl_surface *);
     598             : 
     599             :         bool ownsSurface(wl_surface *) const;
     600             :         bool isDecoration(wl_surface *) const;
     601             : 
     602             :         bool flush();
     603             : 
     604             :         int getSocketFd() const;
     605             : 
     606             :         Rc<WaylandLibrary> wayland;
     607             :         wl_display *display = nullptr;
     608             : 
     609             :         Rc<WaylandShm> shm;
     610             :         Rc<WaylandSeat> seat;
     611             :         Rc<XkbLibrary> xkb;
     612             :         Vector<Rc<WaylandOutput>> outputs;
     613             :         wl_compositor *compositor = nullptr;
     614             :         wl_subcompositor *subcompositor = nullptr;
     615             :         wp_viewporter *viewporter = nullptr;
     616             :         xdg_wm_base *xdgWmBase = nullptr;
     617             :         Set<wl_surface *> surfaces;
     618             :         Set<wl_surface *> decorations;
     619             :         bool seatDirty = false;
     620             : };
     621             : 
     622             : enum class WaylandCursorImage {
     623             :         LeftPtr,
     624             :         EResize,
     625             :         NEResize,
     626             :         NResize,
     627             :         NWResize,
     628             :         SEResize,
     629             :         SResize,
     630             :         SWResize,
     631             :         WResize,
     632             : 
     633             :         RightSide = EResize,
     634             :         TopRigntCorner = NEResize,
     635             :         TopSide = NResize,
     636             :         TopLeftCorner = NWResize,
     637             :         BottomRightCorner = SEResize,
     638             :         BottomSide = SResize,
     639             :         BottomLeftCorner = SWResize,
     640             :         LeftSide = WResize,
     641             : 
     642             :         Max
     643             : };
     644             : 
     645             : enum class WaylandDecorationName {
     646             :         RightSide,
     647             :         TopRigntCorner,
     648             :         TopSide,
     649             :         TopLeftCorner,
     650             :         BottomRightCorner,
     651             :         BottomSide,
     652             :         BottomLeftCorner,
     653             :         LeftSide,
     654             :         HeaderLeft,
     655             :         HeaderRight,
     656             :         HeaderCenter,
     657             :         HeaderBottom,
     658             :         IconClose,
     659             :         IconMaximize,
     660             :         IconMinimize,
     661             :         IconRestore
     662             : };
     663             : 
     664             : struct WaylandCursorTheme : public Ref {
     665             :         ~WaylandCursorTheme();
     666             : 
     667             :         bool init(WaylandDisplay *, StringView name, int size);
     668             : 
     669             :         void setCursor(WaylandSeat *);
     670             :         void setCursor(wl_pointer *, wl_surface *, uint32_t serial, WaylandCursorImage img, int scale);
     671             : 
     672             :         Rc<WaylandLibrary> wayland;
     673             :         wl_cursor_theme *cursorTheme = nullptr;
     674             :         int cursorSize = 24;
     675             :         String cursorName;
     676             :         Vector<wl_cursor *> cursors;
     677             : };
     678             : 
     679             : struct WaylandBuffer : Ref {
     680             :         virtual ~WaylandBuffer();
     681             : 
     682             :         bool init(WaylandLibrary *lib, wl_shm_pool *wl_shm_pool, int32_t offset,
     683             :                         int32_t width, int32_t height, int32_t stride, uint32_t format);
     684             : 
     685             :         Rc<WaylandLibrary> wayland;
     686             :         wl_buffer *buffer = nullptr;
     687             :         uint32_t width = 0;
     688             :         uint32_t height = 0;
     689             : };
     690             : 
     691             : struct WaylandShm : Ref {
     692             :         enum Format {
     693             :                 ARGB = WL_SHM_FORMAT_ARGB8888,
     694             :                 xRGB = WL_SHM_FORMAT_XRGB8888
     695             :         };
     696             : 
     697             :         struct ShadowBuffers {
     698             :                 Rc<WaylandBuffer> top;
     699             :                 Rc<WaylandBuffer> left;
     700             :                 Rc<WaylandBuffer> bottom;
     701             :                 Rc<WaylandBuffer> right;
     702             :                 Rc<WaylandBuffer> topLeft;
     703             :                 Rc<WaylandBuffer> topRight;
     704             :                 Rc<WaylandBuffer> bottomLeft;
     705             :                 Rc<WaylandBuffer> bottomRight;
     706             : 
     707             :                 Rc<WaylandBuffer> topActive;
     708             :                 Rc<WaylandBuffer> leftActive;
     709             :                 Rc<WaylandBuffer> bottomActive;
     710             :                 Rc<WaylandBuffer> rightActive;
     711             :                 Rc<WaylandBuffer> topLeftActive;
     712             :                 Rc<WaylandBuffer> topRightActive;
     713             :                 Rc<WaylandBuffer> bottomLeftActive;
     714             :                 Rc<WaylandBuffer> bottomRightActive;
     715             : 
     716             :                 Rc<WaylandBuffer> headerLeft;
     717             :                 Rc<WaylandBuffer> headerLeftActive;
     718             :                 Rc<WaylandBuffer> headerRight;
     719             :                 Rc<WaylandBuffer> headerRightActive;
     720             :                 Rc<WaylandBuffer> headerCenter;
     721             :                 Rc<WaylandBuffer> headerCenterActive;
     722             : 
     723             :                 Rc<WaylandBuffer> iconClose;
     724             :                 Rc<WaylandBuffer> iconMaximize;
     725             :                 Rc<WaylandBuffer> iconMinimize;
     726             :                 Rc<WaylandBuffer> iconRestore;
     727             : 
     728             :                 Rc<WaylandBuffer> iconCloseActive;
     729             :                 Rc<WaylandBuffer> iconMaximizeActive;
     730             :                 Rc<WaylandBuffer> iconMinimizeActive;
     731             :                 Rc<WaylandBuffer> iconRestoreActive;
     732             :         };
     733             : 
     734             :         virtual ~WaylandShm();
     735             : 
     736             :         bool init(const Rc<WaylandLibrary> &, wl_registry *, uint32_t name, uint32_t version);
     737             : 
     738             :         bool allocateDecorations(ShadowBuffers *ret, uint32_t width, uint32_t inset,
     739             :                         const Color3B &header, const Color3B &headerActive);
     740             : 
     741             :         Rc<WaylandLibrary> wayland;
     742             :         uint32_t id;
     743             :         wl_shm *shm;
     744             :         uint32_t format;
     745             : };
     746             : 
     747             : struct WaylandOutput : Ref {
     748             :         struct Geometry {
     749             :                 int32_t x;
     750             :                 int32_t y;
     751             :                 int32_t physical_width;
     752             :                 int32_t physical_height;
     753             :                 int32_t subpixel;
     754             :                 int32_t transform;
     755             :                 String make;
     756             :                 String model;
     757             :         };
     758             : 
     759             :         struct Mode {
     760             :                 uint32_t flags;
     761             :                 int32_t width;
     762             :                 int32_t height;
     763             :                 int32_t refresh;
     764             :         };
     765             : 
     766             :         virtual ~WaylandOutput();
     767             : 
     768             :         bool init(const Rc<WaylandLibrary> &, wl_registry *, uint32_t name, uint32_t version);
     769             : 
     770             :         String description() const;
     771             : 
     772             :         Rc<WaylandLibrary> wayland;
     773             :         uint32_t id;
     774             :         wl_output *output;
     775             :         Geometry geometry;
     776             :         Mode mode;
     777             :         int32_t scale;
     778             : 
     779             :         String name;
     780             :         String desc;
     781             : };
     782             : 
     783             : struct WaylandSeat : Ref {
     784             :         struct KeyState {
     785             :                 xkb_mod_index_t controlIndex = 0;
     786             :                 xkb_mod_index_t altIndex = 0;
     787             :                 xkb_mod_index_t shiftIndex = 0;
     788             :                 xkb_mod_index_t superIndex = 0;
     789             :                 xkb_mod_index_t capsLockIndex = 0;
     790             :                 xkb_mod_index_t numLockIndex = 0;
     791             : 
     792             :                 int32_t keyRepeatRate = 0;
     793             :                 int32_t keyRepeatDelay = 0;
     794             :                 int32_t keyRepeatInterval = 0;
     795             :                 uint32_t modsDepressed = 0;
     796             :                 uint32_t modsLatched = 0;
     797             :                 uint32_t modsLocked = 0;
     798             : 
     799             :                 core::InputKeyCode keycodes[256] = { core::InputKeyCode::Unknown };
     800             :         };
     801             : 
     802             :         virtual ~WaylandSeat();
     803             : 
     804             :         bool init(const Rc<WaylandLibrary> &, WaylandDisplay *, wl_registry *, uint32_t name, uint32_t version);
     805             :         void initCursors();
     806             :         void tryUpdateCursor();
     807             : 
     808             :         void update();
     809             : 
     810             :         core::InputKeyCode translateKey(uint32_t scancode) const;
     811             :         xkb_keysym_t composeSymbol(xkb_keysym_t sym, core::InputKeyComposeState &compose) const;
     812             : 
     813             :         Rc<WaylandLibrary> wayland;
     814             :         WaylandDisplay *root;
     815             :         uint32_t id;
     816             :         bool hasPointerFrames = false;
     817             :         wl_seat *seat;
     818             :         String name;
     819             :         uint32_t capabilities;
     820             :         wl_pointer *pointer;
     821             :         wl_keyboard *keyboard;
     822             :         wl_touch *touch;
     823             :         int32_t pointerScale = 1;
     824             :         wl_surface *pointerFocus = nullptr;
     825             :         uint32_t serial = 0;
     826             :         wl_surface *cursorSurface = nullptr;
     827             :         xkb_state *state = nullptr;
     828             :         xkb_compose_state *compose = nullptr;
     829             :         KeyState keyState;
     830             : 
     831             :         Rc<WaylandCursorTheme> cursorTheme;
     832             :         WaylandCursorImage cursorImage = WaylandCursorImage::Max;
     833             : 
     834             :         Set<WaylandDecoration *> pointerDecorations;
     835             :         Set<WaylandOutput *> pointerOutputs;
     836             :         Set<WaylandViewInterface *> pointerViews;
     837             :         Set<WaylandViewInterface *> keyboardViews;
     838             : };
     839             : 
     840             : struct WaylandDecoration : Ref {
     841             :         virtual ~WaylandDecoration();
     842             : 
     843             :         bool init(WaylandViewInterface *, Rc<WaylandBuffer> &&buffer, Rc<WaylandBuffer> &&active, WaylandDecorationName);
     844             :         bool init(WaylandViewInterface *, Rc<WaylandBuffer> &&buffer, WaylandDecorationName);
     845             : 
     846             :         void setAltBuffers(Rc<WaylandBuffer> &&b, Rc<WaylandBuffer> &&a);
     847             :         void handlePress(uint32_t serial, uint32_t button, uint32_t state);
     848             :         void handleMotion();
     849             : 
     850             :         void onEnter();
     851             :         void onLeave();
     852             : 
     853             :         void setActive(bool);
     854             :         void setVisible(bool);
     855             :         void setAlternative(bool);
     856             :         void setGeometry(int32_t x, int32_t y, int32_t width, int32_t height);
     857             : 
     858             :         bool commit();
     859             : 
     860             :         bool isTouchable() const;
     861             : 
     862             :         WaylandLibrary *wayland = nullptr;
     863             :         WaylandDisplay *display = nullptr;;
     864             :         WaylandViewInterface *root = nullptr;
     865             :         WaylandDecorationName name = WaylandDecorationName::HeaderCenter;
     866             :         WaylandCursorImage image = WaylandCursorImage::LeftPtr;
     867             :         wl_surface *surface = nullptr;
     868             :         wl_subsurface *subsurface = nullptr;
     869             :         wp_viewport *viewport = nullptr;
     870             :         Rc<WaylandBuffer> buffer;
     871             :         Rc<WaylandBuffer> active;
     872             : 
     873             :         Rc<WaylandBuffer> altBuffer;
     874             :         Rc<WaylandBuffer> altActive;
     875             : 
     876             :         int32_t _x = 0;
     877             :         int32_t _y = 0;
     878             :         int32_t _width = 0;
     879             :         int32_t _height = 0;
     880             :         uint64_t lastTouch = 0;
     881             :         uint32_t serial = 0;
     882             : 
     883             :         bool visible = true;
     884             :         bool isActive = false;
     885             :         bool alternative = false;
     886             :         bool dirty = false;
     887             :         bool waitForMove = false;
     888             : };
     889             : 
     890             : class WaylandViewInterface {
     891             : public:
     892           0 :         virtual ~WaylandViewInterface() { }
     893             : 
     894           0 :         WaylandDisplay *getDisplay() const { return _display; }
     895           0 :         wl_surface *getSurface() const { return _surface; }
     896             : 
     897             :         virtual void handlePointerEnter(wl_fixed_t surface_x, wl_fixed_t surface_y) = 0;
     898             :         virtual void handlePointerLeave() = 0;
     899             :         virtual void handlePointerMotion(uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y) = 0;
     900             :         virtual void handlePointerButton(uint32_t serial, uint32_t time, uint32_t button, uint32_t state) = 0;
     901             :         virtual void handlePointerAxis(uint32_t time, uint32_t axis, wl_fixed_t value) = 0;
     902             :         virtual void handlePointerAxisSource(uint32_t axis_source) = 0;
     903             :         virtual void handlePointerAxisStop(uint32_t time, uint32_t axis) = 0;
     904             :         virtual void handlePointerAxisDiscrete(uint32_t axis, int32_t discrete) = 0;
     905             :         virtual void handlePointerFrame() = 0;
     906             : 
     907             :         virtual void handleKeyboardEnter(Vector<uint32_t> &&, uint32_t depressed, uint32_t latched, uint32_t locked) = 0;
     908             :         virtual void handleKeyboardLeave() = 0;
     909             :         virtual void handleKey(uint32_t time, uint32_t key, uint32_t state) = 0;
     910             :         virtual void handleKeyModifiers(uint32_t depressed, uint32_t latched, uint32_t locked) = 0;
     911             : 
     912             :         virtual void handleDecorationPress(WaylandDecoration *, uint32_t serial, bool released = false) = 0;
     913             : 
     914             : protected:
     915             :         Rc<WaylandDisplay> _display;
     916             :         wl_surface *_surface = nullptr;
     917             : };
     918             : 
     919             : }
     920             : 
     921             : #endif
     922             : 
     923             : #endif /* XENOLITH_PLATFORM_LINUX_XLPLATFORMLINUXWAYLAND_H_ */

Generated by: LCOV version 1.14