Skip to content

Commit c4c6c23

Browse files
authored
fix(rendering/#878): use 1.0 as default scale factor for Linux (#896)
1 parent 6255331 commit c4c6c23

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/Core/Window.re

+9-15
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,26 @@ module WindowMetrics: {
7676
);
7777
scale;
7878

79-
// On Linux, there's a few other things to try:
79+
// On Linux it can be pretty tricky depending on the display server and other factors.
8080
// - First, we'll look for a [GDK_SCALE] environment variable, and prefer that.
81-
// - Otherwise, we'll try and infer it from the DPI.
81+
// - Otherwise we default to 1.0 until we have a reliable method to obtain the value.
82+
// See the following links for more details:
83+
// https://github.com/revery-ui/revery/issues/878
84+
// https://github.com/glfw/glfw/issues/1019
85+
// https://github.com/mosra/magnum/commit/ae31c3cd82ba53454b8ab49d3f9d8ca385560d4b
86+
// https://github.com/glfw/glfw/blob/250b94cd03e6f947ba516869c7f3b277f8d0cacc/src/x11_init.c#L938
87+
// https://wiki.archlinux.org/index.php/HiDPI
8288
| Linux =>
8389
switch (Rench.Environment.getEnvironmentVariable("GDK_SCALE")) {
90+
| None => 1.0
8491
| Some(v) =>
85-
// TODO
8692
Log.trace(
8793
"_getScaleFactor - Linux - got GDK_SCALE variable: " ++ v,
8894
);
8995
switch (Float.of_string_opt(v)) {
9096
| Some(v) => v
9197
| None => 1.0
9298
};
93-
| None =>
94-
let display = Sdl2.Window.getDisplay(sdlWindow);
95-
let dpi = Sdl2.Display.getDPI(display);
96-
let avgDpi = (dpi.hdpi +. dpi.vdpi +. dpi.ddpi) /. 3.0;
97-
let scaleFactor = max(1.0, floor(avgDpi /. 96.0));
98-
Log.tracef(m =>
99-
m(
100-
"_getScaleFactor - Linux - inferring from DPI: %f",
101-
scaleFactor,
102-
)
103-
);
104-
scaleFactor;
10599
}
106100
| _ => 1.0
107101
}

0 commit comments

Comments
 (0)