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

Scale windows and resolution for HiDPI displays #2544

Closed
wants to merge 6 commits into from

Commits on Feb 24, 2023

  1. Make GLMakie aware of the content scale factor on HiDPI screens

    This is accomplished by making the window and rendered framebuffer
    sizes independent of one another. By separating the two concepts, we
    can create rasterized graphics at higher (or lower) resolution than
    what is shown on screen.
    
    The window scale factor is used to scale the sizes of elements within
    the window (and on Linux and Windows, the window size itself from the
    requested logical sizes), and the px-per-unit scale factor dictates
    the size of the rasterized render.
    
    The default scaling factors are initialized by requesting the content
    scale factor from GLFW (and dynamically responding to changes in the
    content scale factor on platforms where GLFW provides support).
    
    Testing is added on Linux where xvfb-run can be used to force a
    HiDPI context.
    jmert committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    3b5110a View commit details
    Browse the repository at this point in the history
  2. Cleanup scalefactor/px_per_unit observables on close & resize on OSX

    - Clear the `scalefactor` and `px_per_unit` observables when the figure
      is closed. It's possible both may be used during a figure's lifetime,
      but that should not persist past a close.
    
    - In the system scale factor callback, do not unconditionally resize
      the native window. Instead, leverage the fact that the observable
      callback will invoke a resize event, and that correctly will check that
      the root scene is not `nothing`.
    
    - Do not completely ignore the scale factor on OSX. The difference is
      that there is a native scaling factor applied by the OS, but if/when
      the desired scale factor differs from the native scaling, we must
      still make adjustments.
    jmert committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    fe6d6cf View commit details
    Browse the repository at this point in the history
  3. Replace window size polling with callback

    Instead of polling for window size changes on every render tick, use
    the size-changed callback from GLFW to only make changes when it is
    known that there's been a change in the size of the window.
    
    This solves a concurrency problem that can happen when the scale factor
    is changed. The sequence of events looks like:
    
    1. The `screen.scalefactor[]` value is changed
    2. The listeners to `scalefactor` start to be notified.
    3. Asynchronously, the `WindowAreaUpdater` listener attached to the
       `render_tick` observable runs.
    4. The window area listener notices that the window size given the
       _new_ value of the scale factor doesn't match the scene size, so
       it updates the scene size.
    5. The `scalefactor` listener responsible for resizing the window
       gets its slice of time to run, and it now sees that everything is
       already the "correct" size.
    
    Therefore, the window is not resized, and instead the scene size is
    rescaled in the opposite direction of the scale factor change.
    jmert committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    5ba035c View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2023

  1. Configuration menu
    Copy the full SHA
    006e050 View commit details
    Browse the repository at this point in the history

Commits on Mar 31, 2023

  1. Configuration menu
    Copy the full SHA
    902d047 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    84b34d8 View commit details
    Browse the repository at this point in the history