/[emacs]/emacs/src/xfns.c
ViewVC logotype

Diff of /emacs/src/xfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.549 by eliz, Fri May 31 17:43:08 2002 UTC revision 1.549.2.1 by miles, Fri Apr 4 06:21:08 2003 UTC
# Line 1  Line 1 
1  /* Functions for the X window system.  /* Functions for the X window system.
2     Copyright (C) 1989, 92, 93, 94, 95, 96, 1997, 1998, 1999, 2000, 2001     Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 01, 02, 03
3       Free Software Foundation.       Free Software Foundation.
4    
5  This file is part of GNU Emacs.  This file is part of GNU Emacs.
# Line 65  Boston, MA 02111-1307, USA.  */ Line 65  Boston, MA 02111-1307, USA.  */
65  #include "[.bitmaps]gray.xbm"  #include "[.bitmaps]gray.xbm"
66  #endif  #endif
67    
68    #ifdef USE_GTK
69    #include "gtkutil.h"
70    #endif
71    
72  #ifdef USE_X_TOOLKIT  #ifdef USE_X_TOOLKIT
73  #include <X11/Shell.h>  #include <X11/Shell.h>
74    
# Line 135  int gray_bitmap_width = gray_width; Line 139  int gray_bitmap_width = gray_width;
139  int gray_bitmap_height = gray_height;  int gray_bitmap_height = gray_height;
140  char *gray_bitmap_bits = gray_bits;  char *gray_bitmap_bits = gray_bits;
141    
 /* The name we're using in resource queries.  Most often "emacs".  */  
   
 Lisp_Object Vx_resource_name;  
   
 /* The application class we're using in resource queries.  
    Normally "Emacs".  */  
   
 Lisp_Object Vx_resource_class;  
   
142  /* Non-zero means we're allowed to display an hourglass cursor.  */  /* Non-zero means we're allowed to display an hourglass cursor.  */
143    
144  int display_hourglass_p;  int display_hourglass_p;
# Line 183  Lisp_Object Vx_bitmap_file_path; Line 178  Lisp_Object Vx_bitmap_file_path;
178    
179  Lisp_Object Vx_pixel_size_width_font_regexp;  Lisp_Object Vx_pixel_size_width_font_regexp;
180    
 Lisp_Object Qauto_raise;  
 Lisp_Object Qauto_lower;  
 Lisp_Object Qbar, Qhbar;  
 Lisp_Object Qborder_color;  
 Lisp_Object Qborder_width;  
 Lisp_Object Qbox;  
 Lisp_Object Qcursor_color;  
 Lisp_Object Qcursor_type;  
 Lisp_Object Qgeometry;  
 Lisp_Object Qicon_left;  
 Lisp_Object Qicon_top;  
 Lisp_Object Qicon_type;  
 Lisp_Object Qicon_name;  
 Lisp_Object Qinternal_border_width;  
 Lisp_Object Qleft;  
 Lisp_Object Qright;  
 Lisp_Object Qmouse_color;  
181  Lisp_Object Qnone;  Lisp_Object Qnone;
 Lisp_Object Qouter_window_id;  
 Lisp_Object Qparent_id;  
 Lisp_Object Qscroll_bar_width;  
182  Lisp_Object Qsuppress_icon;  Lisp_Object Qsuppress_icon;
 extern Lisp_Object Qtop;  
183  Lisp_Object Qundefined_color;  Lisp_Object Qundefined_color;
184  Lisp_Object Qvertical_scroll_bars;  Lisp_Object Qcenter;
 Lisp_Object Qvisibility;  
 Lisp_Object Qwindow_id;  
 Lisp_Object Qx_frame_parameter;  
 Lisp_Object Qx_resource_name;  
 Lisp_Object Quser_position;  
 Lisp_Object Quser_size;  
 extern Lisp_Object Qdisplay;  
 Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;  
 Lisp_Object Qscreen_gamma, Qline_spacing, Qcenter;  
185  Lisp_Object Qcompound_text, Qcancel_timer;  Lisp_Object Qcompound_text, Qcancel_timer;
 Lisp_Object Qwait_for_wm;  
 Lisp_Object Qfullscreen;  
 Lisp_Object Qfullwidth;  
 Lisp_Object Qfullheight;  
 Lisp_Object Qfullboth;  
   
 /* The below are defined in frame.c.  */  
186    
187  extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;  /* In dispnew.c */
 extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;  
 extern Lisp_Object Qtool_bar_lines;  
188    
189  extern Lisp_Object Vwindow_system_version;  extern Lisp_Object Vwindow_system_version;
190    
191  Lisp_Object Qface_set_after_frame_default;  /* The below are defined in frame.c.  */
192    
193  #if GLYPH_DEBUG  #if GLYPH_DEBUG
194  int image_cache_refcount, dpyinfo_refcount;  int image_cache_refcount, dpyinfo_refcount;
# Line 280  check_x_frame (frame) Line 236  check_x_frame (frame)
236     nil stands for the selected frame--or, if that is not an X frame,     nil stands for the selected frame--or, if that is not an X frame,
237     the first X display on the list.  */     the first X display on the list.  */
238    
239  static struct x_display_info *  struct x_display_info *
240  check_x_display_info (frame)  check_x_display_info (frame)
241       Lisp_Object frame;       Lisp_Object frame;
242  {  {
243    struct x_display_info *dpyinfo = NULL;    struct x_display_info *dpyinfo = NULL;
244      
245    if (NILP (frame))    if (NILP (frame))
246      {      {
247        struct frame *sf = XFRAME (selected_frame);        struct frame *sf = XFRAME (selected_frame);
248          
249        if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))        if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
250          dpyinfo = FRAME_X_DISPLAY_INFO (sf);          dpyinfo = FRAME_X_DISPLAY_INFO (sf);
251        else if (x_display_list != 0)        else if (x_display_list != 0)
# Line 301  check_x_display_info (frame) Line 257  check_x_display_info (frame)
257      dpyinfo = x_display_info_for_name (frame);      dpyinfo = x_display_info_for_name (frame);
258    else    else
259      {      {
260        FRAME_PTR f;        FRAME_PTR f = check_x_frame (frame);
   
       CHECK_LIVE_FRAME (frame);  
       f = XFRAME (frame);  
       if (! FRAME_X_P (f))  
         error ("Non-X frame used");  
261        dpyinfo = FRAME_X_DISPLAY_INFO (f);        dpyinfo = FRAME_X_DISPLAY_INFO (f);
262      }      }
263    
# Line 338  x_window_to_frame (dpyinfo, wdesc) Line 289  x_window_to_frame (dpyinfo, wdesc)
289        if (f->output_data.x->hourglass_window == wdesc)        if (f->output_data.x->hourglass_window == wdesc)
290          return f;          return f;
291  #ifdef USE_X_TOOLKIT  #ifdef USE_X_TOOLKIT
292        if ((f->output_data.x->edit_widget        if ((f->output_data.x->edit_widget
293             && XtWindow (f->output_data.x->edit_widget) == wdesc)             && XtWindow (f->output_data.x->edit_widget) == wdesc)
294            /* A tooltip frame?  */            /* A tooltip frame?  */
295            || (!f->output_data.x->edit_widget            || (!f->output_data.x->edit_widget
# Line 346  x_window_to_frame (dpyinfo, wdesc) Line 297  x_window_to_frame (dpyinfo, wdesc)
297            || f->output_data.x->icon_desc == wdesc)            || f->output_data.x->icon_desc == wdesc)
298          return f;          return f;
299  #else /* not USE_X_TOOLKIT */  #else /* not USE_X_TOOLKIT */
300    #ifdef USE_GTK
301          if (f->output_data.x->edit_widget)
302          {
303            GtkWidget *gwdesc = xg_win_to_widget (wdesc);
304            struct x_output *x = f->output_data.x;
305            if (gwdesc != 0 && gwdesc == x->edit_widget)
306              return f;
307          }
308    #endif /* USE_GTK */
309        if (FRAME_X_WINDOW (f) == wdesc        if (FRAME_X_WINDOW (f) == wdesc
310            || f->output_data.x->icon_desc == wdesc)            || f->output_data.x->icon_desc == wdesc)
311          return f;          return f;
# Line 354  x_window_to_frame (dpyinfo, wdesc) Line 314  x_window_to_frame (dpyinfo, wdesc)
314    return 0;    return 0;
315  }  }
316    
317  #ifdef USE_X_TOOLKIT  #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
318  /* Like x_window_to_frame but also compares the window with the widget's  /* Like x_window_to_frame but also compares the window with the widget's
319     windows.  */     windows.  */
320    
# Line 373  x_any_window_to_frame (dpyinfo, wdesc) Line 333  x_any_window_to_frame (dpyinfo, wdesc)
333        frame = XCAR (tail);        frame = XCAR (tail);
334        if (!GC_FRAMEP (frame))        if (!GC_FRAMEP (frame))
335          continue;          continue;
336          
337        f = XFRAME (frame);        f = XFRAME (frame);
338        if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)        if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
339          {          {
# Line 383  x_any_window_to_frame (dpyinfo, wdesc) Line 343  x_any_window_to_frame (dpyinfo, wdesc)
343              found = f;              found = f;
344            else if (x->widget)            else if (x->widget)
345              {              {
346                if (wdesc == XtWindow (x->widget)  #ifdef USE_GTK
347                    || wdesc == XtWindow (x->column_widget)                GtkWidget *gwdesc = xg_win_to_widget (wdesc);
348                  if (gwdesc != 0
349                      && (gwdesc == x->widget
350                          || gwdesc == x->edit_widget
351                          || gwdesc == x->vbox_widget
352                          || gwdesc == x->menubar_widget))
353                    found = f;
354    #else
355                  if (wdesc == XtWindow (x->widget)
356                      || wdesc == XtWindow (x->column_widget)
357                    || wdesc == XtWindow (x->edit_widget))                    || wdesc == XtWindow (x->edit_widget))
358                  found = f;                  found = f;
359                /* Match if the window is this frame's menubar.  */                /* Match if the window is this frame's menubar.  */
360                else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))                else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
361                  found = f;                  found = f;
362    #endif
363              }              }
364            else if (FRAME_X_WINDOW (f) == wdesc)            else if (FRAME_X_WINDOW (f) == wdesc)
365              /* A tooltip frame.  */              /* A tooltip frame.  */
366              found = f;              found = f;
367          }          }
368      }      }
369      
370    return found;    return found;
371  }  }
372    
# Line 425  x_non_menubar_window_to_frame (dpyinfo, Line 395  x_non_menubar_window_to_frame (dpyinfo,
395          return f;          return f;
396        else if (x->widget)        else if (x->widget)
397          {          {
398            if (wdesc == XtWindow (x->widget)  #ifdef USE_GTK
399                || wdesc == XtWindow (x->column_widget)            GtkWidget *gwdesc = xg_win_to_widget (wdesc);
400              if (gwdesc != 0
401                  && (gwdesc == x->widget
402                      || gwdesc == x->edit_widget
403                      || gwdesc == x->vbox_widget))
404                return f;
405    #else
406              if (wdesc == XtWindow (x->widget)
407                  || wdesc == XtWindow (x->column_widget)
408                || wdesc == XtWindow (x->edit_widget))                || wdesc == XtWindow (x->edit_widget))
409              return f;              return f;
410    #endif
411          }          }
412        else if (FRAME_X_WINDOW (f) == wdesc)        else if (FRAME_X_WINDOW (f) == wdesc)
413          /* A tooltip frame.  */          /* A tooltip frame.  */
# Line 458  x_menubar_window_to_frame (dpyinfo, wdes Line 437  x_menubar_window_to_frame (dpyinfo, wdes
437          continue;          continue;
438        x = f->output_data.x;        x = f->output_data.x;
439        /* Match if the window is this frame's menubar.  */        /* Match if the window is this frame's menubar.  */
440    #ifdef USE_GTK
441          if (x->menubar_widget)
442            {
443              GtkWidget *gwdesc = xg_win_to_widget (wdesc);
444              int found = 0;
445    
446              BLOCK_INPUT;
447              if (gwdesc != 0
448                  && (gwdesc == x->menubar_widget
449                      || gtk_widget_get_parent (gwdesc) == x->menubar_widget))
450                found = 1;
451              UNBLOCK_INPUT;
452              if (found) return f;
453            }
454    #else
455        if (x->menubar_widget        if (x->menubar_widget
456            && lw_window_is_in_menubar (wdesc, x->menubar_widget))            && lw_window_is_in_menubar (wdesc, x->menubar_widget))
457          return f;          return f;
458    #endif
459      }      }
460    return 0;    return 0;
461  }  }
# Line 490  x_top_window_to_frame (dpyinfo, wdesc) Line 485  x_top_window_to_frame (dpyinfo, wdesc)
485        if (x->widget)        if (x->widget)
486          {          {
487            /* This frame matches if the window is its topmost widget.  */            /* This frame matches if the window is its topmost widget.  */
488    #ifdef USE_GTK
489              GtkWidget *gwdesc = xg_win_to_widget (wdesc);
490              if (gwdesc == x->widget)
491                return f;
492    #else
493            if (wdesc == XtWindow (x->widget))            if (wdesc == XtWindow (x->widget))
494              return f;              return f;
495  #if 0 /* I don't know why it did this,  #if 0 /* I don't know why it did this,
496           but it seems logically wrong,           but it seems logically wrong,
497           and it causes trouble for MapNotify events.  */           and it causes trouble for MapNotify events.  */
498            /* Match if the window is this frame's menubar.  */            /* Match if the window is this frame's menubar.  */
499            if (x->menubar_widget            if (x->menubar_widget
500                && wdesc == XtWindow (x->menubar_widget))                && wdesc == XtWindow (x->menubar_widget))
501              return f;              return f;
502  #endif  #endif
503    #endif
504          }          }
505        else if (FRAME_X_WINDOW (f) == wdesc)        else if (FRAME_X_WINDOW (f) == wdesc)
506          /* Tooltip frame.  */          /* Tooltip frame.  */
# Line 507  x_top_window_to_frame (dpyinfo, wdesc) Line 508  x_top_window_to_frame (dpyinfo, wdesc)
508      }      }
509    return 0;    return 0;
510  }  }
511  #endif /* USE_X_TOOLKIT */  #endif /* USE_X_TOOLKIT || USE_GTK */
512    
513    
514    
# Line 607  x_create_bitmap_from_data (f, bits, widt Line 608  x_create_bitmap_from_data (f, bits, widt
608    bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),    bitmap = XCreateBitmapFromData (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
609                                    bits, width, height);                                    bits, width, height);
610    
611    
612    
613    if (! bitmap)    if (! bitmap)
614      return -1;      return -1;
615    
# Line 641  x_create_bitmap_from_file (f, file) Line 644  x_create_bitmap_from_file (f, file)
644      {      {
645        if (dpyinfo->bitmaps[id].refcount        if (dpyinfo->bitmaps[id].refcount
646            && dpyinfo->bitmaps[id].file            && dpyinfo->bitmaps[id].file
647            && !strcmp (dpyinfo->bitmaps[id].file, (char *) XSTRING (file)->data))            && !strcmp (dpyinfo->bitmaps[id].file, (char *) SDATA (file)))
648          {          {
649            ++dpyinfo->bitmaps[id].refcount;            ++dpyinfo->bitmaps[id].refcount;
650            return id + 1;            return id + 1;
# Line 654  x_create_bitmap_from_file (f, file) Line 657  x_create_bitmap_from_file (f, file)
657      return -1;      return -1;
658    emacs_close (fd);    emacs_close (fd);
659    
660    filename = (char *) XSTRING (found)->data;    filename = (char *) SDATA (found);
661    
662    result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),    result = XReadBitmapFile (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
663                              filename, &width, &height, &bitmap, &xhot, &yhot);                              filename, &width, &height, &bitmap, &xhot, &yhot);
# Line 665  x_create_bitmap_from_file (f, file) Line 668  x_create_bitmap_from_file (f, file)
668    dpyinfo->bitmaps[id - 1].pixmap = bitmap;    dpyinfo->bitmaps[id - 1].pixmap = bitmap;
669    dpyinfo->bitmaps[id - 1].refcount = 1;    dpyinfo->bitmaps[id - 1].refcount = 1;
670    dpyinfo->bitmaps[id - 1].file    dpyinfo->bitmaps[id - 1].file
671      = (char *) xmalloc (STRING_BYTES (XSTRING (file)) + 1);      = (char *) xmalloc (SBYTES (file) + 1);
672    dpyinfo->bitmaps[id - 1].depth = 1;    dpyinfo->bitmaps[id - 1].depth = 1;
673    dpyinfo->bitmaps[id - 1].height = height;    dpyinfo->bitmaps[id - 1].height = height;
674    dpyinfo->bitmaps[id - 1].width = width;    dpyinfo->bitmaps[id - 1].width = width;
675    strcpy (dpyinfo->bitmaps[id - 1].file, XSTRING (file)->data);    strcpy (dpyinfo->bitmaps[id - 1].file, SDATA (file));
676    
677    return id;    return id;
678  }  }
# Line 717  x_destroy_all_bitmaps (dpyinfo) Line 720  x_destroy_all_bitmaps (dpyinfo)
720    dpyinfo->bitmaps_last = 0;    dpyinfo->bitmaps_last = 0;
721  }  }
722    
 /* Connect the frame-parameter names for X frames  
    to the ways of passing the parameter values to the window system.  
   
    The name of a parameter, as a Lisp symbol,  
    has an `x-frame-parameter' property which is an integer in Lisp  
    that is an index in this table.  */  
   
 struct x_frame_parm_table  
 {  
   char *name;  
   void (*setter) P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 };  
723    
724  static Lisp_Object unwind_create_frame P_ ((Lisp_Object));  static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
725  static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));  static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
 static void x_change_window_heights P_ ((Lisp_Object, int));  
726  static void x_disable_image P_ ((struct frame *, struct image *));  static void x_disable_image P_ ((struct frame *, struct image *));
727    
728  void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
 static void x_set_line_spacing P_ ((struct frame *, Lisp_Object, Lisp_Object));  
729  static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object));  static void x_set_wait_for_wm P_ ((struct frame *, Lisp_Object, Lisp_Object));
 static void x_set_fullscreen P_ ((struct frame *, Lisp_Object, Lisp_Object));  
730  void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
731  void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
732  void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
# Line 745  void x_set_border_color P_ ((struct fram Line 734  void x_set_border_color P_ ((struct fram
734  void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
735  void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
736  void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
 static void x_set_fringe_width P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 void x_set_font P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 void x_set_border_width P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 void x_set_internal_border_width P_ ((struct frame *, Lisp_Object,  
                                       Lisp_Object));  
737  void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_autoraise P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 void x_set_autolower P_ ((struct frame *, Lisp_Object, Lisp_Object));  
 void x_set_vertical_scroll_bars P_ ((struct frame *, Lisp_Object,  
                                      Lisp_Object));  
 void x_set_visibility P_ ((struct frame *, Lisp_Object, Lisp_Object));  
738  void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_scroll_bar_width P_ ((struct frame *, Lisp_Object, Lisp_Object));  
739  void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
 void x_set_unsplittable P_ ((struct frame *, Lisp_Object, Lisp_Object));  
740  void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));  void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
741  void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,  void x_set_scroll_bar_foreground P_ ((struct frame *, Lisp_Object,
742                                        Lisp_Object));                                        Lisp_Object));
# Line 770  static Lisp_Object x_default_scroll_bar_ Line 747  static Lisp_Object x_default_scroll_bar_
747                                                               Lisp_Object,                                                               Lisp_Object,
748                                                               char *, char *,                                                               char *, char *,
749                                                               int));                                                               int));
 static void x_set_screen_gamma P_ ((struct frame *, Lisp_Object, Lisp_Object));  
750  static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object,  static void x_edge_detection P_ ((struct frame *, struct image *, Lisp_Object,
751                                    Lisp_Object));                                    Lisp_Object));
752  static void init_color_table P_ ((void));  static void init_color_table P_ ((void));
# Line 781  static unsigned long lookup_pixel_color Line 757  static unsigned long lookup_pixel_color
757    
758    
759    
 static struct x_frame_parm_table x_frame_parms[] =  
 {  
   {"auto-raise",                x_set_autoraise},  
   {"auto-lower",                x_set_autolower},  
   {"background-color",          x_set_background_color},  
   {"border-color",              x_set_border_color},  
   {"border-width",              x_set_border_width},  
   {"cursor-color",              x_set_cursor_color},  
   {"cursor-type",               x_set_cursor_type},  
   {"font",                      x_set_font},  
   {"foreground-color",          x_set_foreground_color},  
   {"icon-name",                 x_set_icon_name},  
   {"icon-type",                 x_set_icon_type},  
   {"internal-border-width",     x_set_internal_border_width},  
   {"menu-bar-lines",            x_set_menu_bar_lines},  
   {"mouse-color",               x_set_mouse_color},  
   {"name",                      x_explicitly_set_name},  
   {"scroll-bar-width",          x_set_scroll_bar_width},  
   {"title",                     x_set_title},  
   {"unsplittable",              x_set_unsplittable},  
   {"vertical-scroll-bars",      x_set_vertical_scroll_bars},  
   {"visibility",                x_set_visibility},  
   {"tool-bar-lines",            x_set_tool_bar_lines},  
   {"scroll-bar-foreground",     x_set_scroll_bar_foreground},  
   {"scroll-bar-background",     x_set_scroll_bar_background},  
   {"screen-gamma",              x_set_screen_gamma},  
   {"line-spacing",              x_set_line_spacing},  
   {"left-fringe",               x_set_fringe_width},  
   {"right-fringe",              x_set_fringe_width},  
   {"wait-for-wm",               x_set_wait_for_wm},  
   {"fullscreen",                x_set_fullscreen},  
     
 };  
   
 /* Attach the `x-frame-parameter' properties to  
    the Lisp symbol names of parameters relevant to X.  */  
   
 void  
 init_x_parm_symbols ()  
 {  
   int i;  
   
   for (i = 0; i < sizeof (x_frame_parms) / sizeof (x_frame_parms[0]); i++)  
     Fput (intern (x_frame_parms[i].name), Qx_frame_parameter,  
           make_number (i));  
 }  
760    
761    
 /* Really try to move where we want to be in case of fullscreen.  Some WMs  
    moves the window where we tell them.  Some (mwm, twm) moves the outer  
    window manager window there instead.  
    Try to compensate for those WM here. */  
 static void  
 x_fullscreen_move (f, new_top, new_left)  
      struct frame *f;  
      int new_top;  
      int new_left;  
 {  
   if (new_top != f->output_data.x->top_pos  
       || new_left != f->output_data.x->left_pos)  
     {  
       int move_x = new_left + f->output_data.x->x_pixels_outer_diff;  
       int move_y = new_top + f->output_data.x->y_pixels_outer_diff;  
   
       f->output_data.x->want_fullscreen |= FULLSCREEN_MOVE_WAIT;  
       x_set_offset (f, move_x, move_y, 1);  
     }  
 }  
   
 /* Change the parameters of frame F as specified by ALIST.  
    If a parameter is not specially recognized, do nothing special;  
    otherwise call the `x_set_...' function for that parameter.  
    Except for certain geometry properties, always call store_frame_param  
    to store the new value in the parameter alist.  */  
   
 void  
 x_set_frame_parameters (f, alist)  
      FRAME_PTR f;  
      Lisp_Object alist;  
 {  
   Lisp_Object tail;  
   
   /* If both of these parameters are present, it's more efficient to  
      set them both at once.  So we wait until we've looked at the  
      entire list before we set them.  */  
   int width, height;  
   
   /* Same here.  */  
   Lisp_Object left, top;  
   
   /* Same with these.  */  
   Lisp_Object icon_left, icon_top;  
   
   /* Record in these vectors all the parms specified.  */  
   Lisp_Object *parms;  
   Lisp_Object *values;  
   int i, p;  
   int left_no_change = 0, top_no_change = 0;  
   int icon_left_no_change = 0, icon_top_no_change = 0;  
   int fullscreen_is_being_set = 0;  
   
   struct gcpro gcpro1, gcpro2;  
   
   i = 0;  
   for (tail = alist; CONSP (tail); tail = Fcdr (tail))  
     i++;  
   
   parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));  
   values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));  
   
   /* Extract parm names and values into those vectors.  */  
   
   i = 0;  
   for (tail = alist; CONSP (tail); tail = Fcdr (tail))  
     {  
       Lisp_Object elt;  
   
       elt = Fcar (tail);  
       parms[i] = Fcar (elt);  
       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;  
   
   /* Provide default values for HEIGHT and WIDTH.  */  
   if (FRAME_NEW_WIDTH (f))  
     width = FRAME_NEW_WIDTH (f);  
   else  
     width = FRAME_WIDTH (f);  
   
   if (FRAME_NEW_HEIGHT (f))  
     height = FRAME_NEW_HEIGHT (f);  
   else  
     height = FRAME_HEIGHT (f);  
   
   /* Process foreground_color and background_color before anything else.  
      They are independent of other properties, but other properties (e.g.,  
      cursor_color) are dependent upon them.  */  
   /* Process default font as well, since fringe widths depends on it.  */  
   /* Also, process fullscreen, width and height depend upon that */  
   for (p = 0; p < i; p++)  
     {  
       Lisp_Object prop, val;  
   
       prop = parms[p];  
       val = values[p];  
       if (EQ (prop, Qforeground_color)  
           || EQ (prop, Qbackground_color)  
           || EQ (prop, Qfont)  
           || EQ (prop, Qfullscreen))  
         {  
           register Lisp_Object param_index, old_value;  
   
           old_value = get_frame_param (f, prop);  
           fullscreen_is_being_set |= EQ (prop, Qfullscreen);  
             
           if (NILP (Fequal (val, old_value)))  
             {  
               store_frame_param (f, prop, val);  
   
               param_index = Fget (prop, Qx_frame_parameter);  
               if (NATNUMP (param_index)  
                   && (XFASTINT (param_index)  
                       < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))  
                 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);  
             }  
         }  
     }  
   
   /* Now process them in reverse of specified order.  */  
   for (i--; i >= 0; i--)  
     {  
       Lisp_Object prop, val;  
   
       prop = parms[i];  
       val = values[i];  
   
       if (EQ (prop, Qwidth) && NUMBERP (val))  
         width = XFASTINT (val);  
       else if (EQ (prop, Qheight) && NUMBERP (val))  
         height = XFASTINT (val);  
       else if (EQ (prop, Qtop))  
         top = val;  
       else if (EQ (prop, Qleft))  
         left = val;  
       else if (EQ (prop, Qicon_top))  
         icon_top = val;  
       else if (EQ (prop, Qicon_left))  
         icon_left = val;  
       else if (EQ (prop, Qforeground_color)  
                || EQ (prop, Qbackground_color)  
                || EQ (prop, Qfont)  
                || EQ (prop, Qfullscreen))  
         /* Processed above.  */  
         continue;  
       else  
         {  
           register Lisp_Object param_index, old_value;  
   
           old_value = get_frame_param (f, prop);  
   
           store_frame_param (f, prop, val);  
   
           param_index = Fget (prop, Qx_frame_parameter);  
           if (NATNUMP (param_index)  
               && (XFASTINT (param_index)  
                   < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))  
             (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);  
         }  
     }  
   
   /* Don't die if just one of these was set.  */  
   if (EQ (left, Qunbound))  
     {  
       left_no_change = 1;  
       if (f->output_data.x->left_pos < 0)  
         left = Fcons (Qplus, Fcons (make_number (f->output_data.x->left_pos), Qnil));  
       else  
         XSETINT (left, f->output_data.x->left_pos);  
     }  
   if (EQ (top, Qunbound))  
     {  
       top_no_change = 1;  
       if (f->output_data.x->top_pos < 0)  
         top = Fcons (Qplus, Fcons (make_number (f->output_data.x->top_pos), Qnil));  
       else  
         XSETINT (top, f->output_data.x->top_pos);  
     }  
   
   /* If one of the icon positions was not set, preserve or default it.  */  
   if (EQ (icon_left, Qunbound) || ! INTEGERP (icon_left))  
     {  
       icon_left_no_change = 1;  
       icon_left = Fcdr (Fassq (Qicon_left, f->param_alist));  
       if (NILP (icon_left))  
         XSETINT (icon_left, 0);  
     }  
   if (EQ (icon_top, Qunbound) || ! INTEGERP (icon_top))  
     {  
       icon_top_no_change = 1;  
       icon_top = Fcdr (Fassq (Qicon_top, f->param_alist));  
       if (NILP (icon_top))  
         XSETINT (icon_top, 0);  
     }  
   
   if (FRAME_VISIBLE_P (f) && fullscreen_is_being_set)  
     {  
       /* If the frame is visible already and the fullscreen parameter is  
          being set, it is too late to set WM manager hints to specify  
          size and position.  
          Here we first get the width, height and position that applies to  
          fullscreen.  We then move the frame to the appropriate  
          position.  Resize of the frame is taken care of in the code after  
          this if-statement. */  
       int new_left, new_top;  
         
       x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);  
       x_fullscreen_move (f, new_top, new_left);  
     }  
     
   /* Don't set these parameters unless they've been explicitly  
      specified.  The window might be mapped or resized while we're in  
      this function, and we don't want to override that unless the lisp  
      code has asked for it.  
   
      Don't set these parameters unless they actually differ from the  
      window's current parameters; the window may not actually exist  
      yet.  */  
   {  
     Lisp_Object frame;  
   
     check_frame_size (f, &height, &width);  
   
     XSETFRAME (frame, f);  
   
     if (width != FRAME_WIDTH (f)  
         || height != FRAME_HEIGHT (f)  
         || FRAME_NEW_HEIGHT (f) || FRAME_NEW_WIDTH (f))  
       Fset_frame_size (frame, make_number (width), make_number (height));  
   
     if ((!NILP (left) || !NILP (top))  
         && ! (left_no_change && top_no_change)  
         && ! (NUMBERP (left) && XINT (left) == f->output_data.x->left_pos  
               && NUMBERP (top) && XINT (top) == f->output_data.x->top_pos))  
       {  
         int leftpos = 0;  
         int toppos = 0;  
   
         /* Record the signs.  */  
         f->output_data.x->size_hint_flags &= ~ (XNegative | YNegative);  
         if (EQ (left, Qminus))  
           f->output_data.x->size_hint_flags |= XNegative;  
         else if (INTEGERP (left))  
           {  
             leftpos = XINT (left);  
             if (leftpos < 0)  
               f->output_data.x->size_hint_flags |= XNegative;  
           }  
         else if (CONSP (left) && EQ (XCAR (left), Qminus)  
                  && CONSP (XCDR (left))  
                  && INTEGERP (XCAR (XCDR (left))))  
           {  
             leftpos = - XINT (XCAR (XCDR (left)));  
             f->output_data.x->size_hint_flags |= XNegative;  
           }  
         else if (CONSP (left) && EQ (XCAR (left), Qplus)  
                  && CONSP (XCDR (left))  
                  && INTEGERP (XCAR (XCDR (left))))  
           {  
             leftpos = XINT (XCAR (XCDR (left)));  
           }  
   
         if (EQ (top, Qminus))  
           f->output_data.x->size_hint_flags |= YNegative;  
         else if (INTEGERP (top))  
           {  
             toppos = XINT (top);  
             if (toppos < 0)  
               f->output_data.x->size_hint_flags |= YNegative;  
           }  
         else if (CONSP (top) && EQ (XCAR (top), Qminus)  
                  && CONSP (XCDR (top))  
                  && INTEGERP (XCAR (XCDR (top))))  
           {  
             toppos = - XINT (XCAR (XCDR (top)));  
             f->output_data.x->size_hint_flags |= YNegative;  
           }  
         else if (CONSP (top) && EQ (XCAR (top), Qplus)  
                  && CONSP (XCDR (top))  
                  && INTEGERP (XCAR (XCDR (top))))  
           {  
             toppos = XINT (XCAR (XCDR (top)));  
           }  
   
   
         /* Store the numeric value of the position.  */  
         f->output_data.x->top_pos = toppos;  
         f->output_data.x->left_pos = leftpos;  
   
         f->output_data.x->win_gravity = NorthWestGravity;  
   
         /* Actually set that position, and convert to absolute.  */  
         x_set_offset (f, leftpos, toppos, -1);  
       }  
   
     if ((!NILP (icon_left) || !NILP (icon_top))  
         && ! (icon_left_no_change && icon_top_no_change))  
       x_wm_set_icon_position (f, XINT (icon_left), XINT (icon_top));  
   }  
   
   UNGCPRO;  
 }  
   
