1
1
package flutter
2
2
3
3
import (
4
- "encoding/json"
5
4
"fmt"
6
5
"runtime"
7
- "sync"
8
6
"unsafe"
9
7
10
8
"github.com/go-flutter-desktop/go-flutter/embedder"
@@ -29,9 +27,6 @@ type windowManager struct {
29
27
30
28
// caching of ppsc to avoid re-calculating every event
31
29
pixelsPerScreenCoordinate float64
32
-
33
- // sync.Once to limit pixelRatio warning messages.
34
- oncePrintPixelRatioLimit sync.Once
35
30
}
36
31
37
32
func newWindowManager (forcedPixelRatio float64 ) * windowManager {
@@ -242,7 +237,6 @@ func (m *windowManager) getPixelRatioOther(window *glfw.Window) float64 {
242
237
// Fallback to getPixelRatioOther if error occur.
243
238
func (m * windowManager ) getPixelRatioLinux (window * glfw.Window ) float64 {
244
239
widthPx , heightPx := window .GetFramebufferSize ()
245
- width , _ := window .GetSize ()
246
240
247
241
var selectedMonitor * glfw.Monitor
248
242
winX , winY := window .GetPos ()
@@ -284,23 +278,9 @@ func (m *windowManager) getPixelRatioLinux(window *glfw.Window) float64 {
284
278
dpi := m .pixelsPerScreenCoordinate * monitorScreenCoordinatesPerInch
285
279
pixelRatio := dpi / dpPerInch
286
280
287
- // Limit the ratio to 1 to avoid rendering a smaller UI in standard resolution monitors.
281
+ // If the pixelRatio is lower to 1 use this scale factor to downscale the ContentScale
288
282
if pixelRatio < 1.0 {
289
- m .oncePrintPixelRatioLimit .Do (func () {
290
- metrics := map [string ]interface {}{
291
- "ppsc" : m .pixelsPerScreenCoordinate ,
292
- "windowWidthPx" : widthPx ,
293
- "windowWidthSc" : width ,
294
- "mscpi" : monitorScreenCoordinatesPerInch ,
295
- "dpi" : dpi ,
296
- "pixelRatio" : pixelRatio ,
297
- "monitorWidthMm" : selectedMonitorWidthMM ,
298
- "monitorWidthSc" : selectedMonitorMode .Width ,
299
- }
300
- metricsBytes , _ := json .Marshal (metrics )
301
- fmt .Println ("go-flutter: calculated pixelRatio limited to a minimum of 1.0. metrics: " + string (metricsBytes ))
302
- })
303
- pixelRatio = 1.0
283
+ pixelRatio *= m .getPixelRatioOther (window )
304
284
}
305
285
return pixelRatio
306
286
}
0 commit comments