Skip to content

Commit 8101ce2

Browse files
committed
wayland: Set framebuffer scale when creating an OpenGL context
1 parent ff003fb commit 8101ce2

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

gui-lib/mred/private/wx/gtk/gl-context.rkt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@
422422

423423
(define/public (gl-update-size x y w h)
424424
(when win
425-
(wl_egl_window_resize win w h 0 0)
425+
(define scale (if widget (gtk_widget_get_scale_factor widget) 1))
426+
(wl_egl_window_resize win (* scale w) (* scale h) 0 0)
426427
(when (and widget wl-subsurface)
427428
(define toplevel (gtk_widget_get_toplevel widget))
428429
(define-values (dx dy)
@@ -702,10 +703,11 @@
702703
(error 'EGL "subcompositor failed")))
703704

704705
(define (create recreate?)
706+
(define scale (gtk_widget_get_scale_factor widget))
705707
(define-values (width height)
706708
(let ([a (widget-allocation widget)])
707-
(values (GtkAllocation-width a)
708-
(GtkAllocation-height a))))
709+
(values (* scale (GtkAllocation-width a))
710+
(* scale (GtkAllocation-height a)))))
709711

710712
(define wl-surface/sub (or (wayland-compositor-create-surface wl-compositor)
711713
(error 'EGL "subsurface create failed")))
@@ -728,6 +730,7 @@
728730
(wayland-region-destroy region))
729731
(wayland-subsurface-set-position wl-subsurface dx dy)
730732
(wayland-subsurface-set-sync wl-subsurface #f)
733+
(wayland-surface-set-buffer-scale wl-surface/sub scale)
731734
(wayland-surface-commit wl-surface/sub)
732735
(wayland-surface-commit wl-surface))
733736

gui-lib/mred/private/wx/gtk/wayland.rkt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
wayland-subsurface-set-position
1313
wayland-subsurface-set-sync
1414
wayland-surface-commit
15+
wayland-surface-set-buffer-scale
1516
wayland-surface-destroy
1617
wayland-roundtrip
1718
wayland-display-dispatch-pending
@@ -62,6 +63,7 @@
6263
(define WL_SURFACE_FRAME 3)
6364
(define WL_SURFACE_SET_INPUT_REGION 5)
6465
(define WL_SURFACE_COMMIT 6)
66+
(define WL_SURFACE_SET_BUFFER_SCALE 8)
6567
(define WL_REGION_DESTROY 0)
6668

6769
(define _registry (_cpointer/null 'wl_registry))
@@ -132,6 +134,14 @@
132134
-> _pointer
133135
-> (void))
134136
#:c-id wl_proxy_marshal_flags)
137+
(define-wayland wl_proxy_marshal_flags/wl_surface_set_buffer_scale
138+
(_fun #:varargs-after 5
139+
_pointer _uint32 _pointer _uint32
140+
_uint32
141+
_int32
142+
-> _pointer
143+
-> (void))
144+
#:c-id wl_proxy_marshal_flags)
135145
(define-wayland wl_proxy_marshal_flags/wl_surface_<object>
136146
(_fun #:varargs-after 5
137147
_pointer _uint32 _pointer _uint32
@@ -226,6 +236,14 @@
226236
#f (wl_proxy_get_version surface)
227237
0))
228238

239+
(define (wayland-surface-set-buffer-scale surface scale)
240+
(wl_proxy_marshal_flags/wl_surface_set_buffer_scale
241+
surface
242+
WL_SURFACE_SET_BUFFER_SCALE
243+
#f (wl_proxy_get_version surface)
244+
0
245+
scale))
246+
229247
(define (wayland-surface-destroy surface)
230248
(wl_proxy_marshal_flags/wl_<object>_destroy
231249
surface

0 commit comments

Comments
 (0)