aboutsummaryrefslogtreecommitdiff
path: root/wayland.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-06-26 13:51:04 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-06-29 13:38:23 +0000
commit0a5073f5703e89cfa4219d5b532cb134f9def6d5 (patch)
tree4f083a5222aa346943dfd9ec8315a6e26c5e3184 /wayland.c
parentrender: maybe_resize(): convert local variable ‘scale’ to float (diff)
wayland: add wayl_surface_scale(), and wayl_win_scale()
These functions scale a surface+buffer. For now, only using the legacy scaling method (wl_surface_set_buffer_scale()).
Diffstat (limited to 'wayland.c')
-rw-r--r--wayland.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/wayland.c b/wayland.c
index e01a3a50..5aa10966 100644
--- a/wayland.c
+++ b/wayland.c
@@ -1850,6 +1850,40 @@ wayl_roundtrip(struct wayland *wayl)
wayl_flush(wayl);
}
+
+bool
+wayl_fractional_scaling(const struct wayland *wayl)
+{
+#if defined(HAVE_FRACTIONAL_SCALE)
+ return wayl->fractional_scale_manager != NULL;
+#else
+ return false;
+#endif
+}
+
+void
+wayl_surface_scale(const struct wayland *wayl, struct wl_surface *surf,
+ float scale)
+{
+ LOG_WARN("scaling by a factor of %.2f (legacy)", scale);
+
+ if (wayl_fractional_scaling(wayl)) {
+ BUG("not yet implemented");
+ } else {
+ wl_surface_set_buffer_scale(surf, (int)scale);
+ }
+}
+
+void
+wayl_win_scale(struct wl_window *win)
+{
+ const struct terminal *term = win->term;
+ const struct wayland *wayl = term->wl;
+ const float scale = term->scale;
+
+ wayl_surface_scale(wayl, win->surface, scale);
+}
+
void
wayl_win_alpha_changed(struct wl_window *win)
{
@@ -2048,13 +2082,3 @@ wayl_get_activation_token(
return true;
}
#endif
-
-bool
-wayl_fractional_scaling(const struct wayland *wayl)
-{
-#if defined(HAVE_FRACTIONAL_SCALE)
- return wayl->fractional_scale_manager != NULL;
-#else
- return false;
-#endif
-}