Skip to content

Commit fe5da7b

Browse files
committed
Find xprop at runtime instead of checking the path in the configure.ac
1 parent b52d4ac commit fe5da7b

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

make/autoconf/configure.ac

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,6 @@ JVM_FEATURES_SETUP
247247

248248
HOTSPOT_SETUP_MISC
249249

250-
###############################################################################
251-
#
252-
# Configuration for Java ATK Wrapper.
253-
#
254-
###############################################################################
255-
256-
XPROP_PATH=${PATH}:/usr/X11/bin
257-
AC_PATH_PROG(XPROP,xprop,,${XPROP_PATH})
258-
if test -z "$XPROP"; then
259-
AC_MSG_ERROR([No xprop found])
260-
fi
261-
AC_SUBST(XPROP)
262-
263-
AC_CONFIG_FILES([
264-
src/jdk.accessibility/linux/classes/org/GNOME/Accessibility/AtkWrapper.java
265-
])
266-
267250
###############################################################################
268251
#
269252
# We need to do some final tweaking, when everything else is done.

src/jdk.accessibility/linux/classes/org/GNOME/Accessibility/AtkWrapper.java.in renamed to src/jdk.accessibility/linux/classes/org/GNOME/Accessibility/AtkWrapper.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import javax.management.*;
3030
import javax.swing.JComboBox;
3131
import java.lang.management.*;
32+
import java.util.*;
3233

3334
public class AtkWrapper {
3435
static boolean accessibilityEnabled = false;
@@ -37,9 +38,29 @@ static void initAtk() {
3738
if (AtkWrapper.initNativeLibrary())
3839
accessibilityEnabled = true;
3940
}
41+
42+
private static String findXPropPath() {
43+
String pathEnv = System.getenv().get("PATH");
44+
if (pathEnv != null) {
45+
String pathSeparator = File.pathSeparator;
46+
java.util.List<String> paths = Arrays.asList(pathEnv.split(File.pathSeparator));
47+
for (String path : paths) {
48+
File xpropFile = new File(path, "xprop");
49+
if (xpropFile.exists()) {
50+
return xpropFile.getAbsolutePath();
51+
}
52+
}
53+
}
54+
return null;
55+
}
56+
4057
static {
4158
try {
42-
ProcessBuilder builder = new ProcessBuilder("@XPROP@", "-root");
59+
String xpropPath = findXPropPath();
60+
if (xpropPath == null) {
61+
throw new RuntimeException("No xprop found");
62+
}
63+
ProcessBuilder builder = new ProcessBuilder(xpropPath, "-root");
4364
Process p = builder.start();
4465
BufferedReader b = new BufferedReader(new InputStreamReader (p.getInputStream ()));
4566
String result;
@@ -690,7 +711,7 @@ public AtkWrapper() {
690711
AWTEvent.WINDOW_EVENT_MASK |
691712
AWTEvent.FOCUS_EVENT_MASK |
692713
AWTEvent.CONTAINER_EVENT_MASK);
693-
714+
if (toolkit.getSystemEventQueue() != null) {
694715
toolkit.getSystemEventQueue().push(new EventQueue() {
695716
boolean previousPressConsumed = false;
696717

@@ -719,6 +740,7 @@ public void dispatchEvent(AWTEvent e) {
719740
super.dispatchEvent(e);
720741
}
721742
});
743+
}
722744
}
723745

724746
public static long getInstanceFromSwing(AccessibleContext ac) {
@@ -728,4 +750,4 @@ public static long getInstanceFromSwing(AccessibleContext ac) {
728750
public static void main(String args[]) {
729751
new AtkWrapper();
730752
}
731-
}
753+
}

0 commit comments

Comments
 (0)