mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-18 06:46:23 -04:00
wayland: plumbing for wp-fractional-scale
* Bind the wp-viewporter and wp-fractional-scale-manager globals. * Create a viewport and fractional-scale when instantiating a window. * Add fractional-scale listener (that does nothing at the moment). * Destroy everything on teardown.
This commit is contained in:
parent
1e6204e1ac
commit
a9ecf1449e
2 changed files with 77 additions and 0 deletions
61
wayland.c
61
wayland.c
|
|
@ -1121,6 +1121,27 @@ handle_global(void *data, struct wl_registry *registry,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#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))
|
||||||
|
return;
|
||||||
|
|
||||||
|
wayl->viewporter = wl_registry_bind(
|
||||||
|
wayl->registry, name, &wp_viewporter_interface, required);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(interface, wp_fractional_scale_manager_v1_interface.name) == 0) {
|
||||||
|
const uint32_t required = 1;
|
||||||
|
if (!verify_iface_version(interface, version, required))
|
||||||
|
return;
|
||||||
|
|
||||||
|
wayl->fractional_scale_manager = wl_registry_bind(
|
||||||
|
wayl->registry, name,
|
||||||
|
&wp_fractional_scale_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) {
|
||||||
const uint32_t required = 1;
|
const uint32_t required = 1;
|
||||||
|
|
@ -1435,6 +1456,12 @@ wayl_destroy(struct wayland *wayl)
|
||||||
zwp_text_input_manager_v3_destroy(wayl->text_input_manager);
|
zwp_text_input_manager_v3_destroy(wayl->text_input_manager);
|
||||||
#endif
|
#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_XDG_ACTIVATION)
|
#if defined(HAVE_XDG_ACTIVATION)
|
||||||
if (wayl->xdg_activation != NULL)
|
if (wayl->xdg_activation != NULL)
|
||||||
xdg_activation_v1_destroy(wayl->xdg_activation);
|
xdg_activation_v1_destroy(wayl->xdg_activation);
|
||||||
|
|
@ -1469,6 +1496,21 @@ wayl_destroy(struct wayland *wayl)
|
||||||
free(wayl);
|
free(wayl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
static void fractional_scale_preferred_scale(
|
||||||
|
void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1,
|
||||||
|
uint32_t scale)
|
||||||
|
{
|
||||||
|
struct wl_window *win = data;
|
||||||
|
win->scale = (float)scale / 120.;
|
||||||
|
LOG_DBG("fractional scale: %.3f", win->scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct wp_fractional_scale_v1_listener fractional_scale_listener = {
|
||||||
|
.preferred_scale = &fractional_scale_preferred_scale,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct wl_window *
|
struct wl_window *
|
||||||
wayl_win_init(struct terminal *term, const char *token)
|
wayl_win_init(struct terminal *term, const char *token)
|
||||||
{
|
{
|
||||||
|
|
@ -1499,6 +1541,19 @@ wayl_win_init(struct terminal *term, const char *token)
|
||||||
|
|
||||||
wl_surface_add_listener(win->surface, &surface_listener, win);
|
wl_surface_add_listener(win->surface, &surface_listener, win);
|
||||||
|
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
if (wayl->fractional_scale_manager != NULL && wayl->viewporter != NULL) {
|
||||||
|
LOG_ERR("LDKJFLDF");
|
||||||
|
win->viewport = wp_viewporter_get_viewport(wayl->viewporter, win->surface);
|
||||||
|
|
||||||
|
win->fractional_scale =
|
||||||
|
wp_fractional_scale_manager_v1_get_fractional_scale(
|
||||||
|
wayl->fractional_scale_manager, win->surface);
|
||||||
|
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);
|
win->xdg_surface = xdg_wm_base_get_xdg_surface(wayl->shell, win->surface);
|
||||||
xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win);
|
xdg_surface_add_listener(win->xdg_surface, &xdg_surface_listener, win);
|
||||||
|
|
||||||
|
|
@ -1652,6 +1707,12 @@ wayl_win_destroy(struct wl_window *win)
|
||||||
|
|
||||||
tll_remove(win->xdg_tokens, it);
|
tll_remove(win->xdg_tokens, it);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
if (win->fractional_scale != NULL)
|
||||||
|
wp_fractional_scale_v1_destroy(win->fractional_scale);
|
||||||
|
if (win->viewport != NULL)
|
||||||
|
wp_viewport_destroy(win->viewport);
|
||||||
#endif
|
#endif
|
||||||
if (win->frame_callback != NULL)
|
if (win->frame_callback != NULL)
|
||||||
wl_callback_destroy(win->frame_callback);
|
wl_callback_destroy(win->frame_callback);
|
||||||
|
|
|
||||||
16
wayland.h
16
wayland.h
|
|
@ -20,6 +20,11 @@
|
||||||
#include <xdg-activation-v1.h>
|
#include <xdg-activation-v1.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
#include <viewporter.h>
|
||||||
|
#include <fractional-scale-v1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fcft/fcft.h>
|
#include <fcft/fcft.h>
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
|
|
@ -326,9 +331,15 @@ struct wl_window {
|
||||||
#if defined(HAVE_XDG_ACTIVATION)
|
#if defined(HAVE_XDG_ACTIVATION)
|
||||||
tll(struct xdg_activation_token_context *) xdg_tokens;
|
tll(struct xdg_activation_token_context *) xdg_tokens;
|
||||||
bool urgency_token_is_pending;
|
bool urgency_token_is_pending;
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
struct wp_viewport *viewport;
|
||||||
|
struct wp_fractional_scale_v1 *fractional_scale;
|
||||||
#endif
|
#endif
|
||||||
bool unmapped;
|
bool unmapped;
|
||||||
|
|
||||||
|
float scale;
|
||||||
|
|
||||||
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
|
||||||
|
|
||||||
enum csd_mode csd_mode;
|
enum csd_mode csd_mode;
|
||||||
|
|
@ -414,6 +425,11 @@ struct wayland {
|
||||||
struct zwp_text_input_manager_v3 *text_input_manager;
|
struct zwp_text_input_manager_v3 *text_input_manager;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_FRACTIONAL_SCALE)
|
||||||
|
struct wp_viewporter *viewporter;
|
||||||
|
struct wp_fractional_scale_manager_v1 *fractional_scale_manager;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool have_argb8888;
|
bool have_argb8888;
|
||||||
tll(struct monitor) monitors; /* All available outputs */
|
tll(struct monitor) monitors; /* All available outputs */
|
||||||
tll(struct seat) seats;
|
tll(struct seat) seats;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue