From c2b1b95343397de0cd5b33b567caec1133c1b130 Mon Sep 17 00:00:00 2001 From: Menno Finlay-Smits Date: Wed, 6 Feb 2019 02:17:07 +1300 Subject: [PATCH] Use primary monitor for DPI calc if monitor could be determined (#197) This avoids a panic on startup in some specific situations (e.g. when xrandr's --scale option is in use). --- gui/gui.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/gui.go b/gui/gui.go index ad24163..7508128 100644 --- a/gui/gui.go +++ b/gui/gui.go @@ -80,7 +80,6 @@ type ResizeCache struct { } func (g *GUI) GetMonitor() *glfw.Monitor { - if g.window == nil { panic("to determine current monitor the window must be set") } @@ -107,7 +106,8 @@ func (g *GUI) GetMonitor() *glfw.Monitor { } if currentMonitor == nil { - panic("was not able to resolve current monitor") + // Monitor couldn't be found (xrandr scaling?) - default to primary + return glfw.GetPrimaryMonitor() } return currentMonitor