762  /* Store the screen positions of frame F into XPTR and YPTR.  /* Store the screen positions of frame F into XPTR and YPTR.
763     These are the positions of the containing window manager window,     These are the positions of the containing window manager window,
764     not Emacs's own window.  */     not Emacs's own window.  */
# Line 1194  x_real_positions (f, xptr, yptr) Line 809  x_real_positions (f, xptr, yptr)
809    
810        win = wm_window;        win = wm_window;
811      }      }
812        
813    if (! had_errors)    if (! had_errors)
814      {      {
815        int ign;        int ign;
816        Window child, rootw;        Window child, rootw;
817              
818        /* Get the real coordinates for the WM window upper left corner */        /* Get the real coordinates for the WM window upper left corner */
819        XGetGeometry (FRAME_X_DISPLAY (f), win,        XGetGeometry (FRAME_X_DISPLAY (f), win,
820                      &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);                      &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
# Line 1238  x_real_positions (f, xptr, yptr) Line 853  x_real_positions (f, xptr, yptr)
853                                   /* From-window, to-window.  */                                   /* From-window, to-window.  */
854                                   FRAME_X_DISPLAY_INFO (f)->root_window,                                   FRAME_X_DISPLAY_INFO (f)->root_window,
855                                   FRAME_OUTER_WINDOW (f),                                   FRAME_OUTER_WINDOW (f),
856                                        
857                                   /* From-position, to-position.  */                                   /* From-position, to-position.  */
858                                   real_x, real_y, &outer_x, &outer_y,                                   real_x, real_y, &outer_x, &outer_y,
859                            
860                                   /* Child of win.  */                                   /* Child of win.  */
861                                   &child);                                   &child);
862      }      }
863    
864        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
865      }      }
866          
867    x_uncatch_errors (FRAME_X_DISPLAY (f), count);    x_uncatch_errors (FRAME_X_DISPLAY (f), count);
868          
869    UNBLOCK_INPUT;    UNBLOCK_INPUT;
870    
871    if (had_errors) return;    if (had_errors) return;
872          
873    f->output_data.x->x_pixels_diff = -win_x;    f->output_data.x->x_pixels_diff = -win_x;
874    f->output_data.x->y_pixels_diff = -win_y;    f->output_data.x->y_pixels_diff = -win_y;
875    f->output_data.x->x_pixels_outer_diff = -outer_x;    f->output_data.x->x_pixels_outer_diff = -outer_x;
# Line 1264  x_real_positions (f, xptr, yptr) Line 879  x_real_positions (f, xptr, yptr)
879    *yptr = real_y;    *yptr = real_y;
880  }  }
881    
 /* Insert a description of internally-recorded parameters of frame X  
    into the parameter alist *ALISTPTR that is to be given to the user.  
    Only parameters that are specific to the X window system  
    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;  
 {  
   char buf[16];  
   Lisp_Object tem;  
   
   /* Represent negative positions (off the top or left screen edge)  
      in a way that Fmodify_frame_parameters will understand correctly.  */  
   XSETINT (tem, f->output_data.x->left_pos);  
   if (f->output_data.x->left_pos >= 0)  
     store_in_alist (alistptr, Qleft, tem);  
   else  
     store_in_alist (alistptr, Qleft, Fcons (Qplus, Fcons (tem, Qnil)));  
   
   XSETINT (tem, f->output_data.x->top_pos);  
   if (f->output_data.x->top_pos >= 0)  
     store_in_alist (alistptr, Qtop, tem);  
   else  
     store_in_alist (alistptr, Qtop, Fcons (Qplus, Fcons (tem, Qnil)));  
   
   store_in_alist (alistptr, Qborder_width,  
            make_number (f->output_data.x->border_width));  
   store_in_alist (alistptr, Qinternal_border_width,  
            make_number (f->output_data.x->internal_border_width));  
   store_in_alist (alistptr, Qleft_fringe,  
            make_number (f->output_data.x->left_fringe_width));  
   store_in_alist (alistptr, Qright_fringe,  
            make_number (f->output_data.x->right_fringe_width));  
   store_in_alist (alistptr, Qscroll_bar_width,  
            make_number (FRAME_HAS_VERTICAL_SCROLL_BARS (f)  
                         ? FRAME_SCROLL_BAR_PIXEL_WIDTH(f)  
                         : 0));  
   sprintf (buf, "%ld", (long) FRAME_X_WINDOW (f));  
   store_in_alist (alistptr, Qwindow_id,  
            build_string (buf));  
 #ifdef USE_X_TOOLKIT  
   /* Tooltip frame may not have this widget.  */  
   if (f->output_data.x->widget)  
 #endif  
     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,  
                   (FRAME_VISIBLE_P (f) ? Qt  
                    : FRAME_ICONIFIED_P (f) ? Qicon : Qnil));  
   store_in_alist (alistptr, Qdisplay,  
                   XCAR (FRAME_X_DISPLAY_INFO (f)->name_list_element));  
   
   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);  
 }  
882    
883    
884    
# Line 1390  x_decode_color (f, color_name, mono_colo Line 941  x_decode_color (f, color_name, mono_colo
941  #if 0 /* Don't do this.  It's wrong when we're not using the default  #if 0 /* Don't do this.  It's wrong when we're not using the default
942           colormap, it makes freeing difficult, and it's probably not           colormap, it makes freeing difficult, and it's probably not
943           an important optimization.  */           an important optimization.  */
944    if (strcmp (XSTRING (color_name)->data, "black") == 0)    if (strcmp (SDATA (color_name), "black") == 0)
945      return BLACK_PIX_DEFAULT (f);      return BLACK_PIX_DEFAULT (f);
946    else if (strcmp (XSTRING (color_name)->data, "white") == 0)    else if (strcmp (SDATA (color_name), "white") == 0)
947      return WHITE_PIX_DEFAULT (f);      return WHITE_PIX_DEFAULT (f);
948  #endif  #endif
949    
# Line 1402  x_decode_color (f, color_name, mono_colo Line 953  x_decode_color (f, color_name, mono_colo
953    
954    /* x_defined_color is responsible for coping with failures    /* x_defined_color is responsible for coping with failures
955       by looking for a near-miss.  */       by looking for a near-miss.  */
956    if (x_defined_color (f, XSTRING (color_name)->data, &cdef, 1))    if (x_defined_color (f, SDATA (color_name), &cdef, 1))
957      return cdef.pixel;      return cdef.pixel;
958    
959    Fsignal (Qerror, Fcons (build_string ("Undefined color"),    Fsignal (Qerror, Fcons (build_string ("Undefined color"),
# Line 1412  x_decode_color (f, color_name, mono_colo Line 963  x_decode_color (f, color_name, mono_colo
963    
964    
965    
 /* Change the `line-spacing' frame parameter of frame F.  OLD_VALUE is  
    the previous value of that parameter, NEW_VALUE is the new value.  */  
   
 static void  
 x_set_line_spacing (f, new_value, old_value)  
      struct frame *f;  
      Lisp_Object new_value, old_value;  
 {  
   if (NILP (new_value))  
     f->extra_line_spacing = 0;  
   else if (NATNUMP (new_value))  
     f->extra_line_spacing = XFASTINT (new_value);  
   else  
     Fsignal (Qerror, Fcons (build_string ("Invalid line-spacing"),  
                             Fcons (new_value, Qnil)));  
   if (FRAME_VISIBLE_P (f))  
     redraw_frame (f);  
 }  
   
   
966  /* Change the `wait-for-wm' frame parameter of frame F.  OLD_VALUE is  /* Change the `wait-for-wm' frame parameter of frame F.  OLD_VALUE is
967     the previous value of that parameter, NEW_VALUE is the new value.     the previous value of that parameter, NEW_VALUE is the new value.
968     See also the comment of wait_for_wm in struct x_output.  */     See also the comment of wait_for_wm in struct x_output.  */
# Line 1445  x_set_wait_for_wm (f, new_value, old_val Line 976  x_set_wait_for_wm (f, new_value, old_val
976  }  }
977    
978    
 /* Change the `fullscreen' frame parameter of frame F.  OLD_VALUE is  
    the previous value of that parameter, NEW_VALUE is the new value. */  
   
 static void  
 x_set_fullscreen (f, new_value, old_value)  
      struct frame *f;  
      Lisp_Object new_value, old_value;  
 {  
   if (NILP (new_value))  
     f->output_data.x->want_fullscreen = FULLSCREEN_NONE;  
   else if (EQ (new_value, Qfullboth))  
     f->output_data.x->want_fullscreen = FULLSCREEN_BOTH;  
   else if (EQ (new_value, Qfullwidth))  
     f->output_data.x->want_fullscreen = FULLSCREEN_WIDTH;  
   else if (EQ (new_value, Qfullheight))  
     f->output_data.x->want_fullscreen = FULLSCREEN_HEIGHT;  
 }  
   
   
 /* Change the `screen-gamma' frame parameter of frame F.  OLD_VALUE is  
    the previous value of that parameter, NEW_VALUE is the new  
    value.  */  
   
 static void  
 x_set_screen_gamma (f, new_value, old_value)  
      struct frame *f;  
      Lisp_Object new_value, old_value;  
 {  
   if (NILP (new_value))  
     f->gamma = 0;  
   else if (NUMBERP (new_value) && XFLOATINT (new_value) > 0)  
     /* The value 0.4545 is the normal viewing gamma.  */  
     f->gamma = 1.0 / (0.4545 * XFLOATINT (new_value));  
   else  
     Fsignal (Qerror, Fcons (build_string ("Invalid screen-gamma"),  
                             Fcons (new_value, Qnil)));  
   
   clear_face_cache (0);  
 }  
   
   
979  /* Functions called only from `x_set_frame_param'  /* Functions called only from `x_set_frame_param'
980     to set individual parameters.     to set individual parameters.
981    
# Line 1509  x_set_foreground_color (f, arg, oldval) Line 999  x_set_foreground_color (f, arg, oldval)
999    if (FRAME_X_WINDOW (f) != 0)    if (FRAME_X_WINDOW (f) != 0)
1000      {      {
1001        Display *dpy = FRAME_X_DISPLAY (f);        Display *dpy = FRAME_X_DISPLAY (f);
1002          
1003        BLOCK_INPUT;        BLOCK_INPUT;
1004        XSetForeground (dpy, x->normal_gc, fg);        XSetForeground (dpy, x->normal_gc, fg);
1005        XSetBackground (dpy, x->reverse_gc, fg);        XSetBackground (dpy, x->reverse_gc, fg);
# Line 1520  x_set_foreground_color (f, arg, oldval) Line 1010  x_set_foreground_color (f, arg, oldval)
1010            x->cursor_pixel = x_copy_color (f, fg);            x->cursor_pixel = x_copy_color (f, fg);
1011            XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);            XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);
1012          }          }
1013          
1014        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1015          
1016        update_face_from_frame_parameter (f, Qforeground_color, arg);        update_face_from_frame_parameter (f, Qforeground_color, arg);
1017          
1018        if (FRAME_VISIBLE_P (f))        if (FRAME_VISIBLE_P (f))
1019          redraw_frame (f);          redraw_frame (f);
1020      }      }
1021          
1022    unload_color (f, old_fg);    unload_color (f, old_fg);
1023  }  }
1024    
# Line 1547  x_set_background_color (f, arg, oldval) Line 1037  x_set_background_color (f, arg, oldval)
1037    if (FRAME_X_WINDOW (f) != 0)    if (FRAME_X_WINDOW (f) != 0)
1038      {      {
1039        Display *dpy = FRAME_X_DISPLAY (f);        Display *dpy = FRAME_X_DISPLAY (f);
1040          
1041        BLOCK_INPUT;        BLOCK_INPUT;
1042        XSetBackground (dpy, x->normal_gc, bg);        XSetBackground (dpy, x->normal_gc, bg);
1043        XSetForeground (dpy, x->reverse_gc, bg);        XSetForeground (dpy, x->reverse_gc, bg);
1044        XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);        XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);
1045        XSetForeground (dpy, x->cursor_gc, bg);        XSetForeground (dpy, x->cursor_gc, bg);
1046    
1047    #ifdef USE_GTK
1048          xg_set_background_color (f, bg);
1049    #endif
1050    
1051  #ifndef USE_TOOLKIT_SCROLL_BARS /* Turns out to be annoying with  #ifndef USE_TOOLKIT_SCROLL_BARS /* Turns out to be annoying with
1052                                     toolkit scroll bars.  */                                     toolkit scroll bars.  */
1053        {        {
# Line 1583  x_set_mouse_color (f, arg, oldval) Line 1077  x_set_mouse_color (f, arg, oldval)
1077  {  {
1078    struct x_output *x = f->output_data.x;    struct x_output *x = f->output_data.x;
1079    Display *dpy = FRAME_X_DISPLAY (f);    Display *dpy = FRAME_X_DISPLAY (f);
1080    Cursor cursor, nontext_cursor, mode_cursor, cross_cursor;    Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
1081    Cursor hourglass_cursor, horizontal_drag_cursor;    Cursor hourglass_cursor, horizontal_drag_cursor;
1082    int count;    int count;
1083    unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));    unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
# Line 1632  x_set_mouse_color (f, arg, oldval) Line 1126  x_set_mouse_color (f, arg, oldval)
1126    else    else
1127      hourglass_cursor = XCreateFontCursor (dpy, XC_watch);      hourglass_cursor = XCreateFontCursor (dpy, XC_watch);
1128    x_check_errors (dpy, "bad hourglass pointer cursor: %s");    x_check_errors (dpy, "bad hourglass pointer cursor: %s");
1129      
1130    x_check_errors (dpy, "bad nontext pointer cursor: %s");    x_check_errors (dpy, "bad nontext pointer cursor: %s");
1131    if (!NILP (Vx_mode_pointer_shape))    if (!NILP (Vx_mode_pointer_shape))
1132      {      {
# Line 1646  x_set_mouse_color (f, arg, oldval) Line 1140  x_set_mouse_color (f, arg, oldval)
1140    if (!NILP (Vx_sensitive_text_pointer_shape))    if (!NILP (Vx_sensitive_text_pointer_shape))
1141      {      {
1142        CHECK_NUMBER (Vx_sensitive_text_pointer_shape);        CHECK_NUMBER (Vx_sensitive_text_pointer_shape);
1143        cross_cursor        hand_cursor
1144          = XCreateFontCursor (dpy, XINT (Vx_sensitive_text_pointer_shape));          = XCreateFontCursor (dpy, XINT (Vx_sensitive_text_pointer_shape));
1145      }      }
1146    else    else
1147      cross_cursor = XCreateFontCursor (dpy, XC_hand2);      hand_cursor = XCreateFontCursor (dpy, XC_hand2);
1148    
1149    if (!NILP (Vx_window_horizontal_drag_shape))    if (!NILP (Vx_window_horizontal_drag_shape))
1150      {      {
# Line 1673  x_set_mouse_color (f, arg, oldval) Line 1167  x_set_mouse_color (f, arg, oldval)
1167      x_query_color (f, &fore_color);      x_query_color (f, &fore_color);
1168      back_color.pixel = mask_color;      back_color.pixel = mask_color;
1169      x_query_color (f, &back_color);      x_query_color (f, &back_color);
1170        
1171      XRecolorCursor (dpy, cursor, &fore_color, &back_color);      XRecolorCursor (dpy, cursor, &fore_color, &back_color);
1172      XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
1173      XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
1174      XRecolorCursor (dpy, cross_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, hand_cursor, &fore_color, &back_color);
1175      XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);
1176      XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color);
1177    }    }
# Line 1704  x_set_mouse_color (f, arg, oldval) Line 1198  x_set_mouse_color (f, arg, oldval)
1198        && x->modeline_cursor != 0)        && x->modeline_cursor != 0)
1199      XFreeCursor (dpy, f->output_data.x->modeline_cursor);      XFreeCursor (dpy, f->output_data.x->modeline_cursor);
1200    x->modeline_cursor = mode_cursor;    x->modeline_cursor = mode_cursor;
1201      
1202    if (cross_cursor != x->cross_cursor    if (hand_cursor != x->hand_cursor
1203        && x->cross_cursor != 0)        && x->hand_cursor != 0)
1204      XFreeCursor (dpy, x->cross_cursor);      XFreeCursor (dpy, x->hand_cursor);
1205    x->cross_cursor = cross_cursor;    x->hand_cursor = hand_cursor;
1206    
1207    if (horizontal_drag_cursor != x->horizontal_drag_cursor    if (horizontal_drag_cursor != x->horizontal_drag_cursor
1208        && x->horizontal_drag_cursor != 0)        && x->horizontal_drag_cursor != 0)
# Line 1738  x_set_cursor_color (f, arg, oldval) Line 1232  x_set_cursor_color (f, arg, oldval)
1232      }      }
1233    else    else
1234      fore_pixel = x->background_pixel;      fore_pixel = x->background_pixel;
1235      
1236    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1237    pixel_allocated_p = 1;    pixel_allocated_p = 1;
1238    
# Line 1750  x_set_cursor_color (f, arg, oldval) Line 1244  x_set_cursor_color (f, arg, oldval)
1244            x_free_colors (f, &pixel, 1);            x_free_colors (f, &pixel, 1);
1245            pixel_allocated_p = 0;            pixel_allocated_p = 0;
1246          }          }
1247          
1248        pixel = x->mouse_pixel;        pixel = x->mouse_pixel;
1249        if (pixel == fore_pixel)        if (pixel == fore_pixel)
1250          {          {
# Line 1790  x_set_cursor_color (f, arg, oldval) Line 1284  x_set_cursor_color (f, arg, oldval)
1284    update_face_from_frame_parameter (f, Qcursor_color, arg);    update_face_from_frame_parameter (f, Qcursor_color, arg);
1285  }  }
1286    
 /* Set the border-color of frame F to value described by ARG.  
    ARG can be a string naming a color.  
    The border-color is used for the border that is drawn by the X server.  
    Note that this does not fully take effect if done before  
    F has an x-window; it must be redone when the window is created.  
   
    Note: this is done in two routines because of the way X10 works.  
   
    Note: under X11, this is normally the province of the window manager,  
    and so emacs' border colors may be overridden.  */  
   
 void  
 x_set_border_color (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   int pix;  
   
   CHECK_STRING (arg);  
   pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));  
   x_set_border_pixel (f, pix);  
   update_face_from_frame_parameter (f, Qborder_color, arg);  
 }  
   
1287  /* Set the border-color of frame F to pixel value PIX.  /* Set the border-color of frame F to pixel value PIX.
1288     Note that this does not fully take effect if done before     Note that this does not fully take effect if done before
1289     F has an x-window.  */     F has an x-window.  */
# Line 1838  x_set_border_pixel (f, pix) Line 1308  x_set_border_pixel (f, pix)
1308      }      }
1309  }  }
1310    
1311    /* Set the border-color of frame F to value described by ARG.
1312       ARG can be a string naming a color.
1313       The border-color is used for the border that is drawn by the X server.
1314       Note that this does not fully take effect if done before
1315       F has an x-window; it must be redone when the window is created.
1316    
1317  /* Value is the internal representation of the specified cursor type     Note: this is done in two routines because of the way X10 works.
    ARG.  If type is BAR_CURSOR, return in *WIDTH the specified width  
    of the bar cursor.  */  
   
 enum text_cursor_kinds  
 x_specified_cursor_type (arg, width)  
      Lisp_Object arg;  
      int *width;  
 {  
   enum text_cursor_kinds type;  
     
   if (EQ (arg, Qbar))  
     {  
       type = BAR_CURSOR;  
       *width = 2;  
     }  
   else if (CONSP (arg)  
            && EQ (XCAR (arg), Qbar)  
            && INTEGERP (XCDR (arg))  
            && XINT (XCDR (arg)) >= 0)  
     {  
       type = BAR_CURSOR;  
       *width = XINT (XCDR (arg));  
     }  
   else if (EQ (arg, Qhbar))  
     {  
       type = HBAR_CURSOR;  
       *width = 2;  
     }  
   else if (CONSP (arg)  
            && EQ (XCAR (arg), Qhbar)  
            && INTEGERP (XCDR (arg))  
            && XINT (XCDR (arg)) >= 0)  
     {  
       type = HBAR_CURSOR;  
       *width = XINT (XCDR (arg));  
     }  
   else if (NILP (arg))  
     type = NO_CURSOR;  
   else  
     /* Treat anything unknown as "box cursor".  
        It was bad to signal an error; people have trouble fixing  
        .Xdefaults with Emacs, when it has something bad in it.  */  
     type = FILLED_BOX_CURSOR;  
1318    
1319    return type;     Note: under X11, this is normally the province of the window manager,
1320       and so emacs' border colors may be overridden.  */
1321    
1322    void
1323    x_set_border_color (f, arg, oldval)
1324         struct frame *f;
1325         Lisp_Object arg, oldval;
1326    {
1327      int pix;
1328    
1329      CHECK_STRING (arg);
1330      pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1331      x_set_border_pixel (f, pix);
1332      update_face_from_frame_parameter (f, Qborder_color, arg);
1333  }  }
1334    
1335    
1336  void  void
1337  x_set_cursor_type (f, arg, oldval)  x_set_cursor_type (f, arg, oldval)
1338       FRAME_PTR f;       FRAME_PTR f;
1339       Lisp_Object arg, oldval;       Lisp_Object arg, oldval;
1340  {  {
1341    int width;    set_frame_cursor_types (f, arg);
     
   FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width);  
   f->output_data.x->cursor_width = width;  
1342    
1343    /* Make sure the cursor gets redrawn.  */    /* Make sure the cursor gets redrawn.  */
1344    cursor_type_changed = 1;    cursor_type_changed = 1;
# Line 1919  x_set_icon_type (f, arg, oldval) Line 1362  x_set_icon_type (f, arg, oldval)
1362    BLOCK_INPUT;    BLOCK_INPUT;
1363    if (NILP (arg))    if (NILP (arg))
1364      result = x_text_icon (f,      result = x_text_icon (f,
1365                            (char *) XSTRING ((!NILP (f->icon_name)                            (char *) SDATA ((!NILP (f->icon_name)
1366                                               ? f->icon_name                                               ? f->icon_name
1367                                               : f->name))->data);                                               : f->name)));
1368    else    else
1369      result = x_bitmap_icon (f, arg);      result = x_bitmap_icon (f, arg);
1370    
# Line 1935  x_set_icon_type (f, arg, oldval) Line 1378  x_set_icon_type (f, arg, oldval)
1378    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1379  }  }
1380    
 /* Return non-nil if frame F wants a bitmap icon.  */  
   
 Lisp_Object  
 x_icon_type (f)  
      FRAME_PTR f;  
 {  
   Lisp_Object tem;  
   
   tem = assq_no_quit (Qicon_type, f->param_alist);  
   if (CONSP (tem))  
     return XCDR (tem);  
   else  
     return Qnil;  
 }  
   
1381  void  void
1382  x_set_icon_name (f, arg, oldval)  x_set_icon_name (f, arg, oldval)
1383       struct frame *f;       struct frame *f;
# Line 1973  x_set_icon_name (f, arg, oldval) Line 1401  x_set_icon_name (f, arg, oldval)
1401    BLOCK_INPUT;    BLOCK_INPUT;
1402    
1403    result = x_text_icon (f,    result = x_text_icon (f,
1404                          (char *) XSTRING ((!NILP (f->icon_name)                          (char *) SDATA ((!NILP (f->icon_name)
1405                                             ? f->icon_name                                           ? f->icon_name
1406                                             : !NILP (f->title)                                           : !NILP (f->title)
1407                                             ? f->title                                           ? f->title
1408                                             : f->name))->data);                                           : f->name)));
1409    
1410    if (result)    if (result)
1411      {      {
# Line 1988  x_set_icon_name (f, arg, oldval) Line 1416  x_set_icon_name (f, arg, oldval)
1416    XFlush (FRAME_X_DISPLAY (f));    XFlush (FRAME_X_DISPLAY (f));
1417    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1418  }  }
   
 void  
 x_set_font (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   Lisp_Object result;  
   Lisp_Object fontset_name;  
   Lisp_Object frame;  
   int old_fontset = f->output_data.x->fontset;  
   
   CHECK_STRING (arg);  
   
   fontset_name = Fquery_fontset (arg, Qnil);  
   
   BLOCK_INPUT;  
   result = (STRINGP (fontset_name)  
             ? x_new_fontset (f, XSTRING (fontset_name)->data)  
             : x_new_font (f, XSTRING (arg)->data));  
   UNBLOCK_INPUT;  
     
   if (EQ (result, Qnil))  
     error ("Font `%s' is not defined", XSTRING (arg)->data);  
   else if (EQ (result, Qt))  
     error ("The characters of the given font have varying widths");  
   else if (STRINGP (result))  
     {  
       if (STRINGP (fontset_name))  
         {  
           /* Fontset names are built from ASCII font names, so the  
              names may be equal despite there was a change.  */  
           if (old_fontset == f->output_data.x->fontset)  
             return;  
         }  
       else if (!NILP (Fequal (result, oldval)))  
         return;  
         
       store_frame_param (f, Qfont, result);  
       recompute_basic_faces (f);  
     }  
   else  
     abort ();  
   
   do_pending_window_change (0);  
   
   /* Don't call `face-set-after-frame-default' when faces haven't been  
      initialized yet.  This is the case when called from  
      Fx_create_frame.  In that case, the X widget or window doesn't  
      exist either, and we can end up in x_report_frame_params with a  
      null widget which gives a segfault.  */  
   if (FRAME_FACE_CACHE (f))  
     {  
       XSETFRAME (frame, f);  
       call1 (Qface_set_after_frame_default, frame);  
     }  
 }  
   
 static void  
 x_set_fringe_width (f, new_value, old_value)  
      struct frame *f;  
      Lisp_Object new_value, old_value;  
 {  
   x_compute_fringe_widths (f, 1);  
 }  
   
 void  
 x_set_border_width (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   CHECK_NUMBER (arg);  
   
   if (XINT (arg) == f->output_data.x->border_width)  
     return;  
   
   if (FRAME_X_WINDOW (f) != 0)  
     error ("Cannot change the border width of a window");  
   
   f->output_data.x->border_width = XINT (arg);  
 }  
   
 void  
 x_set_internal_border_width (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   int old = f->output_data.x->internal_border_width;  
   
   CHECK_NUMBER (arg);  
   f->output_data.x->internal_border_width = XINT (arg);  
   if (f->output_data.x->internal_border_width < 0)  
     f->output_data.x->internal_border_width = 0;  
   
 #ifdef USE_X_TOOLKIT  
   if (f->output_data.x->edit_widget)  
     widget_store_internal_border (f->output_data.x->edit_widget);  
 #endif  
   
   if (f->output_data.x->internal_border_width == old)  
     return;  
   
   if (FRAME_X_WINDOW (f) != 0)  
     {  
       x_set_window_size (f, 0, f->width, f->height);  
       SET_FRAME_GARBAGED (f);  
       do_pending_window_change (0);  
     }  
   else  
     SET_FRAME_GARBAGED (f);  
 }  
   
 void  
 x_set_visibility (f, value, oldval)  
      struct frame *f;  
      Lisp_Object value, oldval;  
 {  
   Lisp_Object frame;  
   XSETFRAME (frame, f);  
   
   if (NILP (value))  
     Fmake_frame_invisible (frame, Qt);  
   else if (EQ (value, Qicon))  
     Ficonify_frame (frame);  
   else  
     Fmake_frame_visible (frame);  
 }  
1419    
1420    
 /* Change window heights in windows rooted in WINDOW by N lines.  */  
   
 static void  
 x_change_window_heights (window, n)  
   Lisp_Object window;  
   int n;  
 {  
   struct window *w = XWINDOW (window);  
   
   XSETFASTINT (w->top, XFASTINT (w->top) + n);  
   XSETFASTINT (w->height, XFASTINT (w->height) - n);  
   
   if (INTEGERP (w->orig_top))  
     XSETFASTINT (w->orig_top, XFASTINT (w->orig_top) + n);  
   if (INTEGERP (w->orig_height))  
     XSETFASTINT (w->orig_height, XFASTINT (w->orig_height) - n);  
   
   /* Handle just the top child in a vertical split.  */  
   if (!NILP (w->vchild))  
     x_change_window_heights (w->vchild, n);  
   
   /* Adjust all children in a horizontal split.  */  
   for (window = w->hchild; !NILP (window); window = w->next)  
     {  
       w = XWINDOW (window);  
       x_change_window_heights (window, n);  
     }  
 }  
   
