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

Fix context menu issues on Ubuntu 23+ #1733

Merged
merged 4 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 25 additions & 2 deletions main/windows/systemTray.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import { app, screen, BrowserWindow, Menu, KeyboardEvent, Rectangle, Tray as ElectronTray } from 'electron'
// @ts-ignore
import getos from 'getos'
import path from 'path'
import { app, screen, BrowserWindow, Menu, KeyboardEvent, Rectangle, Tray as ElectronTray } from 'electron'

import { capitalize } from '../../resources/utils'

const isMacOS = process.platform === 'darwin'
let isUbuntu23OrGreater = false

if (process.platform === 'linux') {
try {
getos((error: Error, osInfo: any) => {
if (error) {
console.error('Could not determine Linux version', error)
} else {
if (osInfo.dist === 'Ubuntu' && osInfo.release) {
const majorVersion = parseInt(osInfo.release.split('.')[0], 10)
isUbuntu23OrGreater = majorVersion >= 23
}
}
})
} catch (error) {
console.error('Could not determine Linux version', error)
}
}

const delaySettingContextMenu = () => !isMacOS && !isUbuntu23OrGreater

export type SystemTrayEventHandlers = {
click: () => void
Expand Down Expand Up @@ -67,7 +90,7 @@ export class SystemTray {
if (switchScreen) {
this.electronTray?.setContextMenu(menu)
} else {
setTimeout(() => this.electronTray?.setContextMenu(menu), isMacOS ? 0 : 200)
setTimeout(() => this.electronTray?.setContextMenu(menu), delaySettingContextMenu() ? 200 : 0)
}
}

Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"extract-zip": "2.0.1",
"fs-extra": "11.1.0",
"get-pixels": "3.3.3",
"getos": "3.2.1",
"gridplus-sdk": "3.2.0",
"hdkey": "2.1.0",
"hotkeys-js": "3.10.1",
Expand Down
Loading