Small plants wet with dew

Pop!_OS Multi-DPI Support

The Problem

I use a System76 Galago Pro as my laptop. I love it. Their hardware and software play together extremely well, a refreshing change from some of my prior Linux driver experience. I used to use a 2012 MacBook Pro Retina running Arch Linux, and the System76 machine is much nicer (from a driver perspective). It’s even much nicer when running Arch Linux!

But I digress. My Galago Pro has an insanely high resolution for a 13″ laptop: 3200px × 1800px. This is quite nice for viewing high-resolution photos and having crisp fonts, but it creates a bit of a headache for using an external display. Why, you ask?

Because the screen is only 13″, I use monitor scaling to increase the size of everything on screen. GNOME (my current desktop environment) only supports whole-number scaling factors, so I have to double the size of everything in order to make it usable (which makes things a bit larger than I really need, but it’s tolerable).

The problem occurs when I connect my laptop to another monitor (say my 27″ 1440p desk monitor). Everything on the external monitor has also doubled in size automatically (even though that monitor doesn’t need it). The results look like this:

Xorg-HiDPI

The screenshot above has two displays. The one on the left (the larger of the two), is my 13″ laptop screen. The one on the right is my 27″ monitor. You’ll notice that everything on the monitor is enormous, but Xorg has to set it up that way in order to scale the contents up the laptop screen up to a usable size.

I wanted to find a way to make the scaling factor of each monitor independent of the other. This post documents my journey.

Discovering the Wayland Fix

I’ve looked for a way to do this for years, and I’d heard that Wayland was supposed to accomodate Multi-DPI settings like this, but this Ask Ubuntu answer was the first time that I’d heard that GNOME on Wayland actually had support for it.

Since I’m running GNOME (the default on Pop!_OS), I thought that I could simply install the gnome-session-wayland package and then I’d be able to use the shiny new Wayland features. Alas, once I installed the Wayland session, I still didn’t see an option to log in with Wayland on the GDM login screen.

Flummoxed, I decided to search for whether Pop!_OS supported Wayland in the first place. I found this System76 blog post indicating that Wayland sessions were supported (and that they addressed Multi-DPI problems).

The question remained: How do I use this mythical Wayland-based GNOME session? More searching around led me to the Pop!_OS subreddit, where in this thread user jbicha commented:

System76 has disabled Wayland currently because it is a bit complicated to default to X otherwise.

You can change this by editing /etc/gdm3/custom.conf/

and making sure that all WaylandEnable=false lines start with a # to comment them out. Then restart your computer. On the login screen, select your user, then click the gear button to choose Pop (which is Wayland) or Pop on Xorg.

I assume that this configuration is not officially supported by System76.

Sure enough, /etc/gdm3/custom.conf looked like:

# GDM configuration storage
#
# See /usr/share/gdm/gdm.schemas for a list of available options.

[daemon]
# Uncoment the line below to force the login screen to use Xorg
WaylandEnable=false

# Enabling automatic login
#  AutomaticLoginEnable = true
#  AutomaticLogin = user1

# Enabling timed login
#  TimedLoginEnable = true
#  TimedLogin = user1
#  TimedLoginDelay = 10

[security]

[xdmcp]

[chooser]

[debug]
# Uncomment the line below to turn on debugging
# More verbose logs
# Additionally lets the X server dump core if it crashes
#Enable=true

You’ll notice the line that reads WaylandEnable = false. I simply commented this out by prepending a #. Then I restarted my computer.

After the restart, I had a small gear on the GDM login screen that allowed me to choose between Pop (Xorg) and Pop (which is the name for the Wayland session). Choosing Pop logged me in with Wayland.

Wayland is magic

Okay, that’s a bit of an overstatement, but applications automatically rescale themselves when I drag them between screens with different pixel densities. Words cannot express how happy it makes me to finally have a solution to this problem. Now I can actually hook my laptop to an external display and benefit from it.

HiDPI-Wayland-Files

The above screenshot might not seem like a huge change, but the contents of the 27″ monitor (the right side) are scaled appropriately to the size of the monitor.

XWayland is not magic

Applications that are running as Wayland clients (anything using recent versions of GTK3 or Qt) automatically scale beautifully. However, applications that are not Wayland-ready (anything using older versions of GTK or relying directly on Xorg) run within a compatability layer called XWayland. Applications that do this do not rescale properly. Almost all of the default Pop!_OS applications are, of course, Wayland-ready… with the exception of Firefox.

Firefox just picks the scale of one of the displays and keeps that scale regardless of which monitor it is on. There is a development build of Firefox that I tried hoping that it would have support, but it’s not usable yet (that will be the subject of a future post).

In an effort to find a Wayland-enabled browser, I tried Epiphany (also known as GNOME Web). It was a simple sudo apt install epiphany to acquire, but it wasn’t really usable either. Typing in the URL bar had latency so bad as to render the browser unusable.

While I am aware that there are other Wayland-enabled browsers out there, I decided that I’d rather continue to use Firefox and put up with the scaling problem until it is resolved. Firefox always opens scaled correctly for one of the displays, so I can just leave it on that one.

Closing thoughts

I wanted to take screenshots of GDM’s login screen so that I could show the different session options, but I have no idea how to take a screenshot when I’m not even logged in… I suppose that I could log in on a different virtual terminal and then use something like fbgrab? I’ll have to test that sometime. If you know a trick for this, please let me know.

Also, if anyone has a favorite Wayland-compatible browser, I’m open to recommendations.

Image Credit: Narayan G. Maharjan
Image License: CC BY-NC 2.0

2 thoughts on “Pop!_OS Multi-DPI Support”

  1. Thanks for the firefox tip! I tried that, but the scaling issues with MultiDPI prevented me from switching to it permanently. I’m working on another blog post about that experience right now. Also, thanks a bunch for the xrandr script! I definitely might use that in the future.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s