fix settings window show, hide, cancel-hide naming
This commit is contained in:
parent
fde34ef3de
commit
5e5fb4d0e9
@ -343,40 +343,32 @@ export class MainHeader extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
showWindow(name, element) {
|
||||
showSettingsWindow(element) {
|
||||
if (window.require) {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
console.log(`[MainHeader] showWindow('${name}') called at ${Date.now()}`);
|
||||
console.log(`[MainHeader] showSettingsWindow called at ${Date.now()}`);
|
||||
|
||||
ipcRenderer.send('cancel-hide-window', name);
|
||||
ipcRenderer.send('cancel-hide-settings-window');
|
||||
|
||||
if (name === 'settings' && element) {
|
||||
const rect = element.getBoundingClientRect();
|
||||
ipcRenderer.send('show-window', {
|
||||
name: 'settings',
|
||||
bounds: {
|
||||
x: rect.left,
|
||||
y: rect.top,
|
||||
width: rect.width,
|
||||
height: rect.height
|
||||
}
|
||||
if (element) {
|
||||
const { left, top, width, height } = element.getBoundingClientRect();
|
||||
ipcRenderer.send('show-settings-window', {
|
||||
x: left,
|
||||
y: top,
|
||||
width,
|
||||
height,
|
||||
});
|
||||
} else {
|
||||
ipcRenderer.send('show-window', name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hideWindow(name) {
|
||||
hideSettingsWindow() {
|
||||
if (window.require) {
|
||||
console.log(`[MainHeader] hideWindow('${name}') called at ${Date.now()}`);
|
||||
window.require('electron').ipcRenderer.send('hide-window', name);
|
||||
console.log(`[MainHeader] hideSettingsWindow called at ${Date.now()}`);
|
||||
window.require('electron').ipcRenderer.send('hide-settings-window');
|
||||
}
|
||||
}
|
||||
|
||||
cancelHideWindow(name) {
|
||||
|
||||
}
|
||||
|
||||
renderShortcut(accelerator) {
|
||||
if (!accelerator) return html``;
|
||||
@ -449,8 +441,8 @@ export class MainHeader extends LitElement {
|
||||
|
||||
<button
|
||||
class="settings-button"
|
||||
@mouseenter=${(e) => this.showWindow('settings', e.currentTarget)}
|
||||
@mouseleave=${() => this.hideWindow('settings')}
|
||||
@mouseenter=${(e) => this.showSettingsWindow(e.currentTarget)}
|
||||
@mouseleave=${() => this.hideSettingsWindow()}
|
||||
>
|
||||
<div class="settings-icon">
|
||||
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
|
@ -762,9 +762,9 @@ function setupIpcHandlers(movementManager) {
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('show-window', (event, args) => {
|
||||
const { name, bounds } = typeof args === 'object' && args !== null ? args : { name: args, bounds: null };
|
||||
const win = windowPool.get(name);
|
||||
ipcMain.on('show-settings-window', (event, bounds) => {
|
||||
if (!bounds) return;
|
||||
const win = windowPool.get('settings');
|
||||
|
||||
if (win && !win.isDestroyed()) {
|
||||
if (settingsHideTimer) {
|
||||
@ -772,7 +772,6 @@ function setupIpcHandlers(movementManager) {
|
||||
settingsHideTimer = null;
|
||||
}
|
||||
|
||||
if (name === 'settings') {
|
||||
// Adjust position based on button bounds
|
||||
const header = windowPool.get('header');
|
||||
const headerBounds = header?.getBounds() ?? { x: 0, y: 0 };
|
||||
@ -790,22 +789,16 @@ function setupIpcHandlers(movementManager) {
|
||||
win.setBounds({ x, y });
|
||||
win.__lockedByButton = true;
|
||||
console.log(`[WindowManager] Positioning settings window at (${x}, ${y}) based on button bounds.`);
|
||||
}
|
||||
|
||||
win.show();
|
||||
win.moveTop();
|
||||
|
||||
if (name === 'settings') {
|
||||
win.setAlwaysOnTop(true);
|
||||
}
|
||||
// updateLayout();
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('hide-window', (event, name) => {
|
||||
const window = windowPool.get(name);
|
||||
ipcMain.on('hide-settings-window', (event) => {
|
||||
const window = windowPool.get("settings");
|
||||
if (window && !window.isDestroyed()) {
|
||||
if (name === 'settings') {
|
||||
if (settingsHideTimer) {
|
||||
clearTimeout(settingsHideTimer);
|
||||
}
|
||||
@ -816,15 +809,13 @@ function setupIpcHandlers(movementManager) {
|
||||
}
|
||||
settingsHideTimer = null;
|
||||
}, 200);
|
||||
} else {
|
||||
window.hide();
|
||||
}
|
||||
|
||||
window.__lockedByButton = false;
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.on('cancel-hide-window', (event, name) => {
|
||||
if (name === 'settings' && settingsHideTimer) {
|
||||
ipcMain.on('cancel-hide-settings-window', (event) => {
|
||||
if (settingsHideTimer) {
|
||||
clearTimeout(settingsHideTimer);
|
||||
settingsHideTimer = null;
|
||||
}
|
||||
|
@ -1025,14 +1025,14 @@ export class SettingsView extends LitElement {
|
||||
handleMouseEnter = () => {
|
||||
if (window.require) {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('cancel-hide-window', 'settings');
|
||||
ipcRenderer.send('cancel-hide-settings-window');
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseLeave = () => {
|
||||
if (window.require) {
|
||||
const { ipcRenderer } = window.require('electron');
|
||||
ipcRenderer.send('hide-window', 'settings');
|
||||
ipcRenderer.send('hide-settings-window');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user