fix call xseterrorhandler while gdk error trap is up

This commit is contained in:
2026-06-01 03:09:54 +02:00
parent 8f70c4bf45
commit 0be3662a93

View File

@@ -24,6 +24,10 @@ import java.nio.file.Path;
import java.util.List; import java.util.List;
public final class Main extends Application { public final class Main extends Application {
// Mouse pointer location captured in main() before JavaFX loads GTK; used to pick the
// startup monitor. Reading it later (after GTK) makes AWT's X11 init clash with GDK.
private static java.awt.Point startupPointer;
private Compositor compositor; private Compositor compositor;
private TerminalMetrics metrics; private TerminalMetrics metrics;
private AppConfig config; private AppConfig config;
@@ -71,20 +75,14 @@ public final class Main extends Application {
} }
private static Screen activeScreen() { private static Screen activeScreen() {
try { java.awt.Point at = startupPointer;
// AWT is the only way to read the pointer location before any window is shown; if (at != null) {
// its coordinate space matches JavaFX's on the X11 virtual screen. // AWT and JavaFX share a coordinate space on the X11 virtual screen.
java.awt.PointerInfo pointer = java.awt.MouseInfo.getPointerInfo();
if (pointer != null) {
java.awt.Point at = pointer.getLocation();
List<Screen> screens = Screen.getScreensForRectangle(at.x, at.y, 1.0, 1.0); List<Screen> screens = Screen.getScreensForRectangle(at.x, at.y, 1.0, 1.0);
if (!screens.isEmpty()) { if (!screens.isEmpty()) {
return screens.get(0); return screens.get(0);
} }
} }
} catch (Throwable ignored) {
// Headless or AWT unavailable — fall back to the primary screen.
}
return Screen.getPrimary(); return Screen.getPrimary();
} }
@@ -232,6 +230,19 @@ public final class Main extends Application {
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("prism.order", System.getProperty("prism.order", "es2,sw")); System.setProperty("prism.order", System.getProperty("prism.order", "es2,sw"));
// Initialise AWT and read the pointer here, before launch() loads GTK. Done afterwards,
// AWT's X11 init calls XSetErrorHandler while GDK has an error trap pushed and warns.
startupPointer = readPointerLocation();
launch(Main.class, args); launch(Main.class, args);
} }
private static java.awt.Point readPointerLocation() {
try {
java.awt.PointerInfo pointer = java.awt.MouseInfo.getPointerInfo();
return pointer != null ? pointer.getLocation() : null;
} catch (Throwable ignored) {
// Headless or AWT unavailable — the startup monitor falls back to the primary screen.
return null;
}
}
} }