1421  void  void
1422  x_set_menu_bar_lines (f, value, oldval)  x_set_menu_bar_lines (f, value, oldval)
1423       struct frame *f;       struct frame *f;
# Line 2170  x_set_menu_bar_lines (f, value, oldval) Line 1443  x_set_menu_bar_lines (f, value, oldval)
1443    /* Make sure we redisplay all windows in this frame.  */    /* Make sure we redisplay all windows in this frame.  */
1444    windows_or_buffers_changed++;    windows_or_buffers_changed++;
1445    
1446  #ifdef USE_X_TOOLKIT  #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
1447    FRAME_MENU_BAR_LINES (f) = 0;    FRAME_MENU_BAR_LINES (f) = 0;
1448    if (nlines)    if (nlines)
1449      {      {
# Line 2187  x_set_menu_bar_lines (f, value, oldval) Line 1460  x_set_menu_bar_lines (f, value, oldval)
1460        if (FRAME_X_P (f))        if (FRAME_X_P (f))
1461          f->output_data.x->menubar_widget = 0;          f->output_data.x->menubar_widget = 0;
1462      }      }
1463  #else /* not USE_X_TOOLKIT */  #else /* not USE_X_TOOLKIT && not USE_GTK */
1464    FRAME_MENU_BAR_LINES (f) = nlines;    FRAME_MENU_BAR_LINES (f) = nlines;
1465    x_change_window_heights (f->root_window, nlines - olines);    change_window_heights (f->root_window, nlines - olines);
1466  #endif /* not USE_X_TOOLKIT */  #endif /* not USE_X_TOOLKIT */
1467    adjust_glyphs (f);    adjust_glyphs (f);
1468  }  }
# Line 2219  x_set_tool_bar_lines (f, value, oldval) Line 1492  x_set_tool_bar_lines (f, value, oldval)
1492    else    else
1493      nlines = 0;      nlines = 0;
1494    
1495    /* Make sure we redisplay all windows in this frame.  */  #ifdef USE_GTK
1496      FRAME_TOOL_BAR_LINES (f) = 0;
1497      if (nlines)
1498        {
1499          FRAME_EXTERNAL_TOOL_BAR (f) = 1;
1500          if (FRAME_X_P (f) && f->output_data.x->toolbar_widget == 0)
1501            /* Make sure next redisplay shows the tool bar.  */
1502            XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
1503          update_frame_tool_bar (f);
1504        }
1505      else
1506        {
1507          if (FRAME_EXTERNAL_TOOL_BAR (f))
1508            free_frame_tool_bar (f);
1509          FRAME_EXTERNAL_TOOL_BAR (f) = 0;
1510        }
1511    
1512      return;
1513    #endif
1514    
1515         /* Make sure we redisplay all windows in this frame.  */
1516    ++windows_or_buffers_changed;    ++windows_or_buffers_changed;
1517    
1518    delta = nlines - FRAME_TOOL_BAR_LINES (f);    delta = nlines - FRAME_TOOL_BAR_LINES (f);
# Line 2234  x_set_tool_bar_lines (f, value, oldval) Line 1527  x_set_tool_bar_lines (f, value, oldval)
1527      }      }
1528    
1529    FRAME_TOOL_BAR_LINES (f) = nlines;    FRAME_TOOL_BAR_LINES (f) = nlines;
1530    x_change_window_heights (root_window, delta);    change_window_heights (root_window, delta);
1531    adjust_glyphs (f);    adjust_glyphs (f);
1532      
1533    /* We also have to make sure that the internal border at the top of    /* We also have to make sure that the internal border at the top of
1534       the frame, below the menu bar or tool bar, is redrawn when the       the frame, below the menu bar or tool bar, is redrawn when the
1535       tool bar disappears.  This is so because the internal border is       tool bar disappears.  This is so because the internal border is
# Line 2282  x_set_scroll_bar_foreground (f, value, o Line 1575  x_set_scroll_bar_foreground (f, value, o
1575       Lisp_Object value, oldval;       Lisp_Object value, oldval;
1576  {  {
1577    unsigned long pixel;    unsigned long pixel;
1578      
1579    if (STRINGP (value))    if (STRINGP (value))
1580      pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));      pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));
1581    else    else
# Line 2290  x_set_scroll_bar_foreground (f, value, o Line 1583  x_set_scroll_bar_foreground (f, value, o
1583    
1584    if (f->output_data.x->scroll_bar_foreground_pixel != -1)    if (f->output_data.x->scroll_bar_foreground_pixel != -1)
1585      unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);      unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);
1586      
1587    f->output_data.x->scroll_bar_foreground_pixel = pixel;    f->output_data.x->scroll_bar_foreground_pixel = pixel;
1588    if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))    if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
1589      {      {
# Line 2322  x_set_scroll_bar_background (f, value, o Line 1615  x_set_scroll_bar_background (f, value, o
1615      pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));      pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));
1616    else    else
1617      pixel = -1;      pixel = -1;
1618      
1619    if (f->output_data.x->scroll_bar_background_pixel != -1)    if (f->output_data.x->scroll_bar_background_pixel != -1)
1620      unload_color (f, f->output_data.x->scroll_bar_background_pixel);      unload_color (f, f->output_data.x->scroll_bar_background_pixel);
1621      
1622  #ifdef USE_TOOLKIT_SCROLL_BARS  #ifdef USE_TOOLKIT_SCROLL_BARS
1623    /* Scrollbar shadow colors.  */    /* Scrollbar shadow colors.  */
1624    if (f->output_data.x->scroll_bar_top_shadow_pixel != -1)    if (f->output_data.x->scroll_bar_top_shadow_pixel != -1)
# Line 2348  x_set_scroll_bar_background (f, value, o Line 1641  x_set_scroll_bar_background (f, value, o
1641          (*condemn_scroll_bars_hook) (f);          (*condemn_scroll_bars_hook) (f);
1642        if (judge_scroll_bars_hook)        if (judge_scroll_bars_hook)
1643          (*judge_scroll_bars_hook) (f);          (*judge_scroll_bars_hook) (f);
1644          
1645        update_face_from_frame_parameter (f, Qscroll_bar_background, value);        update_face_from_frame_parameter (f, Qscroll_bar_background, value);
1646        redraw_frame (f);        redraw_frame (f);
1647      }      }
# Line 2380  x_encode_text (string, coding_system, se Line 1673  x_encode_text (string, coding_system, se
1673       int *text_bytes, *stringp;       int *text_bytes, *stringp;
1674       int selectionp;       int selectionp;
1675  {  {
1676    unsigned char *str = XSTRING (string)->data;    unsigned char *str = SDATA (string);
1677    int chars = XSTRING (string)->size;    int chars = SCHARS (string);
1678    int bytes = STRING_BYTES (XSTRING (string));    int bytes = SBYTES (string);
1679    int charset_info;    int charset_info;
1680    int bufsize;    int bufsize;
1681    unsigned char *buf;    unsigned char *buf;
# Line 2404  x_encode_text (string, coding_system, se Line 1697  x_encode_text (string, coding_system, se
1697        && !NILP (Ffboundp (coding.pre_write_conversion)))        && !NILP (Ffboundp (coding.pre_write_conversion)))
1698      {      {
1699        string = run_pre_post_conversion_on_str (string, &coding, 1);        string = run_pre_post_conversion_on_str (string, &coding, 1);
1700        str = XSTRING (string)->data;        str = SDATA (string);
1701        chars = XSTRING (string)->size;        chars = SCHARS (string);
1702        bytes = STRING_BYTES (XSTRING (string));        bytes = SBYTES (string);
1703      }      }
1704    coding.src_multibyte = 1;    coding.src_multibyte = 1;
1705    coding.dst_multibyte = 0;    coding.dst_multibyte = 0;
# Line 2443  x_set_name (f, name, explicit) Line 1736  x_set_name (f, name, explicit)
1736       Lisp_Object name;       Lisp_Object name;
1737       int explicit;       int explicit;
1738  {  {
1739    /* Make sure that requests from lisp code override requests from    /* Make sure that requests from lisp code override requests from
1740       Emacs redisplay code.  */       Emacs redisplay code.  */
1741    if (explicit)    if (explicit)
1742      {      {
# Line 2463  x_set_name (f, name, explicit) Line 1756  x_set_name (f, name, explicit)
1756        /* Check for no change needed in this very common case        /* Check for no change needed in this very common case
1757           before we do any consing.  */           before we do any consing.  */
1758        if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,        if (!strcmp (FRAME_X_DISPLAY_INFO (f)->x_id_name,
1759                     XSTRING (f->name)->data))                     SDATA (f->name)))
1760          return;          return;
1761        name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);        name = build_string (FRAME_X_DISPLAY_INFO (f)->x_id_name);
1762      }      }
# Line 2490  x_set_name (f, name, explicit) Line 1783  x_set_name (f, name, explicit)
1783          int bytes, stringp;          int bytes, stringp;
1784          Lisp_Object coding_system;          Lisp_Object coding_system;
1785    
1786          coding_system = Vlocale_coding_system;          /* Note: Encoding strategy
1787          if (NILP (coding_system))  
1788            coding_system = Qcompound_text;             We encode NAME by compound-text and use "COMPOUND-TEXT" in
1789               text.encoding.  But, there are non-internationalized window
1790               managers which don't support that encoding.  So, if NAME
1791               contains only ASCII and 8859-1 characters, encode it by
1792               iso-latin-1, and use "STRING" in text.encoding hoping that
1793               such window manager at least analize this format correctly,
1794               i.e. treat 8-bit bytes as 8859-1 characters.
1795    
1796               We may also be able to use "UTF8_STRING" in text.encoding
1797               in the feature which can encode all Unicode characters.
1798               But, for the moment, there's no way to know that the
1799               current window manager supports it or not.  */
1800            coding_system = Qcompound_text;
1801          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1802          text.encoding = (stringp ? XA_STRING          text.encoding = (stringp ? XA_STRING
1803                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
# Line 2505  x_set_name (f, name, explicit) Line 1810  x_set_name (f, name, explicit)
1810            }            }
1811          else          else
1812            {            {
1813                /* See the above comment "Note: Encoding strategy".  */
1814              icon.value = x_encode_text (f->icon_name, coding_system, 0,              icon.value = x_encode_text (f->icon_name, coding_system, 0,
1815                                          &bytes, &stringp);                                          &bytes, &stringp);
1816              icon.encoding = (stringp ? XA_STRING              icon.encoding = (stringp ? XA_STRING
# Line 2512  x_set_name (f, name, explicit) Line 1818  x_set_name (f, name, explicit)
1818              icon.format = 8;              icon.format = 8;
1819              icon.nitems = bytes;              icon.nitems = bytes;
1820            }            }
1821  #ifdef USE_X_TOOLKIT  #ifdef USE_GTK
1822          XSetWMName (FRAME_X_DISPLAY (f),          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1823                      XtWindow (f->output_data.x->widget), &text);                                SDATA (name));
1824          XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget),  #else /* not USE_GTK */
1825                          &icon);          XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1826  #else /* not USE_X_TOOLKIT */  #endif /* not USE_GTK */
1827          XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);  
1828          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon);          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &icon);
1829  #endif /* not USE_X_TOOLKIT */  
1830          if (!NILP (f->icon_name)          if (!NILP (f->icon_name)
1831              && icon.value != XSTRING (f->icon_name)->data)              && icon.value != (unsigned char *) SDATA (f->icon_name))
1832            xfree (icon.value);            xfree (icon.value);
1833          if (text.value != XSTRING (name)->data)          if (text.value != (unsigned char *) SDATA (name))
1834            xfree (text.value);            xfree (text.value);
1835        }        }
1836  #else /* not HAVE_X11R4 */  #else /* not HAVE_X11R4 */
1837        XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1838                      XSTRING (name)->data);                      SDATA (name));
1839        XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1840                    XSTRING (name)->data);                    SDATA (name));
1841  #endif /* not HAVE_X11R4 */  #endif /* not HAVE_X11R4 */
1842        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1843      }      }
# Line 2597  x_set_title (f, name, old_name) Line 1903  x_set_title (f, name, old_name)
1903          int bytes, stringp;          int bytes, stringp;
1904          Lisp_Object coding_system;          Lisp_Object coding_system;
1905    
1906          coding_system = Vlocale_coding_system;          coding_system = Qcompound_text;
1907          if (NILP (coding_system))          /* See the comment "Note: Encoding strategy" in x_set_name.  */
           coding_system = Qcompound_text;  
1908          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);          text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp);
1909          text.encoding = (stringp ? XA_STRING          text.encoding = (stringp ? XA_STRING
1910                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);                           : FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT);
# Line 2612  x_set_title (f, name, old_name) Line 1917  x_set_title (f, name, old_name)
1917            }            }
1918          else          else
1919            {            {
1920                /* See the comment "Note: Encoding strategy" in x_set_name.  */
1921              icon.value = x_encode_text (f->icon_name, coding_system, 0,              icon.value = x_encode_text (f->icon_name, coding_system, 0,
1922                                          &bytes, &stringp);                                          &bytes, &stringp);
1923              icon.encoding = (stringp ? XA_STRING              icon.encoding = (stringp ? XA_STRING
# Line 2619  x_set_title (f, name, old_name) Line 1925  x_set_title (f, name, old_name)
1925              icon.format = 8;              icon.format = 8;
1926              icon.nitems = bytes;              icon.nitems = bytes;
1927            }            }
1928  #ifdef USE_X_TOOLKIT  
1929          XSetWMName (FRAME_X_DISPLAY (f),  #ifdef USE_GTK
1930                      XtWindow (f->output_data.x->widget), &text);          gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
1931          XSetWMIconName (FRAME_X_DISPLAY (f), XtWindow (f->output_data.x->widget),                                SDATA (name));
1932                          &icon);  #else /* not USE_GTK */
1933  #else /* not USE_X_TOOLKIT */          XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
1934          XSetWMName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &text);  #endif /* not USE_GTK */
1935          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &icon);  
1936  #endif /* not USE_X_TOOLKIT */          XSetWMIconName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
1937                            &icon);
1938    
1939          if (!NILP (f->icon_name)          if (!NILP (f->icon_name)
1940              && icon.value != XSTRING (f->icon_name)->data)              && icon.value != (unsigned char *) SDATA (f->icon_name))
1941            xfree (icon.value);            xfree (icon.value);
1942          if (text.value != XSTRING (name)->data)          if (text.value != (unsigned char *) SDATA (name))
1943            xfree (text.value);            xfree (text.value);
1944        }        }
1945  #else /* not HAVE_X11R4 */  #else /* not HAVE_X11R4 */
1946        XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        XSetIconName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1947                      XSTRING (name)->data);                      SDATA (name));
1948        XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        XStoreName (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
1949                    XSTRING (name)->data);                    SDATA (name));
1950  #endif /* not HAVE_X11R4 */  #endif /* not HAVE_X11R4 */
1951        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1952      }      }
1953  }  }
   
 void  
 x_set_autoraise (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   f->auto_raise = !EQ (Qnil, arg);  
 }  
   
 void  
 x_set_autolower (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   f->auto_lower = !EQ (Qnil, arg);  
 }  
   
 void  
 x_set_unsplittable (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   f->no_split = !NILP (arg);  
 }  
   
 void  
 x_set_vertical_scroll_bars (f, arg, oldval)  
      struct frame *f;  
      Lisp_Object arg, oldval;  
 {  
   if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))  
       || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))  
       || (NILP (arg) && FRAME_HAS_VERTICAL_SCROLL_BARS (f))  
       || (!NILP (arg) && ! FRAME_HAS_VERTICAL_SCROLL_BARS (f)))  
     {  
       FRAME_VERTICAL_SCROLL_BAR_TYPE (f)  
         = (NILP (arg)  
            ? vertical_scroll_bar_none  
            : EQ (Qright, arg)  
            ? vertical_scroll_bar_right  
            : vertical_scroll_bar_left);  
   
       /* We set this parameter before creating the X window for the  
          frame, so we can get the geometry right from the start.  
          However, if the window hasn't been created yet, we shouldn't  
          call x_set_window_size.  */  
       if (FRAME_X_WINDOW (f))  
         x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));  
       do_pending_window_change (0);  
     }  
 }  
1954    
1955  void  void
1956  x_set_scroll_bar_width (f, arg, oldval)  x_set_scroll_bar_default_width (f)
1957       struct frame *f;       struct frame *f;
      Lisp_Object arg, oldval;  
1958  {  {
1959    int wid = FONT_WIDTH (f->output_data.x->font);    int wid = FONT_WIDTH (f->output_data.x->font);
1960    
   if (NILP (arg))  
     {  
1961  #ifdef USE_TOOLKIT_SCROLL_BARS  #ifdef USE_TOOLKIT_SCROLL_BARS
1962        /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */    /* A minimum width of 14 doesn't look good for toolkit scroll bars.  */
1963        int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;    int width = 16 + 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM;
1964        FRAME_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;    FRAME_SCROLL_BAR_COLS (f) = (width + wid - 1) / wid;
1965        FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;    FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;
1966  #else  #else
1967        /* Make the actual width at least 14 pixels and a multiple of a    /* Make the actual width at least 14 pixels and a multiple of a
1968           character width.  */       character width.  */
1969        FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;    FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
1970          
1971        /* Use all of that space (aside from required margins) for the    /* Use all of that space (aside from required margins) for the
1972           scroll bar.  */       scroll bar.  */
1973        FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;    FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
1974  #endif  #endif
   
       if (FRAME_X_WINDOW (f))  
         x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));  
       do_pending_window_change (0);  
     }  
   else if (INTEGERP (arg) && XINT (arg) > 0  
            && XFASTINT (arg) != FRAME_SCROLL_BAR_PIXEL_WIDTH (f))  
     {  
       if (XFASTINT (arg) <= 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM)  
         XSETINT (arg, 2 * VERTICAL_SCROLL_BAR_WIDTH_TRIM + 1);  
   
       FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = XFASTINT (arg);  
       FRAME_SCROLL_BAR_COLS (f) = (XFASTINT (arg) + wid-1) / wid;  
       if (FRAME_X_WINDOW (f))  
         x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));  
     }  
   
   change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);  
   XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;  
   XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;  
1975  }  }
1976    
   
1977    
 /* Subroutines of creating an X frame.  */  
   
 /* Make sure that Vx_resource_name is set to a reasonable value.  
    Fix it up, or set it to `emacs' if it is too hopeless.  */  
   
 static void  
 validate_x_resource_name ()  
 {  
   int len = 0;  
   /* Number of valid characters in the resource name.  */  
   int good_count = 0;  
   /* Number of invalid characters in the resource name.  */  
   int bad_count = 0;  
   Lisp_Object new;  
   int i;  
   
   if (!STRINGP (Vx_resource_class))  
     Vx_resource_class = build_string (EMACS_CLASS);  
   
   if (STRINGP (Vx_resource_name))  
     {  
       unsigned char *p = XSTRING (Vx_resource_name)->data;  
       int i;  
   
       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.  */  
       for (i = 0; i < len; i++)  
         {  
           int c = p[i];  
           if (! ((c >= 'a' && c <= 'z')  
                  || (c >= 'A' && c <= 'Z')  
                  || (c >= '0' && c <= '9')  
                  || c == '-' || c == '_'))  
             bad_count++;  
           else  
             good_count++;  
         }  
     }  
   else  
     /* Not a string => completely invalid.  */  
     bad_count = 5, good_count = 0;  
   
   /* If name is valid already, return.  */  
   if (bad_count == 0)  
     return;  
   
   /* If name is entirely invalid, or nearly so, use `emacs'.  */  
   if (good_count == 0  
       || (good_count == 1 && bad_count > 0))  
     {  
       Vx_resource_name = build_string ("emacs");  
       return;  
     }  
   
   /* Name is partly valid.  Copy it and replace the invalid characters  
      with underscores.  */  
   
   Vx_resource_name = new = Fcopy_sequence (Vx_resource_name);  
   
   for (i = 0; i < len; i++)  
     {  
       int c = XSTRING (new)->data[i];  
       if (! ((c >= 'a' && c <= 'z')  
              || (c >= 'A' && c <= 'Z')  
              || (c >= '0' && c <= '9')  
              || c == '-' || c == '_'))  
         XSTRING (new)->data[i] = '_';  
     }  
 }  
   
   
 extern char *x_get_string_resource ();  
   
 DEFUN ("x-get-resource", Fx_get_resource, Sx_get_resource, 2, 4, 0,  
        doc: /* Return the value of ATTRIBUTE, of class CLASS, from the X defaults database.  
 This uses `INSTANCE.ATTRIBUTE' as the key and `Emacs.CLASS' as the  
 class, where INSTANCE is the name under which Emacs was invoked, or  
 the name specified by the `-name' or `-rn' command-line arguments.  
   
 The optional arguments COMPONENT and SUBCLASS add to the key and the  
 class, respectively.  You must specify both of them or neither.  
 If you specify them, the key is `INSTANCE.COMPONENT.ATTRIBUTE'  
 and the class is `Emacs.CLASS.SUBCLASS'.  */)  
      (attribute, class, component, subclass)  
      Lisp_Object attribute, class, component, subclass;  
 {  
   register char *value;  
   char *name_key;  
   char *class_key;  
   
   check_x ();  
   
   CHECK_STRING (attribute);  
   CHECK_STRING (class);  
   
   if (!NILP (component))  
     CHECK_STRING (component);  
   if (!NILP (subclass))  
     CHECK_STRING (subclass);  
   if (NILP (component) != NILP (subclass))  
     error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");  
   
   validate_x_resource_name ();  
   
   /* 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 (STRING_BYTES (XSTRING (Vx_resource_name))  
                               + (STRINGP (component)  
                                  ? STRING_BYTES (XSTRING (component)) : 0)  
                               + STRING_BYTES (XSTRING (attribute))  
                               + 3);  
   
   class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))  
                                + STRING_BYTES (XSTRING (class))  
                                + (STRINGP (subclass)  
                                   ? STRING_BYTES (XSTRING (subclass)) : 0)  
                                + 3);  
   
   /* Start with emacs.FRAMENAME for the name (the specific one)  
      and with `Emacs' for the class key (the general one).  */  
   strcpy (name_key, XSTRING (Vx_resource_name)->data);  
   strcpy (class_key, XSTRING (Vx_resource_class)->data);  
   
   strcat (class_key, ".");  
   strcat (class_key, XSTRING (class)->data);  
   
   if (!NILP (component))  
     {  
       strcat (class_key, ".");  
       strcat (class_key, XSTRING (subclass)->data);  
   
       strcat (name_key, ".");  
       strcat (name_key, XSTRING (component)->data);  
     }  
   
   strcat (name_key, ".");  
   strcat (name_key, XSTRING (attribute)->data);  
   
   value = x_get_string_resource (check_x_display_info (Qnil)->xrdb,  
                                  name_key, class_key);  
   
   if (value != (char *) 0)  
     return build_string (value);  
   else  
     return Qnil;  
 }  
   
 /* Get an X resource, like Fx_get_resource, but for display DPYINFO.  */  
   
 Lisp_Object  
 display_x_get_resource (dpyinfo, attribute, class, component, subclass)  
      struct x_display_info *dpyinfo;  
      Lisp_Object attribute, class, component, subclass;  
 {  
   register char *value;  
   char *name_key;  
   char *class_key;  
   
   CHECK_STRING (attribute);  
   CHECK_STRING (class);  
   
   if (!NILP (component))  
     CHECK_STRING (component);  
   if (!NILP (subclass))  
     CHECK_STRING (subclass);  
   if (NILP (component) != NILP (subclass))  
     error ("x-get-resource: must specify both COMPONENT and SUBCLASS or neither");  
   
   validate_x_resource_name ();  
   
   /* 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 (STRING_BYTES (XSTRING (Vx_resource_name))  
                               + (STRINGP (component)  
                                  ? STRING_BYTES (XSTRING (component)) : 0)  
                               + STRING_BYTES (XSTRING (attribute))  
                               + 3);  
   
   class_key = (char *) alloca (STRING_BYTES (XSTRING (Vx_resource_class))  
                                + STRING_BYTES (XSTRING (class))  
                                + (STRINGP (subclass)  
                                   ? STRING_BYTES (XSTRING (subclass)) : 0)  
                                + 3);  
   
   /* Start with emacs.FRAMENAME for the name (the specific one)  
      and with `Emacs' for the class key (the general one).  */  
   strcpy (name_key, XSTRING (Vx_resource_name)->data);  
   strcpy (class_key, XSTRING (Vx_resource_class)->data);  
   
   strcat (class_key, ".");  
   strcat (class_key, XSTRING (class)->data);  
   
   if (!NILP (component))  
     {  
       strcat (class_key, ".");  
       strcat (class_key, XSTRING (subclass)->data);  
   
       strcat (name_key, ".");  
       strcat (name_key, XSTRING (component)->data);  
     }  
   
   strcat (name_key, ".");  
   strcat (name_key, XSTRING (attribute)->data);  
   
   value = x_get_string_resource (dpyinfo->xrdb, name_key, class_key);  
   
   if (value != (char *) 0)  
     return build_string (value);  
   else  
     return Qnil;  
 }  
   
 /* Used when C code wants a resource value.  */  
   
 char *  
 x_get_resource_string (attribute, class)  
      char *attribute, *class;  
 {  
   char *name_key;  
   char *class_key;  
   struct frame *sf = SELECTED_FRAME ();  
   
   /* Allocate space for the components, the dots which separate them,  
      and the final '\0'.  */  
   name_key = (char *) alloca (STRING_BYTES (XSTRING (Vinvocation_name))  
                               + strlen (attribute) + 2);  
   class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)  
                                + strlen (class) + 2);  
   
   sprintf (name_key, "%s.%s",  
            XSTRING (Vinvocation_name)->data,  
            attribute);  
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);  
   
   return x_get_string_resource (FRAME_X_DISPLAY_INFO (sf)->xrdb,  
                                 name_key, class_key);  
 }  
   
 /* Types we might convert a resource string into.  */  
 enum resource_types  
 {  
   RES_TYPE_NUMBER,  
   RES_TYPE_FLOAT,  
   RES_TYPE_BOOLEAN,  
   RES_TYPE_STRING,  
   RES_TYPE_SYMBOL  
 };  
   
 /* Return the value of parameter PARAM.  
   
    First search ALIST, then Vdefault_frame_alist, then the X defaults  
    database, using ATTRIBUTE as the attribute name and CLASS as its class.  
   
    Convert the resource to the type specified by desired_type.  
   
    If no default is specified, return Qunbound.  If you call  
    x_get_arg, make sure you deal with Qunbound in a reasonable way,  
    and don't let it get stored in any Lisp-visible variables!  */  
   
 static Lisp_Object  
 x_get_arg (dpyinfo, alist, param, attribute, class, type)  
      struct x_display_info *dpyinfo;  
      Lisp_Object alist, param;  
      char *attribute;  
      char *class;  
      enum resource_types type;  
 {  
   register Lisp_Object tem;  
   
   tem = Fassq (param, alist);  
   if (EQ (tem, Qnil))  
     tem = Fassq (param, Vdefault_frame_alist);  
   if (EQ (tem, Qnil))  
     {  
   
       if (attribute)  
         {  
           tem = display_x_get_resource (dpyinfo,  
                                         build_string (attribute),  
                                         build_string (class),  
                                         Qnil, Qnil);  
   
           if (NILP (tem))  
             return Qunbound;  
   
           switch (type)  
             {  
             case RES_TYPE_NUMBER:  
               return make_number (atoi (XSTRING (tem)->data));  
   
             case RES_TYPE_FLOAT:  
               return make_float (atof (XSTRING (tem)->data));  
   
             case RES_TYPE_BOOLEAN:  
               tem = Fdowncase (tem);  
               if (!strcmp (XSTRING (tem)->data, "on")  
                   || !strcmp (XSTRING (tem)->data, "true"))  
                 return Qt;  
               else  
                 return Qnil;  
   
             case RES_TYPE_STRING:  
               return tem;  
   
             case RES_TYPE_SYMBOL:  
               /* As a special case, we map the values `true' and `on'  
                  to Qt, and `false' and `off' to Qnil.  */  
               {  
                 Lisp_Object lower;  
                 lower = Fdowncase (tem);  
                 if (!strcmp (XSTRING (lower)->data, "on")  
                     || !strcmp (XSTRING (lower)->data, "true"))  
                   return Qt;  
                 else if (!strcmp (XSTRING (lower)->data, "off")  
                       || !strcmp (XSTRING (lower)->data, "false"))  
                   return Qnil;  
                 else  
                   return Fintern (tem, Qnil);  
               }  
   
             default:  
               abort ();  
             }  
         }  
       else  
         return Qunbound;  
     }  
   return Fcdr (tem);  
 }  
   
 /* Like x_get_arg, but also record the value in f->param_alist.  */  
   
 static Lisp_Object  
 x_get_and_record_arg (f, alist, param, attribute, class, type)  
      struct frame *f;  
      Lisp_Object alist, param;  
      char *attribute;  
      char *class;  
      enum resource_types type;  
 {  
   Lisp_Object value;  
   
   value = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, param,  
                      attribute, class, type);  
   if (! NILP (value))  
     store_frame_param (f, param, value);  
   
   return value;  
 }  
   
 /* Record in frame F the specified or default value according to ALIST  
    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.  */  
   
 static Lisp_Object  
 x_default_parameter (f, alist, prop, deflt, xprop, xclass, type)  
      struct frame *f;  
      Lisp_Object alist;  
      Lisp_Object prop;  
      Lisp_Object deflt;  
      char *xprop;  
      char *xclass;  
      enum resource_types type;  
 {  
   Lisp_Object tem;  
   
   tem = x_get_arg (FRAME_X_DISPLAY_INFO (f), alist, prop, xprop, xclass, type);  
   if (EQ (tem, Qunbound))  
     tem = deflt;  
   x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));  
   return tem;  
 }  
   
   
