-
Notifications
You must be signed in to change notification settings - Fork 535
fixed obacity problems on linux #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
} | ||
|
||
Comment on lines
+389
to
+393
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is only for linux, where is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the idea is that on Linux we straight up hide the window, but Windows and Mac we just set opacity to 0, so no need to hide the window on non-Linux platforms. |
||
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 | ||
} | ||
|
||
Comment on lines
+418
to
+429
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure this is working for other OS? |
||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, streamlining the implementation for Linux OS still needs verification that it is not breaking other OS |
||
// 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(); | ||
} | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove, unnecessary change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove, unnecessary change