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

Qt auto scale factor for HiDPI displays #291

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Copy link
Contributor

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

Copy link
Contributor Author

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.


// Initialize Qt app
auto app = std::make_unique<ignition::gui::Application>(_argc, _argv);
app->AddPluginPath(IGN_GAZEBO_GUI_PLUGIN_INSTALL_DIR);
Expand Down