aboutsummaryrefslogtreecommitdiffstats
path: root/src/xfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c185
1 files changed, 112 insertions, 73 deletions
diff --git a/src/xfns.c b/src/xfns.c
index c70f4bb9a82..6f08ada1bb9 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1,6 +1,6 @@
1/* Functions for the X window system. 1/* Functions for the X window system.
2 2
3Copyright (C) 1989, 1992-2011 Free Software Foundation, Inc. 3Copyright (C) 1989, 1992-2012 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -105,7 +105,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
105#include "../lwlib/xlwmenu.h" 105#include "../lwlib/xlwmenu.h"
106#endif 106#endif
107 107
108#if !defined(NO_EDITRES) 108#if !defined (NO_EDITRES)
109#define HACK_EDITRES 109#define HACK_EDITRES
110extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *); 110extern void _XEditResCheckMessages (Widget, XtPointer, XEvent *, Boolean *);
111#endif /* not defined NO_EDITRES */ 111#endif /* not defined NO_EDITRES */
@@ -145,7 +145,8 @@ static Lisp_Object Qcompound_text, Qcancel_timer;
145Lisp_Object Qfont_param; 145Lisp_Object Qfont_param;
146 146
147#if GLYPH_DEBUG 147#if GLYPH_DEBUG
148static int image_cache_refcount, dpyinfo_refcount; 148static ptrdiff_t image_cache_refcount;
149static int dpyinfo_refcount;
149#endif 150#endif
150 151
151#if defined (USE_GTK) && defined (HAVE_FREETYPE) 152#if defined (USE_GTK) && defined (HAVE_FREETYPE)
@@ -1470,7 +1471,8 @@ x_set_scroll_bar_background (struct frame *f, Lisp_Object value, Lisp_Object old
1470 the result should be `COMPOUND_TEXT'. */ 1471 the result should be `COMPOUND_TEXT'. */
1471 1472
1472static unsigned char * 1473static unsigned char *
1473x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, int *text_bytes, int *stringp, int *freep) 1474x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp,
1475 ptrdiff_t *text_bytes, int *stringp, int *freep)
1474{ 1476{
1475 int result = string_xstring_p (string); 1477 int result = string_xstring_p (string);
1476 struct coding_system coding; 1478 struct coding_system coding;
@@ -1488,8 +1490,8 @@ x_encode_text (Lisp_Object string, Lisp_Object coding_system, int selectionp, in
1488 coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK); 1490 coding.mode |= (CODING_MODE_SAFE_ENCODING | CODING_MODE_LAST_BLOCK);
1489 /* We suppress producing escape sequences for composition. */ 1491 /* We suppress producing escape sequences for composition. */
1490 coding.common_flags &= ~CODING_ANNOTATION_MASK; 1492 coding.common_flags &= ~CODING_ANNOTATION_MASK;
1493 coding.destination = xnmalloc (SCHARS (string), 2);
1491 coding.dst_bytes = SCHARS (string) * 2; 1494 coding.dst_bytes = SCHARS (string) * 2;
1492 coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
1493 encode_coding_object (&coding, string, 0, 0, 1495 encode_coding_object (&coding, string, 0, 0,
1494 SCHARS (string), SBYTES (string), Qnil); 1496 SCHARS (string), SBYTES (string), Qnil);
1495 *text_bytes = coding.produced; 1497 *text_bytes = coding.produced;
@@ -1511,7 +1513,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name)
1511 BLOCK_INPUT; 1513 BLOCK_INPUT;
1512 { 1514 {
1513 XTextProperty text, icon; 1515 XTextProperty text, icon;
1514 int bytes, stringp; 1516 ptrdiff_t bytes;
1517 int stringp;
1515 int do_free_icon_value = 0, do_free_text_value = 0; 1518 int do_free_icon_value = 0, do_free_text_value = 0;
1516 Lisp_Object coding_system; 1519 Lisp_Object coding_system;
1517 Lisp_Object encoded_name; 1520 Lisp_Object encoded_name;
@@ -1550,6 +1553,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name)
1550 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1553 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1551 text.format = 8; 1554 text.format = 8;
1552 text.nitems = bytes; 1555 text.nitems = bytes;
1556 if (text.nitems != bytes)
1557 error ("Window name too large");
1553 1558
1554 if (!STRINGP (f->icon_name)) 1559 if (!STRINGP (f->icon_name))
1555 { 1560 {
@@ -1565,6 +1570,8 @@ x_set_name_internal (FRAME_PTR f, Lisp_Object name)
1565 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); 1570 : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
1566 icon.format = 8; 1571 icon.format = 8;
1567 icon.nitems = bytes; 1572 icon.nitems = bytes;
1573 if (icon.nitems != bytes)
1574 error ("Icon name too large");
1568 1575
1569 encoded_icon_name = ENCODE_UTF_8 (f->icon_name); 1576 encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
1570 } 1577 }
@@ -1870,7 +1877,7 @@ static XIMStyle supported_xim_styles[] =
1870#if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT 1877#if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
1871/* Create an X fontset on frame F with base font name BASE_FONTNAME. */ 1878/* Create an X fontset on frame F with base font name BASE_FONTNAME. */
1872 1879
1873static const char xic_defaut_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*"; 1880static const char xic_default_fontset[] = "-*-*-*-r-normal--14-*-*-*-*-*-*-*";
1874 1881
1875/* Create an Xt fontset spec from the name of a base font. 1882/* Create an Xt fontset spec from the name of a base font.
1876 If `motif' is True use the Motif syntax. */ 1883 If `motif' is True use the Motif syntax. */
@@ -1881,7 +1888,7 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1881 char *fontsetname; 1888 char *fontsetname;
1882 1889
1883 /* Make a fontset name from the base font name. */ 1890 /* Make a fontset name from the base font name. */
1884 if (xic_defaut_fontset == base_fontname) 1891 if (xic_default_fontset == base_fontname)
1885 { /* There is no base font name, use the default. */ 1892 { /* There is no base font name, use the default. */
1886 ptrdiff_t len = strlen (base_fontname) + 2; 1893 ptrdiff_t len = strlen (base_fontname) + 2;
1887 fontsetname = xmalloc (len); 1894 fontsetname = xmalloc (len);
@@ -1905,12 +1912,12 @@ xic_create_fontsetname (const char *base_fontname, int motif)
1905 modify it to generalize it to allcs and allfamilies. 1912 modify it to generalize it to allcs and allfamilies.
1906 Use the specified font plus the default. */ 1913 Use the specified font plus the default. */
1907 ptrdiff_t len = 1914 ptrdiff_t len =
1908 strlen (base_fontname) + strlen (xic_defaut_fontset) + 3; 1915 strlen (base_fontname) + strlen (xic_default_fontset) + 3;
1909 fontsetname = xmalloc (len); 1916 fontsetname = xmalloc (len);
1910 memset (fontsetname, 0, len); 1917 memset (fontsetname, 0, len);
1911 strcpy (fontsetname, base_fontname); 1918 strcpy (fontsetname, base_fontname);
1912 strcat (fontsetname, sep); 1919 strcat (fontsetname, sep);
1913 strcat (fontsetname, xic_defaut_fontset); 1920 strcat (fontsetname, xic_default_fontset);
1914 } 1921 }
1915 else 1922 else
1916 { 1923 {
@@ -2001,11 +2008,8 @@ xic_create_fontsetname (const char *base_fontname, int motif)
2001 2008
2002#ifdef DEBUG_XIC_FONTSET 2009#ifdef DEBUG_XIC_FONTSET
2003static void 2010static void
2004print_fontset_result (xfs, name, missing_list, missing_count) 2011print_fontset_result (XFontSet xfs, char *name, char **missing_list,
2005 XFontSet xfs; 2012 int missing_count)
2006 char *name;
2007 char **missing_list;
2008 int missing_count;
2009{ 2013{
2010 if (xfs) 2014 if (xfs)
2011 fprintf (stderr, "XIC Fontset created: %s\n", name); 2015 fprintf (stderr, "XIC Fontset created: %s\n", name);
@@ -2436,7 +2440,7 @@ x_window (struct frame *f, long window_prompting, int minibuffer_only)
2436 /* Do some needed geometry management. */ 2440 /* Do some needed geometry management. */
2437 { 2441 {
2438 ptrdiff_t len; 2442 ptrdiff_t len;
2439 char *tem, shell_position[32]; 2443 char *tem, shell_position[sizeof "=x++" + 4 * INT_STRLEN_BOUND (int)];
2440 Arg gal[10]; 2444 Arg gal[10];
2441 int gac = 0; 2445 int gac = 0;
2442 int extra_borders = 0; 2446 int extra_borders = 0;
@@ -2910,7 +2914,7 @@ x_free_gcs (struct frame *f)
2910 2914
2911 2915
2912/* Handler for signals raised during x_create_frame and 2916/* Handler for signals raised during x_create_frame and
2913 x_create_top_frame. FRAME is the frame which is partially 2917 x_create_tip_frame. FRAME is the frame which is partially
2914 constructed. */ 2918 constructed. */
2915 2919
2916static Lisp_Object 2920static Lisp_Object
@@ -2925,18 +2929,19 @@ unwind_create_frame (Lisp_Object frame)
2925 return Qnil; 2929 return Qnil;
2926 2930
2927 /* If frame is ``official'', nothing to do. */ 2931 /* If frame is ``official'', nothing to do. */
2928 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) 2932 if (NILP (Fmemq (frame, Vframe_list)))
2929 { 2933 {
2930#if GLYPH_DEBUG && XASSERTS 2934#if GLYPH_DEBUG && XASSERTS
2931 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 2935 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2932#endif 2936#endif
2933 2937
2934 x_free_frame_resources (f); 2938 x_free_frame_resources (f);
2939 free_glyphs (f);
2935 2940
2936#if GLYPH_DEBUG 2941#if GLYPH_DEBUG
2937 /* Check that reference counts are indeed correct. */ 2942 /* Check that reference counts are indeed correct. */
2938 xassert (dpyinfo->reference_count == dpyinfo_refcount); 2943 xassert (dpyinfo->reference_count == dpyinfo_refcount);
2939 xassert (dpyinfo->image_cache->refcount == image_cache_refcount); 2944 xassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
2940#endif 2945#endif
2941 return Qt; 2946 return Qt;
2942 } 2947 }
@@ -2944,6 +2949,12 @@ unwind_create_frame (Lisp_Object frame)
2944 return Qnil; 2949 return Qnil;
2945} 2950}
2946 2951
2952static Lisp_Object
2953unwind_create_frame_1 (Lisp_Object val)
2954{
2955 inhibit_lisp_code = val;
2956 return Qnil;
2957}
2947 2958
2948static void 2959static void
2949x_default_font_parameter (struct frame *f, Lisp_Object parms) 2960x_default_font_parameter (struct frame *f, Lisp_Object parms)
@@ -2957,7 +2968,7 @@ x_default_font_parameter (struct frame *f, Lisp_Object parms)
2957 2968
2958 if (NILP (font_param)) 2969 if (NILP (font_param))
2959 { 2970 {
2960 /* System font should take precedendce over X resources. We suggest this 2971 /* System font should take precedence over X resources. We suggest this
2961 regardless of font-use-system-font because .emacs may not have been 2972 regardless of font-use-system-font because .emacs may not have been
2962 read yet. */ 2973 read yet. */
2963 const char *system_font = xsettings_get_system_font (); 2974 const char *system_font = xsettings_get_system_font ();
@@ -3133,7 +3144,6 @@ This function is an internal primitive--use `make-frame' instead. */)
3133 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; 3144 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
3134 3145
3135 f->terminal = dpyinfo->terminal; 3146 f->terminal = dpyinfo->terminal;
3136 f->terminal->reference_count++;
3137 3147
3138 f->output_method = output_x_window; 3148 f->output_method = output_x_window;
3139 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output)); 3149 f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
@@ -3162,7 +3172,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3162 to get the color reference counts right, so initialize them! */ 3172 to get the color reference counts right, so initialize them! */
3163 { 3173 {
3164 Lisp_Object black; 3174 Lisp_Object black;
3165 struct gcpro inner_gcpro1; 3175 struct gcpro gcpro1;
3166 3176
3167 /* Function x_decode_color can signal an error. Make 3177 /* Function x_decode_color can signal an error. Make
3168 sure to initialize color slots so that we won't try 3178 sure to initialize color slots so that we won't try
@@ -3175,7 +3185,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3175 f->output_data.x->mouse_pixel = -1; 3185 f->output_data.x->mouse_pixel = -1;
3176 3186
3177 black = build_string ("black"); 3187 black = build_string ("black");
3178 GCPRO1_VAR (black, inner_gcpro); 3188 GCPRO1 (black);
3179 FRAME_FOREGROUND_PIXEL (f) 3189 FRAME_FOREGROUND_PIXEL (f)
3180 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 3190 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3181 FRAME_BACKGROUND_PIXEL (f) 3191 FRAME_BACKGROUND_PIXEL (f)
@@ -3188,7 +3198,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3188 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 3198 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3189 f->output_data.x->mouse_pixel 3199 f->output_data.x->mouse_pixel
3190 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 3200 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
3191 UNGCPRO_VAR (inner_gcpro); 3201 UNGCPRO;
3192 } 3202 }
3193 3203
3194 /* Specify the parent under which to make this X window. */ 3204 /* Specify the parent under which to make this X window. */
@@ -3270,7 +3280,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3270 "internalBorderWidth", "internalBorderWidth", 3280 "internalBorderWidth", "internalBorderWidth",
3271 RES_TYPE_NUMBER); 3281 RES_TYPE_NUMBER);
3272 x_default_parameter (f, parms, Qvertical_scroll_bars, 3282 x_default_parameter (f, parms, Qvertical_scroll_bars,
3273#if defined(USE_GTK) && defined(USE_TOOLKIT_SCROLL_BARS) 3283#if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
3274 Qright, 3284 Qright,
3275#else 3285#else
3276 Qleft, 3286 Qleft,
@@ -3303,6 +3313,12 @@ This function is an internal primitive--use `make-frame' instead. */)
3303 "scrollBarBackground", 3313 "scrollBarBackground",
3304 "ScrollBarBackground", 0); 3314 "ScrollBarBackground", 0);
3305 3315
3316#if GLYPH_DEBUG
3317 image_cache_refcount =
3318 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
3319 dpyinfo_refcount = dpyinfo->reference_count;
3320#endif /* GLYPH_DEBUG */
3321
3306 /* Init faces before x_default_parameter is called for scroll-bar 3322 /* Init faces before x_default_parameter is called for scroll-bar
3307 parameters because that function calls x_set_scroll_bar_width, 3323 parameters because that function calls x_set_scroll_bar_width,
3308 which calls change_frame_size, which calls Fset_window_buffer, 3324 which calls change_frame_size, which calls Fset_window_buffer,
@@ -3311,22 +3327,30 @@ This function is an internal primitive--use `make-frame' instead. */)
3311 happen. */ 3327 happen. */
3312 init_frame_faces (f); 3328 init_frame_faces (f);
3313 3329
3314#if GLYPH_DEBUG 3330 /* Set the menu-bar-lines and tool-bar-lines parameters. We don't
3315 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; 3331 look up the X resources controlling the menu-bar and tool-bar
3316 dpyinfo_refcount = dpyinfo->reference_count; 3332 here; they are processed specially at startup, and reflected in
3317#endif /* GLYPH_DEBUG */ 3333 the values of the mode variables.
3318 3334
3319 /* The X resources controlling the menu-bar and tool-bar are 3335 Avoid calling window-configuration-change-hook; otherwise we
3320 processed specially at startup, and reflected in the mode 3336 could get an infloop in next_frame since the frame is not yet in
3321 variables; ignore them here. */ 3337 Vframe_list. */
3322 x_default_parameter (f, parms, Qmenu_bar_lines, 3338 {
3323 NILP (Vmenu_bar_mode) 3339 int count2 = SPECPDL_INDEX ();
3324 ? make_number (0) : make_number (1), 3340 record_unwind_protect (unwind_create_frame_1, inhibit_lisp_code);
3325 NULL, NULL, RES_TYPE_NUMBER); 3341 inhibit_lisp_code = Qt;
3326 x_default_parameter (f, parms, Qtool_bar_lines, 3342
3327 NILP (Vtool_bar_mode) 3343 x_default_parameter (f, parms, Qmenu_bar_lines,
3328 ? make_number (0) : make_number (1), 3344 NILP (Vmenu_bar_mode)
3329 NULL, NULL, RES_TYPE_NUMBER); 3345 ? make_number (0) : make_number (1),
3346 NULL, NULL, RES_TYPE_NUMBER);
3347 x_default_parameter (f, parms, Qtool_bar_lines,
3348 NILP (Vtool_bar_mode)
3349 ? make_number (0) : make_number (1),
3350 NULL, NULL, RES_TYPE_NUMBER);
3351
3352 unbind_to (count2, Qnil);
3353 }
3330 3354
3331 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 3355 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
3332 "bufferPredicate", "BufferPredicate", 3356 "bufferPredicate", "BufferPredicate",
@@ -3359,13 +3383,14 @@ This function is an internal primitive--use `make-frame' instead. */)
3359 x_make_gc (f); 3383 x_make_gc (f);
3360 3384
3361 /* Now consider the frame official. */ 3385 /* Now consider the frame official. */
3386 f->terminal->reference_count++;
3362 FRAME_X_DISPLAY_INFO (f)->reference_count++; 3387 FRAME_X_DISPLAY_INFO (f)->reference_count++;
3363 Vframe_list = Fcons (frame, Vframe_list); 3388 Vframe_list = Fcons (frame, Vframe_list);
3364 3389
3365 /* We need to do this after creating the X window, so that the 3390 /* We need to do this after creating the X window, so that the
3366 icon-creation functions can say whose icon they're describing. */ 3391 icon-creation functions can say whose icon they're describing. */
3367 x_default_parameter (f, parms, Qicon_type, Qt, 3392 x_default_parameter (f, parms, Qicon_type, Qt,
3368 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL); 3393 "bitmapIcon", "BitmapIcon", RES_TYPE_BOOLEAN);
3369 3394
3370 x_default_parameter (f, parms, Qauto_raise, Qnil, 3395 x_default_parameter (f, parms, Qauto_raise, Qnil,
3371 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); 3396 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
@@ -3439,7 +3464,7 @@ This function is an internal primitive--use `make-frame' instead. */)
3439 BLOCK_INPUT; 3464 BLOCK_INPUT;
3440 3465
3441 /* Set machine name and pid for the purpose of window managers. */ 3466 /* Set machine name and pid for the purpose of window managers. */
3442 set_machine_and_pid_properties(f); 3467 set_machine_and_pid_properties (f);
3443 3468
3444 /* Set the WM leader property. GTK does this itself, so this is not 3469 /* Set the WM leader property. GTK does this itself, so this is not
3445 needed when using GTK. */ 3470 needed when using GTK. */
@@ -3513,9 +3538,21 @@ FRAME nil means use the selected frame. */)
3513 3538
3514 BLOCK_INPUT; 3539 BLOCK_INPUT;
3515 x_catch_errors (dpy); 3540 x_catch_errors (dpy);
3516 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3541
3517 RevertToParent, CurrentTime); 3542 if (FRAME_X_EMBEDDED_P (f))
3518 x_ewmh_activate_frame (f); 3543 {
3544 /* For Xembedded frames, normally the embedder forwards key
3545 events. See XEmbed Protocol Specification at
3546 http://freedesktop.org/wiki/Specifications/xembed-spec */
3547 xembed_request_focus (f);
3548 }
3549 else
3550 {
3551 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3552 RevertToParent, CurrentTime);
3553 x_ewmh_activate_frame (f);
3554 }
3555
3519 x_uncatch_errors (); 3556 x_uncatch_errors ();
3520 UNBLOCK_INPUT; 3557 UNBLOCK_INPUT;
3521 3558
@@ -3685,7 +3722,7 @@ If omitted or nil, that stands for the selected frame's display. */)
3685 3722
3686DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, 3723DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
3687 doc: /* Return the "vendor ID" string of the X server of display TERMINAL. 3724 doc: /* Return the "vendor ID" string of the X server of display TERMINAL.
3688\(Labelling every distributor as a "vendor" embodies the false assumption 3725\(Labeling every distributor as a "vendor" embodies the false assumption
3689that operating systems cannot be developed and distributed noncommercially.) 3726that operating systems cannot be developed and distributed noncommercially.)
3690The optional argument TERMINAL specifies which display to ask about. 3727The optional argument TERMINAL specifies which display to ask about.
3691TERMINAL should be a terminal object, a frame or a display name (a string). 3728TERMINAL should be a terminal object, a frame or a display name (a string).
@@ -4196,21 +4233,19 @@ FRAME. Default is to change on the edit X window. */)
4196 4233
4197 if (CONSP (value)) 4234 if (CONSP (value))
4198 { 4235 {
4236 ptrdiff_t elsize;
4237
4199 nelements = x_check_property_data (value); 4238 nelements = x_check_property_data (value);
4200 if (nelements == -1) 4239 if (nelements == -1)
4201 error ("Bad data in VALUE, must be number, string or cons"); 4240 error ("Bad data in VALUE, must be number, string or cons");
4202 4241
4203 if (element_format == 8) 4242 /* The man page for XChangeProperty:
4204 data = (unsigned char *) xmalloc (nelements); 4243 "If the specified format is 32, the property data must be a
4205 else if (element_format == 16) 4244 long array."
4206 data = (unsigned char *) xmalloc (nelements*2); 4245 This applies even if long is more than 32 bits. The X library
4207 else /* format == 32 */ 4246 converts to 32 bits before sending to the X server. */
4208 /* The man page for XChangeProperty: 4247 elsize = element_format == 32 ? sizeof (long) : element_format >> 3;
4209 "If the specified format is 32, the property data must be a 4248 data = xnmalloc (nelements, elsize);
4210 long array."
4211 This applies even if long is more than 64 bits. The X library
4212 converts to 32 bits before sending to the X server. */
4213 data = (unsigned char *) xmalloc (nelements * sizeof(long));
4214 4249
4215 x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format); 4250 x_fill_property_data (FRAME_X_DISPLAY (f), value, data, element_format);
4216 } 4251 }
@@ -4218,7 +4253,9 @@ FRAME. Default is to change on the edit X window. */)
4218 { 4253 {
4219 CHECK_STRING (value); 4254 CHECK_STRING (value);
4220 data = SDATA (value); 4255 data = SDATA (value);
4221 nelements = SCHARS (value); 4256 if (INT_MAX < SBYTES (value))
4257 error ("VALUE too long");
4258 nelements = SBYTES (value);
4222 } 4259 }
4223 4260
4224 BLOCK_INPUT; 4261 BLOCK_INPUT;
@@ -4280,7 +4317,7 @@ If TYPE is nil or omitted, get the property as a string.
4280Otherwise TYPE is the name of the atom that denotes the type expected. 4317Otherwise TYPE is the name of the atom that denotes the type expected.
4281If SOURCE is non-nil, get the property on that window instead of from 4318If SOURCE is non-nil, get the property on that window instead of from
4282FRAME. The number 0 denotes the root window. 4319FRAME. The number 0 denotes the root window.
4283If DELETE_P is non-nil, delete the property after retreiving it. 4320If DELETE_P is non-nil, delete the property after retrieving it.
4284If VECTOR_RET_P is non-nil, don't return a string but a vector of values. 4321If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
4285 4322
4286Value is nil if FRAME hasn't a property with name PROP or if PROP has 4323Value is nil if FRAME hasn't a property with name PROP or if PROP has
@@ -4589,7 +4626,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4589 record_unwind_protect (unwind_create_tip_frame, frame); 4626 record_unwind_protect (unwind_create_tip_frame, frame);
4590 4627
4591 f->terminal = dpyinfo->terminal; 4628 f->terminal = dpyinfo->terminal;
4592 f->terminal->reference_count++;
4593 4629
4594 /* By setting the output method, we're essentially saying that 4630 /* By setting the output method, we're essentially saying that
4595 the frame is live, as per FRAME_LIVE_P. If we get a signal 4631 the frame is live, as per FRAME_LIVE_P. If we get a signal
@@ -4615,7 +4651,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4615 to get the color reference counts right, so initialize them! */ 4651 to get the color reference counts right, so initialize them! */
4616 { 4652 {
4617 Lisp_Object black; 4653 Lisp_Object black;
4618 struct gcpro inner_gcpro1; 4654 struct gcpro gcpro1;
4619 4655
4620 /* Function x_decode_color can signal an error. Make 4656 /* Function x_decode_color can signal an error. Make
4621 sure to initialize color slots so that we won't try 4657 sure to initialize color slots so that we won't try
@@ -4628,7 +4664,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4628 f->output_data.x->mouse_pixel = -1; 4664 f->output_data.x->mouse_pixel = -1;
4629 4665
4630 black = build_string ("black"); 4666 black = build_string ("black");
4631 GCPRO1_VAR (black, inner_gcpro); 4667 GCPRO1 (black);
4632 FRAME_FOREGROUND_PIXEL (f) 4668 FRAME_FOREGROUND_PIXEL (f)
4633 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 4669 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
4634 FRAME_BACKGROUND_PIXEL (f) 4670 FRAME_BACKGROUND_PIXEL (f)
@@ -4641,7 +4677,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4641 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 4677 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
4642 f->output_data.x->mouse_pixel 4678 f->output_data.x->mouse_pixel
4643 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 4679 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
4644 UNGCPRO_VAR (inner_gcpro); 4680 UNGCPRO;
4645 } 4681 }
4646 4682
4647 /* Set the name; the functions to which we pass f expect the name to 4683 /* Set the name; the functions to which we pass f expect the name to
@@ -4711,6 +4747,12 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4711 x_default_parameter (f, parms, Qborder_color, build_string ("black"), 4747 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
4712 "borderColor", "BorderColor", RES_TYPE_STRING); 4748 "borderColor", "BorderColor", RES_TYPE_STRING);
4713 4749
4750#if GLYPH_DEBUG
4751 image_cache_refcount =
4752 FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
4753 dpyinfo_refcount = dpyinfo->reference_count;
4754#endif /* GLYPH_DEBUG */
4755
4714 /* Init faces before x_default_parameter is called for scroll-bar 4756 /* Init faces before x_default_parameter is called for scroll-bar
4715 parameters because that function calls x_set_scroll_bar_width, 4757 parameters because that function calls x_set_scroll_bar_width,
4716 which calls change_frame_size, which calls Fset_window_buffer, 4758 which calls change_frame_size, which calls Fset_window_buffer,
@@ -4719,11 +4761,6 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4719 happen. */ 4761 happen. */
4720 init_frame_faces (f); 4762 init_frame_faces (f);
4721 4763
4722#if GLYPH_DEBUG
4723 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
4724 dpyinfo_refcount = dpyinfo->reference_count;
4725#endif /* GLYPH_DEBUG */
4726
4727 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; 4764 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
4728 4765
4729 x_figure_window_size (f, parms, 0); 4766 x_figure_window_size (f, parms, 0);
@@ -4829,14 +4866,16 @@ x_create_tip_frame (struct x_display_info *dpyinfo,
4829 4866
4830 UNGCPRO; 4867 UNGCPRO;
4831 4868
4869 /* Now that the frame will be official, it counts as a reference to
4870 its display and terminal. */
4871 FRAME_X_DISPLAY_INFO (f)->reference_count++;
4872 f->terminal->reference_count++;
4873
4832 /* It is now ok to make the frame official even if we get an error 4874 /* It is now ok to make the frame official even if we get an error
4833 below. And the frame needs to be on Vframe_list or making it 4875 below. And the frame needs to be on Vframe_list or making it
4834 visible won't work. */ 4876 visible won't work. */
4835 Vframe_list = Fcons (frame, Vframe_list); 4877 Vframe_list = Fcons (frame, Vframe_list);
4836 4878
4837 /* Now that the frame is official, it counts as a reference to
4838 its display. */
4839 FRAME_X_DISPLAY_INFO (f)->reference_count++;
4840 4879
4841 /* Setting attributes of faces of the tooltip frame from resources 4880 /* Setting attributes of faces of the tooltip frame from resources
4842 and similar will increment face_change_count, which leads to the 4881 and similar will increment face_change_count, which leads to the
@@ -5590,7 +5629,7 @@ If FRAME is omitted or nil, it defaults to the selected frame. */)
5590 5629
5591 BLOCK_INPUT; 5630 BLOCK_INPUT;
5592 5631
5593 GCPRO2(font_param, font); 5632 GCPRO2 (font_param, font);
5594 5633
5595 XSETFONT (font, FRAME_FONT (f)); 5634 XSETFONT (font, FRAME_FONT (f));
5596 font_param = Ffont_get (font, intern (":name")); 5635 font_param = Ffont_get (font, intern (":name"));
@@ -5906,7 +5945,7 @@ the tool bar buttons. */);
5906 x_gtk_whole_detached_tool_bar = 0; 5945 x_gtk_whole_detached_tool_bar = 0;
5907 5946
5908 DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips, 5947 DEFVAR_BOOL ("x-gtk-use-system-tooltips", x_gtk_use_system_tooltips,
5909 doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ toolip is used. 5948 doc: /* *If non-nil with a Gtk+ built Emacs, the Gtk+ tooltip is used.
5910Otherwise use Emacs own tooltip implementation. 5949Otherwise use Emacs own tooltip implementation.
5911When using Gtk+ tooltips, the tooltip face is not used. */); 5950When using Gtk+ tooltips, the tooltip face is not used. */);
5912 x_gtk_use_system_tooltips = 1; 5951 x_gtk_use_system_tooltips = 1;