[Xfce4-commits] [panel-plugins/xfce4-pulseaudio-plugin] 01/01: wnck: Keep connection to xid once found, move logic out of menu item and into player

noreply at xfce.org noreply at xfce.org
Mon Dec 4 05:03:51 CET 2017


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

b   l   u   e   s   a   b   r   e       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 panel-plugins/xfce4-pulseaudio-plugin.

commit bac5679ec9b6f506e26bbe731a55de4f4b5e0e89
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Dec 3 23:03:45 2017 -0500

    wnck: Keep connection to xid once found, move logic out of menu item and into player
---
 panel-plugin/mprismenuitem.c           | 43 ++---------------------------
 panel-plugin/pulseaudio-mpris-player.c | 50 ++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/panel-plugin/mprismenuitem.c b/panel-plugin/mprismenuitem.c
index 4af905e..b14d254 100644
--- a/panel-plugin/mprismenuitem.c
+++ b/panel-plugin/mprismenuitem.c
@@ -34,11 +34,6 @@
 #include <gdk/gdkkeysyms.h>
 #include <gio/gdesktopappinfo.h>
 
-#ifdef HAVE_WNCK
-#define WNCK_I_KNOW_THIS_IS_UNSTABLE = 1
-#include <libwnck/libwnck.h>
-#endif
-
 
 
 /* for DBG/TRACE */
@@ -474,7 +469,7 @@ mpris_menu_item_class_init (MprisMenuItemClass *item_class)
    * @menuitem: the #MprisMenuItem for which the value changed
    * @value: the mpris signal to emit
    *
-   * Emitted whenever the a media button is clicked.
+   * Emitted whenever a media button is clicked.
    */
   signals[MEDIA_NOTIFY] = g_signal_new ("media-notify",
                                         TYPE_MPRIS_MENU_ITEM,
@@ -561,7 +556,7 @@ mpris_menu_item_raise (MprisMenuItem *item)
 #ifdef HAVE_WNCK
       else if (priv->can_raise_wnck)
         {
-          mpris_menu_item_raise_window (item);
+          media_notify (item, "RaiseWnck");
         }
 #endif
     }
@@ -569,40 +564,6 @@ mpris_menu_item_raise (MprisMenuItem *item)
 
 
 
-#ifdef HAVE_WNCK
-/**
- * Alternative "Raise" method.
- * Some media players (e.g. Spotify) do not support the "Raise" method.
- * This workaround utilizes libwnck to find the correct window and raise it.
- */
-static void
-mpris_menu_item_raise_window (MprisMenuItem *item)
-{
-  MprisMenuItemPrivate *priv;
-  WnckScreen           *screen = NULL;
-  GList                *window = NULL;
-
-  g_return_if_fail (IS_MPRIS_MENU_ITEM (item));
-
-  priv = GET_PRIVATE (item);
-
-  screen = wnck_screen_get_default ();
-  if (screen != NULL)
-    {
-      wnck_screen_force_update (screen);
-      for (window = wnck_screen_get_windows (screen); window != NULL; window = window->next)
-        {
-          if (0 == g_strcmp0 (priv->title, wnck_window_get_name (WNCK_WINDOW (window->data))))
-            {
-              wnck_window_activate (WNCK_WINDOW (window->data), 0);
-            }
-        }
-    }
-}
-#endif
-
-
-
 static void
 mpris_menu_item_launch (MprisMenuItem *item)
 {
diff --git a/panel-plugin/pulseaudio-mpris-player.c b/panel-plugin/pulseaudio-mpris-player.c
index 4ba1037..480cf5f 100644
--- a/panel-plugin/pulseaudio-mpris-player.c
+++ b/panel-plugin/pulseaudio-mpris-player.c
@@ -26,6 +26,11 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 
+#ifdef HAVE_WNCK
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE = 1
+#include <libwnck/libwnck.h>
+#endif
+
 #include "pulseaudio-mpris-player.h"
 
 
@@ -60,6 +65,8 @@ struct _PulseaudioMprisPlayer
   guint             watch_id;
 
   GHashTable       *playlists;
+
+  gulong            xid;
 };
 
 struct _PulseaudioMprisPlayerClass
@@ -176,6 +183,44 @@ pulseaudio_mpris_player_parse_metadata (PulseaudioMprisPlayer *player,
 
 
 
+#ifdef HAVE_WNCK
+/**
+ * Alternative "Raise" method.
+ * Some media players (e.g. Spotify) do not support the "Raise" method.
+ * This workaround utilizes libwnck to find the correct window and raise it.
+ */
+static void
+pulseaudio_mpris_player_raise_wnck (PulseaudioMprisPlayer *player)
+{
+  WnckScreen           *screen = NULL;
+  GList                *window = NULL;
+
+  screen = wnck_screen_get_default ();
+  if (screen != NULL)
+    {
+      wnck_screen_force_update (screen);
+      if (player->xid == 0L)
+        {
+          for (window = wnck_screen_get_windows (screen); window != NULL; window = window->next)
+            {
+              if (0 == g_strcmp0 (player->player_label, wnck_window_get_name (WNCK_WINDOW (window->data))))
+                {
+                  player->xid = wnck_window_get_xid (WNCK_WINDOW (window->data));
+                }
+            }
+        }
+
+      if (player->xid > 0L)
+        {
+          WnckWindow *wdw = wnck_window_get (player->xid);
+          wnck_window_activate (wdw, 0);
+        }
+    }
+}
+#endif
+
+
+
 void
 pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
                                             const gchar           *method)
@@ -186,6 +231,10 @@ pulseaudio_mpris_player_call_player_method (PulseaudioMprisPlayer *player,
 
   if (g_strcmp0 (method, "Raise") == 0)
     iface = "org.mpris.MediaPlayer2";
+#ifdef HAVE_WNCK
+  else if (g_strcmp0 (method, "RaiseWnck") == 0)
+    return pulseaudio_mpris_player_raise_wnck (player);
+#endif
   else if (g_strcmp0 (method, "Quit") == 0)
     iface = "org.mpris.MediaPlayer2";
   else
@@ -556,6 +605,7 @@ pulseaudio_mpris_player_on_dbus_lost (GDBusConnection *connection,
 
   player->title           = NULL;
   player->artist          = NULL;
+  player->xid             = 0L;
 
   g_signal_emit (player, signals[CONNECTION], 0, player->connected);
 }

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


More information about the Xfce4-commits mailing list