wayland: cursor-shape-v1 is now always available

Since we're requiring wayland-protocols >= 1.32
This commit is contained in:
Daniel Eklöf 2023-07-31 16:33:16 +02:00
parent 7eee415b75
commit 698c5b54f3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
10 changed files with 7 additions and 66 deletions

View file

@ -67,12 +67,11 @@ version_and_features(void)
{ {
static char buf[256]; static char buf[256];
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", "version: %s %cpgo %cime %cgraphemes %cassertions",
FOOT_VERSION, FOOT_VERSION,
feature_pgo() ? '+' : '-', feature_pgo() ? '+' : '-',
feature_ime() ? '+' : '-', feature_ime() ? '+' : '-',
feature_graphemes() ? '+' : '-', feature_graphemes() ? '+' : '-',
feature_cursor_shape() ? '+' : '-',
feature_assertions() ? '+' : '-'); feature_assertions() ? '+' : '-');
return buf; return buf;
} }

View file

@ -34,8 +34,6 @@ cursor_shape_to_string(enum cursor_shape shape)
return table[shape]; return table[shape];
} }
#if defined(HAVE_CURSOR_SHAPE)
enum wp_cursor_shape_device_v1_shape enum wp_cursor_shape_device_v1_shape
cursor_shape_to_server_shape(enum cursor_shape shape) cursor_shape_to_server_shape(enum cursor_shape shape)
{ {
@ -111,5 +109,3 @@ cursor_string_to_server_shape(const char *xcursor)
return 0; return 0;
} }
#endif /* HAVE_CURSOR_SHAPE */

View file

@ -1,8 +1,6 @@
#pragma once #pragma once
#if defined(HAVE_CURSOR_SHAPE)
#include <cursor-shape-v1.h> #include <cursor-shape-v1.h>
#endif
enum cursor_shape { enum cursor_shape {
CURSOR_SHAPE_NONE, CURSOR_SHAPE_NONE,
@ -26,9 +24,7 @@ enum cursor_shape {
const char *cursor_shape_to_string(enum cursor_shape shape); const char *cursor_shape_to_string(enum cursor_shape shape);
#if defined(HAVE_CURSOR_SHAPE)
enum wp_cursor_shape_device_v1_shape cursor_shape_to_server_shape( enum wp_cursor_shape_device_v1_shape cursor_shape_to_server_shape(
enum cursor_shape shape); enum cursor_shape shape);
enum wp_cursor_shape_device_v1_shape cursor_string_to_server_shape( enum wp_cursor_shape_device_v1_shape cursor_string_to_server_shape(
const char *xcursor); const char *xcursor);
#endif

View file

@ -37,12 +37,3 @@ static inline bool feature_graphemes(void)
return false; return false;
#endif #endif
} }
static inline bool feature_cursor_shape(void)
{
#if defined(HAVE_CURSOR_SHAPE)
return true;
#else
return false;
#endif
}

3
main.c
View file

@ -53,12 +53,11 @@ version_and_features(void)
{ {
static char buf[256]; static char buf[256];
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", "version: %s %cpgo %cime %cgraphemes %cassertions",
FOOT_VERSION, FOOT_VERSION,
feature_pgo() ? '+' : '-', feature_pgo() ? '+' : '-',
feature_ime() ? '+' : '-', feature_ime() ? '+' : '-',
feature_graphemes() ? '+' : '-', feature_graphemes() ? '+' : '-',
feature_cursor_shape() ? '+' : '-',
feature_assertions() ? '+' : '-'); feature_assertions() ? '+' : '-');
return buf; return buf;
} }

View file

