/[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.572 by handa, Mon Jan 27 01:04:03 2003 UTC revision 1.573 by lektu, Tue Feb 4 14:03:17 2003 UTC
# Line 288  check_x_display_info (frame) Line 288  check_x_display_info (frame)
288       Lisp_Object frame;       Lisp_Object frame;
289  {  {
290    struct x_display_info *dpyinfo = NULL;    struct x_display_info *dpyinfo = NULL;
291      
292    if (NILP (frame))    if (NILP (frame))
293      {      {
294        struct frame *sf = XFRAME (selected_frame);        struct frame *sf = XFRAME (selected_frame);
295          
296        if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))        if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
297          dpyinfo = FRAME_X_DISPLAY_INFO (sf);          dpyinfo = FRAME_X_DISPLAY_INFO (sf);
298        else if (x_display_list != 0)        else if (x_display_list != 0)
# Line 336  x_window_to_frame (dpyinfo, wdesc) Line 336  x_window_to_frame (dpyinfo, wdesc)
336        if (f->output_data.x->hourglass_window == wdesc)        if (f->output_data.x->hourglass_window == wdesc)
337          return f;          return f;
338  #ifdef USE_X_TOOLKIT  #ifdef USE_X_TOOLKIT
339        if ((f->output_data.x->edit_widget        if ((f->output_data.x->edit_widget
340             && XtWindow (f->output_data.x->edit_widget) == wdesc)             && XtWindow (f->output_data.x->edit_widget) == wdesc)
341            /* A tooltip frame?  */            /* A tooltip frame?  */
342            || (!f->output_data.x->edit_widget            || (!f->output_data.x->edit_widget
# Line 380  x_any_window_to_frame (dpyinfo, wdesc) Line 380  x_any_window_to_frame (dpyinfo, wdesc)
380        frame = XCAR (tail);        frame = XCAR (tail);
381        if (!GC_FRAMEP (frame))        if (!GC_FRAMEP (frame))
382          continue;          continue;
383          
384        f = XFRAME (frame);        f = XFRAME (frame);
385        if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)        if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
386          {          {
# Line 399  x_any_window_to_frame (dpyinfo, wdesc) Line 399  x_any_window_to_frame (dpyinfo, wdesc)
399                        || gwdesc == x->menubar_widget))                        || gwdesc == x->menubar_widget))
400                  found = f;                  found = f;
401  #else  #else
402                if (wdesc == XtWindow (x->widget)                if (wdesc == XtWindow (x->widget)
403                    || wdesc == XtWindow (x->column_widget)                    || wdesc == XtWindow (x->column_widget)
404                    || wdesc == XtWindow (x->edit_widget))                    || wdesc == XtWindow (x->edit_widget))
405                  found = f;                  found = f;
406                /* Match if the window is this frame's menubar.  */                /* Match if the window is this frame's menubar.  */
# Line 413  x_any_window_to_frame (dpyinfo, wdesc) Line 413  x_any_window_to_frame (dpyinfo, wdesc)
413              found = f;              found = f;
414          }          }
415      }      }
416      
417    return found;    return found;
418  }  }
419    
# Line 450  x_non_menubar_window_to_frame (dpyinfo, Line 450  x_non_menubar_window_to_frame (dpyinfo,
450                    || gwdesc == x->vbox_widget))                    || gwdesc == x->vbox_widget))
451              return f;              return f;
452  #else  #else
453            if (wdesc == XtWindow (x->widget)            if (wdesc == XtWindow (x->widget)
454                || wdesc == XtWindow (x->column_widget)                || wdesc == XtWindow (x->column_widget)
455                || wdesc == XtWindow (x->edit_widget))                || wdesc == XtWindow (x->edit_widget))
456              return f;              return f;
457  #endif  #endif
# Line 489  x_menubar_window_to_frame (dpyinfo, wdes Line 489  x_menubar_window_to_frame (dpyinfo, wdes
489          {          {
490            GtkWidget *gwdesc = xg_win_to_widget (wdesc);            GtkWidget *gwdesc = xg_win_to_widget (wdesc);
491            int found = 0;            int found = 0;
492              
493            BLOCK_INPUT;            BLOCK_INPUT;
494            if (gwdesc != 0            if (gwdesc != 0
495                && (gwdesc == x->menubar_widget                && (gwdesc == x->menubar_widget
# Line 543  x_top_window_to_frame (dpyinfo, wdesc) Line 543  x_top_window_to_frame (dpyinfo, wdesc)
543           but it seems logically wrong,           but it seems logically wrong,
544           and it causes trouble for MapNotify events.  */           and it causes trouble for MapNotify events.  */
545            /* Match if the window is this frame's menubar.  */            /* Match if the window is this frame's menubar.  */
546            if (x->menubar_widget            if (x->menubar_widget
547                && wdesc == XtWindow (x->menubar_widget))                && wdesc == XtWindow (x->menubar_widget))
548              return f;              return f;
549  #endif  #endif
# Line 860  static struct x_frame_parm_table x_frame Line 860  static struct x_frame_parm_table x_frame
860    {"right-fringe",              x_set_fringe_width},    {"right-fringe",              x_set_fringe_width},
861    {"wait-for-wm",               x_set_wait_for_wm},    {"wait-for-wm",               x_set_wait_for_wm},
862    {"fullscreen",                x_set_fullscreen},    {"fullscreen",                x_set_fullscreen},
863      
864  };  };
865    
866  /* Attach the `x-frame-parameter' properties to  /* Attach the `x-frame-parameter' properties to
# Line 979  x_set_frame_parameters (f, alist) Line 979  x_set_frame_parameters (f, alist)
979       cursor_color) are dependent upon them.  */       cursor_color) are dependent upon them.  */
980    /* Process default font as well, since fringe widths depends on it.  */    /* Process default font as well, since fringe widths depends on it.  */
981    /* Also, process fullscreen, width and height depend upon that */    /* Also, process fullscreen, width and height depend upon that */
982    for (p = 0; p < i; p++)    for (p = 0; p < i; p++)
983      {      {
984        Lisp_Object prop, val;        Lisp_Object prop, val;
985    
# Line 994  x_set_frame_parameters (f, alist) Line 994  x_set_frame_parameters (f, alist)
994    
995            old_value = get_frame_param (f, prop);            old_value = get_frame_param (f, prop);
996            fullscreen_is_being_set |= EQ (prop, Qfullscreen);            fullscreen_is_being_set |= EQ (prop, Qfullscreen);
997              
998            if (NILP (Fequal (val, old_value)))            if (NILP (Fequal (val, old_value)))
999              {              {
1000                store_frame_param (f, prop, val);                store_frame_param (f, prop, val);
# Line 1094  x_set_frame_parameters (f, alist) Line 1094  x_set_frame_parameters (f, alist)
1094           position.  Resize of the frame is taken care of in the code after           position.  Resize of the frame is taken care of in the code after
1095           this if-statement. */           this if-statement. */
1096        int new_left, new_top;        int new_left, new_top;
1097          
1098        x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);        x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
1099        x_fullscreen_move (f, new_top, new_left);        x_fullscreen_move (f, new_top, new_left);
1100      }      }
1101      
1102    /* Don't set these parameters unless they've been explicitly    /* Don't set these parameters unless they've been explicitly
1103       specified.  The window might be mapped or resized while we're in       specified.  The window might be mapped or resized while we're in
1104       this function, and we don't want to override that unless the lisp       this function, and we don't want to override that unless the lisp
# Line 1242  x_real_positions (f, xptr, yptr) Line 1242  x_real_positions (f, xptr, yptr)
1242    
1243        win = wm_window;        win = wm_window;
1244      }      }
1245        
1246    if (! had_errors)    if (! had_errors)
1247      {      {
1248        int ign;        int ign;
1249        Window child, rootw;        Window child, rootw;
1250              
1251        /* Get the real coordinates for the WM window upper left corner */        /* Get the real coordinates for the WM window upper left corner */
1252        XGetGeometry (FRAME_X_DISPLAY (f), win,        XGetGeometry (FRAME_X_DISPLAY (f), win,
1253                      &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);                      &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
# Line 1286  x_real_positions (f, xptr, yptr) Line 1286  x_real_positions (f, xptr, yptr)
1286                                   /* From-window, to-window.  */                                   /* From-window, to-window.  */
1287                                   FRAME_X_DISPLAY_INFO (f)->root_window,                                   FRAME_X_DISPLAY_INFO (f)->root_window,
1288                                   FRAME_OUTER_WINDOW (f),                                   FRAME_OUTER_WINDOW (f),
1289                                        
1290                                   /* From-position, to-position.  */                                   /* From-position, to-position.  */
1291                                   real_x, real_y, &outer_x, &outer_y,                                   real_x, real_y, &outer_x, &outer_y,
1292                            
1293                                   /* Child of win.  */                                   /* Child of win.  */
1294                                   &child);                                   &child);
1295      }      }
1296    
1297        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));        had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
1298      }      }
1299          
1300    x_uncatch_errors (FRAME_X_DISPLAY (f), count);    x_uncatch_errors (FRAME_X_DISPLAY (f), count);
1301          
1302    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1303    
1304    if (had_errors) return;    if (had_errors) return;
1305          
1306    f->output_data.x->x_pixels_diff = -win_x;    f->output_data.x->x_pixels_diff = -win_x;
1307    f->output_data.x->y_pixels_diff = -win_y;    f->output_data.x->y_pixels_diff = -win_y;
1308    f->output_data.x->x_pixels_outer_diff = -outer_x;    f->output_data.x->x_pixels_outer_diff = -outer_x;
# Line 1562  x_set_foreground_color (f, arg, oldval) Line 1562  x_set_foreground_color (f, arg, oldval)
1562    if (FRAME_X_WINDOW (f) != 0)    if (FRAME_X_WINDOW (f) != 0)
1563      {      {
1564        Display *dpy = FRAME_X_DISPLAY (f);        Display *dpy = FRAME_X_DISPLAY (f);
1565          
1566        BLOCK_INPUT;        BLOCK_INPUT;
1567        XSetForeground (dpy, x->normal_gc, fg);        XSetForeground (dpy, x->normal_gc, fg);
1568        XSetBackground (dpy, x->reverse_gc, fg);        XSetBackground (dpy, x->reverse_gc, fg);
# Line 1573  x_set_foreground_color (f, arg, oldval) Line 1573  x_set_foreground_color (f, arg, oldval)
1573            x->cursor_pixel = x_copy_color (f, fg);            x->cursor_pixel = x_copy_color (f, fg);
1574            XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);            XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);
1575          }          }
1576          
1577        UNBLOCK_INPUT;        UNBLOCK_INPUT;
1578          
1579        update_face_from_frame_parameter (f, Qforeground_color, arg);        update_face_from_frame_parameter (f, Qforeground_color, arg);
1580          
1581        if (FRAME_VISIBLE_P (f))        if (FRAME_VISIBLE_P (f))
1582          redraw_frame (f);          redraw_frame (f);
1583      }      }
1584          
1585    unload_color (f, old_fg);    unload_color (f, old_fg);
1586  }  }
1587    
# Line 1600  x_set_background_color (f, arg, oldval) Line 1600  x_set_background_color (f, arg, oldval)
1600    if (FRAME_X_WINDOW (f) != 0)    if (FRAME_X_WINDOW (f) != 0)
1601      {      {
1602        Display *dpy = FRAME_X_DISPLAY (f);        Display *dpy = FRAME_X_DISPLAY (f);
1603          
1604        BLOCK_INPUT;        BLOCK_INPUT;
1605        XSetBackground (dpy, x->normal_gc, bg);        XSetBackground (dpy, x->normal_gc, bg);
1606        XSetForeground (dpy, x->reverse_gc, bg);        XSetForeground (dpy, x->reverse_gc, bg);
# Line 1689  x_set_mouse_color (f, arg, oldval) Line 1689  x_set_mouse_color (f, arg, oldval)
1689    else    else
1690      hourglass_cursor = XCreateFontCursor (dpy, XC_watch);      hourglass_cursor = XCreateFontCursor (dpy, XC_watch);
1691    x_check_errors (dpy, "bad hourglass pointer cursor: %s");    x_check_errors (dpy, "bad hourglass pointer cursor: %s");
1692      
1693    x_check_errors (dpy, "bad nontext pointer cursor: %s");    x_check_errors (dpy, "bad nontext pointer cursor: %s");
1694    if (!NILP (Vx_mode_pointer_shape))    if (!NILP (Vx_mode_pointer_shape))
1695      {      {
# Line 1730  x_set_mouse_color (f, arg, oldval) Line 1730  x_set_mouse_color (f, arg, oldval)
1730      x_query_color (f, &fore_color);      x_query_color (f, &fore_color);
1731      back_color.pixel = mask_color;      back_color.pixel = mask_color;
1732      x_query_color (f, &back_color);      x_query_color (f, &back_color);
1733        
1734      XRecolorCursor (dpy, cursor, &fore_color, &back_color);      XRecolorCursor (dpy, cursor, &fore_color, &back_color);
1735      XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
1736      XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);      XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
# Line 1761  x_set_mouse_color (f, arg, oldval) Line 1761  x_set_mouse_color (f, arg, oldval)
1761        && x->modeline_cursor != 0)        && x->modeline_cursor != 0)
1762      XFreeCursor (dpy, f->output_data.x->modeline_cursor);      XFreeCursor (dpy, f->output_data.x->modeline_cursor);
1763    x->modeline_cursor = mode_cursor;    x->modeline_cursor = mode_cursor;
1764      
1765    if (cross_cursor != x->cross_cursor    if (cross_cursor != x->cross_cursor
1766        && x->cross_cursor != 0)        && x->cross_cursor != 0)
1767      XFreeCursor (dpy, x->cross_cursor);      XFreeCursor (dpy, x->cross_cursor);
# Line 1795  x_set_cursor_color (f, arg, oldval) Line 1795  x_set_cursor_color (f, arg, oldval)
1795      }      }
1796    else    else
1797      fore_pixel = x->background_pixel;      fore_pixel = x->background_pixel;
1798      
1799    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1800    pixel_allocated_p = 1;    pixel_allocated_p = 1;
1801    
# Line 1807  x_set_cursor_color (f, arg, oldval) Line 1807  x_set_cursor_color (f, arg, oldval)
1807            x_free_colors (f, &pixel, 1);            x_free_colors (f, &pixel, 1);
1808            pixel_allocated_p = 0;            pixel_allocated_p = 0;
1809          }          }
1810          
1811        pixel = x->mouse_pixel;        pixel = x->mouse_pixel;
1812        if (pixel == fore_pixel)        if (pixel == fore_pixel)
1813          {          {
# Line 2015  x_set_font (f, arg, oldval) Line 2015  x_set_font (f, arg, oldval)
2015              ? x_new_fontset (f, SDATA (fontset_name))              ? x_new_fontset (f, SDATA (fontset_name))
2016              : x_new_font (f, SDATA (arg)));              : x_new_font (f, SDATA (arg)));
2017    UNBLOCK_INPUT;    UNBLOCK_INPUT;
2018      
2019    if (EQ (result, Qnil))    if (EQ (result, Qnil))
2020      error ("Font `%s' is not defined", SDATA (arg));      error ("Font `%s' is not defined", SDATA (arg));
2021    else if (EQ (result, Qt))    else if (EQ (result, Qt))
# Line 2031  x_set_font (f, arg, oldval) Line 2031  x_set_font (f, arg, oldval)
2031          }          }
2032        else if (!NILP (Fequal (result, oldval)))        else if (!NILP (Fequal (result, oldval)))
2033          return;          return;
2034          
2035        store_frame_param (f, Qfont, result);        store_frame_param (f, Qfont, result);
2036        recompute_basic_faces (f);        recompute_basic_faces (f);
2037      }      }
# Line 2245  x_set_tool_bar_lines (f, value, oldval) Line 2245  x_set_tool_bar_lines (f, value, oldval)
2245    
2246    return;    return;
2247  #endif  #endif
2248      
2249       /* Make sure we redisplay all windows in this frame.  */       /* Make sure we redisplay all windows in this frame.  */
2250    ++windows_or_buffers_changed;    ++windows_or_buffers_changed;
2251    
# Line 2263  x_set_tool_bar_lines (f, value, oldval) Line 2263  x_set_tool_bar_lines (f, value, oldval)
2263    FRAME_TOOL_BAR_LINES (f) = nlines;    FRAME_TOOL_BAR_LINES (f) = nlines;
2264    x_change_window_heights (root_window, delta);    x_change_window_heights (root_window, delta);
2265    adjust_glyphs (f);    adjust_glyphs (f);
2266      
2267    /* 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
2268       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
2269       tool bar disappears.  This is so because the internal border is       tool bar disappears.  This is so because the internal border is
# Line 2309  x_set_scroll_bar_foreground (f, value, o Line 2309  x_set_scroll_bar_foreground (f, value, o
2309       Lisp_Object value, oldval;       Lisp_Object value, oldval;
2310  {  {
2311    unsigned long pixel;    unsigned long pixel;
2312      
2313    if (STRINGP (value))    if (STRINGP (value))
2314      pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));      pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));
2315    else    else
# Line 2317  x_set_scroll_bar_foreground (f, value, o Line 2317  x_set_scroll_bar_foreground (f, value, o
2317    
2318    if (f->output_data.x->scroll_bar_foreground_pixel != -1)    if (f->output_data.x->scroll_bar_foreground_pixel != -1)
2319      unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);      unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);
2320      
2321    f->output_data.x->scroll_bar_foreground_pixel = pixel;    f->output_data.x->scroll_bar_foreground_pixel = pixel;
2322    if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))    if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
2323      {      {
# Line 2349  x_set_scroll_bar_background (f, value, o Line 2349  x_set_scroll_bar_background (f, value, o
2349      pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));      pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));
2350    else    else
2351      pixel = -1;      pixel = -1;
2352      
2353    if (f->output_data.x->scroll_bar_background_pixel != -1)    if (f->output_data.x->scroll_bar_background_pixel != -1)
2354      unload_color (f, f->output_data.x->scroll_bar_background_pixel);      unload_color (f, f->output_data.x->scroll_bar_background_pixel);
2355      
2356  #ifdef USE_TOOLKIT_SCROLL_BARS  #ifdef USE_TOOLKIT_SCROLL_BARS
2357    /* Scrollbar shadow colors.  */    /* Scrollbar shadow colors.  */
2358    if (f->output_data.x->scroll_bar_top_shadow_pixel != -1)    if (f->output_data.x->scroll_bar_top_shadow_pixel != -1)
# Line 2375  x_set_scroll_bar_background (f, value, o Line 2375  x_set_scroll_bar_background (f, value, o
2375          (*condemn_scroll_bars_hook) (f);          (*condemn_scroll_bars_hook) (f);
2376        if (judge_scroll_bars_hook)        if (judge_scroll_bars_hook)
2377          (*judge_scroll_bars_hook) (f);          (*judge_scroll_bars_hook) (f);
2378          
2379        update_face_from_frame_parameter (f, Qscroll_bar_background, value);        update_face_from_frame_parameter (f, Qscroll_bar_background, value);
2380        redraw_frame (f);        redraw_frame (f);
2381      }      }
# Line 2470  x_set_name (f, name, explicit) Line 2470  x_set_name (f, name, explicit)
2470       Lisp_Object name;       Lisp_Object name;
2471       int explicit;       int explicit;
2472  {  {
2473    /* Make sure that requests from lisp code override requests from    /* Make sure that requests from lisp code override requests from
2474       Emacs redisplay code.  */       Emacs redisplay code.  */
2475    if (explicit)    if (explicit)
2476      {      {
# Line 2736  x_set_vertical_scroll_bars (f, arg, oldv Line 2736  x_set_vertical_scroll_bars (f, arg, oldv
2736          = (NILP (arg)          = (NILP (arg)
2737             ? vertical_scroll_bar_none             ? vertical_scroll_bar_none
2738             : EQ (Qright, arg)             : EQ (Qright, arg)
2739             ? vertical_scroll_bar_right             ? vertical_scroll_bar_right
2740             : vertical_scroll_bar_left);             : vertical_scroll_bar_left);
2741    
2742        /* We set this parameter before creating the X window for the        /* We set this parameter before creating the X window for the
# Line 2767  x_set_scroll_bar_width (f, arg, oldval) Line 2767  x_set_scroll_bar_width (f, arg, oldval)
2767        /* 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
2768           character width.  */           character width.  */
2769        FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;        FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
2770          
2771        /* Use all of that space (aside from required margins) for the        /* Use all of that space (aside from required margins) for the
2772           scroll bar.  */           scroll bar.  */
2773        FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;        FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
# Line 3096  x_get_arg (dpyinfo, alist, param, attrib Line 3096  x_get_arg (dpyinfo, alist, param, attrib
3096                if (!strcmp (SDATA (tem), "on")                if (!strcmp (SDATA (tem), "on")
3097                    || !strcmp (SDATA (tem), "true"))                    || !strcmp (SDATA (tem), "true"))
3098                  return Qt;                  return Qt;
3099                else                else
3100                  return Qnil;                  return Qnil;
3101    
3102              case RES_TYPE_STRING:              case RES_TYPE_STRING:
# Line 3215  x_default_scroll_bar_color_parameter (f, Line 3215  x_default_scroll_bar_color_parameter (f,
3215               specified.  */               specified.  */
3216            tem = Qnil;            tem = Qnil;
3217          }          }
3218          
3219  #else /* not USE_TOOLKIT_SCROLL_BARS */  #else /* not USE_TOOLKIT_SCROLL_BARS */
3220          
3221        tem = Qnil;        tem = Qnil;
3222          
3223  #endif /* not USE_TOOLKIT_SCROLL_BARS */  #endif /* not USE_TOOLKIT_SCROLL_BARS */
3224      }      }
3225    
# Line 3417  x_figure_window_size (f, parms) Line 3417  x_figure_window_size (f, parms)
3417      {      {
3418        int left, top;        int left, top;
3419        int width, height;        int width, height;
3420          
3421        /* It takes both for some WM:s to place it where we want */        /* It takes both for some WM:s to place it where we want */
3422        window_prompting = USPosition | PPosition;        window_prompting = USPosition | PPosition;
3423        x_fullscreen_adjust (f, &width, &height, &top, &left);        x_fullscreen_adjust (f, &width, &height, &top, &left);
# Line 3428  x_figure_window_size (f, parms) Line 3428  x_figure_window_size (f, parms)
3428        f->output_data.x->left_pos = left;        f->output_data.x->left_pos = left;
3429        f->output_data.x->top_pos = top;        f->output_data.x->top_pos = top;
3430      }      }
3431      
3432    return window_prompting;    return window_prompting;
3433  }  }
3434    
# Line 3551  xic_create_xfontset (f, base_fontname) Line 3551  xic_create_xfontset (f, base_fontname)
3551    char **missing_list;    char **missing_list;
3552    int missing_count;    int missing_count;
3553    char *def_string;    char *def_string;
3554      
3555    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),    xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
3556                          base_fontname, &missing_list,                          base_fontname, &missing_list,
3557                          &missing_count, &def_string);                          &missing_count, &def_string);
3558    if (missing_list)    if (missing_list)
3559      XFreeStringList (missing_list);      XFreeStringList (missing_list);
3560      
3561    /* No need to free def_string. */    /* No need to free def_string. */
3562    return xfs;    return xfs;
3563  }  }
# Line 3597  create_frame_xic (f) Line 3597  create_frame_xic (f)
3597    
3598    if (FRAME_XIC (f))    if (FRAME_XIC (f))
3599      return;      return;
3600      
3601    xim = FRAME_X_XIM (f);    xim = FRAME_X_XIM (f);
3602    if (xim)    if (xim)
3603      {      {
# Line 3695  create_frame_xic (f) Line 3695  create_frame_xic (f)
3695        XFree (preedit_attr);        XFree (preedit_attr);
3696        XFree (status_attr);        XFree (status_attr);
3697      }      }
3698      
3699    FRAME_XIC (f) = xic;    FRAME_XIC (f) = xic;
3700    FRAME_XIC_STYLE (f) = xic_style;    FRAME_XIC_STYLE (f) = xic_style;
3701    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
# Line 3710  free_frame_xic (f) Line 3710  free_frame_xic (f)
3710  {  {
3711    if (FRAME_XIC (f) == NULL)    if (FRAME_XIC (f) == NULL)
3712      return;      return;
3713      
3714    XDestroyIC (FRAME_XIC (f));    XDestroyIC (FRAME_XIC (f));
3715    if (FRAME_XIC_FONTSET (f))    if (FRAME_XIC_FONTSET (f))
3716      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
# Line 3731  xic_set_preeditarea (w, x, y) Line 3731  xic_set_preeditarea (w, x, y)
3731    struct frame *f = XFRAME (w->frame);    struct frame *f = XFRAME (w->frame);
3732    XVaNestedList attr;    XVaNestedList attr;
3733    XPoint spot;    XPoint spot;
3734          
3735    spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);    spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);
3736    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));
3737    attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);    attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
# Line 3757  xic_set_statusarea (f) Line 3757  xic_set_statusarea (f)
3757    attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);    attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);
3758    XSetICValues (xic, XNStatusAttributes, attr, NULL);    XSetICValues (xic, XNStatusAttributes, attr, NULL);
3759    XFree (attr);    XFree (attr);
3760      
3761    attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);    attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);
3762    XGetICValues (xic, XNStatusAttributes, attr, NULL);    XGetICValues (xic, XNStatusAttributes, attr, NULL);
3763    XFree (attr);    XFree (attr);
# Line 3803  xic_set_xfontset (f, base_fontname) Line 3803  xic_set_xfontset (f, base_fontname)
3803    if (FRAME_XIC_STYLE (f) & XIMStatusArea)    if (FRAME_XIC_STYLE (f) & XIMStatusArea)
3804      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);      XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
3805    XFree (attr);    XFree (attr);
3806      
3807    if (FRAME_XIC_FONTSET (f))    if (FRAME_XIC_FONTSET (f))
3808      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));      XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
3809    FRAME_XIC_FONTSET (f) = xfs;    FRAME_XIC_FONTSET (f) = xfs;
# Line 3839  x_window (f, window_prompting, minibuffe Line 3839  x_window (f, window_prompting, minibuffe
3839       for the window manager, so GC relocation won't bother it.       for the window manager, so GC relocation won't bother it.
3840    
3841       Elsewhere we specify the window name for the window manager.  */       Elsewhere we specify the window name for the window manager.  */
3842        
3843    {    {
3844      char *str = (char *) SDATA (Vx_resource_name);      char *str = (char *) SDATA (Vx_resource_name);
3845      f->namebuf = (char *) xmalloc (strlen (str) + 1);      f->namebuf = (char *) xmalloc (strlen (str) + 1);
# Line 3876  x_window (f, window_prompting, minibuffe Line 3876  x_window (f, window_prompting, minibuffe
3876    XtSetValues (pane_widget, al, ac);    XtSetValues (pane_widget, al, ac);
3877    f->output_data.x->column_widget = pane_widget;    f->output_data.x->column_widget = pane_widget;
3878    
3879    /* mappedWhenManaged to false tells to the paned window to not map/unmap    /* mappedWhenManaged to false tells to the paned window to not map/unmap
3880       the emacs screen when changing menubar.  This reduces flickering.  */       the emacs screen when changing menubar.  This reduces flickering.  */
3881    
3882    ac = 0;    ac = 0;
# Line 3890  x_window (f, window_prompting, minibuffe Line 3890  x_window (f, window_prompting, minibuffe
3890    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;    XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3891    frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,    frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,
3892                                   al, ac);                                   al, ac);
3893    
3894    f->output_data.x->edit_widget = frame_widget;    f->output_data.x->edit_widget = frame_widget;
3895    
3896    XtManageChild (frame_widget);    XtManageChild (frame_widget);
3897    
3898    /* Do some needed geometry management.  */    /* Do some needed geometry management.  */
3899    {    {
# Line 3902  x_window (f, window_prompting, minibuffe Line 3902  x_window (f, window_prompting, minibuffe
3902      Arg al[2];      Arg al[2];
3903      int ac = 0;      int ac = 0;
3904      int extra_borders = 0;      int extra_borders = 0;
3905      int menubar_size      int menubar_size
3906        = (f->output_data.x->menubar_widget        = (f->output_data.x->menubar_widget
3907           ? (f->output_data.x->menubar_widget->core.height           ? (f->output_data.x->menubar_widget->core.height
3908              + f->output_data.x->menubar_widget->core.border_width)              + f->output_data.x->menubar_widget->core.border_width)
# Line 3946  x_window (f, window_prompting, minibuffe Line 3946  x_window (f, window_prompting, minibuffe
3946    
3947        if (window_prompting & USPosition)        if (window_prompting & USPosition)
3948          sprintf (shell_position, "=%dx%d%c%d%c%d",          sprintf (shell_position, "=%dx%d%c%d%c%d",
3949                   PIXEL_WIDTH (f) + extra_borders,                   PIXEL_WIDTH (f) + extra_borders,
3950                   PIXEL_HEIGHT (f) + menubar_size + extra_borders,                   PIXEL_HEIGHT (f) + menubar_size + extra_borders,
3951                   (xneg ? '-' : '+'), left,                   (xneg ? '-' : '+'), left,
3952                   (yneg ? '-' : '+'), top);                   (yneg ? '-' : '+'), top);
3953        else        else
3954          sprintf (shell_position, "=%dx%d",          sprintf (shell_position, "=%dx%d",
3955                   PIXEL_WIDTH (f) + extra_borders,                   PIXEL_WIDTH (f) + extra_borders,
3956                   PIXEL_HEIGHT (f) + menubar_size + extra_borders);                   PIXEL_HEIGHT (f) + menubar_size + extra_borders);
3957      }      }
3958    
# Line 3970  x_window (f, window_prompting, minibuffe Line 3970  x_window (f, window_prompting, minibuffe
3970    XtManageChild (pane_widget);    XtManageChild (pane_widget);
3971    XtRealizeWidget (shell_widget);    XtRealizeWidget (shell_widget);
3972    
3973    FRAME_X_WINDOW (f) = XtWindow (frame_widget);    FRAME_X_WINDOW (f) = XtWindow (frame_widget);
3974    
3975    validate_x_resource_name ();    validate_x_resource_name ();
3976    
# Line 4017  x_window (f, window_prompting, minibuffe Line 4017  x_window (f, window_prompting, minibuffe
4017        attributes.event_mask |= fevent;        attributes.event_mask |= fevent;
4018      }      }
4019  #endif /* HAVE_X_I18N */  #endif /* HAVE_X_I18N */
4020      
4021    attribute_mask = CWEventMask;    attribute_mask = CWEventMask;
4022    XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),    XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),
4023                             attribute_mask, &attributes);                             attribute_mask, &attributes);
# Line 4137  x_window (f) Line 4137  x_window (f)
4137      }      }
4138  #endif  #endif
4139  #endif /* HAVE_X_I18N */  #endif /* HAVE_X_I18N */
4140      
4141    validate_x_resource_name ();    validate_x_resource_name ();
4142    
4143    class_hints.res_name = (char *) SDATA (Vx_resource_name);    class_hints.res_name = (char *) SDATA (Vx_resource_name);
# Line 4302  x_make_gc (f) Line 4302  x_make_gc (f)
4302       this must be done on a per-frame basis.  */       this must be done on a per-frame basis.  */
4303    f->output_data.x->border_tile    f->output_data.x->border_tile
4304      = (XCreatePixmapFromBitmapData      = (XCreatePixmapFromBitmapData
4305         (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,         (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
4306          gray_bits, gray_width, gray_height,          gray_bits, gray_width, gray_height,
4307          f->output_data.x->foreground_pixel,          f->output_data.x->foreground_pixel,
4308          f->output_data.x->background_pixel,          f->output_data.x->background_pixel,
# Line 4321  x_free_gcs (f) Line 4321  x_free_gcs (f)
4321    Display *dpy = FRAME_X_DISPLAY (f);    Display *dpy = FRAME_X_DISPLAY (f);
4322    
4323    BLOCK_INPUT;    BLOCK_INPUT;
4324      
4325    if (f->output_data.x->normal_gc)    if (f->output_data.x->normal_gc)
4326      {      {
4327        XFreeGC (dpy, f->output_data.x->normal_gc);        XFreeGC (dpy, f->output_data.x->normal_gc);
# Line 4333  x_free_gcs (f) Line 4333  x_free_gcs (f)
4333        XFreeGC (dpy, f->output_data.x->reverse_gc);        XFreeGC (dpy, f->output_data.x->reverse_gc);
4334        f->output_data.x->reverse_gc = 0;        f->output_data.x->reverse_gc = 0;
4335      }      }
4336      
4337    if (f->output_data.x->cursor_gc)    if (f->output_data.x->cursor_gc)
4338      {      {
4339        XFreeGC (dpy, f->output_data.x->cursor_gc);        XFreeGC (dpy, f->output_data.x->cursor_gc);
# Line 4366  unwind_create_frame (frame) Line 4366  unwind_create_frame (frame)
4366  #if GLYPH_DEBUG  #if GLYPH_DEBUG
4367        struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);        struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
4368  #endif  #endif
4369          
4370        x_free_frame_resources (f);        x_free_frame_resources (f);
4371    
4372        /* Check that reference counts are indeed correct.  */        /* Check that reference counts are indeed correct.  */
# Line 4374  unwind_create_frame (frame) Line 4374  unwind_create_frame (frame)
4374        xassert (dpyinfo->image_cache->refcount == image_cache_refcount);        xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
4375        return Qt;        return Qt;
4376      }      }
4377      
4378    return Qnil;    return Qnil;
4379  }  }
4380    
# Line 4505  This function is an internal primitive-- Line 4505  This function is an internal primitive--
4505      f->output_data.x->cursor_foreground_pixel = -1;      f->output_data.x->cursor_foreground_pixel = -1;
4506      f->output_data.x->border_pixel = -1;      f->output_data.x->border_pixel = -1;
4507      f->output_data.x->mouse_pixel = -1;      f->output_data.x->mouse_pixel = -1;
4508        
4509      black = build_string ("black");      black = build_string ("black");
4510      GCPRO1 (black);      GCPRO1 (black);
4511      f->output_data.x->foreground_pixel      f->output_data.x->foreground_pixel
# Line 4568  This function is an internal primitive-- Line 4568  This function is an internal primitive--
4568          else          else
4569            font = x_new_font (f, SDATA (font));            font = x_new_font (f, SDATA (font));
4570        }        }
4571        
4572      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
4573      if (!STRINGP (font))      if (!STRINGP (font))
4574        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 4599  This function is an internal primitive-- Line 4599  This function is an internal primitive--
4599    
4600    x_default_parameter (f, parms, Qborder_width, make_number (2),    x_default_parameter (f, parms, Qborder_width, make_number (2),
4601                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
4602      
4603    /* This defaults to 1 in order to match xterm.  We recognize either    /* This defaults to 1 in order to match xterm.  We recognize either
4604       internalBorderWidth or internalBorder (which is what xterm calls       internalBorderWidth or internalBorder (which is what xterm calls
4605       it).  */       it).  */
# Line 4654  This function is an internal primitive-- Line 4654  This function is an internal primitive--
4654       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
4655       happen.  */       happen.  */
4656    init_frame_faces (f);    init_frame_faces (f);
4657      
4658    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
4659                         "menuBar", "MenuBar", RES_TYPE_NUMBER);                         "menuBar", "MenuBar", RES_TYPE_NUMBER);
4660    x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),    x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
# Line 4680  This function is an internal primitive-- Line 4680  This function is an internal primitive--
4680    if (FRAME_TOOL_BAR_LINES (f))    if (FRAME_TOOL_BAR_LINES (f))
4681      {      {
4682        int margin, relief, bar_height;        int margin, relief, bar_height;
4683          
4684        relief = (tool_bar_button_relief >= 0        relief = (tool_bar_button_relief >= 0
4685                  ? tool_bar_button_relief                  ? tool_bar_button_relief
4686                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
# Line 4694  This function is an internal primitive-- Line 4694  This function is an internal primitive--
4694          margin = XFASTINT (XCDR (Vtool_bar_button_margin));          margin = XFASTINT (XCDR (Vtool_bar_button_margin));
4695        else        else
4696          margin = 0;          margin = 0;
4697              
4698        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
4699        f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);        f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
4700      }      }
# Line 4728  This function is an internal primitive-- Line 4728  This function is an internal primitive--
4728  #else  #else
4729    x_window (f);    x_window (f);
4730  #endif  #endif
4731      
4732    x_icon (f, parms);    x_icon (f, parms);
4733    x_make_gc (f);    x_make_gc (f);
4734    
# Line 4756  This function is an internal primitive-- Line 4756  This function is an internal primitive--
4756       f->height.  */       f->height.  */
4757    width = f->width;    width = f->width;
4758    height = f->height;    height = f->height;
4759      
4760    f->height = 0;    f->height = 0;
4761    SET_FRAME_WIDTH (f, 0);    SET_FRAME_WIDTH (f, 0);
4762    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
# Line 4819  This function is an internal primitive-- Line 4819  This function is an internal primitive--
4819    /* Make sure windows on this frame appear in calls to next-window    /* Make sure windows on this frame appear in calls to next-window
4820       and similar functions.  */       and similar functions.  */
4821    Vwindow_list = Qnil;    Vwindow_list = Qnil;
4822      
4823    return unbind_to (count, frame);    return unbind_to (count, frame);
4824  }  }
4825    
# Line 4867  FRAME nil means use the selected frame. Line 4867  FRAME nil means use the selected frame.
4867                    RevertToParent, CurrentTime);                    RevertToParent, CurrentTime);
4868    x_uncatch_errors (dpy, count);    x_uncatch_errors (dpy, count);
4869    UNBLOCK_INPUT;    UNBLOCK_INPUT;
4870      
4871    return Qnil;    return Qnil;
4872  }  }
4873    
# Line 5184  If omitted or nil, that stands for the s Line 5184  If omitted or nil, that stands for the s
5184        error ("Display has an unknown visual class");        error ("Display has an unknown visual class");
5185        result = Qnil;        result = Qnil;
5186      }      }
5187      
5188    return result;    return result;
5189  }  }
5190    
# Line 5339  select_visual (dpyinfo) Line 5339  select_visual (dpyinfo)
5339            || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),            || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),
5340                                  dpyinfo->n_planes, class, &vinfo))                                  dpyinfo->n_planes, class, &vinfo))
5341          fatal ("Invalid visual specification `%s'", SDATA (value));          fatal ("Invalid visual specification `%s'", SDATA (value));
5342          
5343        dpyinfo->visual = vinfo.visual;        dpyinfo->visual = vinfo.visual;
5344      }      }
5345    else    else
5346      {      {
5347        int n_visuals;        int n_visuals;
5348        XVisualInfo *vinfo, vinfo_template;        XVisualInfo *vinfo, vinfo_template;
5349          
5350        dpyinfo->visual = DefaultVisualOfScreen (screen);        dpyinfo->visual = DefaultVisualOfScreen (screen);
5351    
5352  #ifdef HAVE_X11R4  #ifdef HAVE_X11R4
# Line 5640  valid_image_p (object) Line 5640  valid_image_p (object)
5640       Lisp_Object object;       Lisp_Object object;
5641  {  {
5642    int valid_p = 0;    int valid_p = 0;
5643      
5644    if (CONSP (object) && EQ (XCAR (object), Qimage))    if (CONSP (object) && EQ (XCAR (object), Qimage))
5645      {      {
5646        Lisp_Object tem;        Lisp_Object tem;
# Line 5656  valid_image_p (object) Line 5656  valid_image_p (object)
5656                  if (type)                  if (type)
5657                    valid_p = type->valid_p (object);                    valid_p = type->valid_p (object);
5658                }                }
5659                
5660              break;              break;
5661            }            }
5662      }      }
# Line 5775  parse_image_spec (spec, keywords, nkeywo Line 5775  parse_image_spec (spec, keywords, nkeywo
5775           was found more than once, it's an error.  */           was found more than once, it's an error.  */
5776        keywords[i].value = value;        keywords[i].value = value;
5777        ++keywords[i].count;        ++keywords[i].count;
5778          
5779        if (keywords[i].count > 1)        if (keywords[i].count > 1)
5780          return 0;          return 0;
5781    
# Line 5819  parse_image_spec (spec, keywords, nkeywo Line 5819  parse_image_spec (spec, keywords, nkeywo
5819                     && XINT (value) <= 100)                     && XINT (value) <= 100)
5820              break;              break;
5821            return 0;            return 0;
5822                  
5823          case IMAGE_NON_NEGATIVE_INTEGER_VALUE:          case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
5824            if (!INTEGERP (value) || XINT (value) < 0)            if (!INTEGERP (value) || XINT (value) < 0)
5825              return 0;              return 0;
# Line 5830  parse_image_spec (spec, keywords, nkeywo Line 5830  parse_image_spec (spec, keywords, nkeywo
5830    
5831          case IMAGE_FUNCTION_VALUE:          case IMAGE_FUNCTION_VALUE:
5832            value = indirect_function (value);            value = indirect_function (value);
5833            if (SUBRP (value)            if (SUBRP (value)
5834                || COMPILEDP (value)                || COMPILEDP (value)
5835                || (CONSP (value) && EQ (XCAR (value), Qlambda)))                || (CONSP (value) && EQ (XCAR (value), Qlambda)))
5836              break;              break;
# Line 5879  image_spec_value (spec, key, found) Line 5879  image_spec_value (spec, key, found)
5879       int *found;       int *found;
5880  {  {
5881    Lisp_Object tail;    Lisp_Object tail;
5882      
5883    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
5884    
5885    for (tail = XCDR (spec);    for (tail = XCDR (spec);
# Line 5893  image_spec_value (spec, key, found) Line 5893  image_spec_value (spec, key, found)
5893            return XCAR (XCDR (tail));            return XCAR (XCDR (tail));
5894          }          }
5895      }      }
5896      
5897    if (found)    if (found)
5898      *found = 0;      *found = 0;
5899    return Qnil;    return Qnil;
5900  }  }
5901        
5902    
5903  DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,  DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
5904         doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).         doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).
# Line 5919  or omitted means use the selected frame. Line 5919  or omitted means use the selected frame.
5919        struct image *img = IMAGE_FROM_ID (f, id);        struct image *img = IMAGE_FROM_ID (f, id);
5920        int width = img->width + 2 * img->hmargin;        int width = img->width + 2 * img->hmargin;
5921        int height = img->height + 2 * img->vmargin;        int height = img->height + 2 * img->vmargin;
5922      
5923        if (NILP (pixels))        if (NILP (pixels))
5924          size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),          size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
5925                        make_float ((double) height / CANON_Y_UNIT (f)));                        make_float ((double) height / CANON_Y_UNIT (f)));
# Line 5976  make_image (spec, hash) Line 5976  make_image (spec, hash)
5976       unsigned hash;       unsigned hash;
5977  {  {
5978    struct image *img = (struct image *) xmalloc (sizeof *img);    struct image *img = (struct image *) xmalloc (sizeof *img);
5979      
5980    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
5981    bzero (img, sizeof *img);    bzero (img, sizeof *img);
5982    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
# Line 6037  prepare_image_for_display (f, img) Line 6037  prepare_image_for_display (f, img)
6037    if (img->pixmap == None && !img->load_failed_p)    if (img->pixmap == None && !img->load_failed_p)
6038      img->load_failed_p = img->type->load (f, img) == 0;      img->load_failed_p = img->type->load (f, img) == 0;
6039  }  }
6040        
6041    
6042  /* 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
6043     drawn in face FACE.  */     drawn in face FACE.  */
# Line 6089  four_corners_best (ximg, width, height) Line 6089  four_corners_best (ximg, width, height)
6089    for (i = best_count = 0; i < 4; ++i)    for (i = best_count = 0; i < 4; ++i)
6090      {      {
6091        int j, n;        int j, n;
6092              
6093        for (j = n = 0; j < 4; ++j)        for (j = n = 0; j < 4; ++j)
6094          if (corners[i] == corners[j])          if (corners[i] == corners[j])
6095            ++n;            ++n;
# Line 6205  x_clear_image_1 (f, img, pixmap_p, mask_ Line 6205  x_clear_image_1 (f, img, pixmap_p, mask_
6205        img->mask = None;        img->mask = None;
6206        img->background_transparent_valid = 0;        img->background_transparent_valid = 0;
6207      }      }
6208          
6209    if (colors_p && img->ncolors)    if (colors_p && img->ncolors)
6210      {      {
6211        x_free_colors (f, img->colors, img->ncolors);        x_free_colors (f, img->colors, img->ncolors);
# Line 6280  make_image_cache () Line 6280  make_image_cache ()
6280  {  {
6281    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
6282    int size;    int size;
6283      
6284    bzero (c, sizeof *c);    bzero (c, sizeof *c);
6285    c->size = 50;    c->size = 50;
6286    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
# Line 6305  free_image_cache (f) Line 6305  free_image_cache (f)
6305    
6306        /* Cache should not be referenced by any frame when freed.  */        /* Cache should not be referenced by any frame when freed.  */
6307        xassert (c->refcount == 0);        xassert (c->refcount == 0);
6308          
6309        for (i = 0; i < c->used; ++i)        for (i = 0; i < c->used; ++i)
6310          free_image (f, c->images[i]);          free_image (f, c->images[i]);
6311        xfree (c->images);        xfree (c->images);
# Line 6342  clear_image_cache (f, force_p) Line 6342  clear_image_cache (f, force_p)
6342        /* Block input so that we won't be interrupted by a SIGIO        /* Block input so that we won't be interrupted by a SIGIO
6343           while being in an inconsistent state.  */           while being in an inconsistent state.  */
6344        BLOCK_INPUT;        BLOCK_INPUT;
6345          
6346        for (i = nfreed = 0; i < c->used; ++i)        for (i = nfreed = 0; i < c->used; ++i)
6347          {          {
6348            struct image *img = c->images[i];            struct image *img = c->images[i];
# Line 6361  clear_image_cache (f, force_p) Line 6361  clear_image_cache (f, force_p)
6361        if (nfreed)        if (nfreed)
6362          {          {
6363            Lisp_Object tail, frame;            Lisp_Object tail, frame;
6364              
6365            FOR_EACH_FRAME (tail, frame)            FOR_EACH_FRAME (tail, frame)
6366              {              {
6367                struct frame *f = XFRAME (frame);                struct frame *f = XFRAME (frame);
# Line 6389  FRAME t means clear the image caches of Line 6389  FRAME t means clear the image caches of
6389    if (EQ (frame, Qt))    if (EQ (frame, Qt))
6390      {      {
6391        Lisp_Object tail;        Lisp_Object tail;
6392          
6393        FOR_EACH_FRAME (tail, frame)        FOR_EACH_FRAME (tail, frame)
6394          if (FRAME_X_P (XFRAME (frame)))          if (FRAME_X_P (XFRAME (frame)))
6395            clear_image_cache (XFRAME (frame), 1);            clear_image_cache (XFRAME (frame), 1);
# Line 6416  postprocess_image (f, img) Line 6416  postprocess_image (f, img)
6416        Lisp_Object mask;        Lisp_Object mask;
6417    
6418        spec = img->spec;        spec = img->spec;
6419          
6420        /* `:heuristic-mask t'        /* `:heuristic-mask t'
6421           `:mask heuristic'           `:mask heuristic'
6422           means build a mask heuristically.           means build a mask heuristically.
# Line 6426  postprocess_image (f, img) Line 6426  postprocess_image (f, img)
6426           image.           image.
6427           `:mask nil'           `:mask nil'
6428           means remove a mask, if any.  */           means remove a mask, if any.  */
6429                  
6430        mask = image_spec_value (spec, QCheuristic_mask, NULL);        mask = image_spec_value (spec, QCheuristic_mask, NULL);
6431        if (!NILP (mask))        if (!NILP (mask))
6432          x_build_heuristic_mask (f, img, mask);          x_build_heuristic_mask (f, img, mask);
6433        else        else
6434          {          {
6435            int found_p;            int found_p;
6436                        
6437            mask = image_spec_value (spec, QCmask, &found_p);            mask = image_spec_value (spec, QCmask, &found_p);
6438                      
6439            if (EQ (mask, Qheuristic))            if (EQ (mask, Qheuristic))
6440              x_build_heuristic_mask (f, img, Qt);              x_build_heuristic_mask (f, img, Qt);
6441            else if (CONSP (mask)            else if (CONSP (mask)
# Line 6452  postprocess_image (f, img) Line 6452  postprocess_image (f, img)
6452                img->mask = None;                img->mask = None;
6453              }              }
6454          }          }
6455    
6456              
6457        /* Should we apply an image transformation algorithm?  */        /* Should we apply an image transformation algorithm?  */
6458        conversion = image_spec_value (spec, QCconversion, NULL);        conversion = image_spec_value (spec, QCconversion, NULL);
6459        if (EQ (conversion, Qdisabled))        if (EQ (conversion, Qdisabled))
# Line 6495  lookup_image (f, spec) Line 6495  lookup_image (f, spec)
6495       specification.  */       specification.  */
6496    xassert (FRAME_WINDOW_P (f));    xassert (FRAME_WINDOW_P (f));
6497    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
6498      
6499    GCPRO1 (spec);    GCPRO1 (spec);
6500    
6501    /* Look up SPEC in the hash table of the image cache.  */    /* Look up SPEC in the hash table of the image cache.  */
# Line 6510  lookup_image (f, spec) Line 6510  lookup_image (f, spec)
6510    if (img == NULL)    if (img == NULL)
6511      {      {
6512        extern Lisp_Object Qpostscript;        extern Lisp_Object Qpostscript;
6513          
6514        BLOCK_INPUT;        BLOCK_INPUT;
6515        img = make_image (spec, hash);        img = make_image (spec, hash);
6516        cache_image (f, img);        cache_image (f, img);
# Line 6542  lookup_image (f, spec) Line 6542  lookup_image (f, spec)
6542              img->ascent = XFASTINT (ascent);              img->ascent = XFASTINT (ascent);
6543            else if (EQ (ascent, Qcenter))            else if (EQ (ascent, Qcenter))
6544              img->ascent = CENTERED_IMAGE_ASCENT;              img->ascent = CENTERED_IMAGE_ASCENT;
6545              
6546            margin = image_spec_value (spec, QCmargin, NULL);            margin = image_spec_value (spec, QCmargin, NULL);
6547            if (INTEGERP (margin) && XINT (margin) >= 0)            if (INTEGERP (margin) && XINT (margin) >= 0)
6548              img->vmargin = img->hmargin = XFASTINT (margin);              img->vmargin = img->hmargin = XFASTINT (margin);
# Line 6554  lookup_image (f, spec) Line 6554  lookup_image (f, spec)
6554                if (XINT (XCDR (margin)) > 0)                if (XINT (XCDR (margin)) > 0)
6555                  img->vmargin = XFASTINT (XCDR (margin));                  img->vmargin = XFASTINT (XCDR (margin));
6556              }              }
6557              
6558            relief = image_spec_value (spec, QCrelief, NULL);            relief = image_spec_value (spec, QCrelief, NULL);
6559            if (INTEGERP (relief))            if (INTEGERP (relief))
6560              {              {
# Line 6588  lookup_image (f, spec) Line 6588  lookup_image (f, spec)
6588    /* We're using IMG, so set its timestamp to `now'.  */    /* We're using IMG, so set its timestamp to `now'.  */
6589    EMACS_GET_TIME (now);    EMACS_GET_TIME (now);
6590    img->timestamp = EMACS_SECS (now);    img->timestamp = EMACS_SECS (now);
6591      
6592    UNGCPRO;    UNGCPRO;
6593      
6594    /* Value is the image id.  */    /* Value is the image id.  */
6595    return img->id;    return img->id;
6596  }  }
# Line 6742  x_put_x_image (f, ximg, pixmap, width, h Line 6742  x_put_x_image (f, ximg, pixmap, width, h
6742       int width, height;       int width, height;
6743  {  {
6744    GC gc;    GC gc;
6745      
6746    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
6747    gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);    gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
6748    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 6777  x_find_image_file (file) Line 6777  x_find_image_file (file)
6777    
6778    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */
6779    fd = openp (search_path, file, Qnil, &file_found, Qnil);    fd = openp (search_path, file, Qnil, &file_found, Qnil);
6780      
6781    if (fd == -1)    if (fd == -1)
6782      file_found = Qnil;      file_found = Qnil;
6783    else    else
# Line 6819  slurp_file (file, size) Line 6819  slurp_file (file, size)
6819            buf = NULL;            buf = NULL;
6820          }          }
6821      }      }
6822      
6823    return buf;    return buf;
6824  }  }
6825    
# Line 6898  enum xbm_token Line 6898  enum xbm_token
6898    XBM_TK_NUMBER    XBM_TK_NUMBER
6899  };  };
6900    
6901      
6902  /* Return non-zero if OBJECT is a valid XBM-type image specification.  /* Return non-zero if OBJECT is a valid XBM-type image specification.
6903     A valid specification is a list starting with the symbol `image'     A valid specification is a list starting with the symbol `image'
6904     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 6933  xbm_image_p (object) Line 6933  xbm_image_p (object)
6933       Lisp_Object object;       Lisp_Object object;
6934  {  {
6935    struct image_keyword kw[XBM_LAST];    struct image_keyword kw[XBM_LAST];
6936      
6937    bcopy (xbm_format, kw, sizeof kw);    bcopy (xbm_format, kw, sizeof kw);
6938    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
6939      return 0;      return 0;
# Line 6965  xbm_image_p (object) Line 6965  xbm_image_p (object)
6965        data = kw[XBM_DATA].value;        data = kw[XBM_DATA].value;
6966        width = XFASTINT (kw[XBM_WIDTH].value);        width = XFASTINT (kw[XBM_WIDTH].value);
6967        height = XFASTINT (kw[XBM_HEIGHT].value);        height = XFASTINT (kw[XBM_HEIGHT].value);
6968          
6969        /* Check type of data, and width and height against contents of        /* Check type of data, and width and height against contents of
6970           data.  */           data.  */
6971        if (VECTORP (data))        if (VECTORP (data))
6972          {          {
6973            int i;            int i;
6974              
6975            /* Number of elements of the vector must be >= height.  */            /* Number of elements of the vector must be >= height.  */
6976            if (XVECTOR (data)->size < height)            if (XVECTOR (data)->size < height)
6977              return 0;              return 0;
# Line 7031  xbm_scan (s, end, sval, ival) Line 7031  xbm_scan (s, end, sval, ival)
7031    int c;    int c;
7032    
7033   loop:   loop:
7034      
7035    /* Skip white space.  */    /* Skip white space.  */
7036    while (*s < end && (c = *(*s)++, isspace (c)))    while (*s < end && (c = *(*s)++, isspace (c)))
7037      ;      ;
# Line 7041  xbm_scan (s, end, sval, ival) Line 7041  xbm_scan (s, end, sval, ival)
7041    else if (isdigit (c))    else if (isdigit (c))
7042      {      {
7043        int value = 0, digit;        int value = 0, digit;
7044          
7045        if (c == '0' && *s < end)        if (c == '0' && *s < end)
7046          {          {
7047            c = *(*s)++;            c = *(*s)++;
# Line 7139  xbm_read_bitmap_data (contents, end, wid Line 7139  xbm_read_bitmap_data (contents, end, wid
7139       if (LA1 != (TOKEN))        \       if (LA1 != (TOKEN))        \
7140         goto failure;            \         goto failure;            \
7141       else                       \       else                       \
7142         match ()         match ()
7143    
7144  #define expect_ident(IDENT)                                     \  #define expect_ident(IDENT)                                     \
7145       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \
# Line 7182  xbm_read_bitmap_data (contents, end, wid Line 7182  xbm_read_bitmap_data (contents, end, wid
7182      {      {
7183        if (strcmp (buffer, "unsigned") == 0)        if (strcmp (buffer, "unsigned") == 0)
7184          {          {
7185            match ();            match ();
7186            expect_ident ("char");            expect_ident ("char");
7187          }          }
7188        else if (strcmp (buffer, "short") == 0)        else if (strcmp (buffer, "short") == 0)
# Line 7197  xbm_read_bitmap_data (contents, end, wid Line 7197  xbm_read_bitmap_data (contents, end, wid
7197        else        else
7198          goto failure;          goto failure;
7199      }      }
7200    else    else
7201      goto failure;      goto failure;
7202    
7203    expect (XBM_TK_IDENT);    expect (XBM_TK_IDENT);
# Line 7220  xbm_read_bitmap_data (contents, end, wid Line 7220  xbm_read_bitmap_data (contents, end, wid
7220            *p++ = val;            *p++ = val;
7221            if (!padding_p || ((i + 2) % bytes_per_line))            if (!padding_p || ((i + 2) % bytes_per_line))
7222              *p++ = value >> 8;              *p++ = value >> 8;
7223              
7224            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
7225              match ();              match ();
7226            else            else
# Line 7233  xbm_read_bitmap_data (contents, end, wid Line 7233  xbm_read_bitmap_data (contents, end, wid
7233          {          {
7234            int val = value;            int val = value;
7235            expect (XBM_TK_NUMBER);            expect (XBM_TK_NUMBER);
7236              
7237            *p++ = val;            *p++ = val;
7238              
7239            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
7240              match ();              match ();
7241            else            else
# Line 7247  xbm_read_bitmap_data (contents, end, wid Line 7247  xbm_read_bitmap_data (contents, end, wid
7247    return 1;    return 1;
7248    
7249   failure:   failure:
7250      
7251    if (data && *data)    if (data && *data)
7252      {      {
7253        xfree (*data);        xfree (*data);
# Line 7274  xbm_load_image (f, img, contents, end) Line 7274  xbm_load_image (f, img, contents, end)
7274    int rc;    int rc;
7275    unsigned char *data;    unsigned char *data;
7276    int success_p = 0;    int success_p = 0;
7277      
7278    rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);    rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
7279    if (rc)    if (rc)
7280      {      {
# Line 7282  xbm_load_image (f, img, contents, end) Line 7282  xbm_load_image (f, img, contents, end)
7282        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
7283        unsigned long background = FRAME_BACKGROUND_PIXEL (f);        unsigned long background = FRAME_BACKGROUND_PIXEL (f);
7284        Lisp_Object value;        Lisp_Object value;
7285          
7286        xassert (img->width > 0 && img->height > 0);        xassert (img->width > 0 && img->height > 0);
7287    
7288        /* Get foreground and background colors, maybe allocate colors.  */        /* Get foreground and background colors, maybe allocate colors.  */
# Line 7335  xbm_file_p (data) Line 7335  xbm_file_p (data)
7335                                     &w, &h, NULL));                                     &w, &h, NULL));
7336  }  }
7337    
7338        
7339  /* 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
7340     non-zero if successful.  */     non-zero if successful.  */
7341    
# Line 7357  xbm_load (f, img) Line 7357  xbm_load (f, img)
7357        char *contents;        char *contents;
7358        int size;        int size;
7359        struct gcpro gcpro1;        struct gcpro gcpro1;
7360          
7361        file = x_find_image_file (file_name);        file = x_find_image_file (file_name);
7362        GCPRO1 (file);        GCPRO1 (file);
7363        if (!STRINGP (file))        if (!STRINGP (file))
# Line 7427  xbm_load (f, img) Line 7427  xbm_load (f, img)
7427                int i;                int i;
7428                char *p;                char *p;
7429                int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;                int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
7430              
7431                p = bits = (char *) alloca (nbytes * img->height);                p = bits = (char *) alloca (nbytes * img->height);
7432                for (i = 0; i < img->height; ++i, p += nbytes)                for (i = 0; i < img->height; ++i, p += nbytes)
7433                  {                  {
# Line 7465  xbm_load (f, img) Line 7465  xbm_load (f, img)
7465    
7466    return success_p;    return success_p;
7467  }  }
7468      
7469    
7470    
7471  /***********************************************************************  /***********************************************************************
7472                                XPM images                                XPM images
7473   ***********************************************************************/   ***********************************************************************/
7474    
7475  #if HAVE_XPM  #if HAVE_XPM
7476    
7477  static int xpm_image_p P_ ((Lisp_Object object));  static int xpm_image_p P_ ((Lisp_Object object));
7478  static int xpm_load P_ ((struct frame *f, struct image *img));  static int xpm_load P_ ((struct frame *f, struct image *img));
# Line 7589  xpm_init_color_cache (f, attrs) Line 7589  xpm_init_color_cache (f, attrs)
7589      {      {
7590        int i;        int i;
7591        XColor color;        XColor color;
7592          
7593        for (i = 0; i < attrs->numsymbols; ++i)        for (i = 0; i < attrs->numsymbols; ++i)
7594          if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),          if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
7595                           attrs->colorsymbols[i].value, &color))                           attrs->colorsymbols[i].value, &color))
# Line 7632  xpm_color_bucket (color_name) Line 7632  xpm_color_bucket (color_name)
7632  {  {
7633    unsigned h = 0;    unsigned h = 0;
7634    char *s;    char *s;
7635      
7636    for (s = color_name; *s; ++s)    for (s = color_name; *s; ++s)
7637      h = (h << 2) ^ *s;      h = (h << 2) ^ *s;
7638    return h %= XPM_COLOR_CACHE_BUCKETS;    return h %= XPM_COLOR_CACHE_BUCKETS;
# Line 7652  xpm_cache_color (f, color_name, color, b Line 7652  xpm_cache_color (f, color_name, color, b
7652  {  {
7653    size_t nbytes;    size_t nbytes;
7654    struct xpm_cached_color *p;    struct xpm_cached_color *p;
7655      
7656    if (bucket < 0)    if (bucket < 0)
7657      bucket = xpm_color_bucket (color_name);      bucket = xpm_color_bucket (color_name);
7658          
7659    nbytes = sizeof *p + strlen (color_name);    nbytes = sizeof *p + strlen (color_name);
7660    p = (struct xpm_cached_color *) xmalloc (nbytes);    p = (struct xpm_cached_color *) xmalloc (nbytes);
7661    strcpy (p->name, color_name);    strcpy (p->name, color_name);
# Line 7693  xpm_lookup_color (f, color_name, color) Line 7693  xpm_lookup_color (f, color_name, color)
7693                                         color->blue);                                         color->blue);
7694        p = xpm_cache_color (f, color_name, color, h);        p = xpm_cache_color (f, color_name, color, h);
7695      }      }
7696      
7697    return p != NULL;    return p != NULL;
7698  }  }
7699    
# Line 7820  xpm_load (f, img) Line 7820  xpm_load (f, img)
7820        Lisp_Object tail;        Lisp_Object tail;
7821        XpmColorSymbol *xpm_syms;        XpmColorSymbol *xpm_syms;
7822        int i, size;        int i, size;
7823          
7824        attrs.valuemask |= XpmColorSymbols;        attrs.valuemask |= XpmColorSymbols;
7825    
7826        /* Count number of symbols.  */        /* Count number of symbols.  */
# Line 7853  xpm_load (f, img) Line 7853  xpm_load (f, img)
7853  #ifdef ALLOC_XPM_COLORS  #ifdef ALLOC_XPM_COLORS
7854    xpm_init_color_cache (f, &attrs);    xpm_init_color_cache (f, &attrs);
7855  #endif  #endif
7856      
7857    specified_file = image_spec_value (img->spec, QCfile, NULL);    specified_file = image_spec_value (img->spec, QCfile, NULL);
7858    if (STRINGP (specified_file))    if (STRINGP (specified_file))
7859      {      {
# Line 7863  xpm_load (f, img) Line 7863  xpm_load (f, img)
7863            image_error ("Cannot find image file `%s'", specified_file, Qnil);            image_error ("Cannot find image file `%s'", specified_file, Qnil);
7864            return 0;            return 0;
7865          }          }
7866          
7867        rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7868                                  SDATA (file), &img->pixmap, &img->mask,                                  SDATA (file), &img->pixmap, &img->mask,
7869                                  &attrs);                                  &attrs);
# Line 7910  xpm_load (f, img) Line 7910  xpm_load (f, img)
7910          case XpmOpenFailed:          case XpmOpenFailed:
7911            image_error ("Error opening XPM file (%s)", img->spec, Qnil);            image_error ("Error opening XPM file (%s)", img->spec, Qnil);
7912            break;            break;
7913              
7914          case XpmFileInvalid:          case XpmFileInvalid:
7915            image_error ("Invalid XPM file (%s)", img->spec, Qnil);            image_error ("Invalid XPM file (%s)", img->spec, Qnil);
7916            break;            break;
7917              
7918          case XpmNoMemory:          case XpmNoMemory:
7919            image_error ("Out of memory (%s)", img->spec, Qnil);            image_error ("Out of memory (%s)", img->spec, Qnil);
7920            break;            break;
7921              
7922          case XpmColorFailed:          case XpmColorFailed:
7923            image_error ("Color allocation error (%s)", img->spec, Qnil);            image_error ("Color allocation error (%s)", img->spec, Qnil);
7924            break;            break;
7925              
7926          default:          default:
7927            image_error ("Unknown error (%s)", img->spec, Qnil);            image_error ("Unknown error (%s)", img->spec, Qnil);
7928            break;            break;
# Line 8028  lookup_rgb_color (f, r, g, b) Line 8028  lookup_rgb_color (f, r, g, b)
8028        color.red = r;        color.red = r;
8029        color.green = g;        color.green = g;
8030        color.blue = b;        color.blue = b;
8031          
8032        cmap = FRAME_X_COLORMAP (f);        cmap = FRAME_X_COLORMAP (f);
8033        rc = x_alloc_nearest_color (f, cmap, &color);        rc = x_alloc_nearest_color (f, cmap, &color);
8034    
8035        if (rc)        if (rc)
8036          {          {
8037            ++ct_colors_allocated;            ++ct_colors_allocated;
8038          
8039            p = (struct ct_color *) xmalloc (sizeof *p);            p = (struct ct_color *) xmalloc (sizeof *p);
8040            p->r = r;            p->r = r;
8041            p->g = g;            p->g = g;
# Line 8081  lookup_pixel_color (f, pixel) Line 8081  lookup_pixel_color (f, pixel)
8081        if (rc)        if (rc)
8082          {          {
8083            ++ct_colors_allocated;            ++ct_colors_allocated;
8084          
8085            p = (struct ct_color *) xmalloc (sizeof *p);            p = (struct ct_color *) xmalloc (sizeof *p);
8086            p->r = color.red;            p->r = color.red;
8087            p->g = color.green;            p->g = color.green;
# Line 8093  lookup_pixel_color (f, pixel) Line 8093  lookup_pixel_color (f, pixel)
8093        else        else
8094          return FRAME_FOREGROUND_PIXEL (f);          return FRAME_FOREGROUND_PIXEL (f);
8095      }      }
8096      
8097    return p->pixel;    return p->pixel;
8098  }  }
8099    
# Line 8119  colors_in_color_table (n) Line 8119  colors_in_color_table (n)
8119        colors = (unsigned long *) xmalloc (ct_colors_allocated        colors = (unsigned long *) xmalloc (ct_colors_allocated
8120                                            * sizeof *colors);                                            * sizeof *colors);
8121        *n = ct_colors_allocated;        *n = ct_colors_allocated;
8122          
8123        for (i = j = 0; i < CT_SIZE; ++i)        for (i = j = 0; i < CT_SIZE; ++i)
8124          for (p = ct_table[i]; p; p = p->next)          for (p = ct_table[i]; p; p = p->next)
8125            colors[j++] = p->pixel;            colors[j++] = p->pixel;
# Line 8194  x_to_xcolors (f, img, rgb_p) Line 8194  x_to_xcolors (f, img, rgb_p)
8194    for (y = 0; y < img->height; ++y)    for (y = 0; y < img->height; ++y)
8195      {      {
8196        XColor *row = p;        XColor *row = p;
8197          
8198        for (x = 0; x < img->width; ++x, ++p)        for (x = 0; x < img->width; ++x, ++p)
8199          p->pixel = XGetPixel (ximg, x, y);          p->pixel = XGetPixel (ximg, x, y);
8200    
# Line 8221  x_from_xcolors (f, img, colors) Line 8221  x_from_xcolors (f, img, colors)
8221    XImage *oimg;    XImage *oimg;
8222    Pixmap pixmap;    Pixmap pixmap;
8223    XColor *p;    XColor *p;
8224      
8225    init_color_table ();    init_color_table ();
8226      
8227    x_create_x_image_and_pixmap (f, img->width, img->height, 0,    x_create_x_image_and_pixmap (f, img->width, img->height, 0,
8228                                 &oimg, &pixmap);                                 &oimg, &pixmap);
8229    p = colors;    p = colors;
# Line 8250  x_from_xcolors (f, img, colors) Line 8250  x_from_xcolors (f, img, colors)
8250    
8251     MATRIX is a nine-element array specifying the transformation     MATRIX is a nine-element array specifying the transformation
8252     matrix.  See emboss_matrix for an example.     matrix.  See emboss_matrix for an example.
8253      
8254     COLOR_ADJUST is a color adjustment added to each pixel of the     COLOR_ADJUST is a color adjustment added to each pixel of the
8255     outgoing image.  */     outgoing image.  */
8256    
# Line 8278  x_detect_edges (f, img, matrix, color_ad Line 8278  x_detect_edges (f, img, matrix, color_ad
8278        p = COLOR (new, img->width - 1, y);        p = COLOR (new, img->width - 1, y);
8279        p->red = p->green = p->blue = 0xffff/2;        p->red = p->green = p->blue = 0xffff/2;
8280      }      }
8281      
8282    for (x = 1; x < img->width - 1; ++x)    for (x = 1; x < img->width - 1; ++x)
8283      {      {
8284        p = COLOR (new, x, 0);        p = COLOR (new, x, 0);
# Line 8290  x_detect_edges (f, img, matrix, color_ad Line 8290  x_detect_edges (f, img, matrix, color_ad
8290    for (y = 1; y < img->height - 1; ++y)    for (y = 1; y < img->height - 1; ++y)
8291      {      {
8292        p = COLOR (new, 1, y);        p = COLOR (new, 1, y);
8293          
8294        for (x = 1; x < img->width - 1; ++x, ++p)        for (x = 1; x < img->width - 1; ++x, ++p)
8295          {          {
8296            int r, g, b, y1, x1;            int r, g, b, y1, x1;
# Line 8363  x_edge_detection (f, img, matrix, color_ Line 8363  x_edge_detection (f, img, matrix, color_
8363  {  {
8364    int i = 0;    int i = 0;
8365    int trans[9];    int trans[9];
8366      
8367    if (CONSP (matrix))    if (CONSP (matrix))
8368      {      {
8369        for (i = 0;        for (i = 0;
# Line 8483  x_build_heuristic_mask (f, img, how) Line 8483  x_build_heuristic_mask (f, img, how)
8483    /* Determine the background color of ximg.  If HOW is `(R G B)'    /* Determine the background color of ximg.  If HOW is `(R G B)'
8484       take that as color.  Otherwise, use the image's background color. */       take that as color.  Otherwise, use the image's background color. */
8485    use_img_background = 1;    use_img_background = 1;
8486      
8487    if (CONSP (how))    if (CONSP (how))
8488      {      {
8489        int rgb[3], i;        int rgb[3], i;
# Line 8502  x_build_heuristic_mask (f, img, how) Line 8502  x_build_heuristic_mask (f, img, how)
8502            use_img_background = 0;            use_img_background = 0;
8503          }          }
8504      }      }
8505      
8506    if (use_img_background)    if (use_img_background)
8507      bg = four_corners_best (ximg, img->width, img->height);      bg = four_corners_best (ximg, img->width, img->height);
8508    
# Line 8519  x_build_heuristic_mask (f, img, how) Line 8519  x_build_heuristic_mask (f, img, how)
8519    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);
8520    x_destroy_x_image (mask_img);    x_destroy_x_image (mask_img);
8521    XDestroyImage (ximg);    XDestroyImage (ximg);
8522      
8523    return 1;    return 1;
8524  }  }
8525    
# Line 8592  pbm_image_p (object) Line 8592  pbm_image_p (object)
8592       Lisp_Object object;       Lisp_Object object;
8593  {  {
8594    struct image_keyword fmt[PBM_LAST];    struct image_keyword fmt[PBM_LAST];
8595      
8596    bcopy (pbm_format, fmt, sizeof fmt);    bcopy (pbm_format, fmt, sizeof fmt);
8597      
8598    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
8599      return 0;      return 0;
8600    
# Line 8643  pbm_scan_number (s, end) Line 8643  pbm_scan_number (s, end)
8643    
8644  /* Load PBM image IMG for use on frame F.  */  /* Load PBM image IMG for use on frame F.  */
8645    
8646  static int  static int
8647  pbm_load (f, img)  pbm_load (f, img)
8648       struct frame *f;       struct frame *f;
8649       struct image *img;       struct image *img;
# Line 8706  pbm_load (f, img) Line 8706  pbm_load (f, img)
8706      case '1':      case '1':
8707        raw_p = 0, type = PBM_MONO;        raw_p = 0, type = PBM_MONO;
8708        break;        break;
8709          
8710      case '2':      case '2':
8711        raw_p = 0, type = PBM_GRAY;        raw_p = 0, type = PBM_GRAY;
8712        break;        break;
# Line 8718  pbm_load (f, img) Line 8718  pbm_load (f, img)
8718      case '4':      case '4':
8719        raw_p = 1, type = PBM_MONO;        raw_p = 1, type = PBM_MONO;
8720        break;        break;
8721          
8722      case '5':      case '5':
8723        raw_p = 1, type = PBM_GRAY;        raw_p = 1, type = PBM_GRAY;
8724        break;        break;
8725          
8726      case '6':      case '6':
8727        raw_p = 1, type = PBM_COLOR;        raw_p = 1, type = PBM_COLOR;
8728        break;        break;
# Line 8743  pbm_load (f, img) Line 8743  pbm_load (f, img)
8743        if (raw_p && max_color_idx > 255)        if (raw_p && max_color_idx > 255)
8744          max_color_idx = 255;          max_color_idx = 255;
8745      }      }
8746      
8747    if (width < 0    if (width < 0
8748        || height < 0        || height < 0
8749        || (type != PBM_MONO && max_color_idx < 0))        || (type != PBM_MONO && max_color_idx < 0))
# Line 8752  pbm_load (f, img) Line 8752  pbm_load (f, img)
8752    if (!x_create_x_image_and_pixmap (f, width, height, 0,    if (!x_create_x_image_and_pixmap (f, width, height, 0,
8753                                      &ximg, &img->pixmap))                                      &ximg, &img->pixmap))
8754      goto error;      goto error;
8755      
8756    /* Initialize the color hash table.  */    /* Initialize the color hash table.  */
8757    init_color_table ();    init_color_table ();
8758    
# Line 8766  pbm_load (f, img) Line 8766  pbm_load (f, img)
8766        /* Parse the image specification.  */        /* Parse the image specification.  */
8767        bcopy (pbm_format, fmt, sizeof fmt);        bcopy (pbm_format, fmt, sizeof fmt);
8768        parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);        parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);
8769          
8770        /* Get foreground and background colors, maybe allocate colors.  */        /* Get foreground and background colors, maybe allocate colors.  */
8771        if (fmt[PBM_FOREGROUND].count        if (fmt[PBM_FOREGROUND].count
8772            && STRINGP (fmt[PBM_FOREGROUND].value))            && STRINGP (fmt[PBM_FOREGROUND].value))
# Line 8778  pbm_load (f, img) Line 8778  pbm_load (f, img)
8778            img->background = bg;            img->background = bg;
8779            img->background_valid = 1;            img->background_valid = 1;
8780          }          }
8781          
8782        for (y = 0; y < height; ++y)        for (y = 0; y < height; ++y)
8783          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
8784            {            {
# Line 8801  pbm_load (f, img) Line 8801  pbm_load (f, img)
8801          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
8802            {            {
8803              int r, g, b;              int r, g, b;
8804                
8805              if (type == PBM_GRAY)              if (type == PBM_GRAY)
8806                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
8807              else if (raw_p)              else if (raw_p)
# Line 8816  pbm_load (f, img) Line 8816  pbm_load (f, img)
8816                  g = pbm_scan_number (&p, end);                  g = pbm_scan_number (&p, end);
8817                  b = pbm_scan_number (&p, end);                  b = pbm_scan_number (&p, end);
8818                }                }
8819                
8820              if (r < 0 || g < 0 || b < 0)              if (r < 0 || g < 0 || b < 0)
8821                {                {
8822                  xfree (ximg->data);                  xfree (ximg->data);
# Line 8826  pbm_load (f, img) Line 8826  pbm_load (f, img)
8826                               img->spec, Qnil);                               img->spec, Qnil);
8827                  goto error;                  goto error;
8828                }                }
8829                
8830              /* RGB values are now in the range 0..max_color_idx.              /* RGB values are now in the range 0..max_color_idx.
8831                 Scale this to the range 0..0xffff supported by X.  */                 Scale this to the range 0..0xffff supported by X.  */
8832              r = (double) r * 65535 / max_color_idx;              r = (double) r * 65535 / max_color_idx;
# Line 8835  pbm_load (f, img) Line 8835  pbm_load (f, img)
8835              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
8836            }            }
8837      }      }
8838      
8839    /* Store in IMG->colors the colors allocated for the image, and    /* Store in IMG->colors the colors allocated for the image, and
8840       free the color table.  */       free the color table.  */
8841    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
# Line 8844  pbm_load (f, img) Line 8844  pbm_load (f, img)
8844    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
8845    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8846      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
8847      
8848    /* Put the image into a pixmap.  */    /* Put the image into a pixmap.  */
8849    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
8850    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
8851          
8852    img->width = width;    img->width = width;
8853    img->height = height;    img->height = height;
8854    
# Line 8930  png_image_p (object) Line 8930  png_image_p (object)
8930  {  {
8931    struct image_keyword fmt[PNG_LAST];    struct image_keyword fmt[PNG_LAST];
8932    bcopy (png_format, fmt, sizeof fmt);    bcopy (png_format, fmt, sizeof fmt);
8933      
8934    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
8935      return 0;      return 0;
8936    
# Line 8987  png_read_from_memory (png_ptr, data, len Line 8987  png_read_from_memory (png_ptr, data, len
8987    
8988    if (length > tbr->len - tbr->index)    if (length > tbr->len - tbr->index)
8989      png_error (png_ptr, "Read error");      png_error (png_ptr, "Read error");
8990      
8991    bcopy (tbr->bytes + tbr->index, data, length);    bcopy (tbr->bytes + tbr->index, data, length);
8992    tbr->index = tbr->index + length;    tbr->index = tbr->index + length;
8993  }  }
# Line 9129  png_load (f, img) Line 9129  png_load (f, img)
9129    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,
9130                  &interlace_type, NULL, NULL);                  &interlace_type, NULL, NULL);
9131    
9132    /* If image contains simply transparency data, we prefer to    /* If image contains simply transparency data, we prefer to
9133       construct a clipping mask.  */       construct a clipping mask.  */
9134    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
9135      transparent_p = 1;      transparent_p = 1;
9136    else    else
9137      transparent_p = 0;      transparent_p = 0;
9138    
9139    /* This function is easier to write if we only have to handle    /* This function is easier to write if we only have to handle
9140       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
9141       transform other formats into that format.  */       transform other formats into that format.  */
9142    
# Line 9149  png_load (f, img) Line 9149  png_load (f, img)
9149    png_set_expand (png_ptr);    png_set_expand (png_ptr);
9150    
9151    /* Convert grayscale images to RGB.  */    /* Convert grayscale images to RGB.  */
9152    if (color_type == PNG_COLOR_TYPE_GRAY    if (color_type == PNG_COLOR_TYPE_GRAY
9153        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
9154      png_set_gray_to_rgb (png_ptr);      png_set_gray_to_rgb (png_ptr);
9155    
# Line 9198  png_load (f, img) Line 9198  png_load (f, img)
9198              }              }
9199          }          }
9200        else if (png_get_bKGD (png_ptr, info_ptr, &image_bg))        else if (png_get_bKGD (png_ptr, info_ptr, &image_bg))
9201          /* Image contains a background color with which to          /* Image contains a background color with which to
9202             combine the image.  */             combine the image.  */
9203          png_set_background (png_ptr, image_bg,          png_set_background (png_ptr, image_bg,
9204                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
9205        else        else
9206          {          {
9207            /* Image does not contain a background color with which            /* Image does not contain a background color with which
9208               to combine the image data via an alpha channel.  Use               to combine the image data via an alpha channel.  Use
9209               the frame's background instead.  */               the frame's background instead.  */
9210            XColor color;            XColor color;
9211            Colormap cmap;            Colormap cmap;
# Line 9253  png_load (f, img) Line 9253  png_load (f, img)
9253        fclose (fp);        fclose (fp);
9254        fp = NULL;        fp = NULL;
9255      }      }
9256      
9257    /* Create the X image and pixmap.  */    /* Create the X image and pixmap.  */
9258    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,    if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
9259                                      &img->pixmap))                                      &img->pixmap))
9260      goto error;      goto error;
9261      
9262    /* Create an image and pixmap serving as mask if the PNG image    /* Create an image and pixmap serving as mask if the PNG image
9263       contains an alpha channel.  */       contains an alpha channel.  */
9264    if (channels == 4    if (channels == 4
# Line 9289  png_load (f, img) Line 9289  png_load (f, img)
9289            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
9290    
9291            /* An alpha channel, aka mask channel, associates variable            /* An alpha channel, aka mask channel, associates variable
9292               transparency with an image.  Where other image formats               transparency with an image.  Where other image formats
9293               support binary transparency---fully transparent or fully               support binary transparency---fully transparent or fully
9294               opaque---PNG allows up to 254 levels of partial transparency.               opaque---PNG allows up to 254 levels of partial transparency.
9295               The PNG library implements partial transparency by combining               The PNG library implements partial transparency by combining
9296               the image with a specified background color.               the image with a specified background color.
9297    
9298               I'm not sure how to handle this here nicely: because the               I'm not sure how to handle this here nicely: because the
9299               background on which the image is displayed may change, for               background on which the image is displayed may change, for
9300               real alpha channel support, it would be necessary to create               real alpha channel support, it would be necessary to create
9301               a new image for each possible background.                 a new image for each possible background.
9302    
9303               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
9304               boolean transparency information.  Otherwise I'm using               boolean transparency information.  Otherwise I'm using
# Line 9444  jpeg_image_p (object) Line 9444  jpeg_image_p (object)
9444       Lisp_Object object;       Lisp_Object object;
9445  {  {
9446    struct image_keyword fmt[JPEG_LAST];    struct image_keyword fmt[JPEG_LAST];
9447      
9448    bcopy (jpeg_format, fmt, sizeof fmt);    bcopy (jpeg_format, fmt, sizeof fmt);
9449      
9450    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
9451      return 0;      return 0;
9452    
# Line 9517  our_skip_input_data (cinfo, num_bytes) Line 9517  our_skip_input_data (cinfo, num_bytes)
9517      {      {
9518        if (num_bytes > src->bytes_in_buffer)        if (num_bytes > src->bytes_in_buffer)
9519          ERREXIT (cinfo, JERR_INPUT_EOF);          ERREXIT (cinfo, JERR_INPUT_EOF);
9520          
9521        src->bytes_in_buffer -= num_bytes;        src->bytes_in_buffer -= num_bytes;
9522        src->next_input_byte += num_bytes;        src->next_input_byte += num_bytes;
9523      }      }
# Line 9555  jpeg_memory_src (cinfo, data, len) Line 9555  jpeg_memory_src (cinfo, data, len)
9555        src = (struct jpeg_source_mgr *) cinfo->src;        src = (struct jpeg_source_mgr *) cinfo->src;
9556        src->next_input_byte = data;        src->next_input_byte = data;
9557      }      }
9558      
9559    src = (struct jpeg_source_mgr *) cinfo->src;    src = (struct jpeg_source_mgr *) cinfo->src;
9560    src->init_source = our_init_source;    src->init_source = our_init_source;
9561    src->fill_input_buffer = our_fill_input_buffer;    src->fill_input_buffer = our_fill_input_buffer;
# Line 9570  jpeg_memory_src (cinfo, data, len) Line 9570  jpeg_memory_src (cinfo, data, len)
9570  /* Load image IMG for use on frame F.  Patterned after example.c  /* Load image IMG for use on frame F.  Patterned after example.c
9571     from the JPEG lib.  */     from the JPEG lib.  */
9572    
9573  static int  static int
9574  jpeg_load (f, img)  jpeg_load (f, img)
9575       struct frame *f;       struct frame *f;
9576       struct image *img;       struct image *img;
# Line 9603  jpeg_load (f, img) Line 9603  jpeg_load (f, img)
9603            UNGCPRO;            UNGCPRO;
9604            return 0;            return 0;
9605          }          }
9606      
9607        fp = fopen (SDATA (file), "r");        fp = fopen (SDATA (file), "r");
9608        if (fp == NULL)        if (fp == NULL)
9609          {          {
# Line 9617  jpeg_load (f, img) Line 9617  jpeg_load (f, img)
9617       error is detected.  This function will perform a longjmp.  */       error is detected.  This function will perform a longjmp.  */
9618    cinfo.err = jpeg_std_error (&mgr.pub);    cinfo.err = jpeg_std_error (&mgr.pub);
9619    mgr.pub.error_exit = my_error_exit;    mgr.pub.error_exit = my_error_exit;
9620      
9621    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
9622      {      {
9623        if (rc == 1)        if (rc == 1)
# Line 9628  jpeg_load (f, img) Line 9628  jpeg_load (f, img)
9628            image_error ("Error reading JPEG image `%s': %s", img->spec,            image_error ("Error reading JPEG image `%s': %s", img->spec,
9629                         build_string (buffer));                         build_string (buffer));
9630          }          }
9631              
9632        /* Close the input file and destroy the JPEG object.  */        /* Close the input file and destroy the JPEG object.  */
9633        if (fp)        if (fp)
9634          fclose ((FILE *) fp);          fclose ((FILE *) fp);
# Line 9639  jpeg_load (f, img) Line 9639  jpeg_load (f, img)
9639    
9640        /* Free pixmap and colors.  */        /* Free pixmap and colors.  */
9641        x_clear_image (f, img);        x_clear_image (f, img);
9642          
9643        UNGCPRO;        UNGCPRO;
9644        return 0;        return 0;
9645      }      }
# Line 9689  jpeg_load (f, img) Line 9689  jpeg_load (f, img)
9689      init_color_table ();      init_color_table ();
9690      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
9691                                         * sizeof *colors);                                         * sizeof *colors);
9692      
9693      for (i = 0; i < cinfo.actual_number_of_colors; ++i)      for (i = 0; i < cinfo.actual_number_of_colors; ++i)
9694        {        {
9695          /* Multiply RGB values with 255 because X expects RGB values          /* Multiply RGB values with 255 because X expects RGB values
# Line 9725  jpeg_load (f, img) Line 9725  jpeg_load (f, img)
9725    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
9726    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
9727      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
9728      
9729    /* Put the image into the pixmap.  */    /* Put the image into the pixmap.  */
9730    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
9731    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 9806  tiff_image_p (object) Line 9806  tiff_image_p (object)
9806  {  {
9807    struct image_keyword fmt[TIFF_LAST];    struct image_keyword fmt[TIFF_LAST];
9808    bcopy (tiff_format, fmt, sizeof fmt);    bcopy (tiff_format, fmt, sizeof fmt);
9809      
9810    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
9811      return 0;      return 0;
9812      
9813    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
9814    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
9815  }  }
# Line 9873  tiff_seek_in_memory (data, off, whence) Line 9873  tiff_seek_in_memory (data, off, whence)
9873      case SEEK_SET:              /* Go from beginning of source.  */      case SEEK_SET:              /* Go from beginning of source.  */
9874        idx = off;        idx = off;
9875        break;        break;
9876          
9877      case SEEK_END:              /* Go from end of source.  */      case SEEK_END:              /* Go from end of source.  */
9878        idx = src->len + off;        idx = src->len + off;
9879        break;        break;
9880          
9881      case SEEK_CUR:              /* Go from current position.  */      case SEEK_CUR:              /* Go from current position.  */
9882        idx = src->index + off;        idx = src->index + off;
9883        break;        break;
9884          
9885      default:                    /* Invalid `whence'.   */      default:                    /* Invalid `whence'.   */
9886        return -1;        return -1;
9887      }      }
9888      
9889    if (idx > src->len || idx < 0)    if (idx > src->len || idx < 0)
9890      return -1;      return -1;
9891      
9892    src->index = idx;    src->index = idx;
9893    return src->index;    return src->index;
9894  }  }
# Line 9939  tiff_error_handler (title, format, ap) Line 9939  tiff_error_handler (title, format, ap)
9939  {  {
9940    char buf[512];    char buf[512];
9941    int len;    int len;
9942      
9943    len = sprintf (buf, "TIFF error: %s ", title);    len = sprintf (buf, "TIFF error: %s ", title);
9944    vsprintf (buf + len, format, ap);    vsprintf (buf + len, format, ap);
9945    add_to_log (buf, Qnil, Qnil);    add_to_log (buf, Qnil, Qnil);
# Line 9953  tiff_warning_handler (title, format, ap) Line 9953  tiff_warning_handler (title, format, ap)
9953  {  {
9954    char buf[512];    char buf[512];
9955    int len;    int len;
9956      
9957    len = sprintf (buf, "TIFF warning: %s ", title);    len = sprintf (buf, "TIFF warning: %s ", title);
9958    vsprintf (buf + len, format, ap);    vsprintf (buf + len, format, ap);
9959    add_to_log (buf, Qnil, Qnil);    add_to_log (buf, Qnil, Qnil);
# Line 9996  tiff_load (f, img) Line 9996  tiff_load (f, img)
9996            UNGCPRO;            UNGCPRO;
9997            return 0;            return 0;
9998          }          }
9999              
10000        /* Try to open the image file.  */        /* Try to open the image file.  */
10001        tiff = TIFFOpen (SDATA (file), "r");        tiff = TIFFOpen (SDATA (file), "r");
10002        if (tiff == NULL)        if (tiff == NULL)
# Line 10035  tiff_load (f, img) Line 10035  tiff_load (f, img)
10035    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
10036    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
10037    buf = (uint32 *) xmalloc (width * height * sizeof *buf);    buf = (uint32 *) xmalloc (width * height * sizeof *buf);
10038      
10039    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
10040    TIFFClose (tiff);    TIFFClose (tiff);
10041    if (!rc)    if (!rc)
# Line 10061  tiff_load (f, img) Line 10061  tiff_load (f, img)
10061    for (y = 0; y < height; ++y)    for (y = 0; y < height; ++y)
10062      {      {
10063        uint32 *row = buf + y * width;        uint32 *row = buf + y * width;
10064          
10065        for (x = 0; x < width; ++x)        for (x = 0; x < width; ++x)
10066          {          {
10067            uint32 abgr = row[x];            uint32 abgr = row[x];
10068            int r = TIFFGetR (abgr) << 8;            int r = TIFFGetR (abgr) << 8;
10069            int g = TIFFGetG (abgr) << 8;            int g = TIFFGetG (abgr) << 8;
10070            int b = TIFFGetB (abgr) << 8;            int b = TIFFGetB (abgr) << 8;
10071            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));
10072          }          }
10073      }      }
10074    
10075    /* Remember the colors allocated for the image.  Free the color table.  */    /* Remember the colors allocated for the image.  Free the color table.  */
10076    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
10077    free_color_table ();    free_color_table ();
10078          
10079    img->width = width;    img->width = width;
10080    img->height = height;    img->height = height;
10081    
# Line 10167  gif_image_p (object) Line 10167  gif_image_p (object)
10167  {  {
10168    struct image_keyword fmt[GIF_LAST];    struct image_keyword fmt[GIF_LAST];
10169    bcopy (gif_format, fmt, sizeof fmt);    bcopy (gif_format, fmt, sizeof fmt);
10170      
10171    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
10172      return 0;      return 0;
10173      
10174    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
10175    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
10176  }  }
# Line 10245  gif_load (f, img) Line 10245  gif_load (f, img)
10245            UNGCPRO;            UNGCPRO;
10246            return 0;            return 0;
10247          }          }
10248      
10249        /* Open the GIF file.  */        /* Open the GIF file.  */
10250        gif = DGifOpenFileName (SDATA (file));        gif = DGifOpenFileName (SDATA (file));
10251        if (gif == NULL)        if (gif == NULL)
# Line 10303  gif_load (f, img) Line 10303  gif_load (f, img)
10303        UNGCPRO;        UNGCPRO;
10304        return 0;        return 0;
10305      }      }
10306      
10307    /* Allocate colors.  */    /* Allocate colors.  */
10308    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
10309    if (!gif_color_map)    if (!gif_color_map)
10310      gif_color_map = gif->SColorMap;      gif_color_map = gif->SColorMap;
10311    init_color_table ();    init_color_table ();
10312    bzero (pixel_colors, sizeof pixel_colors);    bzero (pixel_colors, sizeof pixel_colors);
10313      
10314    for (i = 0; i < gif_color_map->ColorCount; ++i)    for (i = 0; i < gif_color_map->ColorCount; ++i)
10315      {      {
10316        int r = gif_color_map->Colors[i].Red << 8;        int r = gif_color_map->Colors[i].Red << 8;
# Line 10323  gif_load (f, img) Line 10323  gif_load (f, img)
10323    free_color_table ();    free_color_table ();
10324    
10325    /* Clear the part of the screen image that are not covered by    /* Clear the part of the screen image that are not covered by
10326       the image from the GIF file.  Full animated GIF support       the image from the GIF file.  Full animated GIF support
10327       requires more than can be done here (see the gif89 spec,       requires more than can be done here (see the gif89 spec,
10328       disposal methods).  Let's simply assume that the part       disposal methods).  Let's simply assume that the part
10329       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 10352  gif_load (f, img) Line 10352  gif_load (f, img)
10352       `raster' here because RasterBits below is a char *, and invites       `raster' here because RasterBits below is a char *, and invites
10353       problems with bytes >= 0x80.  */       problems with bytes >= 0x80.  */
10354    raster = (unsigned char *) gif->SavedImages[ino].RasterBits;    raster = (unsigned char *) gif->SavedImages[ino].RasterBits;
10355      
10356    if (gif->SavedImages[ino].ImageDesc.Interlace)    if (gif->SavedImages[ino].ImageDesc.Interlace)
10357      {      {
10358        static int interlace_start[] = {0, 4, 2, 1};        static int interlace_start[] = {0, 4, 2, 1};
# Line 10370  gif_load (f, img) Line 10370  gif_load (f, img)
10370                while (row >= image_height)                while (row >= image_height)
10371                  row = interlace_start[++pass];                  row = interlace_start[++pass];
10372              }              }
10373              
10374            for (x = 0; x < image_width; x++)            for (x = 0; x < image_width; x++)
10375              {              {
10376                int i = raster[(y * image_width) + x];                int i = raster[(y * image_width) + x];
10377                XPutPixel (ximg, x + image_left, row + image_top,                XPutPixel (ximg, x + image_left, row + image_top,
10378                           pixel_colors[i]);                           pixel_colors[i]);
10379              }              }
10380              
10381            row += interlace_increment[pass];            row += interlace_increment[pass];
10382          }          }
10383      }      }
# Line 10390  gif_load (f, img) Line 10390  gif_load (f, img)
10390              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
10391            }            }
10392      }      }
10393      
10394    DGifCloseFile (gif);    DGifCloseFile (gif);
10395    
10396    /* Maybe fill in the background field while we have ximg handy. */    /* Maybe fill in the background field while we have ximg handy. */
10397    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))    if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
10398      IMAGE_BACKGROUND (img, f, ximg);      IMAGE_BACKGROUND (img, f, ximg);
10399      
10400    /* 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.  */
10401    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
10402    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
10403          
10404    UNGCPRO;    UNGCPRO;
10405    return 1;    return 1;
10406  }  }
# Line 10500  gs_image_p (object) Line 10500  gs_image_p (object)
10500    struct image_keyword fmt[GS_LAST];    struct image_keyword fmt[GS_LAST];
10501    Lisp_Object tem;    Lisp_Object tem;
10502    int i;    int i;
10503      
10504    bcopy (gs_format, fmt, sizeof fmt);    bcopy (gs_format, fmt, sizeof fmt);
10505      
10506    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
10507      return 0;      return 0;
10508    
# Line 10568  gs_load (f, img) Line 10568  gs_load (f, img)
10568        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
10569        return 0;        return 0;
10570      }      }
10571        
10572    /* Call the loader to fill the pixmap.  It returns a process object    /* Call the loader to fill the pixmap.  It returns a process object
10573       if successful.  We do not record_unwind_protect here because       if successful.  We do not record_unwind_protect here because
10574       other places in redisplay like calling window scroll functions       other places in redisplay like calling window scroll functions
# Line 10579  gs_load (f, img) Line 10579  gs_load (f, img)
10579             (unsigned long) FRAME_X_WINDOW (f),             (unsigned long) FRAME_X_WINDOW (f),
10580             (unsigned long) img->pixmap);             (unsigned long) img->pixmap);
10581    window_and_pixmap_id = build_string (buffer);    window_and_pixmap_id = build_string (buffer);
10582      
10583    sprintf (buffer, "%lu %lu",    sprintf (buffer, "%lu %lu",
10584             FRAME_FOREGROUND_PIXEL (f),             FRAME_FOREGROUND_PIXEL (f),
10585             FRAME_BACKGROUND_PIXEL (f));             FRAME_BACKGROUND_PIXEL (f));
10586    pixel_colors = build_string (buffer);    pixel_colors = build_string (buffer);
10587      
10588    XSETFRAME (frame, f);    XSETFRAME (frame, f);
10589    loader = image_spec_value (img->spec, QCloader, NULL);    loader = image_spec_value (img->spec, QCloader, NULL);
10590    if (NILP (loader))    if (NILP (loader))
# Line 10622  x_kill_gs_process (pixmap, f) Line 10622  x_kill_gs_process (pixmap, f)
10622       instance, give up.  */       instance, give up.  */
10623    if (i == c->used)    if (i == c->used)
10624      return;      return;
10625      
10626    /* Kill the GS process.  We should have found PIXMAP in the image    /* Kill the GS process.  We should have found PIXMAP in the image
10627       cache and its image should contain a process object.  */       cache and its image should contain a process object.  */
10628    img = c->images[i];    img = c->images[i];
# Line 10646  x_kill_gs_process (pixmap, f) Line 10646  x_kill_gs_process (pixmap, f)
10646        if (ximg)        if (ximg)
10647          {          {
10648            int x, y;            int x, y;
10649              
10650            /* Initialize the color table.  */            /* Initialize the color table.  */
10651            init_color_table ();            init_color_table ();
10652          
10653            /* For each pixel of the image, look its color up in the            /* For each pixel of the image, look its color up in the
10654               color table.  After having done so, the color table will               color table.  After having done so, the color table will
10655               contain an entry for each color used by the image.  */               contain an entry for each color used by the image.  */
# Line 10678  x_kill_gs_process (pixmap, f) Line 10678  x_kill_gs_process (pixmap, f)
10678        else        else
10679          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",
10680                       img->spec, Qnil);                       img->spec, Qnil);
10681          
10682        UNBLOCK_INPUT;        UNBLOCK_INPUT;
10683      }      }
10684    
# Line 10781  value.  */) Line 10781  value.  */)
10781        rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),        rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
10782                                 prop_atom, 0, bytes_remaining,                                 prop_atom, 0, bytes_remaining,
10783                                 False, XA_STRING,                                 False, XA_STRING,
10784                                 &actual_type, &actual_format,                                 &actual_type, &actual_format,
10785                                 &actual_size, &bytes_remaining,                                 &actual_size, &bytes_remaining,
10786                                 (unsigned char **) &tmp_data);                                 (unsigned char **) &tmp_data);
10787        if (rc == Success && tmp_data)        if (rc == Success && tmp_data)
10788          prop_value = make_string (tmp_data, size);          prop_value = make_string (tmp_data, size);
# Line 10831  start_hourglass () Line 10831  start_hourglass ()
10831  {  {
10832    EMACS_TIME delay;    EMACS_TIME delay;
10833    int secs, usecs = 0;    int secs, usecs = 0;
10834      
10835    cancel_hourglass ();    cancel_hourglass ();
10836    
10837    if (INTEGERP (Vhourglass_delay)    if (INTEGERP (Vhourglass_delay)
# Line 10847  start_hourglass () Line 10847  start_hourglass ()
10847      }      }
10848    else    else
10849      secs = DEFAULT_HOURGLASS_DELAY;      secs = DEFAULT_HOURGLASS_DELAY;
10850      
10851    EMACS_SET_SECS_USECS (delay, secs, usecs);    EMACS_SET_SECS_USECS (delay, secs, usecs);
10852    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
10853                                       show_hourglass, NULL);                                       show_hourglass, NULL);
# Line 10865  cancel_hourglass () Line 10865  cancel_hourglass ()
10865        cancel_atimer (hourglass_atimer);        cancel_atimer (hourglass_atimer);
10866        hourglass_atimer = NULL;        hourglass_atimer = NULL;
10867      }      }
10868      
10869    if (hourglass_shown_p)    if (hourglass_shown_p)
10870      hide_hourglass ();      hide_hourglass ();
10871  }  }
# Line 10891  show_hourglass (timer) Line 10891  show_hourglass (timer)
10891    if (!hourglass_shown_p)    if (!hourglass_shown_p)
10892      {      {
10893        Lisp_Object rest, frame;        Lisp_Object rest, frame;
10894      
10895        BLOCK_INPUT;        BLOCK_INPUT;
10896      
10897        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
10898          {          {
10899            struct frame *f = XFRAME (frame);            struct frame *f = XFRAME (frame);
10900              
10901            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))
10902              {              {
10903                Display *dpy = FRAME_X_DISPLAY (f);                Display *dpy = FRAME_X_DISPLAY (f);
10904                  
10905  #ifdef USE_X_TOOLKIT  #ifdef USE_X_TOOLKIT
10906                if (f->output_data.x->widget)                if (f->output_data.x->widget)
10907  #else  #else
# Line 10909  show_hourglass (timer) Line 10909  show_hourglass (timer)
10909  #endif  #endif
10910                  {                  {
10911                    f->output_data.x->hourglass_p = 1;                    f->output_data.x->hourglass_p = 1;
10912            
10913                    if (!f->output_data.x->hourglass_window)                    if (!f->output_data.x->hourglass_window)
10914                      {                      {
10915                        unsigned long mask = CWCursor;                        unsigned long mask = CWCursor;
10916                        XSetWindowAttributes attrs;                        XSetWindowAttributes attrs;
10917                
10918                        attrs.cursor = f->output_data.x->hourglass_cursor;                        attrs.cursor = f->output_data.x->hourglass_cursor;
10919                
10920                        f->output_data.x->hourglass_window                        f->output_data.x->hourglass_window
10921                          = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f),                          = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f),
10922                                           0, 0, 32000, 32000, 0, 0,                                           0, 0, 32000, 32000, 0, 0,
# Line 10924  show_hourglass (timer) Line 10924  show_hourglass (timer)
10924                                           CopyFromParent,                                           CopyFromParent,
10925                                           mask, &attrs);                                           mask, &attrs);
10926                      }                      }
10927            
10928                    XMapRaised (dpy, f->output_data.x->hourglass_window);                    XMapRaised (dpy, f->output_data.x->hourglass_window);
10929                    XFlush (dpy);                    XFlush (dpy);
10930                  }                  }
# Line 10951  hide_hourglass () Line 10951  hide_hourglass ()
10951        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
10952          {          {
10953            struct frame *f = XFRAME (frame);            struct frame *f = XFRAME (frame);
10954          
10955            if (FRAME_X_P (f)            if (FRAME_X_P (f)
10956                /* Watch out for newly created frames.  */                /* Watch out for newly created frames.  */
10957                && f->output_data.x->hourglass_window)                && f->output_data.x->hourglass_window)
# Line 10980  static Lisp_Object x_create_tip_frame P_ Line 10980  static Lisp_Object x_create_tip_frame P_
10980                                             Lisp_Object, Lisp_Object));                                             Lisp_Object, Lisp_Object));
10981  static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,  static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
10982                                  Lisp_Object, int, int, int *, int *));                                  Lisp_Object, int, int, int *, int *));
10983        
10984  /* The frame of a currently visible tooltip.  */  /* The frame of a currently visible tooltip.  */
10985    
10986  Lisp_Object tip_frame;  Lisp_Object tip_frame;
# Line 11013  unwind_create_tip_frame (frame) Line 11013  unwind_create_tip_frame (frame)
11013        tip_window = None;        tip_window = None;
11014        tip_frame = Qnil;        tip_frame = Qnil;
11015      }      }
11016      
11017    return deleted;    return deleted;
11018  }  }
11019    
# Line 11077  x_create_tip_frame (dpyinfo, parms, text Line 11077  x_create_tip_frame (dpyinfo, parms, text
11077    Ferase_buffer ();    Ferase_buffer ();
11078    Finsert (1, &text);    Finsert (1, &text);
11079    set_buffer_internal_1 (old_buffer);    set_buffer_internal_1 (old_buffer);
11080      
11081    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
11082    record_unwind_protect (unwind_create_tip_frame, frame);    record_unwind_protect (unwind_create_tip_frame, frame);
11083    
# Line 11113  x_create_tip_frame (dpyinfo, parms, text Line 11113  x_create_tip_frame (dpyinfo, parms, text
11113    {    {
11114      Lisp_Object black;      Lisp_Object black;
11115      struct gcpro gcpro1;      struct gcpro gcpro1;
11116        
11117      black = build_string ("black");      black = build_string ("black");
11118      GCPRO1 (black);      GCPRO1 (black);
11119      f->output_data.x->foreground_pixel      f->output_data.x->foreground_pixel
# Line 11163  x_create_tip_frame (dpyinfo, parms, text Line 11163  x_create_tip_frame (dpyinfo, parms, text
11163          else          else
11164            font = x_new_font (f, SDATA (font));            font = x_new_font (f, SDATA (font));
11165        }        }
11166        
11167      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
11168      if (!STRINGP (font))      if (!STRINGP (font))
11169        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 11188  x_create_tip_frame (dpyinfo, parms, text Line 11188  x_create_tip_frame (dpyinfo, parms, text
11188    
11189    x_default_parameter (f, parms, Qborder_width, make_number (2),    x_default_parameter (f, parms, Qborder_width, make_number (2),
11190                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
11191      
11192    /* This defaults to 2 in order to match xterm.  We recognize either    /* This defaults to 2 in order to match xterm.  We recognize either
11193       internalBorderWidth or internalBorder (which is what xterm calls       internalBorderWidth or internalBorder (which is what xterm calls
11194       it).  */       it).  */
# Line 11226  x_create_tip_frame (dpyinfo, parms, text Line 11226  x_create_tip_frame (dpyinfo, parms, text
11226       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
11227       happen.  */       happen.  */
11228    init_frame_faces (f);    init_frame_faces (f);
11229      
11230    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;
11231    window_prompting = x_figure_window_size (f, parms);    window_prompting = x_figure_window_size (f, parms);
11232    
# Line 11249  x_create_tip_frame (dpyinfo, parms, text Line 11249  x_create_tip_frame (dpyinfo, parms, text
11249    {    {
11250      XSetWindowAttributes attrs;      XSetWindowAttributes attrs;
11251      unsigned long mask;      unsigned long mask;
11252        
11253      BLOCK_INPUT;      BLOCK_INPUT;
11254      mask = CWBackPixel | CWOverrideRedirect | CWEventMask;      mask = CWBackPixel | CWOverrideRedirect | CWEventMask;
11255      if (DoesSaveUnders (dpyinfo->screen))      if (DoesSaveUnders (dpyinfo->screen))
11256        mask |= CWSaveUnder;        mask |= CWSaveUnder;
11257        
11258      /* Window managers look at the override-redirect flag to determine      /* Window managers look at the override-redirect flag to determine
11259         whether or net to give windows a decoration (Xlib spec, chapter         whether or net to give windows a decoration (Xlib spec, chapter
11260         3.2.8).  */         3.2.8).  */
# Line 11293  x_create_tip_frame (dpyinfo, parms, text Line 11293  x_create_tip_frame (dpyinfo, parms, text
11293    f->height = 0;    f->height = 0;
11294    SET_FRAME_WIDTH (f, 0);    SET_FRAME_WIDTH (f, 0);
11295    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
11296      
11297    /* Add `tooltip' frame parameter's default value. */    /* Add `tooltip' frame parameter's default value. */
11298    if (NILP (Fframe_parameter (frame, intern ("tooltip"))))    if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
11299      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
11300                                              Qnil));                                              Qnil));
11301      
11302    /* Set up faces after all frame parameters are known.  This call    /* Set up faces after all frame parameters are known.  This call
11303       also merges in face attributes specified for new frames.       also merges in face attributes specified for new frames.
11304    
# Line 11313  x_create_tip_frame (dpyinfo, parms, text Line 11313  x_create_tip_frame (dpyinfo, parms, text
11313      /* Set tip_frame here, so that */      /* Set tip_frame here, so that */
11314      tip_frame = frame;      tip_frame = frame;
11315      call1 (Qface_set_after_frame_default, frame);      call1 (Qface_set_after_frame_default, frame);
11316        
11317      if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))      if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
11318        Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),        Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
11319                                                Qnil));                                                Qnil));
11320    }    }
11321      
11322    f->no_split = 1;    f->no_split = 1;
11323    
11324    UNGCPRO;    UNGCPRO;
# Line 11361  compute_tip_xy (f, parms, dx, dy, width, Line 11361  compute_tip_xy (f, parms, dx, dy, width,
11361    int win_x, win_y;    int win_x, win_y;
11362    Window root, child;    Window root, child;
11363    unsigned pmask;    unsigned pmask;
11364      
11365    /* User-specified position?  */    /* User-specified position?  */
11366    left = Fcdr (Fassq (Qleft, parms));    left = Fcdr (Fassq (Qleft, parms));
11367    top  = Fcdr (Fassq (Qtop, parms));    top  = Fcdr (Fassq (Qtop, parms));
11368      
11369    /* Move the tooltip window where the mouse pointer is.  Resize and    /* Move the tooltip window where the mouse pointer is.  Resize and
11370       show it.  */       show it.  */
11371    if (!INTEGERP (left) || !INTEGERP (top))    if (!INTEGERP (left) || !INTEGERP (top))
# Line 11434  Text larger than the specified size is c Line 11434  Text larger than the specified size is c
11434    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
11435    int old_windows_or_buffers_changed = windows_or_buffers_changed;    int old_windows_or_buffers_changed = windows_or_buffers_changed;
11436    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
11437      
11438    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
11439    
11440    GCPRO4 (string, parms, frame, timeout);    GCPRO4 (string, parms, frame, timeout);
# Line 11445  Text larger than the specified size is c Line 11445  Text larger than the specified size is c
11445      timeout = make_number (5);      timeout = make_number (5);
11446    else    else
11447      CHECK_NATNUM (timeout);      CHECK_NATNUM (timeout);
11448      
11449    if (NILP (dx))    if (NILP (dx))
11450      dx = make_number (5);      dx = make_number (5);
11451    else    else
11452      CHECK_NUMBER (dx);      CHECK_NUMBER (dx);
11453      
11454    if (NILP (dy))    if (NILP (dy))
11455      dy = make_number (-10);      dy = make_number (-10);
11456    else    else
# Line 11470  Text larger than the specified size is c Line 11470  Text larger than the specified size is c
11470            && !NILP (Fequal (last_parms, parms)))            && !NILP (Fequal (last_parms, parms)))
11471          {          {
11472            struct frame *f = XFRAME (tip_frame);            struct frame *f = XFRAME (tip_frame);
11473              
11474            /* Only DX and DY have changed.  */            /* Only DX and DY have changed.  */
11475            if (!NILP (tip_timer))            if (!NILP (tip_timer))
11476              {              {
# Line 11517  Text larger than the specified size is c Line 11517  Text larger than the specified size is c
11517    /* Set up the frame's root window.  */    /* Set up the frame's root window.  */
11518    w = XWINDOW (FRAME_ROOT_WINDOW (f));    w = XWINDOW (FRAME_ROOT_WINDOW (f));
11519    w->left = w->top = make_number (0);    w->left = w->top = make_number (0);
11520      
11521    if (CONSP (Vx_max_tooltip_size)    if (CONSP (Vx_max_tooltip_size)
11522        && INTEGERP (XCAR (Vx_max_tooltip_size))        && INTEGERP (XCAR (Vx_max_tooltip_size))
11523        && XINT (XCAR (Vx_max_tooltip_size)) > 0        && XINT (XCAR (Vx_max_tooltip_size)) > 0
# Line 11532  Text larger than the specified size is c Line 11532  Text larger than the specified size is c
11532        w->width = make_number (80);        w->width = make_number (80);
11533        w->height = make_number (40);        w->height = make_number (40);
11534      }      }
11535      
11536    f->window_width = XINT (w->width);    f->window_width = XINT (w->width);
11537    adjust_glyphs (f);    adjust_glyphs (f);
11538    w->pseudo_window_p = 1;    w->pseudo_window_p = 1;
# Line 11570  Text larger than the specified size is c Line 11570  Text larger than the specified size is c
11570          }          }
11571        else        else
11572          row_width = row->pixel_width;          row_width = row->pixel_width;
11573          
11574        height += row->height;        height += row->height;
11575        width = max (width, row_width);        width = max (width, row_width);
11576      }      }
# Line 11589  Text larger than the specified size is c Line 11589  Text larger than the specified size is c
11589                       root_x, root_y, width, height);                       root_x, root_y, width, height);
11590    XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));    XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
11591    UNBLOCK_INPUT;    UNBLOCK_INPUT;
11592      
11593    /* Draw into the window.  */    /* Draw into the window.  */
11594    w->must_be_updated_p = 1;    w->must_be_updated_p = 1;
11595    update_single_window (w, 1);    update_single_window (w, 1);
# Line 11620  Value is t if tooltip was open, nil othe Line 11620  Value is t if tooltip was open, nil othe
11620    /* Return quickly if nothing to do.  */    /* Return quickly if nothing to do.  */
11621    if (NILP (tip_timer) && NILP (tip_frame))    if (NILP (tip_timer) && NILP (tip_frame))
11622      return Qnil;      return Qnil;
11623      
11624    frame = tip_frame;    frame = tip_frame;
11625    timer = tip_timer;    timer = tip_timer;
11626    GCPRO2 (frame, timer);    GCPRO2 (frame, timer);
11627    tip_frame = tip_timer = deleted = Qnil;    tip_frame = tip_timer = deleted = Qnil;
11628      
11629    count = SPECPDL_INDEX ();    count = SPECPDL_INDEX ();
11630    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
11631    specbind (Qinhibit_quit, Qt);    specbind (Qinhibit_quit, Qt);
11632      
11633    if (!NILP (timer))    if (!NILP (timer))
11634      call1 (Qcancel_timer, timer);      call1 (Qcancel_timer, timer);
11635    
# Line 11732  selection dialog's entry field, if MUSTM Line 11732  selection dialog's entry field, if MUSTM
11732    dir = Fexpand_file_name (dir, Qnil);    dir = Fexpand_file_name (dir, Qnil);
11733    dir_xmstring = XmStringCreateLocalized (SDATA (dir));    dir_xmstring = XmStringCreateLocalized (SDATA (dir));
11734    pattern_xmstring = XmStringCreateLocalized ("*");    pattern_xmstring = XmStringCreateLocalized ("*");
11735        
11736    XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac;    XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac;
11737    XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;    XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;
11738    XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;    XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;
# Line 11755  selection dialog's entry field, if MUSTM Line 11755  selection dialog's entry field, if MUSTM
11755    help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);    help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
11756    XtSetSensitive (help, False);    XtSetSensitive (help, False);
11757    
11758    /* Mark OK button as default.  */    /* Mark OK button as default.  */
11759    XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),    XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
11760                   XmNshowAsDefault, True, NULL);                   XmNshowAsDefault, True, NULL);
11761    
# Line 11815  selection dialog's entry field, if MUSTM Line 11815  selection dialog's entry field, if MUSTM
11815      {      {
11816        XmString text;        XmString text;
11817        String data;        String data;
11818          
11819        XtVaGetValues (dialog, XmNtextString, &text, NULL);        XtVaGetValues (dialog, XmNtextString, &text, NULL);
11820        XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);        XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);
11821        XmStringFree (text);        XmStringFree (text);
# Line 11834  selection dialog's entry field, if MUSTM Line 11834  selection dialog's entry field, if MUSTM
11834    /* Make "Cancel" equivalent to C-g.  */    /* Make "Cancel" equivalent to C-g.  */
11835    if (NILP (file))    if (NILP (file))
11836      Fsignal (Qquit, Qnil);      Fsignal (Qquit, Qnil);
11837      
11838    return unbind_to (count, file);    return unbind_to (count, file);
11839  }  }
11840    
# Line 11858  selection dialog's entry field, if MUSTM Line 11858  selection dialog's entry field, if MUSTM
11858    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
11859    char *cdef_file;    char *cdef_file;
11860    char *cprompt;    char *cprompt;
11861      
11862    GCPRO5 (prompt, dir, default_filename, mustmatch, file);    GCPRO5 (prompt, dir, default_filename, mustmatch, file);
11863    CHECK_STRING (prompt);    CHECK_STRING (prompt);
11864    CHECK_STRING (dir);    CHECK_STRING (dir);
# Line 11874  selection dialog's entry field, if MUSTM Line 11874  selection dialog's entry field, if MUSTM
11874      cdef_file = SDATA (dir);      cdef_file = SDATA (dir);
11875    
11876    fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch));    fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch));
11877      
11878    if (fn)    if (fn)
11879      {      {
11880        file = build_string (fn);        file = build_string (fn);
# Line 11887  selection dialog's entry field, if MUSTM Line 11887  selection dialog's entry field, if MUSTM
11887    /* Make "Cancel" equivalent to C-g.  */    /* Make "Cancel" equivalent to C-g.  */
11888    if (NILP (file))    if (NILP (file))
11889      Fsignal (Qquit, Qnil);      Fsignal (Qquit, Qnil);
11890      
11891    return unbind_to (count, file);    return unbind_to (count, file);
11892  }  }
11893    
# Line 11938  usual X keysyms.  */) Line 11938  usual X keysyms.  */)
11938        UNBLOCK_INPUT;        UNBLOCK_INPUT;
11939        return Qnil;        return Qnil;
11940      }      }
11941      
11942    have_keys = Qnil;    have_keys = Qnil;
11943    kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);    kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);
11944    if (kb)    if (kb)
# Line 11965  usual X keysyms.  */) Line 11965  usual X keysyms.  */)
11965          }          }
11966    
11967        XkbFreeClientMap (kb, 0, True);        XkbFreeClientMap (kb, 0, True);
11968      
11969        if (delete_keycode        if (delete_keycode
11970            && backspace_keycode            && backspace_keycode
11971            && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode            && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode
# Line 12095  syms_of_xfns () Line 12095  syms_of_xfns ()
12095    staticpro (&QCcolor_adjustment);    staticpro (&QCcolor_adjustment);
12096    QCmask = intern (":mask");    QCmask = intern (":mask");
12097    staticpro (&QCmask);    staticpro (&QCmask);
12098    
12099    Qface_set_after_frame_default = intern ("face-set-after-frame-default");    Qface_set_after_frame_default = intern ("face-set-after-frame-default");
12100    staticpro (&Qface_set_after_frame_default);    staticpro (&Qface_set_after_frame_default);
12101    
# Line 12163  or when you set the mouse color.  */); Line 12163  or when you set the mouse color.  */);
12163    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
12164      doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);      doc: /* Non-zero means Emacs displays an hourglass pointer on window systems.  */);
12165    display_hourglass_p = 1;    display_hourglass_p = 1;
12166      
12167    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
12168      doc: /* *Seconds to wait before displaying an hourglass pointer.      doc: /* *Seconds to wait before displaying an hourglass pointer.
12169  Value must be an integer or float.  */);  Value must be an integer or float.  */);
# Line 12199  or when you set the mouse color.  */); Line 12199  or when you set the mouse color.  */);
12199      doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).      doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
12200  Text larger than this is clipped.  */);  Text larger than this is clipped.  */);
12201    Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));    Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
12202      
12203    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
12204      doc: /* Non-nil if no X window manager is in use.      doc: /* Non-nil if no X window manager is in use.
12205  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 12268  meaning don't clear the cache.  */); Line 12268  meaning don't clear the cache.  */);
12268    defsubr (&Sx_synchronize);    defsubr (&Sx_synchronize);
12269    defsubr (&Sx_focus_frame);    defsubr (&Sx_focus_frame);
12270    defsubr (&Sx_backspace_delete_keys_p);    defsubr (&Sx_backspace_delete_keys_p);
12271      
12272    /* Setting callback functions for fontset handler.  */    /* Setting callback functions for fontset handler.  */
12273    get_font_info_func = x_get_font_info;    get_font_info_func = x_get_font_info;
12274    
# Line 12276  meaning don't clear the cache.  */); Line 12276  meaning don't clear the cache.  */);
12276           And the pointer assigned has the wrong type, anyway.  */           And the pointer assigned has the wrong type, anyway.  */
12277    list_fonts_func = x_list_fonts;    list_fonts_func = x_list_fonts;
12278  #endif  #endif
12279      
12280    load_font_func = x_load_font;    load_font_func = x_load_font;
12281    find_ccl_program_func = x_find_ccl_program;    find_ccl_program_func = x_find_ccl_program;
12282    query_font_func = x_query_font;    query_font_func = x_query_font;
# Line 12317  meaning don't clear the cache.  */); Line 12317  meaning don't clear the cache.  */);
12317    Qxpm = intern ("xpm");    Qxpm = intern ("xpm");
12318    staticpro (&Qxpm);    staticpro (&Qxpm);
12319  #endif  #endif
12320      
12321  #if HAVE_JPEG  #if HAVE_JPEG
12322    Qjpeg = intern ("jpeg");    Qjpeg = intern ("jpeg");
12323    staticpro (&Qjpeg);    staticpro (&Qjpeg);
12324  #endif  #endif
12325    
12326  #if HAVE_TIFF  #if HAVE_TIFF
12327    Qtiff = intern ("tiff");    Qtiff = intern ("tiff");
12328    staticpro (&Qtiff);    staticpro (&Qtiff);
12329  #endif  #endif
12330    
12331  #if HAVE_GIF  #if HAVE_GIF
12332    Qgif = intern ("gif");    Qgif = intern ("gif");
# Line 12366  init_xfns () Line 12366  init_xfns ()
12366  {  {
12367    image_types = NULL;    image_types = NULL;
12368    Vimage_types = Qnil;    Vimage_types = Qnil;
12369      
12370    define_image_type (&xbm_type);    define_image_type (&xbm_type);
12371    define_image_type (&gs_type);    define_image_type (&gs_type);
12372    define_image_type (&pbm_type);    define_image_type (&pbm_type);
12373      
12374  #if HAVE_XPM  #if HAVE_XPM
12375    define_image_type (&xpm_type);    define_image_type (&xpm_type);
12376  #endif  #endif
12377      
12378  #if HAVE_JPEG  #if HAVE_JPEG
12379    define_image_type (&jpeg_type);    define_image_type (&jpeg_type);
12380  #endif  #endif
12381      
12382  #if HAVE_TIFF  #if HAVE_TIFF
12383    define_image_type (&tiff_type);    define_image_type (&tiff_type);
12384  #endif  #endif
12385      
12386  #if HAVE_GIF  #if HAVE_GIF
12387    define_image_type (&gif_type);    define_image_type (&gif_type);
12388  #endif  #endif
12389      
12390  #if HAVE_PNG  #if HAVE_PNG
12391    define_image_type (&png_type);    define_image_type (&png_type);
12392  #endif  #endif

Legend:
Removed from v.1.572  
changed lines
  Added in v.1.573

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