From 698c5b54f32c885304d5e2ff55580ce7f52b5da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 31 Jul 2023 16:33:16 +0200 Subject: [PATCH] wayland: cursor-shape-v1 is now always available Since we're requiring wayland-protocols >= 1.32 --- client.c | 3 +-- cursor-shape.c | 4 ---- cursor-shape.h | 4 ---- foot-features.h | 9 --------- main.c | 3 +-- meson.build | 14 ++------------ render.c | 2 -- terminal.c | 8 ++------ wayland.c | 22 +--------------------- wayland.h | 4 ---- 10 files changed, 7 insertions(+), 66 deletions(-) diff --git a/client.c b/client.c index 4b334d5e..e68f71aa 100644 --- a/client.c +++ b/client.c @@ -67,12 +67,11 @@ version_and_features(void) { static char buf[256]; snprintf(buf, sizeof(buf), - "version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", + "version: %s %cpgo %cime %cgraphemes %cassertions", FOOT_VERSION, feature_pgo() ? '+' : '-', feature_ime() ? '+' : '-', feature_graphemes() ? '+' : '-', - feature_cursor_shape() ? '+' : '-', feature_assertions() ? '+' : '-'); return buf; } diff --git a/cursor-shape.c b/cursor-shape.c index aafeae8b..a5402928 100644 --- a/cursor-shape.c +++ b/cursor-shape.c @@ -34,8 +34,6 @@ cursor_shape_to_string(enum cursor_shape shape) return table[shape]; } -#if defined(HAVE_CURSOR_SHAPE) - enum wp_cursor_shape_device_v1_shape cursor_shape_to_server_shape(enum cursor_shape shape) { @@ -111,5 +109,3 @@ cursor_string_to_server_shape(const char *xcursor) return 0; } - -#endif /* HAVE_CURSOR_SHAPE */ diff --git a/cursor-shape.h b/cursor-shape.h index a9619553..58755382 100644 --- a/cursor-shape.h +++ b/cursor-shape.h @@ -1,8 +1,6 @@ #pragma once -#if defined(HAVE_CURSOR_SHAPE) #include -#endif enum cursor_shape { CURSOR_SHAPE_NONE, @@ -26,9 +24,7 @@ enum cursor_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 cursor_shape shape); enum wp_cursor_shape_device_v1_shape cursor_string_to_server_shape( const char *xcursor); -#endif diff --git a/foot-features.h b/foot-features.h index f810a0fc..ad447767 100644 --- a/foot-features.h +++ b/foot-features.h @@ -37,12 +37,3 @@ static inline bool feature_graphemes(void) return false; #endif } - -static inline bool feature_cursor_shape(void) -{ -#if defined(HAVE_CURSOR_SHAPE) - return true; -#else - return false; -#endif -} diff --git a/main.c b/main.c index 95cbf0b9..631ef167 100644 --- a/main.c +++ b/main.c @@ -53,12 +53,11 @@ version_and_features(void) { static char buf[256]; snprintf(buf, sizeof(buf), - "version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", + "version: %s %cpgo %cime %cgraphemes %cassertions", FOOT_VERSION, feature_pgo() ? '+' : '-', feature_ime() ? '+' : '-', feature_graphemes() ? '+' : '-', - feature_cursor_shape() ? '+' : '-', feature_assertions() ? '+' : '-'); return buf; } diff --git a/meson.build b/meson.build index 2e3c64ac..729d8f03 100644 --- a/meson.build +++ b/meson.build @@ -155,19 +155,10 @@ wl_proto_xml = [ wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml', wayland_protocols_datadir + '/stable/viewporter/viewporter.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 wl_proto_headers += custom_target( prot.underscorify() + '-client-header', @@ -382,7 +373,6 @@ summary( 'Themes': get_option('themes'), 'IME': get_option('ime'), 'Grapheme clustering': utf8proc.found(), - 'Wayland: cursor-shape-v1': cursor_shape, 'utmp backend': utmp_backend, 'utmp helper default path': utmp_default_helper_path, 'Build terminfo': tic.found(), diff --git a/render.c b/render.c index 05d29c25..70b3fba0 100644 --- a/render.c +++ b/render.c @@ -4314,7 +4314,6 @@ render_xcursor_update(struct seat *seat) xassert(seat->pointer.cursor != NULL); -#if defined(HAVE_CURSOR_SHAPE) const enum cursor_shape shape = seat->pointer.shape; const char *const xcursor = seat->pointer.last_custom_xcursor; @@ -4344,7 +4343,6 @@ render_xcursor_update(struct seat *seat) return; } } -#endif LOG_DBG("setting %scursor shape using a client-side cursor surface", seat->pointer.shape == CURSOR_SHAPE_CUSTOM ? "custom " : ""); diff --git a/terminal.c b/terminal.c index bbc98efc..2f81adc8 100644 --- a/terminal.c +++ b/terminal.c @@ -3176,12 +3176,8 @@ term_xcursor_update_for_seat(struct terminal *term, struct seat *seat) if (seat->pointer.hidden) shape = CURSOR_SHAPE_HIDDEN; -#if defined(HAVE_CURSOR_SHAPE) - else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 -#else - else if (false -#endif - || render_xcursor_is_valid(seat, term->mouse_user_cursor)) + else if (cursor_string_to_server_shape(term->mouse_user_cursor) != 0 || + render_xcursor_is_valid(seat, term->mouse_user_cursor)) { shape = CURSOR_SHAPE_CUSTOM; } diff --git a/wayland.c b/wayland.c index 2c664fbf..d558c489 100644 --- a/wayland.c +++ b/wayland.c @@ -10,14 +10,11 @@ #include #include +#include #include #include #include -#if defined(HAVE_CURSOR_SHAPE) -#include -#endif - #include #define LOG_MODULE "wayland" @@ -210,12 +207,8 @@ seat_destroy(struct seat *seat) zwp_primary_selection_device_v1_destroy(seat->primary_selection_device); if (seat->data_device != NULL) wl_data_device_release(seat->data_device); - -#if defined(HAVE_CURSOR_SHAPE) if (seat->pointer.shape_device != NULL) wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device); -#endif - if (seat->wl_keyboard != NULL) wl_keyboard_release(seat->wl_keyboard); 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); wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat); -#if defined(HAVE_CURSOR_SHAPE) if (seat->wayl->cursor_shape_manager != NULL) { xassert(seat->pointer.shape_device == NULL); seat->pointer.shape_device = wp_cursor_shape_manager_v1_get_pointer( seat->wayl->cursor_shape_manager, seat->wl_pointer); } -#endif } } else { if (seat->wl_pointer != NULL) { -#if defined(HAVE_CURSOR_SHAPE) if (seat->pointer.shape_device != NULL) { wp_cursor_shape_device_v1_destroy(seat->pointer.shape_device); seat->pointer.shape_device = NULL; } -#endif wl_pointer_release(seat->wl_pointer); 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); } -#if defined(HAVE_CURSOR_SHAPE) else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { const uint32_t required = 1; 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->registry, name, &wp_cursor_shape_manager_v1_interface, required); } -#endif #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED 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) LOG_WARN("fractional scaling not available"); -#if defined(HAVE_CURSOR_SHAPE) if (wayl->cursor_shape_manager == NULL) { -#else - if (true) { -#endif LOG_WARN("no server-side cursors available, " "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); if (wayl->viewporter != NULL) wp_viewporter_destroy(wayl->viewporter); - -#if defined(HAVE_CURSOR_SHAPE) if (wayl->cursor_shape_manager != NULL) wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager); -#endif if (wayl->xdg_activation != NULL) xdg_activation_v1_destroy(wayl->xdg_activation); if (wayl->xdg_output_manager != NULL) diff --git a/wayland.h b/wayland.h index 4130bc09..6585191f 100644 --- a/wayland.h +++ b/wayland.h @@ -152,9 +152,7 @@ struct seat { struct wl_cursor *cursor; /* Server-side cursor */ -#if defined(HAVE_CURSOR_SHAPE) struct wp_cursor_shape_device_v1 *shape_device; -#endif float scale; bool hidden; @@ -443,9 +441,7 @@ struct wayland { struct wp_viewporter *viewporter; struct wp_fractional_scale_manager_v1 *fractional_scale_manager; -#if defined(HAVE_CURSOR_SHAPE) struct wp_cursor_shape_manager_v1 *cursor_shape_manager; -#endif bool presentation_timings; struct wp_presentation *presentation;