Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[desktop] Fix drag-n-drop on mac, fix #2850
- Loading branch information
Showing
7 changed files
with
132 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @flow | ||
|
||
/** | ||
* This file provides the functionality used by DesktopTray on mac | ||
*/ | ||
|
||
import type {NativeImage} from "electron" | ||
import {app, Menu, MenuItem, Tray} from "electron" | ||
import type {WindowManager} from "../DesktopWindowManager" | ||
import os from 'os' | ||
import {getResourcePath} from "../resources" | ||
import type {PlatformTray} from "./DesktopTray" | ||
|
||
export class MacTray implements PlatformTray { | ||
needsWindowListInMenu(): boolean { | ||
//MacOs Catalina started showing the window list on its own | ||
return Number(os.release().slice(0, 2)) < 19 | ||
} | ||
|
||
attachMenuToTray(m: Menu, tray: ?Tray): void { | ||
app.dock.setMenu(m) | ||
} | ||
|
||
getPlatformMenuItems(): Array<MenuItem> { | ||
return [] | ||
} | ||
|
||
getTray(wm: WindowManager, icon: NativeImage): ?Tray { | ||
if (!app.dock.isVisible()) { | ||
app.dock.show() | ||
} | ||
return null | ||
} | ||
|
||
setBadge() { | ||
app.dock.bounce() | ||
app.dock.setBadge("●") | ||
} | ||
|
||
clearBadge() { | ||
app.dock.setBadge("") | ||
} | ||
|
||
getAppIconPathFromName(iconName: string): string { | ||
return getResourcePath(`icons/${iconName}.icns`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @flow | ||
import type {NativeImage} from 'electron' | ||
import {app, Menu, MenuItem, Tray} from "electron" | ||
import type {WindowManager} from "../DesktopWindowManager" | ||
import {lang} from "../../misc/LanguageViewModel" | ||
import type {PlatformTray} from './DesktopTray' | ||
import path from "path" | ||
import {getResourcePath} from "../resources" | ||
|
||
/** | ||
* This file provides the functionality used by DesktopTray on windows & linux. | ||
*/ | ||
|
||
export class NonMacTray implements PlatformTray { | ||
attachMenuToTray(m: Menu, tray: ?Tray): void { | ||
if (tray) tray.setContextMenu(m) | ||
} | ||
|
||
needsWindowListInMenu(): boolean { | ||
return true | ||
} | ||
|
||
getPlatformMenuItems(): Array<MenuItem> { | ||
return [ | ||
new MenuItem({type: 'separator'}), | ||
new MenuItem({ | ||
label: lang.get("quit_action"), | ||
accelerator: "CmdOrCtrl+Q", | ||
click: app.quit | ||
}) | ||
] | ||
} | ||
|
||
getTray(wm: WindowManager, icon: NativeImage): Tray { | ||
const tray = new Tray(icon) | ||
/* | ||
setting the context menu is necessary to prevent electron from segfaulting shortly after creating the tray. | ||
workaround from: https://github.com/electron/electron/issues/22137#issuecomment-586105622 | ||
issue: https://github.com/electron/electron/issues/22215 | ||
*/ | ||
tray.setContextMenu(null) | ||
tray.on('click', ev => { | ||
wm.getLastFocused(true) | ||
}) | ||
return tray | ||
} | ||
|
||
|
||
|
||
setBadge() {} | ||
|
||
clearBadge() {} | ||
|
||
getAppIconPathFromName(iconName: string): string { | ||
return getResourcePath(`icons/${iconName}`) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.