[gnome-settings-daemon/benzea/fix-osd-monitor: 6/6] power, media-keys: Signal connector rather than output ID



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

    power,media-keys: Signal connector rather than output ID
    
    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

 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               | 20 ++++++--------
 plugins/power/gsd-backlight.h               |  3 +-
 plugins/power/gsd-power-manager.c           |  8 +++---
 6 files changed, 42 insertions(+), 46 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 c51d3bff..a3c9113b 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 */
@@ -371,7 +370,7 @@ show_osd_with_max_level (GsdMediaKeysManager *manager,
                          const char          *label,
                          int                  level,
                          int                  max_level,
-                         int                  output_id)
+                         const gchar         *connector)
 {
         GsdMediaKeysManagerPrivate *priv = GSD_MEDIA_KEYS_MANAGER_GET_PRIVATE (manager);
 
@@ -379,7 +378,7 @@ show_osd_with_max_level (GsdMediaKeysManager *manager,
                 return;
 
         shell_show_osd_with_max_level (priv->shell_proxy,
-                                       icon, label, level, max_level, output_id);
+                                       icon, label, level, max_level, connector);
 }
 
 static void
@@ -387,10 +386,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 *
@@ -1055,7 +1054,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 */
@@ -1132,7 +1131,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
@@ -1268,9 +1267,9 @@ update_dialog (GsdMediaKeysManager *manager,
                 device = gvc_mixer_control_lookup_device_from_stream (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) {
@@ -1744,7 +1743,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;
         }
 
@@ -1901,7 +1900,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
@@ -2159,11 +2158,12 @@ 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);
         GsdMediaKeysManagerPrivate *priv = GSD_MEDIA_KEYS_MANAGER_GET_PRIVATE (manager);
         const char *icon, *debug;
+        char *connector = NULL;
 
         /* update the dialog with the new value */
         if (G_DBUS_PROXY (source_object) == priv->power_keyboard_proxy) {
@@ -2185,14 +2185,13 @@ update_brightness_cb (GObject             *source_object,
         /* update the dialog with the new value */
         if (G_DBUS_PROXY (source_object) == 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);
 }
 
@@ -2273,7 +2272,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);
@@ -2328,17 +2327,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:
@@ -2367,7 +2366,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;
         }
 
@@ -3507,7 +3506,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 304c6d57..82f507b9 100644
--- a/plugins/power/gsd-backlight.c
+++ b/plugins/power/gsd-backlight.c
@@ -700,29 +700,25 @@ gsd_backlight_cycle_up_finish (GsdBacklight *backlight,
 }
 
 /**
- * gsd_backlight_get_output_id
+ * gsd_backlight_get_connector
  * @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 71086a32..e4fac6b8 100644
--- a/plugins/power/gsd-backlight.h
+++ b/plugins/power/gsd-backlight.h
@@ -70,7 +70,8 @@ gint gsd_backlight_cycle_up_finish       (GsdBacklight         *backlight,
                                           GAsyncResult         *res,
                                           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 6af787f5..c544dc7d 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>"
 "    <method name='Cycle'>"
 "      <arg type='i' name='new_percentage' direction='out'/>"
@@ -2795,9 +2795,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]