24#ifdef WITH_OPENGL_BACKEND
28#ifdef WITH_VULKAN_BACKEND
40#ifdef WITH_GHOST_WAYLAND_DYNLOAD
44#ifdef WITH_OPENGL_BACKEND
45# ifdef WITH_GHOST_WAYLAND_DYNLOAD
48# include <wayland-egl.h>
56#include <unordered_set>
59#ifdef WITH_GHOST_WAYLAND_DYNLOAD
62#include <wayland-cursor.h>
64#include <xkbcommon/xkbcommon-compose.h>
65#include <xkbcommon/xkbcommon.h>
68#include <color-management-v1-client-protocol.h>
69#include <cursor-shape-v1-client-protocol.h>
70#include <fractional-scale-v1-client-protocol.h>
71#include <pointer-constraints-unstable-v1-client-protocol.h>
72#include <pointer-gestures-unstable-v1-client-protocol.h>
73#include <primary-selection-unstable-v1-client-protocol.h>
74#include <relative-pointer-unstable-v1-client-protocol.h>
75#include <tablet-v2-client-protocol.h>
76#include <viewporter-client-protocol.h>
77#include <xdg-activation-v1-client-protocol.h>
78#include <xdg-output-unstable-v1-client-protocol.h>
79#include <xdg-toplevel-icon-v1-client-protocol.h>
81# include <text-input-unstable-v3-client-protocol.h>
85#include <xdg-decoration-unstable-v1-client-protocol.h>
86#include <xdg-shell-client-protocol.h>
138 int *r_interface_slot);
147 xkb_compose_state *compose_state,
149 const xkb_keycode_t key,
152#ifdef USE_EVENT_BACKGROUND_THREAD
162#define pushEvent DONT_USE
177#define USE_GNOME_CONFINE_HACK
184#ifdef USE_GNOME_CONFINE_HACK
193#define USE_KDE_TABLET_HIDDEN_CURSOR_HACK
194#ifdef USE_KDE_TABLET_HIDDEN_CURSOR_HACK
198#ifdef WITH_VULKAN_BACKEND
207# define USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
209#ifdef USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
210static bool use_kde_vulkan_ungrab_cursor_hack =
false;
217#define USE_GNOME_MOTION_MISSING_TIME_HACK
219#ifdef USE_GNOME_MOTION_MISSING_TIME_HACK
246#ifdef USE_VERBOSE_OLD_IFACE_PRINT
247# define _VERBOSE_OLD_IFACE_PRINT(params_version, version_max) \
248 ((params_version > version_max) ? \
250 "%s: version_max=%u, is smaller than run-time version=%u\n", \
256# define _VERBOSE_OLD_IFACE_PRINT(params_version, version_max) \
257 ((void)(params_version), (version_max))
260#define GWL_IFACE_VERSION_CLAMP(params_version, version_min, version_max) \
261 ((void)_VERBOSE_OLD_IFACE_PRINT(params_version, version_max), \
262 std::clamp(params_version, version_min, version_max))
268#define USE_NON_LATIN_KB_WORKAROUND
278#define WL_FIXED_TO_INT_FOR_WINDOW_V2(win, xy) \
279 wl_fixed_to_int((win)->wl_fixed_to_window((xy)[0])), \
280 wl_fixed_to_int((win)->wl_fixed_to_window((xy)[1])),
306#define BTN_RANGE_MIN BTN_LEFT
307#define BTN_RANGE_MAX BTN_BACK
340#ifdef USE_NON_LATIN_KB_WORKAROUND
355#ifndef XKB_VMOD_NAME_HYPER
356# define XKB_VMOD_NAME_HYPER "Hyper"
446 free(
const_cast<char *
>(buffer->
data));
447 buffer->
data =
nullptr;
453 free(
const_cast<char *
>(buffer->
data));
455 char *data =
static_cast<char *
>(malloc(buffer->
data_size));
481 wp_cursor_shape_device_v1_shape
enum_id = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT;
482 wp_cursor_shape_device_v1 *
device =
nullptr;
491 wl_buffer *
buffer =
nullptr;
492 wl_cursor_image
image = {0};
618 const uint32_t serial)
620 const int ty_mask = 1 << int(ty);
650 wl_data_offer *
id =
nullptr;
653 std::unordered_set<std::string>
types;
663 enum wl_data_device_manager_dnd_action
source_actions = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
664 enum wl_data_device_manager_dnd_action
action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
666 wl_fixed_t
xy[2] = {0, 0};
680 wl_data_source *
source =
nullptr;
741 wl_surface *surface_window_csd_margin =
nullptr;
758 wl_fixed_t
xy[2] = {0, 0};
761 std::unordered_set<const GWL_Output *>
outputs;
810#define GWL_SeatStatePointer_EventTypes_NUM (int(GWL_Pointer_EventTypes::Button6_Up) + 1)
843 const uint32_t serial,
850 GHOST_ASSERT(event_ms == 0,
"Scroll events must not have a time-stamp");
853 GHOST_ASSERT(event_ms != 0,
"Non-scroll events must have a time-stamp");
856 const int ty_mask = 1 << int(ty);
858 if (pointer_events->
frame_pending.frame_types_mask & ty_mask) {
899 enum wl_pointer_axis_source
axis_source = WL_POINTER_AXIS_SOURCE_WHEEL;
928 const wl_fixed_t
add)
930 const int result_prev = wl_fixed_to_int(sf->
value * sf->
factor);
932 const int result_curr = wl_fixed_to_int(sf->
value * sf->
factor);
933 return result_curr - result_prev;
976 zxdg_decoration_manager_v1 *
manager =
nullptr;
997 zwp_primary_selection_offer_v1 *
id =
nullptr;
1007 zwp_primary_selection_source_v1 *
source =
nullptr;
1028 zwp_primary_selection_offer_v1_destroy(primary->
data_offer->
wp.id);
1036 if (data_source ==
nullptr) {
1040 if (data_source->
wp.source) {
1041 zwp_primary_selection_source_v1_destroy(data_source->
wp.source);
1047#ifdef WITH_INPUT_IME
1057 GHOST_TEventImeData event_ime_data = {
1074 bool has_preedit =
false;
1077 bool result_is_null =
false;
1079 bool composite_is_null =
false;
1082 bool has_preedit_string_callback =
false;
1084 bool has_commit_string_callback =
false;
1100 wl_seat *
seat =
nullptr;
1101 wl_pointer *
pointer =
nullptr;
1102 wl_touch *
touch =
nullptr;
1113#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
1114 zwp_pointer_gesture_hold_v1 *pointer_gesture_hold =
nullptr;
1116#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
1119#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
1120 zwp_pointer_gesture_swipe_v1 *pointer_gesture_swipe =
nullptr;
1132#ifdef WITH_INPUT_IME
1133 zwp_text_input_v3 *text_input =
nullptr;
1139 xkb_context *
context =
nullptr;
1147 xkb_state *
state =
nullptr;
1176#ifdef WITH_INPUT_IME
1228#ifdef USE_GNOME_CONFINE_HACK
1236#ifdef USE_NON_LATIN_KB_WORKAROUND
1310 return &seat->
touch;
1324 GHOST_ASSERT(0,
"Surface found without pointer/tablet tag");
1336#ifdef WITH_GHOST_CSD
1337 seat_state_pointer->
wl.surface_window_csd_margin =
nullptr;
1341#ifdef USE_NON_LATIN_KB_WORKAROUND
1343 const xkb_layout_index_t layout_active);
1354 const xkb_layout_index_t group = seat->
xkb.layout_active;
1360 xkb_state_update_mask(seat->
xkb.state_empty, 0, 0, 0, 0, 0, group);
1363 GHOST_ASSERT((mod_shift == XKB_MOD_INVALID) == (seat->
xkb.state_empty_with_shift ==
nullptr),
1364 "Invalid state for SHIFT");
1365 if (seat->
xkb.state_empty_with_shift) {
1366 xkb_state_update_mask(seat->
xkb.state_empty_with_shift, 1 << mod_shift, 0, 0, 0, 0, group);
1370 GHOST_ASSERT((mod_mod2 == XKB_MOD_INVALID || mod_numlock == XKB_MOD_INVALID) ==
1371 (seat->
xkb.state_empty_with_numlock ==
nullptr),
1372 "Invalid state for NUMLOCK");
1373 if (seat->
xkb.state_empty_with_numlock) {
1374 xkb_state_update_mask(
1375 seat->
xkb.state_empty_with_numlock, 1 << mod_mod2, 0, 1 << mod_numlock, 0, 0, group);
1378#ifdef USE_NON_LATIN_KB_WORKAROUND
1383 if (seat->
xkb.state_empty_with_shift) {
1388 const xkb_keysym_t sym_test = xkb_state_key_get_one_sym(seat->
xkb.state_empty_with_shift,
1390 if (!(sym_test >= XKB_KEY_0 && sym_test <= XKB_KEY_9)) {
1410 if (wl_surface_focus ==
nullptr) [[unlikely]] {
1420 if (seat->
xkb.compose_state &&
1422 seat->
xkb.compose_state, seat->
xkb.state, payload->
key_code, utf8_buf))
1427 xkb_state_key_get_utf8(seat->
xkb.state, payload->
key_code, utf8_buf,
sizeof(utf8_buf));
1444 const bool use_delay)
1456 time_now + time_start, time_step, key_repeat_fn, payload);
1472#ifdef WITH_INPUT_IME
1474static void gwl_seat_ime_full_reset(
GWL_Seat *seat)
1476 const GWL_SeatIME ime_default{};
1479 wl_surface *surface_window = seat->ime.surface_window;
1480 const bool is_enabled = seat->ime.is_enabled;
1481 const bool has_preedit_string_callback = seat->ime.has_preedit_string_callback;
1482 const bool has_commit_string_callback = seat->ime.has_commit_string_callback;
1484 seat->ime = ime_default;
1486 seat->ime.surface_window = surface_window;
1488 seat->ime.has_preedit_string_callback = has_preedit_string_callback;
1489 seat->ime.has_commit_string_callback = has_commit_string_callback;
1492static void gwl_seat_ime_result_reset(
GWL_Seat *seat)
1495 event_ime_data.
result.clear();
1496 seat->ime.result_is_null =
false;
1499static void gwl_seat_ime_preedit_reset(
GWL_Seat *seat)
1504 seat->ime.composite_is_null =
false;
1511static void gwl_seat_ime_rect_reset(
GWL_Seat *seat)
1513 seat->ime.rect.x = -1;
1514 seat->ime.rect.y = -1;
1515 seat->ime.rect.w = -1;
1516 seat->ime.rect.h = -1;
1523#ifdef WITH_GHOST_DBUS
1532struct GWL_DBusEvent {
1536 struct CSD_ButtonLayout {
1540 std::variant<CursorSize, CSD_ButtonLayout>
data;
1576 wl_shm *
shm =
nullptr;
1599#ifdef WITH_INPUT_IME
1600 zwp_text_input_manager_v3 *text_input_manager =
nullptr;
1676#ifdef WITH_GHOST_CSD
1682#ifdef WITH_GHOST_DBUS
1688 std::vector<GWL_DBusEvent> events;
1690 std::mutex events_mutex;
1695 std::atomic<bool> has_events =
false;
1700#ifdef USE_EVENT_BACKGROUND_THREAD
1760#ifdef USE_EVENT_BACKGROUND_THREAD
1771 if (display->
wl.registry) {
1772 wl_registry_destroy(display->
wl.registry);
1773 display->
wl.registry =
nullptr;
1783#ifdef WITH_OPENGL_BACKEND
1784 if (display->
wl.display) {
1785 if (eglGetDisplay) {
1786 ::eglTerminate(eglGetDisplay(EGLNativeDisplayType(display->
wl.display)));
1797 if (display->
wl.display) {
1806 const auto iter = std::ranges::find(display->
seats, seat);
1807 const int index = (iter != display->
seats.cend()) ? int(iter - display->
seats.begin()) : -1;
1821 if (display->
seats.empty()) [[unlikely]] {
1829 if (display->
seats.empty()) [[unlikely]] {
1957 int *r_interface_slot)
1963 if (r_interface_slot) {
1964 *r_interface_slot = -1;
1968 if (reg->
name == name) {
1973 if (r_interface_slot) {
1977 *reg_link_p = reg_next;
1981 reg_link_p = ®->
next;
1988 const int interface_slot,
2002 *reg_link_p = reg_next;
2007 reg_link_p = ®->
next;
2018 const bool on_exit =
true;
2032 while (interface_slot--) {
2058 GHOST_ASSERT(interface_slot_exclude == -1 || (uint(interface_slot_exclude) <
2060 "Invalid exclude slot");
2063 if (reg->interface_slot == interface_slot_exclude) {
2067 reg->interface_slot);
2073 params.
name = reg->name;
2075 params.
version = reg->version;
2090 return ((
x + multiple - 1) / multiple) * multiple;
2095 uint8_t *rgba =
reinterpret_cast<uint8_t *
>(&rgba_uint);
2096 const uint32_t alpha = uint32_t(rgba[3]);
2097 rgba[0] = uint8_t(((alpha * rgba[0]) + (0xff / 2)) / 0xff);
2098 rgba[1] = uint8_t(((alpha * rgba[1]) + (0xff / 2)) / 0xff);
2099 rgba[2] = uint8_t(((alpha * rgba[2]) + (0xff / 2)) / 0xff);
2105 uint8_t *rgba =
reinterpret_cast<uint8_t *
>(&rgba_uint);
2106 const uint32_t alpha = uint32_t(rgba[3]);
2107 rgba[0] = uint8_t(((alpha * (0xff - rgba[0])) + (0xff / 2)) / 0xff);
2108 rgba[1] = uint8_t(((alpha * (0xff - rgba[1])) + (0xff / 2)) / 0xff);
2109 rgba[2] = uint8_t(((alpha * (0xff - rgba[2])) + (0xff / 2)) / 0xff);
2115 return a >
b ? a -
b :
b - a;
2131 const char *locale = getenv(
"LC_ALL");
2132 if (!locale || !*locale) {
2133 locale = getenv(
"LC_CTYPE");
2134 if (!locale || !*locale) {
2135 locale = getenv(
"LANG");
2136 if (!locale || !*locale) {
2147 if (
ELEM(ecode, EPIPE, ECONNRESET)) {
2148 fprintf(stderr,
"The Wayland connection broke. Did the Wayland compositor die?\n");
2152 if (ecode == EPROTO) {
2153 const wl_interface *
interface = nullptr;
2156 "The Wayland connection experienced a protocol error %d in interface: %s\n",
2158 interface ? interface->name :
"<nil>");
2159 const char *env_debug =
"WAYLAND_DEBUG";
2160 if (getenv(env_debug) ==
nullptr) {
2161 fprintf(stderr,
"Run with the environment variable \"%s=1\" for details.\n", env_debug);
2166 fprintf(stderr,
"The Wayland connection experienced a fatal error: %s\n", strerror(ecode));
2215 fprintf(stderr,
"GHOST/Wayland: ");
2216 vfprintf(stderr, msg, arg);
2220 backtrace_fn(stderr);
2229 const std::string_view msg_view(msg);
2230 if (msg_view.find(
"error: XDG_RUNTIME_DIR not set in the environment") !=
2231 std::string_view::npos ||
2232 msg_view.find(
"error: XDG_RUNTIME_DIR is invalid or not set in the environment") !=
2233 std::string_view::npos)
2244 if (sym >= XKB_KEY_0 && sym <= XKB_KEY_9) {
2247 else if (sym >= XKB_KEY_KP_0 && sym <= XKB_KEY_KP_9) {
2250 else if (sym >= XKB_KEY_A && sym <= XKB_KEY_Z) {
2253 else if (sym >= XKB_KEY_a && sym <= XKB_KEY_z) {
2254 gkey =
GHOST_TKey(sym - XKB_KEY_a + XKB_KEY_A);
2256 else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F24) {
2261#define GXMAP(k, x, y) \
2375 "unhandled key: " << std::hex << std::showbase << sym <<
2376 std::dec <<
" (" << sym <<
"), " <<
2378 "scan-code: " << std::hex << std::showbase << key <<
2379 std::dec <<
" (" << key <<
")" <<
2389#ifdef USE_NON_LATIN_KB_WORKAROUND
2399 const xkb_layout_index_t layout_active)
2401 const xkb_layout_index_t layouts_num = xkb_keymap_num_layouts(keymap);
2402 if (layouts_num <= 1) {
2403 return XKB_LAYOUT_INVALID;
2405 const xkb_keycode_t keycode_min = xkb_keymap_min_keycode(keymap);
2406 const xkb_keycode_t keycode_max = xkb_keymap_max_keycode(keymap);
2407 xkb_layout_index_t layout_best = 0;
2408 int score_best = -1;
2411 int score_active = std::numeric_limits<int>::max();
2412 for (xkb_layout_index_t layout_test = 0; layout_test < layouts_num; layout_test++) {
2414 for (xkb_keycode_t key = keycode_min; key <= keycode_max; key++) {
2415 const xkb_keysym_t *syms;
2416 if (xkb_keymap_key_get_syms_by_level(keymap, key, layout_test, 0, &syms) > 0 &&
2423 if (score_test > score_best) {
2424 score_best = score_test;
2425 layout_best = layout_test;
2427 if (layout_test == layout_active) {
2428 score_active = score_test;
2431 GHOST_ASSERT(score_active != std::numeric_limits<int>::max(),
2432 "Invalid `layout_active` passed in.");
2435 if (score_best <= score_active) {
2436 return XKB_LAYOUT_INVALID;
2449 const xkb_keycode_t key,
2450 const xkb_layout_index_t layout_fallback)
2452#ifndef USE_NON_LATIN_KB_WORKAROUND
2454 "Fallback key-map is expected to be disabled!");
2460 const xkb_keysym_t *syms;
2461 if (xkb_keymap_key_get_syms_by_level(keymap, key, layout_fallback, 0, &syms) > 0 &&
2473 xkb_state *
state,
const xkb_keycode_t key,
const xkb_layout_index_t layout_fallback)
2476 xkb_state_key_get_one_sym(
state, key), xkb_state_get_keymap(
state), key, layout_fallback);
2482 case WL_POINTER_AXIS_HORIZONTAL_SCROLL: {
2485 case WL_POINTER_AXIS_VERTICAL_SCROLL: {
2496 switch (wp_tablet_tool_type) {
2497 case ZWP_TABLET_TOOL_V2_TYPE_ERASER: {
2500 case ZWP_TABLET_TOOL_V2_TYPE_PEN:
2501 case ZWP_TABLET_TOOL_V2_TYPE_BRUSH:
2502 case ZWP_TABLET_TOOL_V2_TYPE_PENCIL:
2503 case ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH:
2504 case ZWP_TABLET_TOOL_V2_TYPE_FINGER:
2505 case ZWP_TABLET_TOOL_V2_TYPE_MOUSE:
2506 case ZWP_TABLET_TOOL_V2_TYPE_LENS: {
2511 GHOST_PRINT(
"unknown tablet tool: " << wp_tablet_tool_type << std::endl);
2517#ifdef WITH_GHOST_DBUS
2519static const int dbus_initial_timeout_ms = 100;
2521static const size_t dbus_events_default_size = 8;
2532 const char *env = getenv(
"XCURSOR_SIZE");
2533 if (!env || (*env ==
'\0')) {
2534 return std::nullopt;
2536 char *env_end =
nullptr;
2537 const long value = strtol(env, &env_end, 10);
2540 if ((*env_end !=
'\0') || (value <= 0)) {
2541 return std::nullopt;
2567 "text/plain;charset=utf-8",
2576 size_t data_buf_len)
2578 std::vector<std::string_view> uris;
2579 const char file_proto[] =
"file://";
2582 const char lf =
'\n';
2584 const std::string_view data = std::string_view(data_buf, data_buf_len);
2587 while (pos != std::string::npos) {
2588 pos = data.find(file_proto, pos);
2589 if (pos == std::string::npos) {
2592 const size_t start = pos +
sizeof(file_proto) - 1;
2593 pos = data.find(lf, pos);
2596 if (end == std::string::npos) [[unlikely]] {
2602 if ((end > 0) && (data[end - 1] ==
'\r')) {
2606 std::string_view data_substr = data.substr(start, end - start);
2607 uris.push_back(data_substr);
2612#ifdef USE_EVENT_BACKGROUND_THREAD
2616 sched_param sch_params;
2617 if (pthread_getschedparam(handle, &policy, &sch_params) == 0) {
2618 sch_params.sched_priority = sched_get_priority_min(policy);
2619 pthread_setschedparam(handle, policy, &sch_params);
2627#ifdef HAVE_MEMFD_CREATE
2628 const int fd = memfd_create(name, MFD_CLOEXEC | MFD_ALLOW_SEALING);
2630 fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
2634 char *path = getenv(
"XDG_RUNTIME_DIR");
2640 asprintf(&tmpname,
"%s/%s-XXXXXX", path, name);
2641 const int fd = mkostemp(tmpname, O_CLOEXEC);
2660 const int fd,
const int fd_stop,
const int flags,
const int timeout_ms,
bool *r_stop)
2673 info[0].events |= POLLIN | POLLPRI;
2676 info[0].events |= POLLOUT;
2680 info[1] = {fd_stop, POLLIN, 0};
2682 result = poll(info, 2, timeout_ms);
2683 if ((result > 0) && (info[1].revents != 0)) {
2722#ifdef USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
2724static void surface_frame_apply_handle_done(
void *data,
2728 *
static_cast<bool *
>(
data) =
true;
2731static const wl_callback_listener surface_frame_apply_listener = {
2732 surface_frame_apply_handle_done,
2746 const int timeout_ms)
2757 bool apply_done =
false;
2760 wl_callback *frame_callback = wl_surface_frame(surface_wrapper);
2761 wl_callback_add_listener(frame_callback, &surface_frame_apply_listener, &apply_done);
2762 wl_surface_commit(surface);
2766 while (!apply_done) {
2782 if (time_now >= time_end) {
2802 wl_callback_destroy(frame_callback);
2810#ifdef USE_EVENT_BACKGROUND_THREAD
2821 std::mutex *server_mutex)
2826 server_mutex->lock();
2830 bool wait_on_fd =
false;
2841 server_mutex->unlock();
2851 server_mutex->unlock();
2857 if (!stop &&
state > 0) {
2858 server_mutex->lock();
2863 server_mutex->unlock();
2867 return stop ? -1 : err;
2874 case WL_SHM_FORMAT_ARGB8888: {
2894 enum wl_shm_format format,
2895 void **r_buffer_data,
2896 size_t *r_buffer_data_size)
2899 wl_buffer *buffer =
nullptr;
2902 const int32_t buffer_size = buffer_stride * size_xy[1];
2903 if (posix_fallocate(fd, 0, buffer_size) == 0) {
2904 void *buffer_data = mmap(
nullptr, buffer_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
2905 if (buffer_data != MAP_FAILED) {
2906 if (wl_shm_pool *pool = wl_shm_create_pool(shm, fd, buffer_size)) {
2907 buffer = wl_shm_pool_create_buffer(pool, 0,
UNPACK2(size_xy), buffer_stride, format);
2908 wl_shm_pool_destroy(pool);
2910 *r_buffer_data = buffer_data;
2911 *r_buffer_data_size = size_t(buffer_size);
2914 if (buffer ==
nullptr) [[unlikely]] {
2915 munmap(buffer_data, buffer_size);
2926 const int32_t size_xy[2] = {1, 1};
2927 void *buffer_data =
nullptr;
2928 size_t buffer_data_size = 0;
2930 shm, size_xy, WL_SHM_FORMAT_ARGB8888, &buffer_data, &buffer_data_size);
2931 if (buffer ==
nullptr) [[unlikely]] {
2934 memset(buffer_data, 0, buffer_data_size);
2935 munmap(buffer_data, buffer_data_size);
2945 ssize_t nbytes_read = read(fd, data, nbytes);
2946 if (nbytes_read > 0) {
2947 while (nbytes_read < nbytes) {
2948 const ssize_t nbytes_extra = read(
2949 fd,
static_cast<char *
>(data) + nbytes_read, nbytes - nbytes_read);
2950 if (nbytes_extra > 0) {
2951 nbytes_read += nbytes_extra;
2954 if (nbytes_extra < 0) [[unlikely]] {
2955 nbytes_read = nbytes_extra;
2975 char data[4096 -
sizeof(ByteChunk *)];
2980 ByteChunk *chunk_first =
static_cast<ByteChunk *
>(malloc(
sizeof(ByteChunk)));
2982 ByteChunk **chunk_link_p = &chunk_first;
2983 ByteChunk *chunk = chunk_first;
2985 if (chunk ==
nullptr) [[unlikely]] {
2990 chunk->next =
nullptr;
2992 const ssize_t len_chunk =
read_exhaustive(fd, chunk->data,
sizeof(ByteChunk::data));
2993 if (len_chunk <= 0) {
2994 if (len_chunk < 0) [[unlikely]] {
2997 if (chunk == chunk_first) {
2998 chunk_first =
nullptr;
3003 *chunk_link_p = chunk;
3004 chunk_link_p = &chunk->next;
3007 if (len_chunk !=
sizeof(ByteChunk::data)) {
3010 chunk =
static_cast<ByteChunk *
>(malloc(
sizeof(ByteChunk)));
3014 char *buf =
nullptr;
3016 buf =
static_cast<char *
>(malloc(
len + (nil_terminate ? 1 : 0)));
3017 if (buf ==
nullptr) [[unlikely]] {
3025 if (nil_terminate) {
3033 char *buf_stride = buf;
3034 while (chunk_first) {
3036 const size_t len_chunk = std::min(
len,
sizeof(chunk_first->data));
3037 memcpy(buf_stride, chunk_first->data, len_chunk);
3038 buf_stride += len_chunk;
3041 ByteChunk *chunk = chunk_first->next;
3043 chunk_first = chunk;
3051 std::string_view needle)
3056 while (!haystack.empty()) {
3057 const size_t pos = haystack.find(delim);
3058 if (haystack.substr(0, pos) == needle) {
3061 if (pos == std::string_view::npos) {
3064 haystack.remove_prefix(pos + 1);
3083 "The size must be a multiple of the scale!");
3089 if (wl_surface_get_version(
wl_surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) {
3093 std::numeric_limits<int32_t>::max(),
3094 std::numeric_limits<int32_t>::max());
3101 std::numeric_limits<int32_t>::max(),
3102 std::numeric_limits<int32_t>::max());
3125 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT;
3127 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE;
3129 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE;
3131 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CONTEXT_MENU;
3133 return std::nullopt;
3135 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_HELP;
3137 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_WAIT;
3139 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT;
3141 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR;
3143 return std::nullopt;
3145 return std::nullopt;
3147 return std::nullopt;
3149 return std::nullopt;
3151 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE;
3153 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE;
3155 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COL_RESIZE;
3157 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ROW_RESIZE;
3159 return std::nullopt;
3161 return std::nullopt;
3163 return std::nullopt;
3165 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_IN;
3167 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_OUT;
3169 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_MOVE;
3171 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRAB;
3173 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRABBING;
3175 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER;
3177 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL;
3179 return std::nullopt;
3181 return std::nullopt;
3183 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED;
3185 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NS_RESIZE;
3187 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_EW_RESIZE;
3189 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE;
3191 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE;
3193 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE;
3195 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE;
3197 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE;
3199 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE;
3201 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE;
3203 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE;
3205 return WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COPY;
3207 return std::nullopt;
3209 return std::nullopt;
3211 return std::nullopt;
3213 return std::nullopt;
3215 return std::nullopt;
3217 return std::nullopt;
3221 return std::nullopt;
3236 if (seat->
wp.tablet_seat) {
3254 wp_cursor_shape_device_v1_set_shape(
3263 wl_pointer_set_cursor(
3268 if (!seat->
wp.tablet_tools.empty()) {
3273 for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->
wp.tablet_tools) {
3275 zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
3277 wp_cursor_shape_device_v1_set_shape(
3281 zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2,
3283 tablet_tool->
wl.surface_cursor,
3286#ifdef USE_KDE_TABLET_HIDDEN_CURSOR_HACK
3288 wl_surface_commit(tablet_tool->
wl.surface_cursor);
3305 for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->
wp.tablet_tools) {
3307 zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
3308 zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2, tablet_tool->
serial,
nullptr, 0, 0);
3313 const wl_cursor_image *wl_image,
3329 visible ? cursor->
wl.surface_cursor :
nullptr,
3335 if (!seat->
wp.tablet_tools.empty()) {
3338 for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->
wp.tablet_tools) {
3340 zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
3342 zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2,
3344 visible ? tablet_tool->
wl.surface_cursor :
nullptr,
3365 const bool is_hardware,
3370 const bool use_visible = is_hardware && visible;
3411#define LOG (&LOG_WL_KEYBOARD_DEPRESSED_STATE)
3429 if (value < 0) [[unlikely]] {
3454 std::make_unique<GHOST_EventKey>(event_ms,
GHOST_kEventKeyUp, win, gkey,
false));
3478#ifdef WITH_GHOST_CSD
3490static bool gwl_window_csd_active_elem_type_apply(
GWL_Seat *seat,
3494 if (type == win->csd_elem_active_type_get()) {
3497 win->csd_elem_active_type_set(type);
3574static bool gwl_window_csd_active_elem_motion(
GWL_Seat *seat,
3576 const int event_xy[2])
3585 for (i = 0; i < elems_num; i++) {
3588 if ((event_xy[0] >= elem.
bounds[0][0] && event_xy[0] <= elem.
bounds[0][1]) &&
3589 (event_xy[1] >= elem.
bounds[1][0] && event_xy[1] <= elem.
bounds[1][1]))
3591 active_type_next = elem.
type;
3596 if (i == elems_num) [[unlikely]] {
3602 event_state.
event_xy[0] = event_xy[0];
3603 event_state.
event_xy[1] = event_xy[1];
3612 if ((std::abs(press.
xy[0] - event_xy[0]) + std::abs(press.
xy[1] - event_xy[1])) >
3615 xdg_toplevel_move(win->xdg_toplevel_get(), seat->
wl.seat, press.
serial);
3621 return gwl_window_csd_active_elem_type_apply(seat, win, active_type_next);
3643static void gwl_window_csd_active_elem_button(
GWL_Seat *seat,
3646 const bool is_press,
3647 const uint32_t serial,
3666 bool is_double_click =
false;
3674 if (actions[0].is_press) {
3675 press_type = actions[0].
type;
3682 if ((is_press ==
false) && (actions[0].is_press ==
true && actions[1].is_press ==
false &&
3683 actions[2].is_press ==
true))
3685 if ((active_type == actions[0].type) &&
3686 ((actions[0].type == actions[1].type) && (actions[1].type == actions[2].type)))
3691 if ((std::abs(actions[0].xy[0] - actions[2].xy[0]) +
3692 std::abs(actions[0].xy[1] - actions[2].xy[1])) <=
3695 is_double_click =
true;
3711 action.
ms = event_ms;
3716 action.
type = active_type;
3718 if (is_double_click) {
3724 switch (active_type) {
3730 xdg_toplevel_resize(
3731 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_TOP);
3737 xdg_toplevel_resize(
3738 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM);
3744 xdg_toplevel_resize(
3745 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_LEFT);
3751 xdg_toplevel_resize(
3752 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_RIGHT);
3758 xdg_toplevel_resize(
3759 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT);
3765 xdg_toplevel_resize(
3766 win->xdg_toplevel_get(), seat->
wl.seat, serial, XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT);
3772 xdg_toplevel_resize(win->xdg_toplevel_get(),
3775 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT);
3781 xdg_toplevel_resize(win->xdg_toplevel_get(),
3784 XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT);
3789 if (is_double_click) {
3791 xdg_toplevel_set_maximized(win->xdg_toplevel_get());
3794 xdg_toplevel_unset_maximized(win->xdg_toplevel_get());
3800 if (is_press ==
false && (active_type == press_type)) {
3801 xdg_toplevel_set_minimized(win->xdg_toplevel_get());
3806 if (is_press ==
false && (active_type == press_type)) {
3808 xdg_toplevel_set_maximized(win->xdg_toplevel_get());
3811 xdg_toplevel_unset_maximized(win->xdg_toplevel_get());
3817 if (is_press ==
false && (active_type == press_type)) {
3823 if (is_press ==
false) {
3835 for (
int i = 0; i < elems_num; i += 1) {
3844 const int button_xy[2] = {
3848 xdg_toplevel_show_window_menu(
3849 win->xdg_toplevel_get(), seat->
wl.seat, action.
serial,
UNPACK2(button_xy));
3859 switch (active_type) {
3867 const int event_xy[2] = {
3871 xdg_toplevel_show_window_menu(
3872 win->xdg_toplevel_get(), seat->
wl.seat, serial,
UNPACK2(event_xy));
3900 "wl_surface is not the CSD margin surface");
3911 const uint32_t serial,
3918 seat_state_pointer->
wl.surface_window =
nullptr;
3919 seat_state_pointer->
wl.surface_window_csd_margin =
wl_surface;
3927 gwl_window_csd_buttons_clear(win);
3940 gwl_window_csd_active_elem_clear(win);
3941 gwl_window_csd_buttons_clear(win);
3942 seat_state_pointer->
wl.surface_window_csd_margin =
nullptr;
3954static bool gwl_window_csd_margin_elem_motion(
GWL_Seat *seat,
3956 const wl_fixed_t xy[2])
3959 int32_t window_size[2] = {0, 0};
3960 win->csd_margin_geometry_get(margin_size, window_size);
3963 const wl_fixed_t xy_min = wl_fixed_from_int(margin_size);
3964 const wl_fixed_t xy_max[2] = {
3965 wl_fixed_from_int(margin_size + window_size[0]),
3966 wl_fixed_from_int(margin_size + window_size[1]),
3970 if (xy[1] < xy_min) {
3975 else if (xy[1] >= xy_max[1]) {
3980 else if (xy[0] < xy_min) {
3983 else if (xy[0] >= xy_max[0]) {
3992 return gwl_window_csd_active_elem_type_apply(seat, win, type);
4005 const char *xdg_current_desktop = [] {
4007 const char *key =
"ORIGINAL_XDG_CURRENT_DESKTOP";
4008 const char *value = getenv(key);
4009 return value ? value : getenv(key + 9);
4012 if (xdg_current_desktop) {
4036#define LOG (&LOG_WL_RELATIVE_POINTER)
4043 const wl_fixed_t xy[2],
4049#ifdef USE_GNOME_CONFINE_HACK
4070 zwp_relative_pointer_v1 * ,
4071 const uint32_t utime_hi,
4072 const uint32_t utime_lo,
4073 const wl_fixed_t dx,
4074 const wl_fixed_t dy,
4088 const wl_fixed_t xy_next[2] = {
4112#define LOG (&LOG_WL_DATA_SOURCE)
4119 if (
wl_surface *wl_surface_focus = seat->
wl.surface_window_focus_dnd) {
4125 event_ms, event, type, win,
UNPACK2(event_xy),
nullptr));
4131 const char *mime_receive,
4133 const bool nil_terminate,
4137 const bool pipefd_ok = pipe(pipefd) == 0;
4139 wl_data_offer_receive(data_offer->
wl.id, mime_receive, pipefd[1]);
4143 CLOG_WARN(
LOG,
"error creating pipe: %s", std::strerror(errno));
4154 char *buf =
nullptr;
4157 if (buf ==
nullptr) {
4158 CLOG_WARN(
LOG,
"unable to pipe into buffer: %s", std::strerror(errno));
4169 const char *mime_receive,
4171 const bool nil_terminate,
4175 const bool pipefd_ok = pipe(pipefd) == 0;
4177 zwp_primary_selection_offer_v1_receive(data_offer->
wp.id, mime_receive, pipefd[1]);
4181 CLOG_WARN(
LOG,
"error creating pipe: %s", std::strerror(errno));
4188 char *buf =
nullptr;
4191 if (buf ==
nullptr) {
4192 CLOG_WARN(
LOG,
"unable to pipe into buffer: %s", std::strerror(errno));
4221 auto write_file_fn = [](
GWL_Seat *seat,
const int fd) {
4225 CLOG_WARN(
LOG,
"error writing to clipboard: %s", std::strerror(errno));
4232 std::thread write_thread(write_file_fn, seat, fd);
4233 write_thread.detach();
4244 data_source->
wl.source =
nullptr;
4247 wl_data_source_destroy(wl_data_source);
4284 const uint32_t dnd_action)
4286 CLOG_DEBUG(
LOG,
"handle_action (dnd_action=%u)", dnd_action);
4307#define LOG (&LOG_WL_DATA_OFFER)
4311 const char *mime_type)
4316 data_offer->
types.insert(mime_type);
4321 const uint32_t source_actions)
4326 data_offer->
dnd.source_actions = (
enum wl_data_device_manager_dnd_action)source_actions;
4331 const uint32_t dnd_action)
4336 data_offer->
dnd.action = (
enum wl_data_device_manager_dnd_action)dnd_action;
4354#define LOG (&LOG_WL_DATA_DEVICE)
4374 data_offer->
wl.id = id;
4380 const uint32_t serial,
4402 wl_data_offer_destroy(data_offer->
wl.id);
4411 data_offer->
dnd.xy[0] =
x;
4412 data_offer->
dnd.xy[1] =
y;
4414 wl_data_offer_set_actions(
id,
4415 WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY |
4416 WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE,
4417 WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY);
4421 if (!data_offer->
types.contains(type)) {
4426 wl_data_offer_accept(
id, serial, type);
4449 seat->
wl.surface_window_focus_dnd =
nullptr;
4460 const uint32_t time,
4499 const char *mime_receive =
"";
4502 if (data_offer->
types.contains(type)) {
4503 mime_receive = type;
4510 auto read_drop_data_fn = [](
GWL_Seat *
const seat,
4513 const char *mime_receive) {
4515 const wl_fixed_t xy[2] = {
UNPACK2(data_offer->
dnd.xy)};
4518 size_t data_buf_len = 0;
4520 data_offer, mime_receive,
nullptr, nil_terminate, &data_buf_len);
4522 CLOG_DEBUG(
LOG,
"read_drop_data mime_receive=%s, data_len=%zu", mime_receive, data_buf_len);
4524 wl_data_offer_finish(data_offer->
wl.id);
4525 wl_data_offer_destroy(data_offer->
wl.id);
4528 data_offer =
nullptr;
4532 if (data_buf !=
nullptr) {
4534 void *ghost_dnd_data =
nullptr;
4542 flist->
count = int(uris.size());
4543 flist->
strings =
static_cast<uint8_t **
>(malloc(uris.size() *
sizeof(uint8_t *)));
4544 for (
size_t i = 0; i < uris.size(); i++) {
4545 flist->
strings[i] =
reinterpret_cast<uint8_t *
>(
4551 ghost_dnd_data = flist;
4555 ghost_dnd_data = (
void *)data_buf;
4565 std::make_unique<GHOST_EventDragnDrop>(event_ms,
4578 free(
const_cast<char *
>(data_buf));
4584 std::thread read_thread(
4585 read_drop_data_fn, seat, data_offer, seat->
wl.surface_window_focus_dnd, mime_receive);
4586 read_thread.detach();
4605 if (
id ==
nullptr) {
4635#define LOG (&LOG_WL_CURSOR_BUFFER)
4642 wl_buffer_destroy(wl_buffer);
4644 if (wl_buffer == cursor->
wl.buffer) {
4646 cursor->
wl.buffer =
nullptr;
4663#define LOG (&LOG_WL_CURSOR_SURFACE)
4674 wl_surface *wl_surface_focus = seat_state_pointer->
wl.surface_window;
4675 if (!wl_surface_focus) {
4709#ifdef WITH_GHOST_DBUS
4711static void cursor_size_set(
GWL_Seat *seat,
const int size_new)
4734 seat_state_pointer->
outputs.insert(reg_output);
4750 seat_state_pointer->
outputs.erase(reg_output);
4759 CLOG_DEBUG(
LOG,
"handle_preferred_buffer_scale (factor=%d)", factor);
4762#if defined(WL_SURFACE_PREFERRED_BUFFER_SCALE_SINCE_VERSION) && \
4763 defined(WL_SURFACE_PREFERRED_BUFFER_TRANSFORM_SINCE_VERSION)
4764static void cursor_surface_handle_preferred_buffer_transform(
void * ,
4777#if defined(WL_SURFACE_PREFERRED_BUFFER_SCALE_SINCE_VERSION) && \
4778 defined(WL_SURFACE_PREFERRED_BUFFER_TRANSFORM_SINCE_VERSION)
4780 cursor_surface_handle_preferred_buffer_transform,
4793#define LOG (&LOG_WL_POINTER)
4795#ifdef WITH_GHOST_CSD
4803static void pointer_handle_enter_csd_margin(
GWL_Seat *seat,
4804 const uint32_t serial,
4806 const wl_fixed_t surface_x,
4807 const wl_fixed_t surface_y)
4819 if (!gwl_window_csd_margin_elem_motion(seat, win, seat->
pointer.
xy)) {
4827 const uint32_t serial,
4829 const wl_fixed_t surface_x,
4830 const wl_fixed_t surface_y)
4834#ifdef WITH_GHOST_CSD
4835 if (ghost_wl_surface_own_csd_margin_with_null_check(
wl_surface)) {
4837 pointer_handle_enter_csd_margin(seat, serial,
wl_surface, surface_x, surface_y);
4866 bool cursor_shape_refresh =
true;
4869#ifdef WITH_GHOST_CSD
4875 gwl_window_csd_buttons_clear(win);
4877 if (gwl_window_csd_active_elem_motion(seat, win, event_xy)) {
4879 cursor_shape_refresh =
false;
4883 if (cursor_shape_refresh) {
4899#ifdef WITH_GHOST_CSD
4900 if (ghost_wl_surface_own_csd_margin_with_null_check(
wl_surface)) {
4913#ifdef WITH_GHOST_CSD
4916 gwl_window_csd_active_elem_clear(win);
4917 gwl_window_csd_buttons_clear(win);
4924 const uint32_t time,
4925 const wl_fixed_t surface_x,
4926 const wl_fixed_t surface_y)
4936#ifdef USE_GNOME_MOTION_MISSING_TIME_HACK
4938 if (event_ms == 0) [[unlikely]] {
4952 const uint32_t serial,
4953 const uint32_t time,
4954 const uint32_t button,
4955 const uint32_t
state)
4966 case WL_POINTER_BUTTON_STATE_RELEASED: {
4970 case WL_POINTER_BUTTON_STATE_PRESSED: {
4993 const uint32_t time,
4994 const uint32_t axis,
4995 const wl_fixed_t value)
5005 if (
index == -1) [[unlikely]] {
5014#ifdef WITH_GHOST_CSD
5034 gwl_window_csd_margin_elem_motion(seat, win, seat->
pointer.
xy);
5059 const int button_enum_offset = int(ty) - int(Button0_Down);
5060 const int button_index = button_enum_offset / 2;
5061 const bool button_down = (button_index * 2) == button_enum_offset;
5064 "Button down events must have a serial");
5065 gwl_window_csd_active_elem_button(seat, win, ebutton, button_down, serial, event_ms);
5079#ifdef WITH_GHOST_CSD
5081 pointer_handle_frame_csd_margin(seat, wl_surface_focus);
5094#ifdef WITH_GHOST_CSD
5104#ifdef WITH_GHOST_CSD
5106 if (gwl_window_csd_active_elem_motion(seat, win, event_xy)) {
5123 GHOST_ASSERT(event_ms == 0,
"Scroll events are not expected to have a time!");
5126 for (
int i = 0; i < 2; i++) {
5137 if (ps.
axis_source == WL_POINTER_AXIS_SOURCE_WHEEL) {
5145 else if (ps.
axis_source == WL_POINTER_AXIS_SOURCE_FINGER) {
5152 for (
int i = 0; i < 2; i++) {
5171 if (ps.
axis_source == WL_POINTER_AXIS_SOURCE_WHEEL) {
5257 const int button_enum_offset = int(ty) - int(
Button0_Down);
5258 const int button_index = button_enum_offset / 2;
5259 const bool button_down = (button_index * 2) == button_enum_offset;
5267#ifdef WITH_GHOST_CSD
5269 gwl_window_csd_active_elem_button(seat, win, ebutton, button_down, serial, event_ms);
5282 const uint32_t axis_source)
5284 CLOG_DEBUG(
LOG,
"axis_source (axis_source=%u)", axis_source);
5290 const uint32_t time,
5291 const uint32_t axis)
5311 const uint32_t axis,
5316 CLOG_DEBUG(
LOG,
"axis_discrete (axis=%u, discrete=%d)", axis, discrete);
5318 if (
index == -1) [[unlikely]] {
5329 const uint32_t axis,
5333 CLOG_DEBUG(
LOG,
"axis_value120 (axis=%u, value120=%d)", axis, value120);
5335 if (
index == -1) [[unlikely]] {
5344#ifdef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM
5345static void pointer_handle_axis_relative_direction(
void *data,
5347 const uint32_t axis,
5348 const uint32_t direction)
5351 CLOG_DEBUG(
LOG,
"axis_relative_direction (axis=%u, direction=%u)", axis, direction);
5353 if (
index == -1) [[unlikely]] {
5358 WL_POINTER_AXIS_RELATIVE_DIRECTION_INVERTED);
5373#ifdef WL_POINTER_AXIS_RELATIVE_DIRECTION_ENUM
5374 pointer_handle_axis_relative_direction,
5386#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
5387static CLG_LogRef LOG_WL_POINTER_GESTURE_HOLD = {
"ghost.wl.handle.pointer_gesture.hold"};
5388# define LOG (&LOG_WL_POINTER_GESTURE_HOLD)
5390static void gesture_hold_handle_begin(
5392 zwp_pointer_gesture_hold_v1 * ,
5396 const uint32_t fingers)
5401static void gesture_hold_handle_end(
void * ,
5402 zwp_pointer_gesture_hold_v1 * ,
5410static const zwp_pointer_gesture_hold_v1_listener gesture_hold_listener = {
5411 gesture_hold_handle_begin,
5412 gesture_hold_handle_end,
5424#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
5425static CLG_LogRef LOG_WL_POINTER_GESTURE_PINCH = {
"ghost.wl.handle.pointer_gesture.pinch"};
5426# define LOG (&LOG_WL_POINTER_GESTURE_PINCH)
5428static void gesture_pinch_handle_begin(
void *data,
5429 zwp_pointer_gesture_pinch_v1 * ,
5431 const uint32_t time,
5433 const uint32_t fingers)
5485static void gesture_pinch_handle_update(
void *data,
5486 zwp_pointer_gesture_pinch_v1 * ,
5487 const uint32_t time,
5488 const wl_fixed_t dx,
5489 const wl_fixed_t dy,
5490 const wl_fixed_t
scale,
5491 const wl_fixed_t rotation)
5497 "update (dx=%.3f, dy=%.3f, scale=%.3f, rotation=%.3f)",
5498 wl_fixed_to_double(dx),
5499 wl_fixed_to_double(dy),
5500 wl_fixed_to_double(
scale),
5501 wl_fixed_to_double(rotation));
5521 if (scale_as_delta_px) {
5523 std::make_unique<GHOST_EventTrackpad>(event_ms,
5533 if (rotation_as_delta_px) {
5535 std::make_unique<GHOST_EventTrackpad>(event_ms,
5540 rotation_as_delta_px,
5547static void gesture_pinch_handle_end(
void *data,
5548 zwp_pointer_gesture_pinch_v1 * ,
5550 const uint32_t time,
5559static const zwp_pointer_gesture_pinch_v1_listener gesture_pinch_listener = {
5560 gesture_pinch_handle_begin,
5561 gesture_pinch_handle_update,
5562 gesture_pinch_handle_end,
5579#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
5580static CLG_LogRef LOG_WL_POINTER_GESTURE_SWIPE = {
"ghost.wl.handle.pointer_gesture.swipe"};
5581# define LOG (&LOG_WL_POINTER_GESTURE_SWIPE)
5583static void gesture_swipe_handle_begin(
5585 zwp_pointer_gesture_swipe_v1 * ,
5594static void gesture_swipe_handle_update(
5596 zwp_pointer_gesture_swipe_v1 * ,
5601 CLOG_DEBUG(
LOG,
"update (dx=%.3f, dy=%.3f)", wl_fixed_to_double(dx), wl_fixed_to_double(dy));
5604static void gesture_swipe_handle_end(
5606 zwp_pointer_gesture_swipe_v1 * ,
5614static const zwp_pointer_gesture_swipe_v1_listener gesture_swipe_listener = {
5615 gesture_swipe_handle_begin,
5616 gesture_swipe_handle_update,
5617 gesture_swipe_handle_end,
5638#define LOG (&LOG_WL_TOUCH)
5640#ifdef WITH_GHOST_CSD
5646static void touch_seat_handle_down_csd_margin(
GWL_Seat *seat,
5647 const uint32_t serial,
5648 const uint32_t time,
5656 gwl_window_csd_margin_focus_set(seat, &seat->
touch, serial,
wl_surface);
5664 seat->
touch_state.motion_event_time_ms = event_ms;
5673 const uint32_t serial,
5674 const uint32_t time,
5685#ifdef WITH_GHOST_CSD
5686 if (ghost_wl_surface_own_csd_margin_with_null_check(surface)) {
5692 touch_seat_handle_down_csd_margin(seat, serial, time,
id, surface,
x,
y);
5724 seat->
touch_state.motion_event_time_ms = event_ms;
5736 void *data, wl_touch * ,
const uint32_t serial,
const uint32_t time,
const int32_t id)
5755 const uint32_t time,
5775 seat->
touch_state.motion_event_time_ms = event_ms;
5779#ifdef WITH_GHOST_CSD
5790 gwl_window_csd_margin_elem_motion(seat, win, seat->
touch.
xy);
5799 gwl_window_csd_active_elem_button(
5810 gwl_window_csd_active_elem_button(
5826#ifdef WITH_GHOST_CSD
5828 touch_seat_handle_frame_csd_margin(seat, wl_surface_focus);
5836 std::unique_ptr<GHOST_Event> touch_events[3];
5837 int touch_events_num = 0;
5842 touch_events[touch_events_num++] = std::make_unique<GHOST_EventCursor>(
5849#ifdef WITH_GHOST_CSD
5851 if (gwl_window_csd_active_elem_motion(seat, win, event_xy)) {
5865 touch_events[touch_events_num++] = std::make_unique<GHOST_EventButton>(
5872#ifdef WITH_GHOST_CSD
5874 const uint32_t serial = seat->
touch_state.down_event_serial;
5876 gwl_window_csd_active_elem_button(
5889 touch_events[touch_events_num++] = std::make_unique<GHOST_EventButton>(
5895#ifdef WITH_GHOST_CSD
5897 const uint32_t serial = seat->
touch_state.up_event_serial;
5899 gwl_window_csd_active_elem_button(
5906 seat->
touch.
wl.surface_window =
nullptr;
5912 if (touch_events_num > 1) [[unlikely]] {
5913 std::ranges::sort(std::span(touch_events, touch_events_num),
5914 [](
const std::unique_ptr<GHOST_Event> &event_a,
5915 const std::unique_ptr<GHOST_Event> &event_b) {
5916 return event_a->getTime() < event_b->getTime();
5920 for (
int i = 0; i < touch_events_num; i++) {
5930#ifdef WITH_GHOST_CSD
5937 gwl_window_csd_margin_focus_clear(&seat->
touch, wl_surface_focus);
5981#define LOG (&LOG_WL_TABLET_TOOL)
5984 zwp_tablet_tool_v2 * ,
5985 const uint32_t tool_type)
5995 zwp_tablet_tool_v2 * ,
6003 zwp_tablet_tool_v2 * ,
6011 zwp_tablet_tool_v2 * ,
6012 const uint32_t capability)
6015 "capability (tilt=%d, distance=%d, rotation=%d, slider=%d, wheel=%d)",
6016 (capability & ZWP_TABLET_TOOL_V2_CAPABILITY_TILT) != 0,
6017 (capability & ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE) != 0,
6018 (capability & ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION) != 0,
6019 (capability & ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER) != 0,
6020 (capability & ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL) != 0);
6034 if (tablet_tool->
wl.surface_cursor) {
6035 wl_surface_destroy(tablet_tool->
wl.surface_cursor);
6038 wp_cursor_shape_device_v1_destroy(tablet_tool->
shape.
device);
6040 seat->
wp.tablet_tools.erase(zwp_tablet_tool_v2);
6044#ifdef WITH_GHOST_CSD
6050static void tablet_tool_handle_proximity_in_csd_margin(
GWL_TabletTool *tablet_tool,
6051 const uint32_t serial,
6066 zwp_tablet_tool_v2 * ,
6067 const uint32_t serial,
6073#ifdef WITH_GHOST_CSD
6074 if (ghost_wl_surface_own_csd_margin_with_null_check(
wl_surface)) {
6076 tablet_tool_handle_proximity_in_csd_margin(tablet_tool, serial,
wl_surface);
6088 tablet_tool->
serial = serial;
6111 zwp_tablet_tool_v2 * )
6122 zwp_tablet_tool_v2 * ,
6123 const uint32_t serial)
6146 zwp_tablet_tool_v2 * ,
6154 tablet_tool->
xy[0] =
x;
6155 tablet_tool->
xy[1] =
y;
6156 tablet_tool->
has_xy =
true;
6162 zwp_tablet_tool_v2 * ,
6163 const uint32_t pressure)
6165 const float pressure_unit =
float(pressure) / 65535;
6177 zwp_tablet_tool_v2 * ,
6184 zwp_tablet_tool_v2 * ,
6185 const wl_fixed_t tilt_x,
6186 const wl_fixed_t tilt_y)
6190 const float tilt_unit[2] = {
6191 float(wl_fixed_to_double(tilt_x) / 90.0f),
6192 float(wl_fixed_to_double(tilt_y) / 90.0f),
6197 td.
Xtilt = std::clamp(tilt_unit[0], -1.0f, 1.0f);
6198 td.
Ytilt = std::clamp(tilt_unit[1], -1.0f, 1.0f);
6204 zwp_tablet_tool_v2 * ,
6211 zwp_tablet_tool_v2 * ,
6217 zwp_tablet_tool_v2 * ,
6235 zwp_tablet_tool_v2 * ,
6236 const uint32_t serial,
6237 const uint32_t button,
6238 const uint32_t
state)
6245 bool is_press =
false;
6247 case WL_POINTER_BUTTON_STATE_RELEASED: {
6251 case WL_POINTER_BUTTON_STATE_PRESSED: {
6282#ifdef WITH_GHOST_CSD
6288static void tablet_tool_handle_frame_csd_margin(
GWL_TabletTool *tablet_tool,
6295 for (
int ty_index = 0; ty_index < tablet_tool->
frame_pending.frame_types_num; ty_index++) {
6302 if (tablet_tool->
has_xy ==
false) {
6308 gwl_window_csd_margin_elem_motion(seat, win, tablet_tool->
xy);
6329 const int button_enum_offset = int(ty) - int(Stylus0_Down);
6330 const int button_index = button_enum_offset / 2;
6331 const bool button_down = (button_index * 2) == button_enum_offset;
6334 "Button down events must have a serial");
6335 gwl_window_csd_active_elem_button(seat, win, ebutton, button_down, serial, event_ms);
6344 zwp_tablet_tool_v2 * ,
6345 const uint32_t time)
6353#ifdef WITH_GHOST_CSD
6355 tablet_tool_handle_frame_csd_margin(tablet_tool, wl_surface_focus, event_ms);
6357 gwl_window_csd_margin_focus_clear(&seat->
tablet, wl_surface_focus);
6367 bool has_motion =
false;
6369 for (
int ty_index = 0; ty_index < tablet_tool->
frame_pending.frame_types_num; ty_index++) {
6371#ifdef WITH_GHOST_CSD
6372 const uint32_t serial = tablet_tool->
frame_pending.frame_serial[ty_index];
6385 if (tablet_tool->
has_xy ==
false) {
6397#ifdef WITH_GHOST_CSD
6399 if (gwl_window_csd_active_elem_motion(seat, win, event_xy)) {
6419 const int button_enum_offset = int(ty) - int(
Stylus0_Down);
6420 const int button_index = button_enum_offset / 2;
6421 const bool button_down = (button_index * 2) == button_enum_offset;
6427 event_ms, etype, win, ebutton, tablet_tool->
data));
6429#ifdef WITH_GHOST_CSD
6431 "Button down events must have a serial");
6433 gwl_window_csd_active_elem_button(seat, win, ebutton, button_down, serial, event_ms);
6440 std::make_unique<GHOST_EventWheel>(event_ms,
6455 seat->
tablet.
wl.surface_window =
nullptr;
6492#define LOG (&LOG_WL_TABLET_SEAT)
6495 zwp_tablet_seat_v2 * ,
6502 zwp_tablet_seat_v2 * ,
6503 zwp_tablet_tool_v2 *
id)
6509 tablet_tool->
seat = seat;
6515 wl_surface_add_listener(
6520 seat->
wp.tablet_tools.insert(
id);
6524 zwp_tablet_seat_v2 * ,
6525 zwp_tablet_pad_v2 *
id)
6545#define LOG (&LOG_WL_KEYBOARD)
6549 const uint32_t format,
6551 const uint32_t
size)
6553 if ((!data) || (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)) {
6561 char *map_str =
static_cast<char *
>(mmap(
nullptr,
size, PROT_READ, MAP_PRIVATE, fd, 0));
6562 if (map_str == MAP_FAILED) {
6564 CLOG_DEBUG(
LOG,
"keymap mmap failed: %s", std::strerror(errno));
6568 xkb_keymap *keymap = xkb_keymap_new_from_string(
6569 seat->
xkb.context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
6570 munmap(map_str,
size);
6585 seat->
xkb.layout_active = 0;
6587 if (seat->
xkb.compose_state) {
6588 xkb_compose_state_reset(seat->
xkb.compose_state);
6590 else if (seat->
xkb.compose_table) {
6591 seat->
xkb.compose_state = xkb_compose_state_new(seat->
xkb.compose_table,
6592 XKB_COMPOSE_STATE_NO_FLAGS);
6596 xkb_state_unref(seat->
xkb.state);
6597 seat->
xkb.state = xkb_state_new(keymap);
6599 xkb_state_unref(seat->
xkb.state_empty);
6600 seat->
xkb.state_empty = xkb_state_new(keymap);
6609 xkb_state_unref(seat->
xkb.state_empty_with_shift);
6610 seat->
xkb.state_empty_with_shift =
nullptr;
6612 seat->
xkb.state_empty_with_shift = xkb_state_new(keymap);
6615 xkb_state_unref(seat->
xkb.state_empty_with_numlock);
6616 seat->
xkb.state_empty_with_numlock =
nullptr;
6620 seat->
xkb.state_empty_with_numlock = xkb_state_new(keymap);
6627 xkb_keymap_unref(keymap);
6637 const uint32_t serial,
6664 uint32_t key = std::numeric_limits<uint32_t>::max();
6665 xkb_keysym_t sym = 0;
6673 seat->
xkb.state, key_code, seat->
xkb.layout_fallback);
6679 if (xkb_keymap_key_repeats(xkb_state_get_keymap(seat->
xkb.state), key_code)) {
6689 if ((repeat.key != std::numeric_limits<uint32_t>::max()) && (seat->
key_repeat.rate > 0)) {
6692#ifdef USE_EVENT_BACKGROUND_THREAD
6700 const xkb_keycode_t key_code = repeat.key +
EVDEV_OFFSET;
6704 key_repeat_payload->
seat = seat;
6705 key_repeat_payload->
key_code = key_code;
6706 key_repeat_payload->
key_data.gkey = gkey;
6735#ifdef USE_EVENT_BACKGROUND_THREAD
6750 xkb_state *xkb_state_empty,
6751 xkb_state *xkb_state_empty_with_numlock,
6752 xkb_state *xkb_state_empty_with_shift,
6753 const xkb_layout_index_t layout_fallback,
6754 const bool xkb_use_non_latin_workaround,
6755 const xkb_keycode_t key)
6758 xkb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state_empty, key);
6768 if (sym >= XKB_KEY_KP_Home && sym <= XKB_KEY_KP_Delete) {
6769 if (xkb_state_empty_with_numlock) {
6770 const xkb_keysym_t sym_test = xkb_state_key_get_one_sym(xkb_state_empty_with_numlock, key);
6771 if (sym_test != XKB_KEY_NoSymbol) {
6777#ifdef USE_NON_LATIN_KB_WORKAROUND
6779 if (xkb_state_empty_with_shift && xkb_use_non_latin_workaround) {
6780 const xkb_keysym_t sym_test = xkb_state_key_get_one_sym(xkb_state_empty_with_shift, key);
6781 if (sym_test != XKB_KEY_NoSymbol) {
6783 GHOST_ASSERT(sym_test >= XKB_KEY_0 && sym_test <= XKB_KEY_9,
"Unexpected key");
6789 (void)xkb_state_empty_with_shift;
6790 (void)xkb_use_non_latin_workaround;
6797 sym, xkb_state_get_keymap(xkb_state_empty), key, layout_fallback);
6801 xkb_compose_state *compose_state,
6803 const xkb_keycode_t key,
6806 const xkb_keysym_t sym = xkb_state_key_get_one_sym(
state, key);
6807 const xkb_compose_feed_result result = xkb_compose_state_feed(compose_state, sym);
6808 bool handled =
false;
6810 if (result == XKB_COMPOSE_FEED_ACCEPTED) {
6811 switch (xkb_compose_state_get_status(compose_state)) {
6812 case XKB_COMPOSE_NOTHING: {
6815 case XKB_COMPOSE_COMPOSING: {
6816 r_utf8_buf[0] =
'\0';
6820 case XKB_COMPOSE_COMPOSED: {
6822 const int utf8_buf_compose_len = xkb_compose_state_get_utf8(
6823 compose_state, utf8_buf_compose,
sizeof(utf8_buf_compose));
6824 if (utf8_buf_compose_len > 0) {
6836 CLOG_WARN(
LOG,
"key (compose_size=%d) exceeds the maximum size", utf8_buf_compose_len);
6843 case XKB_COMPOSE_CANCELLED: {
6849 r_utf8_buf[0] =
'\0';
6888 const uint32_t serial,
6889 const uint32_t time,
6891 const uint32_t
state)
6899 seat->
xkb.state_empty,
6900 seat->
xkb.state_empty_with_numlock,
6901 seat->
xkb.state_empty_with_shift,
6902 seat->
xkb.layout_fallback,
6909 if (sym == XKB_KEY_NoSymbol) {
6910 CLOG_DEBUG(
LOG,
"key (code=%d, state=%u, no symbol, skipped)",
int(key_code),
state);
6916 bool is_repeat =
false;
6918 case WL_KEYBOARD_KEY_STATE_RELEASED: {
6922#ifdef WL_KEYBOARD_KEY_STATE_REPEATED_SINCE_VERSION
6923 case WL_KEYBOARD_KEY_STATE_REPEATED: {
6929 case WL_KEYBOARD_KEY_STATE_PRESSED: {
6935#ifdef USE_EVENT_BACKGROUND_THREAD
6944 enum { NOP = 1, RESET, CANCEL } timer_action = NOP;
6950 timer_action = CANCEL;
6952 else if (key_code == key_repeat_payload->
key_code) {
6954 timer_action = CANCEL;
6956 else if (xkb_keymap_key_repeats(xkb_state_get_keymap(seat->
xkb.state), key_code)) {
6959 timer_action = CANCEL;
6967 timer_action = RESET;
6971 switch (timer_action) {
6974 key_repeat_payload =
nullptr;
6983 delete key_repeat_payload;
6984 key_repeat_payload =
nullptr;
6996 if (seat->
xkb.compose_state &&
6998 seat->
xkb.compose_state, seat->
xkb.state, key_code, utf8_buf))
7003 xkb_state_key_get_utf8(seat->
xkb.state, key_code, utf8_buf,
sizeof(utf8_buf));
7014 std::make_unique<GHOST_EventKey>(event_ms, etype, win, gkey, is_repeat, utf8_buf));
7018 if (key_repeat_payload ==
nullptr) {
7021 xkb_keymap_key_repeats(xkb_state_get_keymap(seat->
xkb.state), key_code))
7024 key_repeat_payload->
seat = seat;
7025 key_repeat_payload->
key_code = key_code;
7026 key_repeat_payload->
key_data.gkey = gkey;
7030 if (key_repeat_payload) {
7037 const uint32_t serial,
7038 const uint32_t mods_depressed,
7039 const uint32_t mods_latched,
7040 const uint32_t mods_locked,
7041 const uint32_t group)
7044 "modifiers (depressed=%u, latched=%u, locked=%u, group=%u)",
7051 xkb_state_update_mask(seat->
xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group);
7055 if (group != seat->
xkb.layout_active) {
7056 seat->
xkb.layout_active = group;
7063#ifdef USE_EVENT_BACKGROUND_THREAD
7082#ifdef USE_EVENT_BACKGROUND_THREAD
7118#define LOG (&LOG_WL_PRIMARY_SELECTION_OFFER)
7121 zwp_primary_selection_offer_v1 *
id,
7126 if (data_offer->
wp.id !=
id) {
7127 CLOG_DEBUG(
LOG,
"offer: %p: offer for unknown selection %p of %s (skipped)", data,
id, type);
7131 data_offer->
types.insert(std::string(type));
7147#define LOG (&LOG_WL_PRIMARY_SELECTION_DEVICE)
7151 zwp_primary_selection_device_v1 * ,
7152 zwp_primary_selection_offer_v1 *
id)
7157 data_offer->
wp.id = id;
7163 zwp_primary_selection_device_v1 * ,
7164 zwp_primary_selection_offer_v1 *
id)
7175 if (
id ==
nullptr) {
7182 zwp_primary_selection_offer_v1_get_user_data(
id));
7200#define LOG (&LOG_WL_PRIMARY_SELECTION_SOURCE)
7203 zwp_primary_selection_source_v1 * ,
7216 CLOG_WARN(
LOG,
"error writing to primary clipboard: %s", std::strerror(errno));
7223 std::thread write_thread(write_file_fn, primary, fd);
7224 write_thread.detach();
7252#ifdef WITH_INPUT_IME
7256 GHOST_TEventImeData event_ime_data;
7268 GHOST_IWindow *window,
7269 const GHOST_TEventImeData *customdata)
7270 : GHOST_Event(msec, type, window)
7274 this->event_ime_data = *customdata;
7275 this->data_ = &this->event_ime_data;
7279static CLG_LogRef LOG_WL_TEXT_INPUT = {
"ghost.wl.handle.text_input"};
7280# define LOG (&LOG_WL_TEXT_INPUT)
7282static void text_input_handle_enter(
void *data,
7283 zwp_text_input_v3 * ,
7292 seat->ime.surface_window = surface;
7295 if (seat->ime.is_enabled) {
7296 zwp_text_input_v3_enable(seat->
wp.text_input);
7297 zwp_text_input_v3_commit(seat->
wp.text_input);
7301static void text_input_handle_leave(
void *data,
7302 zwp_text_input_v3 * ,
7311 if (seat->ime.surface_window == surface) {
7312 seat->ime.surface_window =
nullptr;
7315 zwp_text_input_v3_disable(seat->
wp.text_input);
7316 zwp_text_input_v3_commit(seat->
wp.text_input);
7319static void text_input_handle_preedit_string(
void *data,
7320 zwp_text_input_v3 * ,
7326 "preedit_string (text=\"%s\", cursor_begin=%d, cursor_end=%d)",
7327 text ? text :
"<null>",
7332 if (seat->ime.has_preedit ==
false) {
7334 gwl_seat_ime_full_reset(seat);
7337 seat->ime.composite_is_null = (text ==
nullptr);
7338 if (!seat->ime.composite_is_null) {
7339 seat->ime.event_ime_data.composite = text;
7341 seat->ime.event_ime_data.cursor_position = cursor_begin;
7342 seat->ime.event_ime_data.target_start = cursor_begin;
7343 seat->ime.event_ime_data.target_end = cursor_end;
7346 seat->ime.has_preedit_string_callback =
true;
7349static void text_input_handle_commit_string(
void *data,
7350 zwp_text_input_v3 * ,
7353 CLOG_DEBUG(
LOG,
"commit_string (text=\"%s\")", text ? text :
"<null>");
7356 seat->ime.result_is_null = (text ==
nullptr);
7357 seat->ime.event_ime_data.result = text ? text :
"";
7358 seat->ime.event_ime_data.cursor_position = seat->ime.event_ime_data.result.size();
7360 seat->ime.has_commit_string_callback =
true;
7363static void text_input_handle_delete_surrounding_text(
void * ,
7364 zwp_text_input_v3 * ,
7365 const uint32_t before_length,
7366 const uint32_t after_length)
7369 "delete_surrounding_text (before_length=%u, after_length=%u)",
7377static void text_input_handle_done(
void *data,
7378 zwp_text_input_v3 * ,
7390 if (seat->ime.has_commit_string_callback) {
7391 if (seat->ime.has_preedit) {
7392 const bool is_end = seat->ime.composite_is_null;
7394 seat->ime.has_preedit =
false;
7417 if (seat->ime.has_preedit ==
false) {
7418 gwl_seat_ime_preedit_reset(seat);
7421 else if (seat->ime.has_preedit_string_callback) {
7422 const bool is_end = seat->ime.composite_is_null;
7425 seat->ime.has_preedit =
false;
7430 const bool is_start = seat->ime.has_preedit ==
false;
7432 seat->ime.has_preedit =
true;
7437 &seat->ime.event_ime_data));
7441 seat->ime.has_preedit_string_callback =
false;
7442 seat->ime.has_commit_string_callback =
false;
7445static zwp_text_input_v3_listener text_input_listener = {
7446 text_input_handle_enter,
7447 text_input_handle_leave,
7448 text_input_handle_preedit_string,
7449 text_input_handle_commit_string,
7450 text_input_handle_delete_surrounding_text,
7451 text_input_handle_done,
7465#define LOG (&LOG_WL_SEAT)
7470 if (pointer_gestures ==
nullptr) {
7475#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
7476 if (seat->
wp.pointer_gesture_hold) {
7481#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
7487#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
7488 if (seat->
wp.pointer_gesture_swipe) {
7497 if (found ==
false) {
7510 if (pointer_gestures ==
nullptr) {
7514 const uint pointer_gestures_version = zwp_pointer_gestures_v1_get_version(pointer_gestures);
7515#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
7516 if (pointer_gestures_version >= ZWP_POINTER_GESTURES_V1_GET_HOLD_GESTURE_SINCE_VERSION)
7519 zwp_pointer_gesture_hold_v1 *gesture = zwp_pointer_gestures_v1_get_hold_gesture(
7521 zwp_pointer_gesture_hold_v1_set_user_data(gesture, seat);
7522 zwp_pointer_gesture_hold_v1_add_listener(gesture, &gesture_hold_listener, seat);
7523 seat->
wp.pointer_gesture_hold = gesture;
7526#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
7528 zwp_pointer_gesture_pinch_v1 *gesture = zwp_pointer_gestures_v1_get_pinch_gesture(
7530 zwp_pointer_gesture_pinch_v1_set_user_data(gesture, seat);
7531 zwp_pointer_gesture_pinch_v1_add_listener(gesture, &gesture_pinch_listener, seat);
7535#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
7537 zwp_pointer_gesture_swipe_v1 *gesture = zwp_pointer_gestures_v1_get_swipe_gesture(
7539 zwp_pointer_gesture_swipe_v1_set_user_data(gesture, seat);
7540 zwp_pointer_gesture_swipe_v1_add_listener(gesture, &gesture_swipe_listener, seat);
7541 seat->
wp.pointer_gesture_swipe = gesture;
7555 if (pointer_gestures ==
nullptr) {
7558#ifdef ZWP_POINTER_GESTURE_HOLD_V1_INTERFACE
7560 zwp_pointer_gesture_hold_v1 **gesture_p = &seat->
wp.pointer_gesture_hold;
7562 zwp_pointer_gesture_hold_v1_destroy(*gesture_p);
7563 *gesture_p =
nullptr;
7567#ifdef ZWP_POINTER_GESTURE_PINCH_V1_INTERFACE
7571 zwp_pointer_gesture_pinch_v1_destroy(*gesture_p);
7572 *gesture_p =
nullptr;
7576#ifdef ZWP_POINTER_GESTURE_SWIPE_V1_INTERFACE
7578 zwp_pointer_gesture_swipe_v1 **gesture_p = &seat->
wp.pointer_gesture_swipe;
7580 zwp_pointer_gesture_swipe_v1_destroy(*gesture_p);
7581 *gesture_p =
nullptr;
7592 seat->
wl.
pointer = wl_seat_get_pointer(seat->
wl.seat);
7624 if (seat->
cursor.
wl.surface_cursor) {
7625 wl_surface_destroy(seat->
cursor.
wl.surface_cursor);
7626 seat->
cursor.
wl.surface_cursor =
nullptr;
7638 seat->
wl.
keyboard = wl_seat_get_keyboard(seat->
wl.seat);
7649#ifdef USE_EVENT_BACKGROUND_THREAD
7665 seat->
wl.
touch = wl_seat_get_touch(seat->
wl.seat);
7666 wl_touch_set_user_data(seat->
wl.
touch, seat);
7675 wl_touch_destroy(seat->
wl.
touch);
7681 [[maybe_unused]] wl_seat *wl_seat,
7682 const uint32_t capabilities)
7685 "capabilities (pointer=%d, keyboard=%d, touch=%d)",
7686 (capabilities & WL_SEAT_CAPABILITY_POINTER) != 0,
7687 (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) != 0,
7688 (capabilities & WL_SEAT_CAPABILITY_TOUCH) != 0);
7693 if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
7700 if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
7707 if (capabilities & WL_SEAT_CAPABILITY_TOUCH) {
7718 static_cast<GWL_Seat *
>(data)->name = std::string(name);
7735#define LOG (&LOG_WL_XDG_OUTPUT)
7745 output->position_logical[0] =
x;
7746 output->position_logical[1] =
y;
7747 output->has_position_logical =
true;
7758 if (
output->size_native[0] != 0 &&
output->size_native[1] != 0) {
7766 int width_native =
output->size_native[(
output->transform & WL_OUTPUT_TRANSFORM_90) ? 1 : 0];
7768 GHOST_PRINT(
"xdg_output scale did not match, overriding with wl_output scale\n");
7770#ifdef USE_GNOME_CONFINE_HACK
7779 output->size_logical[0] = width;
7780 output->size_logical[1] = height;
7781 output->has_size_logical =
true;
7790 if (zxdg_output_v1_get_version(
output->xdg.output) < 3) {
7804 const char *description)
7806 CLOG_DEBUG(
LOG,
"description (description=\"%s\")", description);
7826#define LOG (&LOG_WL_OUTPUT)
7833 const int32_t physical_height,
7840 "geometry (make=\"%s\", model=\"%s\", transform=%d, size=[%d, %d])",
7849 output->make = std::string(make);
7850 output->model = std::string(model);
7851 output->size_mm[0] = physical_width;
7852 output->size_mm[1] = physical_height;
7857 const uint32_t flags,
7862 if ((flags & WL_OUTPUT_MODE_CURRENT) == 0) {
7866 CLOG_DEBUG(
LOG,
"mode (size=[%d, %d], flags=%u)", width, height, flags);
7869 output->size_native[0] = width;
7870 output->size_native[1] = height;
7887 if (
output->transform & WL_OUTPUT_TRANSFORM_90) {
7888 std::swap(size_native[0], size_native[1]);
7892 if (
output->has_size_logical) {
7898 "Screen size values were not set when they were expected to be.");
7901 output->has_scale_fractional =
true;
7920 const char *description)
7944 wp_color_manager_v1 * ,
7945 uint32_t render_intent)
7952 wp_color_manager_v1 * ,
7959 wp_color_manager_v1 * ,
7966 void *data, wp_color_manager_v1 * , uint32_t primaries)
7975 if (cm_data->
supported_intents.contains(WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL) &&
7984 if (cm_data->
supported_intents.contains(WP_COLOR_MANAGER_V1_RENDER_INTENT_PERCEPTUAL) &&
8010#define LOG (&LOG_WL_XDG_WM_BASE)
8015 xdg_wm_base_pong(xdg_wm_base, serial);
8031#define LOG (&LOG_WL_REGISTRY)
8039 display->
wl.compositor =
static_cast<wl_compositor *
>(
8040 wl_registry_bind(display->
wl.registry, params.
name, &wl_compositor_interface, version));
8047 wl_compositor **value_p = &display->
wl.compositor;
8048 wl_compositor_destroy(*value_p);
8059 display->
wl.subcompositor =
static_cast<wl_subcompositor *
>(
8060 wl_registry_bind(display->
wl.registry, params.
name, &wl_subcompositor_interface, version));
8067 wl_subcompositor **value_p = &display->
wl.subcompositor;
8068 wl_subcompositor_destroy(*value_p);
8080 decor.
shell =
static_cast<xdg_wm_base *
>(
8081 wl_registry_bind(display->
wl.registry, params.
name, &xdg_wm_base_interface, version));
8091 xdg_wm_base **value_p = &decor.
shell;
8093 xdg_wm_base_destroy(*value_p);
8106 decor.
manager =
static_cast<zxdg_decoration_manager_v1 *
>(wl_registry_bind(
8107 display->
wl.registry, params.
name, &zxdg_decoration_manager_v1_interface, version));
8116 zxdg_decoration_manager_v1 **value_p = &decor.
manager;
8118 zxdg_decoration_manager_v1_destroy(*value_p);
8133 display->
xdg.output_manager =
static_cast<zxdg_output_manager_v1 *
>(wl_registry_bind(
8134 display->
wl.registry, params.
name, &zxdg_output_manager_v1_interface, version));
8141 zxdg_output_manager_v1 **value_p = &display->
xdg.output_manager;
8142 zxdg_output_manager_v1_destroy(*value_p);
8154 output->wl.output =
static_cast<wl_output *
>(
8155 wl_registry_bind(display->
wl.registry, params.
name, &wl_output_interface, version));
8167 if (display->
xdg.output_manager) {
8168 if (
output->xdg.output ==
nullptr) {
8169 output->xdg.output = zxdg_output_manager_v1_get_xdg_output(display->
xdg.output_manager,
8175 output->xdg.output =
nullptr;
8194 "mis-behaving compositor failed to call \"surface_listener.leave\" "
8195 "window scale may be invalid!");
8199 if (
output->xdg.output) {
8200 zxdg_output_v1_destroy(
output->xdg.output);
8202 wl_output_destroy(
output->wl.output);
8205 "invalid internal state");
8217 data->display = display;
8219 display->
wp.color_manager =
static_cast<wp_color_manager_v1 *
>(wl_registry_bind(
8220 display->
wl.registry, params.
name, &wp_color_manager_v1_interface, version));
8229 if (display->
wp.color_manager_queue) {
8231 display->
wp.color_manager_queue =
nullptr;
8233 wp_color_manager_v1 **value_p = &display->
wp.color_manager;
8234 wp_color_manager_v1_destroy(*value_p);
8246 seat->
xkb.context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
8249 seat->
xkb.compose_table = xkb_compose_table_new_from_locale(
8253 seat->
wl.seat =
static_cast<wl_seat *
>(
8254 wl_registry_bind(display->
wl.registry, params.
name, &wl_seat_interface, version));
8255 display->
seats.push_back(seat);
8267 if (display->
wl.data_device_manager) {
8268 if (seat->
wl.data_device ==
nullptr) {
8269 seat->
wl.data_device = wl_data_device_manager_get_data_device(
8270 display->
wl.data_device_manager, seat->
wl.seat);
8275 seat->
wl.data_device =
nullptr;
8278 if (display->
wp.tablet_manager) {
8279 if (seat->
wp.tablet_seat ==
nullptr) {
8280 seat->
wp.tablet_seat = zwp_tablet_manager_v2_get_tablet_seat(display->
wp.tablet_manager,
8286 seat->
wp.tablet_seat =
nullptr;
8289 if (display->
wp.primary_selection_device_manager) {
8290 if (seat->
wp.primary_selection_device ==
nullptr) {
8291 seat->
wp.primary_selection_device = zwp_primary_selection_device_manager_v1_get_device(
8292 display->
wp.primary_selection_device_manager, seat->
wl.seat);
8294 zwp_primary_selection_device_v1_add_listener(seat->
wp.primary_selection_device,
8300 seat->
wp.primary_selection_device =
nullptr;
8303#ifdef WITH_INPUT_IME
8304 if (display->
wp.text_input_manager) {
8305 if (seat->
wp.text_input ==
nullptr) {
8306 seat->
wp.text_input = zwp_text_input_manager_v3_get_text_input(
8307 display->
wp.text_input_manager, seat->
wl.seat);
8308 zwp_text_input_v3_set_user_data(seat->
wp.text_input, seat);
8309 zwp_text_input_v3_add_listener(seat->
wp.text_input, &text_input_listener, seat);
8313 seat->
wp.text_input =
nullptr;
8362 if (seat->
wp.primary_selection_device) {
8363 zwp_primary_selection_device_v1_destroy(seat->
wp.primary_selection_device);
8366#ifdef WITH_INPUT_IME
8367 if (seat->
wp.text_input) {
8368 zwp_text_input_v3_destroy(seat->
wp.text_input);
8372 if (seat->
wl.data_device) {
8373 wl_data_device_release(seat->
wl.data_device);
8376 if (seat->
wp.tablet_seat) {
8377 zwp_tablet_seat_v2_destroy(seat->
wp.tablet_seat);
8396 wl_buffer_destroy(seat->
cursor.
wl.buffer);
8404 xkb_state_unref(seat->
xkb.state);
8405 xkb_state_unref(seat->
xkb.state_empty);
8406 xkb_state_unref(seat->
xkb.state_empty_with_shift);
8407 xkb_state_unref(seat->
xkb.state_empty_with_numlock);
8409 xkb_compose_state_unref(seat->
xkb.compose_state);
8410 xkb_compose_table_unref(seat->
xkb.compose_table);
8412 xkb_context_unref(seat->
xkb.context);
8415 wl_seat_destroy(seat->
wl.seat);
8417 const auto iter = std::ranges::find(display->
seats, seat);
8421 const int index = int(iter - display->
seats.begin());
8425 display->
seats.erase(iter);
8436 display->
wl.shm =
static_cast<wl_shm *
>(
8437 wl_registry_bind(display->
wl.registry, params.
name, &wl_shm_interface, version));
8444 wl_shm **value_p = &display->
wl.shm;
8445 wl_shm_destroy(*value_p);
8456 display->
wl.data_device_manager =
static_cast<wl_data_device_manager *
>(wl_registry_bind(
8457 display->
wl.registry, params.
name, &wl_data_device_manager_interface, version));
8464 wl_data_device_manager **value_p = &display->
wl.data_device_manager;
8465 wl_data_device_manager_destroy(*value_p);
8476 display->
wp.tablet_manager =
static_cast<zwp_tablet_manager_v2 *
>(wl_registry_bind(
8477 display->
wl.registry, params.
name, &zwp_tablet_manager_v2_interface, version));
8484 zwp_tablet_manager_v2 **value_p = &display->
wp.tablet_manager;
8485 zwp_tablet_manager_v2_destroy(*value_p);
8496 display->
wp.relative_pointer_manager =
static_cast<zwp_relative_pointer_manager_v1 *
>(
8498 display->
wl.registry, params.
name, &zwp_relative_pointer_manager_v1_interface, version));
8505 zwp_relative_pointer_manager_v1 **value_p = &display->
wp.relative_pointer_manager;
8506 zwp_relative_pointer_manager_v1_destroy(*value_p);
8517 display->
wp.pointer_constraints =
static_cast<zwp_pointer_constraints_v1 *
>(wl_registry_bind(
8518 display->
wl.registry, params.
name, &zwp_pointer_constraints_v1_interface, version));
8525 zwp_pointer_constraints_v1 **value_p = &display->
wp.pointer_constraints;
8526 zwp_pointer_constraints_v1_destroy(*value_p);
8537 display->
wp.pointer_gestures =
static_cast<zwp_pointer_gestures_v1 *
>(
8538 wl_registry_bind(display->
wl.registry,
8540 &zwp_pointer_gestures_v1_interface,
8541 std::min(params.
version, version)));
8548 zwp_pointer_gestures_v1 **value_p = &display->
wp.pointer_gestures;
8549 zwp_pointer_gestures_v1_destroy(*value_p);
8560 display->
xdg.activation_manager =
static_cast<xdg_activation_v1 *
>(
8561 wl_registry_bind(display->
wl.registry, params.
name, &xdg_activation_v1_interface, version));
8568 xdg_activation_v1 **value_p = &display->
xdg.activation_manager;
8569 xdg_activation_v1_destroy(*value_p);
8576 xdg_toplevel_icon_manager_v1 * ,
8581 if (
size > display->
xdg.toplevel_icon_logical_size_max) {
8582 display->
xdg.toplevel_icon_logical_size_max =
size;
8587 xdg_toplevel_icon_manager_v1 * )
8601 display->
xdg.toplevel_icon_manager =
static_cast<xdg_toplevel_icon_manager_v1 *
>(
8603 display->
wl.registry, params.
name, &xdg_toplevel_icon_manager_v1_interface, version));
8604 xdg_toplevel_icon_manager_v1_add_listener(
8612 xdg_toplevel_icon_manager_v1 **value_p = &display->
xdg.toplevel_icon_manager;
8613 xdg_toplevel_icon_manager_v1_destroy(*value_p);
8624 display->
wp.fractional_scale_manager =
static_cast<wp_fractional_scale_manager_v1 *
>(
8626 display->
wl.registry, params.
name, &wp_fractional_scale_manager_v1_interface, version));
8633 wp_fractional_scale_manager_v1 **value_p = &display->
wp.fractional_scale_manager;
8634 wp_fractional_scale_manager_v1_destroy(*value_p);
8645 display->
wp.viewporter =
static_cast<wp_viewporter *
>(
8646 wl_registry_bind(display->
wl.registry, params.
name, &wp_viewporter_interface, version));
8653 wp_viewporter **value_p = &display->
wp.viewporter;
8654 wp_viewporter_destroy(*value_p);
8665 display->
wp.primary_selection_device_manager =
8666 static_cast<zwp_primary_selection_device_manager_v1 *
>(
8667 wl_registry_bind(display->
wl.registry,
8669 &zwp_primary_selection_device_manager_v1_interface,
8677 zwp_primary_selection_device_manager_v1 **value_p =
8678 &display->
wp.primary_selection_device_manager;
8679 zwp_primary_selection_device_manager_v1_destroy(*value_p);
8683#ifdef WITH_INPUT_IME
8687static void gwl_registry_wp_text_input_manager_add(
GWL_Display *display,
8692 display->
wp.text_input_manager =
static_cast<zwp_text_input_manager_v3 *
>(wl_registry_bind(
8693 display->
wl.registry, params.
name, &zwp_text_input_manager_v3_interface, version));
8696static void gwl_registry_wp_text_input_manager_remove(
GWL_Display *display,
8700 zwp_text_input_manager_v3 **value_p = &display->
wp.text_input_manager;
8701 zwp_text_input_manager_v3_destroy(*value_p);
8714 display->
wp.cursor_shape_manager =
static_cast<wp_cursor_shape_manager_v1 *
>(wl_registry_bind(
8715 display->
wl.registry, params.
name, &wp_cursor_shape_manager_v1_interface, version));
8722 wp_cursor_shape_manager_v1 **value_p = &display->
wp.cursor_shape_manager;
8723 wp_cursor_shape_manager_v1_destroy(*value_p);
8740 &wl_compositor_interface.name,
8746 &wl_subcompositor_interface.name,
8752 &wl_shm_interface.name,
8758 &xdg_wm_base_interface.name,
8765 &zxdg_decoration_manager_v1_interface.name,
8771 &zxdg_output_manager_v1_interface.name,
8777 &wl_data_device_manager_interface.name,
8783 &zwp_primary_selection_device_manager_v1_interface.name,
8789 &zwp_tablet_manager_v2_interface.name,
8795 &zwp_relative_pointer_manager_v1_interface.name,
8800#ifdef WITH_INPUT_IME
8802 &zwp_text_input_manager_v3_interface.name,
8803 gwl_registry_wp_text_input_manager_add,
8805 gwl_registry_wp_text_input_manager_remove,
8809 &wp_cursor_shape_manager_v1_interface.name,
8816 &zwp_pointer_constraints_v1_interface.name,
8822 &zwp_pointer_gestures_v1_interface.name,
8828 &xdg_activation_v1_interface.name,
8834 &xdg_toplevel_icon_manager_v1_interface.name,
8840 &wp_fractional_scale_manager_v1_interface.name,
8846 &wp_viewporter_interface.name,
8853 &wl_output_interface.name,
8859 &wp_color_manager_v1_interface.name,
8868 &wl_seat_interface.name,
8891 if (
STREQ(interface, *handler->interface_p)) {
8901 "Index out of range");
8906 [[maybe_unused]] wl_registry *wl_registry,
8907 const uint32_t name,
8908 const char *interface,
8909 const uint32_t version)
8913 GHOST_ASSERT(display->
wl.registry == wl_registry,
"Registry argument must match!");
8918 if (interface_slot != -1) {
8928 handler->
add_fn(display, params);
8934 "add %s(interface=%s, version=%u, name=%u)",
8935 (interface_slot != -1) ? (added ?
"" :
"(found but not added)") :
"(skipped), ",
8959 [[maybe_unused]] wl_registry *wl_registry,
8960 const uint32_t name)
8963 GHOST_ASSERT(display->
wl.registry == wl_registry,
"Registry argument must match!");
8965 int interface_slot = 0;
8969 "remove (name=%u, interface=%s)",
8994#ifdef USE_EVENT_BACKGROUND_THREAD
9027 if (pipe2(display->
events_pipe, O_CLOEXEC) != 0) {
9087 display_->system =
this;
9088 display_->background = background;
9089 display_->use_window_frame = use_window_frame;
9094 if (!display_->wl.display) {
9095 display_destroy_and_free_all();
9096 throw std::runtime_error(
"unable to connect to display!");
9101#ifdef USE_KDE_TABLET_HIDDEN_CURSOR_HACK
9104#ifdef USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
9105 use_kde_vulkan_ungrab_cursor_hack =
true;
9109#ifdef WITH_GHOST_CSD
9110 if (use_window_frame) {
9111# ifdef USE_GHOST_CSD_FORCE
9112 display_->use_window_frame_csd =
true;
9123#ifdef WITH_GHOST_CSD
9124 if (display_->use_window_frame_csd) {
9129 display_->preferences.csd_button_layout = csd_button_layout;
9133#ifdef WITH_GHOST_DBUS
9136 dbus_watcher_start(!cursor_size_env.has_value());
9145 display_->registry_skip_update_all =
true;
9146 wl_registry *registry = wl_display_get_registry(display_->wl.display);
9147 display_->wl.registry = registry;
9157 display_->registry_skip_update_all =
false;
9160#ifdef USE_GNOME_MOTION_MISSING_TIME_HACK
9169 display_destroy_and_free_all();
9170 throw std::runtime_error(
"unable to access xdg_shell!");
9180#ifdef USE_EVENT_BACKGROUND_THREAD
9184 GHOST_ASSERT(display_->events_pthread == 0,
"Expected to be unset");
9187 display_destroy_and_free_all();
9188 throw std::runtime_error(
"unable to create the event thread!");
9196void GHOST_SystemWayland::display_destroy_and_free_all()
9198#ifdef WITH_GHOST_DBUS
9201 dbus_watcher_.reset();
9206#ifdef USE_EVENT_BACKGROUND_THREAD
9214 display_destroy_and_free_all();
9222#ifdef WITH_INPUT_NDOF
9235 bool any_processed =
false;
9237#ifdef USE_EVENT_BACKGROUND_THREAD
9246 if (!display_->background) {
9247 std::lock_guard
lock{display_->events_pending_mutex};
9248 for (std::unique_ptr<const GHOST_IEvent> &event : display_->events_pending) {
9251 switch (event->getType()) {
9267 display_->events_pending.clear();
9272 display_->events_pending.shrink_to_fit();
9278#ifdef WITH_GHOST_DBUS
9279 dbus_events_handle_pending();
9285 any_processed =
true;
9289#ifdef WITH_INPUT_NDOF
9293 waitForEvent =
false;
9294 any_processed =
true;
9299#ifdef USE_EVENT_BACKGROUND_THREAD
9307#ifdef USE_EVENT_BACKGROUND_THREAD
9327#ifdef USE_EVENT_BACKGROUND_THREAD
9328 std::lock_guard lock_timer_guard{*display_->system->timer_mutex};
9331 any_processed =
true;
9336 any_processed =
true;
9339 return any_processed;
9349#ifdef USE_EVENT_BACKGROUND_THREAD
9354 if (!seat) [[unlikely]] {
9374 const bool is_keyboard_active = seat->
keyboard.
wl.surface_window !=
nullptr;
9375 const xkb_mod_mask_t
state = is_keyboard_active ?
9376 xkb_state_serialize_mods(seat->
xkb.state,
9377 XKB_STATE_MODS_DEPRESSED) :
9396 bool val_l = depressed_l > 0;
9397 bool val_r = depressed_r > 0;
9399 if (is_keyboard_active) {
9404 if (!(val_l || val_r)) [[unlikely]] {
9406 "modifier (%s) state is inconsistent (GHOST held keys do not match XKB)",
9415 if (val_l || val_r) [[unlikely]] {
9417 "modifier (%s) state is inconsistent (GHOST released keys do not match XKB)",
9436#ifdef USE_EVENT_BACKGROUND_THREAD
9441 if (!seat) [[unlikely]] {
9445 if (!seat_state_pointer) {
9449 buttons = seat_state_pointer->
buttons;
9458 const std::unordered_set<std::string> &data_offer_types)
9461 for (
size_t i = 0; i <
ARRAY_SIZE(ghost_supported_types); i++) {
9462 if (data_offer_types.contains(ghost_supported_types[i])) {
9463 return ghost_supported_types[i];
9470 const bool nil_terminate,
9471 const char *mime_receive_override,
9475 if (!seat) [[unlikely]] {
9482 bool mutex_locked =
true;
9483 char *data =
nullptr;
9486 if (data_offer !=
nullptr) {
9487 const char *mime_receive = mime_receive_override ?
9488 mime_receive_override :
9491 data_offer->
types.contains(mime_receive_override),
9492 "Mime type override not found in data offer, caller must check");
9497 struct ThreadResult {
9498 char *data =
nullptr;
9499 size_t data_len = 0;
9500 std::atomic<bool> done =
false;
9503 const bool nil_terminate,
9504 const char *mime_receive,
9506 ThreadResult *thread_result) {
9508 data_offer, mime_receive, mutex, nil_terminate, &thread_result->data_len);
9509 thread_result->done =
true;
9511 std::thread read_thread(
9512 read_clipboard_fn, data_offer, nil_terminate, mime_receive, &mutex, &thread_result);
9513 read_thread.detach();
9515 while (!thread_result.done) {
9518 data = thread_result.data;
9519 *r_data_len = thread_result.data_len;
9522 mutex_locked =
false;
9532 const bool nil_terminate,
9533 const char *mime_receive_override,
9537 if (!seat) [[unlikely]] {
9543 bool mutex_locked =
true;
9544 char *data =
nullptr;
9547 if (data_offer !=
nullptr) {
9548 const char *mime_receive = mime_receive_override ?
9549 mime_receive_override :
9552 data_offer->
types.contains(mime_receive_override),
9553 "Mime type override not found in data offer, caller must check");
9558 struct ThreadResult {
9559 char *data =
nullptr;
9560 size_t data_len = 0;
9561 std::atomic<bool> done =
false;
9564 const bool nil_terminate,
9565 const char *mime_receive,
9567 ThreadResult *thread_result) {
9569 data_offer, mime_receive, mutex, nil_terminate, &thread_result->data_len);
9570 thread_result->done =
true;
9572 std::thread read_thread(
9573 read_clipboard_fn, data_offer, nil_terminate, mime_receive, &mutex, &thread_result);
9574 read_thread.detach();
9576 while (!thread_result.done) {
9579 data = thread_result.data;
9580 *r_data_len = thread_result.data_len;
9583 mutex_locked =
false;
9594#ifdef USE_EVENT_BACKGROUND_THREAD
9598 const bool nil_terminate =
true;
9599 char *data =
nullptr;
9600 size_t data_len = 0;
9612 if (!display->
wp.primary_selection_device_manager) {
9616 if (!seat) [[unlikely]] {
9631 data_source->
wp.source = zwp_primary_selection_device_manager_v1_create_source(
9632 display->
wp.primary_selection_device_manager);
9634 zwp_primary_selection_source_v1_add_listener(
9641 if (seat->
wp.primary_selection_device) {
9642 zwp_primary_selection_device_v1_set_selection(
9649 if (!display->
wl.data_device_manager) {
9653 if (!seat) [[unlikely]] {
9663 data_source->
wl.source = wl_data_device_manager_create_data_source(
9664 display->
wl.data_device_manager);
9672 if (seat->
wl.data_device) {
9673 wl_data_device_set_selection(
9680#ifdef USE_EVENT_BACKGROUND_THREAD
9696#ifdef USE_EVENT_BACKGROUND_THREAD
9701 if (!seat) [[unlikely]] {
9717 const bool nil_terminate =
true;
9718 size_t data_buf_len = 0;
9724 if (!uris.empty()) {
9725 const std::string_view &uri = uris.front();
9744#ifdef USE_EVENT_BACKGROUND_THREAD
9749 if (!seat) [[unlikely]] {
9753 uint *rgba =
nullptr;
9763 size_t data_len = 0;
9774 const bool nil_terminate =
true;
9775 size_t data_len = 0;
9781 if (!uris.empty()) {
9782 const std::string_view &uri = uris.front();
9793 *r_height = ibuf->
y;
9794 const size_t byte_count = size_t(ibuf->
x) * size_t(ibuf->
y) * 4;
9795 rgba = (uint *)malloc(byte_count);
9796 std::memcpy(rgba, ibuf->
byte_data(), byte_count);
9806#ifdef USE_EVENT_BACKGROUND_THREAD
9812 if (!seat) [[unlikely]] {
9821 reinterpret_cast<uint8_t *
>(rgba),
nullptr, width, height, 32);
9835 char *data =
static_cast<char *
>(malloc(imgbuffer->
data_size));
9836 std::memcpy(data, encoded.
data(), encoded.
size());
9837 imgbuffer->
data = data;
9839 data_source->
wl.source = wl_data_device_manager_create_data_source(
9840 display_->wl.data_device_manager);
9846 if (seat->
wl.data_device) {
9847 wl_data_device_set_selection(
9857#ifdef USE_EVENT_BACKGROUND_THREAD
9861 return display_ ? uint8_t(display_->outputs.size()) : 0;
9867 timespec ts = {0, 0};
9868 clock_gettime(CLOCK_MONOTONIC, &ts);
9886 wl_fixed_t xy_wrap[2] = {
9887 seat_state_pointer->
xy[0],
9888 seat_state_pointer->
xy[1],
9940 if (!seat->
wp.relative_pointer) {
9943 const wl_fixed_t xy_next[2]{
9959#ifdef USE_EVENT_BACKGROUND_THREAD
9964 if (!seat) [[unlikely]] {
9968 if (!seat_state_pointer || !seat_state_pointer->
wl.surface_window) {
9979#ifdef USE_EVENT_BACKGROUND_THREAD
9984 if (!seat) [[unlikely]] {
9993#ifdef USE_EVENT_BACKGROUND_THREAD
9998 if (!seat) [[unlikely]] {
10002 if (!seat_state_pointer) {
10006 if (
wl_surface *wl_surface_focus = seat_state_pointer->
wl.surface_window) {
10018#ifdef USE_EVENT_BACKGROUND_THREAD
10023 if (!seat) [[unlikely]] {
10038#ifdef USE_EVENT_BACKGROUND_THREAD
10047#ifdef USE_EVENT_BACKGROUND_THREAD
10051 if (!display_->outputs.empty()) {
10055 if (
output->transform & WL_OUTPUT_TRANSFORM_90) {
10056 std::swap(size_native[0], size_native[1]);
10058 width = uint32_t(size_native[0]);
10059 height = uint32_t(size_native[1]);
10065#ifdef USE_EVENT_BACKGROUND_THREAD
10068 if (!display_->outputs.empty()) {
10075 if (
output->has_position_logical) {
10076 xy[0] =
output->position_logical[0];
10077 xy[1] =
output->position_logical[1];
10079 if (
output->transform & WL_OUTPUT_TRANSFORM_90) {
10080 std::swap(size_native[0], size_native[1]);
10082 xy_min[0] = std::min(xy_min[0], xy[0]);
10083 xy_min[1] = std::min(xy_min[1], xy[1]);
10084 xy_max[0] = std::max(xy_max[0], xy[0] + size_native[0]);
10085 xy_max[1] = std::max(xy_max[1], xy[1] + size_native[1]);
10088 width = xy_max[0] - xy_min[0];
10089 height = xy_max[1] - xy_min[1];
10095#ifdef USE_EVENT_BACKGROUND_THREAD
10104#ifdef WITH_VULKAN_BACKEND
10105 case GHOST_kDrawingContextTypeVulkan: {
10110 GHOST_kVulkanPlatformWayland,
10114 display_->wl.display,
10120 if (context->initializeDrawingContext()) {
10133#ifdef WITH_OPENGL_BACKEND
10134 case GHOST_kDrawingContextTypeOpenGL: {
10139 for (
int minor = 6; minor >= 3; --minor) {
10143 context_params_offscreen,
10144 EGLNativeWindowType(egl_window),
10145 EGLNativeDisplayType(display_->wl.display),
10146 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
10150 (context_params_offscreen.
is_debug ? EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR : 0),
10154 if (context->initializeDrawingContext()) {
10155 wl_surface_set_user_data(
wl_surface, egl_window);
10162 GHOST_PRINT(
"Cannot create off-screen EGL context" << std::endl);
10182#ifdef USE_EVENT_BACKGROUND_THREAD
10187#ifdef WITH_OPENGL_BACKEND
10189 type = GHOST_kDrawingContextTypeOpenGL;
10192#ifdef WITH_VULKAN_BACKEND
10194 type = GHOST_kDrawingContextTypeVulkan;
10205#ifdef WITH_OPENGL_BACKEND
10206 if (type == GHOST_kDrawingContextTypeOpenGL) {
10207 wl_egl_window *egl_window =
static_cast<wl_egl_window *
>(wl_surface_get_user_data(
wl_surface));
10208 if (egl_window !=
nullptr) {
10224 const uint32_t width,
10225 const uint32_t height,
10228 const bool exclusive,
10229 const bool is_dialog,
10234#ifdef WITH_GHOST_DBUS
10237 if (dbus_watcher_) {
10238 dbus_watcher_->wait_initial(dbus_initial_timeout_ms);
10239 dbus_events_handle_pending();
10279#ifdef USE_GNOME_CONFINE_HACK
10281 if (use_software_confine) {
10286 (void)use_software_confine;
10296 if (!seat) [[unlikely]] {
10300 if (!display_->wp.cursor_shape_manager) {
10304 const std::optional<wp_cursor_shape_device_v1_shape> wl_shape =
10306 if (wl_shape == std::nullopt) {
10314 display_->wp.cursor_shape_manager, seat->
wl.
pointer);
10318 wp_cursor_shape_device_v1_set_shape(
10331 for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->
wp.tablet_tools) {
10333 zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
10335 tablet_tool->
shape.
device = wp_cursor_shape_manager_v1_get_tablet_tool_v2(
10336 display_->wp.cursor_shape_manager, zwp_tablet_tool_v2);
10340 wp_cursor_shape_device_v1_set_shape(
10354 if (!seat) [[unlikely]] {
10358 if (!display_->wp.cursor_shape_manager) {
10362 const std::optional<wp_cursor_shape_device_v1_shape> wl_shape =
10364 if (wl_shape == std::nullopt) {
10372 void **buffer_data_p,
10373 size_t *buffer_data_size_p,
10374 const int cursor_size,
10375 const int cursor_size_max,
10376 const int use_dark_theme,
10378 int r_bitmap_size[2],
10381 if (*buffer_data_p) {
10382 munmap(*buffer_data_p, *buffer_data_size_p);
10383 *buffer_data_p =
nullptr;
10384 *buffer_data_size_p = 0;
10387 int bitmap_size_src[2];
10389 bool can_invert_color =
false;
10395 [](
size_t size) -> uint8_t * {
return new uint8_t[
size]; },
10398 &can_invert_color);
10400 if (bitmap_src ==
nullptr) {
10404 const bool invert_color = can_invert_color && use_dark_theme;
10407 int bitmap_size_dst[2] = {
10413 shm, bitmap_size_dst, WL_SHM_FORMAT_ARGB8888, buffer_data_p, buffer_data_size_p);
10415 if (buffer !=
nullptr) {
10416 const bool is_trivial_copy = (bitmap_size_src[0] == bitmap_size_dst[0]) &&
10417 (bitmap_size_src[1] == bitmap_size_dst[1]);
10420 if (is_trivial_copy) {
10422 const uint32_t *px_src =
reinterpret_cast<const uint32_t *
>(bitmap_src);
10423 uint32_t *px_dst =
static_cast<uint32_t *
>(*buffer_data_p);
10424 if (invert_color) {
10425 for (
int y = 0;
y < bitmap_size_src[1];
y++) {
10426 for (
int x = 0;
x < bitmap_size_src[0];
x++) {
10432 for (
int y = 0;
y < bitmap_size_src[1];
y++) {
10433 for (
int x = 0;
x < bitmap_size_src[0];
x++) {
10441 const uint32_t *px_src =
reinterpret_cast<const uint32_t *
>(bitmap_src);
10442 uint32_t *px_dst =
static_cast<uint32_t *
>(*buffer_data_p);
10443 if (invert_color) {
10444 for (
int y = 0;
y < bitmap_size_dst[1];
y++) {
10445 for (
int x = 0;
x < bitmap_size_dst[0];
x++) {
10446 *px_dst++ = (
x >= bitmap_size_src[0] ||
y >= bitmap_size_src[1]) ?
10453 for (
int y = 0;
y < bitmap_size_dst[1];
y++) {
10454 for (
int x = 0;
x < bitmap_size_dst[0];
x++) {
10455 *px_dst++ = (
x >= bitmap_size_src[0] ||
y >= bitmap_size_src[1]) ?
10463 r_bitmap_size[0] = bitmap_size_dst[0];
10464 r_bitmap_size[1] = bitmap_size_dst[1];
10466 r_hot_spot[0] = hot_spot[0];
10467 r_hot_spot[1] = hot_spot[1];
10470 delete[] bitmap_src;
10478 if (!seat) [[unlikely]] {
10490 for (zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : seat->
wp.tablet_tools) {
10492 zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2));
10494 wp_cursor_shape_device_v1_destroy(tablet_tool->
shape.
device);
10502 int bitmap_size[2] = {0, 0};
10503 int hot_spot[2] = {0, 0};
10512 const int cursor_size_max = std::min(256, cursor_size * 2);
10524 if (buffer ==
nullptr) [[unlikely]] {
10533 cursor.
wl.buffer = buffer;
10534 cursor.
wl.image.width = uint32_t(bitmap_size[0]);
10535 cursor.
wl.image.height = uint32_t(bitmap_size[1]);
10536 cursor.
wl.image.hotspot_x = uint32_t(hot_spot[0]);
10537 cursor.
wl.image.hotspot_y = uint32_t(hot_spot[1]);
10548 if (!seat) [[unlikely]] {
10563 bitmap->
hot_spot[0] = cursor->
wl.image.hotspot_x;
10564 bitmap->
hot_spot[1] = cursor->
wl.image.hotspot_y;
10575 if (!seat) [[unlikely]] {
10588 "The trackpad direction was expected to be initialized");
10634 if (!seat) [[unlikely]] {
10638#ifdef USE_GNOME_CONFINE_HACK
10641 const bool use_software_confine =
false;
10647#ifdef USE_GNOME_CONFINE_HACK
10651# ifndef USE_GNOME_CONFINE_HACK_ALWAYS_ON
10664# ifndef USE_GNOME_CONFINE_HACK_ALWAYS_ON
10674 const bool use_software_confine)
10691#ifdef USE_EVENT_BACKGROUND_THREAD
10695 for (
GWL_Seat *seat : display_->seats) {
10718#ifdef WITH_GHOST_CSD
10719static const char *ghost_wl_surface_csd_margin_tag_id =
"GHOST-csd-margin";
10724 const wl_proxy *proxy =
reinterpret_cast<const wl_proxy *
>(wl_output);
10730 const wl_proxy *proxy =
reinterpret_cast<const wl_proxy *
>(
wl_surface);
10741 const wl_proxy *proxy =
reinterpret_cast<const wl_proxy *
>(
wl_surface);
10748 const wl_proxy *proxy =
reinterpret_cast<const wl_proxy *
>(
wl_surface);
10752#ifdef WITH_GHOST_CSD
10755 const wl_proxy *proxy =
reinterpret_cast<const wl_proxy *
>(
wl_surface);
10756 return wl_proxy_get_tag(
const_cast<wl_proxy *
>(proxy)) == &ghost_wl_surface_csd_margin_tag_id;
10762 wl_proxy *proxy =
reinterpret_cast<wl_proxy *
>(wl_output);
10768 wl_proxy *proxy =
reinterpret_cast<wl_proxy *
>(
wl_surface);
10774 wl_proxy *proxy =
reinterpret_cast<wl_proxy *
>(
wl_surface);
10780 wl_proxy *proxy =
reinterpret_cast<wl_proxy *
>(
wl_surface);
10784#ifdef WITH_GHOST_CSD
10787 wl_proxy *proxy =
reinterpret_cast<wl_proxy *
>(
wl_surface);
10802 return display_->wl.display;
10807 return display_->wl.compositor;
10812 return display_->wl.subcompositor;
10817 return display_->wp.primary_selection_device_manager;
10822 return display_->xdg.activation_manager;
10827 return display_->wp.fractional_scale_manager;
10831 return display_->wp.viewporter;
10835 return display_->wp.color_manager;
10839 return display_->wp.color_manager_queue;
10843 return display_->supports_color_manager_feature_windows_scrgb;
10847 return display_->supports_color_manager_extended_srgb_linear;
10852 return display_->wp.pointer_gestures;
10863#ifdef WITH_GHOST_WAYLAND_APP_ID
10877 return display_->xdg_decor->shell;
10882 return display_->xdg_decor->manager;
10889 return display_->outputs;
10894 return display_->wl.shm;
10899 return display_->key_repeat_timer_manager;
10903 xdg_toplevel *toplevel)
10906 xdg_toplevel_icon_manager_v1 *icon_manager = display_->xdg.toplevel_icon_manager;
10907 if (icon_manager ==
nullptr) {
10915 const int icon_logical_size = display_->xdg.toplevel_icon_logical_size_max > 0 ?
10916 display_->xdg.toplevel_icon_logical_size_max :
10924 GHOST_ASSERT(icon_pixel_size > 0,
"Scale must be initialized before setting the icon!");
10932 const int32_t size_xy[2] = {icon_pixel_size, icon_pixel_size};
10933 void *buffer_data =
nullptr;
10934 size_t buffer_data_size = 0;
10936 display_->wl.shm, size_xy, WL_SHM_FORMAT_ARGB8888, &buffer_data, &buffer_data_size);
10938 if (buffer ==
nullptr) [[unlikely]] {
10945 const int pixel_count = icon_pixel_size * icon_pixel_size;
10947 icon_generator_, window,
static_cast<uint8_t *
>(buffer_data), icon_pixel_size);
10948 uint32_t *pixels =
static_cast<uint32_t *
>(buffer_data);
10949 for (
int i = 0; i < pixel_count; i++) {
10950 uint8_t *bytes =
reinterpret_cast<uint8_t *
>(&pixels[i]);
10951 std::swap(bytes[0], bytes[2]);
10962 xdg_toplevel_icon_v1 *toplevel_icon = xdg_toplevel_icon_manager_v1_create_icon(icon_manager);
10963 xdg_toplevel_icon_v1_add_buffer(toplevel_icon, icon.
buffer, buffer_scale);
10964 xdg_toplevel_icon_manager_v1_set_icon(icon_manager, toplevel, toplevel_icon);
10965 xdg_toplevel_icon_v1_destroy(toplevel_icon);
10970 return display_->use_window_frame;
10975 return display_->use_window_frame_csd;
10980 return display_->preferences.cursor_size;
10983#ifdef WITH_GHOST_CSD
10984const GHOST_CSD_Layout &GHOST_SystemWayland::preferences_csd_button_layout_get()
const
10989# ifdef WITH_GHOST_DBUS
11006#ifdef WITH_INPUT_IME
11013 const bool completed)
const
11016 if (!seat) [[unlikely]] {
11019 if (seat->
wp.text_input ==
nullptr) {
11026 gwl_seat_ime_result_reset(seat);
11029 if (seat->ime.is_enabled && completed) {
11033 bool force_rect_update =
false;
11034 if (seat->ime.is_enabled ==
false) {
11035 seat->ime.has_preedit =
false;
11036 seat->ime.is_enabled =
true;
11040 zwp_text_input_v3_enable(seat->
wp.text_input);
11043 zwp_text_input_v3_set_content_type(seat->
wp.text_input,
11044 ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE,
11045 ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL);
11047 gwl_seat_ime_rect_reset(seat);
11048 force_rect_update =
true;
11051 if ((force_rect_update ==
false) &&
11052 (seat->ime.rect.x ==
x) &&
11053 (seat->ime.rect.y ==
y) &&
11054 (seat->ime.rect.w ==
w) &&
11055 (seat->ime.rect.h == h))
11065 zwp_text_input_v3_set_cursor_rectangle(seat->
wp.text_input, rect_x, rect_y, rect_w, rect_h);
11067 zwp_text_input_v3_commit(seat->
wp.text_input);
11069 seat->ime.rect.x =
x;
11070 seat->ime.rect.y =
y;
11071 seat->ime.rect.w =
w;
11072 seat->ime.rect.h = h;
11079 if (!seat) [[unlikely]] {
11083 seat->ime.is_enabled =
false;
11085 gwl_seat_ime_rect_reset(seat);
11087 if (seat->
wp.text_input ==
nullptr) {
11091 zwp_text_input_v3_disable(seat->
wp.text_input);
11092 zwp_text_input_v3_commit(seat->
wp.text_input);
11105 GHOST_ASSERT(wl_output,
"output must not be nullptr");
11128#ifdef WITH_GHOST_DBUS
11129void GHOST_SystemWayland::dbus_watcher_start(
const bool watch_cursor_size)
11131 dbus_watcher_ = std::make_unique<GHOST_SystemDBusUnix>();
11132 display_->dbus.events.reserve(dbus_events_default_size);
11133 dbus_watcher_->setting_add(
11134 "org.freedesktop.appearance",
"color-scheme", [
this](
const GHOST_DBusValue &value) {
11135 const uint32_t *value_uint = std::get_if<uint32_t>(&value);
11139 if (dbus_.color_scheme.exchange(*value_uint) == *value_uint) {
11142 CLOG_INFO(&
LOG,
"XDG: color-scheme changed: %u", *value_uint);
11144 if (watch_cursor_size) {
11145 const auto on_change = [
this](
const GHOST_DBusValue &value) {
11146 const int32_t *value_int = std::get_if<int32_t>(&value);
11147 if (!value_int || (*value_int <= 0)) {
11150 this->dbus_event_push(GWL_DBusEvent{
11152 GWL_DBusEvent::CursorSize{
11153 .size = *value_int,
11157 dbus_watcher_->setting_add(
"org.gnome.desktop.interface",
"cursor-size", on_change);
11159# ifdef WITH_GHOST_CSD
11160 if (display_->use_window_frame_csd) {
11161 const auto on_change = [
this](
const GHOST_DBusValue &value) {
11162 const std::string *value_str = std::get_if<std::string>(&value);
11166 this->dbus_event_push(GWL_DBusEvent{
11168 GWL_DBusEvent::CSD_ButtonLayout{
11169 .layout = *value_str,
11173 dbus_watcher_->setting_add(
"org.gnome.desktop.wm.preferences",
"button-layout", on_change);
11178 dbus_watcher_->start();
11181void GHOST_SystemWayland::dbus_event_push(GWL_DBusEvent dbus_event)
11183 std::lock_guard
lock{display_->dbus.events_mutex};
11184 display_->dbus.events.push_back(std::move(dbus_event));
11185 display_->dbus.has_events.store(
true);
11188void GHOST_SystemWayland::dbus_events_handle_pending()
11190 if (display_->dbus.has_events.exchange(
false)) [[unlikely]] {
11191 std::lock_guard
lock{display_->dbus.events_mutex};
11192# ifdef USE_EVENT_BACKGROUND_THREAD
11195 for (
const GWL_DBusEvent &dbus_event : display_->dbus.events) {
11196 dbus_event_handle(dbus_event);
11198 display_->dbus.events.clear();
11200 if (display_->dbus.events.capacity() > dbus_events_default_size) [[unlikely]] {
11201 display_->dbus.events.shrink_to_fit();
11202 display_->dbus.events.reserve(dbus_events_default_size);
11207void GHOST_SystemWayland::dbus_event_handle(
const GWL_DBusEvent &dbus_event)
11209 if (
const GWL_DBusEvent::CursorSize *value = std::get_if<GWL_DBusEvent::CursorSize>(
11213 display_->preferences.cursor_size = value->size;
11215 for (GWL_Seat *seat : display_->seats) {
11216 cursor_size_set(seat, value->size);
11219# ifdef WITH_GHOST_CSD
11220 else if (
const GWL_DBusEvent::CSD_ButtonLayout *value =
11221 std::get_if<GWL_DBusEvent::CSD_ButtonLayout>(&dbus_event.data))
11223 CLOG_INFO(&
LOG,
"XDG: button-layout: \"%s\"", value->layout.c_str());
11224 GHOST_CSD_Layout csd_button_layout = {0};
11226 CLOG_WARN(&
LOG,
"XDG: ignoring invalid button-layout: \"%s\"", value->layout.c_str());
11229 if (csd_layout_is_equal(preferences_csd_button_layout_get(), csd_button_layout)) {
11232 display_->preferences.csd_button_layout = csd_button_layout;
11239 static_cast<GHOST_WindowWayland *
>(iwin)->csd_layout_refresh();
11259 if (timestamp_as_uint < input_timestamp.
last) [[unlikely]] {
11266 if (input_timestamp.
last - timestamp_as_uint > std::numeric_limits<uint32_t>::max() / 2) {
11270 uint64_t(std::numeric_limits<uint32_t>::max()) + 1;
11276 input_timestamp.
offset = offset_test;
11280 input_timestamp.
last = timestamp_as_uint;
11283 timestamp += input_timestamp.
offset;
11287 const uint32_t now_as_uint32 = uint32_t(now);
11288 if (now_as_uint32 == timestamp_as_uint) {
11296 if (!input_timestamp.
offset) {
11297 input_timestamp.
offset = (now - timestamp);
11299 timestamp += input_timestamp.
offset;
11301 if (timestamp > now) {
11302 input_timestamp.
offset -= (timestamp - now);
11312 std::unique_ptr<const GHOST_IEvent> event)
11314#ifdef USE_EVENT_BACKGROUND_THREAD
11315 GHOST_ASSERT(!display_->background,
"Foreground only");
11317 std::lock_guard
lock{display_->events_pending_mutex};
11318 display_->events_pending.push_back(std::move(event));
11333 if (!seat) [[unlikely]] {
11338 return seat->
wl.seat;
11343 bool changed =
false;
11344#define SURFACE_CLEAR_PTR(surface_test) \
11345 if (surface_test == wl_surface) { \
11346 surface_test = nullptr; \
11352 for (
GWL_Seat *seat : display_->seats) {
11356#ifdef WITH_GHOST_CSD
11363#ifdef WITH_INPUT_IME
11367#undef SURFACE_CLEAR_PTR
11374 bool changed =
false;
11382 if (window_manager) {
11391 for (
GWL_Seat *seat : display_->seats) {
11406 if (window_manager) {
11409 const std::span<GWL_Output *const> outputs = win->
outputs_get();
11410 if (std::ranges::find(outputs,
output) != outputs.end()) {
11415 for (
GWL_Seat *seat : display_->seats) {
11438 if (!display_->wp.relative_pointer_manager || !display_->wp.pointer_constraints) [[unlikely]] {
11443 if (!seat) [[unlikely]] {
11447 if (mode == mode_current) {
11451#ifndef USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
11452 (void)context_type;
11455#ifdef USE_GNOME_CONFINE_HACK
11459 const bool was_software_confine =
false;
11460 const bool use_software_confine =
false;
11464 was_software_confine);
11479 if (seat->
wp.relative_pointer) {
11480 zwp_relative_pointer_v1_destroy(seat->
wp.relative_pointer);
11481 seat->
wp.relative_pointer =
nullptr;
11483 if (seat->
wp.locked_pointer) {
11485 wl_fixed_t xy_motion[2] = {0, 0};
11486 bool xy_motion_create_event =
false;
11488 bool surface_needs_commit =
false;
11499 wl_fixed_from_int(wrap_bounds->
l_));
11501 wl_fixed_from_int(wrap_bounds->
t_));
11503 wl_fixed_from_int(wrap_bounds->
r_));
11505 wl_fixed_from_int(wrap_bounds->
b_));
11511 xy_motion[0] = xy_next[0];
11512 xy_motion[1] = xy_next[1];
11513 xy_motion_create_event =
true;
11518 zwp_locked_pointer_v1_set_cursor_position_hint(seat->
wp.locked_pointer,
UNPACK2(xy_next));
11519 surface_needs_commit =
true;
11522 const wl_fixed_t xy_next[2] = {
11530 zwp_locked_pointer_v1_set_cursor_position_hint(seat->
wp.locked_pointer,
11532 surface_needs_commit =
true;
11537 xy_motion[0] = xy_next[0];
11538 xy_motion[1] = xy_next[1];
11539 xy_motion_create_event =
true;
11541 else if (grab_state_prev.
use_lock) {
11545 xy_motion[0] = xy_next[0];
11546 xy_motion[1] = xy_next[1];
11547 xy_motion_create_event =
true;
11550#ifdef USE_GNOME_CONFINE_HACK
11552 if (was_software_confine) {
11553 zwp_locked_pointer_v1_set_cursor_position_hint(seat->
wp.locked_pointer,
11555 surface_needs_commit =
true;
11560 if (xy_motion_create_event) {
11569 GHOST_TABLET_DATA_NONE));
11572 if (surface_needs_commit) {
11573#ifdef USE_KDE_VULKAN_UNGRAB_CURSOR_HACK
11574 if (use_kde_vulkan_ungrab_cursor_hack && (context_type == GHOST_kDrawingContextTypeVulkan))
11580 const int timeout_ms = 500;
11581 ghost_wl_surface_commit_and_wait_for_apply(
this,
wl_surface, timeout_ms);
11590 zwp_locked_pointer_v1_destroy(seat->
wp.locked_pointer);
11591 seat->
wp.locked_pointer =
nullptr;
11596 if (seat->
wp.confined_pointer) {
11597 zwp_confined_pointer_v1_destroy(seat->
wp.confined_pointer);
11598 seat->
wp.confined_pointer =
nullptr;
11610 seat->
wp.relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
11611 display_->wp.relative_pointer_manager, seat->
wl.
pointer);
11612 zwp_relative_pointer_v1_add_listener(
11614 seat->
wp.locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
11615 display_->wp.pointer_constraints,
11619 ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
11624 init_grab_xy[0] = wl_fixed_to_int(
11626 init_grab_xy[1] = wl_fixed_to_int(
11634 seat->
wp.confined_pointer = zwp_pointer_constraints_v1_confine_pointer(
11635 display_->wp.pointer_constraints,
11639 ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
11647#ifdef USE_GNOME_CONFINE_HACK
11654#ifdef WITH_GHOST_WAYLAND_DYNLOAD
11655bool ghost_wl_dynload_libraries_init()
11657# ifdef WITH_GHOST_X11
11661 bool verbose = getenv(
"WAYLAND_DISPLAY") !=
nullptr;
11663 bool verbose =
true;
11668# ifdef WITH_OPENGL_BACKEND
11669 wayland_dynload_egl_init(verbose)
11680# ifdef WITH_OPENGL_BACKEND
11687void ghost_wl_dynload_libraries_exit()
11691# ifdef WITH_OPENGL_BACKEND
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref,...)
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
#define GHOST_ASSERT(x, info)
char * GHOST_URL_decode_alloc(const char *buf_src, const int buf_src_len)
static void keyboard_handle_repeat_info(void *data, wl_keyboard *, const int32_t rate, const int32_t delay)
void(*)(GWL_Display *display, void *user_data, bool on_exit) GWL_RegistryEntry_RemoveFn
static constexpr int smooth_as_discrete_steps
static void gwl_registry_wp_viewporter_remove(GWL_Display *display, void *, const bool)
static void tablet_tool_handle_button(void *data, zwp_tablet_tool_v2 *, const uint32_t serial, const uint32_t button, const uint32_t state)
static void gwl_registry_subcompositor_remove(GWL_Display *display, void *, const bool)
static void gwl_registry_wl_seat_update(GWL_Display *display, const GWL_RegistryUpdate_Params ¶ms)
static CLG_LogRef LOG_WL_PRIMARY_SELECTION_SOURCE
#define USE_NON_LATIN_KB_WORKAROUND
#define WL_FIXED_TO_INT_FOR_WINDOW_V2(win, xy)
static const char * ghost_wl_mime_send[]
static void cursor_surface_handle_enter(void *data, wl_surface *wl_surface, wl_output *wl_output)
static void tablet_tool_handle_distance(void *, zwp_tablet_tool_v2 *, const uint32_t distance)
static void data_source_handle_target(void *, wl_data_source *, const char *)
static void primary_selection_device_handle_selection(void *data, zwp_primary_selection_device_v1 *, zwp_primary_selection_offer_v1 *id)
static void global_handle_add(void *data, wl_registry *wl_registry, const uint32_t name, const char *interface, const uint32_t version)
static const xdg_toplevel_icon_manager_v1_listener xdg_toplevel_icon_manager_listener
static int gwl_registry_handler_interface_slot_from_string(const char *interface)
static const wl_keyboard_listener keyboard_listener
static CLG_LogRef LOG_WL_TABLET_TOOL
constexpr uint32_t WL_NAME_UNSET
static void gwl_registry_xdg_toplevel_icon_manager_remove(GWL_Display *display, void *, const bool)
static void keyboard_depressed_state_push_events_from_change(GWL_Seat *seat, GHOST_IWindow *win, const uint64_t event_ms, const GWL_KeyboardDepressedState &key_depressed_prev)
static GHOST_TTabletMode tablet_tool_map_type(enum zwp_tablet_tool_v2_type wp_tablet_tool_type)
static void keyboard_handle_modifiers(void *data, wl_keyboard *, const uint32_t serial, const uint32_t mods_depressed, const uint32_t mods_latched, const uint32_t mods_locked, const uint32_t group)
static void seat_handle_capabilities(void *data, wl_seat *wl_seat, const uint32_t capabilities)
static void cursor_surface_handle_leave(void *data, wl_surface *wl_surface, wl_output *wl_output)
void(*)(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms) GWL_RegistryHandler_AddFn
static const char * ghost_wl_surface_cursor_tablet_tag_id
static const xdg_wm_base_listener shell_listener
static CLG_LogRef LOG_WL_KEYBOARD_DEPRESSED_STATE
static void keyboard_handle_keymap(void *data, wl_keyboard *, const uint32_t format, const int32_t fd, const uint32_t size)
static void data_source_handle_cancelled(void *data, wl_data_source *wl_data_source)
static int gwl_seat_cursor_buffer_scale_calc(const GWL_Seat *seat)
bool ghost_wl_surface_own(const wl_surface *wl_surface)
static char * system_clipboard_get(GWL_Display *display, const bool nil_terminate, const char *mime_receive_override, size_t *r_data_len)
static void tablet_seat_handle_tool_added(void *data, zwp_tablet_seat_v2 *, zwp_tablet_tool_v2 *id)
static void xdg_toplevel_icon_manager_handle_icon_size(void *data, xdg_toplevel_icon_manager_v1 *, int32_t size)
static void gwl_registry_xdg_decoration_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void pointer_handle_frame(void *data, wl_pointer *)
static void pointer_handle_axis(void *data, wl_pointer *, const uint32_t time, const uint32_t axis, const wl_fixed_t value)
static const char * ghost_wl_app_id
static void xdg_output_handle_name(void *, zxdg_output_v1 *, const char *name)
static GHOST_TSuccess getCursorPositionClientRelative_impl(const GWL_SeatStatePointer *seat_state_pointer, const GHOST_WindowWayland *win, int32_t &x, int32_t &y)
static void gwl_primary_selection_discard_offer(GWL_PrimarySelection *primary)
static void pthread_set_min_priority(pthread_t handle)
static void touch_seat_handle_down(void *data, wl_touch *, const uint32_t serial, const uint32_t time, wl_surface *surface, const int32_t id, const wl_fixed_t x, const wl_fixed_t y)
static void gwl_registry_wl_data_device_manager_remove(GWL_Display *display, void *, const bool)
static char * read_buffer_from_primary_selection_offer(GWL_PrimarySelection_DataOffer *data_offer, const char *mime_receive, std::mutex *mutex, const bool nil_terminate, size_t *r_len)
static void pointer_handle_axis_discrete(void *data, wl_pointer *, const uint32_t axis, const int32_t discrete)
static void gwl_seat_capability_keyboard_disable(GWL_Seat *seat)
static void gwl_pointer_handle_frame_event_add(GWL_SeatStatePointer_Events *pointer_events, const GWL_Pointer_EventTypes ty, const uint32_t serial, const uint64_t event_ms)
static void tablet_tool_handle_type(void *data, zwp_tablet_tool_v2 *, const uint32_t tool_type)
static bool gwl_registry_entry_remove_by_interface_slot(GWL_Display *display, const int interface_slot, const bool on_exit)
static void gwl_registry_wp_relative_pointer_manager_remove(GWL_Display *display, void *, const bool)
static CLG_LogRef LOG_WL_TABLET_SEAT
static void data_device_handle_drop(void *data, wl_data_device *)
static void data_source_handle_send(void *data, wl_data_source *, const char *, const int32_t fd)
static bool gwl_display_seat_active_set(GWL_Display *display, const GWL_Seat *seat)
static const zwp_relative_pointer_v1_listener relative_pointer_listener
static void tablet_tool_handle_proximity_out(void *data, zwp_tablet_tool_v2 *)
void ghost_wl_output_tag(wl_output *wl_output)
static xkb_keysym_t xkb_state_key_get_one_sym_without_modifiers(xkb_state *xkb_state_empty, xkb_state *xkb_state_empty_with_numlock, xkb_state *xkb_state_empty_with_shift, const xkb_layout_index_t layout_fallback, const bool xkb_use_non_latin_workaround, const xkb_keycode_t key)
static void gwl_registry_wp_color_manager_remove(GWL_Display *display, void *, const bool)
static void output_handle_geometry(void *data, wl_output *, const int32_t, const int32_t, const int32_t physical_width, const int32_t physical_height, const int32_t, const char *make, const char *model, const int32_t transform)
static void gwl_registry_xdg_decoration_manager_remove(GWL_Display *display, void *, const bool)
static CLG_LogRef LOG_WL_PRIMARY_SELECTION_OFFER
static void cursor_shape_refresh_for_pointer(const GWL_Seat *seat, const GWL_SeatStatePointer *seat_state_pointer)
static void data_device_handle_selection(void *data, wl_data_device *, wl_data_offer *id)
static GWL_CurrentDesktopType ghost_wayland_current_desktop()
static int memfd_create_sealed(const char *name)
static uint64_t ghost_wl_ms_from_utime_pair(uint32_t utime_hi, uint32_t utime_lo)
static void touch_seat_handle_motion(void *data, wl_touch *, const uint32_t time, const int32_t id, const wl_fixed_t x, const wl_fixed_t y)
static xkb_keysym_t xkb_state_key_get_one_sym_with_fallback(xkb_state *state, const xkb_keycode_t key, const xkb_layout_index_t layout_fallback)
static void keyboard_handle_key_repeat_cancel(GWL_Seat *seat)
GHOST_WindowWayland * ghost_wl_surface_user_data(wl_surface *wl_surface)
static void gwl_seat_key_repeat_timer_remove(GWL_Seat *seat)
static const GHOST_TButton gwl_pointer_events_ebutton[]
static void gwl_registry_wl_seat_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static CLG_LogRef LOG_WL_TOUCH
static void gwl_registry_wp_primary_selection_device_manager_remove(GWL_Display *display, void *, const bool)
static GHOST_TSuccess setCursorPositionClientRelative_impl(GWL_Seat *seat, GHOST_WindowWayland *win, const int32_t x, const int32_t y)
static const zxdg_output_v1_listener xdg_output_listener
static void keyboard_handle_key_repeat_reset(GWL_Seat *seat, const bool use_delay)
static void global_handle_remove(void *data, wl_registry *wl_registry, const uint32_t name)
static const wl_buffer_listener cursor_buffer_listener
static void gwl_registry_wp_pointer_constraints_remove(GWL_Display *display, void *, const bool)
static void gwl_registry_compositor_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void tablet_tool_handle_done(void *, zwp_tablet_tool_v2 *)
static void output_handle_done(void *data, wl_output *wl_output)
static void gwl_registry_wl_output_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void gwl_seat_capability_keyboard_enable(GWL_Seat *seat)
static ssize_t read_exhaustive(const int fd, void *data, size_t nbytes)
static uint32_t rgba_straight_to_premul(uint32_t rgba_uint)
static CLG_LogRef LOG_WL_RELATIVE_POINTER
static void relative_pointer_handle_relative_motion_impl(GWL_Seat *seat, GHOST_WindowWayland *win, const wl_fixed_t xy[2], const uint64_t event_ms)
static uint64_t sub_abs_u64(const uint64_t a, const uint64_t b)
static bool gwl_registry_entry_remove_by_name(GWL_Display *display, uint32_t name, int *r_interface_slot)
static wl_buffer * ghost_wl_buffer_from_cursor_generator(const GHOST_CursorGenerator &cg, wl_shm *shm, void **buffer_data_p, size_t *buffer_data_size_p, const int cursor_size, const int cursor_size_max, const int use_dark_theme, const int scale, int r_bitmap_size[2], int r_hot_spot[2])
void ghost_wl_surface_tag_cursor_tablet(wl_surface *wl_surface)
static void touch_seat_handle_up(void *data, wl_touch *, const uint32_t serial, const uint32_t time, const int32_t id)
static void xdg_output_handle_description(void *, zxdg_output_v1 *, const char *description)
bool ghost_wl_surface_own_cursor_tablet(const wl_surface *wl_surface)
static CLG_LogRef LOG_WL_XDG_OUTPUT
static void gwl_seat_cursor_buffer_set(const GWL_Seat *seat, const wl_cursor_image *wl_image, wl_buffer *buffer)
static void gwl_registry_wp_cursor_shape_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void gwl_registry_xdg_wm_base_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void gwl_registry_entry_update_all(GWL_Display *display, const int interface_slot_exclude)
static CLG_LogRef LOG_WL_PRIMARY_SELECTION_DEVICE
GWL_Output * ghost_wl_output_user_data(wl_output *wl_output)
static void xdg_toplevel_icon_manager_handle_done(void *, xdg_toplevel_icon_manager_v1 *)
static char * read_buffer_from_data_offer(GWL_DataOffer *data_offer, const char *mime_receive, std::mutex *mutex, const bool nil_terminate, size_t *r_len)
static std::optional< int > cursor_size_from_env()
static bool gwl_seat_capability_pointer_multitouch_check(const GWL_Seat *seat, const bool fallback)
static const wl_registry_listener registry_listener
static void keyboard_depressed_state_reset(GWL_Seat *seat)
static void gwl_tablet_tool_frame_event_add(GWL_TabletTool *tablet_tool, const GWL_TabletTool_EventTypes ty, const uint32_t serial)
static const zwp_tablet_seat_v2_listener tablet_seat_listener
static bool use_kde_tablet_hidden_cursor_hack
static void gwl_tablet_tool_frame_event_reset(GWL_TabletTool *tablet_tool)
static void gwl_registry_xdg_activation_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static GWL_SeatStatePointer * gwl_seat_state_pointer_active(GWL_Seat *seat)
static constexpr const char * ghost_wl_mime_text_plain
static void tablet_seat_handle_tablet_added(void *, zwp_tablet_seat_v2 *, zwp_tablet_v2 *id)
static void tablet_tool_handle_frame(void *data, zwp_tablet_tool_v2 *, const uint32_t time)
static const zwp_primary_selection_offer_v1_listener primary_selection_offer_listener
static int pointer_axis_as_index(const uint32_t axis)
static GHOST_TKey xkb_map_gkey(const xkb_keysym_t sym)
static const wl_pointer_listener pointer_listener
static void system_clipboard_put_primary_selection(GWL_Display *display, const char *buffer)
static bool gwl_display_event_thread_create(GWL_Display *display)
static void data_source_handle_dnd_finished(void *, wl_data_source *)
static void color_manager_v1_done(void *data, wp_color_manager_v1 *)
static void gwl_registry_subcompositor_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static xkb_layout_index_t xkb_keymap_get_fallback_layout(xkb_keymap *keymap, const xkb_layout_index_t layout_active)
static void tablet_tool_handle_hardware_id_wacom(void *, zwp_tablet_tool_v2 *, const uint32_t, const uint32_t)
static void gwl_seat_capability_pointer_disable(GWL_Seat *seat)
static void gwl_registry_wp_pointer_gestures_remove(GWL_Display *display, void *, const bool)
static const wl_data_offer_listener data_offer_listener
static void ghost_wl_display_report_error_from_code(wl_display *display, const int ecode)
static void touch_seat_handle_cancel(void *data, wl_touch *)
static void gwl_registry_xdg_toplevel_icon_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void gwl_pointer_handle_frame_event_reset(GWL_SeatStatePointer_Events *pointer_events)
static void primary_selection_source_send(void *data, zwp_primary_selection_source_v1 *, const char *, const int32_t fd)
static void tablet_tool_handle_motion(void *data, zwp_tablet_tool_v2 *, const wl_fixed_t x, const wl_fixed_t y)
static const GWL_RegistryHandler * gwl_registry_handler_from_interface_slot(int interface_slot)
static void gwl_registry_wl_shm_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static CLG_LogRef LOG_WL_OUTPUT
static const wl_data_source_listener data_source_listener
static const zwp_tablet_tool_v2_listener tablet_tool_listener
static void ghost_wayland_log_handler_background(const char *msg, va_list arg)
static void gwl_registry_wl_seat_remove(GWL_Display *display, void *user_data, const bool on_exit)
static void keyboard_depressed_state_key_event(GWL_Seat *seat, const GHOST_TKey gkey, const GHOST_TEventType etype)
static void touch_seat_handle_frame(void *data, wl_touch *)
static void tablet_seat_handle_pad_added(void *, zwp_tablet_seat_v2 *, zwp_tablet_pad_v2 *id)
static void gwl_registry_wp_tablet_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void tablet_tool_handle_hardware_serial(void *, zwp_tablet_tool_v2 *, const uint32_t, const uint32_t)
static char * system_clipboard_get_primary_selection(GWL_Display *display, const bool nil_terminate, const char *mime_receive_override, size_t *r_data_len)
void ghost_wl_surface_tag(wl_surface *wl_surface)
static void gwl_registry_wp_pointer_constraints_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static wl_buffer * ghost_wl_buffer_create_for_image(wl_shm *shm, const int32_t size_xy[2], enum wl_shm_format format, void **r_buffer_data, size_t *r_buffer_data_size)
static bool cursor_is_software(const GHOST_TGrabCursorMode mode, const bool use_software_confine)
static const wl_data_device_listener data_device_listener
static void color_manager_v1_supported_intent(void *data, wp_color_manager_v1 *, uint32_t render_intent)
constexpr int MOD_INDEX_NUM
static void gwl_seat_capability_touch_disable(GWL_Seat *seat)
static void ghost_wl_display_report_error(wl_display *display)
static void tablet_tool_handle_tilt(void *data, zwp_tablet_tool_v2 *, const wl_fixed_t tilt_x, const wl_fixed_t tilt_y)
bool ghost_wl_display_report_error_if_set(wl_display *display)
static void tablet_tool_handle_removed(void *data, zwp_tablet_tool_v2 *zwp_tablet_tool_v2)
constexpr int EVDEV_OFFSET
static const wl_touch_listener touch_seat_listener
static void pointer_handle_button(void *data, wl_pointer *, const uint32_t serial, const uint32_t time, const uint32_t button, const uint32_t state)
static void gwl_seat_key_layout_active_state_update_mask(GWL_Seat *seat)
static void gwl_display_event_thread_destroy(GWL_Display *display)
static CLG_LogRef LOG_WL_KEYBOARD
static GHOST_TKey xkb_map_gkey_or_scan_code(const xkb_keysym_t sym, const uint32_t key)
static void keyboard_handle_key(void *data, wl_keyboard *, const uint32_t serial, const uint32_t time, const uint32_t key, const uint32_t state)
static bool string_elem_split_by_delim(std::string_view haystack, const char delim, std::string_view needle)
void ghost_wl_surface_tag_cursor_pointer(wl_surface *wl_surface)
static void ghost_wayland_log_handler(const char *msg, va_list arg)
static void gwl_seat_cursor_buffer_show(GWL_Seat *seat)
static CLG_LogRef LOG_WL_REGISTRY
static const wl_surface_listener cursor_surface_listener
static void primary_selection_source_cancelled(void *data, zwp_primary_selection_source_v1 *source)
@ CURSOR_VISIBLE_ONLY_HIDE
@ CURSOR_VISIBLE_ALWAYS_SET
@ CURSOR_VISIBLE_ONLY_SHOW
static CLG_LogRef LOG_WL_POINTER
static bool use_gnome_motion_missing_time_hack
static void gwl_seat_cursor_buffer_hide(GWL_Seat *seat)
static int file_descriptor_is_io_ready(const int fd, const int flags, const int timeout_ms)
static int ghost_wl_display_event_pump_from_thread(wl_display *wl_display, const int fd, const int fd_stop, std::mutex *server_mutex)
static void keyboard_handle_leave(void *data, wl_keyboard *, const uint32_t, wl_surface *wl_surface)
static void gwl_registry_wp_relative_pointer_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static constexpr const char * ghost_wl_mime_img_png
static void data_source_handle_action(void *, wl_data_source *, const uint32_t dnd_action)
#define XKB_VMOD_NAME_HYPER
static void gwl_registry_wp_tablet_manager_remove(GWL_Display *display, void *, const bool)
static void xdg_output_handle_logical_position(void *data, zxdg_output_v1 *, const int32_t x, const int32_t y)
static const zwp_primary_selection_source_v1_listener primary_selection_source_listener
static void data_device_handle_data_offer(void *, wl_data_device *, wl_data_offer *id)
static void pointer_handle_enter(void *data, wl_pointer *, const uint32_t serial, wl_surface *wl_surface, const wl_fixed_t surface_x, const wl_fixed_t surface_y)
static void tablet_tool_handle_capability(void *, zwp_tablet_tool_v2 *, const uint32_t capability)
static void cursor_buffer_set_surface_impl(const wl_cursor_image *wl_image, wl_buffer *buffer, wl_surface *wl_surface, const int scale)
static void gwl_registry_wl_output_remove(GWL_Display *display, void *user_data, const bool on_exit)
static void pointer_handle_motion(void *data, wl_pointer *, const uint32_t time, const wl_fixed_t surface_x, const wl_fixed_t surface_y)
static void primary_selection_device_handle_data_offer(void *, zwp_primary_selection_device_v1 *, zwp_primary_selection_offer_v1 *id)
static const zwp_primary_selection_device_v1_listener primary_selection_device_listener
static void color_manager_v1_supported_tf_named(void *data, wp_color_manager_v1 *, uint32_t tf)
static constexpr const char * ghost_wl_mime_text_uri_list
static void cursor_buffer_handle_release(void *data, wl_buffer *wl_buffer)
static const wp_color_manager_v1_listener color_manager_v1_listener
static const char * system_clipboard_text_mime_type(const std::unordered_set< std::string > &data_offer_types)
bool ghost_wl_output_own(const wl_output *wl_output)
static void * gwl_display_event_thread_fn(void *display_voidp)
static const char * ghost_wl_locale_from_env_with_default()
static void color_manager_v1_supported_primaries_named(void *data, wp_color_manager_v1 *, uint32_t primaries)
static void pointer_handle_axis_source(void *data, wl_pointer *, const uint32_t axis_source)
static uint32_t rgba_straight_to_premul_inverted(uint32_t rgba_uint)
static void pointer_handle_leave(void *data, wl_pointer *, const uint32_t, wl_surface *wl_surface)
static CLG_LogRef LOG_WL_DATA_OFFER
static void data_offer_handle_source_actions(void *data, wl_data_offer *, const uint32_t source_actions)
static void tablet_tool_handle_rotation(void *, zwp_tablet_tool_v2 *, const wl_fixed_t degrees)
static void gwl_seat_capability_pointer_enable(GWL_Seat *seat)
static void gwl_registry_wl_output_update(GWL_Display *display, const GWL_RegistryUpdate_Params ¶ms)
static CLG_LogRef LOG_WL_SEAT
static void data_offer_handle_action(void *data, wl_data_offer *, const uint32_t dnd_action)
static void gwl_seat_cursor_buffer_set_current(GWL_Seat *seat)
static void tablet_tool_handle_proximity_in(void *data, zwp_tablet_tool_v2 *, const uint32_t serial, zwp_tablet_v2 *, wl_surface *wl_surface)
void(*)(GWL_Display *display, const GWL_RegistryUpdate_Params ¶ms) GWL_RegistryHandler_UpdateFn
#define SURFACE_CLEAR_PTR(surface_test)
static void color_manager_v1_supported_feature(void *data, wp_color_manager_v1 *, uint32_t feature)
static void seat_handle_name(void *data, wl_seat *, const char *name)
static void tablet_tool_handle_wheel(void *data, zwp_tablet_tool_v2 *, const wl_fixed_t, const int32_t clicks)
static void pointer_handle_axis_stop(void *data, wl_pointer *, const uint32_t time, const uint32_t axis)
static void gwl_primary_selection_discard_source(GWL_PrimarySelection *primary)
static void tablet_tool_handle_down(void *data, zwp_tablet_tool_v2 *, const uint32_t serial)
static xkb_keysym_t xkb_keymap_get_one_sym_with_fallback(const xkb_keysym_t sym, xkb_keymap *keymap, const xkb_keycode_t key, const xkb_layout_index_t layout_fallback)
static void gwl_seat_cursor_visible_set(GWL_Seat *seat, const bool visible, const bool is_hardware, const enum eCursorSetMode set_mode)
static CLG_LogRef LOG_WL_CURSOR_SURFACE
static void gwl_registry_wp_primary_selection_device_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void output_handle_scale(void *data, wl_output *, const int32_t factor)
static void data_device_handle_leave(void *data, wl_data_device *)
static const char * ghost_wl_surface_cursor_pointer_tag_id
static void gwl_display_destroy(GWL_Display *display)
static void touch_seat_handle_shape(void *, wl_touch *, const int32_t, const wl_fixed_t, const wl_fixed_t)
static uint32_t round_up_uint(const uint32_t x, const uint32_t multiple)
static void gwl_registry_wp_color_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void gwl_seat_capability_touch_enable(GWL_Seat *seat)
constexpr uint32_t WL_SERIAL_NONE
static bool xkb_compose_state_feed_and_get_utf8(xkb_compose_state *compose_state, xkb_state *state, const xkb_keycode_t key, char r_utf8_buf[sizeof(GHOST_TEventKeyData::utf8_buf)])
static void primary_selection_offer_offer(void *data, zwp_primary_selection_offer_v1 *id, const char *type)
static const wl_output_listener output_listener
static void gwl_registry_entry_remove_all(GWL_Display *display)
static void keyboard_handle_enter(void *data, wl_keyboard *, const uint32_t serial, wl_surface *wl_surface, wl_array *keys)
static int ghost_wl_display_event_pump(wl_display *wl_display)
static CLG_LogRef LOG_WL_XDG_WM_BASE
static void gwl_registry_xdg_output_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void output_handle_mode(void *data, wl_output *, const uint32_t flags, const int32_t width, const int32_t height, const int32_t)
static void gwl_seat_key_repeat_timer_fn(GHOST_ITimerTask *task, uint64_t time_ms)
static void relative_pointer_handle_relative_motion(void *data, zwp_relative_pointer_v1 *, const uint32_t utime_hi, const uint32_t utime_lo, const wl_fixed_t dx, const wl_fixed_t dy, const wl_fixed_t, const wl_fixed_t)
static GWL_Seat * gwl_display_seat_active_get(const GWL_Display *display)
static const char * ghost_wl_surface_tag_id
static void gwl_registry_wp_fractional_scale_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static void xdg_output_handle_logical_size(void *data, zxdg_output_v1 *, const int32_t width, const int32_t height)
static void pointer_handle_axis_value120(void *data, wl_pointer *, const uint32_t axis, const int32_t value120)
static signed char has_wl_trackpad_physical_direction
constexpr size_t events_pending_default_size
static void gwl_registry_xdg_wm_base_remove(GWL_Display *display, void *, const bool)
static bool setCursorGrab_use_software_confine(const GHOST_TGrabCursorMode mode, wl_surface *wl_surface)
static void data_offer_handle_offer(void *data, wl_data_offer *, const char *mime_type)
static const GHOST_TDragnDropTypes ghost_wl_mime_preference_order_type[]
static char * read_file_as_buffer(const int fd, const bool nil_terminate, size_t *r_len)
static void data_device_handle_motion(void *data, wl_data_device *, const uint32_t time, const wl_fixed_t x, const wl_fixed_t y)
static void gwl_registry_wp_fractional_scale_manager_remove(GWL_Display *display, void *, const bool)
static void gwl_registry_wp_cursor_shape_manager_remove(GWL_Display *display, void *, const bool)
GWL_TabletTool_EventTypes
static void gwl_seat_capability_pointer_multitouch_disable(GWL_Seat *seat)
static void output_handle_description(void *, wl_output *, const char *description)
static std::vector< std::string_view > gwl_clipboard_uri_ranges(const char *data_buf, size_t data_buf_len)
static CLG_LogRef LOG_WL_DATA_SOURCE
bool ghost_wl_surface_own_cursor_pointer(const wl_surface *wl_surface)
static void gwl_simple_buffer_free_data(GWL_SimpleBuffer *buffer)
static void touch_seat_handle_orientation(void *, wl_touch *, const int32_t, const wl_fixed_t)
static CLG_LogRef LOG_WL_CURSOR_BUFFER
static void gwl_registry_wp_pointer_gestures_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static CLG_LogRef LOG_WL_DATA_DEVICE
static void gwl_seat_capability_pointer_multitouch_enable(GWL_Seat *seat)
static const GHOST_TButton gwl_tablet_tool_ebutton[]
static void gwl_registry_xdg_output_manager_remove(GWL_Display *display, void *, const bool)
static GWL_SeatStateGrab seat_grab_state_from_mode(const GHOST_TGrabCursorMode mode, const bool use_software_confine)
static const int default_cursor_size
static const wl_seat_listener seat_listener
static bool update_cursor_scale(GWL_Seat *seat, GWL_Cursor &cursor, GWL_SeatStatePointer *seat_state_pointer)
static const GWL_ModifierInfo g_modifier_info_table[MOD_INDEX_NUM]
static constexpr const char * ghost_wl_mime_text_utf8
static void gwl_seat_key_repeat_timer_add(GWL_Seat *seat, GHOST_TimerProcPtr key_repeat_fn, GHOST_TUserDataPtr payload, const bool use_delay)
static void data_source_handle_dnd_drop_performed(void *, wl_data_source *)
static void tablet_tool_handle_up(void *data, zwp_tablet_tool_v2 *)
static void gwl_xdg_decor_system_destroy(GWL_Display *display, GWL_XDG_Decor_System *decor)
static void gwl_simple_buffer_set_from_string(GWL_SimpleBuffer *buffer, const char *str)
static GWL_SeatStatePointer * gwl_seat_state_pointer_from_cursor_surface(GWL_Seat *seat, const wl_surface *wl_surface)
static void gwl_registry_xdg_activation_remove(GWL_Display *display, void *, const bool)
static std::optional< wp_cursor_shape_device_v1_shape > gwl_seat_cursor_find_wl_shape_from_ghost(const GHOST_TStandardCursor shape)
wl_buffer * ghost_wl_buffer_create_transparent_pixel(wl_shm *shm)
static void gwl_registry_wp_viewporter_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
static int gwl_scaled_fixed_t_add_and_calc_rounded_delta(GWL_ScaledFixedT *sf, const wl_fixed_t add)
constexpr int GWL_TabletTool_FrameTypes_NUM
static const GWL_RegistryHandler gwl_registry_handlers[]
static int file_descriptor_is_io_ready_ex(const int fd, const int fd_stop, const int flags, const int timeout_ms, bool *r_stop)
static void gwl_registry_wl_shm_remove(GWL_Display *display, void *, const bool)
static bool use_gnome_confine_hack
static void tablet_tool_handle_slider(void *, zwp_tablet_tool_v2 *, const int32_t position)
bool ghost_wl_surface_own_with_null_check(const wl_surface *wl_surface)
static void output_handle_name(void *, wl_output *, const char *name)
static void data_device_handle_enter(void *data, wl_data_device *, const uint32_t serial, wl_surface *wl_surface, const wl_fixed_t x, const wl_fixed_t y, wl_data_offer *id)
static void system_clipboard_put(GWL_Display *display, const char *buffer)
static void gwl_seat_state_pointer_surface_window_set(GWL_SeatStatePointer *seat_state_pointer, wl_surface *wl_surface)
static int gwl_display_seat_index(GWL_Display *display, const GWL_Seat *seat)
static const char * ghost_wl_output_tag_id
static const char * ghost_wl_mime_preference_order[]
static void shell_handle_ping(void *, xdg_wm_base *xdg_wm_base, const uint32_t serial)
static void dnd_events(const GWL_Seat *const seat, const GHOST_TEventType event, const uint64_t event_ms)
static void tablet_tool_handle_pressure(void *data, zwp_tablet_tool_v2 *, const uint32_t pressure)
#define GWL_IFACE_VERSION_CLAMP(params_version, version_min, version_max)
static int gwl_registry_handler_interface_slot_max()
static void cursor_surface_handle_preferred_buffer_scale(void *, wl_surface *, const int32_t factor)
static void xdg_output_handle_done(void *data, zxdg_output_v1 *)
static void gwl_registry_entry_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms, void *user_data)
static size_t ghost_wl_shm_format_as_size(enum wl_shm_format format)
static void gwl_registry_compositor_remove(GWL_Display *display, void *, const bool)
static void gwl_registry_wl_data_device_manager_add(GWL_Display *display, const GWL_RegistryAdd_Params ¶ms)
wl_fixed_t gwl_window_scale_wl_fixed_to(const GWL_WindowScaleParams &scale_params, wl_fixed_t value)
wl_fixed_t gwl_window_scale_wl_fixed_from(const GWL_WindowScaleParams &scale_params, wl_fixed_t value)
int gwl_window_scale_int_to(const GWL_WindowScaleParams &scale_params, int value)
#define FRACTIONAL_DENOMINATOR
int gwl_window_scale_buffer_size_to(const GWL_WindowScaleParams &scale_params, int logical_size, int *r_buffer_scale)
bool ghost_wl_output_own(const struct wl_output *wl_output)
struct GWL_Output * ghost_wl_output_user_data(struct wl_output *wl_output)
GHOST_WindowWayland * ghost_wl_surface_user_data(struct wl_surface *wl_surface)
@ GHOST_kEventWheelAxisVertical
@ GHOST_kEventWheelAxisHorizontal
void * GHOST_TUserDataPtr
#define GHOST_CSD_DPI_FRACTIONAL_BASE
@ GHOST_kTrackpadEventMagnify
@ GHOST_kTrackpadEventRotate
@ GHOST_kTrackpadEventScroll
@ GHOST_kWindowStateNormal
@ GHOST_kStandardCursorLeftHandle
@ GHOST_kStandardCursorHandClosed
@ GHOST_kStandardCursorHandOpen
@ GHOST_kStandardCursorBottomLeftCorner
@ GHOST_kStandardCursorZoomIn
@ GHOST_kStandardCursorVerticalSplit
@ GHOST_kStandardCursorHelp
@ GHOST_kStandardCursorCopy
@ GHOST_kStandardCursorWait
@ GHOST_kStandardCursorRightHandle
@ GHOST_kStandardCursorHorizontalSplit
@ GHOST_kStandardCursorTopSide
@ GHOST_kStandardCursorStop
@ GHOST_kStandardCursorCrosshair
@ GHOST_kStandardCursorCustom
@ GHOST_kStandardCursorNSEWScroll
@ GHOST_kStandardCursorLeftRight
@ GHOST_kStandardCursorPencil
@ GHOST_kStandardCursorNSScroll
@ GHOST_kStandardCursorCrosshairA
@ GHOST_kStandardCursorUpDown
@ GHOST_kStandardCursorUpArrow
@ GHOST_kStandardCursorHandPoint
@ GHOST_kStandardCursorBottomSide
@ GHOST_kStandardCursorBothHandles
@ GHOST_kStandardCursorInfo
@ GHOST_kStandardCursorTopLeftCorner
@ GHOST_kStandardCursorEyedropper
@ GHOST_kStandardCursorKnife
@ GHOST_kStandardCursorMove
@ GHOST_kStandardCursorCrosshairB
@ GHOST_kStandardCursorBlade
@ GHOST_kStandardCursorSlip
@ GHOST_kStandardCursorBottomRightCorner
@ GHOST_kStandardCursorDownArrow
@ GHOST_kStandardCursorEraser
@ GHOST_kStandardCursorDefault
@ GHOST_kStandardCursorEWScroll
@ GHOST_kStandardCursorRightSide
@ GHOST_kStandardCursorRightArrow
@ GHOST_kStandardCursorTopRightCorner
@ GHOST_kStandardCursorDestroy
@ GHOST_kStandardCursorCrosshairC
@ GHOST_kStandardCursorZoomOut
@ GHOST_kStandardCursorLeftSide
@ GHOST_kStandardCursorText
@ GHOST_kStandardCursorLeftArrow
#define GHOST_KEY_MODIFIER_TO_INDEX(key)
@ GHOST_kEventDraggingDropDone
@ GHOST_kEventDraggingExited
@ GHOST_kEventImeComposition
@ GHOST_kEventDraggingUpdated
@ GHOST_kEventDraggingEntered
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowDeactivate
@ GHOST_kEventImeCompositionStart
@ GHOST_kEventImeCompositionEnd
void(*)(FILE *file_handle) GHOST_TBacktraceFn
static const GHOST_TabletData GHOST_TABLET_DATA_NONE
#define GHOST_KEY_MODIFIER_CHECK(key)
#define GHOST_KEY_MODIFIER_NUM
@ GHOST_kTabletModeEraser
@ GHOST_kTabletModeStylus
@ GHOST_kCSDTypeBorderBottomRight
@ GHOST_kCSDTypeButtonClose
@ GHOST_kCSDTypeBorderBottomLeft
@ GHOST_kCSDTypeButtonMinimize
@ GHOST_kCSDTypeBorderBottom
@ GHOST_kCSDTypeBorderTopRight
@ GHOST_kCSDTypeBorderTop
@ GHOST_kCSDTypeBorderLeft
@ GHOST_kCSDTypeButtonMaximize
@ GHOST_kCSDTypeBorderTopLeft
@ GHOST_kCSDTypeButtonMenu
@ GHOST_kCSDTypeBorderRight
@ GHOST_kCapabilityWindowDecorationServerSide
@ GHOST_kCapabilityWindowPosition
@ GHOST_kCapabilityGPUReadFrontBuffer
@ GHOST_kCapabilityCursorWarp
@ GHOST_kCapabilityWindowPath
@ GHOST_kCapabilityTrackpadPhysicalDirection
@ GHOST_kCapabilityMultiMonitorPlacement
@ GHOST_kCapabilityWindowDecorationStyles
@ GHOST_kCapabilityDesktopSample
#define GHOST_CONTEXT_PARAMS_FROM_GPU_SETTINGS(gpu_settings)
#define GHOST_CAPABILITY_FLAG_ALL
#define GHOST_KEY_MODIFIER_FROM_INDEX(key)
@ GHOST_kKeyNumpadAsterisk
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeNone
@ GHOST_kModifierKeyRightControl
@ GHOST_kModifierKeyLeftControl
@ GHOST_kModifierKeyRightHyper
@ GHOST_kModifierKeyRightAlt
@ GHOST_kModifierKeyRightShift
@ GHOST_kModifierKeyLeftAlt
@ GHOST_kModifierKeyLeftShift
@ GHOST_kModifierKeyLeftOS
@ GHOST_kModifierKeyRightOS
@ GHOST_kModifierKeyLeftHyper
#define GHOST_CONTEXT_PARAMS_FROM_GPU_SETTINGS_OFFSCREEN(gpu_settings)
@ GHOST_kDragnDropTypeUnknown
@ GHOST_kDragnDropTypeFilenames
@ GHOST_kDragnDropTypeString
@ GHOST_kButtonMaskButton4
@ GHOST_kButtonMaskButton7
@ GHOST_kButtonMaskButton6
@ GHOST_kButtonMaskButton5
@ GHOST_kButtonMaskMiddle
void(*)(GHOST_ITimerTask *task, uint64_t time) GHOST_TimerProcPtr
GHOST_TConsoleWindowState
#define WL_ARRAY_FOR_EACH(pos, array)
bool GHOST_WindowCSD_LayoutFromString(GHOST_CSD_Layout &layout, const std::string_view buttons)
bool GHOST_WindowCSD_Check(GWL_CurrentDesktopType desktop_type)
void GHOST_WindowCSD_LayoutDefault(GHOST_CSD_Layout &layout)
void gwl_xdg_window_icon_free(GWL_XDG_WindowIcon &icon)
#define USE_EVENT_BACKGROUND_THREAD
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
struct AtomicSpinLock __attribute__((aligned(32))) AtomicSpinLock
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static void add(btAlignedObjectArray< T > &items, const Q &value)
GHOST_ContextEGL(const GHOST_System *const system, const GHOST_ContextParams &context_params, EGLNativeWindowType nativeWindow, EGLNativeDisplayType nativeDisplay, EGLint contextProfileMask, EGLint contextMajorVersion, EGLint contextMinorVersion, EGLint contextFlags, EGLint contextResetNotificationStrategy, EGLenum api)
GHOST_ContextVK(const GHOST_ContextParams &context_params, GHOST_TVulkanPlatformType platform, Window window, Display *display, wl_surface *wayland_surface, wl_display *wayland_display, const GHOST_ContextVK_WindowInfo *wayland_window_info, int contextMajorVersion, int contextMinorVersion, const GHOST_GPUDevice &preferred_device, const GHOST_WindowHDRInfo *hdr_info_=nullptr)
static GHOST_TBacktraceFn getBacktraceFn()
static bool getUseWindowFrame()
virtual GHOST_TUserDataPtr getUserData() const =0
GHOST_NDOFManagerUnix(GHOST_System &)
virtual void wrapPoint(int32_t &x, int32_t &y, int32_t ofs, GHOST_TAxisFlag axis)
virtual void clampPoint(int32_t &x, int32_t &y)
struct zwp_primary_selection_device_manager_v1 * wp_primary_selection_manager_get()
static const char * xdg_app_id_get()
GHOST_TSuccess init() override
bool supports_color_manager_extended_srgb_linear() const
struct wl_event_queue * wp_color_manager_queue_get()
void xdg_toplevel_icon_update(GHOST_WindowWayland *window, struct xdg_toplevel *toplevel)
bool supports_color_manager_feature_windows_scrgb() const
bool window_surface_unref(const wl_surface *wl_surface)
uint64_t getMilliSeconds() const override
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpu_settings) override
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override
GHOST_TSuccess cursor_visibility_set(bool visible)
std::thread::id main_thread_id
struct wl_display * wl_display_get()
bool use_window_frame_csd_get() const
char * getClipboard(bool selection) const override
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override
GHOST_TimerManager * key_repeat_timer_manager()
const std::span< GWL_Output *const > outputs_get() const
bool cursor_grab_use_software_display_get(const GHOST_TGrabCursorMode mode)
uint64_t ms_from_input_time(const uint32_t timestamp_as_uint)
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpu_settings, const bool exclusive, const bool is_dialog, const GHOST_IWindow *parent_window) override
uint * getClipboardImage(int *r_width, int *r_height) const override
struct xdg_wm_base * xdg_decor_shell_get()
struct wl_compositor * wl_compositor_get()
bool use_window_frame_get() const
struct wp_fractional_scale_manager_v1 * wp_fractional_scale_manager_get()
struct wl_subcompositor * wl_subcompositor_get()
int preferences_cursor_size_get() const
void setMultitouchGestures(const bool use) override
struct wl_shm * wl_shm_get() const
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const override
GHOST_TSuccess cursor_shape_set(GHOST_TStandardCursor shape)
GHOST_TSuccess disposeContext(GHOST_IContext *context) override
struct wp_viewporter * wp_viewporter_get()
struct zxdg_decoration_manager_v1 * xdg_decor_manager_get()
struct wl_seat * wl_seat_active_get_with_input_serial(uint32_t &serial)
GHOST_TSuccess cursor_bitmap_get(GHOST_CursorBitmapRef *bitmap)
GHOST_TSuccess pushEvent_maybe_pending(std::unique_ptr< const GHOST_IEvent > event)
GHOST_TSuccess cursor_shape_custom_set(const GHOST_CursorGenerator &cg)
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override
void ime_begin(const GHOST_WindowWayland *win, int32_t x, int32_t y, int32_t w, int32_t h, bool completed) const
uint8_t getNumDisplays() const override
bool output_unref(struct wl_output *wl_output)
~GHOST_SystemWayland() override
void putClipboard(const char *buffer, bool selection) const override
void output_scale_update(GWL_Output *output)
GHOST_TCapabilityFlag getCapabilities() const override
struct wp_color_manager_v1 * wp_color_manager_get()
bool window_cursor_grab_set(const GHOST_TGrabCursorMode mode, const GHOST_TGrabCursorMode mode_current, int32_t init_grab_xy[2], const GHOST_Rect *wrap_bounds, GHOST_TAxisFlag wrap_axis, wl_surface *wl_surface, const struct GWL_WindowScaleParams &scale_params, const GHOST_TDrawingContextType context_type)
std::atomic< bool > has_pending_actions_for_window
bool processEvents(bool waitForEvent) override
void seat_active_set(const struct GWL_Seat *seat)
GHOST_TSuccess getCursorPositionClientRelative(const GHOST_IWindow *window, int32_t &x, int32_t &y) const override
GHOST_TSuccess cursor_shape_check(GHOST_TStandardCursor cursor_shape)
GHOST_TSuccess setCursorPositionClientRelative(GHOST_IWindow *window, int32_t x, int32_t y) override
GHOST_TSuccess hasClipboardImage() const override
bool setConsoleWindowState(GHOST_TConsoleWindowState action) override
std::mutex * server_mutex
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override
struct xdg_activation_v1 * xdg_activation_manager_get()
uint32_t getCursorPreferredLogicalSize() const override
struct zwp_pointer_gestures_v1 * wp_pointer_gestures_get()
void ime_end(const GHOST_WindowWayland *win) const
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const override
GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const override
GHOST_EventManager * getEventManager() const
GHOST_WindowManager * getWindowManager() const
const GHOST_CSD_Params & getWindowCSD() const
GHOST_WindowManager * window_manager_
GHOST_TSuccess init() override
GHOST_TimerManager * getTimerManager() const
GHOST_TSuccess pushEvent(std::unique_ptr< const GHOST_IEvent > event)
bool multitouch_gestures_
const GHOST_IconGenerator * icon_generator_
void setWindowCSD_Layout(const GHOST_CSD_Layout &csd_layout)
GHOST_TSuccess removeTimer(GHOST_TimerTask *timer)
GHOST_TSuccess addTimer(GHOST_TimerTask *timer)
GHOST_TimerTask(uint64_t start, uint64_t interval, GHOST_TimerProcPtr timer_proc, GHOST_TUserDataPtr user_data=nullptr)
GHOST_TSuccess addWindow(GHOST_IWindow *window)
const std::vector< GHOST_IWindow * > & getWindows() const
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
void setWindowInactive(const GHOST_IWindow *window)
const struct GWL_WindowScaleParams & scale_params_get() const
bool outputs_leave(GWL_Output *output)
wl_fixed_t wl_fixed_to_window(wl_fixed_t value) const
void outputs_changed_update_scale_tag()
GHOST_WindowWayland(GHOST_SystemWayland *system, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, const GHOST_IWindow *parent_window, GHOST_TDrawingContextType type, const bool is_dialog, const GHOST_ContextParams &context_params, const bool exclusive, const GHOST_GPUDevice &preferred_device)
void pending_actions_handle()
bool getValid() const override
wl_fixed_t wl_fixed_from_window(wl_fixed_t value) const
void getClientBounds(GHOST_Rect &bounds) const override
const std::span< GWL_Output *const > outputs_get() const
uint16_t getDPIHint() override
GHOST_TSuccess cursor_shape_refresh()
GWL_XDG_WindowIcon & gwl_xdg_icon_get()
virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) const
GHOST_TAxisFlag getCursorGrabAxis() const
GHOST_TGrabCursorMode getCursorGrabMode() const
bool getCursorGrabModeIsWarp() const
float distance(float, float) RET
constexpr T degrees(T) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
bool is_enabled(const Scene &scene, ExecutionMode mode)
int size(const AssetLibraryReference *library_reference)
constexpr toml::spec version
Vector< uint8_t > IMB_save_image_to_buffer(ImBuf *ibuf, ImBufFlags flags)
ImBuf * IMB_load_image_from_filepath(const char *filepath, ImBufFlags flags, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
void IMB_freeImBuf(ImBuf *ibuf)
BMesh const char void * data
ImBuf * IMB_load_image_from_memory(const unsigned char *mem, size_t size, ImBufFlags flags, const char *descr, const char *filepath=nullptr, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
ImBuf * IMB_allocFromBuffer(const uint8_t *byte_buffer, const float *float_buffer, unsigned int w, unsigned int h, unsigned int channels)
bool IMB_test_image(const char *filepath)
std::string format(const std::string &fmt, Args &&...args)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
std::unordered_set< uint32_t > supported_features
std::unordered_set< uint32_t > supported_intents
std::unordered_set< uint32_t > supported_transfers
std::unordered_set< uint32_t > supported_primaries
GHOST_CSD_EventState_Button buttons[1]
GHOST_TCSD_Type buttons[5]
int cursor_drag_threshold
int cursor_double_click_ms
uint8_t *(*) generate_fn(const struct GHOST_CursorGenerator *cursor_generator, int cursor_size, int cursor_size_max, uint8_t *(*alloc_fn)(size_t size), int r_bitmap_size[2], int r_hot_spot[2], bool *r_can_invert_color)
GHOST_TDrawingContextType context_type
GHOST_GPUDevice preferred_device
void(*) generate_fn(const struct GHOST_IconGenerator *icon_generator, GHOST_IWindow *window, uint8_t *pixels, int icon_size)
void set(GHOST_TModifierKey mask, bool down)
wp_cursor_shape_device_v1_shape enum_id
wp_cursor_shape_device_v1 * device
wl_surface * surface_cursor
struct GWL_Cursor::@314323000336233220053044211217215260043022110370 wl
enum wl_data_device_manager_dnd_action action
enum wl_data_device_manager_dnd_action source_actions
std::unordered_set< std::string > types
struct GWL_DataOffer::@147314011101112272276200161236160363120320024113 dnd
struct GWL_DataOffer::@330245371112075341223137156202074106325150315265 wl
GWL_SimpleBuffer buffer_out
struct GWL_DataSource::@125015032307213225102306360346203116110370120237 wl
wl_compositor * compositor
wl_subcompositor * subcompositor
wl_data_device_manager * data_device_manager
wp_color_manager_v1 * color_manager
wp_fractional_scale_manager_v1 * fractional_scale_manager
zwp_tablet_manager_v2 * tablet_manager
zwp_pointer_constraints_v1 * pointer_constraints
wp_viewporter * viewporter
zwp_relative_pointer_manager_v1 * relative_pointer_manager
wp_cursor_shape_manager_v1 * cursor_shape_manager
zwp_primary_selection_device_manager_v1 * primary_selection_device_manager
zwp_pointer_gestures_v1 * pointer_gestures
wl_event_queue * color_manager_queue
xdg_activation_v1 * activation_manager
zxdg_output_manager_v1 * output_manager
int toplevel_icon_logical_size_max
xdg_toplevel_icon_manager_v1 * toplevel_icon_manager
std::vector< GWL_Seat * > seats
struct GWL_Display::@277165256066036227055246100260074022344031031116 wl
bool supports_color_manager_extended_srgb_linear
struct GWL_Display::@334354154372233112110216243051323015254071064001 xdg
std::vector< GWL_Output * > outputs
bool supports_color_manager_feature_windows_scrgb
GWL_DisplayTimeStamp input_timestamp
GWL_XDG_Decor_System * xdg_decor
bool registry_skip_update_all
GWL_RegistryEntry * registry_entry
struct GWL_Display::@343256373343037257351064040231203210353357104223 preferences
GHOST_TimerManager * key_repeat_timer_manager
struct GWL_Display::@175264057036315311150262170030065173245371075342 wp
bool use_window_frame_csd
GHOST_SystemWayland * system
std::mutex events_pending_mutex
std::vector< std::unique_ptr< const GHOST_IEvent > > events_pending
struct GWL_KeyRepeatPlayload::@143313365314317262065200322120246146007031257122 key_data
int16_t mods[GHOST_KEY_MODIFIER_NUM]
const char * display_name
std::unordered_set< std::string > types
struct GWL_PrimarySelection_DataOffer::@304056113042126166305355272212365024044000320333 wp
zwp_primary_selection_source_v1 * source
GWL_SimpleBuffer buffer_out
struct GWL_PrimarySelection_DataSource::@262172322224217140223156023104024361151202160341 wp
GWL_PrimarySelection_DataSource * data_source
std::mutex data_offer_mutex
GWL_PrimarySelection_DataOffer * data_offer
std::mutex data_source_mutex
GWL_RegistryHandler_AddFn add_fn
const char *const * interface_p
GWL_RegistryEntry_RemoveFn remove_fn
GWL_RegistryHandler_UpdateFn update_fn
wl_surface * surface_window
struct GWL_SeatStateKeyboard::@002236227201217376126360362076131233146143306151 wl
GWL_ScaledFixedT rotation
wl_surface * surface_window
uint32_t frame_serial[GWL_TabletTool_FrameTypes_NUM]
GWL_Pointer_EventTypes frame_types[GWL_TabletTool_FrameTypes_NUM]
uint64_t frame_event_ms[GWL_TabletTool_FrameTypes_NUM]
struct GWL_SeatStatePointer_Events::@271006335365153047125127025353303353266201161350 frame_pending
struct GWL_SeatStatePointer::@176021020360003204014146270025272344077006150320 wl
std::unordered_set< const GWL_Output * > outputs
uint64_t motion_event_time_ms
uint64_t up_event_time_ms
uint64_t down_event_time_ms
uint64_t down_event_serial
wl_surface * surface_window_focus_dnd
wl_data_device * data_device
zwp_relative_pointer_v1 * relative_pointer
zwp_primary_selection_device_v1 * primary_selection_device
std::unordered_set< zwp_tablet_tool_v2 * > tablet_tools
zwp_tablet_seat_v2 * tablet_seat
zwp_locked_pointer_v1 * locked_pointer
zwp_confined_pointer_v1 * confined_pointer
xkb_layout_index_t layout_fallback
xkb_layout_index_t layout_active
xkb_compose_state * compose_state
xkb_state * state_empty_with_numlock
xkb_compose_table * compose_table
xkb_state * state_empty_with_shift
struct GWL_Seat::@077323275360216145363375106070375251161004153061 key_repeat
struct GWL_Seat::@152027136010022314057316376113115357364375226120 wp
GHOST_SystemWayland * system
GWL_SeatStatePointerScroll pointer_scroll
GWL_KeyboardDepressedState key_depressed
GWL_SeatStatePointer_Events pointer_events
GWL_DataSource * data_source
GWL_SeatStatePointer touch
uint32_t data_source_serial
GWL_DataOffer * data_offer_copy_paste
struct GWL_Seat::@161057270257110375042361055064237015070232240153 wl
GWL_SeatStatePointer pointer
std::mutex data_source_mutex
xkb_mod_index_t xkb_keymap_mod_index[MOD_INDEX_NUM]
std::optional< GHOST_TSuccess > data_offer_copy_paste_has_image
std::mutex data_offer_dnd_mutex
GWL_PrimarySelection primary_selection
std::mutex data_offer_copy_paste_mutex
uint32_t cursor_source_serial
GWL_SeatStatePointer tablet
bool use_pointer_scroll_smooth_as_discrete
struct GWL_Seat::@311222234142063271106307226121357254360171231034 touch_state
xkb_mod_index_t xkb_keymap_mod_index_numlock
bool xkb_use_non_latin_workaround
wl_fixed_t grab_lock_xy[2]
GWL_DataOffer * data_offer_dnd
xkb_mod_index_t xkb_keymap_mod_index_mod2
GWL_SeatStatePointerGesture_Pinch pointer_gesture_pinch
struct GWL_Seat::@317134123165032204353254344161063045010227232131 xkb
GWL_SeatStateKeyboard keyboard
bool use_pointer_software_confine
zxdg_decoration_manager_v1 * manager
struct wl_buffer * buffer
ImbFormatOptions foptions
const uint8_t * byte_data() const
void wayland_dynload_client_exit(void)
void wayland_dynload_cursor_exit(void)
bool wayland_dynload_cursor_init(bool verbose)
bool wayland_dynload_client_init(bool verbose)
#define wl_proxy_get_tag(...)
#define wl_display_connect(...)
#define wl_log_set_handler_client(...)
#define wl_display_dispatch_pending(...)
#define wl_proxy_set_tag(...)
#define wl_proxy_create_wrapper(...)
#define wl_display_get_error(...)
#define wl_display_cancel_read(...)
#define wl_display_dispatch(...)
#define wl_display_dispatch_queue_pending(...)
#define wl_display_get_fd(...)
#define wl_display_prepare_read_queue(...)
#define wl_display_prepare_read(...)
#define wl_display_create_queue(...)
#define wl_proxy_wrapper_destroy(...)
#define wl_display_flush(...)
#define wl_display_get_protocol_error(...)
#define wl_display_disconnect(...)
#define wl_display_read_events(...)
#define wl_proxy_set_queue(...)
#define wl_display_roundtrip(...)
#define wl_event_queue_destroy(...)
void wayland_dynload_egl_exit(void)
#define wl_egl_window_create(...)
#define wl_egl_window_destroy(...)