]> code.delx.au - gnu-emacs/blobdiff - src/xfns.c
Merged patches from Meadow.
[gnu-emacs] / src / xfns.c
index fa837e6a4c026df6d92305dc168d8f08a64f83b9..d7097e06a10a06073b30159f843d8e1a9941a114 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for the X window system.
-   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996 Free Software Foundation.
+   Copyright (C) 1989, 92, 93, 94, 95, 96, 1997 Free Software Foundation.
 
 This file is part of GNU Emacs.
 
@@ -36,7 +36,7 @@ Boston, MA 02111-1307, USA.  */
 #include "dispextern.h"
 #include "keyboard.h"
 #include "blockinput.h"
-#include <paths.h>
+#include <epaths.h>
 #include "charset.h"
 #include "fontset.h"
 
@@ -136,6 +136,9 @@ Lisp_Object Vx_bitmap_file_path;
 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.  */
 Lisp_Object Vx_pixel_size_width_font_regexp;
 
+/* A flag to control how to display unibyte 8-bit character.  */
+int unibyte_display_via_language_environment;
+
 /* Evaluate this expression to rebuild the section of syms_of_xfns
    that initializes and staticpros the symbols declared below.  Note
    that Emacs 18 has a bug that keeps C-x C-e from being able to
@@ -191,6 +194,7 @@ Lisp_Object Qleft;
 Lisp_Object Qright;
 Lisp_Object Qmouse_color;
 Lisp_Object Qnone;
+Lisp_Object Qouter_window_id;
 Lisp_Object Qparent_id;
 Lisp_Object Qscroll_bar_width;
 Lisp_Object Qsuppress_icon;
@@ -211,6 +215,7 @@ extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
 
 extern Lisp_Object Vwindow_system_version;
 
+Lisp_Object Qface_set_after_frame_default;
 \f
 /* Error if we are not connected to X.  */
 void
@@ -260,7 +265,8 @@ check_x_display_info (frame)
 {
   if (NILP (frame))
     {
-      if (FRAME_X_P (selected_frame))
+      if (FRAME_X_P (selected_frame)
+         && FRAME_LIVE_P (selected_frame))
        return FRAME_X_DISPLAY_INFO (selected_frame);
       else if (x_display_list != 0)
        return x_display_list;
@@ -586,6 +592,9 @@ x_create_bitmap_from_file (f, file)
   fd = openp (Vx_bitmap_file_path, file, "", &found, 0);
   if (fd < 0)
     return -1;
+  /* XReadBitmapFile won't handle magic file names.  */
+  if (fd == 0)
+    return -1;
   close (fd);
 
   filename = (char *) XSTRING (found)->data;
@@ -598,7 +607,8 @@ x_create_bitmap_from_file (f, file)
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].refcount = 1;
-  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (XSTRING (file)->size + 1);
+  dpyinfo->bitmaps[id - 1].file
+    = (char *) xmalloc (STRING_BYTES (XSTRING (file)) + 1);
   dpyinfo->bitmaps[id - 1].depth = 1;
   dpyinfo->bitmaps[id - 1].height = height;
   dpyinfo->bitmaps[id - 1].width = width;
@@ -609,7 +619,7 @@ x_create_bitmap_from_file (f, file)
 
 /* Remove reference to bitmap with id number ID.  */
 
-int
+void
 x_destroy_bitmap (f, id)
      FRAME_PTR f;
      int id;
@@ -711,6 +721,7 @@ static struct x_frame_parm_table x_frame_parms[] =
 /* Attach the `x-frame-parameter' properties to
    the Lisp symbol names of parameters relevant to X.  */
 
+void
 init_x_parm_symbols ()
 {
   int i;
@@ -720,7 +731,7 @@ init_x_parm_symbols ()
          make_number (i));
 }
 \f
-/* Change the parameters of FRAME as specified by ALIST.
+/* Change the parameters of frame F as specified by ALIST.
    If a parameter is not specially recognized, do nothing;
    otherwise call the `x_set_...' function for that parameter.  */
 
@@ -749,6 +760,8 @@ x_set_frame_parameters (f, alist)
   int left_no_change = 0, top_no_change = 0;
   int icon_left_no_change = 0, icon_top_no_change = 0;
 
