File tree 1 file changed +9
-15
lines changed
1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -76,32 +76,26 @@ module WindowMetrics: {
76
76
);
77
77
scale;
78
78
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.
80
80
// - 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
82
88
| Linux =>
83
89
switch (Rench . Environment . getEnvironmentVariable("GDK_SCALE" )) {
90
+ | None => 1 . 0
84
91
| Some (v ) =>
85
- // TODO
86
92
Log . trace(
87
93
"_getScaleFactor - Linux - got GDK_SCALE variable: " ++ v,
88
94
);
89
95
switch (Float . of_string_opt(v)) {
90
96
| Some (v ) => v
91
97
| None => 1 . 0
92
98
};
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;
105
99
}
106
100
| _ => 1 . 0
107
101
}
You can’t perform that action at this time.
0 commit comments