aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Djärv2012-08-13 21:12:26 +0200
committerJan Djärv2012-08-13 21:12:26 +0200
commitca06f160f428224a98cbd6e3ea0dac89b99119ef (patch)
tree506600b9abcb0993a82fc81c8016ca458d7b9ec9
parentaa7c6dbeba48522d892cbf011c40a9fef0c369f7 (diff)
downloademacs-ca06f160f428224a98cbd6e3ea0dac89b99119ef.tar.gz
emacs-ca06f160f428224a98cbd6e3ea0dac89b99119ef.zip
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.
-rw-r--r--src/ChangeLog12
-rw-r--r--src/gtkutil.c84
2 files changed, 96 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a30c5af1eb9..538a8d235de 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,15 @@
12012-08-13 Jan Djärv <jan.h.d@swipnet.se>
2
3 * gtkutil.c (xg_frame_tb_info): New struct.
4 (TB_INFO_KEY): New define.
5 (xg_free_frame_widgets): Free xg_frame_tb_info for frame if present.
6 (xg_mark_data): Mark Lisp_Objects in xg_frame_tb_info.
7 (xg_create_tool_bar): Allocate and initialize a xg_frame_tb_info
8 if not present.
9 (update_frame_tool_bar): Return early if data in xg_frame_tb_info
10 is up to date. Otherwise store new data.
11 (free_frame_tool_bar): Free xg_frame_tb_info if present.
12
12012-08-13 Dmitry Antipov <dmantipov@yandex.ru> 132012-08-13 Dmitry Antipov <dmantipov@yandex.ru>
2 14
3 Use KSET for write access to Lisp_Object members of struct kboard. 15 Use KSET for write access to Lisp_Object members of struct kboard.
diff --git a/src/gtkutil.c b/src/gtkutil.c
index dec4ee079e2..6b74e27eb7a 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -110,6 +110,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
110 110
111static void update_theme_scrollbar_width (void); 111static void update_theme_scrollbar_width (void);
112 112
113#define TB_INFO_KEY "xg_frame_tb_info"
114struct xg_frame_tb_info
115{
116 Lisp_Object last_tool_bar;
117 Lisp_Object style;
118 int n_last_items;
119 int hmargin, vmargin;
120 GtkTextDirection dir;
121};
122
113 123
114/*********************************************************************** 124/***********************************************************************
115 Display handling functions 125 Display handling functions
@@ -1277,6 +1287,12 @@ xg_free_frame_widgets (FRAME_PTR f)
1277#ifdef USE_GTK_TOOLTIP 1287#ifdef USE_GTK_TOOLTIP
1278 struct x_output *x = f->output_data.x; 1288 struct x_output *x = f->output_data.x;
1279#endif 1289#endif
1290 struct xg_frame_tb_info *tbinfo
1291 = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
1292 TB_INFO_KEY);
1293 if (tbinfo)
1294 xfree (tbinfo);
1295
1280 gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f)); 1296 gtk_widget_destroy (FRAME_GTK_OUTER_WIDGET (f));
1281 FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */ 1297 FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
1282 FRAME_GTK_OUTER_WIDGET (f) = 0; 1298 FRAME_GTK_OUTER_WIDGET (f) = 0;
@@ -2145,6 +2161,24 @@ xg_mark_data (void)
2145 if (! NILP (cb_data->help)) 2161 if (! NILP (cb_data->help))
2146 mark_object (cb_data->help); 2162 mark_object (cb_data->help);
2147 } 2163 }
2164
2165 Lisp_Object rest, frame;
2166 FOR_EACH_FRAME (rest, frame)
2167 {
2168 FRAME_PTR f = XFRAME (frame);
2169
2170 if (FRAME_X_OUTPUT (f) && FRAME_GTK_OUTER_WIDGET (f))
2171 {
2172 struct xg_frame_tb_info *tbinfo
2173 = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
2174 TB_INFO_KEY);
2175 if (tbinfo)
2176 {
2177 mark_object (tbinfo->last_tool_bar);
2178 mark_object (tbinfo->style);
2179 }
2180 }
2181 }
2148} 2182}
2149 2183
2150 2184
@@ -4220,6 +4254,21 @@ xg_create_tool_bar (FRAME_PTR f)
4220#if GTK_CHECK_VERSION (3, 3, 6) 4254#if GTK_CHECK_VERSION (3, 3, 6)
4221 GtkStyleContext *gsty; 4255 GtkStyleContext *gsty;
4222#endif 4256#endif
4257 struct xg_frame_tb_info *tbinfo
4258 = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
4259 TB_INFO_KEY);
4260 if (! tbinfo)
4261 {
4262 tbinfo = xmalloc (sizeof (*tbinfo));
4263 tbinfo->last_tool_bar = Qnil;
4264 tbinfo->style = Qnil;
4265 tbinfo->hmargin = tbinfo->vmargin = 0;
4266 tbinfo->dir = GTK_TEXT_DIR_NONE;
4267 tbinfo->n_last_items = 0;
4268 g_object_set_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
4269 TB_INFO_KEY,
4270 tbinfo);
4271 }
4223 4272
4224 x->toolbar_widget = gtk_toolbar_new (); 4273 x->toolbar_widget = gtk_toolbar_new ();
4225 x->toolbar_detached = 0; 4274 x->toolbar_detached = 0;
@@ -4490,6 +4539,7 @@ update_frame_tool_bar (FRAME_PTR f)
4490 int pack_tool_bar = x->handlebox_widget == NULL; 4539 int pack_tool_bar = x->handlebox_widget == NULL;
4491 Lisp_Object style; 4540 Lisp_Object style;
4492 int text_image, horiz; 4541 int text_image, horiz;
4542 struct xg_frame_tb_info *tbinfo;
4493 4543
4494 if (! FRAME_GTK_WIDGET (f)) 4544 if (! FRAME_GTK_WIDGET (f))
4495 return; 4545 return;
@@ -4524,6 +4574,29 @@ update_frame_tool_bar (FRAME_PTR f)
4524 dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar)); 4574 dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar));
4525 4575
4526 style = Ftool_bar_get_system_style (); 4576 style = Ftool_bar_get_system_style ();
4577
4578 /* Are we up to date? */
4579 tbinfo = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
4580 TB_INFO_KEY);
4581
4582 if (! NILP (tbinfo->last_tool_bar) && ! NILP (f->tool_bar_items)
4583 && tbinfo->n_last_items == f->n_tool_bar_items
4584 && tbinfo->hmargin == hmargin && tbinfo->vmargin == vmargin
4585 && tbinfo->dir == dir
4586 && Fequal (tbinfo->style, style) == Qt
4587 && Fequal (tbinfo->last_tool_bar, f->tool_bar_items) == Qt)
4588 {
4589 UNBLOCK_INPUT;
4590 return;
4591 }
4592
4593 tbinfo->last_tool_bar = f->tool_bar_items;
4594 tbinfo->n_last_items = f->n_tool_bar_items;
4595 tbinfo->style = style;
4596 tbinfo->hmargin = hmargin;
4597 tbinfo->vmargin = vmargin;
4598 tbinfo->dir = dir;
4599
4527 text_image = EQ (style, Qtext_image_horiz); 4600 text_image = EQ (style, Qtext_image_horiz);
4528 horiz = EQ (style, Qboth_horiz) || text_image; 4601 horiz = EQ (style, Qboth_horiz) || text_image;
4529 4602
@@ -4737,6 +4810,7 @@ free_frame_tool_bar (FRAME_PTR f)
4737 4810
4738 if (x->toolbar_widget) 4811 if (x->toolbar_widget)
4739 { 4812 {
4813 struct xg_frame_tb_info *tbinfo;
4740 int is_packed = x->handlebox_widget != 0; 4814 int is_packed = x->handlebox_widget != 0;
4741 BLOCK_INPUT; 4815 BLOCK_INPUT;
4742 /* We may have created the toolbar_widget in xg_create_tool_bar, but 4816 /* We may have created the toolbar_widget in xg_create_tool_bar, but
@@ -4758,6 +4832,16 @@ free_frame_tool_bar (FRAME_PTR f)
4758 FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0; 4832 FRAME_TOOLBAR_TOP_HEIGHT (f) = FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = 0;
4759 FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0; 4833 FRAME_TOOLBAR_LEFT_WIDTH (f) = FRAME_TOOLBAR_RIGHT_WIDTH (f) = 0;
4760 4834
4835 tbinfo = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
4836 TB_INFO_KEY);
4837 if (tbinfo)
4838 {
4839 xfree (tbinfo);
4840 g_object_set_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
4841 TB_INFO_KEY,
4842 NULL);
4843 }
4844
4761 xg_height_or_width_changed (f); 4845 xg_height_or_width_changed (f);
4762 4846
4763 UNBLOCK_INPUT; 4847 UNBLOCK_INPUT;