1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
Description: Read display scaling from gsettings.
Author: Chad MILLER <chad.miller@canonical.com>
Forwarded: yes
--- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -7,7 +7,12 @@
#include <X11/extensions/Xrandr.h>
#include <X11/Xlib.h>
-// It clashes with out RootWindow.
+#ifdef USE_GLIB
+#include <gio/gio.h>
+#include <glib.h>
+#endif
+
+// It clashes with our RootWindow.
#undef RootWindow
#include "base/debug/trace_event.h"
@@ -307,6 +312,29 @@ std::vector<gfx::Display> DesktopScreenX
return GetFallbackDisplayList();
}
+#ifdef USE_GLIB
+ GSettingsSchemaSource* gsettings_schema_source =
+ g_settings_schema_source_get_default();
+ GSettingsSchema* gsettings_schema =
+ g_settings_schema_source_lookup(gsettings_schema_source,
+ "com.ubuntu.user-interface", TRUE);
+
+ GVariant* display_scales = NULL;
+ if (gsettings_schema != NULL) {
+ GSettings* gsettings = NULL;
+ gsettings = g_settings_new_full(gsettings_schema, NULL, NULL);
+
+ if (gsettings != NULL) {
+ g_settings_get(gsettings, "scale-factor", "@a{si}", &display_scales);
+ DVLOG(1) << "Got com.ubuntu.desktop gsettings.";
+ } else {
+ DVLOG(1) << "No com.ubuntu.desktop gsettings available.";
+ }
+ } else {
+ DVLOG(1) << "No com.ubuntu.desktop gsettings schema available.";
+ }
+#endif
+
bool has_work_area = false;
gfx::Rect work_area;
std::vector<int> value;
@@ -343,7 +371,27 @@ std::vector<gfx::Display> DesktopScreenX
gfx::Rect crtc_bounds(crtc->x, crtc->y, crtc->width, crtc->height);
gfx::Display display(display_id, crtc_bounds);
- if (!gfx::Display::HasForceDeviceScaleFactor()) {
+ // An integer that forces discrete steps.
+ int density_indicator = 0;
+#ifdef USE_GLIB
+ if (display_scales != NULL) {
+ (void) g_variant_lookup(display_scales, output_info->name, "i",
+ &density_indicator);
+ DCHECK_LE(0, density_indicator);
+ DVLOG(1) << "Got density indictor " << density_indicator << " from display_scales for " << output_info->name;
+ }
+#else
+ VLOG(1) << "Not using gsettings to get display scale info. No use_glib";
+#endif
+
+ if (density_indicator != 0) {
+ // n/8 is actual scaling factor. Zero means discover from hardware.
+ device_scale_factor = float(density_indicator / 8.0);
+ DVLOG(1) << "Set " << output_info->name << " screen scaling to "
+ << device_scale_factor << " from gsettings.";
+ display.SetScaleAndBounds(device_scale_factor, crtc_bounds);
+ } else if (!gfx::Display::HasForceDeviceScaleFactor()) {
+
if (i == 0 && !ui::IsXDisplaySizeBlackListed(output_info->mm_width,
output_info->mm_height)) {
// As per display scale factor is not supported right now,
@@ -352,6 +400,7 @@ std::vector<gfx::Display> DesktopScreenX
output_info->mm_width);
DCHECK_LE(1.0f, device_scale_factor);
}
+ DVLOG(1) << "Didn't use gsettings info at all. Picked " << device_scale_factor;
display.SetScaleAndBounds(device_scale_factor, crtc_bounds);
}
|