MM-60233 - fix issue in kde of focus after minimize (#3157)
* MM-60233 - fix issue in kde of focus after minimize * fix and add unit tests * enhance condition logic * place the iskde in utils to be reusable, adjust tests * move logic to prevent potential problems with upcoming version * adjust unit test to the new logic
This commit is contained in:
@@ -130,3 +130,9 @@ export function openScreensharePermissionsSettingsMacOS() {
|
|||||||
return exec('open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"',
|
return exec('open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"',
|
||||||
{timeout: 1000});
|
{timeout: 1000});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isKDE() {
|
||||||
|
return (process.env.XDG_CURRENT_DESKTOP ?? '').toUpperCase() === 'KDE' ||
|
||||||
|
(process.env.DESKTOP_SESSION ?? '').toLowerCase() === 'plasma' ||
|
||||||
|
(process.env.KDE_FULL_SESSION ?? '').toLowerCase() === 'true';
|
||||||
|
}
|
||||||
|
@@ -68,6 +68,7 @@ jest.mock('../contextMenu', () => jest.fn());
|
|||||||
jest.mock('../utils', () => ({
|
jest.mock('../utils', () => ({
|
||||||
isInsideRectangle: jest.fn(),
|
isInsideRectangle: jest.fn(),
|
||||||
getLocalPreload: jest.fn(),
|
getLocalPreload: jest.fn(),
|
||||||
|
isKDE: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock('main/i18nManager', () => ({
|
jest.mock('main/i18nManager', () => ({
|
||||||
@@ -98,6 +99,7 @@ describe('main/windows/mainWindow', () => {
|
|||||||
isMaximized: jest.fn(),
|
isMaximized: jest.fn(),
|
||||||
isFullScreen: jest.fn(),
|
isFullScreen: jest.fn(),
|
||||||
getBounds: jest.fn(),
|
getBounds: jest.fn(),
|
||||||
|
isMinimized: jest.fn().mockReturnValue(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -515,6 +517,9 @@ describe('main/windows/mainWindow', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add override shortcuts for the top menu on Linux to stop it showing up', () => {
|
it('should add override shortcuts for the top menu on Linux to stop it showing up', () => {
|
||||||
|
const {isKDE} = require('../utils');
|
||||||
|
isKDE.mockReturnValue(false);
|
||||||
|
|
||||||
const originalPlatform = process.platform;
|
const originalPlatform = process.platform;
|
||||||
Object.defineProperty(process, 'platform', {
|
Object.defineProperty(process, 'platform', {
|
||||||
value: 'linux',
|
value: 'linux',
|
||||||
@@ -536,6 +541,34 @@ describe('main/windows/mainWindow', () => {
|
|||||||
});
|
});
|
||||||
expect(globalShortcut.registerAll).toHaveBeenCalledWith(['Alt+F', 'Alt+E', 'Alt+V', 'Alt+H', 'Alt+W', 'Alt+P'], expect.any(Function));
|
expect(globalShortcut.registerAll).toHaveBeenCalledWith(['Alt+F', 'Alt+E', 'Alt+V', 'Alt+H', 'Alt+W', 'Alt+P'], expect.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should register global shortcuts even when window is minimized on KDE/KWin', () => {
|
||||||
|
const {isKDE} = require('../utils');
|
||||||
|
isKDE.mockReturnValue(true);
|
||||||
|
|
||||||
|
const originalPlatform = process.platform;
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: 'linux',
|
||||||
|
});
|
||||||
|
const window = {
|
||||||
|
...baseWindow,
|
||||||
|
isMinimized: jest.fn().mockReturnValue(true),
|
||||||
|
on: jest.fn().mockImplementation((event, cb) => {
|
||||||
|
if (event === 'focus') {
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
BrowserWindow.mockImplementation(() => window);
|
||||||
|
const mainWindow = new MainWindow();
|
||||||
|
mainWindow.getBounds = jest.fn();
|
||||||
|
mainWindow.init();
|
||||||
|
|
||||||
|
expect(globalShortcut.registerAll).toHaveBeenCalled();
|
||||||
|
Object.defineProperty(process, 'platform', {
|
||||||
|
value: originalPlatform,
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('show', () => {
|
describe('show', () => {
|
||||||
|
@@ -39,7 +39,7 @@ import performanceMonitor from 'main/performanceMonitor';
|
|||||||
import type {SavedWindowState} from 'types/mainWindow';
|
import type {SavedWindowState} from 'types/mainWindow';
|
||||||
|
|
||||||
import ContextMenu from '../contextMenu';
|
import ContextMenu from '../contextMenu';
|
||||||
import {getLocalPreload, isInsideRectangle} from '../utils';
|
import {getLocalPreload, isInsideRectangle, isKDE} from '../utils';
|
||||||
|
|
||||||
const log = new Logger('MainWindow');
|
const log = new Logger('MainWindow');
|
||||||
const ALT_MENU_KEYS = ['Alt+F', 'Alt+E', 'Alt+V', 'Alt+H', 'Alt+W', 'Alt+P'];
|
const ALT_MENU_KEYS = ['Alt+F', 'Alt+E', 'Alt+V', 'Alt+H', 'Alt+W', 'Alt+P'];
|
||||||
@@ -329,6 +329,12 @@ export class MainWindow extends EventEmitter {
|
|||||||
globalShortcut.registerAll(ALT_MENU_KEYS, () => {
|
globalShortcut.registerAll(ALT_MENU_KEYS, () => {
|
||||||
// do nothing because we want to supress the menu popping up
|
// do nothing because we want to supress the menu popping up
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// check if KDE + windows is minimized to prevent unwanted focus event
|
||||||
|
// that was causing an error not allowing minimization (MM-60233)
|
||||||
|
if ((!this.win || this.win.isMinimized()) && isKDE()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit(MAIN_WINDOW_RESIZED, this.getBounds());
|
this.emit(MAIN_WINDOW_RESIZED, this.getBounds());
|
||||||
|
Reference in New Issue
Block a user