diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-07-31 14:32:53 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-08-07 14:53:19 +0000 |
| commit | 7eee415b7573f5a20852c6e29001945149e920a2 (patch) | |
| tree | 5ab946564dc5ce701c3e906688563143413a0bb4 | |
| parent | wayland: xdg-activation is now always available (diff) | |
wayland: fractional-scale-v1 is now always available
Since we're requiring wayland-protocols >= 1.32
| -rw-r--r-- | client.c | 3 | ||||
| -rw-r--r-- | foot-features.h | 9 | ||||
| -rw-r--r-- | main.c | 3 | ||||
| -rw-r--r-- | meson.build | 11 | ||||
| -rw-r--r-- | terminal.c | 4 | ||||
| -rw-r--r-- | wayland.c | 39 | ||||
| -rw-r--r-- | wayland.h | 26 |
7 files changed, 17 insertions, 78 deletions
@@ -67,12 +67,11 @@ version_and_features(void) { static char buf[256]; snprintf(buf, sizeof(buf), - "version: %s %cpgo %cime %cgraphemes %cfractional-scaling %ccursor-shape %cassertions", + "version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", FOOT_VERSION, feature_pgo() ? '+' : '-', feature_ime() ? '+' : '-', feature_graphemes() ? '+' : '-', - feature_fractional_scaling() ? '+' : ':', feature_cursor_shape() ? '+' : '-', feature_assertions() ? '+' : '-'); return buf; diff --git a/foot-features.h b/foot-features.h index f8043c12..f810a0fc 100644 --- a/foot-features.h +++ b/foot-features.h @@ -38,15 +38,6 @@ static inline bool feature_graphemes(void) #endif } -static inline bool feature_fractional_scaling(void) -{ -#if defined(HAVE_FRACTIONAL_SCALE) - return true; -#else - return false; -#endif -} - static inline bool feature_cursor_shape(void) { #if defined(HAVE_CURSOR_SHAPE) @@ -53,12 +53,11 @@ version_and_features(void) { static char buf[256]; snprintf(buf, sizeof(buf), - "version: %s %cpgo %cime %cgraphemes %cfractional-scaling %ccursor-shape %cassertions", + "version: %s %cpgo %cime %cgraphemes %ccursor-shape %cassertions", FOOT_VERSION, feature_pgo() ? '+' : '-', feature_ime() ? '+' : '-', feature_graphemes() ? '+' : '-', - feature_fractional_scaling() ? '+' : '-', feature_cursor_shape() ? '+' : '-', feature_assertions() ? '+' : '-'); return buf; diff --git a/meson.build b/meson.build index c6a9228d..2e3c64ac 100644 --- a/meson.build +++ b/meson.build @@ -153,16 +153,10 @@ wl_proto_xml = [ wayland_protocols_datadir + '/stable/presentation-time/presentation-time.xml', wayland_protocols_datadir + '/unstable/text-input/text-input-unstable-v3.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', ] -if wayland_protocols.version().version_compare('>=1.31') - add_project_arguments('-DHAVE_FRACTIONAL_SCALE', language: 'c') - wl_proto_xml += [wayland_protocols_datadir + '/stable/viewporter/viewporter.xml'] - wl_proto_xml += [wayland_protocols_datadir + '/staging/fractional-scale/fractional-scale-v1.xml'] - fractional_scale = true -else - fractional_scale = false -endif 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 @@ -388,7 +382,6 @@ summary( 'Themes': get_option('themes'), 'IME': get_option('ime'), 'Grapheme clustering': utf8proc.found(), - 'Wayland: fractional-scale-v1': fractional_scale, 'Wayland: cursor-shape-v1': cursor_shape, 'utmp backend': utmp_backend, 'utmp helper default path': utmp_default_helper_path, @@ -2080,11 +2080,7 @@ term_font_size_reset(struct terminal *term) bool term_fractional_scaling(const struct terminal *term) { -#if defined(HAVE_FRACTIONAL_SCALE) return term->wl->fractional_scale_manager != NULL && term->window->scale > 0.; -#else - return false; -#endif } bool @@ -193,10 +193,8 @@ seat_destroy(struct seat *seat) wl_cursor_theme_destroy(seat->pointer.theme); if (seat->pointer.surface.surf != NULL) wl_surface_destroy(seat->pointer.surface.surf); -#if defined(HAVE_FRACTIONAL_SCALE) if (seat->pointer.surface.viewport != NULL) wp_viewport_destroy(seat->pointer.surface.viewport); -#endif if (seat->pointer.xcursor_callback != NULL) wl_callback_destroy(seat->pointer.xcursor_callback); @@ -314,7 +312,6 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat, return; } -#if defined(HAVE_FRACTIONAL_SCALE) if (seat->wayl->viewporter != NULL) { xassert(seat->pointer.surface.viewport == NULL); seat->pointer.surface.viewport = wp_viewporter_get_viewport( @@ -327,7 +324,6 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat, return; } } -#endif seat->wl_pointer = wl_seat_get_pointer(wl_seat); wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat); @@ -352,12 +348,10 @@ seat_handle_capabilities(void *data, struct wl_seat *wl_seat, wl_pointer_release(seat->wl_pointer); wl_surface_destroy(seat->pointer.surface.surf); -#if defined(HAVE_FRACTIONAL_SCALE) if (seat->pointer.surface.viewport != NULL) { wp_viewport_destroy(seat->pointer.surface.viewport); seat->pointer.surface.viewport = NULL; } -#endif if (seat->pointer.theme != NULL) wl_cursor_theme_destroy(seat->pointer.theme); @@ -1226,7 +1220,6 @@ handle_global(void *data, struct wl_registry *registry, wayl->registry, name, &xdg_activation_v1_interface, required); } -#if defined(HAVE_FRACTIONAL_SCALE) else if (strcmp(interface, wp_viewporter_interface.name) == 0) { const uint32_t required = 1; if (!verify_iface_version(interface, version, required)) @@ -1245,7 +1238,6 @@ handle_global(void *data, struct wl_registry *registry, wayl->registry, name, &wp_fractional_scale_manager_v1_interface, required); } -#endif #if defined(HAVE_CURSOR_SHAPE) else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) { @@ -1485,13 +1477,8 @@ wayl_init(struct fdm *fdm, struct key_binding_manager *key_binding_manager, "bell.urgent will fall back to coloring the window margins red"); } -#if defined(HAVE_FRACTIONAL_SCALE) - if (wayl->fractional_scale_manager == NULL || wayl->viewporter == NULL) { -#else - if (true) { -#endif + 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) { @@ -1588,12 +1575,11 @@ wayl_destroy(struct wayland *wayl) zwp_text_input_manager_v3_destroy(wayl->text_input_manager); #endif -#if defined(HAVE_FRACTIONAL_SCALE) if (wayl->fractional_scale_manager != NULL) wp_fractional_scale_manager_v1_destroy(wayl->fractional_scale_manager); if (wayl->viewporter != NULL) wp_viewporter_destroy(wayl->viewporter); -#endif + #if defined(HAVE_CURSOR_SHAPE) if (wayl->cursor_shape_manager != NULL) wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager); @@ -1630,8 +1616,8 @@ wayl_destroy(struct wayland *wayl) free(wayl); } -#if defined(HAVE_FRACTIONAL_SCALE) -static void fractional_scale_preferred_scale( +static void +fractional_scale_preferred_scale( void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) { @@ -1651,7 +1637,6 @@ static void fractional_scale_preferred_scale( static const struct wp_fractional_scale_v1_listener fractional_scale_listener = { .preferred_scale = &fractional_scale_preferred_scale, }; -#endif struct wl_window * wayl_win_init(struct terminal *term, const char *token) @@ -1684,7 +1669,6 @@ wayl_win_init(struct terminal *term, const char *token) wl_surface_add_listener(win->surface.surf, &surface_listener, win); -#if defined(HAVE_FRACTIONAL_SCALE) if (wayl->fractional_scale_manager != NULL && wayl->viewporter != NULL) { win->surface.viewport = wp_viewporter_get_viewport(wayl->viewporter, win->surface.surf); @@ -1694,7 +1678,6 @@ wayl_win_init(struct terminal *term, const char *token) wp_fractional_scale_v1_add_listener( win->fractional_scale, &fractional_scale_listener, win); } -#endif win->xdg_surface = xdg_wm_base_get_xdg_surface(wayl->shell, win->surface.surf); xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win); @@ -1847,12 +1830,10 @@ wayl_win_destroy(struct wl_window *win) tll_remove(win->xdg_tokens, it); } -#if defined(HAVE_FRACTIONAL_SCALE) if (win->fractional_scale != NULL) wp_fractional_scale_v1_destroy(win->fractional_scale); if (win->surface.viewport != NULL) wp_viewport_destroy(win->surface.viewport); -#endif if (win->frame_callback != NULL) wl_callback_destroy(win->frame_callback); if (win->xdg_toplevel_decoration != NULL) @@ -1995,7 +1976,6 @@ surface_scale_explicit_width_height( int width, int height, float scale, bool verify) { if (term_fractional_scaling(win->term)) { -#if defined(HAVE_FRACTIONAL_SCALE) LOG_DBG("scaling by a factor of %.2f using fractional scaling " "(width=%d, height=%d) ", scale, width, height); @@ -2018,10 +1998,6 @@ surface_scale_explicit_width_height( wl_surface_set_buffer_scale(surf->surf, 1); wp_viewport_set_destination( surf->viewport, roundf(width / scale), roundf(height / scale)); -#else - BUG("wayl_fraction_scaling() returned true, " - "but fractional scaling was not available at compile time"); -#endif } else { LOG_DBG("scaling by a factor of %.2f using legacy mode " "(width=%d, height=%d)", scale, width, height); @@ -2152,7 +2128,6 @@ wayl_win_subsurface_new_with_custom_parent( return false; } -#if defined(HAVE_FRACTIONAL_SCALE) struct wp_viewport *viewport = NULL; if (wayl->fractional_scale_manager != NULL && wayl->viewporter != NULL) { viewport = wp_viewporter_get_viewport(wayl->viewporter, main_surface); @@ -2163,7 +2138,6 @@ wayl_win_subsurface_new_with_custom_parent( return false; } } -#endif wl_surface_set_user_data(main_surface, win); wl_subsurface_set_sync(sub); @@ -2178,9 +2152,7 @@ wayl_win_subsurface_new_with_custom_parent( surf->surface.surf = main_surface; surf->sub = sub; -#if defined(HAVE_FRACTIONAL_SCALE) surf->surface.viewport = viewport; -#endif return true; } @@ -2198,12 +2170,11 @@ wayl_win_subsurface_destroy(struct wayl_sub_surface *surf) if (surf == NULL) return; -#if defined(HAVE_FRACTIONAL_SCALE) if (surf->surface.viewport != NULL) { wp_viewport_destroy(surf->surface.viewport); surf->surface.viewport = NULL; } -#endif + if (surf->sub != NULL) { wl_subsurface_destroy(surf->sub); surf->sub = NULL; @@ -9,18 +9,15 @@ #include <xkbcommon/xkbcommon.h> /* Wayland protocols */ +#include <fractional-scale-v1.h> #include <presentation-time.h> #include <primary-selection-unstable-v1.h> #include <text-input-unstable-v3.h> +#include <viewporter.h> +#include <xdg-activation-v1.h> #include <xdg-decoration-unstable-v1.h> #include <xdg-output-unstable-v1.h> #include <xdg-shell.h> -#include <xdg-activation-v1.h> - -#if defined(HAVE_FRACTIONAL_SCALE) - #include <viewporter.h> - #include <fractional-scale-v1.h> -#endif #include <fcft/fcft.h> #include <tllist.h> @@ -54,9 +51,7 @@ enum touch_state { struct wayl_surface { struct wl_surface *surf; -#if defined(HAVE_FRACTIONAL_SCALE) struct wp_viewport *viewport; -#endif }; struct wayl_sub_surface { @@ -362,15 +357,12 @@ struct wl_window { struct wayl_surface surface; struct xdg_surface *xdg_surface; struct xdg_toplevel *xdg_toplevel; + struct wp_fractional_scale_v1 *fractional_scale; tll(struct xdg_activation_token_context *) xdg_tokens; bool urgency_token_is_pending; -#if defined(HAVE_FRACTIONAL_SCALE) - struct wp_fractional_scale_v1 *fractional_scale; -#endif bool unmapped; - float scale; struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration; @@ -448,6 +440,9 @@ struct wayland { struct xdg_activation_v1 *xdg_activation; + 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 @@ -455,16 +450,11 @@ struct wayland { bool presentation_timings; struct wp_presentation *presentation; uint32_t presentation_clock_id; - + #if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED struct zwp_text_input_manager_v3 *text_input_manager; #endif -#if defined(HAVE_FRACTIONAL_SCALE) - struct wp_viewporter *viewporter; - struct wp_fractional_scale_manager_v1 *fractional_scale_manager; -#endif - bool have_argb8888; tll(struct monitor) monitors; /* All available outputs */ tll(struct seat) seats; |
