remove movementmanager dependency on toggleAllWindowsVisibility
This commit is contained in:
parent
5e5fb4d0e9
commit
88cacb4bc3
@ -136,16 +136,6 @@ export class PickleGlassApp extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestWindowResize() {
|
|
||||||
if (window.require) {
|
|
||||||
const { ipcRenderer } = window.require('electron');
|
|
||||||
ipcRenderer.invoke('resize-window', {
|
|
||||||
isMainViewVisible: this.isMainViewVisible,
|
|
||||||
view: this.currentView,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setStatus(text) {
|
setStatus(text) {
|
||||||
this.statusText = text;
|
this.statusText = text;
|
||||||
}
|
}
|
||||||
|
@ -78,13 +78,6 @@ function updateLayout() {
|
|||||||
let movementManager = null;
|
let movementManager = null;
|
||||||
|
|
||||||
|
|
||||||
const featureWindows = ['listen','ask','settings'];
|
|
||||||
// const featureWindows = ['listen','ask','settings','shortcut-settings'];
|
|
||||||
function isAllowed(name) {
|
|
||||||
if (name === 'header') return true;
|
|
||||||
return featureWindows.includes(name) && currentHeaderState === 'main';
|
|
||||||
}
|
|
||||||
|
|
||||||
function createFeatureWindows(header, namesToCreate) {
|
function createFeatureWindows(header, namesToCreate) {
|
||||||
// if (windowPool.has('listen')) return;
|
// if (windowPool.has('listen')) return;
|
||||||
|
|
||||||
@ -305,6 +298,7 @@ function createFeatureWindows(header, namesToCreate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function destroyFeatureWindows() {
|
function destroyFeatureWindows() {
|
||||||
|
const featureWindows = ['listen','ask','settings','shortcut-settings'];
|
||||||
if (settingsHideTimer) {
|
if (settingsHideTimer) {
|
||||||
clearTimeout(settingsHideTimer);
|
clearTimeout(settingsHideTimer);
|
||||||
settingsHideTimer = null;
|
settingsHideTimer = null;
|
||||||
@ -337,72 +331,35 @@ function getDisplayById(displayId) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function toggleAllWindowsVisibility(movementManager) {
|
function toggleAllWindowsVisibility() {
|
||||||
const header = windowPool.get('header');
|
const header = windowPool.get('header');
|
||||||
if (!header) return;
|
if (!header) return;
|
||||||
|
|
||||||
if (header.isVisible()) {
|
if (header.isVisible()) {
|
||||||
console.log('[Visibility] Smart hiding - calculating nearest edge');
|
lastVisibleWindows.clear();
|
||||||
|
|
||||||
const headerBounds = header.getBounds();
|
windowPool.forEach((win, name) => {
|
||||||
const display = screen.getPrimaryDisplay();
|
if (win && !win.isDestroyed() && win.isVisible()) {
|
||||||
const { width: screenWidth, height: screenHeight } = display.workAreaSize;
|
lastVisibleWindows.add(name);
|
||||||
|
}
|
||||||
const centerX = headerBounds.x + headerBounds.width / 2;
|
});
|
||||||
const centerY = headerBounds.y + headerBounds.height / 2;
|
|
||||||
|
lastVisibleWindows.forEach(name => {
|
||||||
const distances = {
|
if (name === 'header') return;
|
||||||
top: centerY,
|
const win = windowPool.get(name);
|
||||||
bottom: screenHeight - centerY,
|
if (win && !win.isDestroyed()) win.hide();
|
||||||
left: centerX,
|
});
|
||||||
right: screenWidth - centerX,
|
header.hide();
|
||||||
};
|
|
||||||
|
return;
|
||||||
const nearestEdge = Object.keys(distances).reduce((nearest, edge) => (distances[edge] < distances[nearest] ? edge : nearest));
|
|
||||||
|
|
||||||
console.log(`[Visibility] Nearest edge: ${nearestEdge} (distance: ${distances[nearestEdge].toFixed(1)}px)`);
|
|
||||||
|
|
||||||
lastVisibleWindows.clear();
|
|
||||||
lastVisibleWindows.add('header');
|
|
||||||
|
|
||||||
windowPool.forEach((win, name) => {
|
|
||||||
if (win.isVisible()) {
|
|
||||||
lastVisibleWindows.add(name);
|
|
||||||
if (name !== 'header') {
|
|
||||||
win.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('[Visibility] Visible windows before hide:', Array.from(lastVisibleWindows));
|
|
||||||
|
|
||||||
movementManager.hideToEdge(nearestEdge, () => {
|
|
||||||
header.hide();
|
|
||||||
console.log('[Visibility] Smart hide completed');
|
|
||||||
}, { instant: true });
|
|
||||||
} else {
|
|
||||||
console.log('[Visibility] Smart showing from hidden position');
|
|
||||||
console.log('[Visibility] Restoring windows:', Array.from(lastVisibleWindows));
|
|
||||||
|
|
||||||
header.show();
|
|
||||||
|
|
||||||
movementManager.showFromEdge(() => {
|
|
||||||
lastVisibleWindows.forEach(name => {
|
|
||||||
if (name === 'header') return;
|
|
||||||
const win = windowPool.get(name);
|
|
||||||
if (win && !win.isDestroyed()) {
|
|
||||||
win.show();
|
|
||||||
win.webContents.send('window-show-animation');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setImmediate(updateLayout);
|
|
||||||
setTimeout(updateLayout, 120);
|
|
||||||
|
|
||||||
console.log('[Visibility] Smart show completed');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
lastVisibleWindows.forEach(name => {
|
||||||
|
const win = windowPool.get(name);
|
||||||
|
if (win && !win.isDestroyed())
|
||||||
|
win.show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function createWindows() {
|
function createWindows() {
|
||||||
@ -508,7 +465,7 @@ function createWindows() {
|
|||||||
updateLayout();
|
updateLayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('toggle-all-windows-visibility', () => toggleAllWindowsVisibility(movementManager));
|
ipcMain.handle('toggle-all-windows-visibility', () => toggleAllWindowsVisibility());
|
||||||
|
|
||||||
ipcMain.handle('toggle-feature', async (event, featureName) => {
|
ipcMain.handle('toggle-feature', async (event, featureName) => {
|
||||||
if (!windowPool.get(featureName) && currentHeaderState === 'main') {
|
if (!windowPool.get(featureName) && currentHeaderState === 'main') {
|
||||||
@ -821,18 +778,11 @@ function setupIpcHandlers(movementManager) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('hide-all', () => {
|
|
||||||
windowPool.forEach(win => {
|
|
||||||
if (win.isFocused()) return;
|
|
||||||
win.hide();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.handle('quit-application', () => {
|
ipcMain.handle('quit-application', () => {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('is-window-visible', (event, windowName) => {
|
ipcMain.handle('is-ask-window-visible', (event, windowName) => {
|
||||||
const window = windowPool.get(windowName);
|
const window = windowPool.get(windowName);
|
||||||
if (window && !window.isDestroyed()) {
|
if (window && !window.isDestroyed()) {
|
||||||
return window.isVisible();
|
return window.isVisible();
|
||||||
@ -866,15 +816,6 @@ function setupIpcHandlers(movementManager) {
|
|||||||
destroyFeatureWindows();
|
destroyFeatureWindows();
|
||||||
}
|
}
|
||||||
loadAndRegisterShortcuts(movementManager);
|
loadAndRegisterShortcuts(movementManager);
|
||||||
|
|
||||||
for (const [name, win] of windowPool) {
|
|
||||||
if (!isAllowed(name) && !win.isDestroyed()) {
|
|
||||||
win.hide();
|
|
||||||
}
|
|
||||||
if (isAllowed(name) && win.isVisible()) {
|
|
||||||
win.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('update-keybinds', (event, newKeybinds) => {
|
ipcMain.on('update-keybinds', (event, newKeybinds) => {
|
||||||
@ -947,9 +888,6 @@ function setupIpcHandlers(movementManager) {
|
|||||||
|
|
||||||
setupApiKeyIPC();
|
setupApiKeyIPC();
|
||||||
|
|
||||||
ipcMain.handle('resize-window', () => {});
|
|
||||||
|
|
||||||
ipcMain.handle('resize-for-view', () => {});
|
|
||||||
|
|
||||||
ipcMain.handle('resize-header-window', (event, { width, height }) => {
|
ipcMain.handle('resize-header-window', (event, { width, height }) => {
|
||||||
const header = windowPool.get('header');
|
const header = windowPool.get('header');
|
||||||
@ -1010,7 +948,6 @@ function setupIpcHandlers(movementManager) {
|
|||||||
header.hide();
|
header.hide();
|
||||||
console.log('[WindowManager] Header hidden after animation.');
|
console.log('[WindowManager] Header hidden after animation.');
|
||||||
} else if (state === 'visible') {
|
} else if (state === 'visible') {
|
||||||
// 자식 창들을 다시 보여주는 로직은 toggleAllWindowsVisibility에 이미 있으므로 여기서는 중복 작업을 피합니다.
|
|
||||||
console.log('[WindowManager] Header shown after animation.');
|
console.log('[WindowManager] Header shown after animation.');
|
||||||
updateLayout();
|
updateLayout();
|
||||||
}
|
}
|
||||||
@ -1322,7 +1259,7 @@ function updateGlobalShortcuts(keybinds, mainWindow, sendToRenderer, movementMan
|
|||||||
if (state === 'apikey') {
|
if (state === 'apikey') {
|
||||||
if (keybinds.toggleVisibility) {
|
if (keybinds.toggleVisibility) {
|
||||||
try {
|
try {
|
||||||
globalShortcut.register(keybinds.toggleVisibility, () => toggleAllWindowsVisibility(movementManager));
|
globalShortcut.register(keybinds.toggleVisibility, () => toggleAllWindowsVisibility());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to register toggleVisibility (${keybinds.toggleVisibility}):`, error);
|
console.error(`Failed to register toggleVisibility (${keybinds.toggleVisibility}):`, error);
|
||||||
}
|
}
|
||||||
@ -1358,7 +1295,7 @@ function updateGlobalShortcuts(keybinds, mainWindow, sendToRenderer, movementMan
|
|||||||
let callback;
|
let callback;
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case 'toggleVisibility':
|
case 'toggleVisibility':
|
||||||
callback = () => toggleAllWindowsVisibility(movementManager);
|
callback = () => toggleAllWindowsVisibility();
|
||||||
break;
|
break;
|
||||||
case 'nextStep':
|
case 'nextStep':
|
||||||
callback = () => {
|
callback = () => {
|
||||||
@ -1528,9 +1465,6 @@ module.exports = {
|
|||||||
createWindows,
|
createWindows,
|
||||||
windowPool,
|
windowPool,
|
||||||
fixedYPosition,
|
fixedYPosition,
|
||||||
//////// before_modelStateService ////////
|
|
||||||
// setApiKey,
|
|
||||||
//////// before_modelStateService ////////
|
|
||||||
getStoredApiKey,
|
getStoredApiKey,
|
||||||
getStoredProvider,
|
getStoredProvider,
|
||||||
getCurrentModelInfo,
|
getCurrentModelInfo,
|
||||||
|
@ -412,7 +412,7 @@ export class SummaryView extends LitElement {
|
|||||||
const { ipcRenderer } = window.require('electron');
|
const { ipcRenderer } = window.require('electron');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isAskViewVisible = await ipcRenderer.invoke('is-window-visible', 'ask');
|
const isAskViewVisible = await ipcRenderer.invoke('is-ask-window-visible', 'ask');
|
||||||
|
|
||||||
if (!isAskViewVisible) {
|
if (!isAskViewVisible) {
|
||||||
await ipcRenderer.invoke('toggle-feature', 'ask');
|
await ipcRenderer.invoke('toggle-feature', 'ask');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user