+  struct gcpro gcpro1, gcpro2;
+
   i = 0;
   for (tail = alist; CONSP (tail); tail = Fcdr (tail))
     i++;
@@ -768,7 +781,15 @@ x_set_frame_parameters (f, alist)
       values[i] = Fcdr (elt);
       i++;
     }
+  /* TAIL and ALIST are not used again below here.  */
+  alist = tail = Qnil;
+
+  GCPRO2 (*parms, *values);
+  gcpro1.nvars = i;
+  gcpro2.nvars = i;
 
+  /* There is no need to gcpro LEFT, TOP, ICON_LEFT, or ICON_TOP,
+     because their values appear in VALUES and strings are not valid.  */
   top = left = Qunbound;
   icon_left = icon_top = Qunbound;
 
@@ -940,6 +961,8 @@ x_set_frame_parameters (f, alist)
        && ! (icon_left_no_change && icon_top_no_change))
       x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));
   }
+
+  UNGCPRO;
 }
 
 /* Store the screen positions of frame F into XPTR and YPTR.
@@ -1021,6 +1044,7 @@ x_real_positions (f, xptr, yptr)
    and whose values are not correctly recorded in the frame's
    param_alist need to be considered here.  */
 
+void
 x_report_frame_params (f, alistptr)
      struct frame *f;
      Lisp_Object *alistptr;
@@ -1049,6 +1073,9 @@ x_report_frame_params (f, alistptr)
   sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));
   store_in_alist (alistptr, Qwindow_id,
                   build_string (buf));
+  sprintf (buf, "%ld", (long) FRAME_OUTER_WINDOW (f));
+  store_in_alist (alistptr, Qouter_window_id,
+                  build_string (buf));
   store_in_alist (alistptr, Qicon_name, f->icon_name);
   FRAME_SAMPLE_VISIBILITY (f);
   store_in_alist (alistptr, Qvisibility,
@@ -1057,9 +1084,11 @@ x_report_frame_params (f, alistptr)
   store_in_alist (alistptr, Qdisplay,
                  XCONS (FRAME_X_DISPLAY_INFO (f)->name_list_element)->car);
 
-  store_in_alist (alistptr, Qparent_id,
-                 (f->output_data.x->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window
-                  ? Qnil : f->output_data.x->parent_desc));
+  if (f->output_data.x->parent_desc == FRAME_X_DISPLAY_INFO (f)->root_window)
+    tem = Qnil;
+  else
+    XSETFASTINT (tem, f->output_data.x->parent_desc);
+  store_in_alist (alistptr, Qparent_id, tem);
 }
 \f
 
