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

High DPI screen with non-high DPI resolution causes enlarged application #2815

Closed
affinityv opened this issue Mar 20, 2019 · 68 comments
Closed
Milestone

Comments

@affinityv
Copy link

affinityv commented Mar 20, 2019

Expected Behavior

Easily readable text on FHD screen, not enlarged text on HiDPI screen

Current Behavior

HiDPI screen is readable and okay, but I normally move the database window to my FHD screen, now the FHD screen has tiny text and it is hard to read.

Possible Solution

Allow alternative display settings for screens with different DPI profiles/settings?

Allow turning off of HiDPI settings when database window is on non HiDPI screen (even if the other screen is HiDPI).

Automatically adjust HiDPI setting depending on the screen that the window is open on (or moved to) to suit.

Steps to Reproduce

Need two screens, one with very high resolution and the other with FHD or lower.
Open app, move displayed window between screens, see the differences, difficulty in using the lesser resolution screen.

Context

Can't easily use the FHD screen for my database now, it's too difficult to read.

Debug Info

KeePassXC - Version 2.4.0
Revision: c51752d
Distribution: AppImage

Libraries:

  • Qt 5.10.1
  • libgcrypt 1.8.1

Operating system: Devuan GNU/Linux ascii
CPU architecture: x86_64
Kernel: linux 4.9.0-6-amd64

Enabled extensions:

  • Auto-Type
  • Browser Integration
  • SSH Agent
  • KeeShare (only unsigned sharing)
  • YubiKey
@affinityv affinityv added the bug label Mar 20, 2019
@stucki
Copy link

stucki commented Mar 22, 2019

Duplicate of #2808?

@affinityv
Copy link
Author

I think it is different, but related to the DPI changes. We need DPI to be relevant to the display that the application's window is being displayed on. Or be able to turn on or off the special DPI settings as a preference if it can't be done automatically and dynamically when you move the window from screen to screen.

@dok18
Copy link

dok18 commented Mar 22, 2019

I just upgraded to 2.4.0 from 2.3.4 ... GUI is basicly not useable. I have FHD screen. Everything was ok until this upgrade. UI is not huge but terribly small. Ubuntu 18.04.

Dropdown menus open somewhere on the screen in correct size, but whole window has basically totally wrong DPI.

Any ideas how to fix this?

Thanks

@dok18
Copy link

dok18 commented Mar 22, 2019

Bildschirmfoto_2019-03-22_11-41-26

@dok18
Copy link

dok18 commented Mar 22, 2019

This screenshot shows the current situation

@dok18
Copy link

dok18 commented Mar 22, 2019

Update: switching back to 2.3.4 did not help, GUI is still terribly small.

But following is working with 2.3.4 and it fixes everything:
SCALE_FACTOR=1 QT_AUTO_SCREEN_SCALE_FACTOR=0.8 ./KeePassXC-2.3.4-x86_64.AppImage

but it does not work for 2.4.0.

@droidmonkey
Copy link
Member

QT_AUTO_SCREEN_SCALE_FACTOR is a boolean 1 or 0 variable. @affinityv this is what you want to support different DPI per monitor. QT made this opt-in unfortunately, you have to setup your environment on Linux.

@affinityv
Copy link
Author

QT_AUTO_SCREEN_SCALE_FACTOR is a boolean 1 or 0 variable. @affinityv this is what you want to support different DPI per monitor. QT made this opt-in unfortunately, you have to setup your environment on Linux.

Okay, thanks that helps.

This link seems to help with more information:
https://www.enpass.io/support/enpass-looks-too-small-or-big-on-my-display-how-can-i-fix-it/

And these are the entries I added to my .profile:
export QT_AUTO_SCREEN_SCALE_FACTOR=0
export QT_SCREEN_SCALE_FACTORS='1.5;1'

So, you are effectively telling QT to NOT scale automatically and you are setting the scaling for each screen as above. Then dragging the application window between monitors is good for both of my screens.

That works nicely, thanks again.

@droidmonkey
Copy link
Member

