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) {
|
if (window.require) {
|
||||||
const { ipcRenderer } = window.require('electron');
|
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) {
|
if (element) {
|
||||||
const rect = element.getBoundingClientRect();
|
const { left, top, width, height } = element.getBoundingClientRect();
|
||||||
ipcRenderer.send('show-window', {
|
ipcRenderer.send('show-settings-window', {
|
||||||
name: 'settings',
|
x: left,
|
||||||
bounds: {
|
y: top,
|
||||||
x: rect.left,
|
width,
|
||||||
y: rect.top,
|
height,
|
||||||
width: rect.width,
|
|
||||||
height: rect.height
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
ipcRenderer.send('show-window', name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hideWindow(name) {
|
hideSettingsWindow() {
|
||||||
if (window.require) {
|
if (window.require) {
|
||||||
console.log(`[MainHeader] hideWindow('${name}') called at ${Date.now()}`);
|
console.log(`[MainHeader] hideSettingsWindow called at ${Date.now()}`);
|
||||||
window.require('electron').ipcRenderer.send('hide-window', name);
|
window.require('electron').ipcRenderer.send('hide-settings-window');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelHideWindow(name) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
renderShortcut(accelerator) {
|
renderShortcut(accelerator) {
|
||||||
if (!accelerator) return html``;
|
if (!accelerator) return html``;
|
||||||
@ -449,8 +441,8 @@ export class MainHeader extends LitElement {
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
class="settings-button"
|
class="settings-button"
|
||||||
@mouseenter=${(e) => this.showWindow('settings', e.currentTarget)}
|
@mouseenter=${(e) => this.showSettingsWindow(e.currentTarget)}
|
||||||
@mouseleave=${() => this.hideWindow('settings')}
|
@mouseleave=${() => this.hideSettingsWindow()}
|
||||||
>
|
>
|
||||||
<div class="settings-icon">
|
<div class="settings-icon">
|
||||||
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<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) => {
|
ipcMain.on('show-settings-window', (event, bounds) => {
|
||||||
const { name, bounds } = typeof args === 'object' && args !== null ? args : { name: args, bounds: null };
|
if (!bounds) return;
|
||||||
const win = windowPool.get(name);
|
const win = windowPool.get('settings');
|
||||||
|
|
||||||
if (win && !win.isDestroyed()) {
|
if (win && !win.isDestroyed()) {
|
||||||
if (settingsHideTimer) {
|
if (settingsHideTimer) {
|
||||||
@ -772,59 +772,50 @@ function setupIpcHandlers(movementManager) {
|
|||||||
settingsHideTimer = null;
|
settingsHideTimer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name === 'settings') {
|
// Adjust position based on button bounds
|
||||||
// Adjust position based on button bounds
|
const header = windowPool.get('header');
|
||||||
const header = windowPool.get('header');
|
const headerBounds = header?.getBounds() ?? { x: 0, y: 0 };
|
||||||
const headerBounds = header?.getBounds() ?? { x: 0, y: 0 };
|
const settingsBounds = win.getBounds();
|
||||||
const settingsBounds = win.getBounds();
|
|
||||||
|
|
||||||
const disp = getCurrentDisplay(header);
|
const disp = getCurrentDisplay(header);
|
||||||
const { x: waX, y: waY, width: waW, height: waH } = disp.workArea;
|
const { x: waX, y: waY, width: waW, height: waH } = disp.workArea;
|
||||||
|
|
||||||
let x = Math.round(headerBounds.x + (bounds?.x ?? 0) + (bounds?.width ?? 0) / 2 - settingsBounds.width / 2);
|
let x = Math.round(headerBounds.x + (bounds?.x ?? 0) + (bounds?.width ?? 0) / 2 - settingsBounds.width / 2);
|
||||||
let y = Math.round(headerBounds.y + (bounds?.y ?? 0) + (bounds?.height ?? 0) + 31);
|
let y = Math.round(headerBounds.y + (bounds?.y ?? 0) + (bounds?.height ?? 0) + 31);
|
||||||
|
|
||||||
x = Math.max(waX + 10, Math.min(waX + waW - settingsBounds.width - 10, x));
|
x = Math.max(waX + 10, Math.min(waX + waW - settingsBounds.width - 10, x));
|
||||||
y = Math.max(waY + 10, Math.min(waY + waH - settingsBounds.height - 10, y));
|
y = Math.max(waY + 10, Math.min(waY + waH - settingsBounds.height - 10, y));
|
||||||
|
|
||||||
win.setBounds({ x, y });
|
win.setBounds({ x, y });
|
||||||
win.__lockedByButton = true;
|
win.__lockedByButton = true;
|
||||||
console.log(`[WindowManager] Positioning settings window at (${x}, ${y}) based on button bounds.`);
|
console.log(`[WindowManager] Positioning settings window at (${x}, ${y}) based on button bounds.`);
|
||||||
}
|
|
||||||
|
|
||||||
win.show();
|
win.show();
|
||||||
win.moveTop();
|
win.moveTop();
|
||||||
|
win.setAlwaysOnTop(true);
|
||||||
if (name === 'settings') {
|
|
||||||
win.setAlwaysOnTop(true);
|
|
||||||
}
|
|
||||||
// updateLayout();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('hide-window', (event, name) => {
|
ipcMain.on('hide-settings-window', (event) => {
|
||||||
const window = windowPool.get(name);
|
const window = windowPool.get("settings");
|
||||||
if (window && !window.isDestroyed()) {
|
if (window && !window.isDestroyed()) {
|
||||||
if (name === 'settings') {
|
if (settingsHideTimer) {
|
||||||
if (settingsHideTimer) {
|
clearTimeout(settingsHideTimer);
|
||||||
clearTimeout(settingsHideTimer);
|
|
||||||
}
|
|
||||||
settingsHideTimer = setTimeout(() => {
|
|
||||||
if (window && !window.isDestroyed()) {
|
|
||||||
window.setAlwaysOnTop(false);
|
|
||||||
window.hide();
|
|
||||||
}
|
|
||||||
settingsHideTimer = null;
|
|
||||||
}, 200);
|
|
||||||
} else {
|
|
||||||
window.hide();
|
|
||||||
}
|
}
|
||||||
|
settingsHideTimer = setTimeout(() => {
|
||||||
|
if (window && !window.isDestroyed()) {
|
||||||
|
window.setAlwaysOnTop(false);
|
||||||
|
window.hide();
|
||||||
|
}
|
||||||
|
settingsHideTimer = null;
|
||||||
|
}, 200);
|
||||||
|
|
||||||
window.__lockedByButton = false;
|
window.__lockedByButton = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('cancel-hide-window', (event, name) => {
|
ipcMain.on('cancel-hide-settings-window', (event) => {
|
||||||
if (name === 'settings' && settingsHideTimer) {
|
if (settingsHideTimer) {
|
||||||
clearTimeout(settingsHideTimer);
|
clearTimeout(settingsHideTimer);
|
||||||
settingsHideTimer = null;
|
settingsHideTimer = null;
|
||||||
}
|
}
|
||||||
|
@ -1025,14 +1025,14 @@ export class SettingsView extends LitElement {
|
|||||||
handleMouseEnter = () => {
|
handleMouseEnter = () => {
|
||||||
if (window.require) {
|
if (window.require) {
|
||||||
const { ipcRenderer } = window.require('electron');
|
const { ipcRenderer } = window.require('electron');
|
||||||
ipcRenderer.send('cancel-hide-window', 'settings');
|
ipcRenderer.send('cancel-hide-settings-window');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseLeave = () => {
|
handleMouseLeave = () => {
|
||||||
if (window.require) {
|
if (window.require) {
|
||||||
const { ipcRenderer } = window.require('electron');
|
const { ipcRenderer } = window.require('electron');
|
||||||
ipcRenderer.send('hide-window', 'settings');
|
ipcRenderer.send('hide-settings-window');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user