From 21f9f797c67d437298158786cdde1ba5cbf8fe1c Mon Sep 17 00:00:00 2001 From: Abdisalam Hassan Date: Tue, 8 Apr 2025 10:19:02 +0300 Subject: [PATCH 1/2] fixed ctrl + b not working --- electron/main.ts | 38 ++++++++++++++++++++++++++++++++------ electron/shortcuts.ts | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 2378c37..6ecdf46 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -385,10 +385,16 @@ function hideMainWindow(): void { const bounds = state.mainWindow.getBounds(); state.windowPosition = { x: bounds.x, y: bounds.y }; state.windowSize = { width: bounds.width, height: bounds.height }; + + // Linux-specific fix: Hide the window completely rather than just setting opacity + if (process.platform === 'linux') { + state.mainWindow.hide(); + } + state.mainWindow.setIgnoreMouseEvents(true, { forward: true }); state.mainWindow.setOpacity(0); state.isWindowVisible = false; - console.log('Window hidden, opacity set to 0'); + console.log('Window hidden, opacity set to 0, platform:', process.platform); } } @@ -400,27 +406,47 @@ function showMainWindow(): void { ...state.windowSize }); } + state.mainWindow.setIgnoreMouseEvents(false); state.mainWindow.setAlwaysOnTop(true, "screen-saver", 1); state.mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true }); state.mainWindow.setContentProtection(true); - state.mainWindow.setOpacity(0); // Set opacity to 0 before showing - state.mainWindow.showInactive(); // Use showInactive instead of show+focus - state.mainWindow.setOpacity(1); // Then set opacity to 1 after showing + + // Linux-specific show logic + if (process.platform === 'linux') { + state.mainWindow.show(); + state.mainWindow.focus(); + // Set opacity after showing to ensure the window is visible + state.mainWindow.setOpacity(configHelper.getOpacity()); + } else { + // Mac/Windows behavior + state.mainWindow.setOpacity(0); // Set opacity to 0 before showing + state.mainWindow.showInactive(); // Use showInactive instead of show+focus + state.mainWindow.setOpacity(1); // Then set opacity to 1 after showing + } + state.isWindowVisible = true; - console.log('Window shown with showInactive(), opacity set to 1'); + console.log('Window shown, platform:', process.platform); } } function toggleMainWindow(): void { - console.log(`Toggling window. Current state: ${state.isWindowVisible ? 'visible' : 'hidden'}`); + console.log(`Toggling window. Current state: ${state.isWindowVisible ? 'visible' : 'hidden'}, platform: ${process.platform}`); + if (state.isWindowVisible) { hideMainWindow(); } else { showMainWindow(); } + + // Additional logging to verify state + if (state.mainWindow && !state.mainWindow.isDestroyed()) { + setTimeout(() => { + console.log(`After toggle: isVisible=${state.isWindowVisible}, actual opacity=${state.mainWindow?.getOpacity()}`); + }, 100); + } } // Window movement functions diff --git a/electron/shortcuts.ts b/electron/shortcuts.ts index a6fa5eb..3228167 100644 --- a/electron/shortcuts.ts +++ b/electron/shortcuts.ts @@ -4,32 +4,56 @@ import { configHelper } from "./ConfigHelper" export class ShortcutsHelper { private deps: IShortcutsHelperDeps + // Track opacity locally to avoid getOpacity() inconsistency + private currentOpacity: number constructor(deps: IShortcutsHelperDeps) { this.deps = deps + // Initialize from stored config + this.currentOpacity = configHelper.getOpacity() } private adjustOpacity(delta: number): void { const mainWindow = this.deps.getMainWindow(); if (!mainWindow) return; - let currentOpacity = mainWindow.getOpacity(); - let newOpacity = Math.max(0.1, Math.min(1.0, currentOpacity + delta)); - console.log(`Adjusting opacity from ${currentOpacity} to ${newOpacity}`); + // Use our tracked opacity value instead of getOpacity() + let newOpacity = Math.max(0.1, Math.min(1.0, this.currentOpacity + delta)); + console.log(`Adjusting opacity from ${this.currentOpacity} to ${newOpacity}`); + // Linux-specific handling for opacity changes + if (process.platform === 'linux') { + // If we're going from visible to invisible, hide the window completely + if (this.currentOpacity > 0.1 && newOpacity <= 0.1) { + console.log('Linux: Opacity too low, hiding window completely'); + this.deps.toggleMainWindow(); // This will call hideMainWindow() which hides the window + return; // Skip further processing + } + + // If we're already hidden, but increasing opacity to a visible level, show the window + if (!this.deps.isVisible() && newOpacity > 0.1) { + console.log('Linux: Window hidden but opacity increasing, showing window'); + this.deps.toggleMainWindow(); // This will call showMainWindow() which shows the window + // Don't return, let it also set the opacity below + } + } + + // Apply the opacity mainWindow.setOpacity(newOpacity); - // Save the opacity setting to config without re-initializing the client + // Update our tracked opacity value + this.currentOpacity = newOpacity; + + // Save the opacity setting to config try { - const config = configHelper.loadConfig(); - config.opacity = newOpacity; - configHelper.saveConfig(config); + configHelper.setOpacity(newOpacity); } catch (error) { console.error('Error saving opacity to config:', error); } // If we're making the window visible, also make sure it's shown and interaction is enabled - if (newOpacity > 0.1 && !this.deps.isVisible()) { + // Only do this for non-Linux platforms (Linux handled above) + if (process.platform !== 'linux' && newOpacity > 0.1 && !this.deps.isVisible()) { this.deps.toggleMainWindow(); } } From 398bb7b8613b036f2dafab75f94f48789c7f5066 Mon Sep 17 00:00:00 2001 From: Abdisalam Hassan Date: Tue, 8 Apr 2025 10:22:59 +0300 Subject: [PATCH 2/2] Add Azure best practices guidance and update stealth-run.sh permissions --- .github/copilot-instructions.md | 1 + stealth-run.sh | 0 2 files changed, 1 insertion(+) create mode 100644 .github/copilot-instructions.md mode change 100644 => 100755 stealth-run.sh diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..7ec3ec1 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1 @@ +- @azure Rule - Use Azure Best Practices: When generating code for Azure, running terminal commands for Azure, or performing operations related to Azure, invoke your `get_azure_best_practices` tool if available.c \ No newline at end of file diff --git a/stealth-run.sh b/stealth-run.sh old mode 100644 new mode 100755