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

Proposed by Eleni Maria Stea
Status: Merged
Approved by: Sebastien Bacher
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 Approve
PS Jenkins bot (community) continuous-integration Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
12771. By Eleni Maria Stea

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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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
=== modified file 'panels/display/cc-display-panel.c'
--- panels/display/cc-display-panel.c 2014-03-28 12:57:57 +0000
+++ panels/display/cc-display-panel.c 2014-04-04 08:51:00 +0000
@@ -20,6 +20,7 @@
20 */20 */
2121
22#include <config.h>22#include <config.h>
23#include <math.h>
23#include <string.h>24#include <string.h>
24#include <stdlib.h>25#include <stdlib.h>
25#include <sys/wait.h>26#include <sys/wait.h>
@@ -597,6 +598,42 @@
597 return g_variant_builder_end (&builder);598 return g_variant_builder_end (&builder);
598}599}
599600
601static int
602get_ui_scale_from_monitor (CcDisplayPanel *self, const char *monitor_name)
603{
604 int value;
605 GVariant *dict;
606
607 dict = g_settings_get_value (self->priv->desktop_settings, "scale-factor");
608 if (!g_variant_lookup (dict, monitor_name, "i", &value))
609 value = UI_SCALE_DEFAULT;
610
611 return value;
612}
613
614static int
615calculate_max_ui_scale (CcDisplayPanel *self)
616{
617 int win_max_dimension;
618 int output_width, output_height;
619 float max_scale;
620
621 GnomeRROutputInfo *output = self->priv->current_output;
622 const char *monitor_name = gnome_rr_output_info_get_name (output);
623 int current_ui_scale = get_ui_scale_from_monitor (self, monitor_name);
624 float current_scale_factor = (float)current_ui_scale / 8.0;
625 float win_scale_factor = current_scale_factor > 1 ? floor (current_scale_factor) : 1;
626
627 get_geometry (output, &output_width, &output_height);
628
629 /* only the integer part of the scale-factor contributes to the window size */
630
631 win_max_dimension = MINIMUM_HEIGHT / win_scale_factor;
632 max_scale = (float)output_height / (float)win_max_dimension;
633
634 return (int)(max_scale * 8.0);
635}
636
600static void637static void
601rebuild_ui_scale (CcDisplayPanel *self)638rebuild_ui_scale (CcDisplayPanel *self)
602{639{
@@ -615,7 +652,7 @@
615 }652 }
616653
617 gtk_adjustment_set_step_increment (adj, UI_SCALE_STEP);654 gtk_adjustment_set_step_increment (adj, UI_SCALE_STEP);
618 gtk_adjustment_set_upper (adj, UI_SCALE_MAX);655 gtk_adjustment_set_upper (adj, calculate_max_ui_scale(self));
619 gtk_adjustment_set_lower (adj, UI_SCALE_MIN);656 gtk_adjustment_set_lower (adj, UI_SCALE_MIN);
620 gtk_scale_set_digits (GTK_SCALE(self->priv->ui_scale), 0);657 gtk_scale_set_digits (GTK_SCALE(self->priv->ui_scale), 0);
621 gtk_scale_add_mark (GTK_SCALE(self->priv->ui_scale), UI_SCALE_DEFAULT, GTK_POS_TOP, NULL);658 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