After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 777687 - Fix hidpi detection on vertical monitor layouts
Fix hidpi detection on vertical monitor layouts
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: wayland
unspecified
Other Linux
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
: 775349 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2017-01-24 10:21 UTC by Carlos Garnacho
Modified: 2017-04-12 09:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
backends: Calculate output scale correctly on vertical transforms (2.53 KB, patch)
2017-01-24 10:21 UTC, Carlos Garnacho
committed Details | Review
meta-monitor-config: Pass logical monitor scale via config (4.93 KB, patch)
2017-03-17 11:03 UTC, Jonas Ådahl
none Details | Review
monitor-manager: Remove 'scale' from MetaOutput (25.84 KB, patch)
2017-03-17 11:03 UTC, Jonas Ådahl
reviewed Details | Review
monitor-manager: Update the monitor mode state before the logical state (2.49 KB, patch)
2017-03-24 16:13 UTC, Jonas Ådahl
none Details | Review

Description Carlos Garnacho 2017-01-24 10:21:13 UTC
Mutter assigns a wrong output scale (=1) when a hidpi screen is rotated to portrait. It turns out that the code doing the scale calculations operate on pixel and mm sizes, with the small catch that pixel sizes have the applied transformation (i.e. h>w), which botches the DPI calculations, and bail out because one axis falls below the hidpi threshold.

I'm attaching a patch that fixes this by transforming back pixel sizes to the untransformed layout, so comparisons happen between the right axes.
Comment 1 Carlos Garnacho 2017-01-24 10:21:48 UTC
Created attachment 344104 [details] [review]
backends: Calculate output scale correctly on vertical transforms

The code calculating the output scale involves calculations around pixel
and mm sizes, however we do compare post-transformation pixel sizes to
untransformed mm sizes, which breaks the DPI calculations. Fix this by
transforming back pixel sizes back to untransformed.

While we're at it, actually compare the output height to HIDPI_MIN_HEIGHT
instead of its width, it seems right according to the #define name and
comment.
Comment 2 Jonas Ådahl 2017-01-24 12:28:17 UTC
I have a commit on my wip branch that accidentally fixes this, as part of a larger refactorization:

https://github.com/jadahl/mutter/commit/d538a0218eb4d20fa4d4833ae41857fbb5bfc886

The patch looks good, but could we just put it on gnome-3-22, but just go with some version of the one linked above for master? It'd save me some rebase head ache.
Comment 3 Carlos Garnacho 2017-01-24 13:10:58 UTC
Sure, makes sense.
Comment 4 Carlos Garnacho 2017-01-25 08:59:24 UTC
Pushed to gnome-3-22, master will be handled in bug #777732

Attachment 344104 [details] pushed as f8fd02d - backends: Calculate output scale correctly on vertical transforms
Comment 5 Jonas Ådahl 2017-03-17 11:03:09 UTC
Created attachment 348163 [details] [review]
meta-monitor-config: Pass logical monitor scale via config

The default (calculated) scale is derived from the output, but
ultimately set via the monitor scale. This will enable config files to
override the scale. Yet to be done is handling when a scale is not
supported by a backend (i.e. the X11 backend).
Comment 6 Jonas Ådahl 2017-03-17 11:03:27 UTC
Created attachment 348164 [details] [review]
monitor-manager: Remove 'scale' from MetaOutput

Replace the 'scale' of an output with a vfunc on the MetaMonitorManager
class that takes a monitor and a monitor mode which calculates the
scale. On X11 this always returns 1, on KMS, the old formula is used.
On the dummy and test backends, the already configured values are
returned.
Comment 7 Carlos Garnacho 2017-03-24 15:57:53 UTC
Review of attachment 348164 [details] [review]:

Hmm, I fear this didn't rebase as easily. It seems to work fine to fix the issue of this bug (i.e. rotating doesn't affect scale anymore), but I do get crashes as soon as I plug an external monitor, it seems it's trying to create the MetaLogicalOutput (and guess its scale) when the MetaMonitor still has a NULL MetaMonitorMode.

Since MetaLogicalOuput scale seems static after creation, I guess it's not ok to just guess 1 in this case, so there's perhaps any more piece missing here?
Comment 8 Jonas Ådahl 2017-03-24 16:13:08 UTC
Created attachment 348657 [details] [review]
monitor-manager: Update the monitor mode state before the logical state

This means we can use up to date monitor mode data when generating the
logical state.

-----

(In reply to Carlos Garnacho from comment #7)
> Review of attachment 348164 [details] [review] [review]:
> 
> Hmm, I fear this didn't rebase as easily. It seems to work fine to fix the
> issue of this bug (i.e. rotating doesn't affect scale anymore), but I do get
> crashes as soon as I plug an external monitor, it seems it's trying to
> create the MetaLogicalOutput (and guess its scale) when the MetaMonitor
> still has a NULL MetaMonitorMode.
> 
> Since MetaLogicalOuput scale seems static after creation, I guess it's not
> ok to just guess 1 in this case, so there's perhaps any more piece missing
> here?

Yes, seems so. I put this patch before the others, and I can plug in a monitor
withoun anything crashing. The only thing that worries me with these patches is
that some user sets a mode on a monitor that is unknown to mutter, meaning it
couldn't derive the current mode. I don't think it should happen, but maybe we
should consider being more graceful in this regard, at least in paths that can
be taken when running on X11.
Comment 9 Carlos Garnacho 2017-03-24 17:12:41 UTC
As discussed in IRC, I did a forward port of the patch to master.
Comment 10 Jonas Ådahl 2017-04-12 09:16:40 UTC
*** Bug 775349 has been marked as a duplicate of this bug. ***