View | Details | Raw Unified | Return to bug 231395
Collapse All | Expand All

(-)x11/xfce4-taskmanager/files/patch-src_app-manager.c (+60 lines)
Line 0 Link Here
1
--- src/app-manager.c	2018-05-30 22:29:22.000000000 +0300
2
+++ src/app-manager.c	2018-06-21 12:08:04.839503000 +0300
3
@@ -44,6 +44,7 @@
4
 static void	apps_add_application				(GArray *apps, WnckApplication *application, GPid pid);
5
 static void	apps_remove_application				(GArray *apps, WnckApplication *application);
6
 static App *	apps_lookup_pid					(GArray *apps, GPid pid);
7
+static App *	apps_lookup_app					(GArray *apps, WnckApplication *application);
8
 static void	application_opened				(WnckScreen *screen, WnckApplication *application, XtmAppManager *manager);
9
 static void	application_closed				(WnckScreen *screen, WnckApplication *application, XtmAppManager *manager);
10
 
11
@@ -97,12 +98,17 @@
12
 app_get_pid(WnckApplication *application)
13
 {
14
 	GPid pid;
15
+	GList *windows;
16
+
17
 	if (NULL == application)
18
 		return (0);
19
 	pid = wnck_application_get_pid (application);
20
 	if (pid != 0)
21
 		return (pid);
22
-	return (wnck_window_get_pid (WNCK_WINDOW (wnck_application_get_windows (application)->data)));
23
+	windows = wnck_application_get_windows (application);
24
+	if (NULL != windows && NULL != windows->data)
25
+		return (wnck_window_get_pid (WNCK_WINDOW (windows->data)));
26
+	return (0);
27
 }
28
 
29
 static gint
30
@@ -135,6 +141,8 @@
31
 	App *app = apps_lookup_pid(apps, app_get_pid (application));
32
 
33
 	if (app == NULL)
34
+		app = apps_lookup_app(apps, application);
35
+	if (app == NULL)
36
 		return;
37
 	g_object_unref (app->icon);
38
 	g_array_remove_index (apps, (guint)(((size_t)app - (size_t)apps->data) / sizeof(App)));
39
@@ -150,6 +158,21 @@
40
 	return (bsearch(&tapp, apps->data, apps->len, sizeof(App), app_pid_compare_fn));
41
 }
42
 
43
+static App *
44
+apps_lookup_app (GArray *apps, WnckApplication *application)
45
+{
46
+	App *tapp;
47
+	guint i;
48
+
49
+	for (i = 0; i < apps->len; i++) {
50
+		tapp = &g_array_index (apps, App, i);
51
+		if (tapp->application == application)
52
+			return (tapp);
53
+	}
54
+
55
+	return (NULL);
56
+}
57
+
58
 static void
59
 application_opened (WnckScreen *screen __unused, WnckApplication *application, XtmAppManager *manager)
60
 {
(-)x11/xfce4-taskmanager/files/patch-src_task-manager.c (+70 lines)
Line 0 Link Here
1
--- src/task-manager.c	2018-06-03 18:43:41.000000000 +0300
2
+++ src/task-manager.c	2018-07-29 09:21:33.383945000 +0300
3
@@ -22,6 +22,7 @@
4
 #include <glib-object.h>
5
 #include <glib/gi18n.h>
6
 #include <gtk/gtk.h>
7
+#include <gmodule.h>
8
 
9
 #include "task-manager.h"
10
 #ifdef HAVE_WNCK
11
@@ -125,12 +126,44 @@
12
 static gchar *
13
 pretty_cmdline (gchar *cmdline, gchar *comm)
14
 {
15
-	/* Use the printable range of 0x20-0x7E */
16
-	const gchar *valid_chars = " !\"#$%&'()*+,-./0123456789:;<=>?@"
17
-				   "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
18
-				   "abcdefghijklmnopqrstuvwxyz{|}~";
19
-	gchar *text = g_strstrip (g_strcanon (g_strdup (cmdline), valid_chars, ' '));
20
-	gsize text_size = (gsize)strlen (text);
21
+	gunichar c;
22
+	gchar *ch, *text_max, *text = g_strstrip (g_strdup (cmdline));
23
+	gsize csize, text_size = (gsize)strlen (text);
24
+
25
+	/* UTF-8 normalize. */
26
+	do {
27
+		for (ch = text, text_max = (text + text_size);
28
+		     text_max > ch;
29
+		     text_max = (text + text_size), ch = g_utf8_next_char(ch)) {
30
+			c = g_utf8_get_char_validated(ch, -1); /* If use (text_max - ch) - result is worse. */
31
+			if ((gunichar)-2 == c) {
32
+				text_size = (gsize)(ch - text);
33
+				(*ch) = 0;
34
+				break;
35
+			}
36
+			if ((gunichar)-1 == c) {
37
+				(*ch) = ' ';
38
+				continue;
39
+			}
40
+			csize = (gsize)g_unichar_to_utf8(c, NULL);
41
+
42
+			if (!g_unichar_isdefined(c) ||
43
+			    !g_unichar_isprint(c) ||
44
+			    (g_unichar_isspace(c) && (1 != csize || (' ' != (*ch) && '	' != (*ch)))) ||
45
+			    g_unichar_ismark(c) ||
46
+			    g_unichar_istitle(c) ||
47
+			    g_unichar_iswide(c) ||
48
+			    g_unichar_iszerowidth(c) ||
49
+			    g_unichar_iscntrl(c)) {
50
+				if (text_max < (ch + csize))
51
+					break;
52
+				memmove(ch, (ch + csize), (gsize)(text_max - (ch + csize)));
53
+				text_size -= csize;
54
+			}
55
+		}
56
+		text[text_size] = 0;
57
+	} while (!g_utf8_validate(text, (gssize)text_size, NULL));
58
+
59
 	if (!full_cmdline && text_size > 3)
60
 	{
61
 		/* Shorten full path to commands and wine applications */
62
@@ -139,7 +172,7 @@
63
 			gchar *p = g_strstr_len (text, (gssize)text_size, comm);
64
 			if (p != NULL)
65
 			{
66
-				g_strlcpy (text, p, text_size);
67
+				memmove (text, p, text_size);
68
 			}
69
 		}
70
 	}

Return to bug 231395