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

The program tray icon doesn't look too good - perhaps the users could pick their favorite? #151

Closed
unalignedcoder opened this issue Apr 29, 2023 · 7 comments

Comments

@unalignedcoder
Copy link

unalignedcoder commented Apr 29, 2023

This is definitely a minor issue but, at least on Windows, the tray icon in particular looks quite ugly.

image

A great improvement would be an option to give the user a choice on what program icon to use.

The program icon can be changed replacing messengerWindow.ico in the program's chrome folder, but this unfortunately doesn't take care of the tray icon...

@unalignedcoder unalignedcoder changed the title The program icon doesn't look good - perhaps the users should pick their favorite The program icon doesn't look good - perhaps the users could pick their favorite? Apr 29, 2023
@unalignedcoder unalignedcoder changed the title The program icon doesn't look good - perhaps the users could pick their favorite? The program icon doesn't look too good - perhaps the users could pick their favorite? Apr 29, 2023
@unalignedcoder unalignedcoder changed the title The program icon doesn't look too good - perhaps the users could pick their favorite? The program tray icon doesn't look too good - perhaps the users could pick their favorite? Apr 29, 2023
@Betterbird
Copy link
Owner

The tray icon isn't ideal, here seen with the Windows magnifier:
image
That's because (at least) Windows 10 still uses 16x16 icons, it's better in most Linux desktops.

You're right that changing C:\Program Files\Betterbird\chrome\icons\default\messengerWindow.ico changes the taskbar icon but not the systray icon. We'll check what the mechanism is and potentially improve it. Strangely the newmail icon isn't installed anywhere, yet it's displayed in the systray.

@Betterbird
Copy link
Owner

Betterbird commented May 10, 2023

We looked at this some more, and yes, it can be done if where change these calls to LoadIcon()
https://searchfox.org/comm-central/rev/cbd8afe916f94a039bb9cbbbd66f3a5fb98395be/mailnews/base/src/nsMessengerWinIntegration.cpp#362,381
which use static resources compiled into the program to using dynamic icons created with CreateIcon() similar to this code
https://searchfox.org/mozilla-central/rev/445a5ab684b73eb56d807d0f3b2fabcc85a7c3dd/widget/windows/SystemStatusBar.cpp#192-197


Just for the record, this is the first version of the comment which shows how we got to this result:

So the issue of changing the program icon isn't new, see Issue #83 and Issue #92. In we commented that the icon are actually in the executable and that you can manipulate them with something like Resource Hacker. Here's a screenshot using the tool:

image

Looks like the icons are defined as resources here:
https://searchfox.org/comm-central/rev/cbd8afe916f94a039bb9cbbbd66f3a5fb98395be/mail/app/splash.rc#19-20
and then accessed via IDI_APPLICATION or IDI_MAILBIFF using LoadIcon():
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadicona
The documentation states: hInstance: A handle to an instance of the module whose executable file contains the icon to be loaded.
Even the replacement function (https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea) has the same description of the parameter.

BTW, if you remove C:\Program Files\Betterbird\chrome\icons\default\messengerWindow.ico, the program defaults to the standard mail icon.

We were a bit surprised to learn from your report that the program icon in the taskbar can be changed by storing a different icon file under C:\Program Files\Betterbird\chrome\icons\default\messengerWindow.ico. According to this article you can use this Windows API SendMessage(hwnd, WM_SETICON, ICON_SMALL, hIcon); to change the taskbar icon, and it appears that such calls are used in the Mozilla platform code, see here:
https://searchfox.org/comm-central/search?q=SendMessage.*wm_seticon&path=&case=false&regexp=true
However, we still haven't tracked how the icon from the chrome directory is set there, but we can do that later. But that only sets the taskbar and not the systray.

Starting with this query https://www.google.com.au/search?q=How+to+change+the+icon+in+systray+using+windows+api (analog to the article quoted above), we got here:
https://stackoverflow.com/questions/4964630/system-tray-icon-in-c
and to this demo:
https://www.codeproject.com/Articles/74/Adding-Icons-to-the-System-Tray
We signed up to the site, downloaded the demo and found code inside using, surprise, surprise: LoadIcon() and LoadImage(), which we know refer to resources.

Further reading here https://learn.microsoft.com/en-us/windows/win32/menurc/using-icons, quote:
An application should implement custom icons as resources and should use the LoadIcon or LoadImage function, rather than create the icons at run-time.

That page also gives an example for creating icons on the fly, but is seems that quite a bit of Windows system programming would be needed to make this happen. The CreateIcon() call is used in the Mozilla platform code
https://searchfox.org/comm-central/search?q=createicon%28&path=&case=false&regexp=false
in the context of changing the taskbar icon dynamically.

Looks like it could be made to work by changing the LoadIcon() calls here
https://searchfox.org/comm-central/rev/cbd8afe916f94a039bb9cbbbd66f3a5fb98395be/mailnews/base/src/nsMessengerWinIntegration.cpp#362,381
to using dynamically created icons like here:
https://searchfox.org/mozilla-central/rev/445a5ab684b73eb56d807d0f3b2fabcc85a7c3dd/widget/windows/SystemStatusBar.cpp#192-197.

@Betterbird
Copy link
Owner

OK, this is done now. If you replace messengerWindow.ico and newmail.ico, they will be reflected in the systray:
image
The thing that looks like Saturn is an only SeaMonkey icon we used for testing (and the other one is OpenRBG unrelated to the work here). With the newmail.ico also changed to the TB Daily icon, it looks like this:
image

Test version here: https://www.betterbird.eu/downloads/WindowsInstaller/betterbird-102.11.0-bb35-latest-build.en-US.win64.installer.exe

FInal thought: Different icons were high on the wish list in our recent survey, so this gets us one step closer.

@Betterbird
Copy link
Owner

Had to rebuild everything due to a bug, so this is now already in the official version (and the latest build was deleted).

@Betterbird
Copy link
Owner

We've documented how to configure the icons on our expert tips page. The current (un)installer still removes the messengerWindow.ico file, but with the next version the icons the users stores into C:\Program Files\Betterbird\chrome\icons\default\ will be preserved.

@unalignedcoder
Copy link
Author

unalignedcoder commented May 12, 2023

It's great that we can now customize both those icons. If would be great it there also was an "unread" icon. Often I forget I have unread messages buried into some folder, but the newmail icon only shows up where there are new ones.

If you think about it, these icons should really be changed from the /chrome folder of the user profile... Doesn't seem possible, currently.

@Betterbird
Copy link
Owner

You can control this with pref mail.biff.use_new_count_in_badge, also exposed in the UI:
image

Set to false and it will track the unread messages. This is pretty useless for people who are subscribed on mailing lists and have thousands of unread messages. But give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants