emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r109586: Don't redraw tool bar for Gt


From: Jan D.
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r109586: Don't redraw tool bar for Gtk+ unless out of date.
Date: Mon, 13 Aug 2012 21:12:26 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 109586
committer: Jan D. <address@hidden>
branch nick: trunk
timestamp: Mon 2012-08-13 21:12:26 +0200
message:
  Don't redraw tool bar for Gtk+ unless out of date.
  
  * gtkutil.c (xg_frame_tb_info): New struct.
  (TB_INFO_KEY): New define.
  (xg_free_frame_widgets): Free xg_frame_tb_info for frame if present.
  (xg_mark_data): Mark Lisp_Objects in xg_frame_tb_info.
  (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info
  if not present.
  (update_frame_tool_bar): Return early if data in xg_frame_tb_info
  is up to date. Otherwise store new data.
  (free_frame_tool_bar): Free xg_frame_tb_info if present.
modified:
  src/ChangeLog
  src/gtkutil.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-08-13 03:44:27 +0000
+++ b/src/ChangeLog     2012-08-13 19:12:26 +0000
@@ -1,3 +1,15 @@
+2012-08-13  Jan Djärv  <address@hidden>
+
+       * gtkutil.c (xg_frame_tb_info): New struct.
+       (TB_INFO_KEY): New define.
+       (xg_free_frame_widgets): Free xg_frame_tb_info for frame if present.
+       (xg_mark_data): Mark Lisp_Objects in xg_frame_tb_info.
+       (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info
+       if not present.
+       (update_frame_tool_bar): Return early if data in xg_frame_tb_info
+       is up to date. Otherwise store new data.
+       (free_frame_tool_bar): Free xg_frame_tb_info if present.
+
 2012-08-13  Dmitry Antipov  <address@hidden>
 
        Use KSET for write access to Lisp_Object members of struct kboard.

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2012-08-11 08:54:35 +0000
+++ b/src/gtkutil.c     2012-08-13 19:12:26 +0000
@@ -110,6 +110,16 @@
 
 static void update_theme_scrollbar_width (void);
 
+#define TB_INFO_KEY "xg_frame_tb_info"
+struct xg_frame_tb_info
+{
+  Lisp_Object last_tool_bar;
+  Lisp_Object style;
+  int n_last_items;
+  int hmargin, vmargin;
+  GtkTextDirection dir;
+};
+
 
 /***********************************************************************
                       Display handling functions
@@ -1277,6 +1287,12 @@
 #ifdef USE_GTK_TOOLTIP
       struct x_output *x = f->output_data.x;
 #endif
+      struct xg_frame_tb_info *tbinfo
+        = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                             TB_INFO_KEY);
+      if (tbinfo)
+        xfree (tbinfo);
+
       gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
       FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
       FRAME_GTK_OUTER_WIDGET (f) = 0;
@@ -2145,6 +2161,24 @@
       if (! NILP (cb_data->help))
         mark_object (cb_data->help);
     }
+
+  Lisp_Object rest, frame;
+  FOR_EACH_FRAME (rest, frame)
+    {
+      FRAME_PTR f = XFRAME (frame);
+
+      if (FRAME_X_OUTPUT (f) && FRAME_GTK_OUTER_WIDGET (f))
+        {
+          struct xg_frame_tb_info *tbinfo
+            = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                                 TB_INFO_KEY);
+          if (tbinfo)
+            {
+              mark_object (tbinfo->last_tool_bar);
+              mark_object (tbinfo->style);
+            }
+        }
+    }
 }
 
 
@@ -4220,6 +4254,21 @@
 #if GTK_CHECK_VERSION (3, 3, 6)
   GtkStyleContext *gsty;
 #endif
+  struct xg_frame_tb_info *tbinfo
+    = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                         TB_INFO_KEY);
+  if (! tbinfo)
+    {
+      tbinfo = xmalloc (sizeof (*tbinfo));
+      tbinfo->last_tool_bar = Qnil;
+      tbinfo->style = Qnil;
+      tbinfo->hmargin = tbinfo->vmargin = 0;
+      tbinfo->dir = GTK_TEXT_DIR_NONE;
+      tbinfo->n_last_items = 0;
+      g_object_set_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                         TB_INFO_KEY,
+                         tbinfo);
+    }
 
   x->toolbar_widget = gtk_toolbar_new ();
   x->toolbar_detached = 0;
@@ -4490,6 +4539,7 @@
   int pack_tool_bar = x->handlebox_widget == NULL;
   Lisp_Object style;
   int text_image, horiz;
+  struct xg_frame_tb_info *tbinfo;
 
   if (! FRAME_GTK_WIDGET (f))
     return;
@@ -4524,6 +4574,29 @@
   dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar));
 
   style = Ftool_bar_get_system_style ();
+
+  /* Are we up to date? */
+  tbinfo = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                              TB_INFO_KEY);
+
+  if (! NILP (tbinfo->last_tool_bar) && ! NILP (f->tool_bar_items)
+      && tbinfo->n_last_items == f->n_tool_bar_items
+      && tbinfo->hmargin == hmargin && tbinfo->vmargin == vmargin
+      && tbinfo->dir == dir
+      && Fequal (tbinfo->style, style) == Qt
+      && Fequal (tbinfo->last_tool_bar, f->tool_bar_items) == Qt)
+    {
+      UNBLOCK_INPUT;
+      return;
+    }
+
+  tbinfo->last_tool_bar = f->tool_bar_items;
+  tbinfo->n_last_items = f->n_tool_bar_items;
+  tbinfo->style = style;
+  tbinfo->hmargin = hmargin;
+  tbinfo->vmargin = vmargin;
+  tbinfo->dir = dir;
+
   text_image = EQ (style, Qtext_image_horiz);
   horiz = EQ (style, Qboth_horiz) || text_image;
 
@@ -4737,6 +4810,7 @@
 
   if (x->toolbar_widget)
     {
+      struct xg_frame_tb_info *tbinfo;
       int is_packed = x->handlebox_widget != 0;
       BLOCK_INPUT;
       /* We may have created the toolbar_widget in xg_create_tool_bar, but
@@ -4758,6 +4832,16 @@
       FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
       FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0;
 
+      tbinfo = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                                  TB_INFO_KEY);
+      if (tbinfo)
+        {
+          xfree (tbinfo);
+          g_object_set_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
+                             TB_INFO_KEY,
+                             NULL);
+        }
+
       xg_height_or_width_changed (f);
 
       UNBLOCK_INPUT;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]