Implement MPRIS Raise method to allow showing the window (#1845)
* add functionality to raise window on mpris method call * since electron tray doesn't support double click on linux, open on single click there
This commit is contained in:
parent
b1d0f698a1
commit
e814b13b22
2 changed files with 15 additions and 1 deletions
|
@ -281,7 +281,7 @@ export class AppEvents {
|
||||||
this.tray.setToolTip(app.getName());
|
this.tray.setToolTip(app.getName());
|
||||||
this.setTray(false);
|
this.setTray(false);
|
||||||
|
|
||||||
this.tray.on("double-click", () => {
|
this.tray.on("double-click", () => { // supports windows and mac only
|
||||||
if (utils.getWindow()) {
|
if (utils.getWindow()) {
|
||||||
if (utils.getWindow().isVisible()) {
|
if (utils.getWindow().isVisible()) {
|
||||||
utils.getWindow().focus();
|
utils.getWindow().focus();
|
||||||
|
@ -291,6 +291,16 @@ export class AppEvents {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.tray.on("click", () => {
|
||||||
|
if (utils.getWindow() && process.platform === "linux") { // use single click to open when double doesn't work
|
||||||
|
if (utils.getWindow().isVisible()) {
|
||||||
|
utils.getWindow().focus();
|
||||||
|
} else {
|
||||||
|
utils.getWindow().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
utils.getWindow().on("show", () => {
|
utils.getWindow().on("show", () => {
|
||||||
this.setTray(true);
|
this.setTray(true);
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,6 +73,10 @@ export default class mpris {
|
||||||
player.on("volume", (volume: string) => {
|
player.on("volume", (volume: string) => {
|
||||||
renderer.executeJavaScript(`app.mk.volume = ${parseFloat(volume)}`);
|
renderer.executeJavaScript(`app.mk.volume = ${parseFloat(volume)}`);
|
||||||
});
|
});
|
||||||
|
player.on("raise", () => {
|
||||||
|
mpris.utils.getWindow().show();
|
||||||
|
mpris.utils.getWindow().focus();
|
||||||
|
});
|
||||||
|
|
||||||
mpris.utils.getIPCMain().on("mpris:playbackTimeDidChange", (event: any, time: number) => {
|
mpris.utils.getIPCMain().on("mpris:playbackTimeDidChange", (event: any, time: number) => {
|
||||||
player.getPosition = () => time;
|
player.getPosition = () => time;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue