Skip to content

Commit a7ba53f

Browse files
[GR-52134] Merge in tag jdk-22+36
PullRequest: labsjdk-ce-22/13
2 parents 2621518 + 708d531 commit a7ba53f

File tree

3 files changed

+93
-8
lines changed

3 files changed

+93
-8
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ local contains(str, needle) = std.findSubstr(needle, str) != [];
246246
# Downstream Graal branch to test against. If you change this value to anything but
247247
# "master", you must create an ol-jira issue to change it back to master once the
248248
# next JVMCI release has been made. Add the issue id as a comment here.
249-
local downstream_branch = "labsjdk/automation-1-26-2024-4799",
249+
local downstream_branch = "release/graal-vm/24.0",
250250

251251
local clone_graal(defs) = {
252252
# Checkout the graal-enterprise repo to the "_gate" version of the

src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
3333
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR;
3434
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VRGB;
3535
import static java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
36+
import static java.util.concurrent.TimeUnit.SECONDS;
3637

3738
import java.awt.color.ColorSpace;
3839

@@ -47,6 +48,9 @@
4748
import java.awt.image.DataBufferByte;
4849
import java.awt.image.Raster;
4950
import java.awt.image.WritableRaster;
51+
import java.io.BufferedReader;
52+
import java.io.IOException;
53+
import java.io.InputStreamReader;
5054
import java.security.AccessController;
5155
import java.security.PrivilegedAction;
5256
import java.util.Arrays;
@@ -240,6 +244,72 @@ protected Object lazilyLoadGTKIcon(String longname) {
240244
return img;
241245
}
242246

247+
private static volatile Boolean shouldDisableSystemTray = null;
248+
249+
/**
250+
* There is an issue displaying the xembed icons in appIndicators
251+
* area with certain Gnome Shell versions.
252+
* To avoid any loss of quality of service, we are disabling
253+
* SystemTray support in such cases.
254+
*
255+
* @return true if system tray should be disabled
256+
*/
257+
public boolean shouldDisableSystemTray() {
258+
Boolean result = shouldDisableSystemTray;
259+
if (result == null) {
260+
synchronized (GTK_LOCK) {
261+
result = shouldDisableSystemTray;
262+
if (result == null) {
263+
if ("gnome".equals(getDesktop())) {
264+
@SuppressWarnings("removal")
265+
Integer gnomeShellMajorVersion =
266+
AccessController
267+
.doPrivileged((PrivilegedAction<Integer>)
268+
this::getGnomeShellMajorVersion);
269+
270+
if (gnomeShellMajorVersion == null
271+
|| gnomeShellMajorVersion < 45) {
272+
273+
return shouldDisableSystemTray = true;
274+
}
275+
}
276+
shouldDisableSystemTray = result = false;
277+
}
278+
}
279+
}
280+
return result;
281+
}
282+
283+
private Integer getGnomeShellMajorVersion() {
284+
try {
285+
Process process =
286+
new ProcessBuilder("/usr/bin/gnome-shell", "--version")
287+
.start();
288+
try (InputStreamReader isr = new InputStreamReader(process.getInputStream());
289+
BufferedReader reader = new BufferedReader(isr)) {
290+
291+
if (process.waitFor(2, SECONDS) && process.exitValue() == 0) {
292+
String line = reader.readLine();
293+
if (line != null) {
294+
String[] versionComponents = line
295+
.replaceAll("[^\\d.]", "")
296+
.split("\\.");
297+
298+
if (versionComponents.length >= 1) {
299+
return Integer.parseInt(versionComponents[0]);
300+
}
301+
}
302+
}
303+
}
304+
} catch (IOException
305+
| InterruptedException
306+
| IllegalThreadStateException
307+
| NumberFormatException ignored) {
308+
}
309+
310+
return null;
311+
}
312+
243313
/**
244314
* Returns a BufferedImage which contains the Gtk icon requested. If no
245315
* such icon exists or an error occurs loading the icon the result will

src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
import sun.awt.SunToolkit;
3131
import sun.awt.AppContext;
3232
import sun.awt.AWTAccessor;
33+
import sun.awt.UNIXToolkit;
3334
import sun.util.logging.PlatformLogger;
3435

3536
public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener {
@@ -48,22 +49,32 @@ public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener {
4849
private static final XAtom _NET_SYSTEM_TRAY_OPCODE = XAtom.get("_NET_SYSTEM_TRAY_OPCODE");
4950
private static final XAtom _NET_WM_ICON = XAtom.get("_NET_WM_ICON");
5051
private static final long SYSTEM_TRAY_REQUEST_DOCK = 0;
52+
private final boolean shouldDisableSystemTray;
5153

5254
XSystemTrayPeer(SystemTray target) {
5355
this.target = target;
5456
peerInstance = this;
5557

56-
selection.addSelectionListener(this);
58+
UNIXToolkit tk = (UNIXToolkit)Toolkit.getDefaultToolkit();
59+
shouldDisableSystemTray = tk.shouldDisableSystemTray();
5760

58-
long selection_owner = selection.getOwner(SCREEN);
59-
available = (selection_owner != XConstants.None);
61+
if (!shouldDisableSystemTray) {
62+
selection.addSelectionListener(this);
6063

61-
if (log.isLoggable(PlatformLogger.Level.FINE)) {
62-
log.fine(" check if system tray is available. selection owner: " + selection_owner);
64+
long selection_owner = selection.getOwner(SCREEN);
65+
available = (selection_owner != XConstants.None);
66+
67+
if (log.isLoggable(PlatformLogger.Level.FINE)) {
68+
log.fine(" check if system tray is available. selection owner: " + selection_owner);
69+
}
6370
}
6471
}
6572

6673
public void ownerChanged(int screen, XMSelection sel, long newOwner, long data, long timestamp) {
74+
if (shouldDisableSystemTray) {
75+
return;
76+
}
77+
6778
if (screen != SCREEN) {
6879
return;
6980
}
@@ -77,6 +88,10 @@ public void ownerChanged(int screen, XMSelection sel, long newOwner, long data,
7788
}
7889

7990
public void ownerDeath(int screen, XMSelection sel, long deadOwner) {
91+
if (shouldDisableSystemTray) {
92+
return;
93+
}
94+
8095
if (screen != SCREEN) {
8196
return;
8297
}

0 commit comments

Comments
 (0)