gioui.org@v0.6.1-0.20240506124620-7a9ce51988ce/app/os_wayland.c (about) 1 // SPDX-License-Identifier: Unlicense OR MIT 2 3 //go:build ((linux && !android) || freebsd) && !nowayland 4 // +build linux,!android freebsd 5 // +build !nowayland 6 7 #include <wayland-client.h> 8 #include "wayland_xdg_shell.h" 9 #include "wayland_xdg_decoration.h" 10 #include "wayland_text_input.h" 11 #include "_cgo_export.h" 12 13 const struct wl_registry_listener gio_registry_listener = { 14 // Cast away const parameter. 15 .global = (void (*)(void *, struct wl_registry *, uint32_t, const char *, uint32_t))gio_onRegistryGlobal, 16 .global_remove = gio_onRegistryGlobalRemove 17 }; 18 19 const struct wl_surface_listener gio_surface_listener = { 20 .enter = gio_onSurfaceEnter, 21 .leave = gio_onSurfaceLeave, 22 }; 23 24 const struct xdg_surface_listener gio_xdg_surface_listener = { 25 .configure = gio_onXdgSurfaceConfigure, 26 }; 27 28 const struct xdg_toplevel_listener gio_xdg_toplevel_listener = { 29 .configure = gio_onToplevelConfigure, 30 .close = gio_onToplevelClose, 31 }; 32 33 const struct zxdg_toplevel_decoration_v1_listener gio_zxdg_toplevel_decoration_v1_listener = { 34 .configure = gio_onToplevelDecorationConfigure, 35 }; 36 37 static void xdg_wm_base_handle_ping(void *data, struct xdg_wm_base *wm, uint32_t serial) { 38 xdg_wm_base_pong(wm, serial); 39 } 40 41 const struct xdg_wm_base_listener gio_xdg_wm_base_listener = { 42 .ping = xdg_wm_base_handle_ping, 43 }; 44 45 const struct wl_callback_listener gio_callback_listener = { 46 .done = gio_onFrameDone, 47 }; 48 49 const struct wl_output_listener gio_output_listener = { 50 // Cast away const parameter. 51 .geometry = (void (*)(void *, struct wl_output *, int32_t, int32_t, int32_t, int32_t, int32_t, const char *, const char *, int32_t))gio_onOutputGeometry, 52 .mode = gio_onOutputMode, 53 .done = gio_onOutputDone, 54 .scale = gio_onOutputScale, 55 }; 56 57 const struct wl_seat_listener gio_seat_listener = { 58 .capabilities = gio_onSeatCapabilities, 59 // Cast away const parameter. 60 .name = (void (*)(void *, struct wl_seat *, const char *))gio_onSeatName, 61 }; 62 63 const struct wl_pointer_listener gio_pointer_listener = { 64 .enter = gio_onPointerEnter, 65 .leave = gio_onPointerLeave, 66 .motion = gio_onPointerMotion, 67 .button = gio_onPointerButton, 68 .axis = gio_onPointerAxis, 69 .frame = gio_onPointerFrame, 70 .axis_source = gio_onPointerAxisSource, 71 .axis_stop = gio_onPointerAxisStop, 72 .axis_discrete = gio_onPointerAxisDiscrete, 73 }; 74 75 const struct wl_touch_listener gio_touch_listener = { 76 .down = gio_onTouchDown, 77 .up = gio_onTouchUp, 78 .motion = gio_onTouchMotion, 79 .frame = gio_onTouchFrame, 80 .cancel = gio_onTouchCancel, 81 }; 82 83 const struct wl_keyboard_listener gio_keyboard_listener = { 84 .keymap = gio_onKeyboardKeymap, 85 .enter = gio_onKeyboardEnter, 86 .leave = gio_onKeyboardLeave, 87 .key = gio_onKeyboardKey, 88 .modifiers = gio_onKeyboardModifiers, 89 .repeat_info = gio_onKeyboardRepeatInfo 90 }; 91 92 const struct zwp_text_input_v3_listener gio_zwp_text_input_v3_listener = { 93 .enter = gio_onTextInputEnter, 94 .leave = gio_onTextInputLeave, 95 // Cast away const parameter. 96 .preedit_string = (void (*)(void *, struct zwp_text_input_v3 *, const char *, int32_t, int32_t))gio_onTextInputPreeditString, 97 .commit_string = (void (*)(void *, struct zwp_text_input_v3 *, const char *))gio_onTextInputCommitString, 98 .delete_surrounding_text = gio_onTextInputDeleteSurroundingText, 99 .done = gio_onTextInputDone 100 }; 101 102 const struct wl_data_device_listener gio_data_device_listener = { 103 .data_offer = gio_onDataDeviceOffer, 104 .enter = gio_onDataDeviceEnter, 105 .leave = gio_onDataDeviceLeave, 106 .motion = gio_onDataDeviceMotion, 107 .drop = gio_onDataDeviceDrop, 108 .selection = gio_onDataDeviceSelection, 109 }; 110 111 const struct wl_data_offer_listener gio_data_offer_listener = { 112 .offer = (void (*)(void *, struct wl_data_offer *, const char *))gio_onDataOfferOffer, 113 .source_actions = gio_onDataOfferSourceActions, 114 .action = gio_onDataOfferAction, 115 }; 116 117 const struct wl_data_source_listener gio_data_source_listener = { 118 .target = (void (*)(void *, struct wl_data_source *, const char *))gio_onDataSourceTarget, 119 .send = (void (*)(void *, struct wl_data_source *, const char *, int32_t))gio_onDataSourceSend, 120 .cancelled = gio_onDataSourceCancelled, 121 .dnd_drop_performed = gio_onDataSourceDNDDropPerformed, 122 .dnd_finished = gio_onDataSourceDNDFinished, 123 .action = gio_onDataSourceAction, 124 };