Merge lp:~hikiko/unity-control-center/unity-control-center.clamp-ui-scale into lp:unity-control-center

Proposed by Eleni Maria Stea on 2014-04-03
Status: Merged
Approved by: Sebastien Bacher on 2014-04-04
Approved revision: 12771
Merged at revision: 12769
Proposed branch: lp:~hikiko/unity-control-center/unity-control-center.clamp-ui-scale
Merge into: lp:unity-control-center
Diff against target: 63 lines (+38/-1)
1 file modified
panels/display/cc-display-panel.c (+38/-1)
To merge this branch: bzr merge lp:~hikiko/unity-control-center/unity-control-center.clamp-ui-scale
Reviewer Review Type Date Requested Status
Sebastien Bacher 2014-04-03 Approve on 2014-04-04
PS Jenkins bot (community) continuous-integration Approve on 2014-04-04
Review via email: mp+214019@code.launchpad.net

Commit message

When the u-c-c starts the UI scale is clamped to a reasonable value in order to make sure that the user can always see the slider.

Description of the change

When the u-c-c starts the UI scale is clamped to a reasonable value in order to make sure that the user can always see the slider.

To post a comment you must log in.
12771. By Eleni Maria Stea on 2014-04-04

used a fixed window size that always fit the screen instead of the
current window size, to have a predictable maximum value in the ui scale

Sebastien Bacher (seb128) wrote :

Thanks, looks fine to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/display/cc-display-panel.c'
2--- panels/display/cc-display-panel.c 2014-03-28 12:57:57 +0000
3+++ panels/display/cc-display-panel.c 2014-04-04 08:51:00 +0000
4@@ -20,6 +20,7 @@
5 */
6
7 #include <config.h>
8+#include <math.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <sys/wait.h>
12@@ -597,6 +598,42 @@
13 return g_variant_builder_end (&builder);
14 }
15
16+static int
17+get_ui_scale_from_monitor (CcDisplayPanel *self, const char *monitor_name)
18+{
19+ int value;
20+ GVariant *dict;
21+
22+ dict = g_settings_get_value (self->priv->desktop_settings, "scale-factor");
23+ if (!g_variant_lookup (dict, monitor_name, "i", &value))
24+ value = UI_SCALE_DEFAULT;
25+
26+ return value;
27+}
28+
29+static int
30+calculate_max_ui_scale (CcDisplayPanel *self)
31+{
32+ int win_max_dimension;
33+ int output_width, output_height;
34+ float max_scale;
35+
36+ GnomeRROutputInfo *output = self->priv->current_output;
37+ const char *monitor_name = gnome_rr_output_info_get_name (output);
38+ int current_ui_scale = get_ui_scale_from_monitor (self, monitor_name);
39+ float current_scale_factor = (float)current_ui_scale / 8.0;
40+ float win_scale_factor = current_scale_factor > 1 ? floor (current_scale_factor) : 1;
41+
42+ get_geometry (output, &output_width, &output_height);
43+
44+ /* only the integer part of the scale-factor contributes to the window size */
45+
46+ win_max_dimension = MINIMUM_HEIGHT / win_scale_factor;
47+ max_scale = (float)output_height / (float)win_max_dimension;
48+
49+ return (int)(max_scale * 8.0);
50+}
51+
52 static void
53 rebuild_ui_scale (CcDisplayPanel *self)
54 {
55@@ -615,7 +652,7 @@
56 }
57
58 gtk_adjustment_set_step_increment (adj, UI_SCALE_STEP);
59- gtk_adjustment_set_upper (adj, UI_SCALE_MAX);
60+ gtk_adjustment_set_upper (adj, calculate_max_ui_scale(self));
61 gtk_adjustment_set_lower (adj, UI_SCALE_MIN);
62 gtk_scale_set_digits (GTK_SCALE(self->priv->ui_scale), 0);
63 gtk_scale_add_mark (GTK_SCALE(self->priv->ui_scale), UI_SCALE_DEFAULT, GTK_POS_TOP, NULL);

Subscribers

People subscribed via source and target branches