diff --git a/src/main/scala/ocelot/desktop/ui/UiHandler.scala b/src/main/scala/ocelot/desktop/ui/UiHandler.scala index ede3805..b7d86f5 100644 --- a/src/main/scala/ocelot/desktop/ui/UiHandler.scala +++ b/src/main/scala/ocelot/desktop/ui/UiHandler.scala @@ -94,8 +94,22 @@ object UiHandler extends Logging { Display.setDisplayMode(new DisplayMode(root.size.width.toInt, root.size.height.toInt)) // Updating position from settings - if (Settings.get.windowPosition.isSet) + if (Settings.get.windowPosition.isSet) { + // the configuration can have incorrect values for coordinates + // and that can cause the window to "disappear" from the screen + // TODO: after upgrading to LWJGL 3 consider the multi-monitor setups + val desktop = Display.getDesktopDisplayMode + if (Settings.get.windowPosition.x < -Settings.get.windowSize.x) + Settings.get.windowPosition.x = 0 + if (Settings.get.windowPosition.x > desktop.getWidth) + Settings.get.windowPosition.x = desktop.getWidth - Settings.get.windowSize.x + if (Settings.get.windowPosition.y < -Settings.get.windowSize.y) + Settings.get.windowPosition.y = 0 + if (Settings.get.windowPosition.y > desktop.getHeight) + Settings.get.windowPosition.y = desktop.getHeight - Settings.get.windowSize.y + Display.setLocation(Settings.get.windowPosition.x, Settings.get.windowPosition.y) + } // Window should be resizable after exit from fullscreen mode // But it seems like there's lwjgl bug with internal resizable value caching