WM: add a capability flag for physical trackpad direction

Support detecting if the trackpad direction flag is propertly set
(currently unused).

Needed so Wayland compositors that don't support seat-version 9 or
newer (GNOME-46 & KDE5 for e.g) can have a working trackpad.

Eventually this option will be removed when the functionality is
widely supported.
This commit is contained in:
Campbell Barton 2024-04-26 21:26:43 +10:00
parent 954dc21581
commit c444f128d3
4 changed files with 22 additions and 3 deletions

@ -123,6 +123,10 @@ typedef enum {
* Supports IME text input methods (when `WITH_INPUT_IME` is defined).
*/
GHOST_kCapabilityInputIME = (1 << 6),
/**
* Support detecting the physical trackpad direction.
*/
GHOST_kCapabilityTrackpadPhysicalDirection = (1 << 7),
} GHOST_TCapabilityFlag;
/**
@ -132,7 +136,8 @@ typedef enum {
#define GHOST_CAPABILITY_FLAG_ALL \
(GHOST_kCapabilityCursorWarp | GHOST_kCapabilityWindowPosition | \
GHOST_kCapabilityPrimaryClipboard | GHOST_kCapabilityGPUReadFrontBuffer | \
GHOST_kCapabilityClipboardImages | GHOST_kCapabilityDesktopSample | GHOST_kCapabilityInputIME)
GHOST_kCapabilityClipboardImages | GHOST_kCapabilityDesktopSample | \
GHOST_kCapabilityInputIME | GHOST_kCapabilityTrackpadPhysicalDirection)
/* Xtilt and Ytilt represent how much the pen is tilted away from
* vertically upright in either the X or Y direction, with X and Y the

@ -108,6 +108,8 @@ static bool has_libdecor = true;
# endif
#endif
static signed char has_wl_trackpad_physical_direction = -1;
#include "IMB_imbuf.hh"
#include "IMB_imbuf_types.hh"
@ -6410,6 +6412,8 @@ static void gwl_registry_wl_seat_add(GWL_Display *display, const GWL_RegisteryAd
display->seats.push_back(seat);
wl_seat_add_listener(seat->wl.seat, &seat_listener, seat);
gwl_registry_entry_add(display, params, static_cast<void *>(seat));
has_wl_trackpad_physical_direction = version >= 9;
}
static void gwl_registry_wl_seat_update(GWL_Display *display,
const GWL_RegisteryUpdate_Params &params)
@ -8367,6 +8371,9 @@ GHOST_TSuccess GHOST_SystemWayland::cursor_visibility_set(const bool visible)
GHOST_TCapabilityFlag GHOST_SystemWayland::getCapabilities() const
{
GHOST_ASSERT(has_wl_trackpad_physical_direction != -1,
"The trackpad direction was expected to be initialized");
return GHOST_TCapabilityFlag(
GHOST_CAPABILITY_FLAG_ALL &
~(
@ -8388,7 +8395,9 @@ GHOST_TCapabilityFlag GHOST_SystemWayland::getCapabilities() const
* is negligible. */
GHOST_kCapabilityGPUReadFrontBuffer |
/* This WAYLAND back-end has not yet implemented desktop color sample. */
GHOST_kCapabilityDesktopSample));
GHOST_kCapabilityDesktopSample |
/* This flag will eventually be removed. */
(has_wl_trackpad_physical_direction ? 0 : GHOST_kCapabilityTrackpadPhysicalDirection)));
}
bool GHOST_SystemWayland::cursor_grab_use_software_display_get(const GHOST_TGrabCursorMode mode)

@ -186,10 +186,12 @@ enum eWM_CapabilitiesFlag {
WM_CAPABILITY_DESKTOP_SAMPLE = (1 << 5),
/** Support for IME input methods. */
WM_CAPABILITY_INPUT_IME = (1 << 6),
/** Trackpad physical scroll detection. */
WM_CAPABILITY_TRACKPAD_PHYSICAL_DIRECTION = (1 << 7),
/** The initial value, indicates the value needs to be set by inspecting GHOST. */
WM_CAPABILITY_INITIALIZED = (1u << 31),
};
ENUM_OPERATORS(eWM_CapabilitiesFlag, WM_CAPABILITY_INPUT_IME)
ENUM_OPERATORS(eWM_CapabilitiesFlag, WM_CAPABILITY_TRACKPAD_PHYSICAL_DIRECTION)
eWM_CapabilitiesFlag WM_capabilities_flag();

@ -2077,6 +2077,9 @@ eWM_CapabilitiesFlag WM_capabilities_flag()
if (ghost_flag & GHOST_kCapabilityInputIME) {
flag |= WM_CAPABILITY_INPUT_IME;
}
if (ghost_flag & GHOST_kCapabilityTrackpadPhysicalDirection) {
flag |= WM_CAPABILITY_TRACKPAD_PHYSICAL_DIRECTION;
}
return flag;
}