[Xfce4-commits] [xfce/xfce4-settings] 10/18: display: Only auto-apply profiles if num of connected displays changes

noreply at xfce.org noreply at xfce.org
Thu Apr 4 23:03:08 CEST 2019


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-settings.

commit d7482b940106261fd54876d397f87c8c71b58aa2
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Sun Mar 31 23:34:46 2019 +0200

    display: Only auto-apply profiles if num of connected displays changes
    
    This is a way better approach than what was tried in the previous commit
    (which turned out to be racy, because you can never know if the helper
    has already applied all settings until you re-set the "AutoEnableProfiles"
    property).
---
 common/xfce-randr.c    | 14 --------------
 xfsettingsd/displays.c | 28 +++++++++++++++++-----------
 2 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/common/xfce-randr.c b/common/xfce-randr.c
index 44ef694..98ccb59 100644
--- a/common/xfce-randr.c
+++ b/common/xfce-randr.c
@@ -496,25 +496,11 @@ xfce_randr_apply (XfceRandr     *randr,
                   const gchar   *scheme,
                   XfconfChannel *channel)
 {
-    gboolean autoenable;
-
     g_return_if_fail (randr != NULL && scheme != NULL);
     g_return_if_fail (XFCONF_IS_CHANNEL (channel));
 
-    /* Temporarily disable auto-enabling of profiles (if active).
-       Otherwise the user (changing settings in the display settings dialog) and
-       xfsettingsd (re-applying the unchanged profile) will fight against each other.
-       (Spoiler alert: xfsettingsd always wins!) */
-    autoenable = xfconf_channel_get_bool (channel, "/AutoEnableProfiles", FALSE);
-    if (autoenable)
-        xfconf_channel_set_bool (channel, "/AutoEnableProfiles", !autoenable);
-
     /* tell the helper to apply this theme */
     xfconf_channel_set_string (channel, "/Schemes/Apply", scheme);
-
-    /* Re-enable auto-enabling of profiles (if it was previously enabled) */
-    if (autoenable)
-        xfconf_channel_set_bool (channel, "/AutoEnableProfiles", autoenable);
 }
 
 
diff --git a/xfsettingsd/displays.c b/xfsettingsd/displays.c
index c17a040..ffbfced 100644
--- a/xfsettingsd/displays.c
+++ b/xfsettingsd/displays.c
@@ -280,7 +280,7 @@ xfce_displays_helper_init (XfceDisplaysHelper *helper)
 
             /* remove any leftover apply property before setting the monitor */
             xfconf_channel_reset_property (helper->channel, APPLY_SCHEME_PROP, FALSE);
-            xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, "Default");
+            xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, DEFAULT_SCHEME_NAME);
 
             /* monitor channel changes */
             helper->handler = g_signal_connect (G_OBJECT (helper->channel),
@@ -459,7 +459,6 @@ xfce_displays_helper_get_matching_profile (XfceDisplaysHelper *helper)
         property = g_strdup_printf ("/%s", (gchar *) profile);
         profile_name = xfconf_channel_get_string (helper->channel, property, NULL);
         xfsettings_dbg (XFSD_DEBUG_DISPLAYS, "Applied the only matching display profile: %s", profile_name);
-        xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, (gchar *) profile);
         g_free (profile_name);
         g_free (property);
         return (gchar *)profile;
@@ -503,19 +502,24 @@ xfce_displays_helper_screen_on_event (GdkXEvent *xevent,
         xfsettings_dbg (XFSD_DEBUG_DISPLAYS, "Noutput: before = %d, after = %d.",
                         old_outputs->len, helper->outputs->len);
 
-        /* Check if we have a matching profile and apply it if there's only one */
-        if (xfconf_channel_get_bool (helper->channel, AUTO_ENABLE_PROFILES, TRUE))
+        /* Check if we have different amount of outputs and a matching profile and
+           apply it if there's only one */
+        if (old_outputs->len > helper->outputs->len ||
+            old_outputs->len < helper->outputs->len)
         {
-            gchar *matching_profile = NULL;
-
-            matching_profile = xfce_displays_helper_get_matching_profile (helper);
-            if (matching_profile)
+            if (xfconf_channel_get_bool (helper->channel, AUTO_ENABLE_PROFILES, TRUE))
             {
-                xfce_displays_helper_channel_apply (helper, matching_profile);
-                return GDK_FILTER_CONTINUE;
+                gchar *matching_profile = NULL;
+
+                matching_profile = xfce_displays_helper_get_matching_profile (helper);
+                if (matching_profile)
+                {
+                    xfce_displays_helper_channel_apply (helper, matching_profile);
+                    return GDK_FILTER_CONTINUE;
+                }
             }
+            xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, DEFAULT_SCHEME_NAME);
         }
-        xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, "Default");
 
         if (old_outputs->len > helper->outputs->len)
         {
@@ -1445,6 +1449,8 @@ xfce_displays_helper_channel_apply (XfceDisplaysHelper *helper,
     helper->primary = None;
 #endif
 
+    xfconf_channel_set_string (helper->channel, ACTIVE_PROFILE, scheme);
+
     /* finally the list of saved outputs from xfconf */
     g_snprintf (property, sizeof (property), "/%s", scheme);
     saved_outputs = xfconf_channel_get_properties (helper->channel, property);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list