-
Notifications
You must be signed in to change notification settings - Fork 276
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
Qt auto scale factor for HiDPI displays #291
Conversation
Signed-off-by: Mabel Zhang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never had DPI issues with my Ignition setup, and adding this environment doesn't seem to be changing anything. So if it fixes other setups, I think it's good to add it in!
src/gui/Gui.cc
Outdated
@@ -53,6 +53,9 @@ std::unique_ptr<ignition::gui::Application> createGui( | |||
ignmsg << "Ignition Gazebo GUI v" << IGNITION_GAZEBO_VERSION_FULL | |||
<< std::endl; | |||
|
|||
// Set auto scaling factor for HiDPI displays | |||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about checking to see if the env variable exists and only set the the variable if it does not? This allows users to override it if needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 04488ee
Tested with:
$ ign gazebo
in which case the window auto scales, and
$ QT_AUTO_SCREEN_SCALE_FACTOR=0 ign gazebo
in which case the window does not auto scale, and
$ QT_AUTO_SCREEN_SCALE_FACTOR=2 ign gazebo
in which case the window auto scales, and
$ QT_AUTO_SCREEN_SCALE_FACTOR=-1 ign gazebo
in which case the window does not auto scale.
Signed-off-by: Mabel Zhang <[email protected]>
Signed-off-by: Mabel Zhang <[email protected]>
Signed-off-by: Mabel Zhang <[email protected]>
On HiDPI displays, Ignition menus, fonts, and buttons don't appear correctly.
I don't have a non-HiDPI display to test whether this change messes it up for non-HiDPI displays. Can someone test this?
This PR is the equivalent of setting this on the command line:
I'm putting this line in
ign-gazebo
as opposed toign-gui
, because this environment variable needs to be set beforeignition::gui::Application
is called. I tried setting it inApplication()
constructor inign-gui
, and that did not have an effect.Test simply with
What I did test was whether this flag needs a guard, i.e. getting the value before setting it, then restoring it afterwards. It seems a guard is not needed, because after I terminate
ign gazebo
, then I launch another app in the same terminal that usually doesn't do auto-scale adjustment, and it still doesn't. So seems the flag is not propagated beyond program termination.If this gets merged, then I can also add the same line before every
Application()
call inign-gui
entry point https://github.com/ignitionrobotics/ign-gui/blob/master/src/ign.cc It seems to work there from brief testing.Before the fix
For example, on such a display with Gnome auto-scaling set to 200%, Ignition menu font sizes are inconsistent. Compare the font sizes of "Show/Hide Grid" and "Cell Count", which are the same size on non-HiDPI displays.
The mouse cursor takes on the wrong shape on the run button, making it difficult to unpause physics:
When a second panel is added, the cursor is always in double-arrow for the entire length of the panel title bar, which makes closing the second panel impossible:
After the fix
Font sizes are consistent, cursor size and behavior are correct:
Signed-off-by: Mabel Zhang [email protected]