Unverified Commit a11fa20b authored by Thibaut Sardan's avatar Thibaut Sardan Committed by GitHub
Browse files

Merge pull request #443 from paritytech/luke-442-window-shrink-bug

fix: Fixes #442. Only run moveWindowUp when Fether window "frameless" and when showing window
parents 5ceb26dc 01147fa6
Pipeline #31581 passed with stages
in 9 minutes and 19 seconds
...@@ -26,14 +26,7 @@ export default async (fetherAppWindow, event, action, ...args) => { ...@@ -26,14 +26,7 @@ export default async (fetherAppWindow, event, action, ...args) => {
// Conversion to integer is required to pass as argument to setContentSize. // Conversion to integer is required to pass as argument to setContentSize.
// Reference: https://electronjs.org/docs/all#winsetcontentsizewidth-height-animate // Reference: https://electronjs.org/docs/all#winsetcontentsizewidth-height-animate
const newHeight = parseInt(args[0]); const newHeight = parseInt(args[0]);
const feedbackButtonHeight = 20; fetherAppWindow.setContentSize(width, Math.round(newHeight) + 2);
const resizeHeight = newHeight + 2;
const height =
process.platform === 'win32' && fetherAppWindow.isMenuBarVisible()
? resizeHeight + feedbackButtonHeight
: resizeHeight;
fetherAppWindow.setContentSize(width, height);
break; break;
} }
case 'check-clock-sync': { case 'check-clock-sync': {
......
...@@ -30,10 +30,7 @@ function loadTray (fetherApp) { ...@@ -30,10 +30,7 @@ function loadTray (fetherApp) {
tray.on('double-click', () => onTrayClick(fetherApp)); tray.on('double-click', () => onTrayClick(fetherApp));
// Right click event handler does not work on Windows as intended // Right click event handler does not work on Windows as intended
tray.on('right-click', () => { tray.on('right-click', () => {
if (process.platform === 'win32') { pino.info('Detected right click on Windows');
pino.info('Detected right click on Windows');
showTrayBalloon(fetherApp);
}
}); });
tray.setToolTip(options.tooltip); tray.setToolTip(options.tooltip);
tray.setHighlightMode('never'); tray.setHighlightMode('never');
......
...@@ -8,13 +8,7 @@ import Pino from '../utils/pino'; ...@@ -8,13 +8,7 @@ import Pino from '../utils/pino';
const pino = Pino(); const pino = Pino();
function setupWin32Listeners (fetherApp) { function setupWin32Listeners (fetherApp) {
const { const { onWindowClose, processSaveWinPosition, win } = fetherApp;
moveWindowUp,
onWindowClose,
processSaveWinPosition,
showTrayBalloon,
win
} = fetherApp;
if (process.platform === 'win32') { if (process.platform === 'win32') {
/** /**
...@@ -52,7 +46,6 @@ function setupWin32Listeners (fetherApp) { ...@@ -52,7 +46,6 @@ function setupWin32Listeners (fetherApp) {
} else if (wParam.readUInt32LE(0) === 0xf030) { } else if (wParam.readUInt32LE(0) === 0xf030) {
// SC_MAXIMIZE // SC_MAXIMIZE
eventName = 'maximize'; eventName = 'maximize';
showTrayBalloon(fetherApp);
} else if (wParam.readUInt32LE(0) === 0xf020) { } else if (wParam.readUInt32LE(0) === 0xf020) {
// SC_MINIMIZE // SC_MINIMIZE
eventName = 'minimize'; eventName = 'minimize';
...@@ -60,7 +53,6 @@ function setupWin32Listeners (fetherApp) { ...@@ -60,7 +53,6 @@ function setupWin32Listeners (fetherApp) {
} else if (wParam.readUInt32LE(0) === 0xf120) { } else if (wParam.readUInt32LE(0) === 0xf120) {
// SC_RESTORE // SC_RESTORE
eventName = 'restored'; eventName = 'restored';
showTrayBalloon(fetherApp);
} }
if (eventName !== null) { if (eventName !== null) {
...@@ -74,17 +66,7 @@ function setupWin32Listeners (fetherApp) { ...@@ -74,17 +66,7 @@ function setupWin32Listeners (fetherApp) {
* Detect event on Windows when Fether window was moved or resized * Detect event on Windows when Fether window was moved or resized
*/ */
win.hookWindowMessage(Number.parseInt('0x0232'), (wParam, lParam) => { win.hookWindowMessage(Number.parseInt('0x0232'), (wParam, lParam) => {
pino.info('Detected completion of move or resize event'); pino.info('Detected completion of moved or resize event');
// Move Fether window back up into view if it was a resize event
// that causes the bottom to be cropped
moveWindowUp(fetherApp);
// Try again after a delay incase Fether window resize occurs
// x seconds after navigating to a new page.
setTimeout(() => {
moveWindowUp(fetherApp);
}, 5000);
// Save Fether window position to Electron settings // Save Fether window position to Electron settings
processSaveWinPosition(fetherApp); processSaveWinPosition(fetherApp);
......
...@@ -11,12 +11,7 @@ import Pino from '../utils/pino'; ...@@ -11,12 +11,7 @@ import Pino from '../utils/pino';
const pino = Pino(); const pino = Pino();
function setupWinListeners (fetherApp) { function setupWinListeners (fetherApp) {
const { const { onWindowClose, processSaveWinPosition, win } = fetherApp;
moveWindowUp,
onWindowClose,
processSaveWinPosition,
win
} = fetherApp;
// Open external links in browser // Open external links in browser
win.webContents.on('new-window', (event, url) => { win.webContents.on('new-window', (event, url) => {
...@@ -24,7 +19,7 @@ function setupWinListeners (fetherApp) { ...@@ -24,7 +19,7 @@ function setupWinListeners (fetherApp) {
electron.shell.openExternal(url); electron.shell.openExternal(url);
}); });
// Linux (unchecked on others) // Windows and Linux (unchecked on others)
win.on('move', () => { win.on('move', () => {
/** /**
* On Linux using this with debouncing is the closest equivalent * On Linux using this with debouncing is the closest equivalent
...@@ -49,17 +44,12 @@ function setupWinListeners (fetherApp) { ...@@ -49,17 +44,12 @@ function setupWinListeners (fetherApp) {
* On Linux the closest equivalent to achieving 'moved' is debouncing * On Linux the closest equivalent to achieving 'moved' is debouncing
* on the 'move' event. It also works in 'close' even when app crashes * on the 'move' event. It also works in 'close' even when app crashes
*/ */
processSaveWinPosition(fetherApp); pino.info('Detected moved event');
}); });
// macOS and Linux (not Windows) // macOS and Linux and Windows
win.on('resize', () => { win.on('resize', () => {
pino.info('Detected resize event'); pino.info('Detected resize event');
moveWindowUp(fetherApp);
setTimeout(() => {
moveWindowUp(fetherApp);
}, 5000);
}); });
win.on('blur', () => { win.on('blur', () => {
......
...@@ -16,6 +16,8 @@ function showWindow (fetherApp, trayPos) { ...@@ -16,6 +16,8 @@ function showWindow (fetherApp, trayPos) {
calculateWinPosition, calculateWinPosition,
createWindow, createWindow,
fixWinPosition, fixWinPosition,
moveWindowUp,
processSaveWinPosition,
setupWinListeners, setupWinListeners,
setupWin32Listeners, setupWin32Listeners,
win win
...@@ -84,6 +86,13 @@ function showWindow (fetherApp, trayPos) { ...@@ -84,6 +86,13 @@ function showWindow (fetherApp, trayPos) {
fetherApp.hasSetupWinListeners = true; fetherApp.hasSetupWinListeners = true;
} }
moveWindowUp(fetherApp);
setTimeout(() => {
moveWindowUp(fetherApp);
}, 5000);
processSaveWinPosition(fetherApp);
fetherApp.emit('after-show-window'); fetherApp.emit('after-show-window');
} }
......
...@@ -40,8 +40,6 @@ if (process.platform === 'win32') { ...@@ -40,8 +40,6 @@ if (process.platform === 'win32') {
); );
} }
const shouldUseFrame = process.platform === 'win32';
const windowPosition = const windowPosition =
process.platform === 'win32' ? 'trayBottomCenter' : 'trayCenter'; process.platform === 'win32' ? 'trayBottomCenter' : 'trayCenter';
...@@ -69,7 +67,9 @@ const DEFAULT_OPTIONS = { ...@@ -69,7 +67,9 @@ const DEFAULT_OPTIONS = {
}; };
const TASKBAR_OPTIONS = { const TASKBAR_OPTIONS = {
frame: shouldUseFrame, // Do not use frame but context menu required on non-macOS.
// Without frame it causes window height to shrink upon show/hide
frame: false,
height: 464, height: 464,
// On Linux the user must click the tray icon and then click the tooltip // On Linux the user must click the tray icon and then click the tooltip
// to toggle the Fether window open/close // to toggle the Fether window open/close
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment