[Xfce4-commits] [apps/xfce4-taskmanager] 01/01: Improve app search on close (bug 14466)

noreply at xfce.org noreply at xfce.org
Fri Jun 22 11:43:18 CEST 2018


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

l   a   n   d   r   y       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/xfce4-taskmanager.

commit af078d406a43243388e0a61d647c3a6b7ada60ed
Author: rim <rozhuk.im at gmail.com>
Date:   Thu Jun 21 12:10:15 2018 +0300

    Improve app search on close (bug 14466)
---
 src/app-manager.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/app-manager.c b/src/app-manager.c
index 5092e00..b2bdb0c 100644
--- a/src/app-manager.c
+++ b/src/app-manager.c
@@ -44,6 +44,7 @@ static gint	app_pid_compare_fn				(gconstpointer a, gconstpointer b);
 static void	apps_add_application				(GArray *apps, WnckApplication *application, GPid pid);
 static void	apps_remove_application				(GArray *apps, WnckApplication *application);
 static App *	apps_lookup_pid					(GArray *apps, GPid pid);
+static App *	apps_lookup_app					(GArray *apps, WnckApplication *application);
 static void	application_opened				(WnckScreen *screen, WnckApplication *application, XtmAppManager *manager);
 static void	application_closed				(WnckScreen *screen, WnckApplication *application, XtmAppManager *manager);
 
@@ -97,12 +98,17 @@ static GPid
 app_get_pid(WnckApplication *application)
 {
 	GPid pid;
+	GList *windows;
+
 	if (NULL == application)
 		return (0);
 	pid = wnck_application_get_pid (application);
 	if (pid != 0)
 		return (pid);
-	return (wnck_window_get_pid (WNCK_WINDOW (wnck_application_get_windows (application)->data)));
+	windows = wnck_application_get_windows (application);
+	if (NULL != windows && NULL != windows->data)
+		return (wnck_window_get_pid (WNCK_WINDOW (windows->data)));
+	return (0);
 }
 
 static gint
@@ -135,6 +141,8 @@ apps_remove_application (GArray *apps, WnckApplication *application)
 	App *app = apps_lookup_pid(apps, app_get_pid (application));
 
 	if (app == NULL)
+		app = apps_lookup_app(apps, application);
+	if (app == NULL)
 		return;
 	g_object_unref (app->icon);
 	g_array_remove_index (apps, (guint)(((size_t)app - (size_t)apps->data) / sizeof(App)));
@@ -150,6 +158,21 @@ apps_lookup_pid (GArray *apps, GPid pid)
 	return (bsearch(&tapp, apps->data, apps->len, sizeof(App), app_pid_compare_fn));
 }
 
+static App *
+apps_lookup_app (GArray *apps, WnckApplication *application)
+{
+	App *tapp;
+	guint i;
+
+	for (i = 0; i < apps->len; i++) {
+		tapp = &g_array_index (apps, App, i);
+		if (tapp->application == application)
+			return (tapp);
+	}
+
+	return (NULL);
+}
+
 static void
 application_opened (WnckScreen *screen __unused, WnckApplication *application, XtmAppManager *manager)
 {

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


More information about the Xfce4-commits mailing list