Merge ~3v1n0/ubuntu/+source/gnome-control-center:ubuntu/xrandr-scaling into ~ubuntu-desktop/ubuntu/+source/gnome-control-center:ubuntu/master

Proposed by Marco Trevisan (Treviño) on 2019-04-06
Status: Merged
Approved by: Sebastien Bacher on 2019-04-08
Approved revision: bd2bd6e2ba7cf4668f970ca8e10783fd7cb0e2af
Merged at revision: bd2bd6e2ba7cf4668f970ca8e10783fd7cb0e2af
Proposed branch: ~3v1n0/ubuntu/+source/gnome-control-center:ubuntu/xrandr-scaling
Merge into: ~ubuntu-desktop/ubuntu/+source/gnome-control-center:ubuntu/master
Diff against target: 261 lines (+82/-36)
2 files modified
debian/changelog (+7/-0)
debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch (+75/-36)
Reviewer Review Type Date Requested Status
Sebastien Bacher 2019-04-06 Approve on 2019-04-08
Review via email: mp+365623@code.launchpad.net

Description of the change

Fixed initial disposition when switching from one to multiple monitors (and one is scaled)

To post a comment you must log in.
Sebastien Bacher (seb128) wrote :

Thanks Marco, looks fine to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index f1d9438..92f7eb4 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+gnome-control-center (1:3.32.1-1ubuntu2) UNRELEASED; urgency=medium
7+
8+ * debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch:
9+ - Take care of global UI scaled logical monitors width (LP: #1823488)
10+
11+ -- Marco Trevisan (Treviño) <marco@ubuntu.com> Sat, 06 Apr 2019 15:43:01 -0400
12+
13 gnome-control-center (1:3.32.1-1ubuntu1) disco; urgency=medium
14
15 * New upstream stable version, based on the Debian update
16diff --git a/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch b/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch
17index d97584f..db6d4b6 100644
18--- a/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch
19+++ b/debian/patches/display-Support-UI-scaled-logical-monitor-mode.patch
20@@ -10,16 +10,16 @@ Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/mutter/+bug/1820850
21 Forwarded: No, MPs will follow shortly
22 ---
23 panels/display/cc-display-arrangement.c | 45 +++++++++++++++++++++++++++++----
24- panels/display/cc-display-config-dbus.c | 16 +++++++++---
25+ panels/display/cc-display-config-dbus.c | 41 +++++++++++++++++++++++++++---
26 panels/display/cc-display-config.c | 6 +++++
27 panels/display/cc-display-config.h | 2 ++
28- 4 files changed, 61 insertions(+), 8 deletions(-)
29+ 4 files changed, 86 insertions(+), 8 deletions(-)
30
31-Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
32-===================================================================
33---- gnome-control-center-3.32.1.orig/panels/display/cc-display-arrangement.c
34-+++ gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
35-@@ -95,10 +95,31 @@ apply_rotation_to_geometry (CcDisplayMon
36+diff --git a/panels/display/cc-display-arrangement.c b/panels/display/cc-display-arrangement.c
37+index adbbcbc..7080bf6 100644
38+--- a/panels/display/cc-display-arrangement.c
39++++ b/panels/display/cc-display-arrangement.c
40+@@ -95,10 +95,31 @@ apply_rotation_to_geometry (CcDisplayMonitor *output,
41 }
42 }
43
44@@ -51,18 +51,18 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
45 int *x,
46 int *y,
47 int *w,
48-@@ -117,6 +138,10 @@ get_scaled_geometry (CcDisplayConfig *c
49+@@ -117,6 +138,10 @@ get_scaled_geometry (CcDisplayConfig *config,
50 if (cc_display_config_is_layout_logical (config))
51 {
52 double scale = cc_display_monitor_get_scale (output);
53 +
54 + if (cc_display_config_layout_use_ui_scale (config))
55-+ scale /= ceilf (max_scale);
56++ scale /= ceil (max_scale);
57 +
58 *w = round (*w / scale);
59 *h = round (*h / scale);
60 }
61-@@ -134,6 +159,7 @@ get_bounding_box (CcDisplayConfig *confi
62+@@ -134,6 +159,7 @@ get_bounding_box (CcDisplayConfig *config,
63 gint *max_h)
64 {
65 GList *outputs, *l;
66@@ -70,7 +70,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
67
68 g_assert (x1 && y1 && x2 && y2);
69
70-@@ -141,6 +167,7 @@ get_bounding_box (CcDisplayConfig *confi
71+@@ -141,6 +167,7 @@ get_bounding_box (CcDisplayConfig *config,
72 *x2 = *y2 = G_MININT;
73 *max_w = 0;
74 *max_h = 0;
75@@ -78,7 +78,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
76
77 outputs = cc_display_config_get_monitors (config);
78 for (l = outputs; l; l = l->next)
79-@@ -151,7 +178,7 @@ get_bounding_box (CcDisplayConfig *confi
80+@@ -151,7 +178,7 @@ get_bounding_box (CcDisplayConfig *config,
81 if (!cc_display_monitor_is_useful (output))
82 continue;
83
84@@ -87,7 +87,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
85
86 *x1 = MIN (*x1, x);
87 *y1 = MIN (*y1, y);
88-@@ -171,8 +198,10 @@ monitor_get_drawing_rect (CcDisplayArran
89+@@ -171,8 +198,10 @@ monitor_get_drawing_rect (CcDisplayArrangement *self,
90 gint *y2)
91 {
92 gdouble x, y;
93@@ -99,7 +99,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
94
95 /* get_scaled_geometry returns the width and height */
96 *x2 = *x1 + *x2;
97-@@ -325,10 +354,12 @@ find_best_snapping (CcDisplayConfig *c
98+@@ -325,10 +354,12 @@ find_best_snapping (CcDisplayConfig *config,
99 GList *outputs, *l;
100 gint x1, y1, x2, y2;
101 gint w, h;
102@@ -113,7 +113,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
103 x2 = x1 + w;
104 y2 = y1 + h;
105
106-@@ -344,6 +375,7 @@ find_best_snapping (CcDisplayConfig *c
107+@@ -344,6 +375,7 @@ find_best_snapping (CcDisplayConfig *config,
108 gint left_snap_pos;
109 gint right_snap_pos;
110 gdouble dist_x, dist_y;
111@@ -121,7 +121,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
112 gdouble tmp;
113
114 if (output == snap_output)
115-@@ -352,7 +384,8 @@ find_best_snapping (CcDisplayConfig *c
116+@@ -352,7 +384,8 @@ find_best_snapping (CcDisplayConfig *config,
117 if (!cc_display_monitor_is_useful (output))
118 continue;
119
120@@ -131,7 +131,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
121 _x2 = _x1 + _w;
122 _y2 = _y1 + _h;
123
124-@@ -965,6 +998,7 @@ cc_display_config_snap_output (CcDisplay
125+@@ -965,6 +998,7 @@ cc_display_config_snap_output (CcDisplayConfig *config,
126 {
127 SnapData snap_data;
128 gint x, y, w, h;
129@@ -139,7 +139,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
130
131 if (!cc_display_monitor_is_useful (output))
132 return;
133-@@ -972,7 +1006,8 @@ cc_display_config_snap_output (CcDisplay
134+@@ -972,7 +1006,8 @@ cc_display_config_snap_output (CcDisplayConfig *config,
135 if (cc_display_config_count_useful_monitors (config) <= 1)
136 return;
137
138@@ -149,11 +149,11 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-arrangement.c
139
140 snap_data.snapped = SNAP_DIR_NONE;
141 snap_data.mon_x = x;
142-Index: gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
143-===================================================================
144---- gnome-control-center-3.32.1.orig/panels/display/cc-display-config-dbus.c
145-+++ gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
146-@@ -861,7 +861,8 @@ cc_display_monitor_dbus_new (GVariant *v
147+diff --git a/panels/display/cc-display-config-dbus.c b/panels/display/cc-display-config-dbus.c
148+index 2615461..7b9165d 100644
149+--- a/panels/display/cc-display-config-dbus.c
150++++ b/panels/display/cc-display-config-dbus.c
151+@@ -861,7 +861,8 @@ cc_display_monitor_dbus_new (GVariant *variant,
152 typedef enum _CcDisplayLayoutMode
153 {
154 CC_DISPLAY_LAYOUT_MODE_LOGICAL = 1,
155@@ -163,7 +163,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
156 } CcDisplayLayoutMode;
157
158 typedef enum _CcDisplayConfigMethod
159-@@ -1197,7 +1198,15 @@ cc_display_config_dbus_is_layout_logical
160+@@ -1197,7 +1198,15 @@ cc_display_config_dbus_is_layout_logical (CcDisplayConfig *pself)
161 {
162 CcDisplayConfigDBus *self = CC_DISPLAY_CONFIG_DBUS (pself);
163
164@@ -180,7 +180,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
165 }
166
167 static void
168-@@ -1393,7 +1402,7 @@ cc_display_config_dbus_constructed (GObj
169+@@ -1393,7 +1402,7 @@ cc_display_config_dbus_constructed (GObject *object)
170 guint32 u = 0;
171 g_variant_get (v, "u", &u);
172 if (u >= CC_DISPLAY_LAYOUT_MODE_LOGICAL &&
173@@ -189,7 +189,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
174 self->layout_mode = u;
175 }
176 }
177-@@ -1481,6 +1490,7 @@ cc_display_config_dbus_class_init (CcDis
178+@@ -1481,6 +1490,7 @@ cc_display_config_dbus_class_init (CcDisplayConfigDBusClass *klass)
179 parent_class->set_cloning = cc_display_config_dbus_set_cloning;
180 parent_class->get_cloning_modes = cc_display_config_dbus_get_cloning_modes;
181 parent_class->is_layout_logical = cc_display_config_dbus_is_layout_logical;
182@@ -197,11 +197,50 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config-dbus.c
183
184 pspec = g_param_spec_variant ("state",
185 "GVariant",
186-Index: gnome-control-center-3.32.1/panels/display/cc-display-config.c
187-===================================================================
188---- gnome-control-center-3.32.1.orig/panels/display/cc-display-config.c
189-+++ gnome-control-center-3.32.1/panels/display/cc-display-config.c
190-@@ -568,3 +568,9 @@ cc_display_config_is_layout_logical (CcD
191+@@ -1541,6 +1551,26 @@ logical_monitor_is_rotated (CcDisplayLogicalMonitor *lm)
192+ }
193+ }
194+
195++static double
196++get_maximum_scale (CcDisplayConfig *config)
197++{
198++ GList *outputs, *l;
199++ double max_scale = 1.0;
200++ outputs = cc_display_config_get_monitors (config);
201++
202++ for (l = outputs; l; l = l->next)
203++ {
204++ CcDisplayMonitor *output = l->data;
205++
206++ if (!cc_display_monitor_is_useful (output))
207++ continue;
208++
209++ max_scale = MAX (max_scale, cc_display_monitor_get_scale (output));
210++ }
211++
212++ return max_scale;
213++}
214++
215+ static int
216+ logical_monitor_width (CcDisplayLogicalMonitor *lm)
217+ {
218+@@ -1559,6 +1589,11 @@ logical_monitor_width (CcDisplayLogicalMonitor *lm)
219+
220+ if (monitor->config->layout_mode == CC_DISPLAY_LAYOUT_MODE_LOGICAL)
221+ return round (width / lm->scale);
222++ if (monitor->config->layout_mode == CC_DISPLAY_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
223++ {
224++ double max_scale = get_maximum_scale(CC_DISPLAY_CONFIG (monitor->config));
225++ return round ((width * ceil (max_scale)) / lm->scale);
226++ }
227+ else
228+ return width;
229+ }
230+diff --git a/panels/display/cc-display-config.c b/panels/display/cc-display-config.c
231+index 3bed67a..00696ad 100644
232+--- a/panels/display/cc-display-config.c
233++++ b/panels/display/cc-display-config.c
234+@@ -568,3 +568,9 @@ cc_display_config_is_layout_logical (CcDisplayConfig *self)
235 {
236 return CC_DISPLAY_CONFIG_GET_CLASS (self)->is_layout_logical (self);
237 }
238@@ -211,10 +250,10 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config.c
239 +{
240 + return CC_DISPLAY_CONFIG_GET_CLASS (self)->layout_use_ui_scale (self);
241 +}
242-Index: gnome-control-center-3.32.1/panels/display/cc-display-config.h
243-===================================================================
244---- gnome-control-center-3.32.1.orig/panels/display/cc-display-config.h
245-+++ gnome-control-center-3.32.1/panels/display/cc-display-config.h
246+diff --git a/panels/display/cc-display-config.h b/panels/display/cc-display-config.h
247+index faeae8e..27b939a 100644
248+--- a/panels/display/cc-display-config.h
249++++ b/panels/display/cc-display-config.h
250 @@ -154,6 +154,7 @@ struct _CcDisplayConfigClass
251 gboolean clone);
252 GList* (*get_cloning_modes) (CcDisplayConfig *self);
253@@ -223,7 +262,7 @@ Index: gnome-control-center-3.32.1/panels/display/cc-display-config.h
254 };
255
256
257-@@ -174,6 +175,7 @@ void cc_display_config_set_
258+@@ -174,6 +175,7 @@ void cc_display_config_set_mode_on_all_outputs (CcDisplayConfig *co
259 CcDisplayMode *mode);
260
261 gboolean cc_display_config_is_layout_logical (CcDisplayConfig *self);

Subscribers

People subscribed via source and target branches