Skip to content

Commit

Permalink
prevent available modification
Browse files Browse the repository at this point in the history
  • Loading branch information
azvegint committed Feb 15, 2024
1 parent e001b46 commit 7e1b315
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/java.desktop/unix/classes/sun/awt/X11/XSystemTrayPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener {
private static final XAtom _NET_SYSTEM_TRAY_OPCODE = XAtom.get("_NET_SYSTEM_TRAY_OPCODE");
private static final XAtom _NET_WM_ICON = XAtom.get("_NET_WM_ICON");
private static final long SYSTEM_TRAY_REQUEST_DOCK = 0;
private final boolean shouldDisableSystemTray;

XSystemTrayPeer(SystemTray target) {
this.target = target;
peerInstance = this;

selection.addSelectionListener(this);

UNIXToolkit tk = (UNIXToolkit)Toolkit.getDefaultToolkit();
if (!tk.shouldDisableSystemTray()) {
shouldDisableSystemTray = tk.shouldDisableSystemTray();

if (!shouldDisableSystemTray) {
selection.addSelectionListener(this);

long selection_owner = selection.getOwner(SCREEN);
available = (selection_owner != XConstants.None);

Expand All @@ -68,6 +71,10 @@ public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener {
}

public void ownerChanged(int screen, XMSelection sel, long newOwner, long data, long timestamp) {
if (shouldDisableSystemTray) {
return;
}

if (screen != SCREEN) {
return;
}
Expand All @@ -81,6 +88,10 @@ public void ownerChanged(int screen, XMSelection sel, long newOwner, long data,
}

public void ownerDeath(int screen, XMSelection sel, long deadOwner) {
if (shouldDisableSystemTray) {
return;
}

if (screen != SCREEN) {
return;
}
Expand Down

0 comments on commit 7e1b315

Please sign in to comment.