소스 검색

enhance screen selection by adding primary fallback

Jan-Peter Klein 1 년 전
부모
커밋
a213f073b1
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

+ 4 - 1
src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java

@@ -116,7 +116,10 @@ public class UnlockWorkflow extends Task<Void> {
 				double x = mainWindow.getX() + (mainWindow.getWidth() - window.getWidth()) / 2;
 				double y = mainWindow.getY() + (mainWindow.getHeight() - window.getHeight()) / 2;
 				if(!mainWindow.isShowing()) {
-					Screen screen = Screen.getScreensForRectangle(mainWindow.getX(), mainWindow.getY(), mainWindow.getWidth(), mainWindow.getHeight()).get(0);
+					Screen screen = Screen.getScreensForRectangle(mainWindow.getX(), mainWindow.getY(), mainWindow.getWidth(), mainWindow.getHeight())
+							.stream()
+							.findFirst()
+							.orElse(Screen.getPrimary());
 					Rectangle2D bounds = screen.getVisualBounds();
 					x = bounds.getMinX() + (bounds.getWidth() - window.getWidth()) / 2;
 					y = bounds.getMinY() + (bounds.getHeight() - window.getHeight()) / 2;