[MM-49743] Remove screen change listeners due to electron's bug (#2506)
* Remove screen change listeners due to electron bug * Remove unused functions
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {app, ipcMain, screen, session} from 'electron';
|
import {app, ipcMain, session} from 'electron';
|
||||||
import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer';
|
import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer';
|
||||||
import isDev from 'electron-is-dev';
|
import isDev from 'electron-is-dev';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
@@ -119,8 +119,6 @@ export async function initialize() {
|
|||||||
app.whenReady(),
|
app.whenReady(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
initializeScreenEventListeners();
|
|
||||||
|
|
||||||
// no need to continue initializing if app is quitting
|
// no need to continue initializing if app is quitting
|
||||||
if (global.willAppQuit) {
|
if (global.willAppQuit) {
|
||||||
return;
|
return;
|
||||||
@@ -190,11 +188,6 @@ function initializeAppEventListeners() {
|
|||||||
app.on('will-finish-launching', handleAppWillFinishLaunching);
|
app.on('will-finish-launching', handleAppWillFinishLaunching);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeScreenEventListeners() {
|
|
||||||
screen.on('display-removed', WindowManager.displayRemoved);
|
|
||||||
screen.on('display-metrics-changed', WindowManager.displayMetricsChanged);
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeBeforeAppReady() {
|
function initializeBeforeAppReady() {
|
||||||
if (!Config.data) {
|
if (!Config.data) {
|
||||||
log.error('No config loaded');
|
log.error('No config loaded');
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
/* eslint-disable max-lines */
|
/* eslint-disable max-lines */
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent, IpcMainInvokeEvent, desktopCapturer, Display, screen} from 'electron';
|
import {app, BrowserWindow, nativeImage, systemPreferences, ipcMain, IpcMainEvent, IpcMainInvokeEvent, desktopCapturer} from 'electron';
|
||||||
import log from 'electron-log';
|
import log from 'electron-log';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -255,42 +255,6 @@ export class WindowManager {
|
|||||||
this.sendToRenderer(MAXIMIZE_CHANGE, false);
|
this.sendToRenderer(MAXIMIZE_CHANGE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
maximizeMainWindow = () => {
|
|
||||||
if (!(this.viewManager && this.mainWindow)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.mainWindow.maximize?.();
|
|
||||||
}
|
|
||||||
|
|
||||||
displayRemoved = (event: Event, oldDisplay: Display) => {
|
|
||||||
log.debug('WindowManager.displayRemoved', {oldDisplay});
|
|
||||||
|
|
||||||
if (!oldDisplay) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isActiveScreen(oldDisplay.id)) {
|
|
||||||
this.maximizeMainWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
displayMetricsChanged = (event: Event, display: Display, changedMetrics: string[]) => {
|
|
||||||
log.debug('WindowManager.displayMetricsChanged', {display, changedMetrics});
|
|
||||||
|
|
||||||
this.maximizeMainWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
isActiveScreen = (id: Display['id']): boolean => {
|
|
||||||
if (!(this.viewManager && this.mainWindow)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const mainWindowBounds = this.mainWindow.getBounds();
|
|
||||||
const currentDisplay = screen.getDisplayNearestPoint({x: mainWindowBounds.x, y: mainWindowBounds.y});
|
|
||||||
log.debug('WindowManager.isActiveScreen', {id, currentDisplay});
|
|
||||||
return currentDisplay.id === id;
|
|
||||||
}
|
|
||||||
|
|
||||||
isResizing = false;
|
isResizing = false;
|
||||||
|
|
||||||
handleWillResizeMainWindow = (event: Event, newBounds: Electron.Rectangle) => {
|
handleWillResizeMainWindow = (event: Event, newBounds: Electron.Rectangle) => {
|
||||||
|
Reference in New Issue
Block a user