mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
wayland: fractional-scale-v1 is now always available
Since we're requiring wayland-protocols >= 1.32
This commit is contained in:
parent
d59a4e7a77
commit
7eee415b75
7 changed files with 17 additions and 78 deletions
39
wayland.c
39
wayland.c
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue