[gnome-settings-daemon] xsettings: Only support the new mutter D-Bus DisplayConfig API



commit 8a51cd03a813e9522656a866c8c9edd9e9579ede
Author: Jonas Ådahl <jadahl gmail com>
Date:   Fri Aug 11 15:33:11 2017 +0800

    xsettings: Only support the new mutter D-Bus DisplayConfig API
    
    The legacy API is no longer supported by mutter, so lets remove it from
    gnome-settings-daemon too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777732

 plugins/xsettings/gsd-xsettings-manager.c |  205 +----------------------------
 1 files changed, 1 insertions(+), 204 deletions(-)
---
diff --git a/plugins/xsettings/gsd-xsettings-manager.c b/plugins/xsettings/gsd-xsettings-manager.c
index ddbbe74..c89184d 100644
--- a/plugins/xsettings/gsd-xsettings-manager.c
+++ b/plugins/xsettings/gsd-xsettings-manager.c
@@ -503,141 +503,6 @@ get_dpi_from_gsettings (GnomeXSettingsManager *manager)
         return dpi * factor;
 }
 
-static GnomeRROutput *
-get_primary_output (GnomeRRScreen *screen)
-{
-        GnomeRROutput *primary = NULL;
-        GnomeRROutput **outputs;
-        guint i;
-
-        outputs = gnome_rr_screen_list_outputs (screen);
-        if (outputs == NULL || outputs[0] == NULL)
-                return NULL;
-        for (i = 0; outputs[i] != NULL; i++) {
-                if (gnome_rr_output_get_is_primary (outputs[i])) {
-                        primary = outputs[i];
-                        break;
-                }
-        }
-        if (primary == NULL)
-                primary = outputs[0];
-
-        return primary;
-}
-
-static gboolean
-primary_monitor_is_4k (GnomeRROutput *primary)
-{
-        GnomeRRMode *mode;
-
-        mode = gnome_rr_output_get_current_mode (primary);
-        if (gnome_rr_mode_get_width (mode) >= SMALLEST_4K_WIDTH)
-                return TRUE;
-        return FALSE;
-}
-
-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 gboolean
-primary_monitor_should_skip_resolution_check (GnomeRROutput *primary)
-{
-        if (!primary_monitor_is_4k (primary) && primary_monitor_on_hdmi (primary))
-                return TRUE;
-
-        return FALSE;
-}
-
-static void
-get_dimensions_xrandr (GnomeRROutput *primary,
-                       int           *width,
-                       int           *height,
-                       int           *width_mm,
-                       int           *height_mm)
-{
-        GnomeRRMode *mode;
-
-        mode = gnome_rr_output_get_current_mode (primary);
-        *width = gnome_rr_mode_get_width (mode);
-        *height = gnome_rr_mode_get_height (mode);
-
-        gnome_rr_output_get_physical_size (primary,
-                                           width_mm,
-                                           height_mm);
-}
-
-static void
-get_dimensions_gdk (int *width,
-                    int *height,
-                    int *width_mm,
-                    int *height_mm)
-{
-        GdkDisplay *display;
-        GdkScreen *screen;
-        GdkRectangle rect;
-        int primary;
-        int monitor_scale;
-
-        display = gdk_display_get_default ();
-        screen = gdk_display_get_default_screen (display);
-        primary = gdk_screen_get_primary_monitor (screen);
-        gdk_screen_get_monitor_geometry (screen, primary, &rect);
-        monitor_scale = gdk_screen_get_monitor_scale_factor (screen, primary);
-
-        *width = rect.width * monitor_scale;
-        *height = rect.height * monitor_scale;
-
-        *width_mm = gdk_screen_get_monitor_width_mm (screen, primary);
-        *height_mm = gdk_screen_get_monitor_height_mm (screen, primary);
-}
-
-static gboolean
-is_experimental_display_config_api_enabled (GnomeXSettingsManager *manager)
-{
-        GVariant *property_variant;
-        GVariant *property_value_variant;
-        GError *error = NULL;
-        gboolean is_experimental_api_enabled;
-
-        property_variant =
-                g_dbus_connection_call_sync (manager->priv->dbus_connection,
-                                             "org.gnome.Mutter.DisplayConfig",
-                                             "/org/gnome/Mutter/DisplayConfig",
-                                             "org.freedesktop.DBus.Properties",
-                                             "Get",
-                                             g_variant_new ("(ss)",
-                                                            "org.gnome.Mutter.DisplayConfig",
-                                                            "IsExperimentalApiEnabled"),
-                                             NULL,
-                                             G_DBUS_CALL_FLAGS_NO_AUTO_START,
-                                             -1,
-                                             NULL,
-                                             &error);
-        if (!property_variant) {
-                g_warning ("Failed to check API availability: %s",
-                           error->message);
-                g_error_free (error);
-                return FALSE;
-        }
-
-        g_variant_get_child (property_variant, 0, "v", &property_value_variant);
-        is_experimental_api_enabled = g_variant_get_boolean (property_value_variant);
-
-        g_variant_unref (property_variant);
-        g_variant_unref (property_value_variant);
-
-        return is_experimental_api_enabled;
-}
-
 static gboolean
 is_layout_mode_logical (GVariantIter *properties)
 {
@@ -681,7 +546,7 @@ is_layout_mode_logical (GVariantIter *properties)
 #define CURRENT_STATE_FORMAT "(u" MONITORS_FORMAT LOGICAL_MONITORS_FORMAT "a{sv})"
 
 static int
-get_window_scale_experimental (GnomeXSettingsManager *manager)
+get_window_scale (GnomeXSettingsManager *manager)
 {
         GError *error = NULL;
         GVariant *current_state;
@@ -748,74 +613,6 @@ out:
         return scale;
 }
 
-static int
-get_window_scale (GnomeXSettingsManager *manager)
-{
-       GSettings  *interface_settings;
-        int window_scale;
-        int width, height;
-        int width_mm, height_mm;
-        double dpi_x, dpi_y;
-
-        if (is_experimental_display_config_api_enabled (manager))
-                return get_window_scale_experimental (manager);
-
-       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) {
-                GnomeRROutput *output = NULL;
-
-                window_scale = 1;
-
-                if (manager->priv->rr_screen)
-                        output = get_primary_output (manager->priv->rr_screen);
-
-                if (output) {
-                        if (primary_monitor_should_skip_resolution_check (output))
-                                goto out;
-
-                        get_dimensions_xrandr (output,
-                                               &width, &height,
-                                               &width_mm, &height_mm);
-                } else {
-                        /* Before the D-Bus DisplayConfig service exported by
-                         * Mutter becomes available, use the current information
-                         * that GDK has from the X server; in simple cases, this
-                         * will hopefully keep us from switching the window_scale
-                         * during startup.
-                         */
-                        get_dimensions_gdk (&width, &height,
-                                            &width_mm, &height_mm);
-                }
-
-                if (height < HIDPI_MIN_HEIGHT)
-                        goto out;
-
-                /* Somebody encoded the aspect ratio (16/9 or 16/10)
-                 * instead of the physical size */
-                if ((width_mm == 160 && height_mm == 90) ||
-                    (width_mm == 160 && height_mm == 100) ||
-                    (width_mm == 16 && height_mm == 9) ||
-                    (width_mm == 16 && height_mm == 10))
-                        goto out;
-
-                window_scale = 1;
-                if (width_mm > 0 && height_mm > 0) {
-                        dpi_x = (double)width / (width_mm / 25.4);
-                        dpi_y = (double)height / (height_mm / 25.4);
-                        /* We don't completely trust these values so both
-                           must be high, and never pick higher ratio than
-                           2 automatically */
-                        if (dpi_x > HIDPI_LIMIT && dpi_y > HIDPI_LIMIT)
-                                window_scale = 2;
-                }
-        }
-
-out:
-        return window_scale;
-}
-
 typedef struct {
         gboolean    antialias;
         gboolean    hinting;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]