Great, glad that works

@affinityv
Copy link
Author

Other info that might help others is here:
https://doc.qt.io/qt-5/highdpi.html

@phoerious
Copy link
Member

This should totally work without the need for setting environment variables. Windows is smart enough for it, but apparently X fails us again and yet again. But I guess that just happens if you cling to 30-year old software and refuse to adopt something more modern that actually works.

@phoerious phoerious mentioned this issue Mar 31, 2019
@lespea
Copy link

lespea commented Apr 5, 2019

I have this same problem in Windows. I'm using different scaling values on the monitors which I assume is causing the issue. Setting the env variables helps.

@stucki
Copy link

stucki commented Apr 11, 2019

@droidmonkey Why did you close the issue? Is there a fix for it?

@stucki
Copy link

stucki commented Apr 11, 2019

I see that there were lots of duplicates to this issue: #434 #2808 #2815 #2981
Not sure which one to reopen, but there should be one.

IMO the issue is not solved. Prior to KeePassXC 2.4.0, the font size was ok and no change was needed. After 2.4.0 it seems like a environment variable needs to be set for having a normal font size.

(Besides this, the problem does not only affect the AppImage. It also happens on my Ubuntu 18.04 using the official snap package. Unfortunately, even the workaround mentioned above does not help here...)

@droidmonkey
Copy link
Member

This is not an issue with KeePassXC. This is a Qt issue. We added support for High DPI in 2.4.0, see my comment in the other thread: #2808 (comment)

@ledermueller
Copy link

Am I wrong or does the High DPI support broke other systems? I see issues with Windows and Linux in all those threads. Seems this feature is only working correctly on Apple OS's.

So the suggestion is that all affected people should adjust the Qt environment variables to fix something that wasn't an issue before High DPI support was activated?

I'm not really into Qt development and I don't know what are the benefits of the High DPI support nor do I know how to fix it. But this solution feels bad, IMHO.

@stucki
Copy link

stucki commented Apr 15, 2019

@droidmonkey The point is that you changed something in 2.4.0 which breaks many systems now while it worked fine before. I think you can't blame Qt for this.

@droidmonkey
Copy link
Member

droidmonkey commented Apr 15, 2019

@stucki, the change made was to enable Qt's support for hidpi. So yes, I can blame them. It was literally one line of code. It would already, and is documented, that Qt is not properly detecting a hidpi monitor / setup which necessitates the environment variables.

We can just as easily disable support for hidpi and receive complaints from those users that want support for it.

@stucki
Copy link

stucki commented Apr 15, 2019

Whoever is to blame... Thing is, the workaround mentioned above didn't work for me while using the official snap package. Instead, I had to edit the file /var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop which contains the command that is executed for running keepassxc:

--- keepassxc_keepassxc.desktop
+++ keepassxc_keepassxc.desktop
@@ -7,7 +7,7 @@
 GenericName[fr]=Gestionnaire de mot de passe
 GenericName[ru]=менеджер паролей
 Comment=Community-driven port of the Windows application “KeePass Password Safe”
-Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop /snap/bin/keepassxc %U
+Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop QT_AUTO_SCREEN_SCALE_FACTOR=0 QT_SCREEN_SCALE_FACTORS='1.5;1' /snap/bin/keepassxc %U
 Icon=/snap/keepassxc/267/usr/share/icons/hicolor/256x256/apps/keepassxc.png
 StartupWMClass=keepassxc
 StartupNotify=true

Also notice that I had to set QT_SCREEN_SCALE_FACTORS='1' in order to get human readable fonts back. However, it's finally working for me. :-)

@ledermueller
Copy link

@droidmonkey No offence, but I don't understand that decision.

I think if a feature of a framework isn't working correctly on all supported platforms it should not be activated or at least you/we should try to find a better solution/workaround instead of breaking the experience of other users.

I get that most of the people here are experienced enough to set some environment variables but what about all the other users that don't come here to check for issues regarding a huge interface? I'm not sure if they even bother searching for a solution if they encounter the huge UI issue.

