aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2004-10-27 05:42:04 +0000
committerMiles Bader2004-10-27 05:42:04 +0000
commite0da2cddda8d2244be17fe33fd3130af8c8041c8 (patch)
tree4f29220860cddf776e784932fde024d8ca03c802 /src
parent69c48766bbee2af7643b8995213120216b26a73e (diff)
parente65837df545fcf0791b3c8db27186e605cf89538 (diff)
downloademacs-e0da2cddda8d2244be17fe33fd3130af8c8041c8.tar.gz
emacs-e0da2cddda8d2244be17fe33fd3130af8c8041c8.zip
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-65
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-634 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-639 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-640 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-641 Update from CVS * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-59 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-60 Update from CVS
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog43
-rw-r--r--src/buffer.c12
-rw-r--r--src/callint.c23
-rw-r--r--src/fontset.c26
-rw-r--r--src/gtkutil.c105
-rw-r--r--src/regex.c3
-rw-r--r--src/regex.h3
-rw-r--r--src/xfns.c17
-rw-r--r--src/xsmfns.c82
9 files changed, 241 insertions, 73 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index efb792df4d6..2b0f6922ed6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,46 @@
12004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
2
3 * gtkutil.c: Put empty line between comment and function body.
4 (xg_destroy_widgets): Renamed from remove_from_container. Just
5 destroy all widgets in list. Argument wcont removed.
6 (xg_update_menubar, xg_update_submenu): Call xg_destroy_widgets
7 instead of remove_from_container.
8 (xg_display_close, xg_create_tool_bar, update_frame_tool_bar)
9 (free_frame_tool_bar): Add comment.
10
11 * xfns.c (xic_create_xfontset): Check that FRAME_XIC_BASE_FONTNAME
12 is not NULL before strcmp.
13
142004-10-26 Kim F. Storm <storm@cua.dk>
15
16 * callint.c (Fcall_interactively): Add 'U' code to get the
17 up-event discarded by a previous 'k' or 'K' argument.
18
192004-10-26 David Kastrup <dak@gnu.org>
20
21 * buffer.c (syms_of_buffer): Fix a few typos.
22
232004-10-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
24
25 * xsmfns.c: Put empty line between comment and function body.
26 Use two spaces before comment end.
27
282004-10-25 Kenichi Handa <handa@m17n.org>
29
30 * fontset.c (fontset_pattern_regexp): Optimize for the case that
31 PATTERN is full XLFD.
32
332004-10-24 Kenichi Handa <handa@m17n.org>
34
35 * regex.h (enum reg_errcode_t): New value REG_ERANGEX.
36
37 * regex.c (re_error_msgid): Add an entry for REG_ERANGEX.
38 (regex_compile): Return REG_ERANGEX if appropriate.
39
402004-10-22 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
41
42 * xfns.c (xic_create_xfontset): Initialize missing_list to NULL.
43
12004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu> 442004-10-21 K,Aa(Broly L$,1 q(Brentey <lorentey@elte.hu>
2 45
3 * xterm.h (x_output): New member `xic_base_fontname'. 46 * xterm.h (x_output): New member `xic_base_fontname'.
diff --git a/src/buffer.c b/src/buffer.c
index b8aefcdbcca..b3dd6149487 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5828,21 +5828,21 @@ If the value of the variable is t, undo information is not recorded. */);
5828 doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly. 5828 doc: /* Non-nil means that Emacs should use caches to handle long lines more quickly.
5829 5829
5830Normally, the line-motion functions work by scanning the buffer for 5830Normally, the line-motion functions work by scanning the buffer for
5831newlines. Columnar operations (like move-to-column and 5831newlines. Columnar operations (like `move-to-column' and
5832compute-motion) also work by scanning the buffer, summing character 5832`compute-motion') also work by scanning the buffer, summing character
5833widths as they go. This works well for ordinary text, but if the 5833widths as they go. This works well for ordinary text, but if the
5834buffer's lines are very long (say, more than 500 characters), these 5834buffer's lines are very long (say, more than 500 characters), these
5835motion functions will take longer to execute. Emacs may also take 5835motion functions will take longer to execute. Emacs may also take
5836longer to update the display. 5836longer to update the display.
5837 5837
5838If cache-long-line-scans is non-nil, these motion functions cache the 5838If `cache-long-line-scans' is non-nil, these motion functions cache the
5839results of their scans, and consult the cache to avoid rescanning 5839results of their scans, and consult the cache to avoid rescanning
5840regions of the buffer until the text is modified. The caches are most 5840regions of the buffer until the text is modified. The caches are most
5841beneficial when they prevent the most searching---that is, when the 5841beneficial when they prevent the most searching---that is, when the
5842buffer contains long lines and large regions of characters with the 5842buffer contains long lines and large regions of characters with the
5843same, fixed screen width. 5843same, fixed screen width.
5844 5844
5845When cache-long-line-scans is non-nil, processing short lines will 5845When `cache-long-line-scans' is non-nil, processing short lines will
5846become slightly slower (because of the overhead of consulting the 5846become slightly slower (because of the overhead of consulting the
5847cache), and the caches will use memory roughly proportional to the 5847cache), and the caches will use memory roughly proportional to the
5848number of newlines and characters whose screen width varies. 5848number of newlines and characters whose screen width varies.
@@ -5922,8 +5922,8 @@ Values are interpreted as follows:
5922 hollow display a hollow box cursor 5922 hollow display a hollow box cursor
5923 bar display a vertical bar cursor with default width 5923 bar display a vertical bar cursor with default width
5924 (bar . WIDTH) display a vertical bar cursor with width WIDTH 5924 (bar . WIDTH) display a vertical bar cursor with width WIDTH
5925 hbar display a horisontal bar cursor with default width 5925 hbar display a horizontal bar cursor with default width
5926 (hbar . WIDTH) display a horisontal bar cursor with width WIDTH 5926 (hbar . WIDTH) display a horizontal bar cursor with width WIDTH
5927 ANYTHING ELSE display a hollow box cursor. 5927 ANYTHING ELSE display a hollow box cursor.
5928 5928
5929When the buffer is displayed in a nonselected window, 5929When the buffer is displayed in a nonselected window,
diff --git a/src/callint.c b/src/callint.c
index 8b8cb032095..da88693cd78 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -110,6 +110,7 @@ P -- Prefix arg in raw form. Does not do I/O.
110r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O. 110r -- Region: point and mark as 2 numeric args, smallest first. Does no I/O.
111s -- Any string. Does not inherit the current input method. 111s -- Any string. Does not inherit the current input method.
112S -- Any symbol. 112S -- Any symbol.
113U -- Mouse up event discarded by a previous k or K argument.
113v -- Variable name: symbol that is user-variable-p. 114v -- Variable name: symbol that is user-variable-p.
114x -- Lisp expression read but not evaluated. 115x -- Lisp expression read but not evaluated.
115X -- Lisp expression read and evaluated. 116X -- Lisp expression read and evaluated.
@@ -268,6 +269,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
268 Lisp_Object specs; 269 Lisp_Object specs;
269 Lisp_Object filter_specs; 270 Lisp_Object filter_specs;
270 Lisp_Object teml; 271 Lisp_Object teml;
272 Lisp_Object up_event;
271 Lisp_Object enable; 273 Lisp_Object enable;
272 int speccount = SPECPDL_INDEX (); 274 int speccount = SPECPDL_INDEX ();
273 275
@@ -289,7 +291,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
289 char prompt1[100]; 291 char prompt1[100];
290 char *tem1; 292 char *tem1;
291 int arg_from_tty = 0; 293 int arg_from_tty = 0;
292 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 294 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
293 int key_count; 295 int key_count;
294 int record_then_fail = 0; 296 int record_then_fail = 0;
295 297
@@ -328,6 +330,9 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
328 The feature is not fully implemented. */ 330 The feature is not fully implemented. */
329 filter_specs = Qnil; 331 filter_specs = Qnil;
330 332
333 /* If k or K discard an up-event, save it here so it can be retrieved with U */
334 up_event = Qnil;
335
331 /* Decode the kind of function. Either handle it and return, 336 /* Decode the kind of function. Either handle it and return,
332 or go to `lose' if not interactive, or go to `retry' 337 or go to `lose' if not interactive, or go to `retry'
333 to specify a different function, or set either STRING or SPECS. */ 338 to specify a different function, or set either STRING or SPECS. */
@@ -499,7 +504,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
499 varies[i] = 0; 504 varies[i] = 0;
500 } 505 }
501 506
502 GCPRO4 (prefix_arg, function, *args, *visargs); 507 GCPRO5 (prefix_arg, function, *args, *visargs, up_event);
503 gcpro3.nvars = (count + 1); 508 gcpro3.nvars = (count + 1);
504 gcpro4.nvars = (count + 1); 509 gcpro4.nvars = (count + 1);
505 510
@@ -628,7 +633,7 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
628 /* Ignore first element, which is the base key. */ 633 /* Ignore first element, which is the base key. */
629 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 634 tem2 = Fmemq (intern ("down"), Fcdr (teml));
630 if (! NILP (tem2)) 635 if (! NILP (tem2))
631 Fread_event (Qnil, Qnil); 636 up_event = Fread_event (Qnil, Qnil);
632 } 637 }
633 } 638 }
634 break; 639 break;
@@ -656,11 +661,21 @@ If KEYS is omitted or nil, the return value of `this-command-keys' is used. */)
656 /* Ignore first element, which is the base key. */ 661 /* Ignore first element, which is the base key. */
657 tem2 = Fmemq (intern ("down"), Fcdr (teml)); 662 tem2 = Fmemq (intern ("down"), Fcdr (teml));
658 if (! NILP (tem2)) 663 if (! NILP (tem2))
659 Fread_event (Qnil, Qnil); 664 up_event = Fread_event (Qnil, Qnil);
660 } 665 }
661 } 666 }
662 break; 667 break;
663 668
669 case 'U': /* Up event from last k or K */
670 if (!NILP (up_event))
671 {
672 args[i] = Fmake_vector (make_number (1), up_event);
673 up_event = Qnil;
674 teml = args[i];
675 visargs[i] = Fkey_description (teml, Qnil);
676 }
677 break;
678
664 case 'e': /* The invoking event. */ 679 case 'e': /* The invoking event. */
665 if (next_event >= key_count) 680 if (next_event >= key_count)
666 error ("%s must be bound to an event with parameters", 681 error ("%s must be bound to an event with parameters",
diff --git a/src/fontset.c b/src/fontset.c
index 84384c06d8c..a8bab6897d6 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1069,16 +1069,34 @@ fontset_pattern_regexp (pattern)
1069 || strcmp (SDATA (pattern), CACHED_FONTSET_NAME)) 1069 || strcmp (SDATA (pattern), CACHED_FONTSET_NAME))
1070 { 1070 {
1071 /* We must at first update the cached data. */ 1071 /* We must at first update the cached data. */
1072 char *regex = (char *) alloca (SCHARS (pattern) * 2 + 3); 1072 char *regex, *p0, *p1;
1073 char *p0, *p1 = regex; 1073 int ndashes = 0, nstars = 0;
1074
1075 for (p0 = SDATA (pattern); *p0; p0++)
1076 {
1077 if (*p0 == '-')
1078 ndashes++;
1079 else if (*p0 == '*')
1080 nstars++;
1081 }
1082
1083 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
1084 we convert "*" to "[^-]*" which is much faster in regular
1085 expression matching. */
1086 if (ndashes < 14)
1087 p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
1088 else
1089 p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
1074 1090
1075 /* Convert "*" to ".*", "?" to ".". */
1076 *p1++ = '^'; 1091 *p1++ = '^';
1077 for (p0 = (char *) SDATA (pattern); *p0; p0++) 1092 for (p0 = (char *) SDATA (pattern); *p0; p0++)
1078 { 1093 {
1079 if (*p0 == '*') 1094 if (*p0 == '*')
1080 { 1095 {
1081 *p1++ = '.'; 1096 if (ndashes < 14)
1097 *p1++ = '.';
1098 else
1099 *p1++ = '[', *p1++ = '^', *p1++ = '-', *p1++ = ']';
1082 *p1++ = '*'; 1100 *p1++ = '*';
1083 } 1101 }
1084 else if (*p0 == '?') 1102 else if (*p0 == '?')
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 8182ff45766..dc091c1a09b 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -48,6 +48,7 @@ Boston, MA 02111-1307, USA. */
48#ifdef HAVE_GTK_MULTIDISPLAY 48#ifdef HAVE_GTK_MULTIDISPLAY
49 49
50/* Return the GdkDisplay that corresponds to the X display DPY. */ 50/* Return the GdkDisplay that corresponds to the X display DPY. */
51
51static GdkDisplay * 52static GdkDisplay *
52xg_get_gdk_display (dpy) 53xg_get_gdk_display (dpy)
53 Display *dpy; 54 Display *dpy;
@@ -58,6 +59,7 @@ xg_get_gdk_display (dpy)
58/* When the GTK widget W is to be created on a display for F that 59/* When the GTK widget W is to be created on a display for F that
59 is not the default display, set the display for W. 60 is not the default display, set the display for W.
60 W can be a GtkMenu or a GtkWindow widget. */ 61 W can be a GtkMenu or a GtkWindow widget. */
62
61static void 63static void
62xg_set_screen (w, f) 64xg_set_screen (w, f)
63 GtkWidget *w; 65 GtkWidget *w;
@@ -80,6 +82,7 @@ xg_set_screen (w, f)
80 82
81/* Make some defines so we can use the GTK 2.2 functions when 83/* Make some defines so we can use the GTK 2.2 functions when
82 compiling with GTK 2.0. */ 84 compiling with GTK 2.0. */
85
83#define xg_set_screen(w, f) 86#define xg_set_screen(w, f)
84#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w) 87#define gdk_xid_table_lookup_for_display(dpy, w) gdk_xid_table_lookup (w)
85#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p) 88#define gdk_pixmap_foreign_new_for_display(dpy, p) gdk_pixmap_foreign_new (p)
@@ -95,6 +98,7 @@ xg_set_screen (w, f)
95 Returns non-zero if display could be opened, zero if display could not 98 Returns non-zero if display could be opened, zero if display could not
96 be opened, and less than zero if the GTK version doesn't support 99 be opened, and less than zero if the GTK version doesn't support
97 multipe displays. */ 100 multipe displays. */
101
98int 102int
99xg_display_open (display_name, dpy) 103xg_display_open (display_name, dpy)
100 char *display_name; 104 char *display_name;
@@ -115,6 +119,8 @@ xg_display_open (display_name, dpy)
115} 119}
116 120
117 121
122/* Close display DPY. */
123
118void 124void
119xg_display_close (Display *dpy) 125xg_display_close (Display *dpy)
120{ 126{
@@ -176,6 +182,7 @@ static int malloc_cpt;
176 widget_value_free_list or by malloc:ing a new one. 182 widget_value_free_list or by malloc:ing a new one.
177 183
178 Return a pointer to the allocated structure. */ 184 Return a pointer to the allocated structure. */
185
179widget_value * 186widget_value *
180malloc_widget_value () 187malloc_widget_value ()
181{ 188{
@@ -197,6 +204,7 @@ malloc_widget_value ()
197 204
198/* This is analogous to free. It frees only what was allocated 205/* This is analogous to free. It frees only what was allocated
199 by malloc_widget_value, and no substructures. */ 206 by malloc_widget_value, and no substructures. */
207
200void 208void
201free_widget_value (wv) 209free_widget_value (wv)
202 widget_value *wv; 210 widget_value *wv;
@@ -221,6 +229,7 @@ free_widget_value (wv)
221 229
222/* Create and return the cursor to be used for popup menus and 230/* Create and return the cursor to be used for popup menus and
223 scroll bars on display DPY. */ 231 scroll bars on display DPY. */
232
224GdkCursor * 233GdkCursor *
225xg_create_default_cursor (dpy) 234xg_create_default_cursor (dpy)
226 Display *dpy; 235 Display *dpy;
@@ -239,6 +248,7 @@ xg_create_default_cursor (dpy)
239 WIDGET is used to find the GdkColormap to use for the GdkPixbuf. 248 WIDGET is used to find the GdkColormap to use for the GdkPixbuf.
240 If OLD_WIDGET is NULL, a new widget is constructed and returned. 249 If OLD_WIDGET is NULL, a new widget is constructed and returned.
241 If OLD_WIDGET is not NULL, that widget is modified. */ 250 If OLD_WIDGET is not NULL, that widget is modified. */
251
242static GtkWidget * 252static GtkWidget *
243xg_get_image_for_pixmap (f, img, widget, old_widget) 253xg_get_image_for_pixmap (f, img, widget, old_widget)
244 FRAME_PTR f; 254 FRAME_PTR f;
@@ -373,6 +383,7 @@ xg_get_image_for_pixmap (f, img, widget, old_widget)
373/* Set CURSOR on W and all widgets W contain. We must do like this 383/* Set CURSOR on W and all widgets W contain. We must do like this
374 for scroll bars and menu because they create widgets internally, 384 for scroll bars and menu because they create widgets internally,
375 and it is those widgets that are visible. */ 385 and it is those widgets that are visible. */
386
376static void 387static void
377xg_set_cursor (w, cursor) 388xg_set_cursor (w, cursor)
378 GtkWidget *w; 389 GtkWidget *w;
@@ -400,6 +411,7 @@ xg_set_cursor (w, cursor)
400 has expired by calling the GTK event loop. 411 has expired by calling the GTK event loop.
401 Also, when a menu is active, it has a small timeout before it 412 Also, when a menu is active, it has a small timeout before it
402 pops down the sub menu under it. */ 413 pops down the sub menu under it. */
414
403static void 415static void
404xg_process_timeouts (timer) 416xg_process_timeouts (timer)
405 struct atimer *timer; 417 struct atimer *timer;
@@ -415,6 +427,7 @@ xg_process_timeouts (timer)
415/* Start the xg_timer with an interval of 0.1 seconds, if not already started. 427/* Start the xg_timer with an interval of 0.1 seconds, if not already started.
416 xg_process_timeouts is called when the timer expires. The timer 428 xg_process_timeouts is called when the timer expires. The timer
417 started is continuous, i.e. runs until xg_stop_timer is called. */ 429 started is continuous, i.e. runs until xg_stop_timer is called. */
430
418static void 431static void
419xg_start_timer () 432xg_start_timer ()
420{ 433{
@@ -430,6 +443,7 @@ xg_start_timer ()
430} 443}
431 444
432/* Stop the xg_timer if started. */ 445/* Stop the xg_timer if started. */
446
433static void 447static void
434xg_stop_timer () 448xg_stop_timer ()
435{ 449{
@@ -441,6 +455,7 @@ xg_stop_timer ()
441} 455}
442 456
443/* Insert NODE into linked LIST. */ 457/* Insert NODE into linked LIST. */
458
444static void 459static void
445xg_list_insert (xg_list_node *list, xg_list_node *node) 460xg_list_insert (xg_list_node *list, xg_list_node *node)
446{ 461{
@@ -453,6 +468,7 @@ xg_list_insert (xg_list_node *list, xg_list_node *node)
453} 468}
454 469
455/* Remove NODE from linked LIST. */ 470/* Remove NODE from linked LIST. */
471
456static void 472static void
457xg_list_remove (xg_list_node *list, xg_list_node *node) 473xg_list_remove (xg_list_node *list, xg_list_node *node)
458{ 474{
@@ -473,6 +489,7 @@ xg_list_remove (xg_list_node *list, xg_list_node *node)
473 utf8 or NULL, just return STR. 489 utf8 or NULL, just return STR.
474 If not, a new string is allocated and the caller must free the result 490 If not, a new string is allocated and the caller must free the result
475 with g_free. */ 491 with g_free. */
492
476static char * 493static char *
477get_utf8_string (str) 494get_utf8_string (str)
478 char *str; 495 char *str;
@@ -496,6 +513,7 @@ get_utf8_string (str)
496 only way to get geometry position right if the user explicitly 513 only way to get geometry position right if the user explicitly
497 asked for a position when starting Emacs. 514 asked for a position when starting Emacs.
498 F is the frame we shall set geometry for. */ 515 F is the frame we shall set geometry for. */
516
499static void 517static void
500xg_set_geometry (f) 518xg_set_geometry (f)
501 FRAME_PTR f; 519 FRAME_PTR f;
@@ -529,6 +547,7 @@ xg_set_geometry (f)
529/* Resize the outer window of frame F after chainging the height. 547/* Resize the outer window of frame F after chainging the height.
530 This happend when the menu bar or the tool bar is added or removed. 548 This happend when the menu bar or the tool bar is added or removed.
531 COLUMNS/ROWS is the size the edit area shall have after the resize. */ 549 COLUMNS/ROWS is the size the edit area shall have after the resize. */
550
532static void 551static void
533xg_resize_outer_widget (f, columns, rows) 552xg_resize_outer_widget (f, columns, rows)
534 FRAME_PTR f; 553 FRAME_PTR f;
@@ -555,6 +574,7 @@ xg_resize_outer_widget (f, columns, rows)
555 manually. 574 manually.
556 F is the frame to resize. 575 F is the frame to resize.
557 PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */ 576 PIXELWIDTH, PIXELHEIGHT is the new size in pixels. */
577
558void 578void
559xg_resize_widgets (f, pixelwidth, pixelheight) 579xg_resize_widgets (f, pixelwidth, pixelheight)
560 FRAME_PTR f; 580 FRAME_PTR f;
@@ -591,6 +611,7 @@ xg_resize_widgets (f, pixelwidth, pixelheight)
591 611
592 612
593/* Update our widget size to be COLS/ROWS characters for frame F. */ 613/* Update our widget size to be COLS/ROWS characters for frame F. */
614
594void 615void
595xg_frame_set_char_size (f, cols, rows) 616xg_frame_set_char_size (f, cols, rows)
596 FRAME_PTR f; 617 FRAME_PTR f;
@@ -630,6 +651,7 @@ xg_frame_set_char_size (f, cols, rows)
630 X Window that aren't accessible. 651 X Window that aren't accessible.
631 652
632 Return 0 if no widget match WDESC. */ 653 Return 0 if no widget match WDESC. */
654
633GtkWidget * 655GtkWidget *
634xg_win_to_widget (dpy, wdesc) 656xg_win_to_widget (dpy, wdesc)
635 Display *dpy; 657 Display *dpy;
@@ -655,6 +677,7 @@ xg_win_to_widget (dpy, wdesc)
655 677
656/* Fill in the GdkColor C so that it represents PIXEL. 678/* Fill in the GdkColor C so that it represents PIXEL.
657 W is the widget that color will be used for. Used to find colormap. */ 679 W is the widget that color will be used for. Used to find colormap. */
680
658static void 681static void
659xg_pix_to_gcolor (w, pixel, c) 682xg_pix_to_gcolor (w, pixel, c)
660 GtkWidget *w; 683 GtkWidget *w;
@@ -667,6 +690,7 @@ xg_pix_to_gcolor (w, pixel, c)
667 690
668/* Create and set up the GTK widgets for frame F. 691/* Create and set up the GTK widgets for frame F.
669 Return 0 if creation failed, non-zero otherwise. */ 692 Return 0 if creation failed, non-zero otherwise. */
693
670int 694int
671xg_create_frame_widgets (f) 695xg_create_frame_widgets (f)
672 FRAME_PTR f; 696 FRAME_PTR f;
@@ -802,6 +826,7 @@ xg_create_frame_widgets (f)
802 that the window now has. 826 that the window now has.
803 If USER_POSITION is nonzero, we set the User Position 827 If USER_POSITION is nonzero, we set the User Position
804 flag (this is useful when FLAGS is 0). */ 828 flag (this is useful when FLAGS is 0). */
829
805void 830void
806x_wm_set_size_hint (f, flags, user_position) 831x_wm_set_size_hint (f, flags, user_position)
807 FRAME_PTR f; 832 FRAME_PTR f;
@@ -900,6 +925,7 @@ x_wm_set_size_hint (f, flags, user_position)
900 keep the GTK and X colors in sync. 925 keep the GTK and X colors in sync.
901 F is the frame to change, 926 F is the frame to change,
902 BG is the pixel value to change to. */ 927 BG is the pixel value to change to. */
928
903void 929void
904xg_set_background_color (f, bg) 930xg_set_background_color (f, bg)
905 FRAME_PTR f; 931 FRAME_PTR f;
@@ -923,6 +949,7 @@ xg_set_background_color (f, bg)
923 ***********************************************************************/ 949 ***********************************************************************/
924/* Return the dialog title to use for a dialog of type KEY. 950/* Return the dialog title to use for a dialog of type KEY.
925 This is the encoding used by lwlib. We use the same for GTK. */ 951 This is the encoding used by lwlib. We use the same for GTK. */
952
926static char * 953static char *
927get_dialog_title (char key) 954get_dialog_title (char key)
928{ 955{
@@ -963,6 +990,7 @@ get_dialog_title (char key)
963 user_data is NULL (not used). 990 user_data is NULL (not used).
964 991
965 Returns TRUE to end propagation of event. */ 992 Returns TRUE to end propagation of event. */
993
966static gboolean 994static gboolean
967dialog_delete_callback (w, event, user_data) 995dialog_delete_callback (w, event, user_data)
968 GtkWidget *w; 996 GtkWidget *w;
@@ -979,6 +1007,7 @@ dialog_delete_callback (w, event, user_data)
979 DEACTIVATE_CB is the callback to use when the dialog pops down. 1007 DEACTIVATE_CB is the callback to use when the dialog pops down.
980 1008
981 Returns the GTK dialog widget. */ 1009 Returns the GTK dialog widget. */
1010
982static GtkWidget * 1011static GtkWidget *
983create_dialog (wv, select_cb, deactivate_cb) 1012create_dialog (wv, select_cb, deactivate_cb)
984 widget_value *wv; 1013 widget_value *wv;
@@ -1101,6 +1130,7 @@ enum
1101 a file dialog. 1130 a file dialog.
1102 W is the file dialog widget, 1131 W is the file dialog widget,
1103 ARG points to an integer where we record what has happend. */ 1132 ARG points to an integer where we record what has happend. */
1133
1104static void 1134static void
1105xg_file_sel_ok (w, arg) 1135xg_file_sel_ok (w, arg)
1106 GtkWidget *w; 1136 GtkWidget *w;
@@ -1113,6 +1143,7 @@ xg_file_sel_ok (w, arg)
1113 a file dialog. 1143 a file dialog.
1114 W is the file dialog widget, 1144 W is the file dialog widget,
1115 ARG points to an integer where we record what has happend. */ 1145 ARG points to an integer where we record what has happend. */
1146
1116static void 1147static void
1117xg_file_sel_cancel (w, arg) 1148xg_file_sel_cancel (w, arg)
1118 GtkWidget *w; 1149 GtkWidget *w;
@@ -1127,6 +1158,7 @@ xg_file_sel_cancel (w, arg)
1127 the dialog is popped down, but the dialog widget is not destroyed. 1158 the dialog is popped down, but the dialog widget is not destroyed.
1128 W is the file dialog widget, 1159 W is the file dialog widget,
1129 ARG points to an integer where we record what has happend. */ 1160 ARG points to an integer where we record what has happend. */
1161
1130static void 1162static void
1131xg_file_sel_destroy (w, arg) 1163xg_file_sel_destroy (w, arg)
1132 GtkWidget *w; 1164 GtkWidget *w;
@@ -1144,6 +1176,7 @@ xg_file_sel_destroy (w, arg)
1144 1176
1145 Returns a file name or NULL if no file was selected. 1177 Returns a file name or NULL if no file was selected.
1146 The returned string must be freed by the caller. */ 1178 The returned string must be freed by the caller. */
1179
1147char * 1180char *
1148xg_get_file_name (f, prompt, default_filename, mustmatch_p) 1181xg_get_file_name (f, prompt, default_filename, mustmatch_p)
1149 FRAME_PTR f; 1182 FRAME_PTR f;
@@ -1234,6 +1267,7 @@ static xg_list_node xg_menu_item_cb_list;
1234 1267
1235 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly 1268 Returns CL_DATA if CL_DATA is not NULL, or a pointer to a newly
1236 allocated xg_menu_cb_data if CL_DATA is NULL. */ 1269 allocated xg_menu_cb_data if CL_DATA is NULL. */
1270
1237static xg_menu_cb_data * 1271static xg_menu_cb_data *
1238make_cl_data (cl_data, f, highlight_cb) 1272make_cl_data (cl_data, f, highlight_cb)
1239 xg_menu_cb_data *cl_data; 1273 xg_menu_cb_data *cl_data;
@@ -1267,6 +1301,7 @@ make_cl_data (cl_data, f, highlight_cb)
1267 HIGHLIGHT_CB could change, there is no check that the same 1301 HIGHLIGHT_CB could change, there is no check that the same
1268 function is given when modifying a menu bar as was given when 1302 function is given when modifying a menu bar as was given when
1269 creating the menu bar. */ 1303 creating the menu bar. */
1304
1270static void 1305static void
1271update_cl_data (cl_data, f, highlight_cb) 1306update_cl_data (cl_data, f, highlight_cb)
1272 xg_menu_cb_data *cl_data; 1307 xg_menu_cb_data *cl_data;
@@ -1284,6 +1319,7 @@ update_cl_data (cl_data, f, highlight_cb)
1284 1319
1285/* Decrease reference count for CL_DATA. 1320/* Decrease reference count for CL_DATA.
1286 If reference count is zero, free CL_DATA. */ 1321 If reference count is zero, free CL_DATA. */
1322
1287static void 1323static void
1288unref_cl_data (cl_data) 1324unref_cl_data (cl_data)
1289 xg_menu_cb_data *cl_data; 1325 xg_menu_cb_data *cl_data;
@@ -1300,6 +1336,7 @@ unref_cl_data (cl_data)
1300} 1336}
1301 1337
1302/* Function that marks all lisp data during GC. */ 1338/* Function that marks all lisp data during GC. */
1339
1303void 1340void
1304xg_mark_data () 1341xg_mark_data ()
1305{ 1342{
@@ -1321,6 +1358,7 @@ xg_mark_data ()
1321/* Callback called when a menu item is destroyed. Used to free data. 1358/* Callback called when a menu item is destroyed. Used to free data.
1322 W is the widget that is being destroyed (not used). 1359 W is the widget that is being destroyed (not used).
1323 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */ 1360 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. */
1361
1324static void 1362static void
1325menuitem_destroy_callback (w, client_data) 1363menuitem_destroy_callback (w, client_data)
1326 GtkWidget *w; 1364 GtkWidget *w;
@@ -1340,6 +1378,7 @@ menuitem_destroy_callback (w, client_data)
1340 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W. 1378 CLIENT_DATA points to the xg_menu_item_cb_data associated with the W.
1341 1379
1342 Returns FALSE to tell GTK to keep processing this event. */ 1380 Returns FALSE to tell GTK to keep processing this event. */
1381
1343static gboolean 1382static gboolean
1344menuitem_highlight_callback (w, event, client_data) 1383menuitem_highlight_callback (w, event, client_data)
1345 GtkWidget *w; 1384 GtkWidget *w;
@@ -1364,6 +1403,7 @@ menuitem_highlight_callback (w, event, client_data)
1364/* Callback called when a menu is destroyed. Used to free data. 1403/* Callback called when a menu is destroyed. Used to free data.
1365 W is the widget that is being destroyed (not used). 1404 W is the widget that is being destroyed (not used).
1366 CLIENT_DATA points to the xg_menu_cb_data associated with W. */ 1405 CLIENT_DATA points to the xg_menu_cb_data associated with W. */
1406
1367static void 1407static void
1368menu_destroy_callback (w, client_data) 1408menu_destroy_callback (w, client_data)
1369 GtkWidget *w; 1409 GtkWidget *w;
@@ -1379,6 +1419,7 @@ menu_destroy_callback (w, client_data)
1379 W is the widget that does the grab (not used). 1419 W is the widget that does the grab (not used).
1380 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. 1420 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab.
1381 CLIENT_DATA is NULL (not used). */ 1421 CLIENT_DATA is NULL (not used). */
1422
1382static void 1423static void
1383menu_grab_callback (GtkWidget *widget, 1424menu_grab_callback (GtkWidget *widget,
1384 gboolean ungrab_p, 1425 gboolean ungrab_p,
@@ -1398,6 +1439,7 @@ menu_grab_callback (GtkWidget *widget,
1398 must be non-NULL) and can be inserted into a menu item. 1439 must be non-NULL) and can be inserted into a menu item.
1399 1440
1400 Returns the GtkHBox. */ 1441 Returns the GtkHBox. */
1442
1401static GtkWidget * 1443static GtkWidget *
1402make_widget_for_menu_item (utf8_label, utf8_key) 1444make_widget_for_menu_item (utf8_label, utf8_key)
1403 char *utf8_label; 1445 char *utf8_label;
@@ -1437,6 +1479,7 @@ make_widget_for_menu_item (utf8_label, utf8_key)
1437 1479
1438 Unfortunately, keys don't line up as nicely as in Motif, 1480 Unfortunately, keys don't line up as nicely as in Motif,
1439 but the MacOS X version doesn't either, so I guess that is OK. */ 1481 but the MacOS X version doesn't either, so I guess that is OK. */
1482
1440static GtkWidget * 1483static GtkWidget *
1441make_menu_item (utf8_label, utf8_key, item, group) 1484make_menu_item (utf8_label, utf8_key, item, group)
1442 char *utf8_label; 1485 char *utf8_label;
@@ -1486,6 +1529,7 @@ make_menu_item (utf8_label, utf8_key, item, group)
1486 1529
1487/* Return non-zero if LABEL specifies a separator (GTK only has one 1530/* Return non-zero if LABEL specifies a separator (GTK only has one
1488 separator type) */ 1531 separator type) */
1532
1489static int 1533static int
1490xg_separator_p (char *label) 1534xg_separator_p (char *label)
1491{ 1535{
@@ -1534,6 +1578,7 @@ xg_separator_p (char *label)
1534static int xg_detached_menus; 1578static int xg_detached_menus;
1535 1579
1536/* Returns non-zero if there are detached menus. */ 1580/* Returns non-zero if there are detached menus. */
1581
1537int 1582int
1538xg_have_tear_offs () 1583xg_have_tear_offs ()
1539{ 1584{
@@ -1544,6 +1589,7 @@ xg_have_tear_offs ()
1544 decrease the xg_detached_menus count. 1589 decrease the xg_detached_menus count.
1545 WIDGET is the top level window that is removed (the parent of the menu). 1590 WIDGET is the top level window that is removed (the parent of the menu).
1546 CLIENT_DATA is not used. */ 1591 CLIENT_DATA is not used. */
1592
1547static void 1593static void
1548tearoff_remove (widget, client_data) 1594tearoff_remove (widget, client_data)
1549 GtkWidget *widget; 1595 GtkWidget *widget;
@@ -1556,6 +1602,7 @@ tearoff_remove (widget, client_data)
1556 xg_detached_menus count. 1602 xg_detached_menus count.
1557 WIDGET is the GtkTearoffMenuItem. 1603 WIDGET is the GtkTearoffMenuItem.
1558 CLIENT_DATA is not used. */ 1604 CLIENT_DATA is not used. */
1605
1559static void 1606static void
1560tearoff_activate (widget, client_data) 1607tearoff_activate (widget, client_data)
1561 GtkWidget *widget; 1608 GtkWidget *widget;
@@ -1585,6 +1632,7 @@ tearoff_activate (widget, client_data)
1585 in the group. On exit, *GROUP contains the radio item group. 1632 in the group. On exit, *GROUP contains the radio item group.
1586 1633
1587 Returns the created GtkWidget. */ 1634 Returns the created GtkWidget. */
1635
1588static GtkWidget * 1636static GtkWidget *
1589xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group) 1637xg_create_one_menuitem (item, f, select_cb, highlight_cb, cl_data, group)
1590 widget_value *item; 1638 widget_value *item;
@@ -1802,6 +1850,7 @@ create_menus (data, f, select_cb, deactivate_cb, highlight_cb,
1802 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 1850 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
1803 1851
1804 Returns the widget created. */ 1852 Returns the widget created. */
1853
1805GtkWidget * 1854GtkWidget *
1806xg_create_widget (type, name, f, val, 1855xg_create_widget (type, name, f, val,
1807 select_cb, deactivate_cb, highlight_cb) 1856 select_cb, deactivate_cb, highlight_cb)
@@ -1859,6 +1908,7 @@ xg_create_widget (type, name, f, val,
1859} 1908}
1860 1909
1861/* Return the label for menu item WITEM. */ 1910/* Return the label for menu item WITEM. */
1911
1862static const char * 1912static const char *
1863xg_get_menu_item_label (witem) 1913xg_get_menu_item_label (witem)
1864 GtkMenuItem *witem; 1914 GtkMenuItem *witem;
@@ -1868,6 +1918,7 @@ xg_get_menu_item_label (witem)
1868} 1918}
1869 1919
1870/* Return non-zero if the menu item WITEM has the text LABEL. */ 1920/* Return non-zero if the menu item WITEM has the text LABEL. */
1921
1871static int 1922static int
1872xg_item_label_same_p (witem, label) 1923xg_item_label_same_p (witem, label)
1873 GtkMenuItem *witem; 1924 GtkMenuItem *witem;
@@ -1887,10 +1938,10 @@ xg_item_label_same_p (witem, label)
1887 return is_same; 1938 return is_same;
1888} 1939}
1889 1940
1890/* Remove widgets in LIST from container WCONT. */ 1941/* Destroy widgets in LIST. */
1942
1891static void 1943static void
1892remove_from_container (wcont, list) 1944xg_destroy_widgets (list)
1893 GtkWidget *wcont;
1894 GList *list; 1945 GList *list;
1895{ 1946{
1896 GList *iter; 1947 GList *iter;
@@ -1899,15 +1950,7 @@ remove_from_container (wcont, list)
1899 { 1950 {
1900 GtkWidget *w = GTK_WIDGET (iter->data); 1951 GtkWidget *w = GTK_WIDGET (iter->data);
1901 1952
1902 /* Add a ref to w so we can explicitly destroy it later. */ 1953 /* Destroying the widget will remove it from the container it is in. */
1903 gtk_widget_ref (w);
1904 gtk_container_remove (GTK_CONTAINER (wcont), w);
1905
1906 /* If there is a menu under this widget that has been detached,
1907 there is a reference to it, and just removing w from the
1908 container does not destroy the submenu. By explicitly
1909 destroying w we make sure the submenu is destroyed, thus
1910 removing the detached window also if there was one. */
1911 gtk_widget_destroy (w); 1954 gtk_widget_destroy (w);
1912 } 1955 }
1913} 1956}
@@ -1923,6 +1966,7 @@ remove_from_container (wcont, list)
1923 CL_DATA points to the callback data to be used for this menu bar. 1966 CL_DATA points to the callback data to be used for this menu bar.
1924 1967
1925 This function calls itself to walk through the menu bar names. */ 1968 This function calls itself to walk through the menu bar names. */
1969
1926static void 1970static void
1927xg_update_menubar (menubar, f, list, iter, pos, val, 1971xg_update_menubar (menubar, f, list, iter, pos, val,
1928 select_cb, highlight_cb, cl_data) 1972 select_cb, highlight_cb, cl_data)
@@ -1941,7 +1985,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val,
1941 else if (iter && ! val) 1985 else if (iter && ! val)
1942 { 1986 {
1943 /* Item(s) have been removed. Remove all remaining items. */ 1987 /* Item(s) have been removed. Remove all remaining items. */
1944 remove_from_container (menubar, iter); 1988 xg_destroy_widgets (iter);
1945 1989
1946 /* All updated. */ 1990 /* All updated. */
1947 val = 0; 1991 val = 0;
@@ -2095,6 +2139,7 @@ xg_update_menubar (menubar, f, list, iter, pos, val,
2095 SELECT_CB is the callback to use when a menu item is selected. 2139 SELECT_CB is the callback to use when a menu item is selected.
2096 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. 2140 HIGHLIGHT_CB is the callback to call when entering/leaving menu items.
2097 CL_DATA is the data to set in the widget for menu invokation. */ 2141 CL_DATA is the data to set in the widget for menu invokation. */
2142
2098static void 2143static void
2099xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data) 2144xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data)
2100 widget_value *val; 2145 widget_value *val;
@@ -2229,6 +2274,7 @@ xg_update_menu_item (val, w, select_cb, highlight_cb, cl_data)
2229} 2274}
2230 2275
2231/* Update the toggle menu item W so it corresponds to VAL. */ 2276/* Update the toggle menu item W so it corresponds to VAL. */
2277
2232static void 2278static void
2233xg_update_toggle_item (val, w) 2279xg_update_toggle_item (val, w)
2234 widget_value *val; 2280 widget_value *val;
@@ -2238,6 +2284,7 @@ xg_update_toggle_item (val, w)
2238} 2284}
2239 2285
2240/* Update the radio menu item W so it corresponds to VAL. */ 2286/* Update the radio menu item W so it corresponds to VAL. */
2287
2241static void 2288static void
2242xg_update_radio_item (val, w) 2289xg_update_radio_item (val, w)
2243 widget_value *val; 2290 widget_value *val;
@@ -2367,8 +2414,8 @@ xg_update_submenu (submenu, f, val,
2367 { 2414 {
2368 /* If we are adding new menu items below, we must remove from 2415 /* If we are adding new menu items below, we must remove from
2369 first radio button so that radio groups become correct. */ 2416 first radio button so that radio groups become correct. */
2370 if (cur && first_radio) remove_from_container (submenu, first_radio); 2417 if (cur && first_radio) xg_destroy_widgets (first_radio);
2371 else remove_from_container (submenu, iter); 2418 else xg_destroy_widgets (iter);
2372 } 2419 }
2373 2420
2374 if (cur) 2421 if (cur)
@@ -2400,6 +2447,7 @@ xg_update_submenu (submenu, f, val,
2400 SELECT_CB is the callback to use when a menu item is selected. 2447 SELECT_CB is the callback to use when a menu item is selected.
2401 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore. 2448 DEACTIVATE_CB is the callback to use when a sub menu is not shown anymore.
2402 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */ 2449 HIGHLIGHT_CB is the callback to call when entering/leaving menu items. */
2450
2403void 2451void
2404xg_modify_menubar_widgets (menubar, f, val, deep_p, 2452xg_modify_menubar_widgets (menubar, f, val, deep_p,
2405 select_cb, deactivate_cb, highlight_cb) 2453 select_cb, deactivate_cb, highlight_cb)
@@ -2544,12 +2592,14 @@ free_frame_menubar (f)
2544 2592
2545/* Setting scroll bar values invokes the callback. Use this variable 2593/* Setting scroll bar values invokes the callback. Use this variable
2546 to indicate that callback should do nothing. */ 2594 to indicate that callback should do nothing. */
2595
2547int xg_ignore_gtk_scrollbar; 2596int xg_ignore_gtk_scrollbar;
2548 2597
2549/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in 2598/* SET_SCROLL_BAR_X_WINDOW assumes the second argument fits in
2550 32 bits. But we want to store pointers, and they may be larger 2599 32 bits. But we want to store pointers, and they may be larger
2551 than 32 bits. Keep a mapping from integer index to widget pointers 2600 than 32 bits. Keep a mapping from integer index to widget pointers
2552 to get around the 32 bit limitation. */ 2601 to get around the 32 bit limitation. */
2602
2553static struct 2603static struct
2554{ 2604{
2555 GtkWidget **widgets; 2605 GtkWidget **widgets;
@@ -2558,9 +2608,11 @@ static struct
2558} id_to_widget; 2608} id_to_widget;
2559 2609
2560/* Grow this much every time we need to allocate more */ 2610/* Grow this much every time we need to allocate more */
2611
2561#define ID_TO_WIDGET_INCR 32 2612#define ID_TO_WIDGET_INCR 32
2562 2613
2563/* Store the widget pointer W in id_to_widget and return the integer index. */ 2614/* Store the widget pointer W in id_to_widget and return the integer index. */
2615
2564static int 2616static int
2565xg_store_widget_in_map (w) 2617xg_store_widget_in_map (w)
2566 GtkWidget *w; 2618 GtkWidget *w;
@@ -2599,6 +2651,7 @@ xg_store_widget_in_map (w)
2599 2651
2600/* Remove pointer at IDX from id_to_widget. 2652/* Remove pointer at IDX from id_to_widget.
2601 Called when scroll bar is destroyed. */ 2653 Called when scroll bar is destroyed. */
2654
2602static void 2655static void
2603xg_remove_widget_from_map (idx) 2656xg_remove_widget_from_map (idx)
2604 int idx; 2657 int idx;
@@ -2611,6 +2664,7 @@ xg_remove_widget_from_map (idx)
2611} 2664}
2612 2665
2613/* Get the widget pointer at IDX from id_to_widget. */ 2666/* Get the widget pointer at IDX from id_to_widget. */
2667
2614static GtkWidget * 2668static GtkWidget *
2615xg_get_widget_from_map (idx) 2669xg_get_widget_from_map (idx)
2616 int idx; 2670 int idx;
@@ -2623,6 +2677,7 @@ xg_get_widget_from_map (idx)
2623 2677
2624/* Return the scrollbar id for X Window WID on display DPY. 2678/* Return the scrollbar id for X Window WID on display DPY.
2625 Return -1 if WID not in id_to_widget. */ 2679 Return -1 if WID not in id_to_widget. */
2680
2626int 2681int
2627xg_get_scroll_id_for_window (dpy, wid) 2682xg_get_scroll_id_for_window (dpy, wid)
2628 Display *dpy; 2683 Display *dpy;
@@ -2646,6 +2701,7 @@ xg_get_scroll_id_for_window (dpy, wid)
2646/* Callback invoked when scroll bar WIDGET is destroyed. 2701/* Callback invoked when scroll bar WIDGET is destroyed.
2647 DATA is the index into id_to_widget for WIDGET. 2702 DATA is the index into id_to_widget for WIDGET.
2648 We free pointer to last scroll bar values here and remove the index. */ 2703 We free pointer to last scroll bar values here and remove the index. */
2704
2649static void 2705static void
2650xg_gtk_scroll_destroy (widget, data) 2706xg_gtk_scroll_destroy (widget, data)
2651 GtkWidget *widget; 2707 GtkWidget *widget;
@@ -2668,6 +2724,7 @@ xg_gtk_scroll_destroy (widget, data)
2668 2724
2669 Returns FALSE to tell GTK that it shall continue propagate the event 2725 Returns FALSE to tell GTK that it shall continue propagate the event
2670 to widgets. */ 2726 to widgets. */
2727
2671static gboolean 2728static gboolean
2672scroll_bar_button_cb (widget, event, user_data) 2729scroll_bar_button_cb (widget, event, user_data)
2673 GtkWidget *widget; 2730 GtkWidget *widget;
@@ -2692,6 +2749,7 @@ scroll_bar_button_cb (widget, event, user_data)
2692 bar changes. 2749 bar changes.
2693 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used 2750 SCROLL_BAR_NAME is the name we use for the scroll bar. Can be used
2694 to set resources for the widget. */ 2751 to set resources for the widget. */
2752
2695void 2753void
2696xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) 2754xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2697 FRAME_PTR f; 2755 FRAME_PTR f;
@@ -2753,6 +2811,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name)
2753} 2811}
2754 2812
2755/* Make the scroll bar represented by SCROLLBAR_ID visible. */ 2813/* Make the scroll bar represented by SCROLLBAR_ID visible. */
2814
2756void 2815void
2757xg_show_scroll_bar (scrollbar_id) 2816xg_show_scroll_bar (scrollbar_id)
2758 int scrollbar_id; 2817 int scrollbar_id;
@@ -2763,6 +2822,7 @@ xg_show_scroll_bar (scrollbar_id)
2763} 2822}
2764 2823
2765/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */ 2824/* Remove the scroll bar represented by SCROLLBAR_ID from the frame F. */
2825
2766void 2826void
2767xg_remove_scroll_bar (f, scrollbar_id) 2827xg_remove_scroll_bar (f, scrollbar_id)
2768 FRAME_PTR f; 2828 FRAME_PTR f;
@@ -2782,6 +2842,7 @@ xg_remove_scroll_bar (f, scrollbar_id)
2782 in frame F. 2842 in frame F.
2783 TOP/LEFT are the new pixel positions where the bar shall appear. 2843 TOP/LEFT are the new pixel positions where the bar shall appear.
2784 WIDTH, HEIGHT is the size in pixels the bar shall have. */ 2844 WIDTH, HEIGHT is the size in pixels the bar shall have. */
2845
2785void 2846void
2786xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) 2847xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height)
2787 FRAME_PTR f; 2848 FRAME_PTR f;
@@ -2810,6 +2871,7 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height)
2810 2871
2811/* Set the thumb size and position of scroll bar BAR. We are currently 2872/* Set the thumb size and position of scroll bar BAR. We are currently
2812 displaying PORTION out of a whole WHOLE, and our position POSITION. */ 2873 displaying PORTION out of a whole WHOLE, and our position POSITION. */
2874
2813void 2875void
2814xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) 2876xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
2815 struct scroll_bar *bar; 2877 struct scroll_bar *bar;
@@ -2902,6 +2964,7 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
2902 W is the button widget in the tool bar that got pressed, 2964 W is the button widget in the tool bar that got pressed,
2903 CLIENT_DATA is an integer that is the index of the button in the 2965 CLIENT_DATA is an integer that is the index of the button in the
2904 tool bar. 0 is the first button. */ 2966 tool bar. 0 is the first button. */
2967
2905static void 2968static void
2906xg_tool_bar_callback (w, client_data) 2969xg_tool_bar_callback (w, client_data)
2907 GtkWidget *w; 2970 GtkWidget *w;
@@ -2938,6 +3001,7 @@ xg_tool_bar_callback (w, client_data)
2938 WBOX is the handle box widget that enables detach/attach of the tool bar. 3001 WBOX is the handle box widget that enables detach/attach of the tool bar.
2939 W is the tool bar widget. 3002 W is the tool bar widget.
2940 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3003 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3004
2941static void 3005static void
2942xg_tool_bar_detach_callback (wbox, w, client_data) 3006xg_tool_bar_detach_callback (wbox, w, client_data)
2943 GtkHandleBox *wbox; 3007 GtkHandleBox *wbox;
@@ -2966,6 +3030,7 @@ xg_tool_bar_detach_callback (wbox, w, client_data)
2966 WBOX is the handle box widget that enables detach/attach of the tool bar. 3030 WBOX is the handle box widget that enables detach/attach of the tool bar.
2967 W is the tool bar widget. 3031 W is the tool bar widget.
2968 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */ 3032 CLIENT_DATA is a pointer to the frame the tool bar belongs to. */
3033
2969static void 3034static void
2970xg_tool_bar_attach_callback (wbox, w, client_data) 3035xg_tool_bar_attach_callback (wbox, w, client_data)
2971 GtkHandleBox *wbox; 3036 GtkHandleBox *wbox;
@@ -2995,6 +3060,7 @@ xg_tool_bar_attach_callback (wbox, w, client_data)
2995 tool bar. 0 is the first button. 3060 tool bar. 0 is the first button.
2996 3061
2997 Returns FALSE to tell GTK to keep processing this event. */ 3062 Returns FALSE to tell GTK to keep processing this event. */
3063
2998static gboolean 3064static gboolean
2999xg_tool_bar_help_callback (w, event, client_data) 3065xg_tool_bar_help_callback (w, event, client_data)
3000 GtkWidget *w; 3066 GtkWidget *w;
@@ -3040,6 +3106,7 @@ xg_tool_bar_help_callback (w, event, client_data)
3040 CLIENT_DATA is unused. 3106 CLIENT_DATA is unused.
3041 3107
3042 Returns FALSE to tell GTK to keep processing this event. */ 3108 Returns FALSE to tell GTK to keep processing this event. */
3109
3043static gboolean 3110static gboolean
3044xg_tool_bar_item_expose_callback (w, event, client_data) 3111xg_tool_bar_item_expose_callback (w, event, client_data)
3045 GtkWidget *w; 3112 GtkWidget *w;
@@ -3070,6 +3137,7 @@ xg_tool_bar_item_expose_callback (w, event, client_data)
3070 CLIENT_DATA is pointing to the frame for this tool bar. 3137 CLIENT_DATA is pointing to the frame for this tool bar.
3071 3138
3072 Returns FALSE to tell GTK to keep processing this event. */ 3139 Returns FALSE to tell GTK to keep processing this event. */
3140
3073static gboolean 3141static gboolean
3074xg_tool_bar_expose_callback (w, event, client_data) 3142xg_tool_bar_expose_callback (w, event, client_data)
3075 GtkWidget *w; 3143 GtkWidget *w;
@@ -3080,6 +3148,8 @@ xg_tool_bar_expose_callback (w, event, client_data)
3080 return FALSE; 3148 return FALSE;
3081} 3149}
3082 3150
3151/* Create a tool bar for frame F. */
3152
3083static void 3153static void
3084xg_create_tool_bar (f) 3154xg_create_tool_bar (f)
3085 FRAME_PTR f; 3155 FRAME_PTR f;
@@ -3133,6 +3203,8 @@ xg_create_tool_bar (f)
3133 SET_FRAME_GARBAGED (f); 3203 SET_FRAME_GARBAGED (f);
3134} 3204}
3135 3205
3206/* Update the tool bar for frame F. Add new buttons and remove old. */
3207
3136void 3208void
3137update_frame_tool_bar (f) 3209update_frame_tool_bar (f)
3138 FRAME_PTR f; 3210 FRAME_PTR f;
@@ -3300,6 +3372,9 @@ update_frame_tool_bar (f)
3300 UNBLOCK_INPUT; 3372 UNBLOCK_INPUT;
3301} 3373}
3302 3374
3375/* Deallocate all resources for the tool bar on frame F.
3376 Remove the tool bar. */
3377
3303void 3378void
3304free_frame_tool_bar (f) 3379free_frame_tool_bar (f)
3305 FRAME_PTR f; 3380 FRAME_PTR f;
diff --git a/src/regex.c b/src/regex.c
index 006b79acba8..71a450f9b23 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1308,6 +1308,7 @@ static const char *re_error_msgid[] =
1308 gettext_noop ("Premature end of regular expression"), /* REG_EEND */ 1308 gettext_noop ("Premature end of regular expression"), /* REG_EEND */
1309 gettext_noop ("Regular expression too big"), /* REG_ESIZE */ 1309 gettext_noop ("Regular expression too big"), /* REG_ESIZE */
1310 gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */ 1310 gettext_noop ("Unmatched ) or \\)"), /* REG_ERPAREN */
1311 gettext_noop ("Range striding over charsets") /* REG_ERANGEX */
1311 }; 1312 };
1312 1313
1313/* Avoiding alloca during matching, to placate r_alloc. */ 1314/* Avoiding alloca during matching, to placate r_alloc. */
@@ -2925,7 +2926,7 @@ regex_compile (pattern, size, syntax, bufp)
2925 if (c > c1) 2926 if (c > c1)
2926 { 2927 {
2927 if (syntax & RE_NO_EMPTY_RANGES) 2928 if (syntax & RE_NO_EMPTY_RANGES)
2928 FREE_STACK_RETURN (REG_ERANGE); 2929 FREE_STACK_RETURN (REG_ERANGEX);
2929 /* Else, repeat the loop. */ 2930 /* Else, repeat the loop. */
2930 } 2931 }
2931 } 2932 }
diff --git a/src/regex.h b/src/regex.h
index 26c589bde92..b1cfd5fdd11 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -316,7 +316,8 @@ typedef enum
316 /* Error codes we've added. */ 316 /* Error codes we've added. */
317 REG_EEND, /* Premature end. */ 317 REG_EEND, /* Premature end. */
318 REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ 318 REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
319 REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ 319 REG_ERPAREN, /* Unmatched ) or \); not returned from regcomp. */
320 REG_ERANGEX /* Range striding over charsets. */
320} reg_errcode_t; 321} reg_errcode_t;
321 322
322/* This data structure represents a compiled pattern. Before calling 323/* This data structure represents a compiled pattern. Before calling
diff --git a/src/xfns.c b/src/xfns.c
index 3c8035c925a..39262235e8b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1929,7 +1929,7 @@ xic_create_xfontset (f, base_fontname)
1929 char *base_fontname; 1929 char *base_fontname;
1930{ 1930{
1931 XFontSet xfs = NULL; 1931 XFontSet xfs = NULL;
1932 char **missing_list; 1932 char **missing_list = NULL;
1933 int missing_count; 1933 int missing_count;
1934 char *def_string; 1934 char *def_string;
1935 Lisp_Object rest, frame; 1935 Lisp_Object rest, frame;
@@ -1940,6 +1940,7 @@ xic_create_xfontset (f, base_fontname)
1940 struct frame *cf = XFRAME (frame); 1940 struct frame *cf = XFRAME (frame);
1941 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf) 1941 if (cf != f && FRAME_LIVE_P (f) && FRAME_X_P (cf)
1942 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f) 1942 && FRAME_X_DISPLAY_INFO (cf) == FRAME_X_DISPLAY_INFO (f)
1943 && FRAME_XIC_BASE_FONTNAME (cf)
1943 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname)) 1944 && !strcmp (FRAME_XIC_BASE_FONTNAME (cf), base_fontname))
1944 { 1945 {
1945 xfs = FRAME_XIC_FONTSET (cf); 1946 xfs = FRAME_XIC_FONTSET (cf);
@@ -1948,12 +1949,14 @@ xic_create_xfontset (f, base_fontname)
1948 } 1949 }
1949 1950
1950 if (!xfs) 1951 if (!xfs)
1951 /* New fontset. */ 1952 {
1952 xfs = XCreateFontSet (FRAME_X_DISPLAY (f), 1953 /* New fontset. */
1953 base_fontname, &missing_list, 1954 xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
1954 &missing_count, &def_string); 1955 base_fontname, &missing_list,
1955 if (missing_list) 1956 &missing_count, &def_string);
1956 XFreeStringList (missing_list); 1957 if (missing_list)
1958 XFreeStringList (missing_list);
1959 }
1957 1960
1958 if (FRAME_XIC_BASE_FONTNAME (f)) 1961 if (FRAME_XIC_BASE_FONTNAME (f))
1959 xfree (FRAME_XIC_BASE_FONTNAME (f)); 1962 xfree (FRAME_XIC_BASE_FONTNAME (f));
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 9a6a7ccefb8..5b53c0ca34d 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -73,33 +73,35 @@ static int ice_fd = -1;
73 73
74static int doing_interact = False; 74static int doing_interact = False;
75 75
76/* The session manager object for the session manager connection */ 76/* The session manager object for the session manager connection. */
77 77
78static SmcConn smc_conn; 78static SmcConn smc_conn;
79 79
80/* The client session id for this session */ 80/* The client session id for this session. */
81
81static char *client_id; 82static char *client_id;
82 83
83/* The full path name to the Emacs program */ 84/* The full path name to the Emacs program. */
85
84static char *emacs_program; 86static char *emacs_program;
85 87
86/* The client session id for this session as a lisp object. */ 88/* The client session id for this session as a lisp object. */
87 89
88Lisp_Object Vx_session_id; 90Lisp_Object Vx_session_id;
89 91
90/* The id we had the previous session. This is only available if we 92/* The id we had the previous session. This is only available if we
91 have been started by the session manager with SMID_OPT. */ 93 have been started by the session manager with SMID_OPT. */
92 94
93Lisp_Object Vx_session_previous_id; 95Lisp_Object Vx_session_previous_id;
94 96
95/* The option we tell the session manager to start Emacs with when 97/* The option we tell the session manager to start Emacs with when
96 restarting Emacs. The client_id is appended. */ 98 restarting Emacs. The client_id is appended. */
97 99
98#define SMID_OPT "--smid=" 100#define SMID_OPT "--smid="
99 101
100 102
101/* The option to start Emacs without the splash screen when 103/* The option to start Emacs without the splash screen when
102 restarting Emacs. */ 104 restarting Emacs. */
103 105
104#define NOSPLASH_OPT "--no-splash" 106#define NOSPLASH_OPT "--no-splash"
105 107
@@ -107,6 +109,7 @@ Lisp_Object Vx_session_previous_id;
107/* Handle any messages from the session manager. If no connection is 109/* Handle any messages from the session manager. If no connection is
108 open to a session manager, just return 0. 110 open to a session manager, just return 0.
109 Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */ 111 Otherwise returns 1 if SAVE_SESSION_EVENT is stored in buffer BUFP. */
112
110int 113int
111x_session_check_input (bufp) 114x_session_check_input (bufp)
112 struct input_event *bufp; 115 struct input_event *bufp;
@@ -125,7 +128,7 @@ x_session_check_input (bufp)
125 /* Reset this so wo can check kind after callbacks have been called by 128 /* Reset this so wo can check kind after callbacks have been called by
126 IceProcessMessages. The smc_interact_CB sets the kind to 129 IceProcessMessages. The smc_interact_CB sets the kind to
127 SAVE_SESSION_EVENT, but we don't know beforehand if that callback 130 SAVE_SESSION_EVENT, but we don't know beforehand if that callback
128 will be called. */ 131 will be called. */
129 emacs_event.kind = NO_EVENT; 132 emacs_event.kind = NO_EVENT;
130 133
131 if (select (ice_fd+1, &read_fds, 134 if (select (ice_fd+1, &read_fds,
@@ -142,7 +145,7 @@ x_session_check_input (bufp)
142 145
143 146
144 /* Check if smc_interact_CB was called and we shall generate a 147 /* Check if smc_interact_CB was called and we shall generate a
145 SAVE_SESSION_EVENT. */ 148 SAVE_SESSION_EVENT. */
146 if (emacs_event.kind == NO_EVENT) 149 if (emacs_event.kind == NO_EVENT)
147 return 0; 150 return 0;
148 151
@@ -150,7 +153,8 @@ x_session_check_input (bufp)
150 return 1; 153 return 1;
151} 154}
152 155
153/* Return non-zero if we have a connection to a session manager.*/ 156/* Return non-zero if we have a connection to a session manager. */
157
154int 158int
155x_session_have_connection () 159x_session_have_connection ()
156{ 160{
@@ -159,7 +163,8 @@ x_session_have_connection ()
159 163
160/* This is called when the session manager says it is OK to interact with the 164/* This is called when the session manager says it is OK to interact with the
161 user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated. 165 user. Here we set the kind to SAVE_SESSION_EVENT so an event is generated.
162 Then lisp code can interact with the user. */ 166 Then lisp code can interact with the user. */
167
163static void 168static void
164smc_interact_CB (smcConn, clientData) 169smc_interact_CB (smcConn, clientData)
165 SmcConn smcConn; 170 SmcConn smcConn;
@@ -175,7 +180,8 @@ smc_interact_CB (smcConn, clientData)
175 are started in the correct directory. 180 are started in the correct directory.
176 181
177 If this is a shutdown and we can request to interact with the user, 182 If this is a shutdown and we can request to interact with the user,
178 we do so, because we don't know what the lisp code might do. */ 183 we do so, because we don't know what the lisp code might do. */
184
179static void 185static void
180smc_save_yourself_CB (smcConn, 186smc_save_yourself_CB (smcConn,
181 clientData, 187 clientData,
@@ -202,7 +208,7 @@ smc_save_yourself_CB (smcConn,
202 char cwd[MAXPATHLEN+1]; 208 char cwd[MAXPATHLEN+1];
203 char *smid_opt; 209 char *smid_opt;
204 210
205 /* How to start a new instance of Emacs */ 211 /* How to start a new instance of Emacs. */
206 props[props_idx] = &prop_ptr[props_idx]; 212 props[props_idx] = &prop_ptr[props_idx];
207 props[props_idx]->name = SmCloneCommand; 213 props[props_idx]->name = SmCloneCommand;
208 props[props_idx]->type = SmLISTofARRAY8; 214 props[props_idx]->type = SmLISTofARRAY8;
@@ -212,7 +218,7 @@ smc_save_yourself_CB (smcConn,
212 props[props_idx]->vals[0].value = emacs_program; 218 props[props_idx]->vals[0].value = emacs_program;
213 ++props_idx; 219 ++props_idx;
214 220
215 /* The name of the program */ 221 /* The name of the program. */
216 props[props_idx] = &prop_ptr[props_idx]; 222 props[props_idx] = &prop_ptr[props_idx];
217 props[props_idx]->name = SmProgram; 223 props[props_idx]->name = SmProgram;
218 props[props_idx]->type = SmARRAY8; 224 props[props_idx]->type = SmARRAY8;
@@ -222,11 +228,11 @@ smc_save_yourself_CB (smcConn,
222 props[props_idx]->vals[0].value = SDATA (Vinvocation_name); 228 props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
223 ++props_idx; 229 ++props_idx;
224 230
225 /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */ 231 /* How to restart Emacs (i.e.: /path/to/emacs --smid=xxxx --no-splash). */
226 props[props_idx] = &prop_ptr[props_idx]; 232 props[props_idx] = &prop_ptr[props_idx];
227 props[props_idx]->name = SmRestartCommand; 233 props[props_idx]->name = SmRestartCommand;
228 props[props_idx]->type = SmLISTofARRAY8; 234 props[props_idx]->type = SmLISTofARRAY8;
229 props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */ 235 props[props_idx]->num_vals = 3; /* /path/to/emacs, --smid=xxx --no-splash */
230 props[props_idx]->vals = &values[val_idx]; 236 props[props_idx]->vals = &values[val_idx];
231 props[props_idx]->vals[0].length = strlen (emacs_program); 237 props[props_idx]->vals[0].length = strlen (emacs_program);
232 props[props_idx]->vals[0].value = emacs_program; 238 props[props_idx]->vals[0].value = emacs_program;
@@ -243,7 +249,7 @@ smc_save_yourself_CB (smcConn,
243 val_idx += 3; 249 val_idx += 3;
244 ++props_idx; 250 ++props_idx;
245 251
246 /* User id */ 252 /* User id. */
247 props[props_idx] = &prop_ptr[props_idx]; 253 props[props_idx] = &prop_ptr[props_idx];
248 props[props_idx]->name = SmUserID; 254 props[props_idx]->name = SmUserID;
249 props[props_idx]->type = SmARRAY8; 255 props[props_idx]->type = SmARRAY8;
@@ -253,7 +259,7 @@ smc_save_yourself_CB (smcConn,
253 props[props_idx]->vals[0].value = SDATA (Vuser_login_name); 259 props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
254 ++props_idx; 260 ++props_idx;
255 261
256 /* The current directory property, not mandatory */ 262 /* The current directory property, not mandatory. */
257#ifdef HAVE_GETCWD 263#ifdef HAVE_GETCWD
258 if (getcwd (cwd, MAXPATHLEN+1) != 0) 264 if (getcwd (cwd, MAXPATHLEN+1) != 0)
259#else 265#else
@@ -275,18 +281,19 @@ smc_save_yourself_CB (smcConn,
275 281
276 xfree (smid_opt); 282 xfree (smid_opt);
277 283
278 /* See if we maybe shall interact with the user. */ 284 /* See if we maybe shall interact with the user. */
279 if (interactStyle != SmInteractStyleAny 285 if (interactStyle != SmInteractStyleAny
280 || ! shutdown 286 || ! shutdown
281 || saveType == SmSaveLocal 287 || saveType == SmSaveLocal
282 || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0)) 288 || ! SmcInteractRequest (smcConn, SmDialogNormal, smc_interact_CB, 0))
283 { 289 {
284 /* No interaction, we are done saving ourself. */ 290 /* No interaction, we are done saving ourself. */
285 SmcSaveYourselfDone (smcConn, True); 291 SmcSaveYourselfDone (smcConn, True);
286 } 292 }
287} 293}
288 294
289/* According to the SM specification, this shall close the connection */ 295/* According to the SM specification, this shall close the connection. */
296
290static void 297static void
291smc_die_CB (smcConn, clientData) 298smc_die_CB (smcConn, clientData)
292 SmcConn smcConn; 299 SmcConn smcConn;
@@ -300,7 +307,8 @@ smc_die_CB (smcConn, clientData)
300 According to the SM specification, we should not interact with the 307 According to the SM specification, we should not interact with the
301 user between smc_save_yourself_CB is called and until smc_save_complete_CB 308 user between smc_save_yourself_CB is called and until smc_save_complete_CB
302 is called. It seems like a lot of job to implement this and it doesn't 309 is called. It seems like a lot of job to implement this and it doesn't
303 even seem necessary. */ 310 even seem necessary. */
311
304static void 312static void
305smc_save_complete_CB (smcConn, clientData) 313smc_save_complete_CB (smcConn, clientData)
306 SmcConn smcConn; 314 SmcConn smcConn;
@@ -318,7 +326,8 @@ smc_shutdown_cancelled_CB (smcConn, clientData)
318} 326}
319 327
320/* Error handlers for SM and ICE. We don't want to exit Emacs just 328/* Error handlers for SM and ICE. We don't want to exit Emacs just
321 because there is some error in the session management. */ 329 because there is some error in the session management. */
330
322static void 331static void
323smc_error_handler (smcConn, 332smc_error_handler (smcConn,
324 swap, 333 swap,
@@ -335,7 +344,7 @@ smc_error_handler (smcConn,
335 int severity; 344 int severity;
336 SmPointer values; 345 SmPointer values;
337{ 346{
338 /* Empty */ 347 /* Empty */
339} 348}
340 349
341static void 350static void
@@ -354,7 +363,7 @@ ice_error_handler (iceConn,
354 int severity; 363 int severity;
355 IcePointer values; 364 IcePointer values;
356{ 365{
357 /* Empty */ 366 /* Empty */
358} 367}
359 368
360 369
@@ -362,12 +371,13 @@ static void
362ice_io_error_handler (iceConn) 371ice_io_error_handler (iceConn)
363 IceConn iceConn; 372 IceConn iceConn;
364{ 373{
365 /* Connection probably gone. */ 374 /* Connection probably gone. */
366 ice_fd = -1; 375 ice_fd = -1;
367} 376}
368 377
369/* This is called when the ICE connection is created or closed. The SM library 378/* This is called when the ICE connection is created or closed. The SM library
370 uses ICE as it transport protocol. */ 379 uses ICE as it transport protocol. */
380
371static void 381static void
372ice_conn_watch_CB (iceConn, clientData, opening, watchData) 382ice_conn_watch_CB (iceConn, clientData, opening, watchData)
373 IceConn iceConn; 383 IceConn iceConn;
@@ -400,6 +410,7 @@ ice_conn_watch_CB (iceConn, clientData, opening, watchData)
400} 410}
401 411
402/* Create the client leader window. */ 412/* Create the client leader window. */
413
403static void 414static void
404create_client_leader_window (dpyinfo, client_id) 415create_client_leader_window (dpyinfo, client_id)
405 struct x_display_info *dpyinfo; 416 struct x_display_info *dpyinfo;
@@ -426,7 +437,8 @@ create_client_leader_window (dpyinfo, client_id)
426 dpyinfo->client_leader_window = w; 437 dpyinfo->client_leader_window = w;
427} 438}
428 439
429/* Try to open a connection to the session manager. */ 440/* Try to open a connection to the session manager. */
441
430void 442void
431x_session_initialize (dpyinfo) 443x_session_initialize (dpyinfo)
432 struct x_display_info *dpyinfo; 444 struct x_display_info *dpyinfo;
@@ -438,17 +450,17 @@ x_session_initialize (dpyinfo)
438 int name_len = 0; 450 int name_len = 0;
439 451
440 /* Check if we where started by the session manager. If so, we will 452 /* Check if we where started by the session manager. If so, we will
441 have a previous id. */ 453 have a previous id. */
442 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id)) 454 if (! EQ (Vx_session_previous_id, Qnil) && STRINGP (Vx_session_previous_id))
443 previous_id = SDATA (Vx_session_previous_id); 455 previous_id = SDATA (Vx_session_previous_id);
444 456
445 /* Construct the path to the Emacs program. */ 457 /* Construct the path to the Emacs program. */
446 if (! EQ (Vinvocation_directory, Qnil)) 458 if (! EQ (Vinvocation_directory, Qnil))
447 name_len += strlen (SDATA (Vinvocation_directory)); 459 name_len += strlen (SDATA (Vinvocation_directory));
448 name_len += strlen (SDATA (Vinvocation_name)); 460 name_len += strlen (SDATA (Vinvocation_name));
449 461
450 /* This malloc will not be freed, but it is only done once, and hopefully 462 /* This malloc will not be freed, but it is only done once, and hopefully
451 not very large */ 463 not very large */
452 emacs_program = xmalloc (name_len + 1); 464 emacs_program = xmalloc (name_len + 1);
453 emacs_program[0] = '\0'; 465 emacs_program[0] = '\0';
454 466
@@ -457,7 +469,7 @@ x_session_initialize (dpyinfo)
457 strcat (emacs_program, SDATA (Vinvocation_name)); 469 strcat (emacs_program, SDATA (Vinvocation_name));
458 470
459 /* The SM protocol says all callbacks are mandatory, so set up all 471 /* The SM protocol says all callbacks are mandatory, so set up all
460 here and in the mask passed to SmcOpenConnection */ 472 here and in the mask passed to SmcOpenConnection. */
461 callbacks.save_yourself.callback = smc_save_yourself_CB; 473 callbacks.save_yourself.callback = smc_save_yourself_CB;
462 callbacks.save_yourself.client_data = 0; 474 callbacks.save_yourself.client_data = 0;
463 callbacks.die.callback = smc_die_CB; 475 callbacks.die.callback = smc_die_CB;
@@ -467,17 +479,17 @@ x_session_initialize (dpyinfo)
467 callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB; 479 callbacks.shutdown_cancelled.callback = smc_shutdown_cancelled_CB;
468 callbacks.shutdown_cancelled.client_data = 0; 480 callbacks.shutdown_cancelled.client_data = 0;
469 481
470 /* Set error handlers. */ 482 /* Set error handlers. */
471 SmcSetErrorHandler (smc_error_handler); 483 SmcSetErrorHandler (smc_error_handler);
472 IceSetErrorHandler (ice_error_handler); 484 IceSetErrorHandler (ice_error_handler);
473 IceSetIOErrorHandler (ice_io_error_handler); 485 IceSetIOErrorHandler (ice_io_error_handler);
474 486
475 /* Install callback for when connection status changes. */ 487 /* Install callback for when connection status changes. */
476 IceAddConnectionWatch (ice_conn_watch_CB, 0); 488 IceAddConnectionWatch (ice_conn_watch_CB, 0);
477 489
478 /* Open the connection to the session manager. A failure is not 490 /* Open the connection to the session manager. A failure is not
479 critical, it usually means that no session manager is running. 491 critical, it usually means that no session manager is running.
480 The errorstring is here for debugging. */ 492 The errorstring is here for debugging. */
481 smc_conn = SmcOpenConnection (NULL, NULL, 1, 0, 493 smc_conn = SmcOpenConnection (NULL, NULL, 1, 0,
482 (SmcSaveYourselfProcMask| 494 (SmcSaveYourselfProcMask|
483 SmcDieProcMask| 495 SmcDieProcMask|