GNOME Bugzilla – Bug 705915
Support high dpi displays
Last modified: 2014-02-07 17:32:58 UTC
similar to the hidpi work done in GTK, Clutter needs to support scaling the UI by a known factor transparently to the application developer. this bug is for supporting scaling the UI in the X11 backend; the Wayland and GDK backends will have to follow suit separately.
Created attachment 251595 [details] [review] stage-window: Add scaling factor accessors We'll need to set and get the scaling factor of a ClutterStage from its StageWindow implementation.
Created attachment 251596 [details] [review] stage: Adjust drawing to include the window scaling factor In order to transparently support high DPI density displays, we must maintain all coordinates and sizes exactly as they are now — but draw them on a surface that is scaled up by a certain factor. In order to do that we have to change the viewport and initial transformation matrix so that they are scaled up by the same factor.
Created attachment 251597 [details] [review] x11: Apply the window scaling factor On high DPI density displays we create surfaces with a size scaled up by a certain factor. Even if the contents stay at the same relative size and position, we need to compensate the scaling both when changing the surface size, and when dealing with input.
Created attachment 251598 [details] [review] cogl: Compensate for window scaling The common stage window code that we share on Cogl-based backends should also use the scaling factor.
Created attachment 251599 [details] [review] settings: Add window scaling related settings We share two settings with GDK, so we can pick the window scaling factor and the unscaled font resolution when we initialize Clutter.
*** Bug 705298 has been marked as a duplicate of this bug. ***
Attachment 251595 [details] pushed as b9072a5 - stage-window: Add scaling factor accessors Attachment 251596 [details] pushed as 0d0cb13 - stage: Adjust drawing to include the window scaling factor Attachment 251597 [details] pushed as 75f81fe - x11: Apply the window scaling factor Attachment 251598 [details] pushed as a26690a - cogl: Compensate for window scaling
Created attachment 266449 [details] [review] Check for cairo_surface_set_device_scale() Like gtk+, we don't want to bump the dependency of Clutter for that function alone.
Created attachment 266450 [details] [review] settings: Handle window scaling factor internally We want the settings object to handle setting and getting the window scaling factor value, both through backend-specific settings and through the CLUTTER_SCALE environment variable. This means turning the ClutterSettings:window-scaling-factor property into a readwrite one, instead of write-only, so that ClutterStage implementations will be able to query the window scaling factor on construction.
Created attachment 266451 [details] [review] x11/stage: Remove CLUTTER_SCALE handling Use the ClutterSettings:window-scaling-factor property instead.
Created attachment 266452 [details] [review] x11/stage: Resize on window-scaling-factor changes If we get a change in the window scaling factor we want to resize the backing store of each stage, so we use the notification on the ClutterSettings:window-scaling-factor property to do so.
Created attachment 266453 [details] [review] settings: Remove explicit stage scaling factor update We can rely on the window-scaling-factor property notification instead.
Created attachment 266454 [details] [review] canvas: Use the window-scaling-factor setting ClutterCanvas is a ClutterContent interface implementation; this means that it can be created and modified regardless of whether it is associated to a specific actor or a stage. For this reason, we cannot walk the hierarchy and get the window scaling factor for high DPI density displays out of the ClutterStage when we create the Cairo surface that we will use to draw the canvas contents on. We can use ClutterSettings:window-scaling-factor instead, since it's what each ClutterStage will use anyway. This will get slightly more complicated when we support per-output window scaling factors (like on Wayland), but that will require changes in the entire settings architecture anyway.
with the last batch of commits I'm able to get ClutterCanvas with proper scaling. this does not help the Shell, because they are using StDrawingArea, which is a reimplementation of ClutterCairoTexture, so we'll need to patch that to use the window scaling factor explicitly — or to use ClutterCanvas internally.
Created attachment 266542 [details] [review] canvas: Add scale-factor property We need to provide an escape hatch to ClutterCanvas so that it's possible to override the window-scaling-factor ClutterSetting. This is going to be useful in the future in case the user has better knowledge of the window scaling factor that is going to be used with a specific set of ClutterCanvas contents (e.g. on different outputs or stages).
pushed the additional commits, alongside with a couple of fixes for ClutterSettings and ClutterStageX11.
*** Bug 723602 has been marked as a duplicate of this bug. ***