@ -155,19 +155,10 @@ wl_proto_xml = [
wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml', wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml',
wayland_protocols_datadir + '/stable/viewporter/viewporter.xml', wayland_protocols_datadir + '/stable/viewporter/viewporter.xml',
wayland_protocols_datadir + '/staging/fractional-scale/fractional-scale-v1.xml', wayland_protocols_datadir + '/staging/fractional-scale/fractional-scale-v1.xml',
wayland_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml', # required by cursor-shape-v1
wayland_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml',
] ]
if wayland_protocols.version().version_compare('>=1.32')
wl_proto_xml += [
wayland_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml', # required by cursor-shape-v1
wayland_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml',
]
add_project_arguments('-DHAVE_CURSOR_SHAPE', language: 'c')
cursor_shape = true
else
cursor_shape = false
endif
foreach prot : wl_proto_xml foreach prot : wl_proto_xml
wl_proto_headers += custom_target( wl_proto_headers += custom_target(
prot.underscorify() + '-client-header', prot.underscorify() + '-client-header',
@ -382,7 +373,6 @@ summary(
'Themes': get_option('themes'), 'Themes': get_option('themes'),
'IME': get_option('ime'), 'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(), 'Grapheme clustering': utf8proc.found(),
'Wayland: cursor-shape-v1': cursor_shape,
'utmp backend': utmp_backend, 'utmp backend': utmp_backend,
'utmp helper default path': utmp_default_helper_path, 'utmp helper default path': utmp_default_helper_path,
'Build terminfo': tic.found(), 'Build terminfo': tic.found(),

View file

@ -4314,7 +4314,6 @@ render_xcursor_update(struct seat *seat)
xassert(seat->pointer.cursor != NULL); xassert(seat->pointer.cursor != NULL);
#if defined(HAVE_CURSOR_SHAPE)
const enum cursor_shape shape = seat->pointer.shape; const enum cursor_shape shape = seat->pointer.shape;
const char *const xcursor = seat->pointer.last_custom_xcursor; const char *const xcursor = seat->pointer.last_custom_xcursor;
@ -4344,7 +4343,6 @@ render_xcursor_update(struct seat *seat)
return; return;
} }
} }
#endif
LOG_DBG("setting %scursor shape using a client-side cursor surface", LOG_DBG("setting %scursor shape using a client-side cursor surface",
seat->pointer.shape == CURSOR_SHAPE_CUSTOM ? "custom " : ""); seat->pointer.shape == CURSOR_SHAPE_CUSTOM ? "custom " : "");

View file

@ -3176,12 +3176,8 @@ term_xcursor_update_for_seat(struct terminal *term, struct seat *seat)
if (seat->pointer.hidden) if (seat->pointer.hidden)
shape = CURSOR_SHAPE_HIDDEN; shape = CURSOR_SHAPE_HIDDEN;
#if defined(HAVE_CURSOR_SHAPE) else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 ||
else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 render_xcursor_is_valid(seat, term->mouse_user_cursor))
#else
else if (false
#endif
|| render_xcursor_is_valid(seat, term->mouse_user_cursor))
{ {
shape = CURSOR_SHAPE_CUSTOM; shape = CURSOR_SHAPE_CUSTOM;
} }

View file

