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

Merge branch 'master' into luke-421-linux-dock-icon

parents 334aa181 a11fa20b
Pipeline #44435 canceled with stage
......@@ -26,14 +26,7 @@ export default async (fetherAppWindow, event, action, ...args) => {
// Conversion to integer is required to pass as argument to setContentSize.
// Reference: https://electronjs.org/docs/all#winsetcontentsizewidth-height-animate
const newHeight = parseInt(args[0]);
const feedbackButtonHeight = 20;
const resizeHeight = newHeight + 2;
const height =
process.platform === 'win32' && fetherAppWindow.isMenuBarVisible()
? resizeHeight + feedbackButtonHeight
: resizeHeight;
fetherAppWindow.setContentSize(width, height);
fetherAppWindow.setContentSize(width, Math.round(newHeight) + 2);
break;
}
case 'check-clock-sync': {
......
......@@ -30,10 +30,7 @@ function loadTray (fetherApp) {
tray.on('double-click', () => onTrayClick(fetherApp));
// Right click event handler does not work on Windows as intended
tray.on('right-click', () => {
if (process.platform === 'win32') {
pino.info('Detected right click on Windows');
showTrayBalloon(fetherApp);
}
});
tray.setToolTip(options.tooltip);
tray.setHighlightMode('never');
......
......@@ -8,13 +8,7 @@ import Pino from '../utils/pino';
const pino = Pino();
function setupWin32Listeners (fetherApp) {
const {
moveWindowUp,
onWindowClose,
processSaveWinPosition,
showTrayBalloon,
win
} = fetherApp;
const { onWindowClose, processSaveWinPosition, win } = fetherApp;
if (process.platform === 'win32') {
/**
......@@ -52,7 +46,6 @@ function setupWin32Listeners (fetherApp) {
} else if (wParam.readUInt32LE(0) === 0xf030) {
// SC_MAXIMIZE
eventName = 'maximize';
showTrayBalloon(fetherApp);
} else if (wParam.readUInt32LE(0) === 0xf020) {
// SC_MINIMIZE
eventName = 'minimize';
......@@ -60,7 +53,6 @@ function setupWin32Listeners (fetherApp) {
} else if (wParam.readUInt32LE(0) === 0xf120) {
// SC_RESTORE
eventName = 'restored';
showTrayBalloon(fetherApp);
}
if (eventName !== null) {
......@@ -74,17 +66,7 @@ function setupWin32Listeners (fetherApp) {
* Detect event on Windows when Fether window was moved or resized
*/
win.hookWindowMessage(Number.parseInt('0x0232'), (wParam, lParam) => {
pino.info('Detected completion of move 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);
pino.info('Detected completion of moved or resize event');
// Save Fether window position to Electron settings
processSaveWinPosition(fetherApp);
......
......@@ -11,12 +11,7 @@ import Pino from '../utils/pino';
const pino = Pino();
function setupWinListeners (fetherApp) {
const {
moveWindowUp,
onWindowClose,
processSaveWinPosition,
win
} = fetherApp;
const { onWindowClose, processSaveWinPosition, win } = fetherApp;
// Open external links in browser
win.webContents.on('new-window', (event, url) => {
......@@ -24,7 +19,7 @@ function setupWinListeners (fetherApp) {
electron.shell.openExternal(url);
});
// Linux (unchecked on others)
// Windows and Linux (unchecked on others)
win.on('move', () => {
/**
* On Linux using this with debouncing is the closest equivalent
......@@ -49,17 +44,12 @@ function setupWinListeners (fetherApp) {
* On Linux the closest equivalent to achieving 'moved' is debouncing
* 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', () => {
pino.info('Detected resize event');
moveWindowUp(fetherApp);
setTimeout(() => {
moveWindowUp(fetherApp);
}, 5000);
});
win.on('blur', () => {
......
......@@ -16,6 +16,8 @@ function showWindow (fetherApp, trayPos) {
calculateWinPosition,
createWindow,
fixWinPosition,
moveWindowUp,
processSaveWinPosition,
setupWinListeners,
setupWin32Listeners,
win
......@@ -84,6 +86,13 @@ function showWindow (fetherApp, trayPos) {
fetherApp.hasSetupWinListeners = true;
}
moveWindowUp(fetherApp);
setTimeout(() => {
moveWindowUp(fetherApp);
}, 5000);
processSaveWinPosition(fetherApp);
fetherApp.emit('after-show-window');
}
......
......@@ -40,8 +40,6 @@ if (process.platform === 'win32') {
);
}
const shouldUseFrame = process.platform === 'win32';
const windowPosition =
process.platform === 'win32' ? 'trayBottomCenter' : 'trayCenter';
......@@ -69,7 +67,9 @@ const DEFAULT_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,
// On Linux the user must click the tray icon and then click the tooltip
// 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