@ng-native/desktop 0.26.1 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +6 -3
  2. package/bin/app-config.mjs +1 -0
  3. package/bin/archive.mjs +166 -0
  4. package/bin/autolink.mjs +61 -30
  5. package/bin/cli.mjs +127 -27
  6. package/bin/host.mjs +255 -58
  7. package/bin/package-linux.mjs +1394 -0
  8. package/bin/package.mjs +171 -35
  9. package/bin/plist.mjs +6 -2
  10. package/bin/png-icon.mjs +315 -0
  11. package/bin/prebuilt.mjs +147 -26
  12. package/bin/toolchain.mjs +258 -19
  13. package/native/CMakeLists.txt +64 -6
  14. package/native/appkit/CMakeLists.txt +2 -1
  15. package/native/appkit/appkit-backend.h +1 -0
  16. package/native/appkit/appkit-backend.mm +13 -0
  17. package/native/appkit/header-toolbar.mm +28 -25
  18. package/native/appkit/host-view.h +10 -0
  19. package/native/appkit/host-view.mm +146 -40
  20. package/native/appkit/input-replay.h +6 -0
  21. package/native/appkit/input-replay.mm +21 -12
  22. package/native/appkit/main.mm +11 -7
  23. package/native/appkit/native-controls.mm +13 -1
  24. package/native/appkit/split-view.mm +7 -13
  25. package/native/appkit/text-input-field.h +4 -0
  26. package/native/appkit/text-input-field.mm +20 -1
  27. package/native/cmake/curl.cmake +79 -0
  28. package/native/cmake/libraries/react-native-reanimated.cmake +5 -0
  29. package/native/cmake/libraries/react-native-worklets.cmake +5 -0
  30. package/native/cmake/linked-modules.cmake +20 -4
  31. package/native/cmake/react-native.cmake +18 -1
  32. package/native/core/include/ngn/accent-colors.h +38 -0
  33. package/native/core/include/ngn/accessibility-relations.h +65 -0
  34. package/native/core/include/ngn/accessibility.h +26 -0
  35. package/native/core/include/ngn/animated-frame-loop.h +56 -0
  36. package/native/core/include/ngn/app-info.h +24 -8
  37. package/native/core/include/ngn/app-menus.h +14 -1
  38. package/native/core/include/ngn/app-windows.h +15 -2
  39. package/native/core/include/ngn/aria-role.h +96 -0
  40. package/native/core/include/ngn/audio.h +2 -0
  41. package/native/core/include/ngn/camera.h +9 -0
  42. package/native/core/include/ngn/control-sizes.h +7 -2
  43. package/native/core/include/ngn/crash-report.h +31 -0
  44. package/native/core/include/ngn/curl-network.h +93 -0
  45. package/native/core/include/ngn/dbus-menu.h +39 -0
  46. package/native/core/include/ngn/default-menu.h +36 -0
  47. package/native/core/include/ngn/desktop-expo.h +7 -1
  48. package/native/core/include/ngn/desktop-modules.h +22 -0
  49. package/native/core/include/ngn/desktop-props.h +21 -1
  50. package/native/core/include/ngn/desktop-view-props.h +6 -0
  51. package/native/core/include/ngn/focus-order.h +10 -0
  52. package/native/core/include/ngn/header-bar.h +22 -0
  53. package/native/core/include/ngn/host-os.h +6 -0
  54. package/native/core/include/ngn/host-reload.h +21 -0
  55. package/native/core/include/ngn/host-state.h +23 -0
  56. package/native/core/include/ngn/image-source.h +26 -1
  57. package/native/core/include/ngn/input-script.h +3 -3
  58. package/native/core/include/ngn/input.h +4 -1
  59. package/native/core/include/ngn/launch-frame.h +21 -0
  60. package/native/core/include/ngn/launch-settings.h +23 -5
  61. package/native/core/include/ngn/mounting-backend.h +5 -0
  62. package/native/core/include/ngn/mounting-manager.h +1 -0
  63. package/native/core/include/ngn/native-controls.h +26 -5
  64. package/native/core/include/ngn/notification-schedule.h +74 -0
  65. package/native/core/include/ngn/notifications.h +2 -1
  66. package/native/core/include/ngn/openssl-update-crypto.h +15 -0
  67. package/native/core/include/ngn/photo-library.h +60 -20
  68. package/native/core/include/ngn/posix-locale.h +43 -0
  69. package/native/core/include/ngn/runtime.h +5 -0
  70. package/native/core/include/ngn/safe-areas.h +14 -2
  71. package/native/core/include/ngn/split-view.h +78 -0
  72. package/native/core/include/ngn/surface-metrics.h +7 -0
  73. package/native/core/include/ngn/system.h +14 -0
  74. package/native/core/include/ngn/text-input.h +13 -0
  75. package/native/core/include/ngn/text-units.h +38 -0
  76. package/native/core/include/ngn/updates.h +14 -2
  77. package/native/core/include/ngn/view-box.h +40 -0
  78. package/native/core/include/ngn/view-transform.h +15 -0
  79. package/native/core/include/ngn/web-browser.h +46 -0
  80. package/native/core/src/accent-colors.cpp +88 -0
  81. package/native/core/src/accessibility-relations.cpp +138 -0
  82. package/native/core/src/accessibility.cpp +50 -0
  83. package/native/core/src/animated-frame-loop.cpp +166 -0
  84. package/native/core/src/app-menus.cpp +26 -9
  85. package/native/core/src/app-windows.cpp +27 -6
  86. package/native/core/src/aria-role.cpp +127 -0
  87. package/native/core/src/control-sizes.cpp +9 -5
  88. package/native/core/src/crash-report.cpp +196 -0
  89. package/native/core/src/curl-network.cpp +1562 -0
  90. package/native/core/src/dbus-menu.cpp +71 -0
  91. package/native/core/src/default-menu.cpp +134 -0
  92. package/native/core/src/desktop-view-props.cpp +14 -0
  93. package/native/core/src/focus-order.cpp +19 -0
  94. package/native/core/src/header-bar.cpp +20 -0
  95. package/native/core/src/host-os.cpp +19 -0
  96. package/native/core/src/host-reload.cpp +45 -0
  97. package/native/core/src/host-state.cpp +8 -0
  98. package/native/core/src/image-source.cpp +90 -0
  99. package/native/core/src/input-dispatcher.cpp +27 -5
  100. package/native/core/src/input-script.cpp +3 -2
  101. package/native/core/src/launch-settings.cpp +76 -0
  102. package/native/core/src/libraries/react-native-reanimated.cpp +6 -1
  103. package/native/core/src/modules/app-info.cpp +55 -6
  104. package/native/core/src/modules/app-modules.cpp +1 -1
  105. package/native/core/src/modules/audio.cpp +4 -2
  106. package/native/core/src/modules/camera.cpp +8 -11
  107. package/native/core/src/modules/desktop-expo.cpp +10 -5
  108. package/native/core/src/modules/desktop-modules.cpp +106 -41
  109. package/native/core/src/modules/file-photo-picker.cpp +408 -0
  110. package/native/core/src/modules/notifications.cpp +13 -17
  111. package/native/core/src/modules/photo-library.cpp +42 -13
  112. package/native/core/src/modules/web-browser.cpp +89 -0
  113. package/native/core/src/mounting-manager.cpp +12 -0
  114. package/native/core/src/native-controls.cpp +42 -1
  115. package/native/core/src/notification-schedule.cpp +429 -0
  116. package/native/core/src/openssl-update-crypto.cpp +83 -0
  117. package/native/core/src/posix-locale.cpp +192 -0
  118. package/native/core/src/runtime.cpp +30 -1
  119. package/native/core/src/safe-areas.cpp +19 -4
  120. package/native/core/src/spawn-rules.cpp +4 -1
  121. package/native/core/src/split-view.cpp +93 -0
  122. package/native/core/src/system.cpp +19 -0
  123. package/native/core/src/text-input.cpp +18 -1
  124. package/native/core/src/text-units.cpp +99 -0
  125. package/native/core/src/updates.cpp +76 -17
  126. package/native/core/src/view-box.cpp +75 -40
  127. package/native/core/src/view-transform.cpp +28 -0
  128. package/native/docker/Dockerfile +38 -0
  129. package/native/docker/Dockerfile.fedora +36 -0
  130. package/native/docker/glibc-floor.sh +49 -0
  131. package/native/gtk/CMakeLists.txt +137 -0
  132. package/native/gtk/accent-colour.cpp +57 -0
  133. package/native/gtk/accent-colour.h +41 -0
  134. package/native/gtk/accessibility-settings.cpp +159 -0
  135. package/native/gtk/accessibility-settings.h +62 -0
  136. package/native/gtk/accessible-text.cpp +151 -0
  137. package/native/gtk/accessible-text.h +49 -0
  138. package/native/gtk/accessible.cpp +306 -0
  139. package/native/gtk/accessible.h +75 -0
  140. package/native/gtk/alerts.cpp +267 -0
  141. package/native/gtk/alerts.h +30 -0
  142. package/native/gtk/animation-frames.cpp +159 -0
  143. package/native/gtk/animation-frames.h +20 -0
  144. package/native/gtk/app-info.cpp +91 -0
  145. package/native/gtk/app-info.h +25 -0
  146. package/native/gtk/app-windows.cpp +439 -0
  147. package/native/gtk/app-windows.h +150 -0
  148. package/native/gtk/audio.cpp +370 -0
  149. package/native/gtk/audio.h +54 -0
  150. package/native/gtk/auth-session.cpp +73 -0
  151. package/native/gtk/auth-session.h +16 -0
  152. package/native/gtk/battery.cpp +110 -0
  153. package/native/gtk/battery.h +19 -0
  154. package/native/gtk/box-paint.cpp +262 -0
  155. package/native/gtk/box-paint.h +32 -0
  156. package/native/gtk/cairo-canvas.cpp +755 -0
  157. package/native/gtk/cairo-canvas.h +49 -0
  158. package/native/gtk/camera.cpp +909 -0
  159. package/native/gtk/camera.h +69 -0
  160. package/native/gtk/capture.cpp +46 -0
  161. package/native/gtk/capture.h +19 -0
  162. package/native/gtk/clock-format.cpp +151 -0
  163. package/native/gtk/clock-format.h +36 -0
  164. package/native/gtk/crypto.cpp +75 -0
  165. package/native/gtk/crypto.h +14 -0
  166. package/native/gtk/dbus-properties.cpp +131 -0
  167. package/native/gtk/dbus-properties.h +61 -0
  168. package/native/gtk/drag-and-drop.cpp +339 -0
  169. package/native/gtk/drag-and-drop.h +30 -0
  170. package/native/gtk/file-dialogs.cpp +239 -0
  171. package/native/gtk/file-dialogs.h +21 -0
  172. package/native/gtk/file-system.cpp +212 -0
  173. package/native/gtk/file-system.h +25 -0
  174. package/native/gtk/focus.cpp +282 -0
  175. package/native/gtk/focus.h +37 -0
  176. package/native/gtk/fonts.cpp +89 -0
  177. package/native/gtk/fonts.h +22 -0
  178. package/native/gtk/gst-frames.cpp +150 -0
  179. package/native/gtk/gst-frames.h +47 -0
  180. package/native/gtk/gst-playback.cpp +496 -0
  181. package/native/gtk/gst-playback.h +81 -0
  182. package/native/gtk/gtk-backend.cpp +690 -0
  183. package/native/gtk/gtk-backend.h +134 -0
  184. package/native/gtk/host-sources.cpp +354 -0
  185. package/native/gtk/host-sources.h +46 -0
  186. package/native/gtk/image-manipulator.cpp +254 -0
  187. package/native/gtk/image-manipulator.h +30 -0
  188. package/native/gtk/image-view.cpp +256 -0
  189. package/native/gtk/image-view.h +54 -0
  190. package/native/gtk/input-replay.cpp +299 -0
  191. package/native/gtk/input-replay.h +36 -0
  192. package/native/gtk/launcher-badge.cpp +29 -0
  193. package/native/gtk/launcher-badge.h +21 -0
  194. package/native/gtk/locales.cpp +131 -0
  195. package/native/gtk/locales.h +23 -0
  196. package/native/gtk/location.cpp +274 -0
  197. package/native/gtk/location.h +19 -0
  198. package/native/gtk/main.cpp +1092 -0
  199. package/native/gtk/menus.cpp +447 -0
  200. package/native/gtk/menus.h +100 -0
  201. package/native/gtk/native-controls.cpp +831 -0
  202. package/native/gtk/native-controls.h +58 -0
  203. package/native/gtk/network-state.cpp +72 -0
  204. package/native/gtk/network-state.h +24 -0
  205. package/native/gtk/notifications.cpp +235 -0
  206. package/native/gtk/notifications.h +30 -0
  207. package/native/gtk/pango-text.cpp +274 -0
  208. package/native/gtk/pango-text.h +73 -0
  209. package/native/gtk/portal.cpp +451 -0
  210. package/native/gtk/portal.h +71 -0
  211. package/native/gtk/printing.cpp +338 -0
  212. package/native/gtk/printing.h +34 -0
  213. package/native/gtk/proxy-resolver.cpp +74 -0
  214. package/native/gtk/proxy-resolver.h +20 -0
  215. package/native/gtk/screens.cpp +1461 -0
  216. package/native/gtk/screens.h +274 -0
  217. package/native/gtk/scroll-view.cpp +414 -0
  218. package/native/gtk/scroll-view.h +82 -0
  219. package/native/gtk/secret-store.cpp +120 -0
  220. package/native/gtk/secret-store.h +27 -0
  221. package/native/gtk/settings-portal.cpp +129 -0
  222. package/native/gtk/settings-portal.h +47 -0
  223. package/native/gtk/split-view.cpp +1105 -0
  224. package/native/gtk/split-view.h +195 -0
  225. package/native/gtk/status-notifier.cpp +487 -0
  226. package/native/gtk/status-notifier.h +43 -0
  227. package/native/gtk/surface-input.cpp +251 -0
  228. package/native/gtk/surface-input.h +57 -0
  229. package/native/gtk/system-access.cpp +295 -0
  230. package/native/gtk/system-access.h +37 -0
  231. package/native/gtk/text-field.cpp +827 -0
  232. package/native/gtk/text-field.h +78 -0
  233. package/native/gtk/video.cpp +527 -0
  234. package/native/gtk/video.h +47 -0
  235. package/native/gtk/view-widget.cpp +431 -0
  236. package/native/gtk/view-widget.h +105 -0
  237. package/native/gtk/window-scale.cpp +95 -0
  238. package/native/gtk/window-scale.h +35 -0
  239. package/native/scripts/atspi-check.py +310 -0
  240. package/native/scripts/atspi-check.test.py +48 -0
  241. package/native/scripts/build.sh +20 -3
  242. package/native/scripts/compilers.sh +17 -0
  243. package/native/scripts/deb-depends-check.sh +22 -0
  244. package/native/scripts/fetch.sh +23 -2
  245. package/native/scripts/launch-cell.sh +157 -0
  246. package/native/scripts/launch-probe.sh +14 -3
  247. package/native/scripts/make-prebuilt.mjs +133 -44
  248. package/native/scripts/prebuilt-host-cache.mjs +71 -40
  249. package/native/scripts/reset-for-compilers.sh +44 -0
  250. package/native/scripts/start-xvfb.sh +35 -0
  251. package/native/shim/paragraph-platform/react/renderer/components/text/HostPlatformParagraphProps.h +35 -0
  252. package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +5 -2
  253. package/native/shim/worklets/linux-reanimated-props.h +14 -0
  254. package/native/shim/worklets/linux-worklets.h +23 -0
  255. package/package.json +6 -3
  256. package/prebuilt.json +70 -6
