Show the local client's state in the system tray
The icon carries the badge the tree draws next to our own nickname on the active server — idle, talking, away, commander, microphone or speakers muted — and clicking it brings the window back to the front. Right click offers "Show TS3J" and "Quit". AWT's tray icon cannot be transparent on X11: the toolkit embeds a window of the screen's default, opaque visual and fills it with a background colour before drawing the image, so every icon sits in a box. Panels that can show transparent icons advertise an ARGB visual instead, so the icon is docked by hand over the system tray protocol, in that visual, with the image put on the window premultiplied. AWT's own icon stays as the fallback for everything else. Two details a panel will not forgive: an icon that publishes no size hints is allocated a one-pixel sliver, and docking is a request, so an icon that is never adopted has to hand over to the fallback rather than sit invisible. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -153,6 +153,18 @@ final class ServerTab implements ConnectionListener, ServerTreePanel.Actions {
|
||||
return commander;
|
||||
}
|
||||
|
||||
/** What the local client looks like on this server, for the tray icon. */
|
||||
SelfState selfState() {
|
||||
if (!conn.isConnected()) return SelfState.DISCONNECTED;
|
||||
if (deafened) return SelfState.DEAFENED;
|
||||
if (micMuted) return SelfState.MIC_MUTED;
|
||||
if (away) return SelfState.AWAY;
|
||||
ClientEntry self = conn.getModel().getClient(conn.getSelfClientId());
|
||||
boolean talking = self != null && self.talking;
|
||||
if (commander) return talking ? SelfState.COMMANDER_TALKING : SelfState.COMMANDER;
|
||||
return talking ? SelfState.TALKING : SelfState.IDLE;
|
||||
}
|
||||
|
||||
/** Path of the channel we are in, or empty when not connected. */
|
||||
String currentChannelPath() {
|
||||
if (!conn.isConnected()) return "";
|
||||
@@ -511,7 +523,10 @@ final class ServerTab implements ConnectionListener, ServerTreePanel.Actions {
|
||||
|
||||
@Override
|
||||
public void onTalkStateChanged(int clientId, boolean talking) {
|
||||
SwingUtilities.invokeLater(treePanel::refreshVisual);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
treePanel.refreshVisual();
|
||||
if (clientId == conn.getSelfClientId()) host.selfStateChanged(this);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user