From c02c9947a664ccbf8eafbc751d261d37fd2d217a Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 28 Jan 2026 16:21:20 +0000 Subject: [PATCH] Various fixes --- .../xpipe/app/core/AppDesktopIntegration.java | 21 ----------------- .../io/xpipe/app/core/AppWindowsShutdown.java | 23 +++++++++++++++++++ app/src/main/java/module-info.java | 1 + dist/changelog/21.0.md | 2 +- lang/strings/translations_en.properties | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java b/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java index aa4a85610..25db249c1 100644 --- a/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java +++ b/app/src/main/java/io/xpipe/app/core/AppDesktopIntegration.java @@ -46,27 +46,6 @@ public class AppDesktopIntegration { b.runOnWake(); } }); - - Desktop.getDesktop().addAppEventListener(new UserSessionListener() { - @Override - public void userSessionDeactivated(UserSessionEvent e) { - if (AppPrefs.get() == null) { - return; - } - - var b = AppPrefs.get().hibernateBehaviour().getValue(); - if (b == null) { - return; - } - - b.runOnSleep(); - } - - @Override - public void userSessionActivated(UserSessionEvent e) { - - } - }); } // This will initialize the toolkit on macOS and create the dock icon diff --git a/app/src/main/java/io/xpipe/app/core/AppWindowsShutdown.java b/app/src/main/java/io/xpipe/app/core/AppWindowsShutdown.java index 5b6ee6351..f8f536822 100644 --- a/app/src/main/java/io/xpipe/app/core/AppWindowsShutdown.java +++ b/app/src/main/java/io/xpipe/app/core/AppWindowsShutdown.java @@ -4,6 +4,7 @@ import io.xpipe.app.core.mode.AppOperationMode; import io.xpipe.app.issue.ErrorEventFactory; import io.xpipe.app.issue.TrackEvent; import io.xpipe.app.platform.PlatformState; +import io.xpipe.app.prefs.AppPrefs; import io.xpipe.app.util.ThreadHelper; import com.sun.jna.*; @@ -17,6 +18,8 @@ import java.util.List; public class AppWindowsShutdown { + public static final int WTS_SESSION_LOCK = 0x7; + public static final int WTS_SESSION_UNLOCK = 0x8; public static final int WM_ENDSESSION = 0x16; public static final int WM_QUERYENDSESSION = 0x11; public static final long ENDSESSION_CRITICAL = 0x40000000L; @@ -103,6 +106,26 @@ public class AppWindowsShutdown { return new WinDef.LRESULT(0); } + + // The awt UserSessionListener does not work, so do it manually + if (hookProcStruct.message.longValue() == WinUser.WM_SESSION_CHANGE) { + var type = hookProcStruct.wParam.longValue(); + if (type == WTS_SESSION_LOCK || type == WTS_SESSION_UNLOCK) { + if (AppPrefs.get() != null) { + var b = AppPrefs.get().hibernateBehaviour().getValue(); + if (b != null) { + ThreadHelper.runAsync(() -> { + if (type == WTS_SESSION_LOCK) { + b.runOnSleep(); + } else { + b.runOnWake(); + } + }); + return new WinDef.LRESULT(0); + } + } + } + } } return User32.INSTANCE.CallNextHookEx( hhook, nCode, wParam, new WinDef.LPARAM(Pointer.nativeValue(hookProcStruct.getPointer()))); diff --git a/app/src/main/java/module-info.java b/app/src/main/java/module-info.java index f310696e6..55f43e66b 100644 --- a/app/src/main/java/module-info.java +++ b/app/src/main/java/module-info.java @@ -110,6 +110,7 @@ open module io.xpipe.app { requires org.kordamp.ikonli.bootstrapicons; requires jdk.zipfs; requires org.int4.fx.builders; + requires io.xpipe.app; uses TerminalLauncher; uses ActionProvider; diff --git a/dist/changelog/21.0.md b/dist/changelog/21.0.md index 633ee252c..d4faa98cc 100644 --- a/dist/changelog/21.0.md +++ b/dist/changelog/21.0.md @@ -56,7 +56,7 @@ The scripting system has been completely reworked with the goal of becoming simp - Fix SSH config write, e.g. for vscode SSH, not properly passing all configured options - Fix SSH config identity detection not working for patterns in host entries - Fix custom SSH agent setting not always overriding other agents configured in SSH config -- Fix SSH config files include wildcards failing to parse in soe cases +- Fix SSH config files include wildcards failing to parse in some cases - Fix mstsc certificates trust status not persisting for tunneled RDP connections - Fix vscode-based editors not working when cmd.exe was disabled on the system - Fix various issues with the Keeper password manager and 2FA support diff --git a/lang/strings/translations_en.properties b/lang/strings/translations_en.properties index 0fab34391..0770afa83 100644 --- a/lang/strings/translations_en.properties +++ b/lang/strings/translations_en.properties @@ -1607,7 +1607,7 @@ gitRepoOverwriteLocalDescription=Replace all local changes with changes from the gitRepoForcePush=Overwrite remote repository gitRepoForcePushDescription=Use git push --force to apply your local changes to the remote gitRepoDontWarn=Don't warn anymore -gitRepoDontWarnDescription=If this is intentional, ignore this error in the future +gitRepoDontWarnDescription=If this is expected, make XPipe ignore this error in the future gitRepoTryAgain=Try again gitRepoTryAgainDescription=Attempt the same operation again gitRepoDisable=Disable git vault for now