@droidmonkey
Copy link
Member

We ran a 3 month beta period with the feature enabled and did not receive complaints. It's unfortunate but until you release to a wide audience some issues are not readily apparent. I am preparing a PR that will add a setting to disable HiDPI support so you dont have to setup the env vars. You must understand though that ANY Qt based application that enables HiDPI support will require you to setup your env vars. It is not unique to KeePassXC. Perhaps we are slightly unique in enabling the option in the first place.

@ledermueller
Copy link

Thanks for sharing more details on that issue and for providing a really superb cross-platform password manager 😃
A setting to enable/disable HiDPI sounds great 👍
Maybe consider to disable HiDPI per default depending on which scenario (huge UI, extremely small UI?) is more likely to put of off new users.

@droidmonkey droidmonkey changed the title Problems with high DPI screen with non-high DPI (2880x1800 and 1920x1080) High DPI screen with non-high DPI resolution causes enlarged application Apr 15, 2019
@eturk1
Copy link

eturk1 commented Jun 21, 2020

Scaled at 250%? It looks perfectly appropriate based on your settings. You are scaling your display way too much. Anything over 200% is actually making your display "smaller" than a non-4K display.

We already enable that Qt flag.

I didn't want to show all my logins so I used the settings page, so yes, I admit it's hard to tell how larger the text/icons are.

  1. Notice that the text is larger than the text for the time/clock in tray & the browser text behind the window (to the right. Note too the size of the toolbar buttons compared to the program icons in tray. It that how KeePassXC was designed to look?
  2. When I set QT_ENABLE_HIGHDPI_SCALING=1 it corrects the scale. The icons & list shrink to a normal size matching browsers & other apps. Why would that be?

@droidmonkey
Copy link
Member

droidmonkey commented Jun 21, 2020

Check your eyes please, the text in KeePassXC is quite literally the same size as Google Chrome and your start menu:

image

I just moved the text next to the settings text and added a border, absolutely no other changes were made. The clock text is smaller on Windows then anything else.

@database64128
Copy link
Contributor

Check your eyes please, the text in KeePassXC is quite literally the same size as Google Chrome and your start menu:

Seriously, PLEASE find a HiDPI display and test KeePassXC on it. You won't know the pain unless you experience it yourself.

Scaled at 250%? It looks perfectly appropriate based on your settings. You are scaling your display way too much. Anything over 200% is actually making your display "smaller" than a non-4K display.

On my 15.6' laptop with a 4K display, 250% is the most appropriate scaling factor. And KeePassXC's UI looks WAY TOO LARGE on it.

@droidmonkey
Copy link
Member

droidmonkey commented Jun 22, 2020

I have a 4k display... 15.6" laptop.... Scaled to 175%

@database64128
Copy link
Contributor

database64128 commented Jun 22, 2020

I have a 4k display... 15.6" laptop.... Scaled to 175%

  1. Are you running Windows? This is a Windows-only Qt issue.
  2. 200% would be the lowest acceptable scaling factor. Anything below 200% would be way too small.
  3. Screenshot of KeePassXC with a 250% scaling factor on Windows.
    image
    As you can see, KeePassXC's interface is significantly larger than other applications.

@eturk1
Copy link

eturk1 commented Jun 22, 2020

More pics to better describe.
Here's before & after switching Win 10 from application scaling to system scaling "High DPI override" on my 28" 4K desktop.

Application: (window is 1K of screen to read many lines, huge tool icons relative to Word. Font much larger than menu fonts in Photoshop, Chrome, etc.)
image

System (Window nice small size as a simple tool showing same number in list. Fonts match all other app fonts)
image

@phoerious
Copy link
Member

phoerious commented Jun 23, 2020

Please try a 2.6 snapshot build. 2.5 will see no further updates and 2.6 has some font fixes.

@droidmonkey
Copy link
Member

droidmonkey commented Jun 23, 2020

@database64128 welcome to KeePassXC! I am a lead developer along with @phoerious. I am well versed in how KeePassXC runs on ALL platforms.

As for scaling... couple notes:

  • A scale factor of 200% means that High DPI aware applications multiply everything by a factor of 2. 12pt fonts become 24pt fonts (its based on font, but for sake of example). 2px features become 4px features.
  • In effect, a 4K display at 200% scaling would result in a UI that is the same size as a comparable 2K (FHD) display.
  • Using a scale factor > 200% actually results in an effectively SMALLER usable display area than a Full-HD display.
  • Using the Compatibility Override settings is not appropriate, and results in invalid results, since we are High DPI aware.

Using KeePassXC 2.6.0 with your comparison of the Task Manager results in the same font size (note our font is bolder):

175% Scale
image

250% Scale
image

@database64128
Copy link
Contributor

database64128 commented Jun 24, 2020

Please try a 2.6 snapshot build. 2.5 will see no further updates and 2.6 has some font fixes.

Tried 2.6.0-beta1 and it's the same. The layout and texts are still larger than how they should be.

First off, database64128 welcome to KeePassXC! I am a lead developer along with phoerious. Your downvotes are most appreciated. I am well versed in how KeePassXC runs on ALL platforms.

I'm aware that you and phoerious are the lead developers of this project. And I really do appreciate your hard work! 👍

That being said, I did and still do find some of your comments ignorant and arrogant, and a little offensive 😥, such as

Check your eyes please

Uh looks perfect to me

You are scaling your display way too much. Anything over 200% is actually making your display "smaller" than a non-4K display.

These are mostly opinion-based and not constructive comments.

Anyways, I have thought about this for a while. And I feel it doesn't really justify my downvotes. Downvoting opinions from the project maintainers is disrespectful and it really hurts feelings. Maintaining a project like this is not easy. So I'm taking back by downvotes. And I apologize for that. 🥺

Here's another comparison.

  1. Default scaling behavior. The interface is larger than expected. Window size 2404x1874.
    image

  2. Run with -platform windows:dpiawareness=0. The size of the interface is now normal. Window size 2004x1580.
    image

@droidmonkey
Copy link
Member

droidmonkey commented Jun 24, 2020

True, I'm a tad salty but this is a fun topic.

As for your experiment, the second image is very blurry (compared to the first). This is actually because your window is being rendered at 100% scale and Windows is "upscaling" it a bit so it looks "OK". In reality nothing is OK and the application is actually misbehaving. You can see this blurriness in eturk1 screenshot of the System scale compatibility override.

Basically what you want is a scale factor of 200%. I encourage you to give it a try.

@database64128
Copy link
Contributor

In reality nothing is OK and the application is actually misbehaving. You can see this blurriness in eturk1 screenshot of the System scale compatibility override.

Let's just ignore the blurriness and focus on the size of the UI elements. The UI elements in the 2nd picture are in their designed/expected size. In the first screenshot they are 1.2x of its expected size. That makes KeePassXC look out of line among other applications.

Basically what you want is a scale factor of 200%. I encourage you to give it a try.

I already tried it a few times. It makes a lot of stuff too small on my 15.6' laptop display. 😅

@droidmonkey
Copy link
Member

Granted I do think 2.6.0 has a little too much padding in various areas, but the font size and face is literally the same as the windows desktop. If you have suggestions on where the UI can be nipped and tucked I'd like to hear em.

@stucki
Copy link

stucki commented Jun 24, 2020

Looking at the screenshots above, I want to point out that the original issue that was reported here is about a much different font size, and it still exists!

Just look at this screenshot to see how my keepassxc looks right after being installed:

Bildschirmfoto von 2020-06-24 15-45-56

What I need to do after every new release is to patch the .desktop file as follows:

# see https://github.com/keepassxreboot/keepassxc/issues/2815
--- /var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop.orig	2019-11-12 15:21:54.200929705 +0100
+++ /var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop	2019-11-12 15:22:03.720670979 +0100
@@ -9,7 +9,7 @@
 GenericName[ru]=менеджер паролей
 Comment=Community-driven port of the Windows application “KeePass Password Safe”
 Comment[da]=Fællesskabsdrevet port af Windows-programmet “KeePass Password Safe”
-Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop /snap/bin/keepassxc %f
+Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/keepassxc_keepassxc.desktop QT_AUTO_SCREEN_SCALE_FACTOR=0 QT_SCREEN_SCALE_FACTORS='1' /snap/bin/keepassxc %f
 Icon=/snap/keepassxc/625/usr/share/icons/hicolor/256x256/apps/keepassxc.png
 StartupWMClass=keepassxc
 StartupNotify=true

With this patch applied, the font size looks ok to me:

Bildschirmfoto von 2020-06-24 15-51-02

@droidmonkey
Copy link
Member

That is actually a snap issue

@stucki
Copy link

stucki commented Jun 24, 2020

Thanks for clarifying! Should I create a PR for this change?

@droidmonkey
Copy link
Member

No, what I meant was its an issue with snaps in general, not something we can fix per say.

@stucki
Copy link

stucki commented Jun 25, 2020

Hmm but the fix solves the problem, no? Does it have any negative implications for other users? If not then it should be added in keepassxc nevertheless.

After all the issue here is that users who install keepassxc via snap will have a weird display size of keepassxc whereas other applications (even if installed via snap) work fine. I can solve the problem for myself using the patch above, but we should find a fix which works out of the box. Agree?

@phoerious
Copy link
Member

The correct values for these environment variables depend on your monitor configuration. We cannot simply hard-code something we know will break some people's setup only to fix that of some others.

@stucki
Copy link

stucki commented Jun 25, 2020

Hmm ok. However, doesn't look as if this is going to be fixed soon.

I did some research to see if the issue is reported anywhere else:

I still think that it may be useful to make the HiDPI feature configurable in the settings so that users have an easy way to fix this without having to edit files in /var/lib/snapd as root...

@droidmonkey
Copy link
Member

This change should help all you who want a "smaller" application: #4910

@droidmonkey droidmonkey added this to the v2.6.0 milestone Jun 28, 2020
@database64128
Copy link
Contributor

Just realized what the problem actually is: Qt defaults to rounding the scale factor up for .5 and above on desktop. That's why on my 250% Display the UI is 1.2x the size it should be: 2.5 * 1.2 == 3.

As per https://doc.qt.io/qt-5/highdpi.html:

The QT_SCALE_FACTOR_ROUNDING_POLICY environment variable and QGuiApplication::highDpiScaleFactorRoundingPolicy API, introduced in Qt 5.14, makes it possible to control if and how the device pixel ratio should be rounded to the nearest integer. This is relevant for configurations like Windows at 150% scale. Possible values are Round, Ceil, Floor, RoundPreferFloor, PassThrough. See the Qt::HighDpiScaleFactorRoundingPolicy enum documentation for a full description of the options.

So the workaround would be to set the QT_SCALE_FACTOR_ROUNDING_POLICY environment variable to PassThrough. The fix would be to call the QGuiApplication::setHighDpiScaleFactorRoundingPolicy function before creating the application object.

Without QT_SCALE_FACTOR_ROUNDING_POLICY set:
image
Window size 2404x1874. It's actually running in 300% scale factor due to the rounding policy.

With QT_SCALE_FACTOR_ROUNDING_POLICY set to PassThrough:
image
Window size 2004x1574. This is the correct size.

@droidmonkey
Copy link
Member

Wow didn't know they introduced that option! Will add that to 2.6.0

@phoerious
Copy link
Member

phoerious commented Jun 29, 2020 via email

geraldcombs pushed a commit to wireshark/wireshark that referenced this issue Apr 25, 2021
- Set `Qt::HighDpiScaleFactorRoundingPolicy::PassThrough` to fix large UI on devices with non-integer scaling factors
- Fix #17007
- See discussions at keepassxreboot/keepassxc#2815 and my fix at keepassxreboot/keepassxc#4915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests