[Xfce4-commits] [apps/xfdashboard] 01/02: Cancel active pop-up menu when application was suspended

noreply at xfce.org noreply at xfce.org
Thu Oct 26 08:11:53 CEST 2017


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

n   o   m   a   d       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 apps/xfdashboard.

commit 95cfd982cce89b7e3a380d6b21495e48aaef5408
Author: Stephan Haller <nomad at froevel.de>
Date:   Thu Oct 26 08:09:52 2017 +0200

    Cancel active pop-up menu when application was suspended
    
    An active pop-up menu did not get notified when a daemonized instance was suspended. The result was that if the application resumed, the pop-up menu was still active. But that is not expected by the user. So cancel pop-up menu now when application suspends.
    
    This commit addresses issue GH #158
---
 libxfdashboard/popup-menu.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/libxfdashboard/popup-menu.c b/libxfdashboard/popup-menu.c
index aeec0d5..2f355a9 100644
--- a/libxfdashboard/popup-menu.c
+++ b/libxfdashboard/popup-menu.c
@@ -104,6 +104,8 @@ struct _XfdashboardPopupMenuPrivate
 	guint							capturedEventSignalID;
 
 	guint							sourceDestroySignalID;
+
+	guint							suspendSignalID;
 };
 
 /* Properties */
@@ -146,6 +148,37 @@ static guint XfdashboardPopupMenuSignals[SIGNAL_LAST]={ 0, };
 
 /* IMPLEMENTATION: Private variables and methods */
 
+/* Suspension state of application changed */
+static void _xfdashboard_popup_menu_on_application_suspended_changed(XfdashboardPopupMenu *self,
+																		GParamSpec *inSpec,
+																		gpointer inUserData)
+{
+	XfdashboardPopupMenuPrivate		*priv;
+	XfdashboardApplication			*application;
+	gboolean						isSuspended;
+
+	g_return_if_fail(XFDASHBOARD_IS_POPUP_MENU(self));
+	g_return_if_fail(XFDASHBOARD_IS_APPLICATION(inUserData));
+
+	priv=self->priv;
+	application=XFDASHBOARD_APPLICATION(inUserData);
+
+	/* Get application suspend state */
+	isSuspended=xfdashboard_application_is_suspended(application);
+
+	/* If application is suspended then cancel pop-up menu */
+	if(isSuspended)
+	{
+		XFDASHBOARD_DEBUG(self, ACTOR,
+							"Cancel active pop-up menu '%s' for source %s@%p because application was suspended",
+							xfdashboard_popup_menu_get_title(self),
+							priv->source ? G_OBJECT_TYPE_NAME(priv->source) : "<nil>",
+							priv->source);
+
+		xfdashboard_popup_menu_cancel(self);
+	}
+}
+
 /* An event occured after a popup menu was activated so check if popup menu should
  * be cancelled because a button was pressed and release outside the popup menu.
  */
@@ -723,6 +756,12 @@ static void _xfdashboard_popup_menu_dispose(GObject *inObject)
 	xfdashboard_popup_menu_cancel(self);
 
 	/* Release our allocated variables */
+	if(priv->suspendSignalID)
+	{
+		g_signal_handler_disconnect(xfdashboard_application_get_default(), priv->suspendSignalID);
+		priv->suspendSignalID=0;
+	}
+
 	if(priv->capturedEventSignalID)
 	{
 		g_signal_handler_disconnect(priv->stage, priv->capturedEventSignalID);
@@ -1116,6 +1155,7 @@ static void xfdashboard_popup_menu_init(XfdashboardPopupMenu *self)
 	priv->stage=NULL;
 	priv->capturedEventSignalID=0;
 	priv->sourceDestroySignalID=0;
+	priv->suspendSignalID=0;
 
 	/* This actor is react on events */
 	clutter_actor_set_reactive(CLUTTER_ACTOR(self), TRUE);
@@ -1155,6 +1195,12 @@ static void xfdashboard_popup_menu_init(XfdashboardPopupMenu *self)
 	/* Add popup menu to stage */
 	priv->stage=xfdashboard_application_get_stage(xfdashboard_application_get_default());
 	clutter_actor_insert_child_above(CLUTTER_ACTOR(priv->stage), CLUTTER_ACTOR(self), NULL);
+
+	/* Connect signal to get notified when application suspends to cancel pop-up menu */
+	priv->suspendSignalID=g_signal_connect_swapped(xfdashboard_application_get_default(),
+													"notify::is-suspended",
+													G_CALLBACK(_xfdashboard_popup_menu_on_application_suspended_changed),
+													self);
 }
 
 /* IMPLEMENTATION: Public API */

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


More information about the Xfce4-commits mailing list