1978  /* Record in frame F the specified or default value according to ALIST  /* Record in frame F the specified or default value according to ALIST
1979     of the parameter named PROP (a Lisp symbol).  If no value is     of the parameter named PROP (a Lisp symbol).  If no value is
1980     specified for PROP, look for an X default for XPROP on the frame     specified for PROP, look for an X default for XPROP on the frame
# Line 3161  x_default_scroll_bar_color_parameter (f, Line 2016  x_default_scroll_bar_color_parameter (f,
2016               specified.  */               specified.  */
2017            tem = Qnil;            tem = Qnil;
2018          }          }
2019          
2020  #else /* not USE_TOOLKIT_SCROLL_BARS */  #else /* not USE_TOOLKIT_SCROLL_BARS */
2021          
2022        tem = Qnil;        tem = Qnil;
2023          
2024  #endif /* not USE_TOOLKIT_SCROLL_BARS */  #endif /* not USE_TOOLKIT_SCROLL_BARS */
2025      }      }
2026    
# Line 3174  x_default_scroll_bar_color_parameter (f, Line 2029  x_default_scroll_bar_color_parameter (f,
2029  }  }
2030    
2031    
   
 DEFUN ("x-parse-geometry", Fx_parse_geometry, Sx_parse_geometry, 1, 1, 0,  
        doc: /* Parse an X-style geometry string STRING.  
 Returns an alist of the form ((top . TOP), (left . LEFT) ... ).  
 The properties returned may include `top', `left', `height', and `width'.  
 The value of `left' or `top' may be an integer,  
 or a list (+ N) meaning N pixels relative to top/left corner,  
 or a list (- N) meaning -N pixels relative to bottom/right corner.  */)  
      (string)  
      Lisp_Object string;  
 {  
   int geometry, x, y;  
   unsigned int width, height;  
   Lisp_Object result;  
   
   CHECK_STRING (string);  
   
   geometry = XParseGeometry ((char *) XSTRING (string)->data,  
                              &x, &y, &width, &height);  
   
 #if 0  
   if (!!(geometry & XValue) != !!(geometry & YValue))  
     error ("Must specify both x and y position, or neither");  
 #endif  
   
   result = Qnil;  
   if (geometry & XValue)  
     {  
       Lisp_Object element;  
   
       if (x >= 0 && (geometry & XNegative))  
         element = Fcons (Qleft, Fcons (Qminus, Fcons (make_number (-x), Qnil)));  
       else if (x < 0 && ! (geometry & XNegative))  
         element = Fcons (Qleft, Fcons (Qplus, Fcons (make_number (x), Qnil)));  
       else  
         element = Fcons (Qleft, make_number (x));  
       result = Fcons (element, result);  
     }  
   
   if (geometry & YValue)  
     {  
       Lisp_Object element;  
   
       if (y >= 0 && (geometry & YNegative))  
         element = Fcons (Qtop, Fcons (Qminus, Fcons (make_number (-y), Qnil)));  
       else if (y < 0 && ! (geometry & YNegative))  
         element = Fcons (Qtop, Fcons (Qplus, Fcons (make_number (y), Qnil)));  
       else  
         element = Fcons (Qtop, make_number (y));  
       result = Fcons (element, result);  
     }  
   
   if (geometry & WidthValue)  
     result = Fcons (Fcons (Qwidth, make_number (width)), result);  
   if (geometry & HeightValue)  
     result = Fcons (Fcons (Qheight, make_number (height)), result);  
   
   return result;  
 }  
   
 /* Calculate the desired size and position of this window,  
    and return the flags saying which aspects were specified.  
   
    This function does not make the coordinates positive.  */  
   
 #define DEFAULT_ROWS 40  
 #define DEFAULT_COLS 80  
   
 static int  
 x_figure_window_size (f, parms)  
      struct frame *f;  
      Lisp_Object parms;  
 {  
   register Lisp_Object tem0, tem1, tem2;  
   long window_prompting = 0;  
   struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);  
   
   /* Default values if we fall through.  
      Actually, if that happens we should get  
      window manager prompting.  */  
   SET_FRAME_WIDTH (f, DEFAULT_COLS);  
   f->height = DEFAULT_ROWS;  
   /* Window managers expect that if program-specified  
      positions are not (0,0), they're intentional, not defaults.  */  
   f->output_data.x->top_pos = 0;  
   f->output_data.x->left_pos = 0;  
   
   tem0 = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);  
   tem1 = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);  
   tem2 = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, RES_TYPE_NUMBER);  
   if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))  
     {  
       if (!EQ (tem0, Qunbound))  
         {  
           CHECK_NUMBER (tem0);  
           f->height = XINT (tem0);  
         }  
       if (!EQ (tem1, Qunbound))  
         {  
           CHECK_NUMBER (tem1);  
           SET_FRAME_WIDTH (f, XINT (tem1));  
         }  
       if (!NILP (tem2) && !EQ (tem2, Qunbound))  
         window_prompting |= USSize;  
       else  
         window_prompting |= PSize;  
     }  
   
   f->output_data.x->vertical_scroll_bar_extra  
     = (!FRAME_HAS_VERTICAL_SCROLL_BARS (f)  
        ? 0  
        : (FRAME_SCROLL_BAR_COLS (f) * FONT_WIDTH (f->output_data.x->font)));  
   
   x_compute_fringe_widths (f, 0);  
   
   f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);  
   f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);  
   
   tem0 = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);  
   tem1 = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);  
   tem2 = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, RES_TYPE_NUMBER);  
   if (! EQ (tem0, Qunbound) || ! EQ (tem1, Qunbound))  
     {  
       if (EQ (tem0, Qminus))  
         {  
           f->output_data.x->top_pos = 0;  
           window_prompting |= YNegative;  
         }  
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qminus)  
                && CONSP (XCDR (tem0))  
                && INTEGERP (XCAR (XCDR (tem0))))  
         {  
           f->output_data.x->top_pos = - XINT (XCAR (XCDR (tem0)));  
           window_prompting |= YNegative;  
         }  
       else if (CONSP (tem0) && EQ (XCAR (tem0), Qplus)  
                && CONSP (XCDR (tem0))  
                && INTEGERP (XCAR (XCDR (tem0))))  
         {  
           f->output_data.x->top_pos = XINT (XCAR (XCDR (tem0)));  
         }  
       else if (EQ (tem0, Qunbound))  
         f->output_data.x->top_pos = 0;  
       else  
         {  
           CHECK_NUMBER (tem0);  
           f->output_data.x->top_pos = XINT (tem0);  
           if (f->output_data.x->top_pos < 0)  
             window_prompting |= YNegative;  
         }  
   
       if (EQ (tem1, Qminus))  
         {  
           f->output_data.x->left_pos = 0;  
           window_prompting |= XNegative;  
         }  
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qminus)  
                && CONSP (XCDR (tem1))  
                && INTEGERP (XCAR (XCDR (tem1))))  
         {  
           f->output_data.x->left_pos = - XINT (XCAR (XCDR (tem1)));  
           window_prompting |= XNegative;  
         }  
       else if (CONSP (tem1) && EQ (XCAR (tem1), Qplus)  
                && CONSP (XCDR (tem1))  
                && INTEGERP (XCAR (XCDR (tem1))))  
         {  
           f->output_data.x->left_pos = XINT (XCAR (XCDR (tem1)));  
         }  
       else if (EQ (tem1, Qunbound))  
         f->output_data.x->left_pos = 0;  
       else  
         {  
           CHECK_NUMBER (tem1);  
           f->output_data.x->left_pos = XINT (tem1);  
           if (f->output_data.x->left_pos < 0)  
             window_prompting |= XNegative;  
         }  
   
       if (!NILP (tem2) && ! EQ (tem2, Qunbound))  
         window_prompting |= USPosition;  
       else  
         window_prompting |= PPosition;  
     }  
   
   if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE)  
     {  
       int left, top;  
       int width, height;  
         
       /* It takes both for some WM:s to place it where we want */  
       window_prompting = USPosition | PPosition;  
       x_fullscreen_adjust (f, &width, &height, &top, &left);  
       f->width = width;  
       f->height = height;  
       f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);  
       f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);  
       f->output_data.x->left_pos = left;  
       f->output_data.x->top_pos = top;  
     }  
     
   return window_prompting;  
 }  
2032    
2033  #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)  #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
2034    
# Line 3497  xic_create_xfontset (f, base_fontname) Line 2149  xic_create_xfontset (f, base_fontname)
2149    char **missing_list;    char **missing_list;
2150    int missing_count;    int missing_count;
2151    char *def_string;    char *def_string;
2152      
2153    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
2154                          base_fontname, &missing_list,                          base_fontname, &missing_list,
2155                          &missing_count, &def_string);                          &missing_count, &def_string);
2156    if (missing_list)    if (missing_list)
2157      XFreeStringList (missing_list);      XFreeStringList (missing_list);
2158      
2159    /* No need to free def_string. */    /* No need to free def_string. */
2160    return xfs;    return xfs;
2161  }  }
# Line 3543  create_frame_xic (f) Line 2195  create_frame_xic (f)
2195    
2196    if (FRAME_XIC (f))    if (FRAME_XIC (f))
2197      return;      return;
2198      
2199    xim = FRAME_X_XIM (f);    xim = FRAME_X_XIM (f);
2200    if (xim)    if (xim)
2201      {      {
# Line 3564  create_frame_xic (f) Line 2216  create_frame_xic (f)
2216          {          {
2217            /* Determine the base fontname from the ASCII font name of            /* Determine the base fontname from the ASCII font name of
2218               FONTSET.  */               FONTSET.  */
2219            char *ascii_font = (char *) XSTRING (fontset_ascii (fontset))->data;            char *ascii_font = (char *) SDATA (fontset_ascii (fontset));
2220            char *p = ascii_font;            char *p = ascii_font;
2221            int i;            int i;
2222    
# Line 3641  create_frame_xic (f) Line 2293  create_frame_xic (f)
2293        XFree (preedit_attr);        XFree (preedit_attr);
2294        XFree (status_attr);        XFree (status_attr);
2295      }      }
2296      
2297    FRAME_XIC (f) = xic;    FRAME_XIC (f) = xic;
2298    FRAME_XIC_STYLE (f) = xic_style;    FRAME_XIC_STYLE (f) = xic_style;
2299    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
# Line 3656  free_frame_xic (f) Line 2308  free_frame_xic (f)
2308  {  {
2309    if (FRAME_XIC (f) == NULL)    if (FRAME_XIC (f) == NULL)
2310      return;      return;
2311      
2312    XDestroyIC (FRAME_XIC (f));    XDestroyIC (FRAME_XIC (f));
2313    if (FRAME_XIC_FONTSET (f))    if (FRAME_XIC_FONTSET (f))
2314      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
# Line 3677  xic_set_preeditarea (w, x, y) Line 2329  xic_set_preeditarea (w, x, y)
2329    struct frame *f = XFRAME (w->frame);    struct frame *f = XFRAME (w->frame);
2330    XVaNestedList attr;    XVaNestedList attr;
2331    XPoint spot;    XPoint spot;
2332          
2333    spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);    spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);
2334    spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f));    spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f));
2335    attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);    attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
# Line 3703  xic_set_statusarea (f) Line 2355  xic_set_statusarea (f)
2355    attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);    attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);
2356    XSetICValues (xic, XNStatusAttributes, attr, NULL);    XSetICValues (xic, XNStatusAttributes, attr, NULL);
2357    XFree (attr);    XFree (attr);
2358      
2359    attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);    attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);
2360    XGetICValues (xic, XNStatusAttributes, attr, NULL);    XGetICValues (xic, XNStatusAttributes, attr, NULL);
2361    XFree (attr);    XFree (attr);
# Line 3719  xic_set_statusarea (f) Line 2371  xic_set_statusarea (f)
2371    area.height = needed->height;    area.height = needed->height;
2372    area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);    area.x = PIXEL_WIDTH (f) - area.width - FRAME_INTERNAL_BORDER_WIDTH (f);
2373    area.y = (PIXEL_HEIGHT (f) - area.height    area.y = (PIXEL_HEIGHT (f) - area.height
2374              - FRAME_MENUBAR_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f));              - FRAME_MENUBAR_HEIGHT (f)
2375                - FRAME_TOOLBAR_HEIGHT (f)
2376                - FRAME_INTERNAL_BORDER_WIDTH (f));
2377    XFree (needed);    XFree (needed);
2378    
2379    attr = XVaCreateNestedList (0, XNArea, &area, NULL);    attr = XVaCreateNestedList (0, XNArea, &area, NULL);
# Line 3747  xic_set_xfontset (f, base_fontname) Line 2401  xic_set_xfontset (f, base_fontname)
2401    if (FRAME_XIC_STYLE (f) & XIMStatusArea)    if (FRAME_XIC_STYLE (f) & XIMStatusArea)
2402      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
2403    XFree (attr);    XFree (attr);
2404      
2405    if (FRAME_XIC_FONTSET (f))    if (FRAME_XIC_FONTSET (f))
2406      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
2407    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
# Line 3783  x_window (f, window_prompting, minibuffe Line 2437  x_window (f, window_prompting, minibuffe
2437       for the window manager, so GC relocation won't bother it.       for the window manager, so GC relocation won't bother it.
2438    
2439       Elsewhere we specify the window name for the window manager.  */       Elsewhere we specify the window name for the window manager.  */
2440        
2441    {    {
2442      char *str = (char *) XSTRING (Vx_resource_name)->data;      char *str = (char *) SDATA (Vx_resource_name);
2443      f->namebuf = (char *) xmalloc (strlen (str) + 1);      f->namebuf = (char *) xmalloc (strlen (str) + 1);
2444      strcpy (f->namebuf, str);      strcpy (f->namebuf, str);
2445    }    }
# Line 3820  x_window (f, window_prompting, minibuffe Line 2474  x_window (f, window_prompting, minibuffe
2474    XtSetValues (pane_widget, al, ac);    XtSetValues (pane_widget, al, ac);
2475    f->output_data.x->column_widget = pane_widget;    f->output_data.x->column_widget = pane_widget;
2476    
2477    /* mappedWhenManaged to false tells to the paned window to not map/unmap    /* mappedWhenManaged to false tells to the paned window to not map/unmap
2478       the emacs screen when changing menubar.  This reduces flickering.  */       the emacs screen when changing menubar.  This reduces flickering.  */
2479    
2480    ac = 0;    ac = 0;
# Line 3834  x_window (f, window_prompting, minibuffe Line 2488  x_window (f, window_prompting, minibuffe
2488    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
2489    frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,    frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,
2490                                   al, ac);                                   al, ac);
2491    
2492    f->output_data.x->edit_widget = frame_widget;    f->output_data.x->edit_widget = frame_widget;
2493    
2494    XtManageChild (frame_widget);    XtManageChild (frame_widget);
2495    
2496    /* Do some needed geometry management.  */    /* Do some needed geometry management.  */
2497    {    {
# Line 3846  x_window (f, window_prompting, minibuffe Line 2500  x_window (f, window_prompting, minibuffe
2500      Arg al[2];      Arg al[2];
2501      int ac = 0;      int ac = 0;
2502      int extra_borders = 0;      int extra_borders = 0;
2503      int menubar_size      int menubar_size
2504        = (f->output_data.x->menubar_widget        = (f->output_data.x->menubar_widget
2505           ? (f->output_data.x->menubar_widget->core.height           ? (f->output_data.x->menubar_widget->core.height
2506              + f->output_data.x->menubar_widget->core.border_width)              + f->output_data.x->menubar_widget->core.border_width)
# Line 3890  x_window (f, window_prompting, minibuffe Line 2544  x_window (f, window_prompting, minibuffe
2544    
2545        if (window_prompting & USPosition)        if (window_prompting & USPosition)
2546          sprintf (shell_position, "=%dx%d%c%d%c%d",          sprintf (shell_position, "=%dx%d%c%d%c%d",
2547                   PIXEL_WIDTH (f) + extra_borders,                   PIXEL_WIDTH (f) + extra_borders,
2548                   PIXEL_HEIGHT (f) + menubar_size + extra_borders,                   PIXEL_HEIGHT (f) + menubar_size + extra_borders,
2549                   (xneg ? '-' : '+'), left,                   (xneg ? '-' : '+'), left,
2550                   (yneg ? '-' : '+'), top);                   (yneg ? '-' : '+'), top);
2551        else        else
2552          sprintf (shell_position, "=%dx%d",          sprintf (shell_position, "=%dx%d",
2553                   PIXEL_WIDTH (f) + extra_borders,                   PIXEL_WIDTH (f) + extra_borders,
2554                   PIXEL_HEIGHT (f) + menubar_size + extra_borders);                   PIXEL_HEIGHT (f) + menubar_size + extra_borders);
2555      }      }
2556    
# Line 3914  x_window (f, window_prompting, minibuffe Line 2568  x_window (f, window_prompting, minibuffe
2568    XtManageChild (pane_widget);    XtManageChild (pane_widget);
2569    XtRealizeWidget (shell_widget);    XtRealizeWidget (shell_widget);
2570    
2571    FRAME_X_WINDOW (f) = XtWindow (frame_widget);    FRAME_X_WINDOW (f) = XtWindow (frame_widget);
2572    
2573    validate_x_resource_name ();    validate_x_resource_name ();
2574    
2575    class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;    class_hints.res_name = (char *) SDATA (Vx_resource_name);
2576    class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;    class_hints.res_class = (char *) SDATA (Vx_resource_class);
2577    XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);    XSetClassHint (FRAME_X_DISPLAY (f), XtWindow (shell_widget), &class_hints);
2578    
2579  #ifdef HAVE_X_I18N  #ifdef HAVE_X_I18N
# Line 3961  x_window (f, window_prompting, minibuffe Line 2615  x_window (f, window_prompting, minibuffe
2615        attributes.event_mask |= fevent;        attributes.event_mask |= fevent;
2616      }      }
2617  #endif /* HAVE_X_I18N */  #endif /* HAVE_X_I18N */
2618      
2619    attribute_mask = CWEventMask;    attribute_mask = CWEventMask;
2620    XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),    XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),
2621                             attribute_mask, &attributes);                             attribute_mask, &attributes);
# Line 3993  x_window (f, window_prompting, minibuffe Line 2647  x_window (f, window_prompting, minibuffe
2647  }  }
2648    
2649  #else /* not USE_X_TOOLKIT */  #else /* not USE_X_TOOLKIT */
2650    #ifdef USE_GTK
2651    void
2652    x_window (f)
2653         FRAME_PTR f;
2654    {
2655      if (! xg_create_frame_widgets (f))
2656        error ("Unable to create window");
2657    
2658    #ifdef HAVE_X_I18N
2659      FRAME_XIC (f) = NULL;
2660    #ifdef USE_XIM
2661      BLOCK_INPUT;
2662      create_frame_xic (f);
2663      if (FRAME_XIC (f))
2664        {
2665          /* XIM server might require some X events. */
2666          unsigned long fevent = NoEventMask;
2667          XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
2668    
2669          if (fevent != NoEventMask)
2670            {
2671              XSetWindowAttributes attributes;
2672              XWindowAttributes wattr;
2673              unsigned long attribute_mask;
2674    
2675              XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2676                                    &wattr);
2677              attributes.event_mask = wattr.your_event_mask | fevent;
2678              attribute_mask = CWEventMask;
2679              XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
2680                                       attribute_mask, &attributes);
2681            }
2682        }
2683      UNBLOCK_INPUT;
2684    #endif
2685    #endif
2686    }
2687    
2688    #else /*! USE_GTK */
2689  /* Create and set up the X window for frame F.  */  /* Create and set up the X window for frame F.  */
2690    
2691  void  void
# Line 4043  x_window (f) Line 2735  x_window (f)
2735      }      }
2736  #endif  #endif
2737  #endif /* HAVE_X_I18N */  #endif /* HAVE_X_I18N */
2738      
2739    validate_x_resource_name ();    validate_x_resource_name ();
2740    
2741    class_hints.res_name = (char *) XSTRING (Vx_resource_name)->data;    class_hints.res_name = (char *) SDATA (Vx_resource_name);
2742    class_hints.res_class = (char *) XSTRING (Vx_resource_class)->data;    class_hints.res_class = (char *) SDATA (Vx_resource_class);
2743    XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);    XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);
2744    
2745    /* The menubar is part of the ordinary display;    /* The menubar is part of the ordinary display;
# Line 4096  x_window (f) Line 2788  x_window (f)
2788      error ("Unable to create window");      error ("Unable to create window");
2789  }  }
2790    
2791    #endif /* not USE_GTK */
2792  #endif /* not USE_X_TOOLKIT */  #endif /* not USE_X_TOOLKIT */
2793    
2794  /* Handle the icon stuff for this window.  Perhaps later we might  /* Handle the icon stuff for this window.  Perhaps later we might
# Line 4112  x_icon (f, parms) Line 2805  x_icon (f, parms)
2805    
2806    /* Set the position of the icon.  Note that twm groups all    /* Set the position of the icon.  Note that twm groups all
2807       icons in an icon window.  */       icons in an icon window.  */
2808    icon_x = x_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);    icon_x = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
2809    icon_y = x_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);    icon_y = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
2810    if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))    if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
2811      {      {
2812        CHECK_NUMBER (icon_x);        CHECK_NUMBER (icon_x);
# Line 4134  x_icon (f, parms) Line 2827  x_icon (f, parms)
2827           ? IconicState           ? IconicState
2828           : NormalState));           : NormalState));
2829    
2830    x_text_icon (f, (char *) XSTRING ((!NILP (f->icon_name)    x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name)
2831                                       ? f->icon_name                                       ? f->icon_name
2832                                       : f->name))->data);                                       : f->name)));
2833    
2834    UNBLOCK_INPUT;    UNBLOCK_INPUT;
2835  }  }
# Line 4207  x_make_gc (f) Line 2900  x_make_gc (f)
2900       this must be done on a per-frame basis.  */       this must be done on a per-frame basis.  */
2901    f->output_data.x->border_tile    f->output_data.x->border_tile
2902      = (XCreatePixmapFromBitmapData      = (XCreatePixmapFromBitmapData
2903         (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,         (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
2904          gray_bits, gray_width, gray_height,          gray_bits, gray_width, gray_height,
2905          f->output_data.x->foreground_pixel,          f->output_data.x->foreground_pixel,
2906          f->output_data.x->background_pixel,          f->output_data.x->background_pixel,
# Line 4226  x_free_gcs (f) Line 2919  x_free_gcs (f)
2919    Display *dpy = FRAME_X_DISPLAY (f);    Display *dpy = FRAME_X_DISPLAY (f);
2920    
2921    BLOCK_INPUT;    BLOCK_INPUT;
2922      
2923    if (f->output_data.x->normal_gc)    if (f->output_data.x->normal_gc)
2924      {      {
2925        XFreeGC (dpy, f->output_data.x->normal_gc);        XFreeGC (dpy, f->output_data.x->normal_gc);
# Line 4238  x_free_gcs (f) Line 2931  x_free_gcs (f)
2931        XFreeGC (dpy, f->output_data.x->reverse_gc);        XFreeGC (dpy, f->output_data.x->reverse_gc);
2932        f->output_data.x->reverse_gc = 0;        f->output_data.x->reverse_gc = 0;
2933      }      }
2934      
2935    if (f->output_data.x->cursor_gc)    if (f->output_data.x->cursor_gc)
2936      {      {
2937        XFreeGC (dpy, f->output_data.x->cursor_gc);        XFreeGC (dpy, f->output_data.x->cursor_gc);
# Line 4271  unwind_create_frame (frame) Line 2964  unwind_create_frame (frame)
2964  #if GLYPH_DEBUG  #if GLYPH_DEBUG
2965        struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);        struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2966  #endif  #endif
2967          
2968        x_free_frame_resources (f);        x_free_frame_resources (f);
2969    
2970        /* Check that reference counts are indeed correct.  */        /* Check that reference counts are indeed correct.  */
# Line 4279  unwind_create_frame (frame) Line 2972  unwind_create_frame (frame)
2972        xassert (dpyinfo->image_cache->refcount == image_cache_refcount);        xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
2973        return Qt;        return Qt;
2974      }      }
2975      
2976    return Qnil;    return Qnil;
2977  }  }
2978    
# Line 4304  This function is an internal primitive-- Line 2997  This function is an internal primitive--
2997    int minibuffer_only = 0;    int minibuffer_only = 0;
2998    long window_prompting = 0;    long window_prompting = 0;
2999    int width, height;    int width, height;
3000    int count = BINDING_STACK_SIZE ();    int count = SPECPDL_INDEX ();
3001    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3002    Lisp_Object display;    Lisp_Object display;
3003    struct x_display_info *dpyinfo = NULL;    struct x_display_info *dpyinfo = NULL;
# Line 4410  This function is an internal primitive-- Line 3103  This function is an internal primitive--
3103      f->output_data.x->cursor_foreground_pixel = -1;      f->output_data.x->cursor_foreground_pixel = -1;
3104      f->output_data.x->border_pixel = -1;      f->output_data.x->border_pixel = -1;
3105      f->output_data.x->mouse_pixel = -1;      f->output_data.x->mouse_pixel = -1;
3106        
3107      black = build_string ("black");      black = build_string ("black");
3108      GCPRO1 (black);      GCPRO1 (black);
3109      f->output_data.x->foreground_pixel      f->output_data.x->foreground_pixel
# Line 4469  This function is an internal primitive-- Line 3162  This function is an internal primitive--
3162        {        {
3163          tem = Fquery_fontset (font, Qnil);          tem = Fquery_fontset (font, Qnil);
3164          if (STRINGP (tem))          if (STRINGP (tem))
3165            font = x_new_fontset (f, XSTRING (tem)->data);            font = x_new_fontset (f, SDATA (tem));
3166          else          else
3167            font = x_new_font (f, XSTRING (font)->data);            font = x_new_font (f, SDATA (font));
3168        }        }
3169        
3170      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
3171      if (!STRINGP (font))      if (!STRINGP (font))
3172        font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");        font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
# Line 4504  This function is an internal primitive-- Line 3197  This function is an internal primitive--
3197    
3198    x_default_parameter (f, parms, Qborder_width, make_number (2),    x_default_parameter (f, parms, Qborder_width, make_number (2),
3199                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
3200      
3201    /* This defaults to 1 in order to match xterm.  We recognize either    /* This defaults to 1 in order to match xterm.  We recognize either
3202       internalBorderWidth or internalBorder (which is what xterm calls       internalBorderWidth or internalBorder (which is what xterm calls
3203       it).  */       it).  */
# Line 4559  This function is an internal primitive-- Line 3252  This function is an internal primitive--
3252       end up in init_iterator with a null face cache, which should not       end up in init_iterator with a null face cache, which should not
3253       happen.  */       happen.  */
3254    init_frame_faces (f);    init_frame_faces (f);
3255      
3256    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
3257                         "menuBar", "MenuBar", RES_TYPE_NUMBER);                         "menuBar", "MenuBar", RES_TYPE_NUMBER);
3258    x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),    x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
# Line 4576  This function is an internal primitive-- Line 3269  This function is an internal primitive--
3269    
3270    f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;    f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
3271    
   /* Add the tool-bar height to the initial frame height so that the  
      user gets a text display area of the size he specified with -g or  
      via .Xdefaults.  Later changes of the tool-bar height don't  
      change the frame size.  This is done so that users can create  
      tall Emacs frames without having to guess how tall the tool-bar  
      will get.  */  
   if (FRAME_TOOL_BAR_LINES (f))  
     {  
       int margin, relief, bar_height;  
         
       relief = (tool_bar_button_relief >= 0  
                 ? tool_bar_button_relief  
                 : DEFAULT_TOOL_BAR_BUTTON_RELIEF);  
   
       if (INTEGERP (Vtool_bar_button_margin)  
           && XINT (Vtool_bar_button_margin) > 0)  
         margin = XFASTINT (Vtool_bar_button_margin);  
       else if (CONSP (Vtool_bar_button_margin)  
                && INTEGERP (XCDR (Vtool_bar_button_margin))  
                && XINT (XCDR (Vtool_bar_button_margin)) > 0)  
         margin = XFASTINT (XCDR (Vtool_bar_button_margin));  
       else  
         margin = 0;  
             
       bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;  
       f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);  
     }  
   
3272    /* Compute the size of the X window.  */    /* Compute the size of the X window.  */
3273    window_prompting = x_figure_window_size (f, parms);    window_prompting = x_figure_window_size (f, parms, 1);
   
   if (window_prompting & XNegative)  
     {  
       if (window_prompting & YNegative)  
         f->output_data.x->win_gravity = SouthEastGravity;  
       else  
         f->output_data.x->win_gravity = NorthEastGravity;  
     }  
   else  
     {  
       if (window_prompting & YNegative)  
         f->output_data.x->win_gravity = SouthWestGravity;  
       else  
         f->output_data.x->win_gravity = NorthWestGravity;  
     }  
   
   f->output_data.x->size_hint_flags = window_prompting;  