@@ -1198,8 +1227,15 @@ x_set_foreground_color (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  f->output_data.x->foreground_pixel
+  unsigned long pixel
     = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+
+  if (f->output_data.x->foreground_pixel != f->output_data.x->mouse_pixel
+      && f->output_data.x->foreground_pixel != f->output_data.x->cursor_pixel
+      && f->output_data.x->foreground_pixel != f->output_data.x->cursor_foreground_pixel)
+    unload_color (f, f->output_data.x->foreground_pixel);
+  f->output_data.x->foreground_pixel = pixel;
+
   if (FRAME_X_WINDOW (f) != 0)
     {
       BLOCK_INPUT;
@@ -1222,9 +1258,15 @@ x_set_background_color (f, arg, oldval)
   Pixmap temp;
   int mask;
 
-  f->output_data.x->background_pixel
+  unsigned long pixel
     = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
 
+  if (f->output_data.x->background_pixel != f->output_data.x->mouse_pixel
+      && f->output_data.x->background_pixel != f->output_data.x->cursor_pixel
+      && f->output_data.x->background_pixel != f->output_data.x->cursor_foreground_pixel)
+    unload_color (f, f->output_data.x->background_pixel);
+  f->output_data.x->background_pixel = pixel;
+
   if (FRAME_X_WINDOW (f) != 0)
     {
       BLOCK_INPUT;
@@ -1262,15 +1304,23 @@ x_set_mouse_color (f, arg, oldval)
   Cursor cursor, nontext_cursor, mode_cursor, cross_cursor;
   int count;
   int mask_color;
-
+  unsigned long pixel = f->output_data.x->mouse_pixel;
+  
   if (!EQ (Qnil, arg))
-    f->output_data.x->mouse_pixel
-      = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+
   mask_color = f->output_data.x->background_pixel;
                                /* No invisible pointers.  */
-  if (mask_color == f->output_data.x->mouse_pixel
-       && mask_color == f->output_data.x->background_pixel)
-    f->output_data.x->mouse_pixel = f->output_data.x->foreground_pixel;
+  if (mask_color == pixel
+      && mask_color == f->output_data.x->background_pixel)
+    pixel = f->output_data.x->foreground_pixel;
+
+  if (f->output_data.x->background_pixel != f->output_data.x->mouse_pixel
+      && f->output_data.x->foreground_pixel != f->output_data.x->mouse_pixel
+      && f->output_data.x->cursor_pixel != f->output_data.x->mouse_pixel
+      && f->output_data.x->cursor_foreground_pixel != f->output_data.x->mouse_pixel)
+    unload_color (f, f->output_data.x->mouse_pixel);
+  f->output_data.x->mouse_pixel = pixel;
 
   BLOCK_INPUT;
 
@@ -1375,24 +1425,37 @@ x_set_cursor_color (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
-  unsigned long fore_pixel;
+  unsigned long fore_pixel, pixel;
 
   if (!EQ (Vx_cursor_fore_pixel, Qnil))
     fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
                                 WHITE_PIX_DEFAULT (f));
   else
     fore_pixel = f->output_data.x->background_pixel;
-  f->output_data.x->cursor_pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-  
+  pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+
   /* Make sure that the cursor color differs from the background color.  */
-  if (f->output_data.x->cursor_pixel == f->output_data.x->background_pixel)
+  if (pixel == f->output_data.x->background_pixel)
     {
-      f->output_data.x->cursor_pixel = f->output_data.x->mouse_pixel;
-      if (f->output_data.x->cursor_pixel == fore_pixel)
+      pixel = f->output_data.x->mouse_pixel;
+      if (pixel == fore_pixel)
        fore_pixel = f->output_data.x->background_pixel;
     }
+
+  if (f->output_data.x->background_pixel != f->output_data.x->cursor_foreground_pixel
+      && f->output_data.x->foreground_pixel != f->output_data.x->cursor_foreground_pixel
+      && f->output_data.x->mouse_pixel != f->output_data.x->cursor_foreground_pixel
+      && f->output_data.x->cursor_pixel != f->output_data.x->cursor_foreground_pixel)
+    unload_color (f, f->output_data.x->cursor_foreground_pixel);
   f->output_data.x->cursor_foreground_pixel = fore_pixel;
 
+  if (f->output_data.x->background_pixel != f->output_data.x->cursor_pixel
+      && f->output_data.x->foreground_pixel != f->output_data.x->cursor_pixel
+      && f->output_data.x->mouse_pixel != f->output_data.x->cursor_pixel
+      && f->output_data.x->cursor_foreground_pixel != f->output_data.x->cursor_pixel)
+    unload_color (f, f->output_data.x->cursor_pixel);
+  f->output_data.x->cursor_pixel = pixel;
+
   if (FRAME_X_WINDOW (f) != 0)
     {
       BLOCK_INPUT;
@@ -1441,10 +1504,12 @@ x_set_border_color (f, arg, oldval)
    Note that this does not fully take effect if done before
    F has an x-window.  */
 
+void
 x_set_border_pixel (f, pix)
      struct frame *f;
      int pix;
 {
+  unload_color (f, f->output_data.x->border_pixel);
   f->output_data.x->border_pixel = pix;
 
   if (FRAME_X_WINDOW (f) != 0 && f->output_data.x->border_width > 0)
@@ -1579,8 +1644,6 @@ x_set_icon_name (f, arg, oldval)
   UNBLOCK_INPUT;
 }
 \f
-extern Lisp_Object x_new_font ();
-
 void
 x_set_font (f, arg, oldval)
      struct frame *f;
@@ -1588,10 +1651,11 @@ x_set_font (f, arg, oldval)
 {
   Lisp_Object result;
   Lisp_Object fontset_name;
+  Lisp_Object frame;
 
   CHECK_STRING (arg, 1);
 
-  fontset_name = Fquery_fontset (arg);
+  fontset_name = Fquery_fontset (arg, Qnil);
 
   BLOCK_INPUT;
   result = (STRINGP (fontset_name)
@@ -1610,6 +1674,9 @@ x_set_font (f, arg, oldval)
     }
   else
     abort ();
+
+  XSETFRAME (frame, f);
+  call1 (Qface_set_after_frame_default, frame);
 }
 
 void
@@ -1643,8 +1710,7 @@ x_set_internal_border_width (f, arg, oldval)
 
 #ifdef USE_X_TOOLKIT
   if (f->output_data.x->edit_widget)
-    widget_store_internal_border (f->output_data.x->edit_widget,
-                                 f->output_data.x->internal_border_width);
+    widget_store_internal_border (f->output_data.x->edit_widget);
 #endif
 
   if (f->output_data.x->internal_border_width == old)
@@ -1813,14 +1879,14 @@ x_set_name (f, name, explicit)
        text.value = XSTRING (name)->data;
        text.encoding = XA_STRING;
        text.format = 8;
-       text.nitems = XSTRING (name)->size;
+       text.nitems = STRING_BYTES (XSTRING (name));
 
        icon_name = (!NILP (f->icon_name) ? f->icon_name : name);
 
        icon.value = XSTRING (icon_name)->data;
        icon.encoding = XA_STRING;
        icon.format = 8;
-       icon.nitems = XSTRING (icon_name)->size;
+       icon.nitems = STRING_BYTES (XSTRING (icon_name));
 #ifdef USE_X_TOOLKIT
        XSetWMName (FRAME_X_DISPLAY (f),
                    XtWindow (f->output_data.x->widget), &text);
@@ -1903,14 +1969,14 @@ x_set_title (f, name)
        text.value = XSTRING (name)->data;
        text.encoding = XA_STRING;
        text.format = 8;
-       text.nitems = XSTRING (name)->size;
+       text.nitems = STRING_BYTES (XSTRING (name));
 
        icon_name = (!NILP (f->icon_name) ? f->icon_name : name);
 
        icon.value = XSTRING (icon_name)->data;
        icon.encoding = XA_STRING;
        icon.format = 8;
-       icon.nitems = XSTRING (icon_name)->size;
+       icon.nitems = STRING_BYTES (XSTRING (icon_name));
 #ifdef USE_X_TOOLKIT
        XSetWMName (FRAME_X_DISPLAY (f),
                    XtWindow (f->output_data.x->widget), &text);
@@ -1986,18 +2052,23 @@ x_set_scroll_bar_width (f, arg, oldval)
      struct frame *f;
      Lisp_Object arg, oldval;
 {
+  int wid = FONT_WIDTH (f->output_data.x->font);
+
   if (NILP (arg))
     {
+      /* Make the actual width at least 14 pixels
+        and a multiple of a character width.  */
+      FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
+      /* Use all of that space (aside from required margins)
+        for the scroll bar.  */
       FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
-      FRAME_SCROLL_BAR_COLS (f) = 3;
+
       if (FRAME_X_WINDOW (f))
         x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
     }
   else if (INTEGERP (arg) && XINT (arg) > 0
           && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))
     {
-      int wid = FONT_WIDTH (f->output_data.x->font);
-
       if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)
        XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);
 
@@ -2035,7 +2106,7 @@ validate_x_resource_name ()
       unsigned char *p = XSTRING (Vx_resource_name)->data;
       int i;
 
-      len = XSTRING (Vx_resource_name)->size;
+      len = STRING_BYTES (XSTRING (Vx_resource_name));
 
       /* Only letters, digits, - and _ are valid in resource names.
         Count the valid characters and count the invalid ones.  */
@@ -2119,16 +2190,16 @@ and the class is `Emacs.CLASS.SUBCLASS'.")
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (XSTRING (Vx_resource_name)->size
+  name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name))
                              + (STRINGP (component)
-                                ? XSTRING (component)->size : 0)
-                             + XSTRING (attribute)->size
+                                ? STRING_BYTES (XSTRING (component)) : 0)
+                             + STRING_BYTES (XSTRING (attribute))
                              + 3);
 
-  class_key = (char *) alloca (XSTRING (Vx_resource_class)->size
-                              + XSTRING (class)->size
+  class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))
+                              + STRING_BYTES (XSTRING (class))
                               + (STRINGP (subclass)
-                                 ? XSTRING (subclass)->size : 0)
+                                 ? STRING_BYTES (XSTRING (subclass)) : 0)
                               + 3);
 
   /* Start with emacs.FRAMENAME for the name (the specific one)
@@ -2187,16 +2258,16 @@ display_x_get_resource (dpyinfo, attribute, class, component, subclass)
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (XSTRING (Vx_resource_name)->size
+  name_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_name))
                              + (STRINGP (component)
-                                ? XSTRING (component)->size : 0)
-                             + XSTRING (attribute)->size
+                                ? STRING_BYTES (XSTRING (component)) : 0)
+                             + STRING_BYTES (XSTRING (attribute))
                              + 3);
 
-  class_key = (char *) alloca (XSTRING (Vx_resource_class)->size
-                              + XSTRING (class)->size
+  class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))
+                              + STRING_BYTES (XSTRING (class))
                               + (STRINGP (subclass)
-                                 ? XSTRING (subclass)->size : 0)
+                                 ? STRING_BYTES (XSTRING (subclass)) : 0)
                               + 3);
 
   /* Start with emacs.FRAMENAME for the name (the specific one)
@@ -2239,7 +2310,7 @@ x_get_resource_string (attribute, class)
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  */
-  name_key = (char *) alloca (XSTRING (Vinvocation_name)->size
+  name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name))
                              + strlen (attribute) + 2);
   class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
                               + strlen (class) + 2);
@@ -2359,8 +2430,8 @@ x_get_and_record_arg (f, alist, param, attribute, class, type)
 }
 
 /* Record in frame F the specified or default value according to ALIST
-   of the parameter named PARAM (a Lisp symbol).
-   If no value is specified for PARAM, look for an X default for XPROP
+   of the parameter named PROP (a Lisp symbol).
+   If no value is specified for PROP, look for an X default for XPROP
    on the frame named NAME.
    If that is not found either, use the value DEFLT.  */
 
@@ -2897,6 +2968,7 @@ x_window (f, window_prompting, minibuffer_only)
 
 /* Create and set up the X window for frame F.  */
 
+void
 x_window (f)
      struct frame *f;
 
@@ -3217,6 +3289,7 @@ This function is an internal primitive--use `make-frame' instead.")
   f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
   bzero (f->output_data.x, sizeof (struct x_output));
   f->output_data.x->icon_bitmap = -1;
+  f->output_data.x->fontset = -1;
 
   f->icon_name
     = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title", string);
@@ -3232,7 +3305,7 @@ This function is an internal primitive--use `make-frame' instead.")
 
   if (!NILP (parent))
     {
-      f->output_data.x->parent_desc = (Window) XINT (parent);
+      f->output_data.x->parent_desc = (Window) XFASTINT (parent);
       f->output_data.x->explicit_parent = 1;
     }
   else
@@ -3268,13 +3341,13 @@ This function is an internal primitive--use `make-frame' instead.")
   {
     Lisp_Object font;
 
-    if (! STRINGP (font))
-      font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", string);
+    font = x_get_arg (dpyinfo, parms, Qfont, "font", "Font", string);
+
     BLOCK_INPUT;
     /* First, try whatever font the caller has specified.  */
     if (STRINGP (font))
       {
-       tem = Fquery_fontset (font);
+       tem = Fquery_fontset (font, Qnil);
        if (STRINGP (tem))
          font = x_new_fontset (f, XSTRING (tem)->data);
        else
@@ -3307,7 +3380,7 @@ This function is an internal primitive--use `make-frame' instead.")
 #endif
 
   x_default_parameter (f, parms, Qborder_width, make_number (2),
-                      "borderwidth", "BorderWidth", number);
+                      "borderWidth", "BorderWidth", number);
   /* This defaults to 2 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
      it).  */
@@ -3324,7 +3397,7 @@ This function is an internal primitive--use `make-frame' instead.")
   x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
                       "internalBorderWidth", "internalBorderWidth", number);
   x_default_parameter (f, parms, Qvertical_scroll_bars, Qleft,
-                      "verticalScrollBars", "ScrollBars", boolean);
+                      "verticalScrollBars", "ScrollBars", symbol);
 
   /* Also do the stuff which must be set before the window exists.  */
   x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
@@ -4018,10 +4091,10 @@ x_char_height (f)
 }
 
 int
-x_screen_planes (frame)
-     Lisp_Object frame;
+x_screen_planes (f)
+     register struct frame *f;
 {
-  return FRAME_X_DISPLAY_INFO (XFRAME (frame))->n_planes;
+  return FRAME_X_DISPLAY_INFO (f)->n_planes;
 }
 \f
 #if 0  /* These no longer seem like the right way to do things.  */
@@ -4855,7 +4928,8 @@ also be depressed for NEWSTRING to appear.")
 
   if (NILP (modifiers))
     XRebindKeysym (x_current_display, keysym, modifier_list, 0,
-                  XSTRING (newstring)->data, XSTRING (newstring)->size);
+                  XSTRING (newstring)->data,
+                  STRING_BYTES (XSTRING (newstring)));
   else
     {
       register Lisp_Object rest, mod;
@@ -4883,7 +4957,8 @@ also be depressed for NEWSTRING to appear.")
        }
 
       XRebindKeysym (x_current_display, keysym, modifier_list, i,
-                    XSTRING (newstring)->data, XSTRING (newstring)->size);
+                    XSTRING (newstring)->data,
+                    STRING_BYTES (XSTRING (newstring)));
     }
 
   return Qnil;
