[gnome-shell] shell: Specify G_PARAM_EXPLICIT_NOTIFY where appropriate



commit 9a2505f18c71b32ffd0d72c142f8a66aff95a28b
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Feb 9 18:37:44 2022 +0100

    shell: Specify G_PARAM_EXPLICIT_NOTIFY where appropriate
    
    Like we did in ST, opt out of g_object_set()'s implicit change
    notifications, so that notify is only emitted when a property
    *actually* changes.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2168>

 src/shell-blur-effect.c    |  6 +++---
 src/shell-global.c         | 24 ++++++++++++++++++++----
 src/shell-keyring-prompt.c |  4 ++--
 src/shell-window-preview.c |  4 +++-
 4 files changed, 28 insertions(+), 10 deletions(-)
---
diff --git a/src/shell-blur-effect.c b/src/shell-blur-effect.c
index 8ea333f0cf..0d4bb458a8 100644
--- a/src/shell-blur-effect.c
+++ b/src/shell-blur-effect.c
@@ -776,14 +776,14 @@ shell_blur_effect_class_init (ShellBlurEffectClass *klass)
                       "Sigma",
                       "Sigma",
                       0, G_MAXINT, 0,
-                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   properties[PROP_BRIGHTNESS] =
     g_param_spec_float ("brightness",
                         "Brightness",
                         "Brightness",
                         0.f, 1.f, 1.f,
-                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   properties[PROP_MODE] =
     g_param_spec_enum ("mode",
@@ -791,7 +791,7 @@ shell_blur_effect_class_init (ShellBlurEffectClass *klass)
                        "Blur mode",
                        SHELL_TYPE_BLUR_MODE,
                        SHELL_BLUR_MODE_ACTOR,
-                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   g_object_class_install_properties (object_class, N_PROPS, properties);
 }
diff --git a/src/shell-global.c b/src/shell-global.c
index 23551790ce..efe1271b5a 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -213,10 +213,26 @@ shell_global_set_property(GObject         *object,
       global->session_mode = g_ascii_strdown (g_value_get_string (value), -1);
       break;
     case PROP_FRAME_TIMESTAMPS:
-      global->frame_timestamps = g_value_get_boolean (value);
+      {
+        gboolean enable = g_value_get_boolean (value);
+
+        if (global->frame_timestamps != enable)
+          {
+            global->frame_timestamps = enable;
+            g_object_notify_by_pspec (object, props[PROP_FRAME_TIMESTAMPS]);
+          }
+      }
       break;
     case PROP_FRAME_FINISH_TIMESTAMP:
-      global->frame_finish_timestamp = g_value_get_boolean (value);
+      {
+        gboolean enable = g_value_get_boolean (value);
+
+        if (global->frame_finish_timestamp != enable)
+          {
+            global->frame_finish_timestamp = enable;
+            g_object_notify_by_pspec (object, props[PROP_FRAME_FINISH_TIMESTAMP]);
+          }
+      }
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -609,14 +625,14 @@ shell_global_class_init (ShellGlobalClass *klass)
                           "Frame Timestamps",
                           "Whether to log frame timestamps in the performance log",
                           FALSE,
-                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   props[PROP_FRAME_FINISH_TIMESTAMP] =
     g_param_spec_boolean ("frame-finish-timestamp",
                           "Frame Finish Timestamps",
                           "Whether at the end of a frame to call glFinish and log paintCompletedTimestamp",
                           FALSE,
-                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   props[PROP_SWITCHEROO_CONTROL] =
     g_param_spec_object ("switcheroo-control",
diff --git a/src/shell-keyring-prompt.c b/src/shell-keyring-prompt.c
index f25d9f8470..83c6746389 100644
--- a/src/shell-keyring-prompt.c
+++ b/src/shell-keyring-prompt.c
@@ -405,7 +405,7 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
                          "Password actor",
                          "Text field for password",
                          CLUTTER_TYPE_TEXT,
-                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   /**
    * ShellKeyringPrompt:confirm-actor:
@@ -417,7 +417,7 @@ shell_keyring_prompt_class_init (ShellKeyringPromptClass *klass)
                          "Confirm actor",
                          "Text field for confirming password",
                          CLUTTER_TYPE_TEXT,
-                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+                         G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
 
   g_object_class_install_properties (gobject_class, N_PROPS, props);
 
diff --git a/src/shell-window-preview.c b/src/shell-window-preview.c
index 2a4c6967cf..47a11c5240 100644
--- a/src/shell-window-preview.c
+++ b/src/shell-window-preview.c
@@ -53,7 +53,8 @@ shell_window_preview_set_property (GObject      *gobject,
   switch (property_id)
     {
     case PROP_WINDOW_CONTAINER:
-      g_set_object (&self->window_container, g_value_get_object (value));
+      if (g_set_object (&self->window_container, g_value_get_object (value)))
+        g_object_notify_by_pspec (gobject, obj_props[PROP_WINDOW_CONTAINER]);
       break;
 
     default:
@@ -169,6 +170,7 @@ shell_window_preview_class_init (ShellWindowPreviewClass *klass)
                          "window-container",
                          CLUTTER_TYPE_ACTOR,
                          G_PARAM_READWRITE |
+                         G_PARAM_EXPLICIT_NOTIFY |
                          G_PARAM_STATIC_STRINGS);
 
   g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);


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