Tray GTK fixes

This commit is contained in:
crschnick 2023-10-21 10:13:08 +00:00
parent 9ef6dcacb6
commit 5e1fc3910a
3 changed files with 10 additions and 4 deletions

View file

@ -59,7 +59,7 @@ public class AppMainWindow {
private synchronized void onChange() { private synchronized void onChange() {
lastUpdate = Instant.now(); lastUpdate = Instant.now();
if (thread == null) { if (thread == null) {
thread = ThreadHelper.createPlatformThread("window change timeout", true, () -> { thread = ThreadHelper.unstarted(() -> {
while (true) { while (true) {
var toStop = lastUpdate.plus(Duration.of(1, ChronoUnit.SECONDS)); var toStop = lastUpdate.plus(Duration.of(1, ChronoUnit.SECONDS));
if (Instant.now().isBefore(toStop)) { if (Instant.now().isBefore(toStop)) {
@ -237,6 +237,10 @@ public class AppMainWindow {
} }
public void show() { public void show() {
// Due to some weird GTK bug, we have to set these sizes every time we show a window even though they have been previously set
stage.setWidth(stage.getWidth());
stage.setHeight(stage.getHeight());
stage.show(); stage.show();
} }

View file

@ -14,7 +14,7 @@ import java.net.URL;
public class AppTrayIcon { public class AppTrayIcon {
private boolean shown = false; private boolean shown = false;
/** /**
* The default AWT SystemTray * The default AWT SystemTray
*/ */
@ -37,8 +37,8 @@ public class AppTrayIcon {
var image = switch (OsType.getLocal()) { var image = switch (OsType.getLocal()) {
case OsType.Windows windows -> "img/logo/logo_16x16.png"; case OsType.Windows windows -> "img/logo/logo_16x16.png";
case OsType.Linux linux -> "img/logo/logo_22x22.png"; case OsType.Linux linux -> "img/logo/logo_24x24.png";
case OsType.MacOs macOs -> "img/logo/logo_22x22.png"; case OsType.MacOs macOs -> "img/logo/logo_24x24.png";
}; };
var url = AppResources.getResourceURL(AppResources.XPIPE_MODULE, image).orElseThrow(); var url = AppResources.getResourceURL(AppResources.XPIPE_MODULE, image).orElseThrow();
@ -49,6 +49,7 @@ public class AppTrayIcon {
{ {
var open = new MenuItem(AppI18n.get("open")); var open = new MenuItem(AppI18n.get("open"));
open.addActionListener(e -> { open.addActionListener(e -> {
tray.remove(trayIcon);
OperationMode.switchToAsync(OperationMode.GUI); OperationMode.switchToAsync(OperationMode.GUI);
}); });
popupMenu.add(open); popupMenu.add(open);
@ -65,6 +66,7 @@ public class AppTrayIcon {
trayIcon.addActionListener(e -> { trayIcon.addActionListener(e -> {
if (OsType.getLocal() != OsType.MACOS) { if (OsType.getLocal() != OsType.MACOS) {
tray.remove(trayIcon);
OperationMode.switchToAsync(OperationMode.GUI); OperationMode.switchToAsync(OperationMode.GUI);
} }
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB