Merge ~3v1n0/ubuntu/+source/mutter:ubuntu/xrandr-scaling into ~ubuntu-desktop/ubuntu/+source/mutter:ubuntu/master

Proposed by Marco Trevisan (Treviño) on 2019-04-06
Status: Merged
Merged at revision: 008842e3bdbf1c9ce17953ca5c5d8eec4570aee8
Proposed branch: ~3v1n0/ubuntu/+source/mutter:ubuntu/xrandr-scaling
Merge into: ~ubuntu-desktop/ubuntu/+source/mutter:ubuntu/master
Diff against target: 697 lines (+257/-99)
2 files modified
debian/changelog (+5/-0)
debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch (+252/-99)
Reviewer Review Type Date Requested Status
Daniel van Vugt (community) Approve on 2019-04-09
Ubuntu Desktop 2019-04-06 Pending
Review via email: mp+365624@code.launchpad.net
To post a comment you must log in.
Daniel van Vugt (vanvugt) wrote :
review: Needs Fixing
Marco Trevisan (Treviño) (3v1n0) wrote :

> The fix for bug 1822616 isn't working yet, at least:
>
> https://bugs.launchpad.net/ubuntu/+source/budgie-
> desktop/+bug/1822616/comments/11

This was also the check I wanted to add, but before I wanted to be sure we rebuilt all the monitor modes.

Anyways, I've added this further check too, so it's now all fine.

Daniel van Vugt (vanvugt) wrote :

Looks OK, but of course it's too hard to be sure. I don't really know this area of code.

Notes:

(1) The fix for bug 1822616 looks good now.

(2) Upstream will (eventually) ask you to reformat function parameters to be one parameter per line. Remember to do that (some time).

(3) Another formatting nit: Indentation in apply_crtc_assignments

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 67c17c0..f11f75b 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -3,6 +3,11 @@ mutter (3.32.0-1ubuntu2) UNRELEASED; urgency=medium
6 * debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch:
7 - Don't invert the screen size when rotation is enabled (LP: #1822513)
8 - Remove unneeded cleanup changes
9+ - Use xcb checked function to set scaling to catch errors
10+ - Update screen size only after monitors modes have been derived
11+ (LP: #1822616)
12+ - Trigger a monitors rebuild only if scale has changed (LP: #1823485)
13+ - Only update UI scaling when output scaling is enabled (LP: #1822478)
14
15 -- Marco Trevisan (Treviño) <marco@ubuntu.com> Wed, 03 Apr 2019 19:19:59 -0400
16
17diff --git a/debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch b/debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch
18index ea6c35f..90c17a9 100644
19--- a/debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch
20+++ b/debian/patches/x11-Add-support-for-fractional-scaling-using-Randr.patch
21@@ -1,13 +1,6 @@
22-From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
23+From: =?utf-8?b?Ik1hcmNvIFRyZXZpc2FuIChUcmV2acOxbyki?= <mail@3v1n0.net>
24 Date: Wed, 3 Apr 2019 19:18:03 -0400
25 Subject: x11-Add-support-for-fractional-scaling-using-Randr
26-MIME-Version: 1.0
27-Content-Type: text/plain; charset="utf-8"
28-Content-Transfer-Encoding: 8bit
29-
30-commit ed760c44b1998fc5fadde18186c51e74525038cc
31-Author: Marco Trevisan (Treviño) <mail@3v1n0.net>
32-Date: Wed Apr 3 18:57:28 2019 -0400
33
34 Add scaling support using randr under x11.
35
36@@ -19,31 +12,31 @@ Forwarded: No, forwarding is in progress and planned though
37 data/org.gnome.mutter.gschema.xml.in | 5 +
38 data/org.gnome.mutter.x11.gschema.xml.in | 30 ++
39 src/backends/meta-crtc.h | 1 +
40- src/backends/meta-monitor-config-manager.c | 150 +++++++++-
41+ src/backends/meta-monitor-config-manager.c | 150 +++++++-
42 src/backends/meta-monitor-config-migration.c | 15 +-
43 src/backends/meta-monitor-config-store.c | 1 +
44 src/backends/meta-monitor-manager-dummy.c | 24 +-
45- src/backends/meta-monitor-manager-private.h | 28 +-
46- src/backends/meta-monitor-manager.c | 349 ++++++++++++++++++---
47- src/backends/meta-monitor.c | 60 ++--
48+ src/backends/meta-monitor-manager-private.h | 34 +-
49+ src/backends/meta-monitor-manager.c | 353 ++++++++++++++++--
50+ src/backends/meta-monitor.c | 60 +--
51 src/backends/meta-monitor.h | 6 +-
52 src/backends/meta-settings-private.h | 9 +
53- src/backends/meta-settings.c | 76 ++++-
54+ src/backends/meta-settings.c | 76 +++-
55 src/backends/native/meta-monitor-manager-kms.c | 44 ++-
56- src/backends/x11/meta-crtc-xrandr.c | 87 +++++-
57+ src/backends/x11/meta-crtc-xrandr.c | 86 ++++-
58 src/backends/x11/meta-crtc-xrandr.h | 13 +-
59- src/backends/x11/meta-gpu-xrandr.c | 89 +++++-
60+ src/backends/x11/meta-gpu-xrandr.c | 89 ++++-
61 src/backends/x11/meta-gpu-xrandr.h | 4 +
62- src/backends/x11/meta-monitor-manager-xrandr.c | 399 +++++++++++++++++--------
63+ src/backends/x11/meta-monitor-manager-xrandr.c | 485 ++++++++++++++++++-------
64 src/backends/x11/meta-monitor-manager-xrandr.h | 4 +-
65 src/backends/x11/meta-output-xrandr.c | 5 +-
66- src/compositor/compositor.c | 54 ++++
67+ src/compositor/compositor.c | 54 +++
68 src/core/boxes-private.h | 4 +
69 src/core/boxes.c | 21 ++
70- src/core/window.c | 19 ++
71+ src/core/window.c | 19 +
72 src/org.gnome.Mutter.DisplayConfig.xml | 5 +
73 src/tests/meta-monitor-manager-test.c | 14 +-
74- 28 files changed, 1269 insertions(+), 254 deletions(-)
75+ 28 files changed, 1358 insertions(+), 260 deletions(-)
76 create mode 100644 data/org.gnome.mutter.x11.gschema.xml.in
77
78 diff --git a/data/meson.build b/data/meson.build
79@@ -630,7 +623,7 @@ index 46c3b8c..29fde36 100644
80 settings,
81 META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER))
82 diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
83-index 3b951c6..3b375a0 100644
84+index 3b951c6..2ba9ced 100644
85 --- a/src/backends/meta-monitor-manager-private.h
86 +++ b/src/backends/meta-monitor-manager-private.h
87 @@ -44,7 +44,9 @@ typedef enum _MetaMonitorManagerCapability
88@@ -670,7 +663,27 @@ index 3b951c6..3b375a0 100644
89
90 GList *logical_monitors;
91 MetaLogicalMonitor *primary_logical_monitor;
92-@@ -229,9 +234,10 @@ struct _MetaMonitorManagerClass
93+@@ -156,6 +161,9 @@ struct _MetaMonitorManager
94+ * @apply_monitors_config: Tries to apply the given config using the given
95+ * method. Throws an error if something went wrong.
96+ *
97++ * @update_screen_size_derived: Computes the screen size for derived
98++ * configuration.
99++ *
100+ * @set_power_save_mode: Sets the #MetaPowerSave mode (for all displays).
101+ *
102+ * @change_backlight: Changes the backlight intensity to the given value (in
103+@@ -199,6 +207,9 @@ struct _MetaMonitorManagerClass
104+ MetaMonitorsConfigMethod ,
105+ GError **);
106+
107++ void (*update_screen_size_derived) (MetaMonitorManager *,
108++ MetaMonitorsConfig *);
109++
110+ void (*set_power_save_mode) (MetaMonitorManager *,
111+ MetaPowerSave);
112+
113+@@ -229,9 +240,10 @@ struct _MetaMonitorManagerClass
114 MetaCrtc *,
115 MetaMonitorTransform);
116
117@@ -684,7 +697,7 @@ index 3b951c6..3b375a0 100644
118
119 float * (*calculate_supported_scales) (MetaMonitorManager *,
120 MetaLogicalMonitorLayoutMode ,
121-@@ -350,9 +356,10 @@ void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManage
122+@@ -350,9 +362,10 @@ void meta_monitor_manager_lid_is_closed_changed (MetaMonitorManage
123
124 gboolean meta_monitor_manager_is_headless (MetaMonitorManager *manager);
125
126@@ -698,7 +711,7 @@ index 3b951c6..3b375a0 100644
127
128 float * meta_monitor_manager_calculate_supported_scales (MetaMonitorManager *,
129 MetaLogicalMonitorLayoutMode ,
130-@@ -366,6 +373,11 @@ gboolean meta_monitor_manager_is_scale_supported (MetaMonitorManager
131+@@ -366,6 +379,11 @@ gboolean meta_monitor_manager_is_scale_supported (MetaMonitorManager
132 MetaMonitorMode *monitor_mode,
133 float scale);
134
135@@ -711,7 +724,7 @@ index 3b951c6..3b375a0 100644
136 meta_monitor_manager_get_capabilities (MetaMonitorManager *manager);
137
138 diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
139-index c4ed245..8b5b983 100644
140+index c4ed245..d055eec 100644
141 --- a/src/backends/meta-monitor-manager.c
142 +++ b/src/backends/meta-monitor-manager.c
143 @@ -104,8 +104,18 @@ static gboolean
144@@ -1268,6 +1281,21 @@ index c4ed245..8b5b983 100644
145
146 meta_monitor_manager_rebuild_logical_monitors_derived (manager, config);
147 }
148+@@ -2910,10 +3181,14 @@ void
149+ meta_monitor_manager_rebuild_derived (MetaMonitorManager *manager,
150+ MetaMonitorsConfig *config)
151+ {
152++ MetaMonitorManagerClass *klass = META_MONITOR_MANAGER_GET_CLASS (manager);
153+ GList *old_logical_monitors;
154+
155+ meta_monitor_manager_update_monitor_modes_derived (manager);
156+
157++ if (klass->update_screen_size_derived)
158++ klass->update_screen_size_derived (manager, config);
159++
160+ if (manager->in_init)
161+ return;
162+
163 diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
164 index 22a3e45..d1f73a1 100644
165 --- a/src/backends/meta-monitor.c
166@@ -1680,7 +1708,7 @@ index c9a3cab..da3a619 100644
167 if (meta_settings_is_experimental_feature_enabled (
168 settings,
169 diff --git a/src/backends/x11/meta-crtc-xrandr.c b/src/backends/x11/meta-crtc-xrandr.c
170-index d201b85..7aa1b6c 100644
171+index d201b85..212a424 100644
172 --- a/src/backends/x11/meta-crtc-xrandr.c
173 +++ b/src/backends/x11/meta-crtc-xrandr.c
174 @@ -36,6 +36,7 @@
175@@ -1699,7 +1727,7 @@ index d201b85..7aa1b6c 100644
176
177 gboolean
178 meta_crtc_xrandr_set_config (MetaCrtc *crtc,
179-@@ -97,6 +99,62 @@ meta_crtc_xrandr_set_config (MetaCrtc *crtc,
180+@@ -97,6 +99,61 @@ meta_crtc_xrandr_set_config (MetaCrtc *crtc,
181 *out_timestamp = reply->timestamp;
182 free (reply);
183
184@@ -1743,11 +1771,10 @@ index d201b85..7aa1b6c 100644
185 + else
186 + scale_filter = FilterFast;
187 +
188-+ transform_cookie = xcb_randr_set_crtc_transform (xcb_conn, xrandr_crtc,
189-+ transformation,
190-+ strlen (scale_filter),
191-+ scale_filter,
192-+ 0, NULL);
193++ transform_cookie =
194++ xcb_randr_set_crtc_transform_checked (xcb_conn, xrandr_crtc, transformation,
195++ strlen (scale_filter), scale_filter,
196++ 0, NULL);
197 +
198 + xcb_error = xcb_request_check (xcb_conn, transform_cookie);
199 + if (xcb_error)
200@@ -1762,7 +1789,7 @@ index d201b85..7aa1b6c 100644
201 return TRUE;
202 }
203
204-@@ -171,11 +229,31 @@ meta_monitor_transform_from_xrandr_all (Rotation rotation)
205+@@ -171,11 +228,31 @@ meta_monitor_transform_from_xrandr_all (Rotation rotation)
206 return ret;
207 }
208
209@@ -1798,7 +1825,7 @@ index d201b85..7aa1b6c 100644
210 {
211 MetaCrtc *crtc;
212 unsigned int i;
213-@@ -194,6 +272,7 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr,
214+@@ -194,6 +271,7 @@ meta_create_xrandr_crtc (MetaGpuXrandr *gpu_xrandr,
215 meta_monitor_transform_from_xrandr (xrandr_crtc->rotation);
216 crtc->all_transforms =
217 meta_monitor_transform_from_xrandr_all (xrandr_crtc->rotations);
218@@ -1996,7 +2023,7 @@ index aad49d0..4ac32b9 100644
219 int *max_width,
220 int *max_height);
221 diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
222-index 784bbde..47d19d6 100644
223+index 784bbde..246b66d 100644
224 --- a/src/backends/x11/meta-monitor-manager-xrandr.c
225 +++ b/src/backends/x11/meta-monitor-manager-xrandr.c
226 @@ -63,6 +63,9 @@
227@@ -2099,9 +2126,28 @@ index 784bbde..47d19d6 100644
228 static xcb_randr_rotation_t
229 meta_monitor_transform_to_xrandr (MetaMonitorTransform transform)
230 {
231-@@ -204,9 +256,10 @@ xrandr_set_crtc_config (MetaMonitorManagerXrandr *manager_xrandr,
232+@@ -203,13 +255,36 @@ xrandr_set_crtc_config (MetaMonitorManagerXrandr *manager_xrandr,
233+ return TRUE;
234 }
235
236++static float
237++get_maximum_crtc_info_scale (MetaCrtcInfo **crtc_infos,
238++ unsigned int n_crtc_infos)
239++{
240++ float max_scale = 1.0f;
241++ unsigned int i;
242++
243++ for (i = 0; i < n_crtc_infos; i++)
244++ {
245++ MetaCrtcInfo *crtc_info = crtc_infos[i];
246++
247++ if (crtc_info->mode)
248++ max_scale = MAX (max_scale, crtc_info->scale);
249++ }
250++
251++ return max_scale;
252++}
253++
254 static gboolean
255 -is_crtc_assignment_changed (MetaCrtc *crtc,
256 - MetaCrtcInfo **crtc_infos,
257@@ -2111,23 +2157,54 @@ index 784bbde..47d19d6 100644
258 + MetaCrtcInfo **crtc_infos,
259 + unsigned int n_crtc_infos)
260 {
261++ gboolean have_scaling;
262 unsigned int i;
263
264-@@ -230,6 +283,13 @@ is_crtc_assignment_changed (MetaCrtc *crtc,
265++ have_scaling = meta_monitor_manager_get_capabilities (monitor_manager) &
266++ META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING;
267++
268+ for (i = 0; i < n_crtc_infos; i++)
269+ {
270+ MetaCrtcInfo *crtc_info = crtc_infos[i];
271+@@ -230,6 +305,37 @@ is_crtc_assignment_changed (MetaCrtc *crtc,
272 if (crtc->transform != crtc_info->transform)
273 return TRUE;
274
275-+ if ((meta_monitor_manager_get_capabilities (monitor_manager) &
276-+ META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING))
277++ if (have_scaling)
278 + {
279-+ if (fabs (crtc->scale - crtc_info->scale) > 0.001)
280++ float crtc_scale = crtc->scale;
281++ float req_output_scale = crtc_info->scale;
282++ MetaLogicalMonitorLayoutMode layout_mode =
283++ meta_monitor_manager_get_default_layout_mode (monitor_manager);
284++
285++ if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
286++ {
287++ float max_crtc_scale =
288++ meta_monitor_manager_get_maximum_crtc_scale (monitor_manager);
289++ float max_req_scale =
290++ get_maximum_crtc_info_scale (crtc_infos, n_crtc_infos);
291++
292++ /* In scale ui-down mode we need to check if the actual output
293++ * scale that will be applied to the crtc has actually changed
294++ * from the current value, so we need to compare the current crtc
295++ * scale with the scale that will be applied taking care of the
296++ * UI scale (max crtc scale) and of the requested maximum scale.
297++ * If we don't do this, we'd try to call randr calls which won't
298++ * ever trigger a RRScreenChangeNotify, as no actual change is
299++ * needed, and thus we won't ever emit a monitors-changed signal.
300++ */
301++ crtc_scale /= ceilf (max_crtc_scale);
302++ req_output_scale /= ceilf (max_req_scale);
303++ }
304++
305++ if (fabs (crtc_scale - req_output_scale) > 0.001)
306 + return TRUE;
307 + }
308 +
309 for (j = 0; j < crtc_info->outputs->len; j++)
310 {
311 MetaOutput *output = ((MetaOutput**) crtc_info->outputs->pdata)[j];
312-@@ -315,7 +375,7 @@ is_assignments_changed (MetaMonitorManager *manager,
313+@@ -315,7 +421,7 @@ is_assignments_changed (MetaMonitorManager *manager,
314 {
315 MetaCrtc *crtc = l->data;
316
317@@ -2136,7 +2213,40 @@ index 784bbde..47d19d6 100644
318 return TRUE;
319 }
320
321-@@ -343,33 +403,67 @@ apply_crtc_assignments (MetaMonitorManager *manager,
322+@@ -331,6 +437,32 @@ is_assignments_changed (MetaMonitorManager *manager,
323+ return TRUE;
324+ }
325+
326++ if (meta_monitor_manager_get_default_layout_mode (manager) ==
327++ META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
328++ {
329++ /* If nothing has changed, ensure that the crtc logical scaling matches
330++ * with the requested one, as in case of global UI logical layout we might
331++ * assume that it is in fact equal, while it's techincally different.
332++ * Not doing this would then cause a wrong computation of the max crtc
333++ * scale and thus of the UI scaling. */
334++ for (l = meta_gpu_get_crtcs (manager_xrandr->gpu); l; l = l->next)
335++ {
336++ MetaCrtc *crtc = l->data;
337++ unsigned int i;
338++
339++ for (i = 0; i < n_crtc_infos; i++)
340++ {
341++ MetaCrtcInfo *crtc_info = crtc_infos[i];
342++
343++ if (crtc_info->crtc == crtc)
344++ {
345++ crtc->scale = crtc_info->scale;
346++ break;
347++ }
348++ }
349++ }
350++ }
351++
352+ return FALSE;
353+ }
354+
355+@@ -343,33 +475,57 @@ apply_crtc_assignments (MetaMonitorManager *manager,
356 unsigned int n_outputs)
357 {
358 MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager);
359@@ -2158,22 +2268,11 @@ index 784bbde..47d19d6 100644
360 + have_scaling = meta_monitor_manager_get_capabilities (manager) &
361 + META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING;
362 +
363-+ valid_crtcs = 0;
364-+ max_scale = 1.0f;
365-+ for (i = 0; i < n_crtcs; i++)
366-+ {
367-+ MetaCrtcInfo *crtc_info = crtcs[i];
368-+
369-+ if (crtc_info->mode == NULL)
370-+ continue;
371-+
372-+ valid_crtcs++;
373-+ max_scale = MAX (max_scale, crtc_info->scale);
374-+ }
375-+
376 + /* Compute the new size of the screen (framebuffer) */
377++ max_scale = get_maximum_crtc_info_scale (crtcs, n_crtcs);
378 width = 0; height = 0;
379 + avg_screen_scale = 0;
380++ valid_crtcs = 0;
381 for (i = 0; i < n_crtcs; i++)
382 {
383 MetaCrtcInfo *crtc_info = crtcs[i];
384@@ -2207,15 +2306,18 @@ index 784bbde..47d19d6 100644
385 + roundf (crtc_info->mode->height * scale));
386 }
387 +
388-+ avg_screen_scale += crtc_info->scale / (float) valid_crtcs;
389++ avg_screen_scale += (crtc_info->scale - avg_screen_scale) /
390++ (float) (++valid_crtcs);
391 }
392
393 /* Second disable all newly disabled CRTCs, or CRTCs that in the previous
394-@@ -394,12 +488,14 @@ apply_crtc_assignments (MetaMonitorManager *manager,
395+@@ -394,12 +550,16 @@ apply_crtc_assignments (MetaMonitorManager *manager,
396 0, 0, XCB_NONE,
397 XCB_RANDR_ROTATION_ROTATE_0,
398 NULL, 0);
399-+ meta_crtc_xrandr_set_scale (crtc, (xcb_randr_crtc_t) crtc->crtc_id, 1);
400++ if (have_scaling)
401++ meta_crtc_xrandr_set_scale (crtc,
402++ (xcb_randr_crtc_t) crtc->crtc_id, 1.0f);
403
404 crtc->rect.x = 0;
405 crtc->rect.y = 0;
406@@ -2226,11 +2328,13 @@ index 784bbde..47d19d6 100644
407 }
408 }
409
410-@@ -424,25 +520,18 @@ apply_crtc_assignments (MetaMonitorManager *manager,
411+@@ -424,25 +584,20 @@ apply_crtc_assignments (MetaMonitorManager *manager,
412 0, 0, XCB_NONE,
413 XCB_RANDR_ROTATION_ROTATE_0,
414 NULL, 0);
415-+ meta_crtc_xrandr_set_scale (crtc, (xcb_randr_crtc_t) crtc->crtc_id, 1.0f);
416++ if (have_scaling)
417++ meta_crtc_xrandr_set_scale (crtc,
418++ (xcb_randr_crtc_t) crtc->crtc_id, 1.0f);
419
420 crtc->rect.x = 0;
421 crtc->rect.y = 0;
422@@ -2256,7 +2360,7 @@ index 784bbde..47d19d6 100644
423
424 for (i = 0; i < n_crtcs; i++)
425 {
426-@@ -455,12 +544,21 @@ apply_crtc_assignments (MetaMonitorManager *manager,
427+@@ -455,12 +610,21 @@ apply_crtc_assignments (MetaMonitorManager *manager,
428 g_autofree xcb_randr_output_t *output_ids = NULL;
429 unsigned int j, n_output_ids;
430 xcb_randr_rotation_t rotation;
431@@ -2278,7 +2382,7 @@ index 784bbde..47d19d6 100644
432 for (j = 0; j < n_output_ids; j++)
433 {
434 MetaOutput *output;
435-@@ -473,6 +571,20 @@ apply_crtc_assignments (MetaMonitorManager *manager,
436+@@ -473,6 +637,20 @@ apply_crtc_assignments (MetaMonitorManager *manager,
437 output_ids[j] = output->winsys_id;
438 }
439
440@@ -2299,7 +2403,7 @@ index 784bbde..47d19d6 100644
441 rotation = meta_monitor_transform_to_xrandr (crtc_info->transform);
442 if (!xrandr_set_crtc_config (manager_xrandr,
443 crtc,
444-@@ -508,6 +620,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
445+@@ -508,6 +686,7 @@ apply_crtc_assignments (MetaMonitorManager *manager,
446 crtc->rect.height = height;
447 crtc->current_mode = mode;
448 crtc->transform = crtc_info->transform;
449@@ -2307,7 +2411,14 @@ index 784bbde..47d19d6 100644
450 }
451 }
452
453-@@ -568,8 +681,56 @@ meta_monitor_manager_xrandr_rebuild_derived (MetaMonitorManager *manager,
454+@@ -563,14 +742,61 @@ meta_monitor_manager_xrandr_ensure_initial_config (MetaMonitorManager *manager)
455+ }
456+
457+ static void
458+-meta_monitor_manager_xrandr_rebuild_derived (MetaMonitorManager *manager,
459+- MetaMonitorsConfig *config)
460++meta_monitor_manager_xrandr_update_screen_size_derived (MetaMonitorManager *manager,
461++ MetaMonitorsConfig *config)
462 {
463 MetaMonitorManagerXrandr *manager_xrandr =
464 META_MONITOR_MANAGER_XRANDR (manager);
465@@ -2320,7 +2431,9 @@ index 784bbde..47d19d6 100644
466 + float average_scale = 0;
467 + gboolean have_scaling;
468 + GList *l;
469-+
470+
471+- g_clear_pointer (&manager_xrandr->supported_scales, g_free);
472+- meta_monitor_manager_rebuild_derived (manager, config);
473 + have_scaling = meta_monitor_manager_get_capabilities (manager) &
474 + META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING;
475 +
476@@ -2357,34 +2470,51 @@ index 784bbde..47d19d6 100644
477 + average_scale += (crtc->scale - average_scale) / (float) n_crtcs;
478 + }
479 +
480-+ meta_monitor_manager_xrandr_update_screen_size (manager_xrandr,
481-+ screen_width, screen_height,
482-+ average_scale);
483-
484-- g_clear_pointer (&manager_xrandr->supported_scales, g_free);
485- meta_monitor_manager_rebuild_derived (manager, config);
486++ if (screen_width > 0 && screen_height > 0)
487++ meta_monitor_manager_xrandr_update_screen_size (manager_xrandr,
488++ screen_width, screen_height,
489++ average_scale);
490 }
491
492-@@ -595,6 +756,9 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
493+ static gboolean
494+@@ -584,7 +810,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
495
496- if (method != META_MONITORS_CONFIG_METHOD_VERIFY)
497+ if (!config)
498 {
499-+ MetaBackend *backend = meta_monitor_manager_get_backend (manager);
500-+ MetaSettings *settings = meta_backend_get_settings (backend);
501+- meta_monitor_manager_xrandr_rebuild_derived (manager, NULL);
502++ meta_monitor_manager_rebuild_derived (manager, NULL);
503+ return TRUE;
504+ }
505+
506+@@ -609,16 +835,26 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
507+ (MetaOutputInfo **) output_infos->pdata,
508+ output_infos->len))
509+ {
510++ MetaLogicalMonitorLayoutMode layout_mode =
511++ meta_monitor_manager_get_default_layout_mode (manager);
512 +
513- /*
514- * If the assignment has not changed, we won't get any notification about
515- * any new configuration from the X server; but we still need to update
516-@@ -615,6 +779,8 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
517+ apply_crtc_assignments (manager,
518+ TRUE,
519+ (MetaCrtcInfo **) crtc_infos->pdata,
520 crtc_infos->len,
521 (MetaOutputInfo **) output_infos->pdata,
522 output_infos->len);
523 +
524-+ meta_settings_update_ui_scaling_factor (settings);
525++ if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
526++ {
527++ MetaBackend *backend = meta_monitor_manager_get_backend (manager);
528++ MetaSettings *settings = meta_backend_get_settings (backend);
529++ meta_settings_update_ui_scaling_factor (settings);
530++ }
531 }
532 else
533 {
534-@@ -748,7 +914,8 @@ meta_monitor_manager_xrandr_tiled_monitor_added (MetaMonitorManager *manager,
535+- meta_monitor_manager_xrandr_rebuild_derived (manager, config);
536++ meta_monitor_manager_rebuild_derived (manager, config);
537+ }
538+ }
539+
540+@@ -748,7 +984,8 @@ meta_monitor_manager_xrandr_tiled_monitor_added (MetaMonitorManager *manager,
541 GList *l;
542 int i;
543
544@@ -2394,7 +2524,7 @@ index 784bbde..47d19d6 100644
545 return;
546
547 product = meta_monitor_get_product (monitor);
548-@@ -797,7 +964,8 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
549+@@ -797,7 +1034,8 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
550
551 int monitor_count;
552
553@@ -2404,7 +2534,7 @@ index 784bbde..47d19d6 100644
554 return;
555
556 monitor_xrandr_data = meta_monitor_xrandr_data_from_monitor (monitor);
557-@@ -815,10 +983,12 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
558+@@ -815,10 +1053,12 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
559 static void
560 meta_monitor_manager_xrandr_init_monitors (MetaMonitorManagerXrandr *manager_xrandr)
561 {
562@@ -2418,7 +2548,7 @@ index 784bbde..47d19d6 100644
563 return;
564
565 /* delete any tiled monitors setup, as mutter will want to recreate
566-@@ -849,83 +1019,26 @@ meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager,
567+@@ -849,83 +1089,26 @@ meta_monitor_manager_xrandr_is_transform_handled (MetaMonitorManager *manager,
568 return TRUE;
569 }
570
571@@ -2431,7 +2561,8 @@ index 784bbde..47d19d6 100644
572 {
573 - return meta_monitor_calculate_mode_scale (monitor, monitor_mode);
574 -}
575--
576++ MetaMonitorScalesConstraint constraints = 0;
577+
578 -static void
579 -add_supported_scale (GArray *supported_scales,
580 - float scale)
581@@ -2441,15 +2572,14 @@ index 784bbde..47d19d6 100644
582 - for (i = 0; i < supported_scales->len; i++)
583 - {
584 - float supported_scale = g_array_index (supported_scales, float, i);
585-+ MetaMonitorScalesConstraint constraints = 0;
586-
587-- if (scale == supported_scale)
588-- return;
589-- }
590 + if (meta_monitor_manager_get_capabilities (manager) &
591 + META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED)
592 + constraints |= META_MONITOR_SCALES_CONSTRAINT_NO_FRAC;
593
594+- if (scale == supported_scale)
595+- return;
596+- }
597+-
598 - g_array_append_val (supported_scales, scale);
599 + return constraints;
600 }
601@@ -2516,7 +2646,7 @@ index 784bbde..47d19d6 100644
602 }
603
604 static float *
605-@@ -935,21 +1048,35 @@ meta_monitor_manager_xrandr_calculate_supported_scales (MetaMonitorManager
606+@@ -935,21 +1118,35 @@ meta_monitor_manager_xrandr_calculate_supported_scales (MetaMonitorManager
607 MetaMonitorMode *monitor_mode,
608 int *n_supported_scales)
609 {
610@@ -2562,7 +2692,7 @@ index 784bbde..47d19d6 100644
611 }
612
613 static gboolean
614-@@ -966,9 +1093,30 @@ meta_monitor_manager_xrandr_get_max_screen_size (MetaMonitorManager *manager,
615+@@ -966,9 +1163,34 @@ meta_monitor_manager_xrandr_get_max_screen_size (MetaMonitorManager *manager,
616 return TRUE;
617 }
618
619@@ -2570,6 +2700,10 @@ index 784bbde..47d19d6 100644
620 +scale_mode_changed (MetaSettings *settings,
621 + MetaMonitorManager *manager)
622 +{
623++ if (!(meta_monitor_manager_get_capabilities(manager) &
624++ META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING))
625++ return;
626++
627 + meta_monitor_manager_on_hotplug (manager);
628 + meta_settings_update_ui_scaling_factor (settings);
629 +}
630@@ -2593,7 +2727,7 @@ index 784bbde..47d19d6 100644
631 return META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL;
632 }
633
634-@@ -978,10 +1126,15 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
635+@@ -978,10 +1200,11 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
636 MetaMonitorManagerXrandr *manager_xrandr =
637 META_MONITOR_MANAGER_XRANDR (object);
638 MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
639@@ -2602,17 +2736,13 @@ index 784bbde..47d19d6 100644
640 + MetaBackend *backend = meta_monitor_manager_get_backend (manager);
641 + MetaSettings *settings = meta_backend_get_settings (backend);
642 + MetaBackendX11 *x11_backend = META_BACKEND_X11 (backend);
643-+
644-+ manager_xrandr->xdisplay = meta_backend_x11_get_xdisplay (x11_backend);
645
646 - manager_xrandr->xdisplay = meta_backend_x11_get_xdisplay (backend);
647-+ meta_settings_update_ui_scaling_factor (settings);
648-+ g_signal_connect_object (settings, "x11-scale-mode-changed",
649-+ G_CALLBACK (scale_mode_changed), manager_xrandr, 0);
650++ manager_xrandr->xdisplay = meta_backend_x11_get_xdisplay (x11_backend);
651
652 manager_xrandr->gpu = META_GPU (meta_gpu_xrandr_new (manager_xrandr));
653 meta_monitor_manager_add_gpu (manager, manager_xrandr->gpu);
654-@@ -1003,16 +1156,13 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
655+@@ -1003,19 +1226,19 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
656 | RRCrtcChangeNotifyMask
657 | RROutputPropertyNotifyMask);
658
659@@ -2634,7 +2764,13 @@ index 784bbde..47d19d6 100644
660 meta_monitor_manager_xrandr_init_monitors (manager_xrandr);
661 }
662
663-@@ -1026,7 +1176,6 @@ meta_monitor_manager_xrandr_finalize (GObject *object)
664++ g_signal_connect_object (settings, "x11-scale-mode-changed",
665++ G_CALLBACK (scale_mode_changed), manager_xrandr, 0);
666++
667+ G_OBJECT_CLASS (meta_monitor_manager_xrandr_parent_class)->constructed (object);
668+ }
669+
670+@@ -1026,7 +1249,6 @@ meta_monitor_manager_xrandr_finalize (GObject *object)
671
672 g_clear_object (&manager_xrandr->gpu);
673 g_hash_table_destroy (manager_xrandr->tiled_monitor_atoms);
674@@ -2642,6 +2778,23 @@ index 784bbde..47d19d6 100644
675
676 G_OBJECT_CLASS (meta_monitor_manager_xrandr_parent_class)->finalize (object);
677 }
678+@@ -1048,6 +1270,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
679+ manager_class->read_edid = meta_monitor_manager_xrandr_read_edid;
680+ manager_class->ensure_initial_config = meta_monitor_manager_xrandr_ensure_initial_config;
681+ manager_class->apply_monitors_config = meta_monitor_manager_xrandr_apply_monitors_config;
682++ manager_class->update_screen_size_derived = meta_monitor_manager_xrandr_update_screen_size_derived;
683+ manager_class->set_power_save_mode = meta_monitor_manager_xrandr_set_power_save_mode;
684+ manager_class->change_backlight = meta_monitor_manager_xrandr_change_backlight;
685+ manager_class->get_crtc_gamma = meta_monitor_manager_xrandr_get_crtc_gamma;
686+@@ -1108,7 +1331,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
687+ config = NULL;
688+ }
689+
690+- meta_monitor_manager_xrandr_rebuild_derived (manager, config);
691++ meta_monitor_manager_rebuild_derived (manager, config);
692+ }
693+
694+ return TRUE;
695 diff --git a/src/backends/x11/meta-monitor-manager-xrandr.h b/src/backends/x11/meta-monitor-manager-xrandr.h
696 index d55b3d2..515f938 100644
697 --- a/src/backends/x11/meta-monitor-manager-xrandr.h

Subscribers

People subscribed via source and target branches