Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
8247753: UIManager.getSytemLookAndFeelClassName() returns wrong value…
… on Fedora 32

Backport-of: 79a4a019bba1c99bef2377fe88f1464943530a55
  • Loading branch information
Yuri Nesterenko committed Apr 20, 2021
1 parent 5e89755 commit a44e891
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 21 deletions.
11 changes: 10 additions & 1 deletion src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java
Expand Up @@ -95,10 +95,19 @@ public static int getDatatransferTimeout() {

@Override
public String getDesktop() {
String gnome = "gnome";
String gsi = AccessController.doPrivileged(
(PrivilegedAction<String>) ()
-> System.getenv("GNOME_DESKTOP_SESSION_ID"));
return (gsi != null) ? "gnome" : null;
if (gsi != null) {
return gnome;
}

String desktop = AccessController.doPrivileged(
(PrivilegedAction<String>) ()
-> System.getenv("XDG_CURRENT_DESKTOP"));
return (desktop != null && desktop.toLowerCase().contains(gnome))
? gnome : null;
}

/**
Expand Down
Expand Up @@ -21,9 +21,9 @@
* questions.
*/

/*
/*
* @test
* @bug 8226783
* @bug 8226783 8247753
* @key headful
* @summary Verify System L&F
*/
Expand Down Expand Up @@ -52,23 +52,26 @@ public static void main(String[] args) {
} else if (os.contains("macos")) {
expLAF = "com.apple.laf.AquaLookAndFeel";
} else if (os.contains("linux")) {
/*
* The implementation keys off the following desktop setting to
* decide if GTK is an appropriate system L&F.
* In its absence, there probably isn't support for the GTK L&F
* anyway. It does not tell us if the GTK libraries are available
* but they really should be if this is a gnome session.
* If it proves necessary the test can perhaps be updated to see
* if the GTK LAF is listed as installed and can be instantiated.
*/
String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID");
System.out.println("Gnome desktop session ID is " + gnome);
if (gnome != null) {
expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} else if (os.contains("linux")) {
expLAF = "javax.swing.plaf.metal.MetalLookAndFeel";
}
}
/*
* The implementation keys off the following desktop setting to
* decide if GTK is an appropriate system L&F.
* In its absence, there probably isn't support for the GTK L&F
* anyway. It does not tell us if the GTK libraries are available
* but they really should be if this is a gnome session.
* If it proves necessary the test can perhaps be updated to see
* if the GTK LAF is listed as installed and can be instantiated.
*/
String gnome = System.getenv("GNOME_DESKTOP_SESSION_ID");
String desktop = System.getenv("XDG_CURRENT_DESKTOP");
System.out.println("Gnome desktop session ID is " + gnome);
System.out.println("XDG_CURRENT_DESKTOP is set to " + desktop);
if (gnome != null ||
(desktop != null && desktop.toLowerCase().contains("gnome"))) {
expLAF = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
} else {
expLAF = "javax.swing.plaf.metal.MetalLookAndFeel";
}
}
System.out.println("Expected System LAF is " + expLAF);
if (expLAF == null) {
System.out.println("No match for expected LAF, unknown OS ?");
Expand All @@ -77,5 +80,5 @@ public static void main(String[] args) {
if (!(laf.equals(expLAF))) {
throw new RuntimeException("LAF not as expected");
}
}
}
}

1 comment on commit a44e891

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.