@@ -4914,7 +4989,7 @@ See the documentation of `x-rebind-key' for more information.")
       if (!NILP (item))
        {
          CHECK_STRING (item, 2);
-         strsize = XSTRING (item)->size;
+         strsize = STRING_BYTES (XSTRING (item));
          rawstring = (unsigned char *) xmalloc (strsize);
          bcopy (XSTRING (item)->data, rawstring, strsize);
          modifier[1] = 1 << i;
@@ -5166,6 +5241,7 @@ x_sync (f)
   UNBLOCK_INPUT;
 }
 \f
+void
 syms_of_xfns ()
 {
   /* This is zero if not using X windows.  */
@@ -5230,6 +5306,8 @@ syms_of_xfns ()
   staticpro (&Qvisibility);
   Qwindow_id = intern ("window-id");
   staticpro (&Qwindow_id);
+  Qouter_window_id = intern ("outer-window-id");
+  staticpro (&Qouter_window_id);
   Qx_frame_parameter = intern ("x-frame-parameter");
   staticpro (&Qx_frame_parameter);
   Qx_resource_name = intern ("x-resource-name");
@@ -5242,6 +5320,9 @@ syms_of_xfns ()
   staticpro (&Qdisplay);
   /* This is the end of symbol initialization.  */
 
+  Qface_set_after_frame_default = intern ("face-set-after-frame-default");
+  staticpro (&Qface_set_after_frame_default);
+
   Fput (Qundefined_color, Qerror_conditions,
        Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
   Fput (Qundefined_color, Qerror_message,
@@ -5327,6 +5408,15 @@ such a font.  This is especially effective for such large fonts as\n\
 Chinese, Japanese, and Korean.");
   Vx_pixel_size_width_font_regexp = Qnil;
 
+  DEFVAR_BOOL ("unibyte-display-via-language-environment",
+              &unibyte_display_via_language_environment,
+   "*Non-nil means display unibyte text according to language environment.\n\
+Specifically this means that unibyte non-ASCII characters\n\
+are displayed by converting them to the equivalent multibyte characters\n\
+according to the current language environment.  As a result, they are\n\
+displayed according to the current fontset.");
+  unibyte_display_via_language_environment = 0;
+
 #ifdef USE_X_TOOLKIT
   Fprovide (intern ("x-toolkit"));
 #endif
@@ -5380,6 +5470,7 @@ Chinese, Japanese, and Korean.");
   get_font_info_func = x_get_font_info;
   list_fonts_func = x_list_fonts;
   load_font_func = x_load_font;
+  find_ccl_program_func = x_find_ccl_program;
   query_font_func = x_query_font;
   set_frame_fontset_func = x_set_font;
   check_window_system_func = check_x;