3274    
3275    tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);    tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
3276    f->no_split = minibuffer_only || EQ (tem, Qt);    f->no_split = minibuffer_only || EQ (tem, Qt);
# Line 4633  This function is an internal primitive-- Line 3281  This function is an internal primitive--
3281  #else  #else
3282    x_window (f);    x_window (f);
3283  #endif  #endif
3284      
3285    x_icon (f, parms);    x_icon (f, parms);
3286    x_make_gc (f);    x_make_gc (f);
3287    
# Line 4661  This function is an internal primitive-- Line 3309  This function is an internal primitive--
3309       f->height.  */       f->height.  */
3310    width = f->width;    width = f->width;
3311    height = f->height;    height = f->height;
3312      
3313    f->height = 0;    f->height = 0;
3314    SET_FRAME_WIDTH (f, 0);    SET_FRAME_WIDTH (f, 0);
3315    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
# Line 4673  This function is an internal primitive-- Line 3321  This function is an internal primitive--
3321       new frames.  */       new frames.  */
3322    call1 (Qface_set_after_frame_default, frame);    call1 (Qface_set_after_frame_default, frame);
3323    
3324  #ifdef USE_X_TOOLKIT  #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
3325    /* Create the menu bar.  */    /* Create the menu bar.  */
3326    if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))    if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
3327      {      {
# Line 4681  This function is an internal primitive-- Line 3329  This function is an internal primitive--
3329           frame and we didn't make it visible.  */           frame and we didn't make it visible.  */
3330        initialize_frame_menubar (f);        initialize_frame_menubar (f);
3331    
3332    #ifndef USE_GTK
3333        /* This is a no-op, except under Motif where it arranges the        /* This is a no-op, except under Motif where it arranges the
3334           main window for the widgets on it.  */           main window for the widgets on it.  */
3335        lw_set_main_areas (f->output_data.x->column_widget,        lw_set_main_areas (f->output_data.x->column_widget,
3336                           f->output_data.x->menubar_widget,                           f->output_data.x->menubar_widget,
3337                           f->output_data.x->edit_widget);                           f->output_data.x->edit_widget);
3338    #endif /* not USE_GTK */
3339      }      }
3340  #endif /* USE_X_TOOLKIT */  #endif /* USE_X_TOOLKIT || USE_GTK */
3341    
3342    /* Tell the server what size and position, etc, we want, and how    /* Tell the server what size and position, etc, we want, and how
3343       badly we want them.  This should be done after we have the menu       badly we want them.  This should be done after we have the menu
# Line 4722  This function is an internal primitive-- Line 3372  This function is an internal primitive--
3372    /* Make sure windows on this frame appear in calls to next-window    /* Make sure windows on this frame appear in calls to next-window
3373       and similar functions.  */       and similar functions.  */
3374    Vwindow_list = Qnil;    Vwindow_list = Qnil;
3375      
3376    return unbind_to (count, frame);    return unbind_to (count, frame);
3377  }  }
3378    
# Line 4770  FRAME nil means use the selected frame. Line 3420  FRAME nil means use the selected frame.
3420                    RevertToParent, CurrentTime);                    RevertToParent, CurrentTime);
3421    x_uncatch_errors (dpy, count);    x_uncatch_errors (dpy, count);
3422    UNBLOCK_INPUT;    UNBLOCK_INPUT;
3423      
3424    return Qnil;    return Qnil;
3425  }  }
3426    
# Line 4785  DEFUN ("xw-color-defined-p", Fxw_color_d Line 3435  DEFUN ("xw-color-defined-p", Fxw_color_d
3435    
3436    CHECK_STRING (color);    CHECK_STRING (color);
3437    
3438    if (x_defined_color (f, XSTRING (color)->data, &foo, 0))    if (x_defined_color (f, SDATA (color), &foo, 0))
3439      return Qt;      return Qt;
3440    else    else
3441      return Qnil;      return Qnil;
# Line 4801  DEFUN ("xw-color-values", Fxw_color_valu Line 3451  DEFUN ("xw-color-values", Fxw_color_valu
3451    
3452    CHECK_STRING (color);    CHECK_STRING (color);
3453    
3454    if (x_defined_color (f, XSTRING (color)->data, &foo, 0))    if (x_defined_color (f, SDATA (color), &foo, 0))
3455      {      {
3456        Lisp_Object rgb[3];        Lisp_Object rgb[3];
3457    
# Line 5087  If omitted or nil, that stands for the s Line 3737  If omitted or nil, that stands for the s
3737        error ("Display has an unknown visual class");        error ("Display has an unknown visual class");
3738        result = Qnil;        result = Qnil;
3739      }      }
3740      
3741    return result;    return result;
3742  }  }
3743    
# Line 5212  select_visual (dpyinfo) Line 3862  select_visual (dpyinfo)
3862        /* VALUE should be of the form CLASS-DEPTH, where CLASS is one        /* VALUE should be of the form CLASS-DEPTH, where CLASS is one
3863           of `PseudoColor', `TrueColor' etc. and DEPTH is the color           of `PseudoColor', `TrueColor' etc. and DEPTH is the color
3864           depth, a decimal number.  NAME is compared with case ignored.  */           depth, a decimal number.  NAME is compared with case ignored.  */
3865        char *s = (char *) alloca (STRING_BYTES (XSTRING (value)) + 1);        char *s = (char *) alloca (SBYTES (value) + 1);
3866        char *dash;        char *dash;
3867        int i, class = -1;        int i, class = -1;
3868        XVisualInfo vinfo;        XVisualInfo vinfo;
3869    
3870        strcpy (s, XSTRING (value)->data);        strcpy (s, SDATA (value));
3871        dash = index (s, '-');        dash = index (s, '-');
3872        if (dash)        if (dash)
3873          {          {
# Line 5241  select_visual (dpyinfo) Line 3891  select_visual (dpyinfo)
3891        if (class == -1        if (class == -1
3892            || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),            || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),
3893                                  dpyinfo->n_planes, class, &vinfo))                                  dpyinfo->n_planes, class, &vinfo))
3894          fatal ("Invalid visual specification `%s'", XSTRING (value)->data);          fatal ("Invalid visual specification `%s'", SDATA (value));
3895          
3896        dpyinfo->visual = vinfo.visual;        dpyinfo->visual = vinfo.visual;
3897      }      }
3898    else    else
3899      {      {
3900        int n_visuals;        int n_visuals;
3901        XVisualInfo *vinfo, vinfo_template;        XVisualInfo *vinfo, vinfo_template;
3902          
3903        dpyinfo->visual = DefaultVisualOfScreen (screen);        dpyinfo->visual = DefaultVisualOfScreen (screen);
3904    
3905  #ifdef HAVE_X11R4  #ifdef HAVE_X11R4
# Line 5300  x_display_info_for_name (name) Line 3950  x_display_info_for_name (name)
3950    validate_x_resource_name ();    validate_x_resource_name ();
3951    
3952    dpyinfo = x_term_init (name, (char *)0,    dpyinfo = x_term_init (name, (char *)0,
3953                           (char *) XSTRING (Vx_resource_name)->data);                           (char *) SDATA (Vx_resource_name));
3954    
3955    if (dpyinfo == 0)    if (dpyinfo == 0)
3956      error ("Cannot connect to X server %s", XSTRING (name)->data);      error ("Cannot connect to X server %s", SDATA (name));
3957    
3958    x_in_use = 1;    x_in_use = 1;
3959    XSETFASTINT (Vwindow_system_version, 11);    XSETFASTINT (Vwindow_system_version, 11);
# Line 5333  terminate Emacs if we can't open the con Line 3983  terminate Emacs if we can't open the con
3983      error ("Not using X Windows");      error ("Not using X Windows");
3984    
3985    if (! NILP (xrm_string))    if (! NILP (xrm_string))
3986      xrm_option = (unsigned char *) XSTRING (xrm_string)->data;      xrm_option = (unsigned char *) SDATA (xrm_string);
3987    else    else
3988      xrm_option = (unsigned char *) 0;      xrm_option = (unsigned char *) 0;
3989    
# Line 5342  terminate Emacs if we can't open the con Line 3992  terminate Emacs if we can't open the con
3992    /* This is what opens the connection and sets x_current_display.    /* This is what opens the connection and sets x_current_display.
3993       This also initializes many symbols, such as those used for input.  */       This also initializes many symbols, such as those used for input.  */
3994    dpyinfo = x_term_init (display, xrm_option,    dpyinfo = x_term_init (display, xrm_option,
3995                           (char *) XSTRING (Vx_resource_name)->data);                           (char *) SDATA (Vx_resource_name));
3996    
3997    if (dpyinfo == 0)    if (dpyinfo == 0)
3998      {      {
3999        if (!NILP (must_succeed))        if (!NILP (must_succeed))
4000          fatal ("Cannot connect to X server %s.\n\          fatal ("Cannot connect to X server %s.\n\
4001  Check the DISPLAY environment variable or use `-d'.\n\  Check the DISPLAY environment variable or use `-d'.\n\
4002  Also use the `xhost' program to verify that it is set to permit\n\  Also use the `xauth' program to verify that you have the proper\n\
4003  connections from your machine.\n",  authorization information needed to connect the X server.\n\
4004                 XSTRING (display)->data);  An insecure way to solve the problem may be to use `xhost'.\n",
4005                   SDATA (display));
4006        else        else
4007          error ("Cannot connect to X server %s", XSTRING (display)->data);          error ("Cannot connect to X server %s", SDATA (display));
4008      }      }
4009    
4010    x_in_use = 1;    x_in_use = 1;
# Line 5542  valid_image_p (object) Line 4193  valid_image_p (object)
4193       Lisp_Object object;       Lisp_Object object;
4194  {  {
4195    int valid_p = 0;    int valid_p = 0;
4196      
4197    if (CONSP (object) && EQ (XCAR (object), Qimage))    if (CONSP (object) && EQ (XCAR (object), Qimage))
4198      {      {
4199        Lisp_Object tem;        Lisp_Object tem;
# Line 5558  valid_image_p (object) Line 4209  valid_image_p (object)
4209                  if (type)                  if (type)
4210                    valid_p = type->valid_p (object);                    valid_p = type->valid_p (object);
4211                }                }
4212                
4213              break;              break;
4214            }            }
4215      }      }
# Line 5667  parse_image_spec (spec, keywords, nkeywo Line 4318  parse_image_spec (spec, keywords, nkeywo
4318    
4319        /* Find key in KEYWORDS.  Error if not found.  */        /* Find key in KEYWORDS.  Error if not found.  */
4320        for (i = 0; i < nkeywords; ++i)        for (i = 0; i < nkeywords; ++i)
4321          if (strcmp (keywords[i].name, XSTRING (SYMBOL_NAME (key))->data) == 0)          if (strcmp (keywords[i].name, SDATA (SYMBOL_NAME (key))) == 0)
4322            break;            break;
4323    
4324        if (i == nkeywords)        if (i == nkeywords)
# Line 5677  parse_image_spec (spec, keywords, nkeywo Line 4328  parse_image_spec (spec, keywords, nkeywo
4328           was found more than once, it's an error.  */           was found more than once, it's an error.  */
4329        keywords[i].value = value;        keywords[i].value = value;
4330        ++keywords[i].count;        ++keywords[i].count;
4331          
4332        if (keywords[i].count > 1)        if (keywords[i].count > 1)
4333          return 0;          return 0;
4334    
# Line 5721  parse_image_spec (spec, keywords, nkeywo Line 4372  parse_image_spec (spec, keywords, nkeywo
4372                     && XINT (value) <= 100)                     && XINT (value) <= 100)
4373              break;              break;
4374            return 0;            return 0;
4375                  
4376          case IMAGE_NON_NEGATIVE_INTEGER_VALUE:          case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
4377            if (!INTEGERP (value) || XINT (value) < 0)            if (!INTEGERP (value) || XINT (value) < 0)
4378              return 0;              return 0;
# Line 5732  parse_image_spec (spec, keywords, nkeywo Line 4383  parse_image_spec (spec, keywords, nkeywo
4383    
4384          case IMAGE_FUNCTION_VALUE:          case IMAGE_FUNCTION_VALUE:
4385            value = indirect_function (value);            value = indirect_function (value);
4386            if (SUBRP (value)            if (SUBRP (value)
4387                || COMPILEDP (value)                || COMPILEDP (value)
4388                || (CONSP (value) && EQ (XCAR (value), Qlambda)))                || (CONSP (value) && EQ (XCAR (value), Qlambda)))
4389              break;              break;
# Line 5781  image_spec_value (spec, key, found) Line 4432  image_spec_value (spec, key, found)
4432       int *found;       int *found;
4433  {  {
4434    Lisp_Object tail;    Lisp_Object tail;
4435      
4436    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
4437    
4438    for (tail = XCDR (spec);    for (tail = XCDR (spec);
# Line 5795  image_spec_value (spec, key, found) Line 4446  image_spec_value (spec, key, found)
4446            return XCAR (XCDR (tail));            return XCAR (XCDR (tail));
4447          }          }
4448      }      }
4449      
4450    if (found)    if (found)
4451      *found = 0;      *found = 0;
4452    return Qnil;    return Qnil;
4453  }  }
4454        
4455    
4456  DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,  DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
4457         doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).         doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).
# Line 5821  or omitted means use the selected frame. Line 4472  or omitted means use the selected frame.
4472        struct image *img = IMAGE_FROM_ID (f, id);        struct image *img = IMAGE_FROM_ID (f, id);
4473        int width = img->width + 2 * img->hmargin;        int width = img->width + 2 * img->hmargin;
4474        int height = img->height + 2 * img->vmargin;        int height = img->height + 2 * img->vmargin;
4475      
4476        if (NILP (pixels))        if (NILP (pixels))
4477          size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),          size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
4478                        make_float ((double) height / CANON_Y_UNIT (f)));                        make_float ((double) height / CANON_Y_UNIT (f)));
# Line 5878  make_image (spec, hash) Line 4529  make_image (spec, hash)
4529       unsigned hash;       unsigned hash;
4530  {  {
4531    struct image *img = (struct image *) xmalloc (sizeof *img);    struct image *img = (struct image *) xmalloc (sizeof *img);
4532      
4533    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
4534    bzero (img, sizeof *img);    bzero (img, sizeof *img);
4535    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
# Line 5939  prepare_image_for_display (f, img) Line 4590  prepare_image_for_display (f, img)
4590    if (img->pixmap == None && !img->load_failed_p)    if (img->pixmap == None && !img->load_failed_p)
4591      img->load_failed_p = img->type->load (f, img) == 0;      img->load_failed_p = img->type->load (f, img) == 0;
4592  }  }
4593        
4594    
4595  /* Value is the number of pixels for the ascent of image IMG when  /* Value is the number of pixels for the ascent of image IMG when
4596     drawn in face FACE.  */     drawn in face FACE.  */
# Line 5991  four_corners_best (ximg, width, height) Line 4642  four_corners_best (ximg, width, height)
4642    for (i = best_count = 0; i < 4; ++i)    for (i = best_count = 0; i < 4; ++i)
4643      {      {
4644        int j, n;        int j, n;
4645              
4646        for (j = n = 0; j < 4; ++j)        for (j = n = 0; j < 4; ++j)
4647          if (corners[i] == corners[j])          if (corners[i] == corners[j])
4648            ++n;            ++n;
# Line 6107  x_clear_image_1 (f, img, pixmap_p, mask_ Line 4758  x_clear_image_1 (f, img, pixmap_p, mask_
4758        img->mask = None;        img->mask = None;
4759        img->background_transparent_valid = 0;        img->background_transparent_valid = 0;
4760      }      }
4761          
4762    if (colors_p && img->ncolors)    if (colors_p && img->ncolors)
4763      {      {
4764        x_free_colors (f, img->colors, img->ncolors);        x_free_colors (f, img->colors, img->ncolors);
# Line 6147  x_alloc_image_color (f, img, color_name, Line 4798  x_alloc_image_color (f, img, color_name,
4798    
4799    xassert (STRINGP (color_name));    xassert (STRINGP (color_name));
4800    
4801    if (x_defined_color (f, XSTRING (color_name)->data, &color, 1))    if (x_defined_color (f, SDATA (color_name), &color, 1))
4802      {      {
4803        /* This isn't called frequently so we get away with simply        /* This isn't called frequently so we get away with simply
4804           reallocating the color vector to the needed size, here.  */           reallocating the color vector to the needed size, here.  */
# Line 6182  make_image_cache () Line 4833  make_image_cache ()
4833  {  {
4834    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
4835    int size;    int size;
4836      
4837    bzero (c, sizeof *c);    bzero (c, sizeof *c);
4838    c->size = 50;    c->size = 50;
4839    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
# Line 6207  free_image_cache (f) Line 4858  free_image_cache (f)
4858    
4859        /* Cache should not be referenced by any frame when freed.  */        /* Cache should not be referenced by any frame when freed.  */
4860        xassert (c->refcount == 0);        xassert (c->refcount == 0);
4861          
4862        for (i = 0; i < c->used; ++i)        for (i = 0; i < c->used; ++i)
4863          free_image (f, c->images[i]);          free_image (f, c->images[i]);
4864        xfree (c->images);        xfree (c->images);
# Line 6244  clear_image_cache (f, force_p) Line 4895  clear_image_cache (f, force_p)
4895        /* Block input so that we won't be interrupted by a SIGIO        /* Block input so that we won't be interrupted by a SIGIO
4896           while being in an inconsistent state.  */           while being in an inconsistent state.  */
4897        BLOCK_INPUT;        BLOCK_INPUT;
4898          
4899        for (i = nfreed = 0; i < c->used; ++i)        for (i = nfreed = 0; i < c->used; ++i)
4900          {          {
4901            struct image *img = c->images[i];            struct image *img = c->images[i];
# Line 6263  clear_image_cache (f, force_p) Line 4914  clear_image_cache (f, force_p)
4914        if (nfreed)        if (nfreed)
4915          {          {
4916            Lisp_Object tail, frame;            Lisp_Object tail, frame;
4917              
4918            FOR_EACH_FRAME (tail, frame)            FOR_EACH_FRAME (tail, frame)
4919              {              {
4920                struct frame *f = XFRAME (frame);                struct frame *f = XFRAME (frame);
# Line 6291  FRAME t means clear the image caches of Line 4942  FRAME t means clear the image caches of
4942    if (EQ (frame, Qt))    if (EQ (frame, Qt))
4943      {      {
4944        Lisp_Object tail;        Lisp_Object tail;
4945          
4946        FOR_EACH_FRAME (tail, frame)        FOR_EACH_FRAME (tail, frame)
4947          if (FRAME_X_P (XFRAME (frame)))          if (FRAME_X_P (XFRAME (frame)))
4948            clear_image_cache (XFRAME (frame), 1);            clear_image_cache (XFRAME (frame), 1);
# Line 6318  postprocess_image (f, img) Line 4969  postprocess_image (f, img)
4969        Lisp_Object mask;        Lisp_Object mask;
4970    
4971        spec = img->spec;        spec = img->spec;
4972          
4973        /* `:heuristic-mask t'        /* `:heuristic-mask t'
4974           `:mask heuristic'           `:mask heuristic'
4975           means build a mask heuristically.           means build a mask heuristically.
# Line 6328  postprocess_image (f, img) Line 4979  postprocess_image (f, img)
4979           image.           image.
4980           `:mask nil'           `:mask nil'
4981           means remove a mask, if any.  */           means remove a mask, if any.  */
4982                  
4983        mask = image_spec_value (spec, QCheuristic_mask, NULL);        mask = image_spec_value (spec, QCheuristic_mask, NULL);
4984        if (!NILP (mask))        if (!NILP (mask))
4985          x_build_heuristic_mask (f, img, mask);          x_build_heuristic_mask (f, img, mask);
4986        else        else
4987          {          {
4988            int found_p;            int found_p;
4989                        
4990            mask = image_spec_value (spec, QCmask, &found_p);            mask = image_spec_value (spec, QCmask, &found_p);
4991                      
4992            if (EQ (mask, Qheuristic))            if (EQ (mask, Qheuristic))
4993              x_build_heuristic_mask (f, img, Qt);              x_build_heuristic_mask (f, img, Qt);
4994            else if (CONSP (mask)            else if (CONSP (mask)
# Line 6354  postprocess_image (f, img) Line 5005  postprocess_image (f, img)
5005                img->mask = None;                img->mask = None;
5006              }              }
5007          }          }
5008    
5009              
5010        /* Should we apply an image transformation algorithm?  */        /* Should we apply an image transformation algorithm?  */
5011        conversion = image_spec_value (spec, QCconversion, NULL);        conversion = image_spec_value (spec, QCconversion, NULL);
5012        if (EQ (conversion, Qdisabled))        if (EQ (conversion, Qdisabled))
# Line 6397  lookup_image (f, spec) Line 5048  lookup_image (f, spec)
5048       specification.  */       specification.  */
5049    xassert (FRAME_WINDOW_P (f));    xassert (FRAME_WINDOW_P (f));
5050    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
5051      
5052    GCPRO1 (spec);    GCPRO1 (spec);
5053    
5054    /* Look up SPEC in the hash table of the image cache.  */    /* Look up SPEC in the hash table of the image cache.  */
# Line 6412  lookup_image (f, spec) Line 5063  lookup_image (f, spec)
5063    if (img == NULL)    if (img == NULL)
5064      {      {
5065        extern Lisp_Object Qpostscript;        extern Lisp_Object Qpostscript;
5066          
5067        BLOCK_INPUT;        BLOCK_INPUT;
5068        img = make_image (spec, hash);        img = make_image (spec, hash);
5069        cache_image (f, img);        cache_image (f, img);
# Line 6444  lookup_image (f, spec) Line 5095  lookup_image (f, spec)
5095              img->ascent = XFASTINT (ascent);              img->ascent = XFASTINT (ascent);
5096            else if (EQ (ascent, Qcenter))            else if (EQ (ascent, Qcenter))
5097              img->ascent = CENTERED_IMAGE_ASCENT;              img->ascent = CENTERED_IMAGE_ASCENT;
5098              
5099            margin = image_spec_value (spec, QCmargin, NULL);            margin = image_spec_value (spec, QCmargin, NULL);
5100            if (INTEGERP (margin) && XINT (margin) >= 0)            if (INTEGERP (margin) && XINT (margin) >= 0)
5101              img->vmargin = img->hmargin = XFASTINT (margin);              img->vmargin = img->hmargin = XFASTINT (margin);
# Line 6456  lookup_image (f, spec) Line 5107  lookup_image (f, spec)
5107                if (XINT (XCDR (margin)) > 0)                if (XINT (XCDR (margin)) > 0)
5108                  img->vmargin = XFASTINT (XCDR (margin));                  img->vmargin = XFASTINT (XCDR (margin));
5109              }              }
5110              
5111            relief = image_spec_value (spec, QCrelief, NULL);            relief = image_spec_value (spec, QCrelief, NULL);
5112            if (INTEGERP (relief))            if (INTEGERP (relief))
5113              {              {
# Line 6490  lookup_image (f, spec) Line 5141  lookup_image (f, spec)
5141    /* We're using IMG, so set its timestamp to `now'.  */    /* We're using IMG, so set its timestamp to `now'.  */
5142    EMACS_GET_TIME (now);    EMACS_GET_TIME (now);
5143    img->timestamp = EMACS_SECS (now);    img->timestamp = EMACS_SECS (now);
5144      
5145    UNGCPRO;    UNGCPRO;
5146      
5147    /* Value is the image id.  */    /* Value is the image id.  */
5148    return img->id;    return img->id;
5149  }  }
# Line 6641  x_put_x_image (f, ximg, pixmap, width, h Line 5292  x_put_x_image (f, ximg, pixmap, width, h
5292       struct frame *f;       struct frame *f;
5293       XImage *ximg;       XImage *ximg;
5294       Pixmap pixmap;       Pixmap pixmap;
5295         int width, height;
5296  {  {
5297    GC gc;    GC gc;
5298      
5299    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
5300    gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);    gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
5301    XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);    XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);
# Line 6678  x_find_image_file (file) Line 5330  x_find_image_file (file)
5330    
5331    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */
5332    fd = openp (search_path, file, Qnil, &file_found, Qnil);    fd = openp (search_path, file, Qnil, &file_found, Qnil);
5333      
5334    if (fd == -1)    if (fd == -1)
5335      file_found = Qnil;      file_found = Qnil;
5336    else    else
# Line 6720  slurp_file (file, size) Line 5372  slurp_file (file, size)
5372            buf = NULL;            buf = NULL;
5373          }          }
5374      }      }
5375      
5376    return buf;    return buf;
5377  }  }
5378    
# Line 6799  enum xbm_token Line 5451  enum xbm_token
5451    XBM_TK_NUMBER    XBM_TK_NUMBER
5452  };  };
5453    
5454      
5455  /* Return non-zero if OBJECT is a valid XBM-type image specification.  /* Return non-zero if OBJECT is a valid XBM-type image specification.
5456     A valid specification is a list starting with the symbol `image'     A valid specification is a list starting with the symbol `image'
5457     The rest of the list is a property list which must contain an     The rest of the list is a property list which must contain an
# Line 6834  xbm_image_p (object) Line 5486  xbm_image_p (object)
5486       Lisp_Object object;       Lisp_Object object;
5487  {  {
5488    struct image_keyword kw[XBM_LAST];    struct image_keyword kw[XBM_LAST];
5489      
5490    bcopy (xbm_format, kw, sizeof kw);    bcopy (xbm_format, kw, sizeof kw);
5491    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
5492      return 0;      return 0;
# Line 6866  xbm_image_p (object) Line 5518  xbm_image_p (object)
5518        data = kw[XBM_DATA].value;        data = kw[XBM_DATA].value;
5519        width = XFASTINT (kw[XBM_WIDTH].value);        width = XFASTINT (kw[XBM_WIDTH].value);
5520        height = XFASTINT (kw[XBM_HEIGHT].value);        height = XFASTINT (kw[XBM_HEIGHT].value);
5521          
5522        /* Check type of data, and width and height against contents of        /* Check type of data, and width and height against contents of
5523           data.  */           data.  */
5524        if (VECTORP (data))        if (VECTORP (data))
5525          {          {
5526            int i;            int i;
5527              
5528            /* Number of elements of the vector must be >= height.  */            /* Number of elements of the vector must be >= height.  */
5529            if (XVECTOR (data)->size < height)            if (XVECTOR (data)->size < height)
5530              return 0;              return 0;
# Line 6885  xbm_image_p (object) Line 5537  xbm_image_p (object)
5537    
5538                if (STRINGP (elt))                if (STRINGP (elt))
5539                  {                  {
5540                    if (XSTRING (elt)->size                    if (SCHARS (elt)
5541                        < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)                        < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR)
5542                      return 0;                      return 0;
5543                  }                  }
# Line 6900  xbm_image_p (object) Line 5552  xbm_image_p (object)
5552          }          }
5553        else if (STRINGP (data))        else if (STRINGP (data))
5554          {          {
5555            if (XSTRING (data)->size            if (SCHARS (data)
5556                < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)                < (width + BITS_PER_CHAR - 1) / BITS_PER_CHAR * height)
5557              return 0;              return 0;
5558          }          }
# Line 6932  xbm_scan (s, end, sval, ival) Line 5584  xbm_scan (s, end, sval, ival)
5584    int c;    int c;
5585    
5586   loop:   loop:
5587      
5588    /* Skip white space.  */    /* Skip white space.  */
5589    while (*s < end && (c = *(*s)++, isspace (c)))    while (*s < end && (c = *(*s)++, isspace (c)))
5590      ;      ;
# Line 6942  xbm_scan (s, end, sval, ival) Line 5594  xbm_scan (s, end, sval, ival)
5594    else if (isdigit (c))    else if (isdigit (c))
5595      {      {
5596        int value = 0, digit;        int value = 0, digit;
5597          
5598        if (c == '0' && *s < end)        if (c == '0' && *s < end)
5599          {          {
5600            c = *(*s)++;            c = *(*s)++;
# Line 7040  xbm_read_bitmap_data (contents, end, wid Line 5692  xbm_read_bitmap_data (contents, end, wid
5692       if (LA1 != (TOKEN))        \       if (LA1 != (TOKEN))        \
5693         goto failure;            \         goto failure;            \
5694       else                       \       else                       \
5695         match ()         match ()
5696    
5697  #define expect_ident(IDENT)                                     \  #define expect_ident(IDENT)                                     \
5698       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \
# Line 7083  xbm_read_bitmap_data (contents, end, wid Line 5735  xbm_read_bitmap_data (contents, end, wid
5735      {      {
5736        if (strcmp (buffer, "unsigned") == 0)        if (strcmp (buffer, "unsigned") == 0)
5737          {          {
5738            match ();            match ();
5739            expect_ident ("char");            expect_ident ("char");
5740          }          }
5741        else if (strcmp (buffer, "short") == 0)        else if (strcmp (buffer, "short") == 0)
# Line 7098  xbm_read_bitmap_data (contents, end, wid Line 5750  xbm_read_bitmap_data (contents, end, wid
5750        else        else
5751          goto failure;          goto failure;
5752      }      }
5753    else    else
5754      goto failure;      goto failure;
5755    
5756    expect (XBM_TK_IDENT);    expect (XBM_TK_IDENT);
# Line 7121  xbm_read_bitmap_data (contents, end, wid Line 5773  xbm_read_bitmap_data (contents, end, wid
5773            *p++ = val;            *p++ = val;
5774            if (!padding_p || ((i + 2) % bytes_per_line))            if (!padding_p || ((i + 2) % bytes_per_line))
5775              *p++ = value >> 8;              *p++ = value >> 8;
5776              
5777            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
5778              match ();              match ();
5779            else            else
# Line 7134  xbm_read_bitmap_data (contents, end, wid Line 5786  xbm_read_bitmap_data (contents, end, wid
5786          {          {
5787            int val = value;            int val = value;
5788            expect (XBM_TK_NUMBER);            expect (XBM_TK_NUMBER);
5789              
5790            *p++ = val;            *p++ = val;
5791              
5792            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
5793              match ();              match ();
5794            else            else
# Line 7148  xbm_read_bitmap_data (contents, end, wid Line 5800  xbm_read_bitmap_data (contents, end, wid
5800    return 1;    return 1;
5801    
5802   failure:   failure:
5803      
5804    if (data && *data)    if (data && *data)
5805      {      {
5806        xfree (*data);        xfree (*data);
# Line 7175  xbm_load_image (f, img, contents, end) Line 5827  xbm_load_image (f, img, contents, end)
5827    int rc;    int rc;
5828    unsigned char *data;    unsigned char *data;
5829    int success_p = 0;    int success_p = 0;
5830      
5831    rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);    rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
5832    if (rc)    if (rc)
5833      {      {
# Line 7183  xbm_load_image (f, img, contents, end) Line 5835  xbm_load_image (f, img, contents, end)
5835        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
5836        unsigned long background = FRAME_BACKGROUND_PIXEL (f);        unsigned long background = FRAME_BACKGROUND_PIXEL (f);
5837        Lisp_Object value;        Lisp_Object value;
5838          
5839        xassert (img->width > 0 && img->height > 0);        xassert (img->width > 0 && img->height > 0);
5840    
5841        /* Get foreground and background colors, maybe allocate colors.  */        /* Get foreground and background colors, maybe allocate colors.  */
# Line 7230  xbm_file_p (data) Line 5882  xbm_file_p (data)
5882  {  {
5883    int w, h;    int w, h;
5884    return (STRINGP (data)    return (STRINGP (data)
5885            && xbm_read_bitmap_data (XSTRING (data)->data,            && xbm_read_bitmap_data (SDATA (data),
5886                                     (XSTRING (data)->data                                     (SDATA (data)
5887                                      + STRING_BYTES (XSTRING (data))),                                      + SBYTES (data)),
5888                                     &w, &h, NULL));                                     &w, &h, NULL));
5889  }  }
5890    
5891        
5892  /* Fill image IMG which is used on frame F with pixmap data.  Value is  /* Fill image IMG which is used on frame F with pixmap data.  Value is
5893     non-zero if successful.  */     non-zero if successful.  */
5894    
# Line 7258  xbm_load (f, img) Line 5910  xbm_load (f, img)
5910        char *contents;        char *contents;
5911        int size;        int size;
5912        struct gcpro gcpro1;        struct gcpro gcpro1;
5913          
5914        file = x_find_image_file (file_name);        file = x_find_image_file (file_name);
5915        GCPRO1 (file);        GCPRO1 (file);
5916        if (!STRINGP (file))        if (!STRINGP (file))
# Line 7268  xbm_load (f, img) Line 5920  xbm_load (f, img)
5920            return 0;            return 0;
5921          }          }
5922    
5923        contents = slurp_file (XSTRING (file)->data, &size);        contents = slurp_file (SDATA (file), &size);
5924        if (contents == NULL)        if (contents == NULL)
5925          {          {
5926            image_error ("Error loading XBM image `%s'", img->spec, Qnil);            image_error ("Error loading XBM image `%s'", img->spec, Qnil);
# Line 7318  xbm_load (f, img) Line 5970  xbm_load (f, img)
5970                                            background);                                            background);
5971    
5972        if (in_memory_file_p)        if (in_memory_file_p)
5973          success_p = xbm_load_image (f, img, XSTRING (data)->data,          success_p = xbm_load_image (f, img, SDATA (data),
5974                                      (XSTRING (data)->data                                      (SDATA (data)
5975                                       + STRING_BYTES (XSTRING (data))));                                       + SBYTES (data)));
5976        else        else
5977          {          {
5978            if (VECTORP (data))            if (VECTORP (data))
# Line 7328  xbm_load (f, img) Line 5980  xbm_load (f, img)
5980                int i;                int i;
5981                char *p;                char *p;
5982                int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;                int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
5983              
5984                p = bits = (char *) alloca (nbytes * img->height);                p = bits = (char *) alloca (nbytes * img->height);
5985                for (i = 0; i < img->height; ++i, p += nbytes)                for (i = 0; i < img->height; ++i, p += nbytes)
5986                  {                  {
5987                    Lisp_Object line = XVECTOR (data)->contents[i];                    Lisp_Object line = XVECTOR (data)->contents[i];
5988                    if (STRINGP (line))                    if (STRINGP (line))
5989                      bcopy (XSTRING (line)->data, p, nbytes);                      bcopy (SDATA (line), p, nbytes);
5990                    else                    else
5991                      bcopy (XBOOL_VECTOR (line)->data, p, nbytes);                      bcopy (XBOOL_VECTOR (line)->data, p, nbytes);
5992                  }                  }
5993              }              }
5994            else if (STRINGP (data))            else if (STRINGP (data))
5995              bits = XSTRING (data)->data;              bits = SDATA (data);
5996            else            else
5997              bits = XBOOL_VECTOR (data)->data;              bits = XBOOL_VECTOR (data)->data;
5998    
# Line 7366  xbm_load (f, img) Line 6018  xbm_load (f, img)
6018    
6019    return success_p;    return success_p;
6020  }  }
6021      
6022    
6023    
6024  /***********************************************************************  /***********************************************************************
6025                                XPM images                                XPM images
6026   ***********************************************************************/   ***********************************************************************/
6027    
6028  #if HAVE_XPM  #if HAVE_XPM
6029    
6030  static int xpm_image_p P_ ((Lisp_Object object));  static int xpm_image_p P_ ((Lisp_Object object));
6031  static int xpm_load P_ ((struct frame *f, struct image *img));  static int xpm_load P_ ((struct frame *f, struct image *img));
# Line 7490  xpm_init_color_cache (f, attrs) Line 6142  xpm_init_color_cache (f, attrs)
6142      {      {
6143        int i;        int i;
6144        XColor color;        XColor color;
6145          
6146        for (i = 0; i < attrs->numsymbols; ++i)        for (i = 0; i < attrs->numsymbols; ++i)
6147          if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),          if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
6148                           attrs->colorsymbols[i].value, &color))                           attrs->colorsymbols[i].value, &color))
# Line 7533  xpm_color_bucket (color_name) Line 6185  xpm_color_bucket (color_name)
6185  {  {
6186    unsigned h = 0;    unsigned h = 0;
6187    char *s;    char *s;
6188      
6189    for (s = color_name; *s; ++s)    for (s = color_name; *s; ++s)
6190      h = (h << 2) ^ *s;      h = (h << 2) ^ *s;
6191    return h %= XPM_COLOR_CACHE_BUCKETS;    return h %= XPM_COLOR_CACHE_BUCKETS;
# Line 7553  xpm_cache_color (f, color_name, color, b Line 6205  xpm_cache_color (f, color_name, color, b
6205  {  {
6206    size_t nbytes;    size_t nbytes;
6207    struct xpm_cached_color *p;    struct xpm_cached_color *p;
6208      
6209    if (bucket < 0)    if (bucket < 0)
6210      bucket = xpm_color_bucket (color_name);      bucket = xpm_color_bucket (color_name);
6211          
6212    nbytes = sizeof *p + strlen (color_name);    nbytes = sizeof *p + strlen (color_name);
6213    p = (struct xpm_cached_color *) xmalloc (nbytes);    p = (struct xpm_cached_color *) xmalloc (nbytes);
6214    strcpy (p->name, color_name);    strcpy (p->name, color_name);
# Line 7594  xpm_lookup_color (f, color_name, color) Line 6246  xpm_lookup_color (f, color_name, color)
6246                                         color->blue);                                         color->blue);
6247        p = xpm_cache_color (f, color_name, color, h);        p = xpm_cache_color (f, color_name, color, h);
6248      }      }
6249        /* You get `opaque' at least from ImageMagick converting pbm to xpm
6250         with transparency, and it's useful.  */
6251      else if (strcmp ("opaque", color_name) == 0)
6252        {
6253          bzero (color, sizeof (XColor));  /* Is this necessary/correct?  */
6254          color->pixel = FRAME_FOREGROUND_PIXEL (f);
6255          p = xpm_cache_color (f, color_name, color, h);
6256        }
6257    
6258    return p != NULL;    return p != NULL;
6259  }  }
6260    
# Line 7721  xpm_load (f, img) Line 6381  xpm_load (f, img)
6381        Lisp_Object tail;        Lisp_Object tail;
6382        XpmColorSymbol *xpm_syms;        XpmColorSymbol *xpm_syms;
6383        int i, size;        int i, size;
6384          
6385        attrs.valuemask |= XpmColorSymbols;        attrs.valuemask |= XpmColorSymbols;
6386    
6387        /* Count number of symbols.  */        /* Count number of symbols.  */
# Line 7742  xpm_load (f, img) Line 6402  xpm_load (f, img)
6402          {          {
6403            Lisp_Object name = XCAR (XCAR (tail));            Lisp_Object name = XCAR (XCAR (tail));
6404            Lisp_Object color = XCDR (XCAR (tail));            Lisp_Object color = XCDR (XCAR (tail));
6405            xpm_syms[i].name = (char *) alloca (XSTRING (name)->size + 1);            xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1);
6406            strcpy (xpm_syms[i].name, XSTRING (name)->data);            strcpy (xpm_syms[i].name, SDATA (name));
6407            xpm_syms[i].value = (char *) alloca (XSTRING (color)->size + 1);            xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1);
6408            strcpy (xpm_syms[i].value, XSTRING (color)->data);            strcpy (xpm_syms[i].value, SDATA (color));
6409          }          }
6410      }      }
6411    
# Line 7754  xpm_load (f, img) Line 6414  xpm_load (f, img)
6414  #ifdef ALLOC_XPM_COLORS  #ifdef ALLOC_XPM_COLORS
6415    xpm_init_color_cache (f, &attrs);    xpm_init_color_cache (f, &attrs);
6416  #endif  #endif
6417      
6418    specified_file = image_spec_value (img->spec, QCfile, NULL);    specified_file = image_spec_value (img->spec, QCfile, NULL);
6419    if (STRINGP (specified_file))    if (STRINGP (specified_file))
6420      {      {
# Line 7764  xpm_load (f, img) Line 6424  xpm_load (f, img)
6424            image_error ("Cannot find image file `%s'", specified_file, Qnil);            image_error ("Cannot find image file `%s'", specified_file, Qnil);
6425            return 0;            return 0;
6426          }          }
6427          
6428        rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
6429                                  XSTRING (file)->data, &img->pixmap, &img->mask,                                  SDATA (file), &img->pixmap, &img->mask,
6430                                  &attrs);                                  &attrs);
6431      }      }
6432    else    else
6433      {      {
6434        Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);        Lisp_Object buffer = image_spec_value (img->spec, QCdata, NULL);
6435        rc = XpmCreatePixmapFromBuffer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        rc = XpmCreatePixmapFromBuffer (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
6436                                        XSTRING (buffer)->data,                                        SDATA (buffer),
6437                                        &img->pixmap, &img->mask,                                        &img->pixmap, &img->mask,
6438                                        &attrs);                                        &attrs);
6439      }      }
# Line 7811  xpm_load (f, img) Line 6471  xpm_load (f, img)
6471          case XpmOpenFailed:          case XpmOpenFailed:
6472            image_error ("Error opening XPM file (%s)", img->spec, Qnil);            image_error ("Error opening XPM file (%s)", img->spec, Qnil);
6473            break;            break;
6474              
6475          case XpmFileInvalid:          case XpmFileInvalid:
6476            image_error ("Invalid XPM file (%s)", img->spec, Qnil);            image_error ("Invalid XPM file (%s)", img->spec, Qnil);
6477            break;            break;
6478              
6479          case XpmNoMemory:          case XpmNoMemory:
6480            image_error ("Out of memory (%s)", img->spec, Qnil);            image_error ("Out of memory (%s)", img->spec, Qnil);
6481            break;            break;
6482              
6483          case XpmColorFailed:          case XpmColorFailed:
6484            image_error ("Color allocation error (%s)", img->spec, Qnil);            image_error ("Color allocation error (%s)", img->spec, Qnil);
6485            break;            break;
6486              
6487          default:          default:
6488            image_error ("Unknown error (%s)", img->spec, Qnil);            image_error ("Unknown error (%s)", img->spec, Qnil);
6489            break;            break;
# Line 7929  lookup_rgb_color (f, r, g, b) Line 6589  lookup_rgb_color (f, r, g, b)
6589        color.red = r;        color.red = r;
6590        color.green = g;        color.green = g;
6591        color.blue = b;        color.blue = b;
6592          
6593        cmap = FRAME_X_COLORMAP (f);        cmap = FRAME_X_COLORMAP (f);
6594        rc = x_alloc_nearest_color (f, cmap, &color);        rc = x_alloc_nearest_color (f, cmap, &color);
6595    
6596        if (rc)        if (rc)
6597          {          {
6598            ++ct_colors_allocated;            ++ct_colors_allocated;
6599          
6600            p = (struct ct_color *) xmalloc (sizeof *p);            p = (struct ct_color *) xmalloc (sizeof *p);
6601            p->r = r;            p->r = r;
6602            p->g = g;            p->g = g;
# Line 7982  lookup_pixel_color (f, pixel) Line 6642  lookup_pixel_color (f, pixel)
6642        if (rc)        if (rc)
6643          {          {
6644            ++ct_colors_allocated;            ++ct_colors_allocated;
6645          
6646            p = (struct ct_color *) xmalloc (sizeof *p);            p = (struct ct_color *) xmalloc (sizeof *p);
6647            p->r = color.red;            p->r = color.red;
6648            p->g = color.green;            p->g = color.green;
# Line 7994  lookup_pixel_color (f, pixel) Line 6654  lookup_pixel_color (f, pixel)
6654        else        else
6655          return FRAME_FOREGROUND_PIXEL (f);          return FRAME_FOREGROUND_PIXEL (f);
6656      }      }
6657      
6658    return p->pixel;    return p->pixel;
6659  }  }
6660    
# Line 8020  colors_in_color_table (n) Line 6680  colors_in_color_table (n)
6680        colors = (unsigned long *) xmalloc (ct_colors_allocated        colors = (unsigned long *) xmalloc (ct_colors_allocated
6681                                            * sizeof *colors);                                            * sizeof *colors);
6682        *n = ct_colors_allocated;        *n = ct_colors_allocated;
6683          
6684        for (i = j = 0; i < CT_SIZE; ++i)        for (i = j = 0; i < CT_SIZE; ++i)
6685          for (p = ct_table[i]; p; p = p->next)          for (p = ct_table[i]; p; p = p->next)
6686            colors[j++] = p->pixel;            colors[j++] = p->pixel;
# Line 8095  x_to_xcolors (f, img, rgb_p) Line 6755  x_to_xcolors (f, img, rgb_p)
6755    for (y = 0; y < img->height; ++y)    for (y = 0; y < img->height; ++y)
6756      {      {
6757        XColor *row = p;        XColor *row = p;
6758          
6759        for (x = 0; x < img->width; ++x, ++p)        for (x = 0; x < img->width; ++x, ++p)
6760          p->pixel = XGetPixel (ximg, x, y);          p->pixel = XGetPixel (ximg, x, y);
6761    
# Line 8122  x_from_xcolors (f, img, colors) Line 6782  x_from_xcolors (f, img, colors)
6782    XImage *oimg;    XImage *oimg;
6783    Pixmap pixmap;    Pixmap pixmap;
6784    XColor *p;    XColor *p;
6785      
6786    init_color_table ();    init_color_table ();
6787      
6788    x_create_x_image_and_pixmap (f, img->width, img->height, 0,    x_create_x_image_and_pixmap (f, img->width, img->height, 0,
6789                                 &oimg, &pixmap);                                 &oimg, &pixmap);
6790    p = colors;    p = colors;
# Line 8151  x_from_xcolors (f, img, colors) Line 6811  x_from_xcolors (f, img, colors)
6811    
6812     MATRIX is a nine-element array specifying the transformation     MATRIX is a nine-element array specifying the transformation
6813     matrix.  See emboss_matrix for an example.     matrix.  See emboss_matrix for an example.
6814      
6815     COLOR_ADJUST is a color adjustment added to each pixel of the     COLOR_ADJUST is a color adjustment added to each pixel of the
6816     outgoing image.  */     outgoing image.  */
6817    
# Line 8179  x_detect_edges (f, img, matrix, color_ad Line 6839  x_detect_edges (f, img, matrix, color_ad
6839        p = COLOR (new, img->width - 1, y);        p = COLOR (new, img->width - 1, y);
6840        p->red = p->green = p->blue = 0xffff/2;        p->red = p->green = p->blue = 0xffff/2;
6841      }      }
6842      
6843    for (x = 1; x < img->width - 1; ++x)    for (x = 1; x < img->width - 1; ++x)
6844      {      {
6845        p = COLOR (new, x, 0);        p = COLOR (new, x, 0);
# Line 8191  x_detect_edges (f, img, matrix, color_ad Line 6851  x_detect_edges (f, img, matrix, color_ad
6851    for (y = 1; y < img->height - 1; ++y)    for (y = 1; y < img->height - 1; ++y)
6852      {      {
6853        p = COLOR (new, 1, y);        p = COLOR (new, 1, y);
6854          
6855        for (x = 1; x < img->width - 1; ++x, ++p)        for (x = 1; x < img->width - 1; ++x, ++p)
6856          {          {
6857            int r, g, b, y1, x1;            int r, g, b, y1, x1;
# Line 8264  x_edge_detection (f, img, matrix, color_ Line 6924  x_edge_detection (f, img, matrix, color_
6924  {  {
6925    int i = 0;    int i = 0;
6926    int trans[9];    int trans[9];
6927      
6928    if (CONSP (matrix))    if (CONSP (matrix))
6929      {      {
6930        for (i = 0;        for (i = 0;
# Line 8384  x_build_heuristic_mask (f, img, how) Line 7044  x_build_heuristic_mask (f, img, how)
7044    /* Determine the background color of ximg.  If HOW is `(R G B)'    /* Determine the background color of ximg.  If HOW is `(R G B)'
7045       take that as color.  Otherwise, use the image's background color. */       take that as color.  Otherwise, use the image's background color. */
7046    use_img_background = 1;    use_img_background = 1;
7047      
7048    if (CONSP (how))    if (CONSP (how))
7049      {      {
7050        int rgb[3], i;        int rgb[3], i;
# Line 8403  x_build_heuristic_mask (f, img, how) Line 7063  x_build_heuristic_mask (f, img, how)
7063            use_img_background = 0;            use_img_background = 0;
7064          }          }
7065      }      }
7066      
7067    if (use_img_background)    if (use_img_background)
7068      bg = four_corners_best (ximg, img->width, img->height);      bg = four_corners_best (ximg, img->width, img->height);
7069    
# Line 8420  x_build_heuristic_mask (f, img, how) Line 7080  x_build_heuristic_mask (f, img, how)
7080    x_put_x_image (f, mask_img, img->mask, img->width, img->height);    x_put_x_image (f, mask_img, img->mask, img->width, img->height);
7081    x_destroy_x_image (mask_img);    x_destroy_x_image (mask_img);
7082    XDestroyImage (ximg);    XDestroyImage (ximg);
7083      
7084    return 1;    return 1;
7085  }  }
7086    
# Line 8493  pbm_image_p (object) Line 7153  pbm_image_p (object)
7153       Lisp_Object object;       Lisp_Object object;
7154  {  {
7155    struct image_keyword fmt[PBM_LAST];    struct image_keyword fmt[PBM_LAST];
7156      
7157    bcopy (pbm_format, fmt, sizeof fmt);    bcopy (pbm_format, fmt, sizeof fmt);
7158      
7159    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
7160      return 0;      return 0;
7161    
# Line 8544  pbm_scan_number (s, end) Line 7204  pbm_scan_number (s, end)
7204    
7205  /* Load PBM image IMG for use on frame F.  */  /* Load PBM image IMG for use on frame F.  */
7206    
7207  static int  static int
7208  pbm_load (f, img)  pbm_load (f, img)
7209       struct frame *f;       struct frame *f;
7210       struct image *img;       struct image *img;
# Line 8573  pbm_load (f, img) Line 7233  pbm_load (f, img)
7233            return 0;            return 0;
7234          }          }
7235    
7236        contents = slurp_file (XSTRING (file)->data, &size);        contents = slurp_file (SDATA (file), &size);
7237        if (contents == NULL)        if (contents == NULL)
7238          {          {
7239            image_error ("Error reading `%s'", file, Qnil);            image_error ("Error reading `%s'", file, Qnil);
# Line 8588  pbm_load (f, img) Line 7248  pbm_load (f, img)
7248      {      {
7249        Lisp_Object data;        Lisp_Object data;
7250        data = image_spec_value (img->spec, QCdata, NULL);        data = image_spec_value (img->spec, QCdata, NULL);
7251        p = XSTRING (data)->data;        p = SDATA (data);
7252        end = p + STRING_BYTES (XSTRING (data));        end = p + SBYTES (data);
7253      }      }
7254    
7255    /* Check magic number.  */    /* Check magic number.  */
# Line 8607  pbm_load (f, img) Line 7267  pbm_load (f, img)
7267      case '1':      case '1':
7268        raw_p = 0, type = PBM_MONO;        raw_p = 0, type = PBM_MONO;
7269        break;        break;
7270          
7271      case '2':      case '2':
7272        raw_p = 0, type = PBM_GRAY;        raw_p = 0, type = PBM_GRAY;
7273        break;        break;
# Line 8619  pbm_load (f, img) Line 7279  pbm_load (f, img)
7279      case '4':      case '4':
7280        raw_p = 1, type = PBM_MONO;        raw_p = 1, type = PBM_MONO;
7281        break;        break;
7282          
7283      case '5':      case '5':
7284        raw_p = 1, type = PBM_GRAY;        raw_p = 1, type = PBM_GRAY;
7285        break;        break;
7286          
7287      case '6':      case '6':
7288        raw_p = 1, type = PBM_COLOR;        raw_p = 1, type = PBM_COLOR;
7289        break;        break;
# Line 8644  pbm_load (f, img) Line 7304  pbm_load (f, img)
7304        if (raw_p && max_color_idx > 255)        if (raw_p && max_color_idx > 255)
7305          max_color_idx = 255;          max_color_idx = 255;
7306      }      }
7307      
7308    if (width < 0    if (width < 0
7309        || height < 0        || height < 0
7310        || (type != PBM_MONO && max_color_idx < 0))        || (type != PBM_MONO && max_color_idx < 0))
# Line 8653  pbm_load (f, img) Line 7313  pbm_load (f, img)
7313    if (!x_create_x_image_and_pixmap (f, width, height, 0,    if (!x_create_x_image_and_pixmap (f, width, height, 0,
7314                                      &ximg, &img->pixmap))                                      &ximg, &img->pixmap))
7315      goto error;      goto error;
7316      
7317    /* Initialize the color hash table.  */    /* Initialize the color hash table.  */
7318    init_color_table ();    init_color_table ();
7319    
# Line 8667  pbm_load (f, img) Line 7327  pbm_load (f, img)
7327        /* Parse the image specification.  */        /* Parse the image specification.  */
7328        bcopy (pbm_format, fmt, sizeof fmt);        bcopy (pbm_format, fmt, sizeof fmt);
7329        parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);        parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);
7330          
7331        /* Get foreground and background colors, maybe allocate colors.  */        /* Get foreground and background colors, maybe allocate colors.  */
7332        if (fmt[PBM_FOREGROUND].count        if (fmt[PBM_FOREGROUND].count
7333            && STRINGP (fmt[PBM_FOREGROUND].value))            && STRINGP (fmt[PBM_FOREGROUND].value))
# Line 8679  pbm_load (f, img) Line 7339  pbm_load (f, img)
7339            img->background = bg;            img->background = bg;
7340            img->background_valid = 1;            img->background_valid = 1;
7341          }          }
7342          
7343        for (y = 0; y < height; ++y)        for (y = 0; y < height; ++y)
7344          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
7345            {            {
# Line 8702  pbm_load (f, img) Line 7362  pbm_load (f, img)
7362          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
7363            {            {
7364              int r, g, b;              int r, g, b;
7365                
7366              if (type == PBM_GRAY)              if (type == PBM_GRAY)
7367                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
7368              else if (raw_p)              else if (raw_p)
# Line 8717  pbm_load (f, img) Line 7377  pbm_load (f, img)
7377                  g = pbm_scan_number (&p, end);                  g = pbm_scan_number (&p, end);
7378                  b = pbm_scan_number (&p, end);                  b = pbm_scan_number (&p, end);
7379                }                }
7380                
7381              if (r < 0 || g < 0 || b < 0)              if (r < 0 || g < 0 || b < 0)
7382                {                {
7383                  xfree (ximg->data);                  xfree (ximg->data);
# Line 8727  pbm_load (f, img) Line 7387  pbm_load (f, img)
7387                               img->spec, Qnil);                               img->spec, Qnil);
7388                  goto error;                  goto error;
7389                }                }
7390                
7391              /* RGB values are now in the range 0..max_color_idx.              /* RGB values are now in the range 0..max_color_idx.
7392                 Scale this to the range 0..0xffff supported by X.  */                 Scale this to the range 0..0xffff supported by X.  */
7393              r = (double) r * 65535 / max_color_idx;              r = (double) r * 65535 / max_color_idx;
# Line 8736  pbm_load (f, img) Line 7396  pbm_load (f, img)
7396              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
7397            }            }
7398      }      }
7399      
7400    /* Store in IMG->colors the colors allocated for the image, and    /* Store in IMG->colors the colors allocated for the image, and
7401       free the color table.  */       free the color table.  */
7402    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
# Line 8745  pbm_load (f, img) Line 7405  pbm_load (f, img)
7405    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
7406    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
7407      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
7408      
7409    /* Put the image into a pixmap.  */    /* Put the image into a pixmap.  */
7410    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
7411    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
7412          
7413    img->width = width;    img->width = width;
7414    img->height = height;    img->height = height;
7415    
# Line 8831  png_image_p (object) Line 7491  png_image_p (object)
7491  {  {
7492    struct image_keyword fmt[PNG_LAST];    struct image_keyword fmt[PNG_LAST];
7493    bcopy (png_format, fmt, sizeof fmt);    bcopy (png_format, fmt, sizeof fmt);
7494      
7495    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
7496      return 0;      return 0;
7497    
# Line 8888  png_read_from_memory (png_ptr, data, len Line 7548  png_read_from_memory (png_ptr, data, len
7548    
7549    if (length > tbr->len - tbr->index)    if (length > tbr->len - tbr->index)
7550      png_error (png_ptr, "Read error");      png_error (png_ptr, "Read error");
7551      
7552    bcopy (tbr->bytes + tbr->index, data, length);    bcopy (tbr->bytes + tbr->index, data, length);
7553    tbr->index = tbr->index + length;    tbr->index = tbr->index + length;
7554  }  }
# Line 8938  png_load (f, img) Line 7598  png_load (f, img)
7598          }          }
7599    
7600        /* Open the image file.  */        /* Open the image file.  */
7601        fp = fopen (XSTRING (file)->data, "rb");        fp = fopen (SDATA (file), "rb");
7602        if (!fp)        if (!fp)
7603          {          {
7604            image_error ("Cannot open image file `%s'", file, Qnil);            image_error ("Cannot open image file `%s'", file, Qnil);
# Line 8960  png_load (f, img) Line 7620  png_load (f, img)
7620    else    else
7621      {      {
7622        /* Read from memory.  */        /* Read from memory.  */
7623        tbr.bytes = XSTRING (specified_data)->data;        tbr.bytes = SDATA (specified_data);
7624        tbr.len = STRING_BYTES (XSTRING (specified_data));        tbr.len = SBYTES (specified_data);
7625        tbr.index = 0;        tbr.index = 0;
7626    
7627        /* Check PNG signature.  */        /* Check PNG signature.  */
# Line 9030  png_load (f, img) Line 7690  png_load (f, img)
7690    png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,    png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
7691                  &interlace_type, NULL, NULL);                  &interlace_type, NULL, NULL);
7692    
7693    /* If image contains simply transparency data, we prefer to    /* If image contains simply transparency data, we prefer to
7694       construct a clipping mask.  */       construct a clipping mask.  */
7695    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
7696      transparent_p = 1;      transparent_p = 1;
7697    else    else
7698      transparent_p = 0;      transparent_p = 0;
7699    
7700    /* This function is easier to write if we only have to handle    /* This function is easier to write if we only have to handle
7701       one data format: RGB or RGBA with 8 bits per channel.  Let's       one data format: RGB or RGBA with 8 bits per channel.  Let's
7702       transform other formats into that format.  */       transform other formats into that format.  */
7703    
# Line 9050  png_load (f, img) Line 7710  png_load (f, img)
7710    png_set_expand (png_ptr);    png_set_expand (png_ptr);
7711    
7712    /* Convert grayscale images to RGB.  */    /* Convert grayscale images to RGB.  */
7713    if (color_type == PNG_COLOR_TYPE_GRAY    if (color_type == PNG_COLOR_TYPE_GRAY
7714        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
7715      png_set_gray_to_rgb (png_ptr);      png_set_gray_to_rgb (png_ptr);
7716    
7717    screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);    screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
7718    
7719    #if 0 /* Avoid double gamma correction for PNG images. */
7720    /* Tell the PNG lib to handle gamma correction for us.  */    /* Tell the PNG lib to handle gamma correction for us.  */
   
7721  #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)  #if defined(PNG_READ_sRGB_SUPPORTED) || defined(PNG_WRITE_sRGB_SUPPORTED)
7722    if (png_get_sRGB (png_ptr, info_ptr, &intent))    if (png_get_sRGB (png_ptr, info_ptr, &intent))
7723      /* The libpng documentation says this is right in this case.  */      /* The libpng documentation says this is right in this case.  */
# Line 9070  png_load (f, img) Line 7730  png_load (f, img)
7730    else    else
7731      /* Use the standard default for the image gamma.  */      /* Use the standard default for the image gamma.  */
7732      png_set_gamma (png_ptr, screen_gamma, 0.45455);      png_set_gamma (png_ptr, screen_gamma, 0.45455);
7733    #endif /* if 0 */
7734    
7735    /* Handle alpha channel by combining the image with a background    /* Handle alpha channel by combining the image with a background
7736       color.  Do this only if a real alpha channel is supplied.  For       color.  Do this only if a real alpha channel is supplied.  For
# Line 9084  png_load (f, img) Line 7745  png_load (f, img)
7745          /* The user specified `:background', use that.  */          /* The user specified `:background', use that.  */
7746          {          {
7747            XColor color;            XColor color;
7748            if (x_defined_color (f, XSTRING (specified_bg)->data, &color, 0))            if (x_defined_color (f, SDATA (specified_bg), &color, 0))
7749              {              {
7750                png_color_16 user_bg;                png_color_16 user_bg;
7751    
# Line 9098  png_load (f, img) Line 7759  png_load (f, img)
7759              }              }
7760          }          }
7761        else if (png_get_bKGD (png_ptr, info_ptr, &image_bg))        else if (png_get_bKGD (png_ptr, info_ptr, &image_bg))
7762          /* Image contains a background color with which to          /* Image contains a background color with which to
7763             combine the image.  */             combine the image.  */
7764          png_set_background (png_ptr, image_bg,          png_set_background (png_ptr, image_bg,
7765                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
7766        else        else
7767          {          {
7768            /* Image does not contain a background color with which            /* Image does not contain a background color with which
7769               to combine the image data via an alpha channel.  Use               to combine the image data via an alpha channel.  Use
7770               the frame's background instead.  */               the frame's background instead.  */
7771            XColor color;            XColor color;
7772            Colormap cmap;            Colormap cmap;
# Line 9153  png_load (f, img) Line 7814  png_load (f, img)
7814        fclose (fp);        fclose (fp);
7815        fp = NULL;        fp = NULL;
7816      }      }
7817      
7818    /* Create the X image and pixmap.  */    /* Create the X image and pixmap.  */
7819    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
7820                                      &img->pixmap))                                      &img->pixmap))
7821      goto error;      goto error;
7822      
7823    /* Create an image and pixmap serving as mask if the PNG image    /* Create an image and pixmap serving as mask if the PNG image
7824       contains an alpha channel.  */       contains an alpha channel.  */
7825    if (channels == 4    if (channels == 4
# Line 9189  png_load (f, img) Line 7850  png_load (f, img)
7850            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
7851    
7852            /* An alpha channel, aka mask channel, associates variable            /* An alpha channel, aka mask channel, associates variable
7853               transparency with an image.  Where other image formats               transparency with an image.  Where other image formats
7854               support binary transparency---fully transparent or fully               support binary transparency---fully transparent or fully
7855               opaque---PNG allows up to 254 levels of partial transparency.               opaque---PNG allows up to 254 levels of partial transparency.
7856               The PNG library implements partial transparency by combining               The PNG library implements partial transparency by combining
7857               the image with a specified background color.               the image with a specified background color.
7858    
7859               I'm not sure how to handle this here nicely: because the               I'm not sure how to handle this here nicely: because the
7860               background on which the image is displayed may change, for               background on which the image is displayed may change, for
7861               real alpha channel support, it would be necessary to create               real alpha channel support, it would be necessary to create
7862               a new image for each possible background.                 a new image for each possible background.
7863    
7864               What I'm doing now is that a mask is created if we have               What I'm doing now is that a mask is created if we have
7865               boolean transparency information.  Otherwise I'm using               boolean transparency information.  Otherwise I'm using
# Line 9344  jpeg_image_p (object) Line 8005  jpeg_image_p (object)
8005       Lisp_Object object;       Lisp_Object object;
8006  {  {
8007    struct image_keyword fmt[JPEG_LAST];    struct image_keyword fmt[JPEG_LAST];
8008      
8009    bcopy (jpeg_format, fmt, sizeof fmt);    bcopy (jpeg_format, fmt, sizeof fmt);
8010      
8011    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
8012      return 0;      return 0;
8013    
# Line 9417  our_skip_input_data (cinfo, num_bytes) Line 8078  our_skip_input_data (cinfo, num_bytes)
8078      {      {
8079        if (num_bytes > src->bytes_in_buffer)        if (num_bytes > src->bytes_in_buffer)
8080          ERREXIT (cinfo, JERR_INPUT_EOF);          ERREXIT (cinfo, JERR_INPUT_EOF);
8081          
8082        src->bytes_in_buffer -= num_bytes;        src->bytes_in_buffer -= num_bytes;
8083        src->next_input_byte += num_bytes;        src->next_input_byte += num_bytes;
8084      }      }
# Line 9455  jpeg_memory_src (cinfo, data, len) Line 8116  jpeg_memory_src (cinfo, data, len)
8116        src = (struct jpeg_source_mgr *) cinfo->src;        src = (struct jpeg_source_mgr *) cinfo->src;
8117        src->next_input_byte = data;        src->next_input_byte = data;
8118      }      }
8119      
8120    src = (struct jpeg_source_mgr *) cinfo->src;    src = (struct jpeg_source_mgr *) cinfo->src;
8121    src->init_source = our_init_source;    src->init_source = our_init_source;
8122    src->fill_input_buffer = our_fill_input_buffer;    src->fill_input_buffer = our_fill_input_buffer;
# Line 9470  jpeg_memory_src (cinfo, data, len) Line 8131  jpeg_memory_src (cinfo, data, len)
8131  /* Load image IMG for use on frame F.  Patterned after example.c  /* Load image IMG for use on frame F.  Patterned after example.c
8132     from the JPEG lib.  */     from the JPEG lib.  */
8133    
8134  static int  static int
8135  jpeg_load (f, img)  jpeg_load (f, img)
8136       struct frame *f;       struct frame *f;
8137       struct image *img;       struct image *img;
# Line 9503  jpeg_load (f, img) Line 8164  jpeg_load (f, img)
8164            UNGCPRO;            UNGCPRO;
8165            return 0;            return 0;
8166          }          }
8167      
8168        fp = fopen (XSTRING (file)->data, "r");        fp = fopen (SDATA (file), "r");
8169        if (fp == NULL)        if (fp == NULL)
8170          {          {
8171            image_error ("Cannot open `%s'", file, Qnil);            image_error ("Cannot open `%s'", file, Qnil);
# Line 9517  jpeg_load (f, img) Line 8178  jpeg_load (f, img)
8178       error is detected.  This function will perform a longjmp.  */       error is detected.  This function will perform a longjmp.  */
8179    cinfo.err = jpeg_std_error (&mgr.pub);    cinfo.err = jpeg_std_error (&mgr.pub);
8180    mgr.pub.error_exit = my_error_exit;    mgr.pub.error_exit = my_error_exit;
8181      
8182    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
8183      {      {
8184        if (rc == 1)        if (rc == 1)
# Line 9528  jpeg_load (f, img) Line 8189  jpeg_load (f, img)
8189            image_error ("Error reading JPEG image `%s': %s", img->spec,            image_error ("Error reading JPEG image `%s': %s", img->spec,
8190                         build_string (buffer));                         build_string (buffer));
8191          }          }
8192              
8193        /* Close the input file and destroy the JPEG object.  */        /* Close the input file and destroy the JPEG object.  */
8194        if (fp)        if (fp)
8195          fclose ((FILE *) fp);          fclose ((FILE *) fp);
# Line 9539  jpeg_load (f, img) Line 8200  jpeg_load (f, img)
8200    
8201        /* Free pixmap and colors.  */        /* Free pixmap and colors.  */
8202        x_clear_image (f, img);        x_clear_image (f, img);
8203          
8204        UNGCPRO;        UNGCPRO;
8205        return 0;        return 0;
8206      }      }
# Line 9551  jpeg_load (f, img) Line 8212  jpeg_load (f, img)
8212    if (NILP (specified_data))    if (NILP (specified_data))
8213      jpeg_stdio_src (&cinfo, (FILE *) fp);      jpeg_stdio_src (&cinfo, (FILE *) fp);
8214    else    else
8215      jpeg_memory_src (&cinfo, XSTRING (specified_data)->data,      jpeg_memory_src (&cinfo, SDATA (specified_data),
8216                       STRING_BYTES (XSTRING (specified_data)));                       SBYTES (specified_data));
8217    
8218    jpeg_read_header (&cinfo, TRUE);    jpeg_read_header (&cinfo, TRUE);
8219    
# Line 9589  jpeg_load (f, img) Line 8250  jpeg_load (f, img)
8250      init_color_table ();      init_color_table ();
8251      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
8252                                         * sizeof *colors);                                         * sizeof *colors);
8253      
8254      for (i = 0; i < cinfo.actual_number_of_colors; ++i)      for (i = 0; i < cinfo.actual_number_of_colors; ++i)
8255        {        {
8256          /* Multiply RGB values with 255 because X expects RGB values          /* Multiply RGB values with 255 because X expects RGB values
# Line 9625  jpeg_load (f, img) Line 8286  jpeg_load (f, img)
8286    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
8287    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8288      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
8289      
8290    /* Put the image into the pixmap.  */    /* Put the image into the pixmap.  */
8291    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
8292    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 9706  tiff_image_p (object) Line 8367  tiff_image_p (object)
8367  {  {
8368    struct image_keyword fmt[TIFF_LAST];    struct image_keyword fmt[TIFF_LAST];
8369    bcopy (tiff_format, fmt, sizeof fmt);    bcopy (tiff_format, fmt, sizeof fmt);
8370      
8371    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
8372      return 0;      return 0;
8373      
8374    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
8375    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
8376  }  }
# Line 9773  tiff_seek_in_memory (data, off, whence) Line 8434  tiff_seek_in_memory (data, off, whence)
8434      case SEEK_SET:              /* Go from beginning of source.  */      case SEEK_SET:              /* Go from beginning of source.  */
8435        idx = off;        idx = off;
8436        break;        break;
8437          
8438      case SEEK_END:              /* Go from end of source.  */      case SEEK_END:              /* Go from end of source.  */
8439        idx = src->len + off;        idx = src->len + off;
8440        break;        break;
8441          
8442      case SEEK_CUR:              /* Go from current position.  */      case SEEK_CUR:              /* Go from current position.  */
8443        idx = src->index + off;        idx = src->index + off;
8444        break;        break;
8445          
8446      default:                    /* Invalid `whence'.   */      default:                    /* Invalid `whence'.   */
8447        return -1;        return -1;
8448      }      }
8449      
8450    if (idx > src->len || idx < 0)    if (idx > src->len || idx < 0)
8451      return -1;      return -1;
8452      
8453    src->index = idx;    src->index = idx;
8454    return src->index;    return src->index;
8455  }  }
# Line 9839  tiff_error_handler (title, format, ap) Line 8500  tiff_error_handler (title, format, ap)
8500  {  {
8501    char buf[512];    char buf[512];
8502    int len;    int len;
8503      
8504    len = sprintf (buf, "TIFF error: %s ", title);    len = sprintf (buf, "TIFF error: %s ", title);
8505    vsprintf (buf + len, format, ap);    vsprintf (buf + len, format, ap);
8506    add_to_log (buf, Qnil, Qnil);    add_to_log (buf, Qnil, Qnil);
# Line 9853  tiff_warning_handler (title, format, ap) Line 8514  tiff_warning_handler (title, format, ap)
8514  {  {
8515    char buf[512];    char buf[512];
8516    int len;    int len;
8517      
8518    len = sprintf (buf, "TIFF warning: %s ", title);    len = sprintf (buf, "TIFF warning: %s ", title);
8519    vsprintf (buf + len, format, ap);    vsprintf (buf + len, format, ap);
8520    add_to_log (buf, Qnil, Qnil);    add_to_log (buf, Qnil, Qnil);
# Line 9896  tiff_load (f, img) Line 8557  tiff_load (f, img)
8557            UNGCPRO;            UNGCPRO;
8558            return 0;            return 0;
8559          }          }
8560              
8561        /* Try to open the image file.  */        /* Try to open the image file.  */
8562        tiff = TIFFOpen (XSTRING (file)->data, "r");        tiff = TIFFOpen (SDATA (file), "r");
8563        if (tiff == NULL)        if (tiff == NULL)
8564          {          {
8565            image_error ("Cannot open `%s'", file, Qnil);            image_error ("Cannot open `%s'", file, Qnil);
# Line 9909  tiff_load (f, img) Line 8570  tiff_load (f, img)
8570    else    else
8571      {      {
8572        /* Memory source! */        /* Memory source! */
8573        memsrc.bytes = XSTRING (specified_data)->data;        memsrc.bytes = SDATA (specified_data);
8574        memsrc.len = STRING_BYTES (XSTRING (specified_data));        memsrc.len = SBYTES (specified_data);
8575        memsrc.index = 0;        memsrc.index = 0;
8576    
8577        tiff = TIFFClientOpen ("memory_source", "r", &memsrc,        tiff = TIFFClientOpen ("memory_source", "r", &memsrc,
# Line 9935  tiff_load (f, img) Line 8596  tiff_load (f, img)
8596    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
8597    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
8598    buf = (uint32 *) xmalloc (width * height * sizeof *buf);    buf = (uint32 *) xmalloc (width * height * sizeof *buf);
8599      
8600    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
8601    TIFFClose (tiff);    TIFFClose (tiff);
8602    if (!rc)    if (!rc)
# Line 9961  tiff_load (f, img) Line 8622  tiff_load (f, img)
8622    for (y = 0; y < height; ++y)    for (y = 0; y < height; ++y)
8623      {      {
8624        uint32 *row = buf + y * width;        uint32 *row = buf + y * width;
8625          
8626        for (x = 0; x < width; ++x)        for (x = 0; x < width; ++x)
8627          {          {
8628            uint32 abgr = row[x];            uint32 abgr = row[x];
8629            int r = TIFFGetR (abgr) << 8;            int r = TIFFGetR (abgr) << 8;
8630            int g = TIFFGetG (abgr) << 8;            int g = TIFFGetG (abgr) << 8;
8631            int b = TIFFGetB (abgr) << 8;            int b = TIFFGetB (abgr) << 8;
8632            XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));            XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
8633          }          }
8634      }      }
8635    
8636    /* Remember the colors allocated for the image.  Free the color table.  */    /* Remember the colors allocated for the image.  Free the color table.  */
8637    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
8638    free_color_table ();    free_color_table ();
8639          
8640    img->width = width;    img->width = width;
8641    img->height = height;    img->height = height;
8642    
# Line 10067  gif_image_p (object) Line 8728  gif_image_p (object)
8728  {  {
8729    struct image_keyword fmt[GIF_LAST];    struct image_keyword fmt[GIF_LAST];
8730    bcopy (gif_format, fmt, sizeof fmt);    bcopy (gif_format, fmt, sizeof fmt);
8731      
8732    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
8733      return 0;      return 0;
8734      
8735    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
8736    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
8737  }  }
# Line 10145  gif_load (f, img) Line 8806  gif_load (f, img)
8806            UNGCPRO;            UNGCPRO;
8807            return 0;            return 0;
8808          }          }
8809      
8810        /* Open the GIF file.  */        /* Open the GIF file.  */
8811        gif = DGifOpenFileName (XSTRING (file)->data);        gif = DGifOpenFileName (SDATA (file));
8812        if (gif == NULL)        if (gif == NULL)
8813          {          {
8814            image_error ("Cannot open `%s'", file, Qnil);            image_error ("Cannot open `%s'", file, Qnil);
# Line 10159  gif_load (f, img) Line 8820  gif_load (f, img)
8820      {      {
8821        /* Read from memory! */        /* Read from memory! */
8822        current_gif_memory_src = &memsrc;        current_gif_memory_src = &memsrc;
8823        memsrc.bytes = XSTRING (specified_data)->data;        memsrc.bytes = SDATA (specified_data);
8824        memsrc.len = STRING_BYTES (XSTRING (specified_data));        memsrc.len = SBYTES (specified_data);
8825        memsrc.index = 0;        memsrc.index = 0;
8826    
8827        gif = DGifOpen(&memsrc, gif_read_from_memory);        gif = DGifOpen(&memsrc, gif_read_from_memory);
# Line 10203  gif_load (f, img) Line 8864  gif_load (f, img)
8864        UNGCPRO;        UNGCPRO;
8865        return 0;        return 0;
8866      }      }
8867      
8868    /* Allocate colors.  */    /* Allocate colors.  */
8869    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
8870    if (!gif_color_map)    if (!gif_color_map)
8871      gif_color_map = gif->SColorMap;      gif_color_map = gif->SColorMap;
8872    init_color_table ();    init_color_table ();
8873    bzero (pixel_colors, sizeof pixel_colors);    bzero (pixel_colors, sizeof pixel_colors);
8874      
8875    for (i = 0; i < gif_color_map->ColorCount; ++i)    for (i = 0; i < gif_color_map->ColorCount; ++i)
8876      {      {
8877        int r = gif_color_map->Colors[i].Red << 8;        int r = gif_color_map->Colors[i].Red << 8;
# Line 10223  gif_load (f, img) Line 8884  gif_load (f, img)
8884    free_color_table ();    free_color_table ();
8885    
8886    /* Clear the part of the screen image that are not covered by    /* Clear the part of the screen image that are not covered by
8887       the image from the GIF file.  Full animated GIF support       the image from the GIF file.  Full animated GIF support
8888       requires more than can be done here (see the gif89 spec,       requires more than can be done here (see the gif89 spec,
8889       disposal methods).  Let's simply assume that the part       disposal methods).  Let's simply assume that the part
8890       not covered by a sub-image is in the frame's background color.  */       not covered by a sub-image is in the frame's background color.  */
# Line 10252  gif_load (f, img) Line 8913  gif_load (f, img)
8913       `raster' here because RasterBits below is a char *, and invites       `raster' here because RasterBits below is a char *, and invites
8914       problems with bytes >= 0x80.  */       problems with bytes >= 0x80.  */
8915    raster = (unsigned char *) gif->SavedImages[ino].RasterBits;    raster = (unsigned char *) gif->SavedImages[ino].RasterBits;
8916      
8917    if (gif->SavedImages[ino].ImageDesc.Interlace)    if (gif->SavedImages[ino].ImageDesc.Interlace)
8918      {      {
8919        static int interlace_start[] = {0, 4, 2, 1};        static int interlace_start[] = {0, 4, 2, 1};
# Line 10270  gif_load (f, img) Line 8931  gif_load (f, img)
8931                while (row >= image_height)                while (row >= image_height)
8932                  row = interlace_start[++pass];                  row = interlace_start[++pass];
8933              }              }
8934              
8935            for (x = 0; x < image_width; x++)            for (x = 0; x < image_width; x++)
8936              {              {
8937                int i = raster[(y * image_width) + x];                int i = raster[(y * image_width) + x];
8938                XPutPixel (ximg, x + image_left, row + image_top,                XPutPixel (ximg, x + image_left, row + image_top,
8939                           pixel_colors[i]);                           pixel_colors[i]);
8940              }              }
8941              
8942            row += interlace_increment[pass];            row += interlace_increment[pass];
8943          }          }
8944      }      }
# Line 10290  gif_load (f, img) Line 8951  gif_load (f, img)
8951              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
8952            }            }
8953      }      }
8954      
8955    DGifCloseFile (gif);    DGifCloseFile (gif);
8956    
8957    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
8958    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8959      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
8960      
8961    /* Put the image into the pixmap, then free the X image and its buffer.  */    /* Put the image into the pixmap, then free the X image and its buffer.  */
8962    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
8963    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
8964          
8965    UNGCPRO;    UNGCPRO;
8966    return 1;    return 1;
8967  }  }
# Line 10400  gs_image_p (object) Line 9061  gs_image_p (object)
9061    struct image_keyword fmt[GS_LAST];    struct image_keyword fmt[GS_LAST];
9062    Lisp_Object tem;    Lisp_Object tem;
9063    int i;    int i;
9064      
9065    bcopy (gs_format, fmt, sizeof fmt);    bcopy (gs_format, fmt, sizeof fmt);
9066      
9067    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
9068      return 0;      return 0;
9069    
# Line 10468  gs_load (f, img) Line 9129  gs_load (f, img)
9129        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
9130        return 0;        return 0;
9131      }      }
9132        
9133    /* Call the loader to fill the pixmap.  It returns a process object    /* Call the loader to fill the pixmap.  It returns a process object
9134       if successful.  We do not record_unwind_protect here because       if successful.  We do not record_unwind_protect here because
9135       other places in redisplay like calling window scroll functions       other places in redisplay like calling window scroll functions
# Line 10479  gs_load (f, img) Line 9140  gs_load (f, img)
9140             (unsigned long) FRAME_X_WINDOW (f),             (unsigned long) FRAME_X_WINDOW (f),
9141             (unsigned long) img->pixmap);             (unsigned long) img->pixmap);
9142    window_and_pixmap_id = build_string (buffer);    window_and_pixmap_id = build_string (buffer);
9143      
9144    sprintf (buffer, "%lu %lu",    sprintf (buffer, "%lu %lu",
9145             FRAME_FOREGROUND_PIXEL (f),             FRAME_FOREGROUND_PIXEL (f),
9146             FRAME_BACKGROUND_PIXEL (f));             FRAME_BACKGROUND_PIXEL (f));
9147    pixel_colors = build_string (buffer);    pixel_colors = build_string (buffer);
9148      
9149    XSETFRAME (frame, f);    XSETFRAME (frame, f);
9150    loader = image_spec_value (img->spec, QCloader, NULL);    loader = image_spec_value (img->spec, QCloader, NULL);
9151    if (NILP (loader))    if (NILP (loader))
# Line 10522  x_kill_gs_process (pixmap, f) Line 9183  x_kill_gs_process (pixmap, f)
9183       instance, give up.  */       instance, give up.  */
9184    if (i == c->used)    if (i == c->used)
9185      return;      return;
9186      
9187    /* Kill the GS process.  We should have found PIXMAP in the image    /* Kill the GS process.  We should have found PIXMAP in the image
9188       cache and its image should contain a process object.  */       cache and its image should contain a process object.  */
9189    img = c->images[i];    img = c->images[i];
# Line 10546  x_kill_gs_process (pixmap, f) Line 9207  x_kill_gs_process (pixmap, f)
9207        if (ximg)        if (ximg)
9208          {          {
9209            int x, y;            int x, y;
9210              
9211            /* Initialize the color table.  */            /* Initialize the color table.  */
9212            init_color_table ();            init_color_table ();
9213          
9214            /* For each pixel of the image, look its color up in the            /* For each pixel of the image, look its color up in the
9215               color table.  After having done so, the color table will               color table.  After having done so, the color table will
9216               contain an entry for each color used by the image.  */               contain an entry for each color used by the image.  */
# Line 10578  x_kill_gs_process (pixmap, f) Line 9239  x_kill_gs_process (pixmap, f)
9239        else        else
9240          image_error ("Cannot get X image of `%s'; colors will not be freed",          image_error ("Cannot get X image of `%s'; colors will not be freed",
9241                       img->spec, Qnil);                       img->spec, Qnil);
9242          
9243        UNBLOCK_INPUT;        UNBLOCK_INPUT;
9244      }      }
9245    
# Line 10610  selected frame.  Value is VALUE.  */) Line 9271  selected frame.  Value is VALUE.  */)
9271    CHECK_STRING (value);    CHECK_STRING (value);
9272    
9273    BLOCK_INPUT;    BLOCK_INPUT;
9274    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
9275    XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),    XChangeProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9276                     prop_atom, XA_STRING, 8, PropModeReplace,                     prop_atom, XA_STRING, 8, PropModeReplace,
9277                     XSTRING (value)->data, XSTRING (value)->size);                     SDATA (value), SCHARS (value));
9278    
9279    /* Make sure the property is set when we return.  */    /* Make sure the property is set when we return.  */
9280    XFlush (FRAME_X_DISPLAY (f));    XFlush (FRAME_X_DISPLAY (f));
# Line 10635  FRAME nil or omitted means use the selec Line 9296  FRAME nil or omitted means use the selec
9296    
9297    CHECK_STRING (prop);    CHECK_STRING (prop);
9298    BLOCK_INPUT;    BLOCK_INPUT;
9299    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
9300    XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom);    XDeleteProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), prop_atom);
9301    
9302    /* Make sure the property is removed when we return.  */    /* Make sure the property is removed when we return.  */
# Line 10666  value.  */) Line 9327  value.  */)
9327    
9328    CHECK_STRING (prop);    CHECK_STRING (prop);
9329    BLOCK_INPUT;    BLOCK_INPUT;
9330    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), XSTRING (prop)->data, False);    prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SDATA (prop), False);
9331    rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),    rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9332                             prop_atom, 0, 0, False, XA_STRING,                             prop_atom, 0, 0, False, XA_STRING,
9333                             &actual_type, &actual_format, &actual_size,                             &actual_type, &actual_format, &actual_size,
# Line 10681  value.  */) Line 9342  value.  */)
9342        rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
9343                                 prop_atom, 0, bytes_remaining,                                 prop_atom, 0, bytes_remaining,
9344                                 False, XA_STRING,                                 False, XA_STRING,
9345                                 &actual_type, &actual_format,                                 &actual_type, &actual_format,
9346                                 &actual_size, &bytes_remaining,                                 &actual_size, &bytes_remaining,
9347                                 (unsigned char **) &tmp_data);                                 (unsigned char **) &tmp_data);
9348        if (rc == Success && tmp_data)        if (rc == Success && tmp_data)
9349          prop_value = make_string (tmp_data, size);          prop_value = make_string (tmp_data, size);
# Line 10731  start_hourglass () Line 9392  start_hourglass ()
9392  {  {
9393    EMACS_TIME delay;    EMACS_TIME delay;
9394    int secs, usecs = 0;    int secs, usecs = 0;
9395      
9396    cancel_hourglass ();    cancel_hourglass ();
9397    
9398    if (INTEGERP (Vhourglass_delay)    if (INTEGERP (Vhourglass_delay)
# Line 10747  start_hourglass () Line 9408  start_hourglass ()
9408      }      }
9409    else    else
9410      secs = DEFAULT_HOURGLASS_DELAY;      secs = DEFAULT_HOURGLASS_DELAY;
9411      
9412    EMACS_SET_SECS_USECS (delay, secs, usecs);    EMACS_SET_SECS_USECS (delay, secs, usecs);
9413    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
9414                                       show_hourglass, NULL);                                       show_hourglass, NULL);
# Line 10765  cancel_hourglass () Line 9426  cancel_hourglass ()
9426        cancel_atimer (hourglass_atimer);        cancel_atimer (hourglass_atimer);
9427        hourglass_atimer = NULL;        hourglass_atimer = NULL;
9428      }      }
9429      
9430    if (hourglass_shown_p)    if (hourglass_shown_p)
9431      hide_hourglass ();      hide_hourglass ();
9432  }  }
# Line 10791  show_hourglass (timer) Line 9452  show_hourglass (timer)
9452    if (!hourglass_shown_p)    if (!hourglass_shown_p)
9453      {      {
9454        Lisp_Object rest, frame;        Lisp_Object rest, frame;
9455      
9456        BLOCK_INPUT;        BLOCK_INPUT;
9457      
9458        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
9459          {          {
9460            struct frame *f = XFRAME (frame);            struct frame *f = XFRAME (frame);
9461              
9462            if (FRAME_LIVE_P (f) && FRAME_X_P (f) && FRAME_X_DISPLAY (f))            if (FRAME_LIVE_P (f) && FRAME_X_P (f) && FRAME_X_DISPLAY (f))
9463              {              {
9464                Display *dpy = FRAME_X_DISPLAY (f);                Display *dpy = FRAME_X_DISPLAY (f);
9465                  
9466  #ifdef USE_X_TOOLKIT  #ifdef USE_X_TOOLKIT
9467                if (f->output_data.x->widget)                if (f->output_data.x->widget)
9468  #else  #else
# Line 10809  show_hourglass (timer) Line 9470  show_hourglass (timer)
9470  #endif  #endif
9471                  {                  {
9472                    f->output_data.x->hourglass_p = 1;                    f->output_data.x->hourglass_p = 1;
9473            
9474                    if (!f->output_data.x->hourglass_window)                    if (!f->output_data.x->hourglass_window)
9475                      {                      {
9476                        unsigned long mask = CWCursor;                        unsigned long mask = CWCursor;
9477                        XSetWindowAttributes attrs;                        XSetWindowAttributes attrs;
9478                
9479                        attrs.cursor = f->output_data.x->hourglass_cursor;                        attrs.cursor = f->output_data.x->hourglass_cursor;
9480                
9481                        f->output_data.x->hourglass_window                        f->output_data.x->hourglass_window
9482                          = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f),                          = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f),
9483                                           0, 0, 32000, 32000, 0, 0,                                           0, 0, 32000, 32000, 0, 0,
# Line 10824  show_hourglass (timer) Line 9485  show_hourglass (timer)
9485                                           CopyFromParent,                                           CopyFromParent,
9486                                           mask, &attrs);                                           mask, &attrs);
9487                      }                      }
9488            
9489                    XMapRaised (dpy, f->output_data.x->hourglass_window);                    XMapRaised (dpy, f->output_data.x->hourglass_window);
9490                    XFlush (dpy);                    XFlush (dpy);
9491                  }                  }
# Line 10851  hide_hourglass () Line 9512  hide_hourglass ()
9512        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
9513          {          {
9514            struct frame *f = XFRAME (frame);            struct frame *f = XFRAME (frame);
9515          
9516            if (FRAME_X_P (f)            if (FRAME_X_P (f)
9517                /* Watch out for newly created frames.  */                /* Watch out for newly created frames.  */
9518                && f->output_data.x->hourglass_window)                && f->output_data.x->hourglass_window)
# Line 10880  static Lisp_Object x_create_tip_frame P_ Line 9541  static Lisp_Object x_create_tip_frame P_
9541                                             Lisp_Object, Lisp_Object));                                             Lisp_Object, Lisp_Object));
9542  static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,  static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
9543                                  Lisp_Object, int, int, int *, int *));                                  Lisp_Object, int, int, int *, int *));
9544        
9545  /* The frame of a currently visible tooltip.  */  /* The frame of a currently visible tooltip.  */
9546    
9547  Lisp_Object tip_frame;  Lisp_Object tip_frame;
# Line 10913  unwind_create_tip_frame (frame) Line 9574  unwind_create_tip_frame (frame)
9574        tip_window = None;        tip_window = None;
9575        tip_frame = Qnil;        tip_frame = Qnil;
9576      }      }
9577      
9578    return deleted;    return deleted;
9579  }  }
9580    
# Line 10937  x_create_tip_frame (dpyinfo, parms, text Line 9598  x_create_tip_frame (dpyinfo, parms, text
9598    Lisp_Object name;    Lisp_Object name;
9599    long window_prompting = 0;    long window_prompting = 0;
9600    int width, height;    int width, height;
9601    int count = BINDING_STACK_SIZE ();    int count = SPECPDL_INDEX ();
9602    struct gcpro gcpro1, gcpro2, gcpro3;    struct gcpro gcpro1, gcpro2, gcpro3;
9603    struct kboard *kb;    struct kboard *kb;
9604    int face_change_count_before = face_change_count;    int face_change_count_before = face_change_count;
# Line 10977  x_create_tip_frame (dpyinfo, parms, text Line 9638  x_create_tip_frame (dpyinfo, parms, text
9638    Ferase_buffer ();    Ferase_buffer ();
9639    Finsert (1, &text);    Finsert (1, &text);
9640    set_buffer_internal_1 (old_buffer);    set_buffer_internal_1 (old_buffer);
9641      
9642    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
9643    record_unwind_protect (unwind_create_tip_frame, frame);    record_unwind_protect (unwind_create_tip_frame, frame);
9644    
# Line 11013  x_create_tip_frame (dpyinfo, parms, text Line 9674  x_create_tip_frame (dpyinfo, parms, text
9674    {    {
9675      Lisp_Object black;      Lisp_Object black;
9676      struct gcpro gcpro1;      struct gcpro gcpro1;
9677        
9678      black = build_string ("black");      black = build_string ("black");
9679      GCPRO1 (black);      GCPRO1 (black);
9680      f->output_data.x->foreground_pixel      f->output_data.x->foreground_pixel
# Line 11059  x_create_tip_frame (dpyinfo, parms, text Line 9720  x_create_tip_frame (dpyinfo, parms, text
9720        {        {
9721          tem = Fquery_fontset (font, Qnil);          tem = Fquery_fontset (font, Qnil);
9722          if (STRINGP (tem))          if (STRINGP (tem))
9723            font = x_new_fontset (f, XSTRING (tem)->data);            font = x_new_fontset (f, SDATA (tem));
9724          else          else
9725            font = x_new_font (f, XSTRING (font)->data);            font = x_new_font (f, SDATA (font));
9726        }        }
9727        
9728      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
9729      if (!STRINGP (font))      if (!STRINGP (font))
9730        font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");        font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
# Line 11088  x_create_tip_frame (dpyinfo, parms, text Line 9749  x_create_tip_frame (dpyinfo, parms, text
9749    
9750    x_default_parameter (f, parms, Qborder_width, make_number (2),    x_default_parameter (f, parms, Qborder_width, make_number (2),
9751                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
9752      
9753    /* This defaults to 2 in order to match xterm.  We recognize either    /* This defaults to 2 in order to match xterm.  We recognize either
9754       internalBorderWidth or internalBorder (which is what xterm calls       internalBorderWidth or internalBorder (which is what xterm calls
9755       it).  */       it).  */
# Line 11126  x_create_tip_frame (dpyinfo, parms, text Line 9787  x_create_tip_frame (dpyinfo, parms, text
9787       end up in init_iterator with a null face cache, which should not       end up in init_iterator with a null face cache, which should not
9788       happen.  */       happen.  */
9789    init_frame_faces (f);    init_frame_faces (f);
9790      
9791    f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;    f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
   window_prompting = x_figure_window_size (f, parms);  
9792    
9793    if (window_prompting & XNegative)    window_prompting = x_figure_window_size (f, parms, 0);
     {  
       if (window_prompting & YNegative)  
         f->output_data.x->win_gravity = SouthEastGravity;  
       else  
         f->output_data.x->win_gravity = NorthEastGravity;  
     }  
   else  
     {  
       if (window_prompting & YNegative)  
         f->output_data.x->win_gravity = SouthWestGravity;  
       else  
         f->output_data.x->win_gravity = NorthWestGravity;  
     }  
9794    
   f->output_data.x->size_hint_flags = window_prompting;  
9795    {    {
9796      XSetWindowAttributes attrs;      XSetWindowAttributes attrs;
9797      unsigned long mask;      unsigned long mask;
9798        
9799      BLOCK_INPUT;      BLOCK_INPUT;
9800      mask = CWBackPixel | CWOverrideRedirect | CWEventMask;      mask = CWBackPixel | CWOverrideRedirect | CWEventMask;
9801      if (DoesSaveUnders (dpyinfo->screen))      if (DoesSaveUnders (dpyinfo->screen))
9802        mask |= CWSaveUnder;        mask |= CWSaveUnder;
9803        
9804      /* Window managers look at the override-redirect flag to determine      /* Window managers look at the override-redirect flag to determine
9805         whether or net to give windows a decoration (Xlib spec, chapter         whether or net to give windows a decoration (Xlib spec, chapter
9806         3.2.8).  */         3.2.8).  */
# Line 11194  x_create_tip_frame (dpyinfo, parms, text Line 9840  x_create_tip_frame (dpyinfo, parms, text
9840    SET_FRAME_WIDTH (f, 0);    SET_FRAME_WIDTH (f, 0);
9841    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
9842    
9843      /* Add `tooltip' frame parameter's default value. */
9844      if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
9845        Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
9846                                                Qnil));
9847    
9848    /* Set up faces after all frame parameters are known.  This call    /* Set up faces after all frame parameters are known.  This call
9849       also merges in face attributes specified for new frames.       also merges in face attributes specified for new frames.
9850    
# Line 11208  x_create_tip_frame (dpyinfo, parms, text Line 9859  x_create_tip_frame (dpyinfo, parms, text
9859      /* Set tip_frame here, so that */      /* Set tip_frame here, so that */
9860      tip_frame = frame;      tip_frame = frame;
9861      call1 (Qface_set_after_frame_default, frame);      call1 (Qface_set_after_frame_default, frame);
9862        
9863      if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))      if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
9864        Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),        Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
9865                                                Qnil));                                                Qnil));
9866    }    }
9867      
9868    f->no_split = 1;    f->no_split = 1;
9869    
9870    UNGCPRO;    UNGCPRO;
# Line 11256  compute_tip_xy (f, parms, dx, dy, width, Line 9907  compute_tip_xy (f, parms, dx, dy, width,
9907    int win_x, win_y;    int win_x, win_y;
9908    Window root, child;    Window root, child;
9909    unsigned pmask;    unsigned pmask;
9910      
9911    /* User-specified position?  */    /* User-specified position?  */
9912    left = Fcdr (Fassq (Qleft, parms));    left = Fcdr (Fassq (Qleft, parms));
9913    top  = Fcdr (Fassq (Qtop, parms));    top  = Fcdr (Fassq (Qtop, parms));
9914      
9915    /* Move the tooltip window where the mouse pointer is.  Resize and    /* Move the tooltip window where the mouse pointer is.  Resize and
9916       show it.  */       show it.  */
9917    if (!INTEGERP (left) || !INTEGERP (top))    if (!INTEGERP (left) || !INTEGERP (top))
# Line 11328  Text larger than the specified size is c Line 9979  Text larger than the specified size is c
9979    int i, width, height;    int i, width, height;
9980    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
9981    int old_windows_or_buffers_changed = windows_or_buffers_changed;    int old_windows_or_buffers_changed = windows_or_buffers_changed;
9982    int count = BINDING_STACK_SIZE ();    int count = SPECPDL_INDEX ();
9983      
9984    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
9985    
9986    GCPRO4 (string, parms, frame, timeout);    GCPRO4 (string, parms, frame, timeout);
# Line 11340  Text larger than the specified size is c Line 9991  Text larger than the specified size is c
9991      timeout = make_number (5);      timeout = make_number (5);
9992    else    else
9993      CHECK_NATNUM (timeout);      CHECK_NATNUM (timeout);
9994      
9995    if (NILP (dx))    if (NILP (dx))
9996      dx = make_number (5);      dx = make_number (5);
9997    else    else
9998      CHECK_NUMBER (dx);      CHECK_NUMBER (dx);
9999      
10000    if (NILP (dy))    if (NILP (dy))
10001      dy = make_number (-10);      dy = make_number (-10);
10002    else    else
# Line 11365  Text larger than the specified size is c Line 10016  Text larger than the specified size is c
10016            && !NILP (Fequal (last_parms, parms)))            && !NILP (Fequal (last_parms, parms)))
10017          {          {
10018            struct frame *f = XFRAME (tip_frame);            struct frame *f = XFRAME (tip_frame);
10019              
10020            /* Only DX and DY have changed.  */            /* Only DX and DY have changed.  */
10021            if (!NILP (tip_timer))            if (!NILP (tip_timer))
10022              {              {
# Line 11412  Text larger than the specified size is c Line 10063  Text larger than the specified size is c
10063    /* Set up the frame's root window.  */    /* Set up the frame's root window.  */
10064    w = XWINDOW (FRAME_ROOT_WINDOW (f));    w = XWINDOW (FRAME_ROOT_WINDOW (f));
10065    w->left = w->top = make_number (0);    w->left = w->top = make_number (0);
10066      
10067    if (CONSP (Vx_max_tooltip_size)    if (CONSP (Vx_max_tooltip_size)
10068        && INTEGERP (XCAR (Vx_max_tooltip_size))        && INTEGERP (XCAR (Vx_max_tooltip_size))
10069        && XINT (XCAR (Vx_max_tooltip_size)) > 0        && XINT (XCAR (Vx_max_tooltip_size)) > 0
# Line 11427  Text larger than the specified size is c Line 10078  Text larger than the specified size is c
10078        w->width = make_number (80);        w->width = make_number (80);
10079        w->height = make_number (40);        w->height = make_number (40);
10080      }      }
10081      
10082    f->window_width = XINT (w->width);    f->window_width = XINT (w->width);
10083    adjust_glyphs (f);    adjust_glyphs (f);
10084    w->pseudo_window_p = 1;    w->pseudo_window_p = 1;
# Line 11465  Text larger than the specified size is c Line 10116  Text larger than the specified size is c
10116          }          }
10117        else        else
10118          row_width = row->pixel_width;          row_width = row->pixel_width;
10119          
10120        height += row->height;        height += row->height;
10121        width = max (width, row_width);        width = max (width, row_width);
10122      }      }
# Line 11484  Text larger than the specified size is c Line 10135  Text larger than the specified size is c
10135                       root_x, root_y, width, height);                       root_x, root_y, width, height);
10136    XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));    XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
10137    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10138      
10139    /* Draw into the window.  */    /* Draw into the window.  */
10140    w->must_be_updated_p = 1;    w->must_be_updated_p = 1;
10141    update_single_window (w, 1);    update_single_window (w, 1);
# Line 11515  Value is t if tooltip was open, nil othe Line 10166  Value is t if tooltip was open, nil othe
10166    /* Return quickly if nothing to do.  */    /* Return quickly if nothing to do.  */
10167    if (NILP (tip_timer) && NILP (tip_frame))    if (NILP (tip_timer) && NILP (tip_frame))
10168      return Qnil;      return Qnil;
10169      
10170    frame = tip_frame;    frame = tip_frame;
10171    timer = tip_timer;    timer = tip_timer;
10172    GCPRO2 (frame, timer);    GCPRO2 (frame, timer);
10173    tip_frame = tip_timer = deleted = Qnil;    tip_frame = tip_timer = deleted = Qnil;
10174      
10175    count = BINDING_STACK_SIZE ();    count = SPECPDL_INDEX ();
10176    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
10177    specbind (Qinhibit_quit, Qt);    specbind (Qinhibit_quit, Qt);
10178      
10179    if (!NILP (timer))    if (!NILP (timer))
10180      call1 (Qcancel_timer, timer);      call1 (Qcancel_timer, timer);
10181    
# Line 11610  selection dialog's entry field, if MUSTM Line 10261  selection dialog's entry field, if MUSTM
10261    int ac = 0;    int ac = 0;
10262    extern XtAppContext Xt_app_con;    extern XtAppContext Xt_app_con;
10263    XmString dir_xmstring, pattern_xmstring;    XmString dir_xmstring, pattern_xmstring;
10264    int count = specpdl_ptr - specpdl;    int count = SPECPDL_INDEX ();
10265    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
10266    
10267    GCPRO5 (prompt, dir, default_filename, mustmatch, file);    GCPRO5 (prompt, dir, default_filename, mustmatch, file);
# Line 11625  selection dialog's entry field, if MUSTM Line 10276  selection dialog's entry field, if MUSTM
10276    /* Create the dialog with PROMPT as title, using DIR as initial    /* Create the dialog with PROMPT as title, using DIR as initial
10277       directory and using "*" as pattern.  */       directory and using "*" as pattern.  */
10278    dir = Fexpand_file_name (dir, Qnil);    dir = Fexpand_file_name (dir, Qnil);
10279    dir_xmstring = XmStringCreateLocalized (XSTRING (dir)->data);    dir_xmstring = XmStringCreateLocalized (SDATA (dir));
10280    pattern_xmstring = XmStringCreateLocalized ("*");    pattern_xmstring = XmStringCreateLocalized ("*");
10281        
10282    XtSetArg (al[ac], XmNtitle, XSTRING (prompt)->data); ++ac;    XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac;
10283    XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;    XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;
10284    XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;    XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;
10285    XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac;    XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac;
# Line 11650  selection dialog's entry field, if MUSTM Line 10301  selection dialog's entry field, if MUSTM
10301    help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);    help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
10302    XtSetSensitive (help, False);    XtSetSensitive (help, False);
10303    
10304    /* Mark OK button as default.  */    /* Mark OK button as default.  */
10305    XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),    XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
10306                   XmNshowAsDefault, True, NULL);                   XmNshowAsDefault, True, NULL);
10307    
# Line 11679  selection dialog's entry field, if MUSTM Line 10330  selection dialog's entry field, if MUSTM
10330        int item_pos;        int item_pos;
10331    
10332        default_xmstring        default_xmstring
10333          = XmStringCreateLocalized (XSTRING (default_filename)->data);          = XmStringCreateLocalized (SDATA (default_filename));
10334    
10335        if (!XmListItemExists (list, default_xmstring))        if (!XmListItemExists (list, default_xmstring))
10336          {          {
# Line 11696  selection dialog's entry field, if MUSTM Line 10347  selection dialog's entry field, if MUSTM
10347        XmListSetPos (list, item_pos);        XmListSetPos (list, item_pos);
10348      }      }
10349    
10350    /* Process events until the user presses Cancel or OK.  Block    /* Process events until the user presses Cancel or OK.  */
      and unblock input here so that we get a chance of processing  
      expose events.  */  
   UNBLOCK_INPUT;  
