Skip to content

Commit fa6dbec

Browse files
authored
Update glfw.go
1 parent e3a4758 commit fa6dbec

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

glfw.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package flutter
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"runtime"
7-
"sync"
86
"unsafe"
97

108
"github.com/go-flutter-desktop/go-flutter/embedder"
@@ -29,9 +27,6 @@ type windowManager struct {
2927

3028
// caching of ppsc to avoid re-calculating every event
3129
pixelsPerScreenCoordinate float64
32-
33-
// sync.Once to limit pixelRatio warning messages.
34-
oncePrintPixelRatioLimit sync.Once
3530
}
3631

3732
func newWindowManager(forcedPixelRatio float64) *windowManager {
@@ -242,7 +237,6 @@ func (m *windowManager) getPixelRatioOther(window *glfw.Window) float64 {
242237
// Fallback to getPixelRatioOther if error occur.
243238
func (m *windowManager) getPixelRatioLinux(window *glfw.Window) float64 {
244239
widthPx, heightPx := window.GetFramebufferSize()
245-
width, _ := window.GetSize()
246240

247241
var selectedMonitor *glfw.Monitor
248242
winX, winY := window.GetPos()
@@ -284,23 +278,9 @@ func (m *windowManager) getPixelRatioLinux(window *glfw.Window) float64 {
284278
dpi := m.pixelsPerScreenCoordinate * monitorScreenCoordinatesPerInch
285279
pixelRatio := dpi / dpPerInch
286280

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
288282
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)
304284
}
305285
return pixelRatio
306286
}

0 commit comments

Comments
 (0)