[gnome-settings-daemon/gnome-3-32] power, media-keys: Signal connector rather than output ID for OSD



commit 4d3fa8511821557e85bfcaeb64704c87c6fcc90f
Author: Benjamin Berg <bberg redhat com>
Date:   Thu Apr 11 11:28:33 2019 +0200

    power,media-keys: Signal connector rather than output ID for OSD
    
    We don't have the concept of an output ID anymore in the DBus API. The
    current code was entirely broken for a long time now (i.e. never
    signalled any output) and the fixup for 3.32 that I did was actually
    doing guesses that were incorrect.
    
    Fix this properly by passing around the connector name rather than an
    output ID. This requires changes in gnome-shell to work properly (but
    doesn't regress without those changes).
    
    Fixes: #401
    (cherry picked from commit ded2c4c35c28422a360e681a455a26895ab99d23)

 plugins/common/gsd-shell-helper.c           | 10 +++----
 plugins/common/gsd-shell-helper.h           |  4 +--
 plugins/media-keys/gsd-media-keys-manager.c | 43 ++++++++++++++---------------
 plugins/power/gsd-backlight.c               | 18 +++++-------
 plugins/power/gsd-backlight.h               |  3 +-
 plugins/power/gsd-power-manager.c           |  8 +++---
 6 files changed, 41 insertions(+), 45 deletions(-)
---
diff --git a/plugins/common/gsd-shell-helper.c b/plugins/common/gsd-shell-helper.c
index 57defdb3..11499e30 100644
--- a/plugins/common/gsd-shell-helper.c
+++ b/plugins/common/gsd-shell-helper.c
@@ -25,9 +25,9 @@ shell_show_osd (GsdShell    *shell,
                const gchar *icon_name,
                const gchar *label,
                gint         level,
-               gint         monitor)
+               const gchar *connector)
 {
-        shell_show_osd_with_max_level (shell, icon_name, label, level, -1, monitor);
+        shell_show_osd_with_max_level (shell, icon_name, label, level, -1, connector);
 }
 
 void
@@ -36,7 +36,7 @@ shell_show_osd_with_max_level (GsdShell    *shell,
                                const gchar *label,
                                gint         level,
                                gint         max_level,
-                               gint         monitor)
+                               const gchar *connector)
 {
        GVariantBuilder builder;
 
@@ -56,9 +56,9 @@ shell_show_osd_with_max_level (GsdShell    *shell,
         if (max_level > 100)
                 g_variant_builder_add (&builder, "{sv}",
                                        "max_level", g_variant_new_int32 (max_level));
-        if (monitor >= 0)
+        if (connector)
                 g_variant_builder_add (&builder, "{sv}",
-                                       "monitor", g_variant_new_int32 (monitor));
+                                       "connector", g_variant_new_string (connector));
 
        gsd_shell_call_show_osd (shell,
                                 g_variant_builder_end (&builder),
diff --git a/plugins/common/gsd-shell-helper.h b/plugins/common/gsd-shell-helper.h
index 6e38cc9a..1de75d49 100644
--- a/plugins/common/gsd-shell-helper.h
+++ b/plugins/common/gsd-shell-helper.h
@@ -28,14 +28,14 @@ void shell_show_osd (GsdShell    *shell,
                     const gchar *icon_name,
                     const gchar *label,
                     gint         level,
-                    gint         monitor);
+                    const gchar *connector);
 
 void shell_show_osd_with_max_level (GsdShell    *shell,
                                     const gchar *icon_name,
                                     const gchar *label,
                                     gint         level,
                                     gint         max_level,
-                                    gint         monitor);
+                                    const gchar *connector);
 
 G_END_DECLS
 
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index fd6a5eca..4d251f08 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -85,7 +85,6 @@
 
 #define SHELL_GRABBER_CALL_TIMEOUT G_MAXINT
 #define SHELL_GRABBER_RETRY_INTERVAL 1
-#define OSD_ALL_OUTPUTS -1
 
 /* How long to suppress power-button presses after resume,
  * 3 seconds is the minimum necessary to make resume reliable */
@@ -380,13 +379,13 @@ show_osd_with_max_level (GsdMediaKeysManager *manager,
                          const char          *label,
                          int                  level,
                          int                  max_level,
-                         int                  output_id)
+                         const gchar         *connector)
 {
         if (manager->priv->shell_proxy == NULL)
                 return;
 
         shell_show_osd_with_max_level (manager->priv->shell_proxy,
-                                       icon, label, level, max_level, output_id);
+                                       icon, label, level, max_level, connector);
 }
 
 static void
@@ -394,10 +393,10 @@ show_osd (GsdMediaKeysManager *manager,
           const char          *icon,
           const char          *label,
           int                  level,
-          int                  output_id)
+          const char          *connector)
 {
         show_osd_with_max_level(manager,
-                                icon, label, level, -1, output_id);
+                                icon, label, level, -1, connector);
 }
 
 static const char *