@@ -0,0 +1,431 @@
1
+ #include "view-widget.h"
2
+
3
+ #include "accessible-text.h"
4
+
5
+ #include "box-paint.h"
6
+ #include "cairo-canvas.h"
7
+ #include "image-view.h"
8
+ #include "focus.h"
9
+ #include "scroll-view.h"
10
+ #include "text-field.h"
11
+ #if NGN_GSTREAMER
12
+ #include "camera.h"
13
+ #include "video.h"
14
+ #endif
15
+
16
+ #include "ngn/view-box.h"
17
+ #include "ngn/view-filter.h"
18
+ #include "ngn/view-transform.h"
19
+
20
+ #include <react/renderer/components/text/ParagraphState.h>
21
+ #include <react/renderer/components/view/ViewProps.h>
22
+ #include <react/renderer/core/ConcreteState.h>
23
+
24
+ #include <cmath>
25
+ #include <optional>
26
+ #include <utility>
27
+ #include <vector>
28
+
29
+ using namespace facebook::react;
30
+
31
+ struct _NgnView {
32
+ GtkWidget parent_instance;
33
+ ngn::gtk::ViewData *data;
34
+ };
35
+
36
+ G_DEFINE_TYPE(NgnView, ngn_view, GTK_TYPE_WIDGET)
37
+
38
+ namespace {
39
+
40
+ using ngn::gtk::ViewData;
41
+
42
+ void viewMeasure(GtkWidget *widget, GtkOrientation orientation, int, int *minimum, int *natural, int *, int *) {
43
+ // Yoga sizes every view; GTK asks for nothing. A scroll view's document asks for the content's
44
+ // size, which its viewport scrolls over.
45
+ ngn::gtk::ScrollBox *box = NGN_VIEW(widget)->data->documentOf;
46
+ Float size = !box ? 0 : orientation == GTK_ORIENTATION_HORIZONTAL ? box->content.width : box->content.height;
47
+ *minimum = static_cast<int>(std::ceil(size));
48
+ *natural = *minimum;
49
+ }
50
+
51
+ // Where a child goes in its parent: its frame's origin, then its transform about its top left.
52
+ GskTransform *childTransform(const ViewData &child) {
53
+ const auto &origin = child.layout.frame.origin;
54
+ graphene_point_t point;
55
+ graphene_point_init(&point, static_cast<float>(origin.x), static_cast<float>(origin.y));
56
+ GskTransform *transform = gsk_transform_translate(nullptr, &point);
57
+ if (auto props = std::dynamic_pointer_cast<const ViewProps>(child.props)) {
58
+ if (auto layer = ngn::layerTransform(*props, child.layout)) {
59
+ // In 2D steps where it has no perspective: GSK's cairo renderer, which a machine with no GL
60
+ // and the host's screenshots draw with, draws a 3D matrix as a pink box.
61
+ if (auto steps = ngn::planeSteps(*layer)) {
62
+ graphene_point_t by;
63
+ graphene_point_init(&by, static_cast<float>(steps->translateX), static_cast<float>(steps->translateY));
64
+ transform = gsk_transform_translate(transform, &by);
65
+ transform = gsk_transform_rotate(transform, static_cast<float>(steps->rotate));
66
+ transform = gsk_transform_skew(transform, static_cast<float>(steps->skewX), 0);
67
+ return gsk_transform_scale(transform, static_cast<float>(steps->scaleX), static_cast<float>(steps->scaleY));
68
+ }
69
+ float values[16];
70
+ for (int i = 0; i < 16; ++i) {
71
+ values[i] = static_cast<float>(layer->matrix[i]);
72
+ }
73
+ graphene_matrix_t matrix;
74
+ graphene_matrix_init_from_float(&matrix, values);
75
+ transform = gsk_transform_matrix(transform, &matrix);
76
+ }
77
+ }
78
+ return transform;
79
+ }
80
+
81
+ void viewSizeAllocate(GtkWidget *widget, int width, int height, int) {
82
+ ViewData *d = NGN_VIEW(widget)->data;
83
+ for (GtkWidget *child = gtk_widget_get_first_child(widget); child; child = gtk_widget_get_next_sibling(child)) {
84
+ if (!NGN_IS_VIEW(child)) {
85
+ if (GTK_IS_POPOVER(child)) {
86
+ // A popover anchored to the view (screens.h), which its parent places as it allocates.
87
+ gtk_popover_present(GTK_POPOVER(child));
88
+ } else if (d->field && child == ngn::gtk::fieldWidget(*d->field)) {
89
+ ngn::gtk::allocateTextField(*d, width, height);
90
+ } else if (d->scroll && child == d->scroll->scrolled) {
91
+ ngn::gtk::allocateScrollView(*d, width, height);
92
+ } else if (auto *frame = static_cast<const Rect *>(g_object_get_data(G_OBJECT(child), "ngn-frame"))) {
93
+ // A source list over its sections (split-view.h).
94
+ GtkAllocation all{static_cast<int>(std::round(frame->origin.x)), static_cast<int>(std::round(frame->origin.y)),
95
+ static_cast<int>(std::ceil(frame->size.width)), static_cast<int>(std::ceil(frame->size.height))};
96
+ gtk_widget_size_allocate(child, &all, -1);
97
+ } else if (child == d->control || child == d->split) {
98
+ GtkAllocation all{0, 0, width, height};
99
+ gtk_widget_size_allocate(child, &all, -1);
100
+ #if NGN_GSTREAMER
101
+ } else if ((d->video && child == ngn::gtk::videoWidget(*d->video)) || (d->camera && child == ngn::gtk::cameraWidget(*d->camera))) {
102
+ GtkAllocation all{0, 0, width, height};
103
+ gtk_widget_size_allocate(child, &all, -1);
104
+ #endif
105
+ }
106
+ continue;
107
+ }
108
+ if (d->surface) {
109
+ // The surface's root fills it: Fabric gives the root no frame of its own.
110
+ GtkAllocation all{0, 0, width, height};
111
+ gtk_widget_size_allocate(child, &all, -1);
112
+ continue;
113
+ }
114
+ ViewData *c = NGN_VIEW(child)->data;
115
+ const auto &size = c->layout.frame.size;
116
+ gtk_widget_allocate(
117
+ child, static_cast<int>(std::ceil(size.width)), static_cast<int>(std::ceil(size.height)), -1, childTransform(*c));
118
+ }
119
+ if (d->surface && (width != d->width || height != d->height)) {
120
+ d->width = width;
121
+ d->height = height;
122
+ if (d->resized) {
123
+ d->resized(width, height);
124
+ }
125
+ }
126
+ }
127
+
128
+ void snapshotText(ViewData *d, GtkSnapshot *snapshot) {
129
+ ngn::gtk::paragraphLayout(*d);
130
+ const auto &insets = d->layout.contentInsets;
131
+ gtk_snapshot_save(snapshot);
132
+ graphene_point_t at;
133
+ graphene_point_init(&at, static_cast<float>(insets.left), static_cast<float>(insets.top + d->text->top));
134
+ gtk_snapshot_translate(snapshot, &at);
135
+ // React Native's default text colour; a run with its own colour carries it as an attribute.
136
+ GdkRGBA black{0, 0, 0, 1};
137
+ gtk_snapshot_append_layout(snapshot, d->text->layout, &black);
138
+ gtk_snapshot_restore(snapshot);
139
+ }
140
+
141
+ // An svg's document, drawn with cairo in the view's bounds, as the macOS host draws it in its own.
142
+ void snapshotSvg(GtkWidget *widget, ViewData *d, GtkSnapshot *snapshot) {
143
+ const auto &size = d->layout.frame.size;
144
+ if (!d->svg || size.width <= 0 || size.height <= 0) {
145
+ // What it drew before is no longer held.
146
+ if (d->svgImages) {
147
+ d->svgImages->drawn();
148
+ }
149
+ return;
150
+ }
151
+ graphene_rect_t bounds;
152
+ graphene_rect_init(&bounds, 0, 0, static_cast<float>(size.width), static_cast<float>(size.height));
153
+ cairo_t *cr = gtk_snapshot_append_cairo(snapshot, &bounds);
154
+ cairo_rectangle(cr, 0, 0, size.width, size.height);
155
+ cairo_clip(cr);
156
+ // An <image> loaded later draws the svg again, while the view is there to draw.
157
+ GWeakRef *weak = g_new0(GWeakRef, 1);
158
+ g_weak_ref_init(weak, widget);
159
+ auto ref = std::shared_ptr<GWeakRef>(weak, [](GWeakRef *w) {
160
+ g_weak_ref_clear(w);
161
+ g_free(w);
162
+ });
163
+ if (!d->svgImages) {
164
+ d->svgImages = std::make_shared<ngn::gtk::SvgImageHold>();
165
+ }
166
+ auto canvas = ngn::gtk::makeCairoCanvas(cr, size.width, size.height, gtk_widget_get_scale_factor(widget), [ref] {
167
+ if (auto *view = static_cast<GtkWidget *>(g_weak_ref_get(ref.get()))) {
168
+ gtk_widget_queue_draw(view);
169
+ g_object_unref(view);
170
+ }
171
+ }, d->svgImages.get());
172
+ ngn::drawSvg(*d->svg, size.width, size.height, *canvas);
173
+ d->svgImages->drawn();
174
+ cairo_destroy(cr);
175
+ }
176
+
177
+ // The view's filter as GSK nodes over all it draws, its children included, the function listed
178
+ // first innermost so that it applies first. How many it pushed, which the caller pops.
179
+ int pushFilter(GtkSnapshot *snapshot, const ViewProps &props) {
180
+ auto steps = ngn::filterSteps(props.filter);
181
+ bool afterMatrix = false;
182
+ for (auto it = steps.rbegin(); it != steps.rend(); ++it) {
183
+ if (it->type == ngn::FilterStep::Type::ColorMatrix && afterMatrix) {
184
+ // GTK multiplies a colour matrix over a colour matrix into one node, which loses the clamp
185
+ // to 0..1 between them (brightness(2) then brightness(0.5) of 0.75 is 0.5, not 0.75). A clear
186
+ // dot beside the inner one makes the outer's child two nodes, so there is nothing to merge.
187
+ GdkRGBA none{0, 0, 0, 0};
188
+ graphene_rect_t dot;
189
+ graphene_rect_init(&dot, 0, 0, 1, 1);
190
+ gtk_snapshot_append_color(snapshot, &none, &dot);
191
+ }
192
+ afterMatrix = it->type == ngn::FilterStep::Type::ColorMatrix;
193
+ // GSK blurs by a radius twice the Gaussian's standard deviation.
194
+ float radius = static_cast<float>(2 * it->standardDeviation);
195
+ switch (it->type) {
196
+ case ngn::FilterStep::Type::ColorMatrix: {
197
+ // graphene's rows are the input channels and its columns the output ones: SVG's matrix
198
+ // turned over.
199
+ const auto &m = it->matrix;
200
+ float values[16];
201
+ for (int in = 0; in < 4; ++in) {
202
+ for (int out = 0; out < 4; ++out) {
203
+ values[in * 4 + out] = static_cast<float>(m[out * 5 + in]);
204
+ }
205
+ }
206
+ graphene_matrix_t matrix;
207
+ graphene_matrix_init_from_float(&matrix, values);
208
+ graphene_vec4_t offset;
209
+ graphene_vec4_init(&offset, static_cast<float>(m[4]), static_cast<float>(m[9]), static_cast<float>(m[14]), static_cast<float>(m[19]));
210
+ gtk_snapshot_push_color_matrix(snapshot, &matrix, &offset);
211
+ break;
212
+ }
213
+ case ngn::FilterStep::Type::Blur:
214
+ gtk_snapshot_push_blur(snapshot, radius);
215
+ break;
216
+ case ngn::FilterStep::Type::DropShadow: {
217
+ GskShadow shadow{ngn::gtk::rgbaOf(it->argb), static_cast<float>(it->offsetX), static_cast<float>(it->offsetY), radius};
218
+ gtk_snapshot_push_shadow(snapshot, &shadow, 1);
219
+ break;
220
+ }
221
+ }
222
+ }
223
+ return static_cast<int>(steps.size());
224
+ }
225
+
226
+ // How a child view blends with what its parent drew under it, when it does. GSK has no
227
+ // plus-lighter: that child draws normally.
228
+ std::optional<GskBlendMode> blendOf(GtkWidget *child) {
229
+ ViewData *c = ngn::gtk::viewData(child);
230
+ auto props = c ? std::dynamic_pointer_cast<const ViewProps>(c->props) : nullptr;
231
+ if (!props) {
232
+ return std::nullopt;
233
+ }
234
+ switch (props->mixBlendMode) {
235
+ case BlendMode::Multiply:
236
+ return GSK_BLEND_MODE_MULTIPLY;
237
+ case BlendMode::Screen:
238
+ return GSK_BLEND_MODE_SCREEN;
239
+ case BlendMode::Overlay:
240
+ return GSK_BLEND_MODE_OVERLAY;
241
+ case BlendMode::Darken:
242
+ return GSK_BLEND_MODE_DARKEN;
243
+ case BlendMode::Lighten:
244
+ return GSK_BLEND_MODE_LIGHTEN;
245
+ case BlendMode::ColorDodge:
246
+ return GSK_BLEND_MODE_COLOR_DODGE;
247
+ case BlendMode::ColorBurn:
248
+ return GSK_BLEND_MODE_COLOR_BURN;
249
+ case BlendMode::HardLight:
250
+ return GSK_BLEND_MODE_HARD_LIGHT;
251
+ case BlendMode::SoftLight:
252
+ return GSK_BLEND_MODE_SOFT_LIGHT;
253
+ case BlendMode::Difference:
254
+ return GSK_BLEND_MODE_DIFFERENCE;
255
+ case BlendMode::Exclusion:
256
+ return GSK_BLEND_MODE_EXCLUSION;
257
+ case BlendMode::Hue:
258
+ return GSK_BLEND_MODE_HUE;
259
+ case BlendMode::Saturation:
260
+ return GSK_BLEND_MODE_SATURATION;
261
+ case BlendMode::Color:
262
+ return GSK_BLEND_MODE_COLOR;
263
+ case BlendMode::Luminosity:
264
+ return GSK_BLEND_MODE_LUMINOSITY;
265
+ default:
266
+ return std::nullopt;
267
+ }
268
+ }
269
+
270
+ // A view draws its box, then its children in Fabric's order. A child with a mix-blend-mode blends
271
+ // with what the view drew before it: its box and the children under it. Each such child is a blend
272
+ // node whose bottom is everything drawn before it, so the nodes are pushed up front, the last
273
+ // blending child's outermost, and each one's bottom ends where its child comes.
274
+ void viewSnapshot(GtkWidget *widget, GtkSnapshot *snapshot) {
275
+ ViewData *d = NGN_VIEW(widget)->data;
276
+ auto props = std::dynamic_pointer_cast<const ViewProps>(d->props);
277
+ int filters = props ? pushFilter(snapshot, *props) : 0;
278
+ std::vector<GskBlendMode> blends;
279
+ for (GtkWidget *child = gtk_widget_get_first_child(widget); child; child = gtk_widget_get_next_sibling(child)) {
280
+ if (auto mode = GTK_IS_NATIVE(child) ? std::nullopt : blendOf(child)) {
281
+ blends.push_back(*mode);
282
+ }
283
+ }
284
+ for (auto it = blends.rbegin(); it != blends.rend(); ++it) {
285
+ gtk_snapshot_push_blend(snapshot, *it);
286
+ }
287
+ std::optional<ngn::BoxDescription> box;
288
+ if (props) {
289
+ box = ngn::describeBox(*props, d->layout);
290
+ // An Image's picture fills its bounds under its border, as a layer's contents do on macOS.
291
+ ngn::gtk::appendBox(snapshot, *box, d->image ? std::function<void()>([&] { ngn::gtk::snapshotImage(*d, snapshot, *box); }) : nullptr);
292
+ if (d->component == "Paragraph" && d->state) {
293
+ snapshotText(d, snapshot);
294
+ }
295
+ snapshotSvg(widget, d, snapshot);
296
+ ngn::gtk::snapshotPlaceholder(*d, snapshot);
297
+ }
298
+ auto clip = [&] { return box && ngn::gtk::pushOverflowClip(snapshot, *box); };
299
+ bool clipped = clip();
300
+ for (GtkWidget *child = gtk_widget_get_first_child(widget); child; child = gtk_widget_get_next_sibling(child)) {
301
+ if (GTK_IS_NATIVE(child)) {
302
+ // A popover is a surface of its own.
303
+ continue;
304
+ }
305
+ if (!blendOf(child)) {
306
+ gtk_widget_snapshot_child(widget, child, snapshot);
307
+ continue;
308
+ }
309
+ // The clip is pushed inside each part, so that the blend node's two parts close in turn.
310
+ if (clipped) {
311
+ gtk_snapshot_pop(snapshot);
312
+ }
313
+ gtk_snapshot_pop(snapshot);
314
+ clipped = clip();
315
+ gtk_widget_snapshot_child(widget, child, snapshot);
316
+ if (clipped) {
317
+ gtk_snapshot_pop(snapshot);
318
+ }
319
+ gtk_snapshot_pop(snapshot);
320
+ clipped = clip();
321
+ }
322
+ if (clipped) {
323
+ gtk_snapshot_pop(snapshot);
324
+ }
325
+ for (int i = 0; i < filters; ++i) {
326
+ gtk_snapshot_pop(snapshot);
327
+ }
328
+ }
329
+
330
+ void viewDispose(GObject *object) {
331
+ GtkWidget *widget = GTK_WIDGET(object);
332
+ ngn::gtk::ViewData *d = NGN_VIEW(object)->data;
333
+ ngn::gtk::destroyTextField(*d);
334
+ ngn::gtk::destroyImage(*d);
335
+ ngn::gtk::destroyScrollView(*d);
336
+ d->video.reset();
337
+ d->camera.reset();
338
+ while (GtkWidget *child = gtk_widget_get_first_child(widget)) {
339
+ gtk_widget_unparent(child);
340
+ }
341
+ G_OBJECT_CLASS(ngn_view_parent_class)->dispose(object);
342
+ }
343
+
344
+ void viewFinalize(GObject *object) {
345
+ delete NGN_VIEW(object)->data;
346
+ G_OBJECT_CLASS(ngn_view_parent_class)->finalize(object);
347
+ }
348
+
349
+ } // namespace
350
+
351
+ static void ngn_view_class_init(NgnViewClass *klass) {
352
+ GtkWidgetClass *widget = GTK_WIDGET_CLASS(klass);
353
+ widget->measure = viewMeasure;
354
+ widget->size_allocate = viewSizeAllocate;
355
+ widget->snapshot = viewSnapshot;
356
+ gtk_widget_class_set_css_name(widget, "ngn-view");
357
+ G_OBJECT_CLASS(klass)->dispose = viewDispose;
358
+ G_OBJECT_CLASS(klass)->finalize = viewFinalize;
359
+ }
360
+
361
+ // A Paragraph's widget: an NgnView that GTK 4.14 and later reads as text (accessible-text.h).
362
+ static GType ngn_text_view_get_type() {
363
+ static GType type = [] {
364
+ GType text = g_type_register_static_simple(
365
+ NGN_TYPE_VIEW, "NgnTextView", sizeof(NgnViewClass), nullptr, sizeof(NgnView), nullptr, GTypeFlags(0));
366
+ ngn::gtk::implementAccessibleText(text);
367
+ return text;
368
+ }();
369
+ return type;
370
+ }
371
+
372
+ static void ngn_view_init(NgnView *self) {
373
+ self->data = new ViewData();
374
+ self->data->widget = GTK_WIDGET(self);
375
+ }
376
+
377
+ namespace ngn::gtk {
378
+
379
+ GtkWidget *makeViewWidget(GtkAccessibleRole role, bool text) {
380
+ GtkWidget *widget = GTK_WIDGET(g_object_new(text ? ngn_text_view_get_type() : NGN_TYPE_VIEW, "accessible-role", role, nullptr));
381
+ // A view's own focus, the same for one made as the view mounts and one replacing it.
382
+ watchFocus(widget);
383
+ return widget;
384
+ }
385
+
386
+ GtkWidget *makeSurfaceWidget(SurfaceId surfaceId, std::function<void(int, int)> resized) {
387
+ GtkWidget *widget = makeViewWidget();
388
+ ViewData *d = viewData(widget);
389
+ d->surface = true;
390
+ d->surfaceId = surfaceId;
391
+ d->resized = std::move(resized);
392
+ gtk_widget_set_hexpand(widget, TRUE);
393
+ gtk_widget_set_vexpand(widget, TRUE);
394
+ gtk_widget_set_overflow(widget, GTK_OVERFLOW_HIDDEN);
395
+ return widget;
396
+ }
397
+
398
+ bool isTextWidget(GtkWidget *widget) {
399
+ return widget && G_TYPE_CHECK_INSTANCE_TYPE(widget, ngn_text_view_get_type());
400
+ }
401
+
402
+ PangoLayout *paragraphLayout(ViewData &d) {
403
+ if (d.component != "Paragraph" || !d.state) {
404
+ return nullptr;
405
+ }
406
+ if (!d.text) {
407
+ auto state = std::static_pointer_cast<const ConcreteState<ParagraphState>>(d.state);
408
+ const auto &data = state->getData();
409
+ const auto &insets = d.layout.contentInsets;
410
+ Float width = d.layout.frame.size.width - insets.left - insets.right;
411
+ // A hair of slack, so the width Yoga rounded to the pixel lays out the lines measure did.
412
+ d.text = layoutText(data.attributedString, data.paragraphAttributes, width + 0.5f);
413
+ }
414
+ return d.text->layout;
415
+ }
416
+
417
+ ViewData *viewData(GtkWidget *widget) {
418
+ return widget && NGN_IS_VIEW(widget) ? NGN_VIEW(widget)->data : nullptr;
419
+ }
420
+
421
+ void swapViewData(GtkWidget *a, GtkWidget *b) {
422
+ std::swap(NGN_VIEW(a)->data, NGN_VIEW(b)->data);
423
+ NGN_VIEW(a)->data->widget = a;
424
+ NGN_VIEW(b)->data->widget = b;
425
+ }
426
+
427
+ void forgetText(ViewData &data) {
428
+ data.text.reset();
429
+ }
430
+
431
+ } // namespace ngn::gtk
@@ -0,0 +1,105 @@
1
+ // NgnView: the GtkWidget each Fabric view mounts as, and the widget a surface fills its window with.
2
+ //
3
+ // Yoga's frames are authoritative: a view asks GTK for no size of its own (`measure` gives 0) and
4
+ // allocates each child at its Fabric frame, moved and transformed as the child's props say. It
5
+ // paints its box and a Paragraph's text as GSK render nodes in its `snapshot`, then its children in
6
+ // Fabric's order, cut to its shape when it clips its overflow. Its `filter` (view-filter.h) applies
7
+ // over all of that. A child's `mix-blend-mode` blends it with what its parent drew under it, the
8
+ // parent's box and the children before it: each view is its own group, as `isolation: isolate`
9
+ // makes it in CSS, and GSK has no plus-lighter. The approach of Basalt's basalt-gtk
10
+ // (MIT, Copyright (c) 2026 Vince Vella); the code is ours.
11
+ #pragma once
12
+
13
+ #include "pango-text.h"
14
+
15
+ #include "ngn/desktop-props.h"
16
+ #include "ngn/svg.h"
17
+
18
+ #include <react/renderer/core/EventEmitter.h>
19
+ #include <react/renderer/core/LayoutMetrics.h>
20
+ #include <react/renderer/core/Props.h>
21
+ #include <react/renderer/core/State.h>
22
+
23
+ #include <gtk/gtk.h>
24
+
25
+ #include <functional>
26
+ #include <memory>
27
+ #include <optional>
28
+ #include <string>
29
+
30
+ G_BEGIN_DECLS
31
+ #define NGN_TYPE_VIEW (ngn_view_get_type())
32
+ G_DECLARE_FINAL_TYPE(NgnView, ngn_view, NGN, VIEW, GtkWidget)
33
+ G_END_DECLS
34
+
35
+ namespace ngn::gtk {
36
+
37
+ struct CameraSurface;
38
+ struct ImageLoad;
39
+ struct ScrollBox;
40
+ class SvgImageHold;
41
+ struct TextField;
42
+ struct VideoSurface;
43
+
44
+ struct ViewData {
45
+ // The widget holding this data, which a view whose role changes trades for another.
46
+ GtkWidget *widget{nullptr};
47
+ facebook::react::Tag tag{-1};
48
+ std::string component;
49
+ facebook::react::Props::Shared props;
50
+ facebook::react::State::Shared state;
51
+ facebook::react::SharedEventEmitter emitter;
52
+ facebook::react::LayoutMetrics layout{};
53
+ DesktopProps desktop;
54
+ // A Paragraph's text, laid out on the first draw after its state or frame changed.
55
+ std::optional<TextLayout> text;
56
+ // A TextInput's field: the editable child it holds.
57
+ TextField *field{nullptr};
58
+ // An Image's source and the image it loaded.
59
+ std::shared_ptr<ImageLoad> image;
60
+ // A native control's widget (native-controls.h), which fills the view.
61
+ GtkWidget *control{nullptr};
62
+ // A ScrollView's scrolled window, which holds the document its content mounts into.
63
+ ScrollBox *scroll{nullptr};
64
+ // A scroll view's document: as large as the content it scrolls, which GTK reads from its measure.
65
+ ScrollBox *documentOf{nullptr};
66
+ // A placed split view's AdwBreakpointBin (split-view.h), which fills the view.
67
+ GtkWidget *split{nullptr};
68
+ // An `<expo-camera>`'s picture and running camera (camera.h).
69
+ std::shared_ptr<CameraSurface> camera;
70
+ // An `<expo-video>`'s picture and controls (video.h).
71
+ std::shared_ptr<VideoSurface> video;
72
+ // An svg's document, which the core builds from the elements under it.
73
+ std::shared_ptr<const SvgDocument> svg;
74
+ // The images its last draw asked for, kept for it in the shared cache.
75
+ std::shared_ptr<SvgImageHold> svgImages;
76
+
77
+ // A surface's widget: its root view fills it, and it reports its size as it changes.
78
+ bool surface{false};
79
+ facebook::react::SurfaceId surfaceId{-1};
80
+ std::function<void(int width, int height)> resized;
81
+ int width{-1}, height{-1};
82
+ };
83
+
84
+ // A view's widget with its accessible role, which GTK fixes as it makes it, floating: the caller
85
+ // sinks it. A Paragraph's (`text`) is read by character, word and line where GTK can
86
+ // (accessible-text.h).
87
+ GtkWidget *makeViewWidget(GtkAccessibleRole role = GTK_ACCESSIBLE_ROLE_GENERIC, bool text = false);
88
+ // Whether the widget is a Paragraph's, made with `text`.
89
+ bool isTextWidget(GtkWidget *widget);
90
+ // The widget a surface's views mount into. It fills its parent and calls `resized` with its size.
91
+ GtkWidget *makeSurfaceWidget(facebook::react::SurfaceId surfaceId, std::function<void(int, int)> resized);
92
+
93
+ // Null for a widget that is not an NgnView.
94
+ ViewData *viewData(GtkWidget *widget);
95
+ // Trades two views' data, for a widget that replaces another: each is freed with the widget that
96
+ // holds it.
97
+ void swapViewData(GtkWidget *a, GtkWidget *b);
98
+
99
+ // Drops a Paragraph's laid-out text, to be laid out again on its next draw.
100
+ void forgetText(ViewData &data);
101
+ // A Paragraph's text laid out as it draws, laying it out now if it has not been since it changed.
102
+ // Null for any other view.
103
+ PangoLayout *paragraphLayout(ViewData &data);
104
+
105
+ } // namespace ngn::gtk
@@ -0,0 +1,95 @@
1
+ #include "window-scale.h"
2
+
3
+ #include <dlfcn.h>
4
+
5
+ #include <optional>
6
+
7
+ namespace ngn::gtk {
8
+
9
+ namespace {
10
+
11
+ GdkSurface *surfaceOf(GtkWidget *widget) {
12
+ GtkNative *native = widget ? gtk_widget_get_native(widget) : nullptr;
13
+ return native ? gtk_native_get_surface(native) : nullptr;
14
+ }
15
+
16
+ // The monitor's scale: fractional from GTK 4.14, found at run time, else its whole number. Nothing
17
+ // without a monitor.
18
+ std::optional<double> monitorScale(GdkDisplay *display, GdkSurface *surface) {
19
+ using GetScale = double (*)(GdkMonitor *);
20
+ static auto getScale = reinterpret_cast<GetScale>(dlsym(RTLD_DEFAULT, "gdk_monitor_get_scale"));
21
+ GdkMonitor *monitor = surface ? gdk_display_get_monitor_at_surface(display, surface) : nullptr;
22
+ GdkMonitor *first = nullptr;
23
+ if (!monitor) {
24
+ GListModel *monitors = gdk_display_get_monitors(display);
25
+ first = g_list_model_get_n_items(monitors) > 0 ? GDK_MONITOR(g_list_model_get_item(monitors, 0)) : nullptr;
26
+ monitor = first;
27
+ }
28
+ std::optional<double> scale;
29
+ if (monitor) {
30
+ scale = getScale ? getScale(monitor) : gdk_monitor_get_scale_factor(monitor);
31
+ }
32
+ if (first) {
33
+ g_object_unref(first);
34
+ }
35
+ return scale;
36
+ }
37
+
38
+ } // namespace
39
+
40
+ double windowScale(GtkWidget *widget) {
41
+ using GetScale = double (*)(GdkSurface *);
42
+ static auto getScale = reinterpret_cast<GetScale>(dlsym(RTLD_DEFAULT, "gdk_surface_get_scale"));
43
+ GdkSurface *surface = surfaceOf(widget);
44
+ if (surface && gdk_surface_get_mapped(surface)) {
45
+ return getScale ? getScale(surface) : gdk_surface_get_scale_factor(surface);
46
+ }
47
+ // Not shown yet: a Wayland surface learns its fractional scale only once it shows, and until then
48
+ // GDK rounds it up, so its monitor's scale stands in, as macOS gives a window off screen its
49
+ // screen's.
50
+ GdkDisplay *display = widget ? gtk_widget_get_display(widget) : gdk_display_get_default();
51
+ if (auto scale = display ? monitorScale(display, surface) : std::nullopt) {
52
+ return *scale;
53
+ }
54
+ return surface ? gdk_surface_get_scale_factor(surface) : 1;
55
+ }
56
+
57
+ ScaleFollow followWindowScale(GtkWidget *window, std::function<void()> changed) {
58
+ GdkSurface *surface = surfaceOf(window);
59
+ ScaleFollow follow;
60
+ if (!surface) {
61
+ return follow;
62
+ }
63
+ follow.surface = GDK_SURFACE(g_object_ref(surface));
64
+ // `scale` from GTK 4.12: it changes with every step `scale-factor` takes, and with fractional ones.
65
+ bool fractional = g_object_class_find_property(G_OBJECT_GET_CLASS(surface), "scale") != nullptr;
66
+ auto connect = [surface, &follow](const char *signal, std::function<void()> callback) {
67
+ follow.handlers.push_back(g_signal_connect_data(
68
+ surface, signal, G_CALLBACK(+[](GdkSurface *, GParamSpec *, gpointer data) { (*static_cast<std::function<void()> *>(data))(); }),
69
+ new std::function<void()>(std::move(callback)), [](gpointer data, GClosure *) { delete static_cast<std::function<void()> *>(data); },
70
+ GConnectFlags(0)));
71
+ };
72
+ connect(fractional ? "notify::scale" : "notify::scale-factor", changed);
73
+ // Showing is a change too: before it windowScale answers with the monitor's scale, and the
74
+ // compositor's own (1.25 where the monitor says 2) can have been announced before the surface
75
+ // mapped, so no notification follows it.
76
+ connect("notify::mapped", [surface, changed = std::move(changed)] {
77
+ if (gdk_surface_get_mapped(surface)) {
78
+ changed();
79
+ }
80
+ });
81
+ return follow;
82
+ }
83
+
84
+ void stopScaleFollow(ScaleFollow &follow) {
85
+ if (!follow.surface) {
86
+ return;
87
+ }
88
+ for (gulong &id : follow.handlers) {
89
+ g_clear_signal_handler(&id, follow.surface);
90
+ }
91
+ follow.handlers.clear();
92
+ g_clear_object(&follow.surface);
93
+ }
94
+
95
+ } // namespace ngn::gtk
@@ -0,0 +1,35 @@
1
+ // The scale a GTK window draws at, in device pixels a point, fractional steps included: what
2
+ // Dimensions' `scale`, PixelRatio and the layout's pixel rounding take, as macOS takes a window's
3
+ // backingScaleFactor.
4
+ //
5
+ // From GTK 4.12 GDK reports a compositor's fractional scale (1.25 or 1.333 on Wayland) as the
6
+ // surface's `scale`, found at run time; gtk_widget_get_scale_factor rounds it up to a whole number
7
+ // and changes only when that does. Below 4.12 the whole number is all there is.
8
+ #pragma once
9
+
10
+ #include <gtk/gtk.h>
11
+
12
+ #include <functional>
13
+ #include <vector>
14
+
15
+ namespace ngn::gtk {
16
+
17
+ // `widget`'s window's scale once it shows; before, its monitor's (the first monitor's when it is on
18
+ // none yet), and 1 with no monitor at all.
19
+ double windowScale(GtkWidget *widget);
20
+
21
+ // The handlers followWindowScale made, on the surface they were made on, which is held until they
22
+ // are stopped.
23
+ struct ScaleFollow {
24
+ GdkSurface *surface{nullptr};
25
+ std::vector<gulong> handlers;
26
+ };
27
+
28
+ // Calls `changed` on each change of the realized `window`'s scale, a fractional one included, until
29
+ // stopScaleFollow, or the window's surface goes. Empty when the window has no surface.
30
+ ScaleFollow followWindowScale(GtkWidget *window, std::function<void()> changed);
31
+
32
+ // Stops the handlers, for whoever must do so before `changed`'s captures go. Safe on an empty one.
33
+ void stopScaleFollow(ScaleFollow &follow);
34
+
35
+ } // namespace ngn::gtk