Fixed window dragging for main menu

This commit is contained in:
2025-05-30 21:20:33 -05:00
parent b31aefe896
commit 16fc8949b3
12 changed files with 307 additions and 14 deletions
+37
View File
@@ -47,6 +47,35 @@ function App() {
}
}, []);
// Function to handle window focus/show events to re-apply cursor
useEffect(() => {
const setupFocusHandler = async () => {
const unlistenFocus = await appWindow.onFocusChanged(async ({ payload: focused }) => {
if (focused) {
console.log('Window gained focus, re-applying custom cursor');
try {
await invoke("reapply_custom_cursor");
} catch (error) {
console.error('Failed to re-apply cursor on focus:', error);
}
}
});
return unlistenFocus;
};
let unlistenFocusFn;
setupFocusHandler().then(unlisten => {
unlistenFocusFn = unlisten;
}).catch(err => console.error('Failed to set up focus handler:', err));
return () => {
if (unlistenFocusFn) {
unlistenFocusFn();
}
};
}, []);
// Load cursors on mount and set up event listeners
useEffect(() => {
const loadCursors = async () => {
@@ -87,6 +116,14 @@ function App() {
// Prevent the window from closing
event.preventDefault();
// Temporarily restore cursor before hiding to tray
try {
console.log('Temporarily restoring cursor before hiding to tray');
await invoke("temporarily_restore_cursor");
} catch (error) {
console.error('Failed to restore cursor before hiding:', error);
}
// Hide the window instead
try {
console.log('Calling minimizeToTray function');