@@ -1047,7 +1046,7 @@ do_eject_action (GsdMediaKeysManager *manager)
         }
 
         /* Show OSD */
-        show_osd (manager, "media-eject-symbolic", NULL, -1, OSD_ALL_OUTPUTS);
+        show_osd (manager, "media-eject-symbolic", NULL, -1, NULL);
 
         /* Clean up the drive selection and exit if no suitable
          * drives are found */
@@ -1122,7 +1121,7 @@ static void
 do_touchpad_osd_action (GsdMediaKeysManager *manager, gboolean state)
 {
         show_osd (manager, state ? "input-touchpad-symbolic"
-                                 : "touchpad-disabled-symbolic", NULL, -1, OSD_ALL_OUTPUTS);
+                                 : "touchpad-disabled-symbolic", NULL, -1, NULL);
 }
 
 static void
@@ -1254,9 +1253,9 @@ update_dialog (GsdMediaKeysManager *manager,
                 device = gvc_mixer_control_lookup_device_from_stream (manager->priv->volume, stream);
                 show_osd_with_max_level (manager, icon,
                                          gvc_mixer_ui_device_get_description (device),
-                                         vol, max_volume_pct, OSD_ALL_OUTPUTS);
+                                         vol, max_volume_pct, NULL);
         } else {
-                show_osd_with_max_level (manager, icon, NULL, vol, max_volume_pct, OSD_ALL_OUTPUTS);
+                show_osd_with_max_level (manager, icon, NULL, vol, max_volume_pct, NULL);
         }
 
         if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) {
@@ -1719,7 +1718,7 @@ gsd_media_player_key_pressed (GsdMediaKeysManager *manager,
 
         if (!have_listeners) {
                 /* Popup a dialog with an (/) icon */
-                show_osd (manager, "action-unavailable-symbolic", NULL, -1, OSD_ALL_OUTPUTS);
+                show_osd (manager, "action-unavailable-symbolic", NULL, -1, NULL);
                return TRUE;
         }
 
@@ -1871,7 +1870,7 @@ do_video_rotate_lock_action (GsdMediaKeysManager *manager,
         g_object_unref (settings);
 
         show_osd (manager, locked ? "rotation-locked-symbolic"
-                                  : "rotation-allowed-symbolic", NULL, -1, OSD_ALL_OUTPUTS);
+                                  : "rotation-allowed-symbolic", NULL, -1, NULL);
 }
 
 static void
@@ -2123,10 +2122,11 @@ update_brightness_cb (GObject             *source_object,
                       gpointer             user_data)
 {
         GError *error = NULL;
-        int percentage, output_id;
+        int percentage;
         GVariant *variant;
         GsdMediaKeysManager *manager = GSD_MEDIA_KEYS_MANAGER (user_data);
         const char *icon, *debug;
+        char *connector = NULL;
 
         /* update the dialog with the new value */
         if (G_DBUS_PROXY (source_object) == manager->priv->power_keyboard_proxy) {
@@ -2148,14 +2148,13 @@ update_brightness_cb (GObject             *source_object,
         /* update the dialog with the new value */
         if (G_DBUS_PROXY (source_object) == manager->priv->power_keyboard_proxy) {
                 icon = "keyboard-brightness-symbolic";
-                output_id = -1;
                 g_variant_get (variant, "(i)", &percentage);
         } else {
                 icon = "display-brightness-symbolic";
-                g_variant_get (variant, "(ii)", &percentage, &output_id);
+                g_variant_get (variant, "(i&s)", &percentage, &connector);
         }
 
-        show_osd (manager, icon, NULL, percentage, output_id);
+        show_osd (manager, icon, NULL, percentage, connector);
         g_variant_unref (variant);
 }
 
@@ -2230,7 +2229,7 @@ do_battery_action (GsdMediaKeysManager *manager)
 
         if (kind == UP_DEVICE_KIND_UPS || kind == UP_DEVICE_KIND_BATTERY) {
                 g_debug ("showing battery level OSD");
-                show_osd (manager, icon_name, NULL, percentage, OSD_ALL_OUTPUTS);
+                show_osd (manager, icon_name, NULL, percentage, NULL);
         }
 
         g_free (icon_name);
@@ -2284,17 +2283,17 @@ set_rfkill_complete (GObject      *object,
         if (data->bluetooth) {
                 if (data->target_state)
                         show_osd (data->manager, "bluetooth-disabled-symbolic",
-                                  _("Bluetooth disabled"), -1, OSD_ALL_OUTPUTS);
+                                  _("Bluetooth disabled"), -1, NULL);
                 else
                         show_osd (data->manager, "bluetooth-active-symbolic",
-                                  _("Bluetooth enabled"), -1, OSD_ALL_OUTPUTS);
+                                  _("Bluetooth enabled"), -1, NULL);
         } else {
                 if (data->target_state)
                         show_osd (data->manager, "airplane-mode-symbolic",
-                                  _("Airplane mode enabled"), -1, OSD_ALL_OUTPUTS);
+                                  _("Airplane mode enabled"), -1, NULL);
                 else
                         show_osd (data->manager, "network-wireless-signal-excellent-symbolic",
-                                  _("Airplane mode disabled"), -1, OSD_ALL_OUTPUTS);
+                                  _("Airplane mode disabled"), -1, NULL);
         }
 
 out:
@@ -2322,7 +2321,7 @@ do_rfkill_action (GsdMediaKeysManager *manager,
 
         if (get_rfkill_property (manager, hw_mode)) {
                 show_osd (manager, "airplane-mode-symbolic",
-                          _("Hardware Airplane Mode"), -1, OSD_ALL_OUTPUTS);
+                          _("Hardware Airplane Mode"), -1, NULL);
                 return;
         }
 
@@ -3436,7 +3435,7 @@ power_keyboard_proxy_signal_cb (GDBusProxy  *proxy,
         if (g_strcmp0 (source, "internal") != 0)
                 return;
 
-        show_osd (manager, "keyboard-brightness-symbolic", NULL, brightness, -1);
+        show_osd (manager, "keyboard-brightness-symbolic", NULL, brightness, NULL);
 }
 
 static void
diff --git a/plugins/power/gsd-backlight.c b/plugins/power/gsd-backlight.c
index e60c649d..d7d10fd2 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -645,26 +645,22 @@ gsd_backlight_step_down_finish (GsdBacklight *backlight,
  * gsd_backlight_get_output_id
  * @backlight: a #GsdBacklight
  *
- * Return the display ID for the display that is being controlled by the
- * #GsdBacklight object. This display ID can be passed to gnome-shell to show
+ * Return the connector for the display that is being controlled by the
+ * #GsdBacklight object. This connector can be passed to gnome-shell to show
  * the on screen display only on the affected screen.
  *
- * Returns: The ID for the controlled output or -1 if unknown.
+ * Returns: The connector of the controlled output or NULL if unknown.
  **/
-gint
-gsd_backlight_get_output_id (GsdBacklight *backlight)
+const char*
+gsd_backlight_get_connector (GsdBacklight *backlight)
 {
         GnomeRROutput *output;
 
         output = gsd_backlight_rr_find_output (backlight, FALSE);
         if (output == NULL)
-                return -1;
+                return NULL;
 
-        /* XXX: Is this really that simple? The old code did a lot more, but
-         * did not return anything sensible these days.
-         * The outputs need to be in the same order as the MetaScreen object
-         * returns to the shell. */
-        return gnome_rr_output_get_id (output);
+        return gnome_rr_output_get_name (output);
 }
 
 static void
diff --git a/plugins/power/gsd-backlight.h b/plugins/power/gsd-backlight.h
index 2d4f3339..901d1cba 100644
--- a/plugins/power/gsd-backlight.h
+++ b/plugins/power/gsd-backlight.h
@@ -63,7 +63,8 @@ gint gsd_backlight_step_down_finish      (GsdBacklight         *backlight,
                                           GError              **error);
 
 
-gint gsd_backlight_get_output_id         (GsdBacklight         *backlight);
+const char*  gsd_backlight_get_connector (GsdBacklight         *backlight);
+
 GsdBacklight* gsd_backlight_new          (GnomeRRScreen        *screen,
                                           GError              **error);
 
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index f965f6f3..d6e200a9 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -90,11 +90,11 @@ static const gchar introspection_xml[] =
 "    <property name='Brightness' type='i' access='readwrite'/>"
 "    <method name='StepUp'>"
 "      <arg type='i' name='new_percentage' direction='out'/>"
-"      <arg type='i' name='output_id' direction='out'/>"
+"      <arg type='s' name='connector' direction='out'/>"
 "    </method>"
 "    <method name='StepDown'>"
 "      <arg type='i' name='new_percentage' direction='out'/>"
-"      <arg type='i' name='output_id' direction='out'/>"
+"      <arg type='s' name='connector' direction='out'/>"
 "    </method>"
 "  </interface>"
 "  <interface name='org.gnome.SettingsDaemon.Power.Keyboard'>"
@@ -2794,9 +2794,9 @@ backlight_brightness_step_cb (GObject *object,
                                                      error);
         } else {
                 g_dbus_method_invocation_return_value (invocation,
-                                                       g_variant_new ("(ii)",
+                                                       g_variant_new ("(is)",
                                                                       brightness,
-                                                                      gsd_backlight_get_output_id 
(backlight)));
+                                                                      gsd_backlight_get_connector 
(backlight)));
         }
 
         g_object_unref (manager);


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