GNOME Bugzilla – Bug 793214
No monitor reported as primary by GDK under Wayland
Last modified: 2018-05-02 19:50:55 UTC
Created attachment 367949 [details] Use GDK to list monitors and identify the primary one Overview ======== In a setup with multiple monitors on Wayland, gdk_display_get_primary_monitor() returns a null pointer and gdk_monitor_is_primary() returns false for all monitors, in spite of a primary monitor being configured via the Displays panel of gnome-control-center. This makes it impossible to determine the primary monitor via these means. Steps to Reproduce ================== 1) Connect two monitors to your machine (in my case, it's an ADI monitor connected via VGA and a DELL via HDMI). 2) Start a GNOME session with Wayland. 3) Configure either of the monitors as primary using Displays. 4) Compile and run the attached program. Actual Results ============== Irrespective of which monitor is configured as primary, the output always is: According to gdk_display_get_primary_monitor(), the primary monitor is (null) Monitor 0 is DELL U2412M, primary?: no Monitor 1 is ADI MS A710, primary?: no Expected Results ================ Say that you've configured the DELL monitor as primary under step 3). The output should then be: According to gdk_display_get_primary_monitor(), the primary monitor is DELL U2412M Monitor 0 is DELL U2412M, primary?: yes Monitor 1 is ADI MS A710, primary?: no Build ===== gtk3 3.22.26+161+g60750b3ffd-1, Arch Linux Additional Information ====================== Under X11, primary monitor reporting via the means indicated above works fine, but the ordering of the monitors changes: the primary one is always Monitor 0. By contrast, under Wayland, the ordering is always the same: DELL first, ADI second. The ordering in Displays is also always the same but reversed: ADI first, DELL second. This suggests that GNOME uses custom code to determine which monitor is which and which monitor is the primary one. Indeed, it must have a way of identifying the primary monitor even under Wayland since it puts the top bar on the right one and Displays shows one of them as primary. However, other GTK applications are out of luck under Wayland. Sample outputs under X11 ------------------------ Note that under X11, the names reported by gdk_monitor_get_model() are plug names, VGA-1 and HDMI-1. With DELL (HDMI-1) set as the primary monitor via Displays: According to gdk_display_get_primary_monitor(), the primary monitor is HDMI-1 Monitor 0 is HDMI-1, primary?: yes Monitor 1 is VGA-1, primary?: no With ADI (VGA-1) set as the primary monitor via Displays: According to gdk_display_get_primary_monitor(), the primary monitor is VGA-1 Monitor 0 is VGA-1, primary?: yes Monitor 1 is HDMI-1, primary?: no
Yup, Display.get_primary_monitor() is simply unimplemented in GdkWaylandDisplay, and Monitor.is_primary() just uses that.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/1028.