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

Implement large notification icon support for windows #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ogzhnsbs
Copy link

@ogzhnsbs ogzhnsbs commented Jan 25, 2021

On Windows 10, toast notification icon seems very small.

before

We can force it to show large icon by setting dwInfoFlags parameter to NIIF_ICON_MASK for NOTIFYICONDATA.

But this change that is not enough to get good result. We need to change LoadImage function cx,cy parameters to load the icon image with like 128x128 pixels. Otherwise it seems blurry.

After changes, toast notification icon seems as it's supposed to be.

after

Copy link
Owner

@moses-palmer moses-palmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!

I have added a few comments. My main issue with this feature is the class-wide configuration of large notification icons.

Is the issue you are trying to resolve---small notification icons---mainly an issue on HiDPI monitors, or are notifications scaled appropriately in that case?

@@ -66,6 +66,10 @@ class Icon(object):
#: notification.
HAS_NOTIFICATION = True

#: Whether this particular implementation forces displaying a
#: large notification icon
FORCE_LARGE_NOTIFICATION_ICON = False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These class-level constants have previously served as an indication that the backend supports a particular feature whereas this new field serves as application-wide configuration.

I understand why you have implemented it this way, but I think a more suitable approach would be to specify this with a constructor argument, but there is currently no way to pass a constructor argument to one implementation only. What do you think of a backend specific options system like this?

Copy link
Author

@ogzhnsbs ogzhnsbs Jan 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we set NIIF_ICON_MASK flag to dwInfoFlags parameter, toast notification adds a text that is the file description of the executable. In our case it is python.exe. It's not a problem for me because I will create an executable via pyinstaller and set a version file for my application. For other library users may not want to see ugly pyhon text.

0,
0,
128 if Icon.FORCE_LARGE_NOTIFICATION_ICON else 0,
128 if Icon.FORCE_LARGE_NOTIFICATION_ICON else 0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason you would not always want to do this? Are there cases where this causes regressions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My screen dpi value is 240 (scaled 250%). I tested it for different dpi. But the result was similar for all. I setted it 128, because my screen resolution 4k and 64x64 is stil a bit blurry. I calculated icon size for the current dpi (96 -> 32x32, 240 -> 80x80) but the blur did not changed. I also tested my code with 1080p resolution (scaled 100%), no difference for 128x128 or default icon size.

Comparison:

image

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

Successfully merging this pull request may close these issues.

2 participants