10351    result = 0;    result = 0;
10352    while (result == 0)    while (result == 0)
10353      {      {
10354        BLOCK_INPUT;        XEvent event;
10355        XtAppProcessEvent (Xt_app_con, XtIMAll);        XtAppNextEvent (Xt_app_con, &event);
10356        UNBLOCK_INPUT;        (void) x_dispatch_event (&event, FRAME_X_DISPLAY (f) );
10357      }      }
   BLOCK_INPUT;  
10358    
10359    /* Get the result.  */    /* Get the result.  */
10360    if (result == XmCR_OK)    if (result == XmCR_OK)
10361      {      {
10362        XmString text;        XmString text;
10363        String data;        String data;
10364          
10365        XtVaGetValues (dialog, XmNtextString, &text, NULL);        XtVaGetValues (dialog, XmNtextString, &text, NULL);
10366        XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);        XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);
10367        XmStringFree (text);        XmStringFree (text);
# Line 11733  selection dialog's entry field, if MUSTM Line 10380  selection dialog's entry field, if MUSTM
10380    /* Make "Cancel" equivalent to C-g.  */    /* Make "Cancel" equivalent to C-g.  */
10381    if (NILP (file))    if (NILP (file))
10382      Fsignal (Qquit, Qnil);      Fsignal (Qquit, Qnil);
10383      
10384    return unbind_to (count, file);    return unbind_to (count, file);
10385  }  }
10386    
10387  #endif /* USE_MOTIF */  #endif /* USE_MOTIF */
10388    
10389    #ifdef USE_GTK
10390    
10391    DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,
10392      "Read file name, prompting with PROMPT in directory DIR.\n\
10393    Use a file selection dialog.\n\
10394    Select DEFAULT-FILENAME in the dialog's file selection box, if\n\
10395    specified.  Don't let the user enter a file name in the file\n\
10396    selection dialog's entry field, if MUSTMATCH is non-nil.")
10397      (prompt, dir, default_filename, mustmatch)
10398         Lisp_Object prompt, dir, default_filename, mustmatch;
10399    {
10400      FRAME_PTR f = SELECTED_FRAME ();
10401      char *fn;
10402      Lisp_Object file = Qnil;
10403      int count = specpdl_ptr - specpdl;
10404      struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
10405      char *cdef_file;
10406      char *cprompt;
10407    
10408      GCPRO5 (prompt, dir, default_filename, mustmatch, file);
10409      CHECK_STRING (prompt);
10410      CHECK_STRING (dir);
10411    
10412      /* Prevent redisplay.  */
10413      specbind (Qinhibit_redisplay, Qt);
10414    
10415      BLOCK_INPUT;
10416    
10417      if (STRINGP (default_filename))
10418        cdef_file = SDATA (default_filename);
10419      else
10420        cdef_file = SDATA (dir);
10421    
10422      fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch));
10423    
10424      if (fn)
10425        {
10426          file = build_string (fn);
10427          xfree (fn);
10428        }
10429    
10430      UNBLOCK_INPUT;
10431      UNGCPRO;
10432    
10433      /* Make "Cancel" equivalent to C-g.  */
10434      if (NILP (file))
10435        Fsignal (Qquit, Qnil);
10436    
10437      return unbind_to (count, file);
10438    }
10439    
10440    #endif /* USE_GTK */
10441    
10442    
10443  /***********************************************************************  /***********************************************************************
# Line 11785  usual X keysyms.  */) Line 10484  usual X keysyms.  */)
10484        UNBLOCK_INPUT;        UNBLOCK_INPUT;
10485        return Qnil;        return Qnil;
10486      }      }
10487      
10488    have_keys = Qnil;    have_keys = Qnil;
10489    kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);    kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);
10490    if (kb)    if (kb)
# Line 11812  usual X keysyms.  */) Line 10511  usual X keysyms.  */)
10511          }          }
10512    
10513        XkbFreeClientMap (kb, 0, True);        XkbFreeClientMap (kb, 0, True);
10514      
10515        if (delete_keycode        if (delete_keycode
10516            && backspace_keycode            && backspace_keycode
10517            && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode            && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode
# Line 11832  usual X keysyms.  */) Line 10531  usual X keysyms.  */)
10531                              Initialization                              Initialization
10532   ***********************************************************************/   ***********************************************************************/
10533    
10534    /* Keep this list in the same order as frame_parms in frame.c.
10535       Use 0 for unsupported frame parameters.  */
10536    
10537    frame_parm_handler x_frame_parm_handlers[] =
10538    {
10539      x_set_autoraise,
10540      x_set_autolower,
10541      x_set_background_color,
10542      x_set_border_color,
10543      x_set_border_width,
10544      x_set_cursor_color,
10545      x_set_cursor_type,
10546      x_set_font,
10547      x_set_foreground_color,
10548      x_set_icon_name,
10549      x_set_icon_type,
10550      x_set_internal_border_width,
10551      x_set_menu_bar_lines,
10552      x_set_mouse_color,
10553      x_explicitly_set_name,
10554      x_set_scroll_bar_width,
10555      x_set_title,
10556      x_set_unsplittable,
10557      x_set_vertical_scroll_bars,
10558      x_set_visibility,
10559      x_set_tool_bar_lines,
10560      x_set_scroll_bar_foreground,
10561      x_set_scroll_bar_background,
10562      x_set_screen_gamma,
10563      x_set_line_spacing,
10564      x_set_fringe_width,
10565      x_set_fringe_width,
10566      x_set_wait_for_wm,
10567      x_set_fullscreen,
10568    };
10569    
10570  void  void
10571  syms_of_xfns ()  syms_of_xfns ()
10572  {  {
# Line 11841  syms_of_xfns () Line 10576  syms_of_xfns ()
10576    /* The section below is built by the lisp expression at the top of the file,    /* The section below is built by the lisp expression at the top of the file,
10577       just above where these variables are declared.  */       just above where these variables are declared.  */
10578    /*&&& init symbols here &&&*/    /*&&& init symbols here &&&*/
   Qauto_raise = intern ("auto-raise");  
   staticpro (&Qauto_raise);  
   Qauto_lower = intern ("auto-lower");  
   staticpro (&Qauto_lower);  
   Qbar = intern ("bar");  
   staticpro (&Qbar);  
   Qhbar = intern ("hbar");  
   staticpro (&Qhbar);  
   Qborder_color = intern ("border-color");  
   staticpro (&Qborder_color);  
   Qborder_width = intern ("border-width");  
   staticpro (&Qborder_width);  
   Qbox = intern ("box");  
   staticpro (&Qbox);  
   Qcursor_color = intern ("cursor-color");  
   staticpro (&Qcursor_color);  
   Qcursor_type = intern ("cursor-type");  
   staticpro (&Qcursor_type);  
   Qgeometry = intern ("geometry");  
   staticpro (&Qgeometry);  
   Qicon_left = intern ("icon-left");  
   staticpro (&Qicon_left);  
   Qicon_top = intern ("icon-top");  
   staticpro (&Qicon_top);  
   Qicon_type = intern ("icon-type");  
   staticpro (&Qicon_type);  
   Qicon_name = intern ("icon-name");  
   staticpro (&Qicon_name);  
   Qinternal_border_width = intern ("internal-border-width");  
   staticpro (&Qinternal_border_width);  
   Qleft = intern ("left");  
   staticpro (&Qleft);  
   Qright = intern ("right");  
   staticpro (&Qright);  
   Qmouse_color = intern ("mouse-color");  
   staticpro (&Qmouse_color);  
10579    Qnone = intern ("none");    Qnone = intern ("none");
10580    staticpro (&Qnone);    staticpro (&Qnone);
   Qparent_id = intern ("parent-id");  
   staticpro (&Qparent_id);  
   Qscroll_bar_width = intern ("scroll-bar-width");  
   staticpro (&Qscroll_bar_width);  
10581    Qsuppress_icon = intern ("suppress-icon");    Qsuppress_icon = intern ("suppress-icon");
10582    staticpro (&Qsuppress_icon);    staticpro (&Qsuppress_icon);
10583    Qundefined_color = intern ("undefined-color");    Qundefined_color = intern ("undefined-color");
10584    staticpro (&Qundefined_color);    staticpro (&Qundefined_color);
   Qvertical_scroll_bars = intern ("vertical-scroll-bars");  
   staticpro (&Qvertical_scroll_bars);  
   Qvisibility = intern ("visibility");  
   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");  
   staticpro (&Qx_resource_name);  
   Quser_position = intern ("user-position");  
   staticpro (&Quser_position);  
   Quser_size = intern ("user-size");  
   staticpro (&Quser_size);  
   Qscroll_bar_foreground = intern ("scroll-bar-foreground");  
   staticpro (&Qscroll_bar_foreground);  
   Qscroll_bar_background = intern ("scroll-bar-background");  
   staticpro (&Qscroll_bar_background);  
   Qscreen_gamma = intern ("screen-gamma");  
   staticpro (&Qscreen_gamma);  
   Qline_spacing = intern ("line-spacing");  
   staticpro (&Qline_spacing);  
10585    Qcenter = intern ("center");    Qcenter = intern ("center");
10586    staticpro (&Qcenter);    staticpro (&Qcenter);
10587    Qcompound_text = intern ("compound-text");    Qcompound_text = intern ("compound-text");
10588    staticpro (&Qcompound_text);    staticpro (&Qcompound_text);
10589    Qcancel_timer = intern ("cancel-timer");    Qcancel_timer = intern ("cancel-timer");
10590    staticpro (&Qcancel_timer);    staticpro (&Qcancel_timer);
   Qwait_for_wm = intern ("wait-for-wm");  
   staticpro (&Qwait_for_wm);  
   Qfullscreen = intern ("fullscreen");  
   staticpro (&Qfullscreen);  
   Qfullwidth = intern ("fullwidth");  
   staticpro (&Qfullwidth);  
   Qfullheight = intern ("fullheight");  
   staticpro (&Qfullheight);  
   Qfullboth = intern ("fullboth");  
   staticpro (&Qfullboth);  
10591    /* This is the end of symbol initialization.  */    /* This is the end of symbol initialization.  */
10592    
10593    /* Text property `display' should be nonsticky by default.  */    /* Text property `display' should be nonsticky by default.  */
# Line 11948  syms_of_xfns () Line 10609  syms_of_xfns ()
10609    staticpro (&QCcolor_adjustment);    staticpro (&QCcolor_adjustment);
10610    QCmask = intern (":mask");    QCmask = intern (":mask");
10611    staticpro (&QCmask);    staticpro (&QCmask);
   
   Qface_set_after_frame_default = intern ("face-set-after-frame-default");  
   staticpro (&Qface_set_after_frame_default);  
10612    
10613    Fput (Qundefined_color, Qerror_conditions,    Fput (Qundefined_color, Qerror_conditions,
10614          Fcons (Qundefined_color, Fcons (Qerror, Qnil)));          Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
10615    Fput (Qundefined_color, Qerror_message,    Fput (Qundefined_color, Qerror_message,
10616          build_string ("Undefined color"));          build_string ("Undefined color"));
10617    
   init_x_parm_symbols ();  
   
10618    DEFVAR_BOOL ("cross-disabled-images", &cross_disabled_images,    DEFVAR_BOOL ("cross-disabled-images", &cross_disabled_images,
10619      doc: /* Non-nil means always draw a cross over disabled images.      doc: /* Non-nil means always draw a cross over disabled images.
10620  Disabled images are those having an `:conversion disabled' property.  Disabled images are those having an `:conversion disabled' property.
# Line 11966  A cross is always drawn on black & white Line 10622  A cross is always drawn on black & white
10622    cross_disabled_images = 0;    cross_disabled_images = 0;
10623    
10624    DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,    DEFVAR_LISP ("x-bitmap-file-path", &Vx_bitmap_file_path,
10625      doc: /* List of directories to search for bitmap files for X.  */);      doc: /* List of directories to search for window system bitmap files.  */);
10626    Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS);    Vx_bitmap_file_path = decode_env_path ((char *) 0, PATH_BITMAPS);
10627    
10628    DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,    DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
# Line 11975  Changing the value does not affect exist Line 10631  Changing the value does not affect exist
10631  unless you set the mouse color.  */);  unless you set the mouse color.  */);
10632    Vx_pointer_shape = Qnil;    Vx_pointer_shape = Qnil;
10633    
   DEFVAR_LISP ("x-resource-name", &Vx_resource_name,  
     doc: /* The name Emacs uses to look up X resources.  
 `x-get-resource' uses this as the first component of the instance name  
 when requesting resource values.  
 Emacs initially sets `x-resource-name' to the name under which Emacs  
 was invoked, or to the value specified with the `-name' or `-rn'  
 switches, if present.  
   
 It may be useful to bind this variable locally around a call  
 to `x-get-resource'.  See also the variable `x-resource-class'.  */);  
   Vx_resource_name = Qnil;  
   
   DEFVAR_LISP ("x-resource-class", &Vx_resource_class,  
     doc: /* The class Emacs uses to look up X resources.  
 `x-get-resource' uses this as the first component of the instance class  
 when requesting resource values.  
   
 Emacs initially sets `x-resource-class' to "Emacs".  
   
 Setting this variable permanently is not a reasonable thing to do,  
 but binding this variable locally around a call to `x-get-resource'  
 is a reasonable practice.  See also the variable `x-resource-name'.  */);  
   Vx_resource_class = build_string (EMACS_CLASS);  
   
10634  #if 0 /* This doesn't really do anything.  */  #if 0 /* This doesn't really do anything.  */
10635    DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,    DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
10636      doc: /* The shape of the pointer when not over text.      doc: /* The shape of the pointer when not over text.
# Line 12016  or when you set the mouse color.  */); Line 10648  or when you set the mouse color.  */);
10648    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
10649      doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);      doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
10650    display_hourglass_p = 1;    display_hourglass_p = 1;
10651      
10652    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
10653      doc: /* *Seconds to wait before displaying an hourglass pointer.      doc: /* *Seconds to wait before displaying an hourglass pointer.
10654  Value must be an integer or float.  */);  Value must be an integer or float.  */);
# Line 12052  or when you set the mouse color.  */); Line 10684  or when you set the mouse color.  */);
10684      doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).      doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
10685  Text larger than this is clipped.  */);  Text larger than this is clipped.  */);
10686    Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));    Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
10687      
10688    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
10689      doc: /* Non-nil if no X window manager is in use.      doc: /* Non-nil if no X window manager is in use.
10690  Emacs doesn't try to figure this out; this is always nil  Emacs doesn't try to figure this out; this is always nil
# Line 12089  meaning don't clear the cache.  */); Line 10721  meaning don't clear the cache.  */);
10721  #endif /* USE_MOTIF */  #endif /* USE_MOTIF */
10722  #endif /* USE_X_TOOLKIT */  #endif /* USE_X_TOOLKIT */
10723    
   defsubr (&Sx_get_resource);  
   
