v1.9.20: Win32 restore watchdog — fix stuck minimized after Win+D
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
33
gui/app.py
33
gui/app.py
@@ -2,6 +2,7 @@
|
|||||||
Main application window — sidebar + tabview layout.
|
Main application window — sidebar + tabview layout.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
import tkinter
|
import tkinter
|
||||||
import customtkinter as ctk
|
import customtkinter as ctk
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox
|
||||||
@@ -118,6 +119,32 @@ class App(ctk.CTk):
|
|||||||
# Cleanup on close
|
# Cleanup on close
|
||||||
self.protocol("WM_DELETE_WINDOW", self._on_close)
|
self.protocol("WM_DELETE_WINDOW", self._on_close)
|
||||||
|
|
||||||
|
# Win32: restore window when stuck minimized after Win+D
|
||||||
|
self._restore_check_id = None
|
||||||
|
if sys.platform == "win32":
|
||||||
|
self.after(3000, self._start_restore_watchdog)
|
||||||
|
|
||||||
|
def _start_restore_watchdog(self):
|
||||||
|
"""Start periodic check for stuck minimized state (Windows only)."""
|
||||||
|
try:
|
||||||
|
import ctypes
|
||||||
|
self._user32 = ctypes.windll.user32
|
||||||
|
self._hwnd = int(self.wm_frame(), 16)
|
||||||
|
self._check_restore()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _check_restore(self):
|
||||||
|
"""If window is iconic but user clicked taskbar, force restore."""
|
||||||
|
try:
|
||||||
|
if self._user32.IsIconic(self._hwnd):
|
||||||
|
fg = self._user32.GetForegroundWindow()
|
||||||
|
if fg == self._hwnd:
|
||||||
|
self._user32.ShowWindow(self._hwnd, 9) # SW_RESTORE
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self._restore_check_id = self.after(500, self._check_restore)
|
||||||
|
|
||||||
def _build_layout(self):
|
def _build_layout(self):
|
||||||
# PanedWindow — resizable sidebar | main area
|
# PanedWindow — resizable sidebar | main area
|
||||||
self._paned = tkinter.PanedWindow(
|
self._paned = tkinter.PanedWindow(
|
||||||
@@ -682,6 +709,12 @@ class App(ctk.CTk):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _on_close(self):
|
def _on_close(self):
|
||||||
|
# Cancel restore watchdog
|
||||||
|
try:
|
||||||
|
if self._restore_check_id:
|
||||||
|
self.after_cancel(self._restore_check_id)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
# Save window geometry (size + position) and sidebar width
|
# Save window geometry (size + position) and sidebar width
|
||||||
try:
|
try:
|
||||||
geo = self.geometry()
|
geo = self.geometry()
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
"""Version info for ServerManager."""
|
"""Version info for ServerManager."""
|
||||||
|
|
||||||
__version__ = "1.9.19"
|
__version__ = "1.9.20"
|
||||||
__app_name__ = "ServerManager"
|
__app_name__ = "ServerManager"
|
||||||
__author__ = "aibot777"
|
__author__ = "aibot777"
|
||||||
__description__ = "Desktop GUI for managing remote servers"
|
__description__ = "Desktop GUI for managing remote servers"
|
||||||
|
|||||||
Reference in New Issue
Block a user