Skip to content

Commit 7b9ae01

Browse files
authored
Merge pull request element-hq#4183 from vector-im/t3chguy/electron_logo_windows_weirdness
to make the windows volume mixer not explode as it can't resize icons.
2 parents 1bc3002 + 1e5a742 commit 7b9ae01

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎electron_app/package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
"description": "A feature-rich client for Matrix.org",
77
"author": "Vector Creations Ltd.",
88
"dependencies": {
9-
"electron-window-state": "^4.1.0",
109
"auto-launch": "^5.0.1",
11-
"minimist": "^1.2.0"
10+
"electron-window-state": "^4.1.0",
11+
"minimist": "^1.2.0",
12+
"png-to-ico": "^1.0.2"
1213
}
1314
}

‎electron_app/src/tray.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ limitations under the License.
1616
*/
1717

1818
const {app, Tray, Menu, nativeImage} = require('electron');
19+
const pngToIco = require('png-to-ico');
20+
const path = require('path');
21+
const fs = require('fs');
1922

2023
let trayIcon = null;
2124

@@ -57,7 +60,7 @@ exports.create = function(win, config) {
5760
trayIcon.on('click', toggleWin);
5861

5962
let lastFavicon = null;
60-
win.webContents.on('page-favicon-updated', function(ev, favicons) {
63+
win.webContents.on('page-favicon-updated', async function(ev, favicons) {
6164
let newFavicon = config.icon_path;
6265
if (favicons && favicons.length > 0 && favicons[0].startsWith('data:')) {
6366
newFavicon = favicons[0];
@@ -70,6 +73,15 @@ exports.create = function(win, config) {
7073
// if its not default we have to construct into nativeImage
7174
if (newFavicon !== config.icon_path) {
7275
newFavicon = nativeImage.createFromDataURL(favicons[0]);
76+
77+
if (process.platform === 'win32') {
78+
try {
79+
const icoPath = path.join(app.getPath('temp'), 'win32_riot_icon.ico')
80+
const icoBuf = await pngToIco(newFavicon.toPNG());
81+
fs.writeFileSync(icoPath, icoBuf);
82+
newFavicon = icoPath;
83+
} catch (e) {console.error(e);}
84+
}
7385
}
7486

7587
trayIcon.setImage(newFavicon);

0 commit comments

Comments
 (0)