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

Listen to screen DPI changes #864

Merged
merged 3 commits into from
Mar 11, 2022
Merged

Listen to screen DPI changes #864

merged 3 commits into from
Mar 11, 2022

Conversation

jwiggins
Copy link
Member

Closes #863

Note that I haven't tested this extensively. base_pixel_scale gets cached in a few places, so there a probably lingering corner cases.

@rahulporuri
Copy link
Contributor

rahulporuri commented Jun 28, 2021

CI is failing because we changed base_pixel_size into a readonly property but a test tries to set it -

======================================================================
ERROR: test_component_hidpi_size_stability (enable.tests.test_component_editor.TestComponentEditor)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/.edm/envs/enable-test-3.6-pyqt5/lib/python3.6/site-packages/enable/tests/test_component_editor.py", line 86, in test_component_hidpi_size_stability
    dialog.thing.window.base_pixel_scale = 2.0
  File "/home/runner/.edm/envs/enable-test-3.6-pyqt5/lib/python3.6/site-packages/traits/trait_type.py", line 67, in _read_only
    % (name, class_of(object))
traits.trait_errors.TraitError: The 'base_pixel_scale' trait of a Window instance is 'read only'.

----------------------------------------------------------------------

@corranwebster
Copy link
Contributor

Revisiting this, it looks like the only place we are setting the base_pixel_scale is here:

dialog.thing.window.base_pixel_scale = 2.0

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

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

This works really smoothly when moving between HiDPI laptop and regular resolution external monitor. Manually tested using:

  • agg
  • celiagg
  • qpainter
  • quartz
  • gl

The gl backend had issues with HiDPI display, but other than that everything worked as expected.

@corranwebster
Copy link
Contributor

I have opened #907 for the OpenGL issues.

@jwiggins
Copy link
Member Author

Wait... How is the Wx test passing now?

@corranwebster
Copy link
Contributor

Wait... How is the Wx test passing now?

Two tests - one for Wx (the old one), one for Qt

@jwiggins
Copy link
Member Author

But that doesn't explain why setting base_pixel_scale in the Wx test doesn't raise a TraitError. What am I missing?

@corranwebster
Copy link
Contributor

But that doesn't explain why setting base_pixel_scale in the Wx test doesn't raise a TraitError. What am I missing?

That the original change was on the Qt-specific Window subclass and not the Wx one. This PR doesn't attempt to handle the Wx case, I think.

@jwiggins
Copy link
Member Author

Right... Thanks for helping me finally understand the code that I wrote. 😞

And thanks for seeing this change through! LGTM.

@jwiggins jwiggins merged commit 13111f6 into main Mar 11, 2022
@jwiggins jwiggins deleted the fix/dpi-changed-now-what branch March 11, 2022 14:12
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.

HighDPI/Retina drawing issues when moving window from high resolution to low
3 participants