[gnome-settings-daemon] xsettings: Disable scaling factor on HDMI outputs
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] xsettings: Disable scaling factor on HDMI outputs
- Date: Fri, 14 Mar 2014 14:37:17 +0000 (UTC)
commit d691c9c1529b2649d9642febc06dde57445996a7
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 20 13:18:16 2013 +0100
xsettings: Disable scaling factor on HDMI outputs
If the output is HDMI, it's likely that the output is a TV, so
don't increase the scaling factor.
https://bugzilla.gnome.org/show_bug.cgi?id=709859
plugins/xsettings/gsd-xsettings-manager.c | 53 ++++++++++++++++++++--------
1 files changed, 38 insertions(+), 15 deletions(-)
---
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index e4bbb0a..5dd9118 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -432,25 +432,16 @@ get_dpi_from_gsettings (GnomeXSettingsManager *manager)
return dpi * factor;
}
-static gboolean
-primary_monitor_at_native_resolution (void)
+static GnomeRROutput *
+get_primary_output (GnomeRRScreen *screen)
{
- GnomeRRScreen *screen;
GnomeRROutput *primary = NULL;
GnomeRROutput **outputs;
- int current_width, current_height;
- int pref_width, pref_height;
- gboolean native = TRUE;
- GnomeRRMode *mode;
guint i;
- screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL);
- if (screen == NULL)
- goto out;
-
outputs = gnome_rr_screen_list_outputs (screen);
if (outputs == NULL || outputs[0] == NULL)
- goto out;
+ return NULL;
for (i = 0; outputs[i] != NULL; i++) {
if (gnome_rr_output_get_is_primary (outputs[i])) {
primary = outputs[i];
@@ -460,6 +451,17 @@ primary_monitor_at_native_resolution (void)
if (primary == NULL)
primary = outputs[0];
+ return primary;
+}
+
+static gboolean
+primary_monitor_at_native_resolution (GnomeRROutput *primary)
+{
+ int current_width, current_height;
+ int pref_width, pref_height;
+ gboolean native = TRUE;
+ GnomeRRMode *mode;
+
mode = gnome_rr_output_get_current_mode (primary);
current_width = gnome_rr_mode_get_width (mode);
current_height = gnome_rr_mode_get_height (mode);
@@ -469,11 +471,21 @@ primary_monitor_at_native_resolution (void)
if (current_width != pref_width || current_height != pref_height)
native = FALSE;
-out:
- g_clear_object (&screen);
return native;
}
+static gboolean
+primary_monitor_on_hdmi (GnomeRROutput *primary)
+{
+ const char *name;
+
+ name = gnome_rr_output_get_name (primary);
+ if (name == NULL ||
+ strstr (name, "HDMI") == NULL)
+ return FALSE;
+ return TRUE;
+}
+
static int
get_window_scale (GnomeXSettingsManager *manager)
{
@@ -485,15 +497,25 @@ get_window_scale (GnomeXSettingsManager *manager)
int width_mm, height_mm;
int monitor_scale;
double dpi_x, dpi_y;
+ GnomeRRScreen *rr_screen = NULL;
interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
window_scale =
g_settings_get_uint (interface_settings, SCALING_FACTOR_KEY);
if (window_scale == 0) {
int primary;
+ GnomeRROutput *output;
window_scale = 1;
- if (!primary_monitor_at_native_resolution ())
+
+ rr_screen = gnome_rr_screen_new (gdk_screen_get_default (), NULL);
+ if (!rr_screen)
+ goto out;
+ output = get_primary_output (rr_screen);
+ if (!output)
+ goto out;
+ if (!primary_monitor_at_native_resolution (output) ||
+ primary_monitor_on_hdmi (output))
goto out;
display = gdk_display_get_default ();
@@ -517,6 +539,7 @@ get_window_scale (GnomeXSettingsManager *manager)
}
out:
+ g_clear_object (&rr_screen);
return window_scale;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]