Marco Trevisan (Treviño) has proposed merging 
~3v1n0/ubuntu/+source/gnome-control-center:ubuntu/xrandr-scaling into 
~ubuntu-desktop/ubuntu/+source/gnome-control-center:ubuntu/master.

Commit message:
display: support UI scaled logical displays mode for X11 randr scaling

Requested reviews:
  Ubuntu Desktop (ubuntu-desktop)
Related bugs:
  Bug #1820850 in mutter (Ubuntu): "[FFe] Distro patch GNOME hi-dpi support for 
x11 sessions"
  https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1820850

For more details, see:
https://code.launchpad.net/~3v1n0/ubuntu/+source/gnome-control-center/+git/gnome-control-center/+merge/365150
-- 
Your team Ubuntu Desktop is requested to review the proposed merge of 
~3v1n0/ubuntu/+source/gnome-control-center:ubuntu/xrandr-scaling into 
~ubuntu-desktop/ubuntu/+source/gnome-control-center:ubuntu/master.
diff --git a/debian/changelog b/debian/changelog
index 89af966..ab949c9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,13 @@
+gnome-control-center (1:3.32.0.1-1ubuntu6) disco; urgency=medium
+
+  * debian/patches/display-Don-t-always-set-the-primary-monitor-to-the-first.patch:
+    - Make sure the display panel primary monitor matches configured one
+  * debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch:
+    - Support scaled logical monitors using UI scale as it could happen when
+      using the X11 Randr scaling (LP: #1820850)
+
+ -- Marco Trevisan (Treviño) <ma...@ubuntu.com>  Wed, 27 Mar 2019 06:10:59 +0100
+
 gnome-control-center (1:3.32.0.1-1ubuntu5) disco; urgency=medium
 
   * debian/patches/0001-sound-Fix-crash-when-sound-device-set-to-NULL.patch:
diff --git a/debian/patches/display-Don-t-always-set-the-primary-monitor-to-the-first.patch b/debian/patches/display-Don-t-always-set-the-primary-monitor-to-the-first.patch
new file mode 100644
index 0000000..5df1bc6
--- /dev/null
+++ b/debian/patches/display-Don-t-always-set-the-primary-monitor-to-the-first.patch
@@ -0,0 +1,33 @@
+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <m...@3v1n0.net>
+Date: Mon, 18 Mar 2019 02:00:49 +0100
+Subject: display: Don't always set the primary monitor to the first in list
+
+As per the binding that we have between the list store and the combo-box, when
+the first element is added to the list-store, the combo box set this value as
+the selected-index, and this leads to a call to cc_display_monitor_set_primary
+which set the first-listed monitor as primary and unset the real primary monitor.
+
+To avoid this, just ignore the binding when rebuilding the UI, since in this
+phase control-center should just reflect the actual state without changing
+anything.
+
+Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/419
+Origin: https://gitlab.gnome.org/GNOME/gnome-control-center/merge_requests/436
+Applied-Upstream: yes, 3.32.1
+---
+ panels/display/cc-display-panel.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
+index 9604883..85ea4ce 100644
+--- a/panels/display/cc-display-panel.c
++++ b/panels/display/cc-display-panel.c
+@@ -550,7 +550,7 @@ on_primary_display_selected_index_changed_cb (CcDisplayPanel *panel)
+   gint idx = hdy_combo_row_get_selected_index (panel->primary_display_row);
+   g_autoptr(CcDisplayMonitor) output = NULL;
+ 
+-  if (idx < 0)
++  if (idx < 0 || panel->rebuilding)
+     return;
+ 
+   output = g_list_model_get_item (G_LIST_MODEL (panel->primary_display_list), idx);
diff --git a/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch b/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch
new file mode 100644
index 0000000..c9609a2
--- /dev/null
+++ b/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch
@@ -0,0 +1,233 @@
+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <m...@3v1n0.net>
+Date: Wed, 27 Mar 2019 05:42:41 +0100
+Subject: display: Support UI scaled logical monitor mode
+
+When this mode is selected we need to assume that all the monitors are scaled
+by their scaling and the global UI scale.
+
+Origin: https://gitlab.gnome.org/3v1n0/gnome-control-center/commits/layout-global-scale
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1820850
+Forwarded: No, MPs will follow shortly
+---
+ panels/display/cc-display-arrangement.c | 45 +++++++++++++++++++++++++++++----
+ panels/display/cc-display-config-dbus.c | 16 +++++++++---
+ panels/display/cc-display-config.c      |  6 +++++
+ panels/display/cc-display-config.h      |  2 ++
+ 4 files changed, 61 insertions(+), 8 deletions(-)
+
+diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c
+index adbbcbc..c3b14e4 100644
+--- a/panels/display/cc-display-arrangement.c
++++ b/panels/display/cc-display-arrangement.c
+@@ -95,10 +95,31 @@ apply_rotation_to_geometry (CcDisplayMonitor *output,
+     }
+ }
+ 
++static double
++get_maximum_scale (CcDisplayConfig *config)
++{
++  GList *outputs, *l;
++  double max_scale = 1.0;
++  outputs = cc_display_config_get_monitors (config);
++
++  for (l = outputs; l; l = l->next)
++    {
++      CcDisplayMonitor *output = l->data;
++
++      if (!cc_display_monitor_is_useful (output))
++        continue;
++
++      max_scale = MAX (max_scale, cc_display_monitor_get_scale (output));
++    }
++
++  return max_scale;
++}
++
+ /* get_geometry */
+ static void
+ get_scaled_geometry (CcDisplayConfig  *config,
+                      CcDisplayMonitor *output,
++                     double            max_scale,
+                      int              *x,
+                      int              *y,
+                      int              *w,
+@@ -117,6 +138,10 @@ get_scaled_geometry (CcDisplayConfig  *config,
+   if (cc_display_config_is_layout_logical (config))
+     {
+       double scale = cc_display_monitor_get_scale (output);
++
++      if (cc_display_config_layout_use_ui_scale (config))
++        scale /= ceilf (max_scale);
++
+       *w = round (*w / scale);
+       *h = round (*h / scale);
+     }
+@@ -134,6 +159,7 @@ get_bounding_box (CcDisplayConfig *config,
+                   gint            *max_h)
+ {
+   GList *outputs, *l;
++  gdouble max_scale;
+ 
+   g_assert (x1 && y1 && x2 && y2);
+ 
+@@ -141,6 +167,7 @@ get_bounding_box (CcDisplayConfig *config,
+   *x2 = *y2 = G_MININT;
+   *max_w = 0;
+   *max_h = 0;
++  max_scale = get_maximum_scale (config);
+ 
+   outputs = cc_display_config_get_monitors (config);
+   for (l = outputs; l; l = l->next)
+@@ -151,7 +178,7 @@ get_bounding_box (CcDisplayConfig *config,
+       if (!cc_display_monitor_is_useful (output))
+         continue;
+ 
+-      get_scaled_geometry (config, output, &x, &y, &w, &h);
++      get_scaled_geometry (config, output, max_scale, &x, &y, &w, &h);
+ 
+       *x1 = MIN (*x1, x);
+       *y1 = MIN (*y1, y);
+@@ -171,8 +198,10 @@ monitor_get_drawing_rect (CcDisplayArrangement *self,
+                           gint                 *y2)
+ {
+   gdouble x, y;
++  gdouble max_scale;
+ 
+-  get_scaled_geometry (self->config, output, x1, y1, x2, y2);
++  max_scale = get_maximum_scale (self->config);
++  get_scaled_geometry (self->config, output, max_scale, x1, y1, x2, y2);
+ 
+   /* get_scaled_geometry returns the width and height */
+   *x2 = *x1 + *x2;
+@@ -325,10 +354,12 @@ find_best_snapping (CcDisplayConfig   *config,
+   GList *outputs, *l;
+   gint x1, y1, x2, y2;
+   gint w, h;
++  double max_scale;
+ 
+   g_assert (snap_data != NULL);
+ 
+-  get_scaled_geometry (config, snap_output, &x1, &y1, &w, &h);
++  max_scale = get_maximum_scale (config);
++  get_scaled_geometry (config, snap_output, max_scale, &x1, &y1, &w, &h);
+   x2 = x1 + w;
+   y2 = y1 + h;
+ 
+@@ -344,6 +375,7 @@ find_best_snapping (CcDisplayConfig   *config,
+       gint left_snap_pos;
+       gint right_snap_pos;
+       gdouble dist_x, dist_y;
++      gdouble max_scale;
+       gdouble tmp;
+ 
+       if (output == snap_output)
+@@ -352,7 +384,8 @@ find_best_snapping (CcDisplayConfig   *config,
+       if (!cc_display_monitor_is_useful (output))
+         continue;
+ 
+-      get_scaled_geometry (config, output, &_x1, &_y1, &_w, &_h);
++      max_scale = get_maximum_scale (config);
++      get_scaled_geometry (config, output, max_scale, &_x1, &_y1, &_w, &_h);
+       _x2 = _x1 + _w;
+       _y2 = _y1 + _h;
+ 
+@@ -965,6 +998,7 @@ cc_display_config_snap_output (CcDisplayConfig  *config,
+ {
+   SnapData snap_data;
+   gint x, y, w, h;
++  gdouble max_scale;
+ 
+   if (!cc_display_monitor_is_useful (output))
+     return;
+@@ -972,7 +1006,8 @@ cc_display_config_snap_output (CcDisplayConfig  *config,
+   if (cc_display_config_count_useful_monitors (config) <= 1)
+     return;
+ 
+-  get_scaled_geometry (config, output, &x, &y, &w, &h);
++  max_scale = get_maximum_scale (config);
++  get_scaled_geometry (config, output, max_scale, &x, &y, &w, &h);
+ 
+   snap_data.snapped = SNAP_DIR_NONE;
+   snap_data.mon_x = x;
+diff --git a/panels/display/cc-display-config-dbus.c b/panels/display/cc-display-config-dbus.c
+index 8c04119..f8ffbfa 100644
+--- a/panels/display/cc-display-config-dbus.c
++++ b/panels/display/cc-display-config-dbus.c
+@@ -858,7 +858,8 @@ cc_display_monitor_dbus_new (GVariant *variant,
+ typedef enum _CcDisplayLayoutMode
+ {
+   CC_DISPLAY_LAYOUT_MODE_LOGICAL = 1,
+-  CC_DISPLAY_LAYOUT_MODE_PHYSICAL = 2
++  CC_DISPLAY_LAYOUT_MODE_PHYSICAL = 2,
++  CC_DISPLAY_LAYOUT_MODE_GLOBAL_UI_LOGICAL = 3
+ } CcDisplayLayoutMode;
+ 
+ typedef enum _CcDisplayConfigMethod
+@@ -1194,7 +1195,15 @@ cc_display_config_dbus_is_layout_logical (CcDisplayConfig *pself)
+ {
+   CcDisplayConfigDBus *self = CC_DISPLAY_CONFIG_DBUS (pself);
+ 
+-  return self->layout_mode == CC_DISPLAY_LAYOUT_MODE_LOGICAL;
++  return self->layout_mode == CC_DISPLAY_LAYOUT_MODE_LOGICAL ||
++         self->layout_mode == CC_DISPLAY_LAYOUT_MODE_GLOBAL_UI_LOGICAL;
++}
++
++static gboolean
++cc_display_config_dbus_layout_use_ui_scale (CcDisplayConfig *pself)
++{
++  CcDisplayConfigDBus *self = CC_DISPLAY_CONFIG_DBUS (pself);
++  return self->layout_mode == CC_DISPLAY_LAYOUT_MODE_GLOBAL_UI_LOGICAL;
+ }
+ 
+ static void
+@@ -1386,7 +1395,7 @@ cc_display_config_dbus_constructed (GObject *object)
+           guint32 u = 0;
+           g_variant_get (v, "u", &u);
+           if (u >= CC_DISPLAY_LAYOUT_MODE_LOGICAL &&
+-              u <= CC_DISPLAY_LAYOUT_MODE_PHYSICAL)
++              u <= CC_DISPLAY_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
+             self->layout_mode = u;
+         }
+     }
+@@ -1474,6 +1483,7 @@ cc_display_config_dbus_class_init (CcDisplayConfigDBusClass *klass)
+   parent_class->set_cloning = cc_display_config_dbus_set_cloning;
+   parent_class->get_cloning_modes = cc_display_config_dbus_get_cloning_modes;
+   parent_class->is_layout_logical = cc_display_config_dbus_is_layout_logical;
++  parent_class->layout_use_ui_scale = cc_display_config_dbus_layout_use_ui_scale;
+ 
+   pspec = g_param_spec_variant ("state",
+                                 "GVariant",
+diff --git a/panels/display/cc-display-config.c b/panels/display/cc-display-config.c
+index 3bed67a..00696ad 100644
+--- a/panels/display/cc-display-config.c
++++ b/panels/display/cc-display-config.c
+@@ -568,3 +568,9 @@ cc_display_config_is_layout_logical (CcDisplayConfig *self)
+ {
+   return CC_DISPLAY_CONFIG_GET_CLASS (self)->is_layout_logical (self);
+ }
++
++gboolean
++cc_display_config_layout_use_ui_scale (CcDisplayConfig *self)
++{
++  return CC_DISPLAY_CONFIG_GET_CLASS (self)->layout_use_ui_scale (self);
++}
+diff --git a/panels/display/cc-display-config.h b/panels/display/cc-display-config.h
+index faeae8e..27b939a 100644
+--- a/panels/display/cc-display-config.h
++++ b/panels/display/cc-display-config.h
+@@ -154,6 +154,7 @@ struct _CcDisplayConfigClass
+                                  gboolean          clone);
+   GList*   (*get_cloning_modes) (CcDisplayConfig  *self);
+   gboolean (*is_layout_logical) (CcDisplayConfig  *self);
++  gboolean (*layout_use_ui_scale) (CcDisplayConfig  *self);
+ };
+ 
+ 
+@@ -174,6 +175,7 @@ void              cc_display_config_set_mode_on_all_outputs (CcDisplayConfig *co
+                                                              CcDisplayMode   *mode);
+ 
+ gboolean          cc_display_config_is_layout_logical       (CcDisplayConfig    *self);
++gboolean          cc_display_config_layout_use_ui_scale     (CcDisplayConfig    *self);
+ 
+ const char*       cc_display_monitor_get_display_name       (CcDisplayMonitor   *monitor);
+ gboolean          cc_display_monitor_is_active              (CcDisplayMonitor   *monitor);
diff --git a/debian/patches/series b/debian/patches/series
index 6c2b153..e9e7906 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -29,3 +29,5 @@ auto_quit_after_goa_add.patch
 0008-applications-Add-hack-detect-snaps-before-X-SnapInst.patch
 0001-sound-Apply-device-changes.patch
 0001-sound-Fix-crash-when-sound-device-set-to-NULL.patch
+display-Don-t-always-set-the-primary-monitor-to-the-first.patch
+display-Support-UI-scaled-logical-monitor-mode.patch
-- 
ubuntu-desktop mailing list
ubuntu-desktop@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-desktop

Reply via email to