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).
This commit is contained in:
Menno Finlay-Smits 2019-02-06 02:17:07 +13:00 committed by Liam Galvin
parent 1f05951012
commit c2b1b95343
1 changed files with 2 additions and 2 deletions

View File

@ -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