Skip to content

Commit c3a7e98

Browse files
committed
fix positioning of multi-screen support
1 parent bcf7c05 commit c3a7e98

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

fx-onscreen-keyboard/src/main/java/org/comtel2000/keyboard/control/KeyBoardPopup.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,17 @@ public void setVisible(final Visibility visible, final TextInputControl textNode
260260
}
261261

262262
Bounds textNodeBounds = textNode.localToScreen(textNode.getBoundsInLocal());
263-
Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
263+
// Find the screen that contains the text input control
264+
Rectangle2D screenBounds =
265+
Screen.getScreensForRectangle(
266+
textNodeBounds.getMinX(),
267+
textNodeBounds.getMinY(),
268+
textNodeBounds.getWidth(),
269+
textNodeBounds.getHeight())
270+
.stream()
271+
.map(Screen::getVisualBounds)
272+
.findFirst()
273+
.orElse(Screen.getPrimary().getVisualBounds());
264274
if (textNodeBounds.getMinX() + getWidth() > screenBounds.getMaxX()) {
265275
setX(screenBounds.getMaxX() - getWidth());
266276
} else {

0 commit comments

Comments
 (0)