Tue Jan 8 01:23:19 2013 UTC ()
x11/xfce4-terminal: PR#46926 PR#45448 Fix 100% CPU usage

Patch provided by Dave Tyson has multiple confirmations that it fixes
the issue of 100% CPU usage simply from opening terminal window.


(marino)
diff -r1.27 -r1.28 pkgsrc/x11/xfce4-terminal/Makefile
diff -r1.6 -r1.7 pkgsrc/x11/xfce4-terminal/distinfo
diff -r0 -r1.1 pkgsrc/x11/xfce4-terminal/patches/patch-terminal_terminal-screen.c

cvs diff -r1.27 -r1.28 pkgsrc/x11/xfce4-terminal/Makefile (expand / switch to unified diff)

--- pkgsrc/x11/xfce4-terminal/Makefile 2012/10/29 05:07:10 1.27
+++ pkgsrc/x11/xfce4-terminal/Makefile 2013/01/08 01:23:18 1.28
@@ -1,22 +1,22 @@ @@ -1,22 +1,22 @@
1# $NetBSD: Makefile,v 1.27 2012/10/29 05:07:10 asau Exp $ 1# $NetBSD: Makefile,v 1.28 2013/01/08 01:23:18 marino Exp $
2 2
3.include "../../meta-pkgs/xfce4/Makefile.common" 3.include "../../meta-pkgs/xfce4/Makefile.common"
4 4
5XFCE4_VERSION= 0.4.2 5XFCE4_VERSION= 0.4.2
6 6
7DISTNAME= Terminal-${XFCE4_VERSION} 7DISTNAME= Terminal-${XFCE4_VERSION}
8PKGNAME= xfce4-terminal-${XFCE4_VERSION} 8PKGNAME= xfce4-terminal-${XFCE4_VERSION}
9PKGREVISION= 13 9PKGREVISION= 14
10CATEGORIES= x11 10CATEGORIES= x11
11COMMENT= Xfce terminal emulator 11COMMENT= Xfce terminal emulator
12 12
13MASTER_SITES= http://www.xfce.org/archive/src/apps/terminal/0.4/ 13MASTER_SITES= http://www.xfce.org/archive/src/apps/terminal/0.4/
14 14
15MAKE_JOBS_SAFE= no 15MAKE_JOBS_SAFE= no
16 16
17.include "../../graphics/hicolor-icon-theme/buildlink3.mk" 17.include "../../graphics/hicolor-icon-theme/buildlink3.mk"
18.include "../../sysutils/dbus/buildlink3.mk" 18.include "../../sysutils/dbus/buildlink3.mk"
19.include "../../sysutils/dbus-glib/buildlink3.mk" 19.include "../../sysutils/dbus-glib/buildlink3.mk"
20.include "../../sysutils/desktop-file-utils/desktopdb.mk" 20.include "../../sysutils/desktop-file-utils/desktopdb.mk"
21.include "../../x11/startup-notification/buildlink3.mk" 21.include "../../x11/startup-notification/buildlink3.mk"
22.include "../../x11/vte/buildlink3.mk" 22.include "../../x11/vte/buildlink3.mk"

cvs diff -r1.6 -r1.7 pkgsrc/x11/xfce4-terminal/distinfo (expand / switch to unified diff)

--- pkgsrc/x11/xfce4-terminal/distinfo 2009/11/29 22:16:34 1.6
+++ pkgsrc/x11/xfce4-terminal/distinfo 2013/01/08 01:23:19 1.7
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
1$NetBSD: distinfo,v 1.6 2009/11/29 22:16:34 snj Exp $ 1$NetBSD: distinfo,v 1.7 2013/01/08 01:23:19 marino Exp $
2 2
3SHA1 (Terminal-0.4.2.tar.bz2) = bf4510e331284d7f68ba193fe1d6f2e57b7815bb 3SHA1 (Terminal-0.4.2.tar.bz2) = bf4510e331284d7f68ba193fe1d6f2e57b7815bb
4RMD160 (Terminal-0.4.2.tar.bz2) = 8e6364673d6b0d8eddfd59f3f82d3944fca45684 4RMD160 (Terminal-0.4.2.tar.bz2) = 8e6364673d6b0d8eddfd59f3f82d3944fca45684
5Size (Terminal-0.4.2.tar.bz2) = 1981158 bytes 5Size (Terminal-0.4.2.tar.bz2) = 1981158 bytes
 6SHA1 (patch-terminal_terminal-screen.c) = dcfa62798ea47e26ed65df031c09991f24d4fa7c

