Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MM-60233 - fix issue in kde of focus after minimize #3157

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/main/windows/mainWindow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ describe('main/windows/mainWindow', () => {
isMaximized: jest.fn(),
isFullScreen: jest.fn(),
getBounds: jest.fn(),
isMinimized: jest.fn().mockReturnValue(false),
};

beforeEach(() => {
Expand Down Expand Up @@ -533,6 +534,39 @@ describe('main/windows/mainWindow', () => {
});
expect(globalShortcut.registerAll).toHaveBeenCalledWith(['Alt+F', 'Alt+E', 'Alt+V', 'Alt+H', 'Alt+W', 'Alt+P'], expect.any(Function));
});

it('should not register global shortcuts when window is minimized on KDE/KWin', () => {
const originalPlatform = process.platform;
Object.defineProperty(process, 'platform', {
value: 'linux',
});
process.env.XDG_CURRENT_DESKTOP = 'KDE';
process.env.DESKTOP_SESSION = 'plasma';
process.env.KDE_FULL_SESSION = 'true';

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).not.toHaveBeenCalled();
Object.defineProperty(process, 'platform', {
value: originalPlatform,
});
delete process.env.XDG_CURRENT_DESKTOP;
delete process.env.DESKTOP_SESSION;
delete process.env.KDE_FULL_SESSION;
});
});

describe('show', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/main/windows/mainWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ export class MainWindow extends EventEmitter {
private onFocus = () => {
// Only add shortcuts when window is in focus
if (process.platform === 'linux') {
const isKDE = (process.env.XDG_CURRENT_DESKTOP ?? '').toUpperCase() === 'KDE' ||
pvev marked this conversation as resolved.
Show resolved Hide resolved
(process.env.DESKTOP_SESSION ?? '').toLowerCase() === 'plasma' ||
(process.env.KDE_FULL_SESSION ?? '').toLowerCase() === 'true';
if ((!this.win || this.win.isMinimized()) && isKDE) {
return;
}
globalShortcut.registerAll(ALT_MENU_KEYS, () => {
pvev marked this conversation as resolved.
Show resolved Hide resolved
// do nothing because we want to supress the menu popping up
});
Expand Down
Loading