@ -10,14 +10,11 @@
#include <sys/timerfd.h> #include <sys/timerfd.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <cursor-shape-v1.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-cursor.h> #include <wayland-cursor.h>
#include <xkbcommon/xkbcommon-compose.h> #include <xkbcommon/xkbcommon-compose.h>
#if defined(HAVE_CURSOR_SHAPE)
#include <cursor-shape-v1.h>
#endif
#include <tllist.h> #include <tllist.h>
#define LOG_MODULE "wayland" #define LOG_MODULE "wayland"
@ -210,12 +207,8 @@ seat_destroy(struct seat *seat)
zwp_primary_selection_device_v1_destroy(seat->primary_selection_device); zwp_primary_selection_device_v1_destroy(seat->primary_selection_device);
if (seat->data_device != NULL) if (seat->data_device != NULL)
wl_data_device_release(seat->data_device); wl_data_device_release(seat->data_device);
#if defined(HAVE_CURSOR_SHAPE)
if (seat->pointer.shape_device != NULL) if (seat->pointer.shape_device != NULL)
wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device); wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device);
#endif
if (seat->wl_keyboard != NULL) if (seat->wl_keyboard != NULL)
wl_keyboard_release(seat->wl_keyboard); wl_keyboard_release(seat->wl_keyboard);
if (seat->wl_pointer != NULL) if (seat->wl_pointer != NULL)
@ -328,22 +321,18 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
seat->wl_pointer = wl_seat_get_pointer(wl_seat); seat->wl_pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat); wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
#if defined(HAVE_CURSOR_SHAPE)
if (seat->wayl->cursor_shape_manager != NULL) { if (seat->wayl->cursor_shape_manager != NULL) {
xassert(seat->pointer.shape_device == NULL); xassert(seat->pointer.shape_device == NULL);
seat->pointer.shape_device = wp_cursor_shape_manager_v1_get_pointer( seat->pointer.shape_device = wp_cursor_shape_manager_v1_get_pointer(
seat->wayl->cursor_shape_manager, seat->wl_pointer); seat->wayl->cursor_shape_manager, seat->wl_pointer);
} }
#endif
} }
} else { } else {
if (seat->wl_pointer != NULL) { if (seat->wl_pointer != NULL) {
#if defined(HAVE_CURSOR_SHAPE)
if (seat->pointer.shape_device != NULL) { if (seat->pointer.shape_device != NULL) {
wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device); wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device);
seat->pointer.shape_device = NULL; seat->pointer.shape_device = NULL;
} }
#endif
wl_pointer_release(seat->wl_pointer); wl_pointer_release(seat->wl_pointer);
wl_surface_destroy(seat->pointer.surface.surf); wl_surface_destroy(seat->pointer.surface.surf);
@ -1239,7 +1228,6 @@ handle_global(void *data, struct wl_registry *registry,
&wp_fractional_scale_manager_v1_interface, required); &wp_fractional_scale_manager_v1_interface, required);
} }
#if defined(HAVE_CURSOR_SHAPE)
else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
const uint32_t required = 1; const uint32_t required = 1;
if (!verify_iface_version(interface, version, required)) if (!verify_iface_version(interface, version, required))
@ -1248,7 +1236,6 @@ handle_global(void *data, struct wl_registry *registry,
wayl->cursor_shape_manager = wl_registry_bind( wayl->cursor_shape_manager = wl_registry_bind(
wayl->registry, name, &wp_cursor_shape_manager_v1_interface, required); wayl->registry, name, &wp_cursor_shape_manager_v1_interface, required);
} }
#endif
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
else if (strcmp(interface, zwp_text_input_manager_v3_interface.name) == 0) { else if (strcmp(interface, zwp_text_input_manager_v3_interface.name) == 0) {
@ -1480,11 +1467,7 @@ wayl_init(struct fdm *fdm, struct key_binding_manager *key_binding_manager,
if (wayl->fractional_scale_manager == NULL || wayl->viewporter == NULL) if (wayl->fractional_scale_manager == NULL || wayl->viewporter == NULL)
LOG_WARN("fractional scaling not available"); LOG_WARN("fractional scaling not available");
#if defined(HAVE_CURSOR_SHAPE)
if (wayl->cursor_shape_manager == NULL) { if (wayl->cursor_shape_manager == NULL) {
#else
if (true) {
#endif
LOG_WARN("no server-side cursors available, " LOG_WARN("no server-side cursors available, "
"falling back to client-side cursors"); "falling back to client-side cursors");
} }
@ -1579,11 +1562,8 @@ wayl_destroy(struct wayland *wayl)
wp_fractional_scale_manager_v1_destroy(wayl->fractional_scale_manager); wp_fractional_scale_manager_v1_destroy(wayl->fractional_scale_manager);
if (wayl->viewporter != NULL) if (wayl->viewporter != NULL)
wp_viewporter_destroy(wayl->viewporter); wp_viewporter_destroy(wayl->viewporter);
#if defined(HAVE_CURSOR_SHAPE)
if (wayl->cursor_shape_manager != NULL) if (wayl->cursor_shape_manager != NULL)
wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager); wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager);
#endif
if (wayl->xdg_activation != NULL) if (wayl->xdg_activation != NULL)
xdg_activation_v1_destroy(wayl->xdg_activation); xdg_activation_v1_destroy(wayl->xdg_activation);
if (wayl->xdg_output_manager != NULL) if (wayl->xdg_output_manager != NULL)

View file

@ -152,9 +152,7 @@ struct seat {
struct wl_cursor *cursor; struct wl_cursor *cursor;
/* Server-side cursor */ /* Server-side cursor */
#if defined(HAVE_CURSOR_SHAPE)
struct wp_cursor_shape_device_v1 *shape_device; struct wp_cursor_shape_device_v1 *shape_device;
#endif
float scale; float scale;
bool hidden; bool hidden;
@ -443,9 +441,7 @@ struct wayland {
struct wp_viewporter *viewporter; struct wp_viewporter *viewporter;
struct wp_fractional_scale_manager_v1 *fractional_scale_manager; struct wp_fractional_scale_manager_v1 *fractional_scale_manager;
#if defined(HAVE_CURSOR_SHAPE)
struct wp_cursor_shape_manager_v1 *cursor_shape_manager; struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
#endif
bool presentation_timings; bool presentation_timings;
struct wp_presentation *presentation; struct wp_presentation *presentation;