File Added: pkgsrc/x11/xfce4-terminal/patches/Attic/patch-terminal_terminal-screen.c
$NetBSD: patch-terminal_terminal-screen.c,v 1.1 2013/01/08 01:23:19 marino Exp $

Fix for 100% CPU usage on XFce4 Terminal (Dave Tyson)
PR# pkg/45448
PR# pkg/46926

--- terminal/terminal-screen.c.orig	2009-10-06 15:07:01.000000000 +0000
+++ terminal/terminal-screen.c
@@ -87,6 +87,7 @@ static gboolean   terminal_screen_get_ch
                                                                  GError               **error);
 static gchar    **terminal_screen_get_child_environment         (TerminalScreen        *screen);
 static void       terminal_screen_update_background             (TerminalScreen        *screen);
+static void       terminal_screen_update_background_fast        (TerminalScreen        *screen);
 static void       terminal_screen_update_binding_backspace      (TerminalScreen        *screen);
 static void       terminal_screen_update_binding_delete         (TerminalScreen        *screen);
 static void       terminal_screen_update_colors                 (TerminalScreen        *screen);
@@ -132,6 +133,8 @@ struct _TerminalScreen
   GtkWidget           *scrollbar;
   GtkWidget           *tab_label;
 
+  gulong              background_signal_id;
+
   GPid                 pid;
   gchar               *working_directory;
 
@@ -231,7 +234,6 @@ terminal_screen_init (TerminalScreen *sc
                     "signal::context-menu", G_CALLBACK (terminal_screen_vte_get_context_menu), screen,
                     "signal::selection-changed", G_CALLBACK (terminal_screen_vte_selection_changed), screen,
                     "signal::window-title-changed", G_CALLBACK (terminal_screen_vte_window_title_changed), screen,
-                    "swapped-signal::size-allocate", G_CALLBACK (terminal_screen_timer_background), screen,
                     "swapped-signal::style-set", G_CALLBACK (terminal_screen_update_colors), screen,
                     NULL);
   gtk_box_pack_start (GTK_BOX (screen), screen->terminal, TRUE, TRUE, 0);
@@ -573,6 +575,18 @@ terminal_screen_get_child_environment (T
 
 
 static void
+terminal_screen_update_background_fast (TerminalScreen *screen)
+{
+  if (G_UNLIKELY (screen->background_timer_id == 0))
+    {
+      screen->background_timer_id = g_idle_add_full (G_PRIORITY_LOW, terminal_screen_timer_background,
+                                                     screen, terminal_screen_timer_background_destroy);
+    }
+}
+
+
+
+static void
 terminal_screen_update_background (TerminalScreen *screen)
 {
   if (G_UNLIKELY (screen->background_timer_id != 0))
@@ -1015,9 +1029,25 @@ terminal_screen_timer_background (gpoint
       if (G_LIKELY (image != NULL))
         g_object_unref (G_OBJECT (image));
       g_object_unref (G_OBJECT (loader));
+      
+            /* refresh background on size changes */
+            if (screen->background_signal_id == 0)
+              {
+                screen->background_signal_id =
+                   g_signal_connect_swapped (G_OBJECT (screen->terminal), "size-allocate",
+                                             G_CALLBACK (terminal_screen_update_background_fast), screen);
+              }
     }
   else
     {
+          /* stop updating on size changes */
+          if (screen->background_signal_id != 0)
+            {
+              g_signal_handler_disconnect (G_OBJECT (screen->terminal), screen->background_signal_id);
+              screen->background_signal_id = 0;
+            }
+    
+          /* WARNING: the causes a resize too! */
       vte_terminal_set_background_image (VTE_TERMINAL (screen->terminal), NULL);
     }