10724    /* X window properties.  */    /* X window properties.  */
10725    defsubr (&Sx_change_window_property);    defsubr (&Sx_change_window_property);
10726    defsubr (&Sx_delete_window_property);    defsubr (&Sx_delete_window_property);
# Line 12113  meaning don't clear the cache.  */); Line 10743  meaning don't clear the cache.  */);
10743    defsubr (&Sx_display_visual_class);    defsubr (&Sx_display_visual_class);
10744    defsubr (&Sx_display_backing_store);    defsubr (&Sx_display_backing_store);
10745    defsubr (&Sx_display_save_under);    defsubr (&Sx_display_save_under);
   defsubr (&Sx_parse_geometry);  
10746    defsubr (&Sx_create_frame);    defsubr (&Sx_create_frame);
10747    defsubr (&Sx_open_connection);    defsubr (&Sx_open_connection);
10748    defsubr (&Sx_close_connection);    defsubr (&Sx_close_connection);
# Line 12121  meaning don't clear the cache.  */); Line 10750  meaning don't clear the cache.  */);
10750    defsubr (&Sx_synchronize);    defsubr (&Sx_synchronize);
10751    defsubr (&Sx_focus_frame);    defsubr (&Sx_focus_frame);
10752    defsubr (&Sx_backspace_delete_keys_p);    defsubr (&Sx_backspace_delete_keys_p);
10753      
10754    /* Setting callback functions for fontset handler.  */    /* Setting callback functions for fontset handler.  */
10755    get_font_info_func = x_get_font_info;    get_font_info_func = x_get_font_info;
10756    
# Line 12129  meaning don't clear the cache.  */); Line 10758  meaning don't clear the cache.  */);
10758           And the pointer assigned has the wrong type, anyway.  */           And the pointer assigned has the wrong type, anyway.  */
10759    list_fonts_func = x_list_fonts;    list_fonts_func = x_list_fonts;
10760  #endif  #endif
10761      
10762    load_font_func = x_load_font;    load_font_func = x_load_font;
10763    find_ccl_program_func = x_find_ccl_program;    find_ccl_program_func = x_find_ccl_program;
10764    query_font_func = x_query_font;    query_font_func = x_query_font;
# Line 12170  meaning don't clear the cache.  */); Line 10799  meaning don't clear the cache.  */);
10799    Qxpm = intern ("xpm");    Qxpm = intern ("xpm");
10800    staticpro (&Qxpm);    staticpro (&Qxpm);
10801  #endif  #endif
10802      
10803  #if HAVE_JPEG  #if HAVE_JPEG
10804    Qjpeg = intern ("jpeg");    Qjpeg = intern ("jpeg");
10805    staticpro (&Qjpeg);    staticpro (&Qjpeg);
10806  #endif  #endif
10807    
10808  #if HAVE_TIFF  #if HAVE_TIFF
10809    Qtiff = intern ("tiff");    Qtiff = intern ("tiff");
10810    staticpro (&Qtiff);    staticpro (&Qtiff);
10811  #endif  #endif
10812    
10813  #if HAVE_GIF  #if HAVE_GIF
10814    Qgif = intern ("gif");    Qgif = intern ("gif");
# Line 12219  init_xfns () Line 10848  init_xfns ()
10848  {  {
10849    image_types = NULL;    image_types = NULL;
10850    Vimage_types = Qnil;    Vimage_types = Qnil;
10851      
10852    define_image_type (&xbm_type);    define_image_type (&xbm_type);
10853    define_image_type (&gs_type);    define_image_type (&gs_type);
10854    define_image_type (&pbm_type);    define_image_type (&pbm_type);
10855      
10856  #if HAVE_XPM  #if HAVE_XPM
10857    define_image_type (&xpm_type);    define_image_type (&xpm_type);
10858  #endif  #endif
10859      
10860  #if HAVE_JPEG  #if HAVE_JPEG
10861    define_image_type (&jpeg_type);    define_image_type (&jpeg_type);
10862  #endif  #endif
10863      
10864  #if HAVE_TIFF  #if HAVE_TIFF
10865    define_image_type (&tiff_type);    define_image_type (&tiff_type);
10866  #endif  #endif
10867      
10868  #if HAVE_GIF  #if HAVE_GIF
10869    define_image_type (&gif_type);    define_image_type (&gif_type);
10870  #endif  #endif
10871      
10872  #if HAVE_PNG  #if HAVE_PNG
10873    define_image_type (&png_type);    define_image_type (&png_type);
10874  #endif  #endif

Legend:
Removed from v.1.549  
changed lines
  Added in v.1.549.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26