]> code.delx.au - gnu-emacs/blobdiff - src/xfns.c
Merged patches from Meadow.
[gnu-emacs] / src / xfns.c
index 520a7022a8b079f3c0dd35a90a107489932ec34e..d7097e06a10a06073b30159f843d8e1a9941a114 100644 (file)
@@ -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;
@@ -261,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;
@@ -587,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;
@@ -713,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;
@@ -751,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++;
@@ -770,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;
 
@@ -942,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.
@@ -1052,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,
@@ -1203,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;
@@ -1227,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;
@@ -1267,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;
 
@@ -1380,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;
@@ -1451,6 +1509,7 @@ 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)
@@ -1585,10 +1644,6 @@ x_set_icon_name (f, arg, oldval)
   UNBLOCK_INPUT;
 }
 \f
-extern Lisp_Object x_new_font ();
-extern Lisp_Object x_new_fontset ();
-extern Lisp_Object Fquery_fontset ();
-
 void
 x_set_font (f, arg, oldval)
      struct frame *f;
@@ -1600,7 +1655,7 @@ x_set_font (f, arg, oldval)
 
   CHECK_STRING (arg, 1);
 
-  fontset_name = Fquery_fontset (arg);
+  fontset_name = Fquery_fontset (arg, Qnil);
 
   BLOCK_INPUT;
   result = (STRINGP (fontset_name)
@@ -2913,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;
 
@@ -3291,7 +3347,7 @@ This function is an internal primitive--use `make-frame' instead.")
     /* 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
@@ -5185,6 +5241,7 @@ x_sync (f)
   UNBLOCK_INPUT;
 }
 \f
+void
 syms_of_xfns ()
 {
   /* This is zero if not using X windows.  */
@@ -5249,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");
@@ -5349,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