comparison src/xfns.c @ 49600:23a1cea22d13

Trailing whitespace deleted.
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Feb 2003 14:56:31 +0000
parents 5579114f7b97
children 834df49192b0
comparison
equal deleted inserted replaced
49599:5ade352e8d1c 49600:23a1cea22d13
286 static struct x_display_info * 286 static struct x_display_info *
287 check_x_display_info (frame) 287 check_x_display_info (frame)
288 Lisp_Object frame; 288 Lisp_Object frame;
289 { 289 {
290 struct x_display_info *dpyinfo = NULL; 290 struct x_display_info *dpyinfo = NULL;
291 291
292 if (NILP (frame)) 292 if (NILP (frame))
293 { 293 {
294 struct frame *sf = XFRAME (selected_frame); 294 struct frame *sf = XFRAME (selected_frame);
295 295
296 if (FRAME_X_P (sf) && FRAME_LIVE_P (sf)) 296 if (FRAME_X_P (sf) && FRAME_LIVE_P (sf))
297 dpyinfo = FRAME_X_DISPLAY_INFO (sf); 297 dpyinfo = FRAME_X_DISPLAY_INFO (sf);
298 else if (x_display_list != 0) 298 else if (x_display_list != 0)
299 dpyinfo = x_display_list; 299 dpyinfo = x_display_list;
300 else 300 else
334 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo) 334 if (!FRAME_X_P (f) || FRAME_X_DISPLAY_INFO (f) != dpyinfo)
335 continue; 335 continue;
336 if (f->output_data.x->hourglass_window == wdesc) 336 if (f->output_data.x->hourglass_window == wdesc)
337 return f; 337 return f;
338 #ifdef USE_X_TOOLKIT 338 #ifdef USE_X_TOOLKIT
339 if ((f->output_data.x->edit_widget 339 if ((f->output_data.x->edit_widget
340 && XtWindow (f->output_data.x->edit_widget) == wdesc) 340 && XtWindow (f->output_data.x->edit_widget) == wdesc)
341 /* A tooltip frame? */ 341 /* A tooltip frame? */
342 || (!f->output_data.x->edit_widget 342 || (!f->output_data.x->edit_widget
343 && FRAME_X_WINDOW (f) == wdesc) 343 && FRAME_X_WINDOW (f) == wdesc)
344 || f->output_data.x->icon_desc == wdesc) 344 || f->output_data.x->icon_desc == wdesc)
378 for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail)) 378 for (tail = Vframe_list; GC_CONSP (tail) && !found; tail = XCDR (tail))
379 { 379 {
380 frame = XCAR (tail); 380 frame = XCAR (tail);
381 if (!GC_FRAMEP (frame)) 381 if (!GC_FRAMEP (frame))
382 continue; 382 continue;
383 383
384 f = XFRAME (frame); 384 f = XFRAME (frame);
385 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo) 385 if (FRAME_X_P (f) && FRAME_X_DISPLAY_INFO (f) == dpyinfo)
386 { 386 {
387 /* This frame matches if the window is any of its widgets. */ 387 /* This frame matches if the window is any of its widgets. */
388 x = f->output_data.x; 388 x = f->output_data.x;
397 || gwdesc == x->edit_widget 397 || gwdesc == x->edit_widget
398 || gwdesc == x->vbox_widget 398 || gwdesc == x->vbox_widget
399 || gwdesc == x->menubar_widget)) 399 || gwdesc == x->menubar_widget))
400 found = f; 400 found = f;
401 #else 401 #else
402 if (wdesc == XtWindow (x->widget) 402 if (wdesc == XtWindow (x->widget)
403 || wdesc == XtWindow (x->column_widget) 403 || wdesc == XtWindow (x->column_widget)
404 || wdesc == XtWindow (x->edit_widget)) 404 || wdesc == XtWindow (x->edit_widget))
405 found = f; 405 found = f;
406 /* Match if the window is this frame's menubar. */ 406 /* Match if the window is this frame's menubar. */
407 else if (lw_window_is_in_menubar (wdesc, x->menubar_widget)) 407 else if (lw_window_is_in_menubar (wdesc, x->menubar_widget))
408 found = f; 408 found = f;
411 else if (FRAME_X_WINDOW (f) == wdesc) 411 else if (FRAME_X_WINDOW (f) == wdesc)
412 /* A tooltip frame. */ 412 /* A tooltip frame. */
413 found = f; 413 found = f;
414 } 414 }
415 } 415 }
416 416
417 return found; 417 return found;
418 } 418 }
419 419
420 /* Likewise, but exclude the menu bar widget. */ 420 /* Likewise, but exclude the menu bar widget. */
421 421
448 && (gwdesc == x->widget 448 && (gwdesc == x->widget
449 || gwdesc == x->edit_widget 449 || gwdesc == x->edit_widget
450 || gwdesc == x->vbox_widget)) 450 || gwdesc == x->vbox_widget))
451 return f; 451 return f;
452 #else 452 #else
453 if (wdesc == XtWindow (x->widget) 453 if (wdesc == XtWindow (x->widget)
454 || wdesc == XtWindow (x->column_widget) 454 || wdesc == XtWindow (x->column_widget)
455 || wdesc == XtWindow (x->edit_widget)) 455 || wdesc == XtWindow (x->edit_widget))
456 return f; 456 return f;
457 #endif 457 #endif
458 } 458 }
459 else if (FRAME_X_WINDOW (f) == wdesc) 459 else if (FRAME_X_WINDOW (f) == wdesc)
487 #ifdef USE_GTK 487 #ifdef USE_GTK
488 if (x->menubar_widget) 488 if (x->menubar_widget)
489 { 489 {
490 GtkWidget *gwdesc = xg_win_to_widget (wdesc); 490 GtkWidget *gwdesc = xg_win_to_widget (wdesc);
491 int found = 0; 491 int found = 0;
492 492
493 BLOCK_INPUT; 493 BLOCK_INPUT;
494 if (gwdesc != 0 494 if (gwdesc != 0
495 && (gwdesc == x->menubar_widget 495 && (gwdesc == x->menubar_widget
496 || gtk_widget_get_parent (gwdesc) == x->menubar_widget)) 496 || gtk_widget_get_parent (gwdesc) == x->menubar_widget))
497 found = 1; 497 found = 1;
541 return f; 541 return f;
542 #if 0 /* I don't know why it did this, 542 #if 0 /* I don't know why it did this,
543 but it seems logically wrong, 543 but it seems logically wrong,
544 and it causes trouble for MapNotify events. */ 544 and it causes trouble for MapNotify events. */
545 /* Match if the window is this frame's menubar. */ 545 /* Match if the window is this frame's menubar. */
546 if (x->menubar_widget 546 if (x->menubar_widget
547 && wdesc == XtWindow (x->menubar_widget)) 547 && wdesc == XtWindow (x->menubar_widget))
548 return f; 548 return f;
549 #endif 549 #endif
550 #endif 550 #endif
551 } 551 }
858 {"line-spacing", x_set_line_spacing}, 858 {"line-spacing", x_set_line_spacing},
859 {"left-fringe", x_set_fringe_width}, 859 {"left-fringe", x_set_fringe_width},
860 {"right-fringe", x_set_fringe_width}, 860 {"right-fringe", x_set_fringe_width},
861 {"wait-for-wm", x_set_wait_for_wm}, 861 {"wait-for-wm", x_set_wait_for_wm},
862 {"fullscreen", x_set_fullscreen}, 862 {"fullscreen", x_set_fullscreen},
863 863
864 }; 864 };
865 865
866 /* Attach the `x-frame-parameter' properties to 866 /* Attach the `x-frame-parameter' properties to
867 the Lisp symbol names of parameters relevant to X. */ 867 the Lisp symbol names of parameters relevant to X. */
868 868
977 /* Process foreground_color and background_color before anything else. 977 /* Process foreground_color and background_color before anything else.
978 They are independent of other properties, but other properties (e.g., 978 They are independent of other properties, but other properties (e.g.,
979 cursor_color) are dependent upon them. */ 979 cursor_color) are dependent upon them. */
980 /* Process default font as well, since fringe widths depends on it. */ 980 /* Process default font as well, since fringe widths depends on it. */
981 /* Also, process fullscreen, width and height depend upon that */ 981 /* Also, process fullscreen, width and height depend upon that */
982 for (p = 0; p < i; p++) 982 for (p = 0; p < i; p++)
983 { 983 {
984 Lisp_Object prop, val; 984 Lisp_Object prop, val;
985 985
986 prop = parms[p]; 986 prop = parms[p];
987 val = values[p]; 987 val = values[p];
992 { 992 {
993 register Lisp_Object param_index, old_value; 993 register Lisp_Object param_index, old_value;
994 994
995 old_value = get_frame_param (f, prop); 995 old_value = get_frame_param (f, prop);
996 fullscreen_is_being_set |= EQ (prop, Qfullscreen); 996 fullscreen_is_being_set |= EQ (prop, Qfullscreen);
997 997
998 if (NILP (Fequal (val, old_value))) 998 if (NILP (Fequal (val, old_value)))
999 { 999 {
1000 store_frame_param (f, prop, val); 1000 store_frame_param (f, prop, val);
1001 1001
1002 param_index = Fget (prop, Qx_frame_parameter); 1002 param_index = Fget (prop, Qx_frame_parameter);
1092 Here we first get the width, height and position that applies to 1092 Here we first get the width, height and position that applies to
1093 fullscreen. We then move the frame to the appropriate 1093 fullscreen. We then move the frame to the appropriate
1094 position. Resize of the frame is taken care of in the code after 1094 position. Resize of the frame is taken care of in the code after
1095 this if-statement. */ 1095 this if-statement. */
1096 int new_left, new_top; 1096 int new_left, new_top;
1097 1097
1098 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left); 1098 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
1099 x_fullscreen_move (f, new_top, new_left); 1099 x_fullscreen_move (f, new_top, new_left);
1100 } 1100 }
1101 1101
1102 /* Don't set these parameters unless they've been explicitly 1102 /* Don't set these parameters unless they've been explicitly
1103 specified. The window might be mapped or resized while we're in 1103 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 1104 this function, and we don't want to override that unless the lisp
1105 code has asked for it. 1105 code has asked for it.
1106 1106
1240 if (wm_window == rootw || had_errors) 1240 if (wm_window == rootw || had_errors)
1241 break; 1241 break;
1242 1242
1243 win = wm_window; 1243 win = wm_window;
1244 } 1244 }
1245 1245
1246 if (! had_errors) 1246 if (! had_errors)
1247 { 1247 {
1248 int ign; 1248 int ign;
1249 Window child, rootw; 1249 Window child, rootw;
1250 1250
1251 /* Get the real coordinates for the WM window upper left corner */ 1251 /* Get the real coordinates for the WM window upper left corner */
1252 XGetGeometry (FRAME_X_DISPLAY (f), win, 1252 XGetGeometry (FRAME_X_DISPLAY (f), win,
1253 &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign); 1253 &rootw, &real_x, &real_y, &ign, &ign, &ign, &ign);
1254 1254
1255 /* Translate real coordinates to coordinates relative to our 1255 /* Translate real coordinates to coordinates relative to our
1284 XTranslateCoordinates (FRAME_X_DISPLAY (f), 1284 XTranslateCoordinates (FRAME_X_DISPLAY (f),
1285 1285
1286 /* From-window, to-window. */ 1286 /* From-window, to-window. */
1287 FRAME_X_DISPLAY_INFO (f)->root_window, 1287 FRAME_X_DISPLAY_INFO (f)->root_window,
1288 FRAME_OUTER_WINDOW (f), 1288 FRAME_OUTER_WINDOW (f),
1289 1289
1290 /* From-position, to-position. */ 1290 /* From-position, to-position. */
1291 real_x, real_y, &outer_x, &outer_y, 1291 real_x, real_y, &outer_x, &outer_y,
1292 1292
1293 /* Child of win. */ 1293 /* Child of win. */
1294 &child); 1294 &child);
1295 } 1295 }
1296 1296
1297 had_errors = x_had_errors_p (FRAME_X_DISPLAY (f)); 1297 had_errors = x_had_errors_p (FRAME_X_DISPLAY (f));
1298 } 1298 }
1299 1299
1300 x_uncatch_errors (FRAME_X_DISPLAY (f), count); 1300 x_uncatch_errors (FRAME_X_DISPLAY (f), count);
1301 1301
1302 UNBLOCK_INPUT; 1302 UNBLOCK_INPUT;
1303 1303
1304 if (had_errors) return; 1304 if (had_errors) return;
1305 1305
1306 f->output_data.x->x_pixels_diff = -win_x; 1306 f->output_data.x->x_pixels_diff = -win_x;
1307 f->output_data.x->y_pixels_diff = -win_y; 1307 f->output_data.x->y_pixels_diff = -win_y;
1308 f->output_data.x->x_pixels_outer_diff = -outer_x; 1308 f->output_data.x->x_pixels_outer_diff = -outer_x;
1309 f->output_data.x->y_pixels_outer_diff = -outer_y; 1309 f->output_data.x->y_pixels_outer_diff = -outer_y;
1310 1310
1560 x->foreground_pixel = fg; 1560 x->foreground_pixel = fg;
1561 1561
1562 if (FRAME_X_WINDOW (f) != 0) 1562 if (FRAME_X_WINDOW (f) != 0)
1563 { 1563 {
1564 Display *dpy = FRAME_X_DISPLAY (f); 1564 Display *dpy = FRAME_X_DISPLAY (f);
1565 1565
1566 BLOCK_INPUT; 1566 BLOCK_INPUT;
1567 XSetForeground (dpy, x->normal_gc, fg); 1567 XSetForeground (dpy, x->normal_gc, fg);
1568 XSetBackground (dpy, x->reverse_gc, fg); 1568 XSetBackground (dpy, x->reverse_gc, fg);
1569 1569
1570 if (x->cursor_pixel == old_fg) 1570 if (x->cursor_pixel == old_fg)
1571 { 1571 {
1572 unload_color (f, x->cursor_pixel); 1572 unload_color (f, x->cursor_pixel);
1573 x->cursor_pixel = x_copy_color (f, fg); 1573 x->cursor_pixel = x_copy_color (f, fg);
1574 XSetBackground (dpy, x->cursor_gc, x->cursor_pixel); 1574 XSetBackground (dpy, x->cursor_gc, x->cursor_pixel);
1575 } 1575 }
1576 1576
1577 UNBLOCK_INPUT; 1577 UNBLOCK_INPUT;
1578 1578
1579 update_face_from_frame_parameter (f, Qforeground_color, arg); 1579 update_face_from_frame_parameter (f, Qforeground_color, arg);
1580 1580
1581 if (FRAME_VISIBLE_P (f)) 1581 if (FRAME_VISIBLE_P (f))
1582 redraw_frame (f); 1582 redraw_frame (f);
1583 } 1583 }
1584 1584
1585 unload_color (f, old_fg); 1585 unload_color (f, old_fg);
1586 } 1586 }
1587 1587
1588 void 1588 void
1589 x_set_background_color (f, arg, oldval) 1589 x_set_background_color (f, arg, oldval)
1598 x->background_pixel = bg; 1598 x->background_pixel = bg;
1599 1599
1600 if (FRAME_X_WINDOW (f) != 0) 1600 if (FRAME_X_WINDOW (f) != 0)
1601 { 1601 {
1602 Display *dpy = FRAME_X_DISPLAY (f); 1602 Display *dpy = FRAME_X_DISPLAY (f);
1603 1603
1604 BLOCK_INPUT; 1604 BLOCK_INPUT;
1605 XSetBackground (dpy, x->normal_gc, bg); 1605 XSetBackground (dpy, x->normal_gc, bg);
1606 XSetForeground (dpy, x->reverse_gc, bg); 1606 XSetForeground (dpy, x->reverse_gc, bg);
1607 XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg); 1607 XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);
1608 XSetForeground (dpy, x->cursor_gc, bg); 1608 XSetForeground (dpy, x->cursor_gc, bg);
1687 = XCreateFontCursor (dpy, XINT (Vx_hourglass_pointer_shape)); 1687 = XCreateFontCursor (dpy, XINT (Vx_hourglass_pointer_shape));
1688 } 1688 }
1689 else 1689 else
1690 hourglass_cursor = XCreateFontCursor (dpy, XC_watch); 1690 hourglass_cursor = XCreateFontCursor (dpy, XC_watch);
1691 x_check_errors (dpy, "bad hourglass pointer cursor: %s"); 1691 x_check_errors (dpy, "bad hourglass pointer cursor: %s");
1692 1692
1693 x_check_errors (dpy, "bad nontext pointer cursor: %s"); 1693 x_check_errors (dpy, "bad nontext pointer cursor: %s");
1694 if (!NILP (Vx_mode_pointer_shape)) 1694 if (!NILP (Vx_mode_pointer_shape))
1695 { 1695 {
1696 CHECK_NUMBER (Vx_mode_pointer_shape); 1696 CHECK_NUMBER (Vx_mode_pointer_shape);
1697 mode_cursor = XCreateFontCursor (dpy, XINT (Vx_mode_pointer_shape)); 1697 mode_cursor = XCreateFontCursor (dpy, XINT (Vx_mode_pointer_shape));
1728 1728
1729 fore_color.pixel = x->mouse_pixel; 1729 fore_color.pixel = x->mouse_pixel;
1730 x_query_color (f, &fore_color); 1730 x_query_color (f, &fore_color);
1731 back_color.pixel = mask_color; 1731 back_color.pixel = mask_color;
1732 x_query_color (f, &back_color); 1732 x_query_color (f, &back_color);
1733 1733
1734 XRecolorCursor (dpy, cursor, &fore_color, &back_color); 1734 XRecolorCursor (dpy, cursor, &fore_color, &back_color);
1735 XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color); 1735 XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
1736 XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color); 1736 XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
1737 XRecolorCursor (dpy, cross_cursor, &fore_color, &back_color); 1737 XRecolorCursor (dpy, cross_cursor, &fore_color, &back_color);
1738 XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color); 1738 XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);
1759 1759
1760 if (mode_cursor != x->modeline_cursor 1760 if (mode_cursor != x->modeline_cursor
1761 && x->modeline_cursor != 0) 1761 && x->modeline_cursor != 0)
1762 XFreeCursor (dpy, f->output_data.x->modeline_cursor); 1762 XFreeCursor (dpy, f->output_data.x->modeline_cursor);
1763 x->modeline_cursor = mode_cursor; 1763 x->modeline_cursor = mode_cursor;
1764 1764
1765 if (cross_cursor != x->cross_cursor 1765 if (cross_cursor != x->cross_cursor
1766 && x->cross_cursor != 0) 1766 && x->cross_cursor != 0)
1767 XFreeCursor (dpy, x->cross_cursor); 1767 XFreeCursor (dpy, x->cross_cursor);
1768 x->cross_cursor = cross_cursor; 1768 x->cross_cursor = cross_cursor;
1769 1769
1793 WHITE_PIX_DEFAULT (f)); 1793 WHITE_PIX_DEFAULT (f));
1794 fore_pixel_allocated_p = 1; 1794 fore_pixel_allocated_p = 1;
1795 } 1795 }
1796 else 1796 else
1797 fore_pixel = x->background_pixel; 1797 fore_pixel = x->background_pixel;
1798 1798
1799 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); 1799 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1800 pixel_allocated_p = 1; 1800 pixel_allocated_p = 1;
1801 1801
1802 /* Make sure that the cursor color differs from the background color. */ 1802 /* Make sure that the cursor color differs from the background color. */
1803 if (pixel == x->background_pixel) 1803 if (pixel == x->background_pixel)
1805 if (pixel_allocated_p) 1805 if (pixel_allocated_p)
1806 { 1806 {
1807 x_free_colors (f, &pixel, 1); 1807 x_free_colors (f, &pixel, 1);
1808 pixel_allocated_p = 0; 1808 pixel_allocated_p = 0;
1809 } 1809 }
1810 1810
1811 pixel = x->mouse_pixel; 1811 pixel = x->mouse_pixel;
1812 if (pixel == fore_pixel) 1812 if (pixel == fore_pixel)
1813 { 1813 {
1814 if (fore_pixel_allocated_p) 1814 if (fore_pixel_allocated_p)
1815 { 1815 {
2013 BLOCK_INPUT; 2013 BLOCK_INPUT;
2014 result = (STRINGP (fontset_name) 2014 result = (STRINGP (fontset_name)
2015 ? x_new_fontset (f, SDATA (fontset_name)) 2015 ? x_new_fontset (f, SDATA (fontset_name))
2016 : x_new_font (f, SDATA (arg))); 2016 : x_new_font (f, SDATA (arg)));
2017 UNBLOCK_INPUT; 2017 UNBLOCK_INPUT;
2018 2018
2019 if (EQ (result, Qnil)) 2019 if (EQ (result, Qnil))
2020 error ("Font `%s' is not defined", SDATA (arg)); 2020 error ("Font `%s' is not defined", SDATA (arg));
2021 else if (EQ (result, Qt)) 2021 else if (EQ (result, Qt))
2022 error ("The characters of the given font have varying widths"); 2022 error ("The characters of the given font have varying widths");
2023 else if (STRINGP (result)) 2023 else if (STRINGP (result))
2029 if (old_fontset == f->output_data.x->fontset) 2029 if (old_fontset == f->output_data.x->fontset)
2030 return; 2030 return;
2031 } 2031 }
2032 else if (!NILP (Fequal (result, oldval))) 2032 else if (!NILP (Fequal (result, oldval)))
2033 return; 2033 return;
2034 2034
2035 store_frame_param (f, Qfont, result); 2035 store_frame_param (f, Qfont, result);
2036 recompute_basic_faces (f); 2036 recompute_basic_faces (f);
2037 } 2037 }
2038 else 2038 else
2039 abort (); 2039 abort ();
2243 FRAME_EXTERNAL_TOOL_BAR (f) = 0; 2243 FRAME_EXTERNAL_TOOL_BAR (f) = 0;
2244 } 2244 }
2245 2245
2246 return; 2246 return;
2247 #endif 2247 #endif
2248 2248
2249 /* Make sure we redisplay all windows in this frame. */ 2249 /* Make sure we redisplay all windows in this frame. */
2250 ++windows_or_buffers_changed; 2250 ++windows_or_buffers_changed;
2251 2251
2252 delta = nlines - FRAME_TOOL_BAR_LINES (f); 2252 delta = nlines - FRAME_TOOL_BAR_LINES (f);
2253 2253
2261 } 2261 }
2262 2262
2263 FRAME_TOOL_BAR_LINES (f) = nlines; 2263 FRAME_TOOL_BAR_LINES (f) = nlines;
2264 x_change_window_heights (root_window, delta); 2264 x_change_window_heights (root_window, delta);
2265 adjust_glyphs (f); 2265 adjust_glyphs (f);
2266 2266
2267 /* We also have to make sure that the internal border at the top of 2267 /* 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 2268 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 2269 tool bar disappears. This is so because the internal border is
2270 below the tool bar if one is displayed, but is below the menu bar 2270 below the tool bar if one is displayed, but is below the menu bar
2271 if there isn't a tool bar. The tool bar draws into the area 2271 if there isn't a tool bar. The tool bar draws into the area
2307 x_set_scroll_bar_foreground (f, value, oldval) 2307 x_set_scroll_bar_foreground (f, value, oldval)
2308 struct frame *f; 2308 struct frame *f;
2309 Lisp_Object value, oldval; 2309 Lisp_Object value, oldval;
2310 { 2310 {
2311 unsigned long pixel; 2311 unsigned long pixel;
2312 2312
2313 if (STRINGP (value)) 2313 if (STRINGP (value))
2314 pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f)); 2314 pixel = x_decode_color (f, value, BLACK_PIX_DEFAULT (f));
2315 else 2315 else
2316 pixel = -1; 2316 pixel = -1;
2317 2317
2318 if (f->output_data.x->scroll_bar_foreground_pixel != -1) 2318 if (f->output_data.x->scroll_bar_foreground_pixel != -1)
2319 unload_color (f, f->output_data.x->scroll_bar_foreground_pixel); 2319 unload_color (f, f->output_data.x->scroll_bar_foreground_pixel);
2320 2320
2321 f->output_data.x->scroll_bar_foreground_pixel = pixel; 2321 f->output_data.x->scroll_bar_foreground_pixel = pixel;
2322 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f)) 2322 if (FRAME_X_WINDOW (f) && FRAME_VISIBLE_P (f))
2323 { 2323 {
2324 /* Remove all scroll bars because they have wrong colors. */ 2324 /* Remove all scroll bars because they have wrong colors. */
2325 if (condemn_scroll_bars_hook) 2325 if (condemn_scroll_bars_hook)
2347 2347
2348 if (STRINGP (value)) 2348 if (STRINGP (value))
2349 pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f)); 2349 pixel = x_decode_color (f, value, WHITE_PIX_DEFAULT (f));
2350 else 2350 else
2351 pixel = -1; 2351 pixel = -1;
2352 2352
2353 if (f->output_data.x->scroll_bar_background_pixel != -1) 2353 if (f->output_data.x->scroll_bar_background_pixel != -1)
2354 unload_color (f, f->output_data.x->scroll_bar_background_pixel); 2354 unload_color (f, f->output_data.x->scroll_bar_background_pixel);
2355 2355
2356 #ifdef USE_TOOLKIT_SCROLL_BARS 2356 #ifdef USE_TOOLKIT_SCROLL_BARS
2357 /* Scrollbar shadow colors. */ 2357 /* Scrollbar shadow colors. */
2358 if (f->output_data.x->scroll_bar_top_shadow_pixel != -1) 2358 if (f->output_data.x->scroll_bar_top_shadow_pixel != -1)
2359 { 2359 {
2360 unload_color (f, f->output_data.x->scroll_bar_top_shadow_pixel); 2360 unload_color (f, f->output_data.x->scroll_bar_top_shadow_pixel);
2373 /* Remove all scroll bars because they have wrong colors. */ 2373 /* Remove all scroll bars because they have wrong colors. */
2374 if (condemn_scroll_bars_hook) 2374 if (condemn_scroll_bars_hook)
2375 (*condemn_scroll_bars_hook) (f); 2375 (*condemn_scroll_bars_hook) (f);
2376 if (judge_scroll_bars_hook) 2376 if (judge_scroll_bars_hook)
2377 (*judge_scroll_bars_hook) (f); 2377 (*judge_scroll_bars_hook) (f);
2378 2378
2379 update_face_from_frame_parameter (f, Qscroll_bar_background, value); 2379 update_face_from_frame_parameter (f, Qscroll_bar_background, value);
2380 redraw_frame (f); 2380 redraw_frame (f);
2381 } 2381 }
2382 } 2382 }
2383 2383
2468 x_set_name (f, name, explicit) 2468 x_set_name (f, name, explicit)
2469 struct frame *f; 2469 struct frame *f;
2470 Lisp_Object name; 2470 Lisp_Object name;
2471 int explicit; 2471 int explicit;
2472 { 2472 {
2473 /* Make sure that requests from lisp code override requests from 2473 /* Make sure that requests from lisp code override requests from
2474 Emacs redisplay code. */ 2474 Emacs redisplay code. */
2475 if (explicit) 2475 if (explicit)
2476 { 2476 {
2477 /* If we're switching from explicit to implicit, we had better 2477 /* If we're switching from explicit to implicit, we had better
2478 update the mode lines and thereby update the title. */ 2478 update the mode lines and thereby update the title. */
2734 { 2734 {
2735 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) 2735 FRAME_VERTICAL_SCROLL_BAR_TYPE (f)
2736 = (NILP (arg) 2736 = (NILP (arg)
2737 ? vertical_scroll_bar_none 2737 ? vertical_scroll_bar_none
2738 : EQ (Qright, arg) 2738 : EQ (Qright, arg)
2739 ? vertical_scroll_bar_right 2739 ? vertical_scroll_bar_right
2740 : vertical_scroll_bar_left); 2740 : vertical_scroll_bar_left);
2741 2741
2742 /* We set this parameter before creating the X window for the 2742 /* We set this parameter before creating the X window for the
2743 frame, so we can get the geometry right from the start. 2743 frame, so we can get the geometry right from the start.
2744 However, if the window hasn't been created yet, we shouldn't 2744 However, if the window hasn't been created yet, we shouldn't
2765 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width; 2765 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = width;
2766 #else 2766 #else
2767 /* Make the actual width at least 14 pixels and a multiple of a 2767 /* Make the actual width at least 14 pixels and a multiple of a
2768 character width. */ 2768 character width. */
2769 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid; 2769 FRAME_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
2770 2770
2771 /* Use all of that space (aside from required margins) for the 2771 /* Use all of that space (aside from required margins) for the
2772 scroll bar. */ 2772 scroll bar. */
2773 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0; 2773 FRAME_SCROLL_BAR_PIXEL_WIDTH (f) = 0;
2774 #endif 2774 #endif
2775 2775
3094 case RES_TYPE_BOOLEAN: 3094 case RES_TYPE_BOOLEAN:
3095 tem = Fdowncase (tem); 3095 tem = Fdowncase (tem);
3096 if (!strcmp (SDATA (tem), "on") 3096 if (!strcmp (SDATA (tem), "on")
3097 || !strcmp (SDATA (tem), "true")) 3097 || !strcmp (SDATA (tem), "true"))
3098 return Qt; 3098 return Qt;
3099 else 3099 else
3100 return Qnil; 3100 return Qnil;
3101 3101
3102 case RES_TYPE_STRING: 3102 case RES_TYPE_STRING:
3103 return tem; 3103 return tem;
3104 3104
3213 difficult to get at without actually creating a scroll 3213 difficult to get at without actually creating a scroll
3214 bar, use nil to indicate that no color has been 3214 bar, use nil to indicate that no color has been
3215 specified. */ 3215 specified. */
3216 tem = Qnil; 3216 tem = Qnil;
3217 } 3217 }
3218 3218
3219 #else /* not USE_TOOLKIT_SCROLL_BARS */ 3219 #else /* not USE_TOOLKIT_SCROLL_BARS */
3220 3220
3221 tem = Qnil; 3221 tem = Qnil;
3222 3222
3223 #endif /* not USE_TOOLKIT_SCROLL_BARS */ 3223 #endif /* not USE_TOOLKIT_SCROLL_BARS */
3224 } 3224 }
3225 3225
3226 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil)); 3226 x_set_frame_parameters (f, Fcons (Fcons (prop, tem), Qnil));
3227 return tem; 3227 return tem;
3415 3415
3416 if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE) 3416 if (f->output_data.x->want_fullscreen != FULLSCREEN_NONE)
3417 { 3417 {
3418 int left, top; 3418 int left, top;
3419 int width, height; 3419 int width, height;
3420 3420
3421 /* It takes both for some WM:s to place it where we want */ 3421 /* It takes both for some WM:s to place it where we want */
3422 window_prompting = USPosition | PPosition; 3422 window_prompting = USPosition | PPosition;
3423 x_fullscreen_adjust (f, &width, &height, &top, &left); 3423 x_fullscreen_adjust (f, &width, &height, &top, &left);
3424 f->width = width; 3424 f->width = width;
3425 f->height = height; 3425 f->height = height;
3426 f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width); 3426 f->output_data.x->pixel_width = CHAR_TO_PIXEL_WIDTH (f, f->width);
3427 f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height); 3427 f->output_data.x->pixel_height = CHAR_TO_PIXEL_HEIGHT (f, f->height);
3428 f->output_data.x->left_pos = left; 3428 f->output_data.x->left_pos = left;
3429 f->output_data.x->top_pos = top; 3429 f->output_data.x->top_pos = top;
3430 } 3430 }
3431 3431
3432 return window_prompting; 3432 return window_prompting;
3433 } 3433 }
3434 3434
3435 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS) 3435 #if !defined (HAVE_X11R4) && !defined (HAVE_XSETWMPROTOCOLS)
3436 3436
3549 { 3549 {
3550 XFontSet xfs; 3550 XFontSet xfs;
3551 char **missing_list; 3551 char **missing_list;
3552 int missing_count; 3552 int missing_count;
3553 char *def_string; 3553 char *def_string;
3554 3554
3555 xfs = XCreateFontSet (FRAME_X_DISPLAY (f), 3555 xfs = XCreateFontSet (FRAME_X_DISPLAY (f),
3556 base_fontname, &missing_list, 3556 base_fontname, &missing_list,
3557 &missing_count, &def_string); 3557 &missing_count, &def_string);
3558 if (missing_list) 3558 if (missing_list)
3559 XFreeStringList (missing_list); 3559 XFreeStringList (missing_list);
3560 3560
3561 /* No need to free def_string. */ 3561 /* No need to free def_string. */
3562 return xfs; 3562 return xfs;
3563 } 3563 }
3564 3564
3565 3565
3595 XIC xic = NULL; 3595 XIC xic = NULL;
3596 XFontSet xfs = NULL; 3596 XFontSet xfs = NULL;
3597 3597
3598 if (FRAME_XIC (f)) 3598 if (FRAME_XIC (f))
3599 return; 3599 return;
3600 3600
3601 xim = FRAME_X_XIM (f); 3601 xim = FRAME_X_XIM (f);
3602 if (xim) 3602 if (xim)
3603 { 3603 {
3604 XRectangle s_area; 3604 XRectangle s_area;
3605 XPoint spot; 3605 XPoint spot;
3693 XNPreeditAttributes, preedit_attr, 3693 XNPreeditAttributes, preedit_attr,
3694 NULL); 3694 NULL);
3695 XFree (preedit_attr); 3695 XFree (preedit_attr);
3696 XFree (status_attr); 3696 XFree (status_attr);
3697 } 3697 }
3698 3698
3699 FRAME_XIC (f) = xic; 3699 FRAME_XIC (f) = xic;
3700 FRAME_XIC_STYLE (f) = xic_style; 3700 FRAME_XIC_STYLE (f) = xic_style;
3701 FRAME_XIC_FONTSET (f) = xfs; 3701 FRAME_XIC_FONTSET (f) = xfs;
3702 } 3702 }
3703 3703
3708 free_frame_xic (f) 3708 free_frame_xic (f)
3709 struct frame *f; 3709 struct frame *f;
3710 { 3710 {
3711 if (FRAME_XIC (f) == NULL) 3711 if (FRAME_XIC (f) == NULL)
3712 return; 3712 return;
3713 3713
3714 XDestroyIC (FRAME_XIC (f)); 3714 XDestroyIC (FRAME_XIC (f));
3715 if (FRAME_XIC_FONTSET (f)) 3715 if (FRAME_XIC_FONTSET (f))
3716 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); 3716 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
3717 3717
3718 FRAME_XIC (f) = NULL; 3718 FRAME_XIC (f) = NULL;
3729 int x, y; 3729 int x, y;
3730 { 3730 {
3731 struct frame *f = XFRAME (w->frame); 3731 struct frame *f = XFRAME (w->frame);
3732 XVaNestedList attr; 3732 XVaNestedList attr;
3733 XPoint spot; 3733 XPoint spot;
3734 3734
3735 spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x); 3735 spot.x = WINDOW_TO_FRAME_PIXEL_X (w, x);
3736 spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f)); 3736 spot.y = WINDOW_TO_FRAME_PIXEL_Y (w, y) + FONT_BASE (FRAME_FONT (f));
3737 attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL); 3737 attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL);
3738 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL); 3738 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL);
3739 XFree (attr); 3739 XFree (attr);
3755 status area, use its current size. */ 3755 status area, use its current size. */
3756 area.x = area.y = area.width = area.height = 0; 3756 area.x = area.y = area.width = area.height = 0;
3757 attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL); 3757 attr = XVaCreateNestedList (0, XNAreaNeeded, &area, NULL);
3758 XSetICValues (xic, XNStatusAttributes, attr, NULL); 3758 XSetICValues (xic, XNStatusAttributes, attr, NULL);
3759 XFree (attr); 3759 XFree (attr);
3760 3760
3761 attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL); 3761 attr = XVaCreateNestedList (0, XNAreaNeeded, &needed, NULL);
3762 XGetICValues (xic, XNStatusAttributes, attr, NULL); 3762 XGetICValues (xic, XNStatusAttributes, attr, NULL);
3763 XFree (attr); 3763 XFree (attr);
3764 3764
3765 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */ 3765 if (needed->width == 0) /* Use XNArea instead of XNAreaNeeded */
3801 if (FRAME_XIC_STYLE (f) & XIMPreeditPosition) 3801 if (FRAME_XIC_STYLE (f) & XIMPreeditPosition)
3802 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL); 3802 XSetICValues (FRAME_XIC (f), XNPreeditAttributes, attr, NULL);
3803 if (FRAME_XIC_STYLE (f) & XIMStatusArea) 3803 if (FRAME_XIC_STYLE (f) & XIMStatusArea)
3804 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL); 3804 XSetICValues (FRAME_XIC (f), XNStatusAttributes, attr, NULL);
3805 XFree (attr); 3805 XFree (attr);
3806 3806
3807 if (FRAME_XIC_FONTSET (f)) 3807 if (FRAME_XIC_FONTSET (f))
3808 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f)); 3808 XFreeFontSet (FRAME_X_DISPLAY (f), FRAME_XIC_FONTSET (f));
3809 FRAME_XIC_FONTSET (f) = xfs; 3809 FRAME_XIC_FONTSET (f) = xfs;
3810 } 3810 }
3811 3811
3837 /* Use the resource name as the top-level widget name 3837 /* Use the resource name as the top-level widget name
3838 for looking up resources. Make a non-Lisp copy 3838 for looking up resources. Make a non-Lisp copy
3839 for the window manager, so GC relocation won't bother it. 3839 for the window manager, so GC relocation won't bother it.
3840 3840
3841 Elsewhere we specify the window name for the window manager. */ 3841 Elsewhere we specify the window name for the window manager. */
3842 3842
3843 { 3843 {
3844 char *str = (char *) SDATA (Vx_resource_name); 3844 char *str = (char *) SDATA (Vx_resource_name);
3845 f->namebuf = (char *) xmalloc (strlen (str) + 1); 3845 f->namebuf = (char *) xmalloc (strlen (str) + 1);
3846 strcpy (f->namebuf, str); 3846 strcpy (f->namebuf, str);
3847 } 3847 }
3874 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++; 3874 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
3875 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++; 3875 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3876 XtSetValues (pane_widget, al, ac); 3876 XtSetValues (pane_widget, al, ac);
3877 f->output_data.x->column_widget = pane_widget; 3877 f->output_data.x->column_widget = pane_widget;
3878 3878
3879 /* mappedWhenManaged to false tells to the paned window to not map/unmap 3879 /* mappedWhenManaged to false tells to the paned window to not map/unmap
3880 the emacs screen when changing menubar. This reduces flickering. */ 3880 the emacs screen when changing menubar. This reduces flickering. */
3881 3881
3882 ac = 0; 3882 ac = 0;
3883 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++; 3883 XtSetArg (al[ac], XtNmappedWhenManaged, 0); ac++;
3884 XtSetArg (al[ac], XtNshowGrip, 0); ac++; 3884 XtSetArg (al[ac], XtNshowGrip, 0); ac++;
3888 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++; 3888 XtSetArg (al[ac], XtNvisual, FRAME_X_VISUAL (f)); ac++;
3889 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++; 3889 XtSetArg (al[ac], XtNdepth, FRAME_X_DISPLAY_INFO (f)->n_planes); ac++;
3890 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++; 3890 XtSetArg (al[ac], XtNcolormap, FRAME_X_COLORMAP (f)); ac++;
3891 frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget, 3891 frame_widget = XtCreateWidget (f->namebuf, emacsFrameClass, pane_widget,
3892 al, ac); 3892 al, ac);
3893 3893
3894 f->output_data.x->edit_widget = frame_widget; 3894 f->output_data.x->edit_widget = frame_widget;
3895 3895
3896 XtManageChild (frame_widget); 3896 XtManageChild (frame_widget);
3897 3897
3898 /* Do some needed geometry management. */ 3898 /* Do some needed geometry management. */
3899 { 3899 {
3900 int len; 3900 int len;
3901 char *tem, shell_position[32]; 3901 char *tem, shell_position[32];
3902 Arg al[2]; 3902 Arg al[2];
3903 int ac = 0; 3903 int ac = 0;
3904 int extra_borders = 0; 3904 int extra_borders = 0;
3905 int menubar_size 3905 int menubar_size
3906 = (f->output_data.x->menubar_widget 3906 = (f->output_data.x->menubar_widget
3907 ? (f->output_data.x->menubar_widget->core.height 3907 ? (f->output_data.x->menubar_widget->core.height
3908 + f->output_data.x->menubar_widget->core.border_width) 3908 + f->output_data.x->menubar_widget->core.border_width)
3909 : 0); 3909 : 0);
3910 3910
3944 if (yneg) 3944 if (yneg)
3945 top = -top; 3945 top = -top;
3946 3946
3947 if (window_prompting & USPosition) 3947 if (window_prompting & USPosition)
3948 sprintf (shell_position, "=%dx%d%c%d%c%d", 3948 sprintf (shell_position, "=%dx%d%c%d%c%d",
3949 PIXEL_WIDTH (f) + extra_borders, 3949 PIXEL_WIDTH (f) + extra_borders,
3950 PIXEL_HEIGHT (f) + menubar_size + extra_borders, 3950 PIXEL_HEIGHT (f) + menubar_size + extra_borders,
3951 (xneg ? '-' : '+'), left, 3951 (xneg ? '-' : '+'), left,
3952 (yneg ? '-' : '+'), top); 3952 (yneg ? '-' : '+'), top);
3953 else 3953 else
3954 sprintf (shell_position, "=%dx%d", 3954 sprintf (shell_position, "=%dx%d",
3955 PIXEL_WIDTH (f) + extra_borders, 3955 PIXEL_WIDTH (f) + extra_borders,
3956 PIXEL_HEIGHT (f) + menubar_size + extra_borders); 3956 PIXEL_HEIGHT (f) + menubar_size + extra_borders);
3957 } 3957 }
3958 3958
3959 len = strlen (shell_position) + 1; 3959 len = strlen (shell_position) + 1;
3960 /* We don't free this because we don't know whether 3960 /* We don't free this because we don't know whether
3968 } 3968 }
3969 3969
3970 XtManageChild (pane_widget); 3970 XtManageChild (pane_widget);
3971 XtRealizeWidget (shell_widget); 3971 XtRealizeWidget (shell_widget);
3972 3972
3973 FRAME_X_WINDOW (f) = XtWindow (frame_widget); 3973 FRAME_X_WINDOW (f) = XtWindow (frame_widget);
3974 3974
3975 validate_x_resource_name (); 3975 validate_x_resource_name ();
3976 3976
3977 class_hints.res_name = (char *) SDATA (Vx_resource_name); 3977 class_hints.res_name = (char *) SDATA (Vx_resource_name);
3978 class_hints.res_class = (char *) SDATA (Vx_resource_class); 3978 class_hints.res_class = (char *) SDATA (Vx_resource_class);
4015 unsigned long fevent = NoEventMask; 4015 unsigned long fevent = NoEventMask;
4016 XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL); 4016 XGetICValues(FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
4017 attributes.event_mask |= fevent; 4017 attributes.event_mask |= fevent;
4018 } 4018 }
4019 #endif /* HAVE_X_I18N */ 4019 #endif /* HAVE_X_I18N */
4020 4020
4021 attribute_mask = CWEventMask; 4021 attribute_mask = CWEventMask;
4022 XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget), 4022 XChangeWindowAttributes (XtDisplay (shell_widget), XtWindow (shell_widget),
4023 attribute_mask, &attributes); 4023 attribute_mask, &attributes);
4024 4024
4025 XtMapWidget (frame_widget); 4025 XtMapWidget (frame_widget);
4135 XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4135 XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4136 attribute_mask, &attributes); 4136 attribute_mask, &attributes);
4137 } 4137 }
4138 #endif 4138 #endif
4139 #endif /* HAVE_X_I18N */ 4139 #endif /* HAVE_X_I18N */
4140 4140
4141 validate_x_resource_name (); 4141 validate_x_resource_name ();
4142 4142
4143 class_hints.res_name = (char *) SDATA (Vx_resource_name); 4143 class_hints.res_name = (char *) SDATA (Vx_resource_name);
4144 class_hints.res_class = (char *) SDATA (Vx_resource_class); 4144 class_hints.res_class = (char *) SDATA (Vx_resource_class);
4145 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints); 4145 XSetClassHint (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), &class_hints);
4300 /* Create the gray border tile used when the pointer is not in 4300 /* Create the gray border tile used when the pointer is not in
4301 the frame. Since this depends on the frame's pixel values, 4301 the frame. Since this depends on the frame's pixel values,
4302 this must be done on a per-frame basis. */ 4302 this must be done on a per-frame basis. */
4303 f->output_data.x->border_tile 4303 f->output_data.x->border_tile
4304 = (XCreatePixmapFromBitmapData 4304 = (XCreatePixmapFromBitmapData
4305 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window, 4305 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
4306 gray_bits, gray_width, gray_height, 4306 gray_bits, gray_width, gray_height,
4307 f->output_data.x->foreground_pixel, 4307 f->output_data.x->foreground_pixel,
4308 f->output_data.x->background_pixel, 4308 f->output_data.x->background_pixel,
4309 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)))); 4309 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))));
4310 4310
4319 struct frame *f; 4319 struct frame *f;
4320 { 4320 {
4321 Display *dpy = FRAME_X_DISPLAY (f); 4321 Display *dpy = FRAME_X_DISPLAY (f);
4322 4322
4323 BLOCK_INPUT; 4323 BLOCK_INPUT;
4324 4324
4325 if (f->output_data.x->normal_gc) 4325 if (f->output_data.x->normal_gc)
4326 { 4326 {
4327 XFreeGC (dpy, f->output_data.x->normal_gc); 4327 XFreeGC (dpy, f->output_data.x->normal_gc);
4328 f->output_data.x->normal_gc = 0; 4328 f->output_data.x->normal_gc = 0;
4329 } 4329 }
4331 if (f->output_data.x->reverse_gc) 4331 if (f->output_data.x->reverse_gc)
4332 { 4332 {
4333 XFreeGC (dpy, f->output_data.x->reverse_gc); 4333 XFreeGC (dpy, f->output_data.x->reverse_gc);
4334 f->output_data.x->reverse_gc = 0; 4334 f->output_data.x->reverse_gc = 0;
4335 } 4335 }
4336 4336
4337 if (f->output_data.x->cursor_gc) 4337 if (f->output_data.x->cursor_gc)
4338 { 4338 {
4339 XFreeGC (dpy, f->output_data.x->cursor_gc); 4339 XFreeGC (dpy, f->output_data.x->cursor_gc);
4340 f->output_data.x->cursor_gc = 0; 4340 f->output_data.x->cursor_gc = 0;
4341 } 4341 }
4364 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) 4364 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
4365 { 4365 {
4366 #if GLYPH_DEBUG 4366 #if GLYPH_DEBUG
4367 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 4367 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
4368 #endif 4368 #endif
4369 4369
4370 x_free_frame_resources (f); 4370 x_free_frame_resources (f);
4371 4371
4372 /* Check that reference counts are indeed correct. */ 4372 /* Check that reference counts are indeed correct. */
4373 xassert (dpyinfo->reference_count == dpyinfo_refcount); 4373 xassert (dpyinfo->reference_count == dpyinfo_refcount);
4374 xassert (dpyinfo->image_cache->refcount == image_cache_refcount); 4374 xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
4375 return Qt; 4375 return Qt;
4376 } 4376 }
4377 4377
4378 return Qnil; 4378 return Qnil;
4379 } 4379 }
4380 4380
4381 4381
4382 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 4382 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
4503 f->output_data.x->background_pixel = -1; 4503 f->output_data.x->background_pixel = -1;
4504 f->output_data.x->cursor_pixel = -1; 4504 f->output_data.x->cursor_pixel = -1;
4505 f->output_data.x->cursor_foreground_pixel = -1; 4505 f->output_data.x->cursor_foreground_pixel = -1;
4506 f->output_data.x->border_pixel = -1; 4506 f->output_data.x->border_pixel = -1;
4507 f->output_data.x->mouse_pixel = -1; 4507 f->output_data.x->mouse_pixel = -1;
4508 4508
4509 black = build_string ("black"); 4509 black = build_string ("black");
4510 GCPRO1 (black); 4510 GCPRO1 (black);
4511 f->output_data.x->foreground_pixel 4511 f->output_data.x->foreground_pixel
4512 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 4512 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
4513 f->output_data.x->background_pixel 4513 f->output_data.x->background_pixel
4566 if (STRINGP (tem)) 4566 if (STRINGP (tem))
4567 font = x_new_fontset (f, SDATA (tem)); 4567 font = x_new_fontset (f, SDATA (tem));
4568 else 4568 else
4569 font = x_new_font (f, SDATA (font)); 4569 font = x_new_font (f, SDATA (font));
4570 } 4570 }
4571 4571
4572 /* Try out a font which we hope has bold and italic variations. */ 4572 /* Try out a font which we hope has bold and italic variations. */
4573 if (!STRINGP (font)) 4573 if (!STRINGP (font))
4574 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); 4574 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
4575 if (!STRINGP (font)) 4575 if (!STRINGP (font))
4576 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); 4576 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
4597 xlwmenu_default_font = f->output_data.x->font; 4597 xlwmenu_default_font = f->output_data.x->font;
4598 #endif 4598 #endif
4599 4599
4600 x_default_parameter (f, parms, Qborder_width, make_number (2), 4600 x_default_parameter (f, parms, Qborder_width, make_number (2),
4601 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 4601 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
4602 4602
4603 /* This defaults to 1 in order to match xterm. We recognize either 4603 /* This defaults to 1 in order to match xterm. We recognize either
4604 internalBorderWidth or internalBorder (which is what xterm calls 4604 internalBorderWidth or internalBorder (which is what xterm calls
4605 it). */ 4605 it). */
4606 if (NILP (Fassq (Qinternal_border_width, parms))) 4606 if (NILP (Fassq (Qinternal_border_width, parms)))
4607 { 4607 {
4652 which calls change_frame_size, which calls Fset_window_buffer, 4652 which calls change_frame_size, which calls Fset_window_buffer,
4653 which runs hooks, which call Fvertical_motion. At the end, we 4653 which runs hooks, which call Fvertical_motion. At the end, we
4654 end up in init_iterator with a null face cache, which should not 4654 end up in init_iterator with a null face cache, which should not
4655 happen. */ 4655 happen. */
4656 init_frame_faces (f); 4656 init_frame_faces (f);
4657 4657
4658 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 4658 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
4659 "menuBar", "MenuBar", RES_TYPE_NUMBER); 4659 "menuBar", "MenuBar", RES_TYPE_NUMBER);
4660 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), 4660 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
4661 "toolBar", "ToolBar", RES_TYPE_NUMBER); 4661 "toolBar", "ToolBar", RES_TYPE_NUMBER);
4662 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 4662 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
4678 tall Emacs frames without having to guess how tall the tool-bar 4678 tall Emacs frames without having to guess how tall the tool-bar
4679 will get. */ 4679 will get. */
4680 if (FRAME_TOOL_BAR_LINES (f)) 4680 if (FRAME_TOOL_BAR_LINES (f))
4681 { 4681 {
4682 int margin, relief, bar_height; 4682 int margin, relief, bar_height;
4683 4683
4684 relief = (tool_bar_button_relief >= 0 4684 relief = (tool_bar_button_relief >= 0
4685 ? tool_bar_button_relief 4685 ? tool_bar_button_relief
4686 : DEFAULT_TOOL_BAR_BUTTON_RELIEF); 4686 : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
4687 4687
4688 if (INTEGERP (Vtool_bar_button_margin) 4688 if (INTEGERP (Vtool_bar_button_margin)
4692 && INTEGERP (XCDR (Vtool_bar_button_margin)) 4692 && INTEGERP (XCDR (Vtool_bar_button_margin))
4693 && XINT (XCDR (Vtool_bar_button_margin)) > 0) 4693 && XINT (XCDR (Vtool_bar_button_margin)) > 0)
4694 margin = XFASTINT (XCDR (Vtool_bar_button_margin)); 4694 margin = XFASTINT (XCDR (Vtool_bar_button_margin));
4695 else 4695 else
4696 margin = 0; 4696 margin = 0;
4697 4697
4698 bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; 4698 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); 4699 f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
4700 } 4700 }
4701 4701
4702 /* Compute the size of the X window. */ 4702 /* Compute the size of the X window. */
4726 #ifdef USE_X_TOOLKIT 4726 #ifdef USE_X_TOOLKIT
4727 x_window (f, window_prompting, minibuffer_only); 4727 x_window (f, window_prompting, minibuffer_only);
4728 #else 4728 #else
4729 x_window (f); 4729 x_window (f);
4730 #endif 4730 #endif
4731 4731
4732 x_icon (f, parms); 4732 x_icon (f, parms);
4733 x_make_gc (f); 4733 x_make_gc (f);
4734 4734
4735 /* Now consider the frame official. */ 4735 /* Now consider the frame official. */
4736 FRAME_X_DISPLAY_INFO (f)->reference_count++; 4736 FRAME_X_DISPLAY_INFO (f)->reference_count++;
4754 /* Dimensions, especially f->height, must be done via change_frame_size. 4754 /* Dimensions, especially f->height, must be done via change_frame_size.
4755 Change will not be effected unless different from the current 4755 Change will not be effected unless different from the current
4756 f->height. */ 4756 f->height. */
4757 width = f->width; 4757 width = f->width;
4758 height = f->height; 4758 height = f->height;
4759 4759
4760 f->height = 0; 4760 f->height = 0;
4761 SET_FRAME_WIDTH (f, 0); 4761 SET_FRAME_WIDTH (f, 0);
4762 change_frame_size (f, height, width, 1, 0, 0); 4762 change_frame_size (f, height, width, 1, 0, 0);
4763 4763
4764 /* Set up faces after all frame parameters are known. This call 4764 /* Set up faces after all frame parameters are known. This call
4817 UNGCPRO; 4817 UNGCPRO;
4818 4818
4819 /* Make sure windows on this frame appear in calls to next-window 4819 /* Make sure windows on this frame appear in calls to next-window
4820 and similar functions. */ 4820 and similar functions. */
4821 Vwindow_list = Qnil; 4821 Vwindow_list = Qnil;
4822 4822
4823 return unbind_to (count, frame); 4823 return unbind_to (count, frame);
4824 } 4824 }
4825 4825
4826 4826
4827 /* FRAME is used only to get a handle on the X display. We don't pass the 4827 /* FRAME is used only to get a handle on the X display. We don't pass the
4865 count = x_catch_errors (dpy); 4865 count = x_catch_errors (dpy);
4866 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4866 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4867 RevertToParent, CurrentTime); 4867 RevertToParent, CurrentTime);
4868 x_uncatch_errors (dpy, count); 4868 x_uncatch_errors (dpy, count);
4869 UNBLOCK_INPUT; 4869 UNBLOCK_INPUT;
4870 4870
4871 return Qnil; 4871 return Qnil;
4872 } 4872 }
4873 4873
4874 4874
4875 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, 4875 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
5182 break; 5182 break;
5183 default: 5183 default:
5184 error ("Display has an unknown visual class"); 5184 error ("Display has an unknown visual class");
5185 result = Qnil; 5185 result = Qnil;
5186 } 5186 }
5187 5187
5188 return result; 5188 return result;
5189 } 5189 }
5190 5190
5191 DEFUN ("x-display-save-under", Fx_display_save_under, 5191 DEFUN ("x-display-save-under", Fx_display_save_under,
5192 Sx_display_save_under, 0, 1, 0, 5192 Sx_display_save_under, 0, 1, 0,
5337 /* Look up a matching visual for the specified class. */ 5337 /* Look up a matching visual for the specified class. */
5338 if (class == -1 5338 if (class == -1
5339 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen), 5339 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen),
5340 dpyinfo->n_planes, class, &vinfo)) 5340 dpyinfo->n_planes, class, &vinfo))
5341 fatal ("Invalid visual specification `%s'", SDATA (value)); 5341 fatal ("Invalid visual specification `%s'", SDATA (value));
5342 5342
5343 dpyinfo->visual = vinfo.visual; 5343 dpyinfo->visual = vinfo.visual;
5344 } 5344 }
5345 else 5345 else
5346 { 5346 {
5347 int n_visuals; 5347 int n_visuals;
5348 XVisualInfo *vinfo, vinfo_template; 5348 XVisualInfo *vinfo, vinfo_template;
5349 5349
5350 dpyinfo->visual = DefaultVisualOfScreen (screen); 5350 dpyinfo->visual = DefaultVisualOfScreen (screen);
5351 5351
5352 #ifdef HAVE_X11R4 5352 #ifdef HAVE_X11R4
5353 vinfo_template.visualid = XVisualIDFromVisual (dpyinfo->visual); 5353 vinfo_template.visualid = XVisualIDFromVisual (dpyinfo->visual);
5354 #else 5354 #else
5638 int 5638 int
5639 valid_image_p (object) 5639 valid_image_p (object)
5640 Lisp_Object object; 5640 Lisp_Object object;
5641 { 5641 {
5642 int valid_p = 0; 5642 int valid_p = 0;
5643 5643
5644 if (CONSP (object) && EQ (XCAR (object), Qimage)) 5644 if (CONSP (object) && EQ (XCAR (object), Qimage))
5645 { 5645 {
5646 Lisp_Object tem; 5646 Lisp_Object tem;
5647 5647
5648 for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem)) 5648 for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem))
5654 struct image_type *type; 5654 struct image_type *type;
5655 type = lookup_image_type (XCAR (tem)); 5655 type = lookup_image_type (XCAR (tem));
5656 if (type) 5656 if (type)
5657 valid_p = type->valid_p (object); 5657 valid_p = type->valid_p (object);
5658 } 5658 }
5659 5659
5660 break; 5660 break;
5661 } 5661 }
5662 } 5662 }
5663 5663
5664 return valid_p; 5664 return valid_p;
5773 5773
5774 /* Record that we recognized the keyword. If a keywords 5774 /* Record that we recognized the keyword. If a keywords
5775 was found more than once, it's an error. */ 5775 was found more than once, it's an error. */
5776 keywords[i].value = value; 5776 keywords[i].value = value;
5777 ++keywords[i].count; 5777 ++keywords[i].count;
5778 5778
5779 if (keywords[i].count > 1) 5779 if (keywords[i].count > 1)
5780 return 0; 5780 return 0;
5781 5781
5782 /* Check type of value against allowed type. */ 5782 /* Check type of value against allowed type. */
5783 switch (keywords[i].type) 5783 switch (keywords[i].type)
5817 else if (INTEGERP (value) 5817 else if (INTEGERP (value)
5818 && XINT (value) >= 0 5818 && XINT (value) >= 0
5819 && XINT (value) <= 100) 5819 && XINT (value) <= 100)
5820 break; 5820 break;
5821 return 0; 5821 return 0;
5822 5822
5823 case IMAGE_NON_NEGATIVE_INTEGER_VALUE: 5823 case IMAGE_NON_NEGATIVE_INTEGER_VALUE:
5824 if (!INTEGERP (value) || XINT (value) < 0) 5824 if (!INTEGERP (value) || XINT (value) < 0)
5825 return 0; 5825 return 0;
5826 break; 5826 break;
5827 5827
5828 case IMAGE_DONT_CHECK_VALUE_TYPE: 5828 case IMAGE_DONT_CHECK_VALUE_TYPE:
5829 break; 5829 break;
5830 5830
5831 case IMAGE_FUNCTION_VALUE: 5831 case IMAGE_FUNCTION_VALUE:
5832 value = indirect_function (value); 5832 value = indirect_function (value);
5833 if (SUBRP (value) 5833 if (SUBRP (value)
5834 || COMPILEDP (value) 5834 || COMPILEDP (value)
5835 || (CONSP (value) && EQ (XCAR (value), Qlambda))) 5835 || (CONSP (value) && EQ (XCAR (value), Qlambda)))
5836 break; 5836 break;
5837 return 0; 5837 return 0;
5838 5838
5877 image_spec_value (spec, key, found) 5877 image_spec_value (spec, key, found)
5878 Lisp_Object spec, key; 5878 Lisp_Object spec, key;
5879 int *found; 5879 int *found;
5880 { 5880 {
5881 Lisp_Object tail; 5881 Lisp_Object tail;
5882 5882
5883 xassert (valid_image_p (spec)); 5883 xassert (valid_image_p (spec));
5884 5884
5885 for (tail = XCDR (spec); 5885 for (tail = XCDR (spec);
5886 CONSP (tail) && CONSP (XCDR (tail)); 5886 CONSP (tail) && CONSP (XCDR (tail));
5887 tail = XCDR (XCDR (tail))) 5887 tail = XCDR (XCDR (tail)))
5891 if (found) 5891 if (found)
5892 *found = 1; 5892 *found = 1;
5893 return XCAR (XCDR (tail)); 5893 return XCAR (XCDR (tail));
5894 } 5894 }
5895 } 5895 }
5896 5896
5897 if (found) 5897 if (found)
5898 *found = 0; 5898 *found = 0;
5899 return Qnil; 5899 return Qnil;
5900 } 5900 }
5901 5901
5902 5902
5903 DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, 5903 DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
5904 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). 5904 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).
5905 PIXELS non-nil means return the size in pixels, otherwise return the 5905 PIXELS non-nil means return the size in pixels, otherwise return the
5906 size in canonical character units. 5906 size in canonical character units.
5917 struct frame *f = check_x_frame (frame); 5917 struct frame *f = check_x_frame (frame);
5918 int id = lookup_image (f, spec); 5918 int id = lookup_image (f, spec);
5919 struct image *img = IMAGE_FROM_ID (f, id); 5919 struct image *img = IMAGE_FROM_ID (f, id);
5920 int width = img->width + 2 * img->hmargin; 5920 int width = img->width + 2 * img->hmargin;
5921 int height = img->height + 2 * img->vmargin; 5921 int height = img->height + 2 * img->vmargin;
5922 5922
5923 if (NILP (pixels)) 5923 if (NILP (pixels))
5924 size = Fcons (make_float ((double) width / CANON_X_UNIT (f)), 5924 size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
5925 make_float ((double) height / CANON_Y_UNIT (f))); 5925 make_float ((double) height / CANON_Y_UNIT (f)));
5926 else 5926 else
5927 size = Fcons (make_number (width), make_number (height)); 5927 size = Fcons (make_number (width), make_number (height));
5974 make_image (spec, hash) 5974 make_image (spec, hash)
5975 Lisp_Object spec; 5975 Lisp_Object spec;
5976 unsigned hash; 5976 unsigned hash;
5977 { 5977 {
5978 struct image *img = (struct image *) xmalloc (sizeof *img); 5978 struct image *img = (struct image *) xmalloc (sizeof *img);
5979 5979
5980 xassert (valid_image_p (spec)); 5980 xassert (valid_image_p (spec));
5981 bzero (img, sizeof *img); 5981 bzero (img, sizeof *img);
5982 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); 5982 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
5983 xassert (img->type != NULL); 5983 xassert (img->type != NULL);
5984 img->spec = spec; 5984 img->spec = spec;
6035 /* If IMG doesn't have a pixmap yet, load it now, using the image 6035 /* If IMG doesn't have a pixmap yet, load it now, using the image
6036 type dependent loader function. */ 6036 type dependent loader function. */
6037 if (img->pixmap == None && !img->load_failed_p) 6037 if (img->pixmap == None && !img->load_failed_p)
6038 img->load_failed_p = img->type->load (f, img) == 0; 6038 img->load_failed_p = img->type->load (f, img) == 0;
6039 } 6039 }
6040 6040
6041 6041
6042 /* Value is the number of pixels for the ascent of image IMG when 6042 /* Value is the number of pixels for the ascent of image IMG when
6043 drawn in face FACE. */ 6043 drawn in face FACE. */
6044 6044
6045 int 6045 int
6087 6087
6088 /* Choose the most frequently found color as background. */ 6088 /* Choose the most frequently found color as background. */
6089 for (i = best_count = 0; i < 4; ++i) 6089 for (i = best_count = 0; i < 4; ++i)
6090 { 6090 {
6091 int j, n; 6091 int j, n;
6092 6092
6093 for (j = n = 0; j < 4; ++j) 6093 for (j = n = 0; j < 4; ++j)
6094 if (corners[i] == corners[j]) 6094 if (corners[i] == corners[j])
6095 ++n; 6095 ++n;
6096 6096
6097 if (n > best_count) 6097 if (n > best_count)
6203 { 6203 {
6204 XFreePixmap (FRAME_X_DISPLAY (f), img->mask); 6204 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
6205 img->mask = None; 6205 img->mask = None;
6206 img->background_transparent_valid = 0; 6206 img->background_transparent_valid = 0;
6207 } 6207 }
6208 6208
6209 if (colors_p && img->ncolors) 6209 if (colors_p && img->ncolors)
6210 { 6210 {
6211 x_free_colors (f, img->colors, img->ncolors); 6211 x_free_colors (f, img->colors, img->ncolors);
6212 xfree (img->colors); 6212 xfree (img->colors);
6213 img->colors = NULL; 6213 img->colors = NULL;
6278 struct image_cache * 6278 struct image_cache *
6279 make_image_cache () 6279 make_image_cache ()
6280 { 6280 {
6281 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); 6281 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
6282 int size; 6282 int size;
6283 6283
6284 bzero (c, sizeof *c); 6284 bzero (c, sizeof *c);
6285 c->size = 50; 6285 c->size = 50;
6286 c->images = (struct image **) xmalloc (c->size * sizeof *c->images); 6286 c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
6287 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; 6287 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
6288 c->buckets = (struct image **) xmalloc (size); 6288 c->buckets = (struct image **) xmalloc (size);
6303 { 6303 {
6304 int i; 6304 int i;
6305 6305
6306 /* Cache should not be referenced by any frame when freed. */ 6306 /* Cache should not be referenced by any frame when freed. */
6307 xassert (c->refcount == 0); 6307 xassert (c->refcount == 0);
6308 6308
6309 for (i = 0; i < c->used; ++i) 6309 for (i = 0; i < c->used; ++i)
6310 free_image (f, c->images[i]); 6310 free_image (f, c->images[i]);
6311 xfree (c->images); 6311 xfree (c->images);
6312 xfree (c->buckets); 6312 xfree (c->buckets);
6313 xfree (c); 6313 xfree (c);
6340 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); 6340 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
6341 6341
6342 /* Block input so that we won't be interrupted by a SIGIO 6342 /* Block input so that we won't be interrupted by a SIGIO
6343 while being in an inconsistent state. */ 6343 while being in an inconsistent state. */
6344 BLOCK_INPUT; 6344 BLOCK_INPUT;
6345 6345
6346 for (i = nfreed = 0; i < c->used; ++i) 6346 for (i = nfreed = 0; i < c->used; ++i)
6347 { 6347 {
6348 struct image *img = c->images[i]; 6348 struct image *img = c->images[i];
6349 if (img != NULL 6349 if (img != NULL
6350 && (force_p || img->timestamp < old)) 6350 && (force_p || img->timestamp < old))
6359 case, current matrices may still contain references to 6359 case, current matrices may still contain references to
6360 images freed above. So, clear these matrices. */ 6360 images freed above. So, clear these matrices. */
6361 if (nfreed) 6361 if (nfreed)
6362 { 6362 {
6363 Lisp_Object tail, frame; 6363 Lisp_Object tail, frame;
6364 6364
6365 FOR_EACH_FRAME (tail, frame) 6365 FOR_EACH_FRAME (tail, frame)
6366 { 6366 {
6367 struct frame *f = XFRAME (frame); 6367 struct frame *f = XFRAME (frame);
6368 if (FRAME_X_P (f) 6368 if (FRAME_X_P (f)
6369 && FRAME_X_IMAGE_CACHE (f) == c) 6369 && FRAME_X_IMAGE_CACHE (f) == c)
6387 Lisp_Object frame; 6387 Lisp_Object frame;
6388 { 6388 {
6389 if (EQ (frame, Qt)) 6389 if (EQ (frame, Qt))
6390 { 6390 {
6391 Lisp_Object tail; 6391 Lisp_Object tail;
6392 6392
6393 FOR_EACH_FRAME (tail, frame) 6393 FOR_EACH_FRAME (tail, frame)
6394 if (FRAME_X_P (XFRAME (frame))) 6394 if (FRAME_X_P (XFRAME (frame)))
6395 clear_image_cache (XFRAME (frame), 1); 6395 clear_image_cache (XFRAME (frame), 1);
6396 } 6396 }
6397 else 6397 else
6414 { 6414 {
6415 Lisp_Object conversion, spec; 6415 Lisp_Object conversion, spec;
6416 Lisp_Object mask; 6416 Lisp_Object mask;
6417 6417
6418 spec = img->spec; 6418 spec = img->spec;
6419 6419
6420 /* `:heuristic-mask t' 6420 /* `:heuristic-mask t'
6421 `:mask heuristic' 6421 `:mask heuristic'
6422 means build a mask heuristically. 6422 means build a mask heuristically.
6423 `:heuristic-mask (R G B)' 6423 `:heuristic-mask (R G B)'
6424 `:mask (heuristic (R G B))' 6424 `:mask (heuristic (R G B))'
6425 means build a mask from color (R G B) in the 6425 means build a mask from color (R G B) in the
6426 image. 6426 image.
6427 `:mask nil' 6427 `:mask nil'
6428 means remove a mask, if any. */ 6428 means remove a mask, if any. */
6429 6429
6430 mask = image_spec_value (spec, QCheuristic_mask, NULL); 6430 mask = image_spec_value (spec, QCheuristic_mask, NULL);
6431 if (!NILP (mask)) 6431 if (!NILP (mask))
6432 x_build_heuristic_mask (f, img, mask); 6432 x_build_heuristic_mask (f, img, mask);
6433 else 6433 else
6434 { 6434 {
6435 int found_p; 6435 int found_p;
6436 6436
6437 mask = image_spec_value (spec, QCmask, &found_p); 6437 mask = image_spec_value (spec, QCmask, &found_p);
6438 6438
6439 if (EQ (mask, Qheuristic)) 6439 if (EQ (mask, Qheuristic))
6440 x_build_heuristic_mask (f, img, Qt); 6440 x_build_heuristic_mask (f, img, Qt);
6441 else if (CONSP (mask) 6441 else if (CONSP (mask)
6442 && EQ (XCAR (mask), Qheuristic)) 6442 && EQ (XCAR (mask), Qheuristic))
6443 { 6443 {
6450 { 6450 {
6451 XFreePixmap (FRAME_X_DISPLAY (f), img->mask); 6451 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
6452 img->mask = None; 6452 img->mask = None;
6453 } 6453 }
6454 } 6454 }
6455 6455
6456 6456
6457 /* Should we apply an image transformation algorithm? */ 6457 /* Should we apply an image transformation algorithm? */
6458 conversion = image_spec_value (spec, QCconversion, NULL); 6458 conversion = image_spec_value (spec, QCconversion, NULL);
6459 if (EQ (conversion, Qdisabled)) 6459 if (EQ (conversion, Qdisabled))
6460 x_disable_image (f, img); 6460 x_disable_image (f, img);
6461 else if (EQ (conversion, Qlaplace)) 6461 else if (EQ (conversion, Qlaplace))
6493 6493
6494 /* F must be a window-system frame, and SPEC must be a valid image 6494 /* F must be a window-system frame, and SPEC must be a valid image
6495 specification. */ 6495 specification. */
6496 xassert (FRAME_WINDOW_P (f)); 6496 xassert (FRAME_WINDOW_P (f));
6497 xassert (valid_image_p (spec)); 6497 xassert (valid_image_p (spec));
6498 6498
6499 GCPRO1 (spec); 6499 GCPRO1 (spec);
6500 6500
6501 /* Look up SPEC in the hash table of the image cache. */ 6501 /* Look up SPEC in the hash table of the image cache. */
6502 hash = sxhash (spec, 0); 6502 hash = sxhash (spec, 0);
6503 i = hash % IMAGE_CACHE_BUCKETS_SIZE; 6503 i = hash % IMAGE_CACHE_BUCKETS_SIZE;
6508 6508
6509 /* If not found, create a new image and cache it. */ 6509 /* If not found, create a new image and cache it. */
6510 if (img == NULL) 6510 if (img == NULL)
6511 { 6511 {
6512 extern Lisp_Object Qpostscript; 6512 extern Lisp_Object Qpostscript;
6513 6513
6514 BLOCK_INPUT; 6514 BLOCK_INPUT;
6515 img = make_image (spec, hash); 6515 img = make_image (spec, hash);
6516 cache_image (f, img); 6516 cache_image (f, img);
6517 img->load_failed_p = img->type->load (f, img) == 0; 6517 img->load_failed_p = img->type->load (f, img) == 0;
6518 6518
6540 ascent = image_spec_value (spec, QCascent, NULL); 6540 ascent = image_spec_value (spec, QCascent, NULL);
6541 if (INTEGERP (ascent)) 6541 if (INTEGERP (ascent))
6542 img->ascent = XFASTINT (ascent); 6542 img->ascent = XFASTINT (ascent);
6543 else if (EQ (ascent, Qcenter)) 6543 else if (EQ (ascent, Qcenter))
6544 img->ascent = CENTERED_IMAGE_ASCENT; 6544 img->ascent = CENTERED_IMAGE_ASCENT;
6545 6545
6546 margin = image_spec_value (spec, QCmargin, NULL); 6546 margin = image_spec_value (spec, QCmargin, NULL);
6547 if (INTEGERP (margin) && XINT (margin) >= 0) 6547 if (INTEGERP (margin) && XINT (margin) >= 0)
6548 img->vmargin = img->hmargin = XFASTINT (margin); 6548 img->vmargin = img->hmargin = XFASTINT (margin);
6549 else if (CONSP (margin) && INTEGERP (XCAR (margin)) 6549 else if (CONSP (margin) && INTEGERP (XCAR (margin))
6550 && INTEGERP (XCDR (margin))) 6550 && INTEGERP (XCDR (margin)))
6552 if (XINT (XCAR (margin)) > 0) 6552 if (XINT (XCAR (margin)) > 0)
6553 img->hmargin = XFASTINT (XCAR (margin)); 6553 img->hmargin = XFASTINT (XCAR (margin));
6554 if (XINT (XCDR (margin)) > 0) 6554 if (XINT (XCDR (margin)) > 0)
6555 img->vmargin = XFASTINT (XCDR (margin)); 6555 img->vmargin = XFASTINT (XCDR (margin));
6556 } 6556 }
6557 6557
6558 relief = image_spec_value (spec, QCrelief, NULL); 6558 relief = image_spec_value (spec, QCrelief, NULL);
6559 if (INTEGERP (relief)) 6559 if (INTEGERP (relief))
6560 { 6560 {
6561 img->relief = XINT (relief); 6561 img->relief = XINT (relief);
6562 img->hmargin += abs (img->relief); 6562 img->hmargin += abs (img->relief);
6586 } 6586 }
6587 6587
6588 /* We're using IMG, so set its timestamp to `now'. */ 6588 /* We're using IMG, so set its timestamp to `now'. */
6589 EMACS_GET_TIME (now); 6589 EMACS_GET_TIME (now);
6590 img->timestamp = EMACS_SECS (now); 6590 img->timestamp = EMACS_SECS (now);
6591 6591
6592 UNGCPRO; 6592 UNGCPRO;
6593 6593
6594 /* Value is the image id. */ 6594 /* Value is the image id. */
6595 return img->id; 6595 return img->id;
6596 } 6596 }
6597 6597
6598 6598
6740 XImage *ximg; 6740 XImage *ximg;
6741 Pixmap pixmap; 6741 Pixmap pixmap;
6742 int width, height; 6742 int width, height;
6743 { 6743 {
6744 GC gc; 6744 GC gc;
6745 6745
6746 xassert (interrupt_input_blocked); 6746 xassert (interrupt_input_blocked);
6747 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL); 6747 gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
6748 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height); 6748 XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);
6749 XFreeGC (FRAME_X_DISPLAY (f), gc); 6749 XFreeGC (FRAME_X_DISPLAY (f), gc);
6750 } 6750 }
6775 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path); 6775 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path);
6776 GCPRO2 (file_found, search_path); 6776 GCPRO2 (file_found, search_path);
6777 6777
6778 /* Try to find FILE in data-directory, then x-bitmap-file-path. */ 6778 /* Try to find FILE in data-directory, then x-bitmap-file-path. */
6779 fd = openp (search_path, file, Qnil, &file_found, Qnil); 6779 fd = openp (search_path, file, Qnil, &file_found, Qnil);
6780 6780
6781 if (fd == -1) 6781 if (fd == -1)
6782 file_found = Qnil; 6782 file_found = Qnil;
6783 else 6783 else
6784 close (fd); 6784 close (fd);
6785 6785
6817 { 6817 {
6818 xfree (buf); 6818 xfree (buf);
6819 buf = NULL; 6819 buf = NULL;
6820 } 6820 }
6821 } 6821 }
6822 6822
6823 return buf; 6823 return buf;
6824 } 6824 }
6825 6825
6826 6826
6827 6827
6896 { 6896 {
6897 XBM_TK_IDENT = 256, 6897 XBM_TK_IDENT = 256,
6898 XBM_TK_NUMBER 6898 XBM_TK_NUMBER
6899 }; 6899 };
6900 6900
6901 6901
6902 /* Return non-zero if OBJECT is a valid XBM-type image specification. 6902 /* Return non-zero if OBJECT is a valid XBM-type image specification.
6903 A valid specification is a list starting with the symbol `image' 6903 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 6904 The rest of the list is a property list which must contain an
6905 entry `:type xbm.. 6905 entry `:type xbm..
6906 6906
6931 static int 6931 static int
6932 xbm_image_p (object) 6932 xbm_image_p (object)
6933 Lisp_Object object; 6933 Lisp_Object object;
6934 { 6934 {
6935 struct image_keyword kw[XBM_LAST]; 6935 struct image_keyword kw[XBM_LAST];
6936 6936
6937 bcopy (xbm_format, kw, sizeof kw); 6937 bcopy (xbm_format, kw, sizeof kw);
6938 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) 6938 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
6939 return 0; 6939 return 0;
6940 6940
6941 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); 6941 xassert (EQ (kw[XBM_TYPE].value, Qxbm));
6963 return 0; 6963 return 0;
6964 6964
6965 data = kw[XBM_DATA].value; 6965 data = kw[XBM_DATA].value;
6966 width = XFASTINT (kw[XBM_WIDTH].value); 6966 width = XFASTINT (kw[XBM_WIDTH].value);
6967 height = XFASTINT (kw[XBM_HEIGHT].value); 6967 height = XFASTINT (kw[XBM_HEIGHT].value);
6968 6968
6969 /* Check type of data, and width and height against contents of 6969 /* Check type of data, and width and height against contents of
6970 data. */ 6970 data. */
6971 if (VECTORP (data)) 6971 if (VECTORP (data))
6972 { 6972 {
6973 int i; 6973 int i;
6974 6974
6975 /* Number of elements of the vector must be >= height. */ 6975 /* Number of elements of the vector must be >= height. */
6976 if (XVECTOR (data)->size < height) 6976 if (XVECTOR (data)->size < height)
6977 return 0; 6977 return 0;
6978 6978
6979 /* Each string or bool-vector in data must be large enough 6979 /* Each string or bool-vector in data must be large enough
7029 int *ival; 7029 int *ival;
7030 { 7030 {
7031 int c; 7031 int c;
7032 7032
7033 loop: 7033 loop:
7034 7034
7035 /* Skip white space. */ 7035 /* Skip white space. */
7036 while (*s < end && (c = *(*s)++, isspace (c))) 7036 while (*s < end && (c = *(*s)++, isspace (c)))
7037 ; 7037 ;
7038 7038
7039 if (*s >= end) 7039 if (*s >= end)
7040 c = 0; 7040 c = 0;
7041 else if (isdigit (c)) 7041 else if (isdigit (c))
7042 { 7042 {
7043 int value = 0, digit; 7043 int value = 0, digit;
7044 7044
7045 if (c == '0' && *s < end) 7045 if (c == '0' && *s < end)
7046 { 7046 {
7047 c = *(*s)++; 7047 c = *(*s)++;
7048 if (c == 'x' || c == 'X') 7048 if (c == 'x' || c == 'X')
7049 { 7049 {
7137 7137
7138 #define expect(TOKEN) \ 7138 #define expect(TOKEN) \
7139 if (LA1 != (TOKEN)) \ 7139 if (LA1 != (TOKEN)) \
7140 goto failure; \ 7140 goto failure; \
7141 else \ 7141 else \
7142 match () 7142 match ()
7143 7143
7144 #define expect_ident(IDENT) \ 7144 #define expect_ident(IDENT) \
7145 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \ 7145 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \
7146 match (); \ 7146 match (); \
7147 else \ 7147 else \
7180 expect_ident ("static"); 7180 expect_ident ("static");
7181 if (LA1 == XBM_TK_IDENT) 7181 if (LA1 == XBM_TK_IDENT)
7182 { 7182 {
7183 if (strcmp (buffer, "unsigned") == 0) 7183 if (strcmp (buffer, "unsigned") == 0)
7184 { 7184 {
7185 match (); 7185 match ();
7186 expect_ident ("char"); 7186 expect_ident ("char");
7187 } 7187 }
7188 else if (strcmp (buffer, "short") == 0) 7188 else if (strcmp (buffer, "short") == 0)
7189 { 7189 {
7190 match (); 7190 match ();
7195 else if (strcmp (buffer, "char") == 0) 7195 else if (strcmp (buffer, "char") == 0)
7196 match (); 7196 match ();
7197 else 7197 else
7198 goto failure; 7198 goto failure;
7199 } 7199 }
7200 else 7200 else
7201 goto failure; 7201 goto failure;
7202 7202
7203 expect (XBM_TK_IDENT); 7203 expect (XBM_TK_IDENT);
7204 expect ('['); 7204 expect ('[');
7205 expect (']'); 7205 expect (']');
7218 expect (XBM_TK_NUMBER); 7218 expect (XBM_TK_NUMBER);
7219 7219
7220 *p++ = val; 7220 *p++ = val;
7221 if (!padding_p || ((i + 2) % bytes_per_line)) 7221 if (!padding_p || ((i + 2) % bytes_per_line))
7222 *p++ = value >> 8; 7222 *p++ = value >> 8;
7223 7223
7224 if (LA1 == ',' || LA1 == '}') 7224 if (LA1 == ',' || LA1 == '}')
7225 match (); 7225 match ();
7226 else 7226 else
7227 goto failure; 7227 goto failure;
7228 } 7228 }
7231 { 7231 {
7232 for (i = 0; i < nbytes; ++i) 7232 for (i = 0; i < nbytes; ++i)
7233 { 7233 {
7234 int val = value; 7234 int val = value;
7235 expect (XBM_TK_NUMBER); 7235 expect (XBM_TK_NUMBER);
7236 7236
7237 *p++ = val; 7237 *p++ = val;
7238 7238
7239 if (LA1 == ',' || LA1 == '}') 7239 if (LA1 == ',' || LA1 == '}')
7240 match (); 7240 match ();
7241 else 7241 else
7242 goto failure; 7242 goto failure;
7243 } 7243 }
7245 7245
7246 success: 7246 success:
7247 return 1; 7247 return 1;
7248 7248
7249 failure: 7249 failure:
7250 7250
7251 if (data && *data) 7251 if (data && *data)
7252 { 7252 {
7253 xfree (*data); 7253 xfree (*data);
7254 *data = NULL; 7254 *data = NULL;
7255 } 7255 }
7272 char *contents, *end; 7272 char *contents, *end;
7273 { 7273 {
7274 int rc; 7274 int rc;
7275 unsigned char *data; 7275 unsigned char *data;
7276 int success_p = 0; 7276 int success_p = 0;
7277 7277
7278 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data); 7278 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
7279 if (rc) 7279 if (rc)
7280 { 7280 {
7281 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f)); 7281 int depth = DefaultDepthOfScreen (FRAME_X_SCREEN (f));
7282 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); 7282 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
7283 unsigned long background = FRAME_BACKGROUND_PIXEL (f); 7283 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
7284 Lisp_Object value; 7284 Lisp_Object value;
7285 7285
7286 xassert (img->width > 0 && img->height > 0); 7286 xassert (img->width > 0 && img->height > 0);
7287 7287
7288 /* Get foreground and background colors, maybe allocate colors. */ 7288 /* Get foreground and background colors, maybe allocate colors. */
7289 value = image_spec_value (img->spec, QCforeground, NULL); 7289 value = image_spec_value (img->spec, QCforeground, NULL);
7290 if (!NILP (value)) 7290 if (!NILP (value))
7333 (SDATA (data) 7333 (SDATA (data)
7334 + SBYTES (data)), 7334 + SBYTES (data)),
7335 &w, &h, NULL)); 7335 &w, &h, NULL));
7336 } 7336 }
7337 7337
7338 7338
7339 /* Fill image IMG which is used on frame F with pixmap data. Value is 7339 /* Fill image IMG which is used on frame F with pixmap data. Value is
7340 non-zero if successful. */ 7340 non-zero if successful. */
7341 7341
7342 static int 7342 static int
7343 xbm_load (f, img) 7343 xbm_load (f, img)
7355 { 7355 {
7356 Lisp_Object file; 7356 Lisp_Object file;
7357 char *contents; 7357 char *contents;
7358 int size; 7358 int size;
7359 struct gcpro gcpro1; 7359 struct gcpro gcpro1;
7360 7360
7361 file = x_find_image_file (file_name); 7361 file = x_find_image_file (file_name);
7362 GCPRO1 (file); 7362 GCPRO1 (file);
7363 if (!STRINGP (file)) 7363 if (!STRINGP (file))
7364 { 7364 {
7365 image_error ("Cannot find image file `%s'", file_name, Qnil); 7365 image_error ("Cannot find image file `%s'", file_name, Qnil);
7425 if (VECTORP (data)) 7425 if (VECTORP (data))
7426 { 7426 {
7427 int i; 7427 int i;
7428 char *p; 7428 char *p;
7429 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 7429 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
7430 7430
7431 p = bits = (char *) alloca (nbytes * img->height); 7431 p = bits = (char *) alloca (nbytes * img->height);
7432 for (i = 0; i < img->height; ++i, p += nbytes) 7432 for (i = 0; i < img->height; ++i, p += nbytes)
7433 { 7433 {
7434 Lisp_Object line = XVECTOR (data)->contents[i]; 7434 Lisp_Object line = XVECTOR (data)->contents[i];
7435 if (STRINGP (line)) 7435 if (STRINGP (line))
7463 } 7463 }
7464 } 7464 }
7465 7465
7466 return success_p; 7466 return success_p;
7467 } 7467 }
7468 7468
7469 7469
7470 7470
7471 /*********************************************************************** 7471 /***********************************************************************
7472 XPM images 7472 XPM images
7473 ***********************************************************************/ 7473 ***********************************************************************/
7474 7474
7475 #if HAVE_XPM 7475 #if HAVE_XPM
7476 7476
7477 static int xpm_image_p P_ ((Lisp_Object object)); 7477 static int xpm_image_p P_ ((Lisp_Object object));
7478 static int xpm_load P_ ((struct frame *f, struct image *img)); 7478 static int xpm_load P_ ((struct frame *f, struct image *img));
7479 static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); 7479 static int xpm_valid_color_symbols_p P_ ((Lisp_Object));
7480 7480
7587 7587
7588 if (attrs->valuemask & XpmColorSymbols) 7588 if (attrs->valuemask & XpmColorSymbols)
7589 { 7589 {
7590 int i; 7590 int i;
7591 XColor color; 7591 XColor color;
7592 7592
7593 for (i = 0; i < attrs->numsymbols; ++i) 7593 for (i = 0; i < attrs->numsymbols; ++i)
7594 if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), 7594 if (XParseColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f),
7595 attrs->colorsymbols[i].value, &color)) 7595 attrs->colorsymbols[i].value, &color))
7596 { 7596 {
7597 color.pixel = lookup_rgb_color (f, color.red, color.green, 7597 color.pixel = lookup_rgb_color (f, color.red, color.green,
7630 xpm_color_bucket (color_name) 7630 xpm_color_bucket (color_name)
7631 char *color_name; 7631 char *color_name;
7632 { 7632 {
7633 unsigned h = 0; 7633 unsigned h = 0;
7634 char *s; 7634 char *s;
7635 7635
7636 for (s = color_name; *s; ++s) 7636 for (s = color_name; *s; ++s)
7637 h = (h << 2) ^ *s; 7637 h = (h << 2) ^ *s;
7638 return h %= XPM_COLOR_CACHE_BUCKETS; 7638 return h %= XPM_COLOR_CACHE_BUCKETS;
7639 } 7639 }
7640 7640
7650 XColor *color; 7650 XColor *color;
7651 int bucket; 7651 int bucket;
7652 { 7652 {
7653 size_t nbytes; 7653 size_t nbytes;
7654 struct xpm_cached_color *p; 7654 struct xpm_cached_color *p;
7655 7655
7656 if (bucket < 0) 7656 if (bucket < 0)
7657 bucket = xpm_color_bucket (color_name); 7657 bucket = xpm_color_bucket (color_name);
7658 7658
7659 nbytes = sizeof *p + strlen (color_name); 7659 nbytes = sizeof *p + strlen (color_name);
7660 p = (struct xpm_cached_color *) xmalloc (nbytes); 7660 p = (struct xpm_cached_color *) xmalloc (nbytes);
7661 strcpy (p->name, color_name); 7661 strcpy (p->name, color_name);
7662 p->color = *color; 7662 p->color = *color;
7663 p->next = xpm_color_cache[bucket]; 7663 p->next = xpm_color_cache[bucket];
7691 { 7691 {
7692 color->pixel = lookup_rgb_color (f, color->red, color->green, 7692 color->pixel = lookup_rgb_color (f, color->red, color->green,
7693 color->blue); 7693 color->blue);
7694 p = xpm_cache_color (f, color_name, color, h); 7694 p = xpm_cache_color (f, color_name, color, h);
7695 } 7695 }
7696 7696
7697 return p != NULL; 7697 return p != NULL;
7698 } 7698 }
7699 7699
7700 7700
7701 /* Callback for allocating color COLOR_NAME. Called from the XPM lib. 7701 /* Callback for allocating color COLOR_NAME. Called from the XPM lib.
7818 if (CONSP (color_symbols)) 7818 if (CONSP (color_symbols))
7819 { 7819 {
7820 Lisp_Object tail; 7820 Lisp_Object tail;
7821 XpmColorSymbol *xpm_syms; 7821 XpmColorSymbol *xpm_syms;
7822 int i, size; 7822 int i, size;
7823 7823
7824 attrs.valuemask |= XpmColorSymbols; 7824 attrs.valuemask |= XpmColorSymbols;
7825 7825
7826 /* Count number of symbols. */ 7826 /* Count number of symbols. */
7827 attrs.numsymbols = 0; 7827 attrs.numsymbols = 0;
7828 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail)) 7828 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail))
7851 /* Create a pixmap for the image, either from a file, or from a 7851 /* Create a pixmap for the image, either from a file, or from a
7852 string buffer containing data in the same format as an XPM file. */ 7852 string buffer containing data in the same format as an XPM file. */
7853 #ifdef ALLOC_XPM_COLORS 7853 #ifdef ALLOC_XPM_COLORS
7854 xpm_init_color_cache (f, &attrs); 7854 xpm_init_color_cache (f, &attrs);
7855 #endif 7855 #endif
7856 7856
7857 specified_file = image_spec_value (img->spec, QCfile, NULL); 7857 specified_file = image_spec_value (img->spec, QCfile, NULL);
7858 if (STRINGP (specified_file)) 7858 if (STRINGP (specified_file))
7859 { 7859 {
7860 Lisp_Object file = x_find_image_file (specified_file); 7860 Lisp_Object file = x_find_image_file (specified_file);
7861 if (!STRINGP (file)) 7861 if (!STRINGP (file))
7862 { 7862 {
7863 image_error ("Cannot find image file `%s'", specified_file, Qnil); 7863 image_error ("Cannot find image file `%s'", specified_file, Qnil);
7864 return 0; 7864 return 0;
7865 } 7865 }
7866 7866
7867 rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7867 rc = XpmReadFileToPixmap (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7868 SDATA (file), &img->pixmap, &img->mask, 7868 SDATA (file), &img->pixmap, &img->mask,
7869 &attrs); 7869 &attrs);
7870 } 7870 }
7871 else 7871 else
7908 switch (rc) 7908 switch (rc)
7909 { 7909 {
7910 case XpmOpenFailed: 7910 case XpmOpenFailed:
7911 image_error ("Error opening XPM file (%s)", img->spec, Qnil); 7911 image_error ("Error opening XPM file (%s)", img->spec, Qnil);
7912 break; 7912 break;
7913 7913
7914 case XpmFileInvalid: 7914 case XpmFileInvalid:
7915 image_error ("Invalid XPM file (%s)", img->spec, Qnil); 7915 image_error ("Invalid XPM file (%s)", img->spec, Qnil);
7916 break; 7916 break;
7917 7917
7918 case XpmNoMemory: 7918 case XpmNoMemory:
7919 image_error ("Out of memory (%s)", img->spec, Qnil); 7919 image_error ("Out of memory (%s)", img->spec, Qnil);
7920 break; 7920 break;
7921 7921
7922 case XpmColorFailed: 7922 case XpmColorFailed:
7923 image_error ("Color allocation error (%s)", img->spec, Qnil); 7923 image_error ("Color allocation error (%s)", img->spec, Qnil);
7924 break; 7924 break;
7925 7925
7926 default: 7926 default:
7927 image_error ("Unknown error (%s)", img->spec, Qnil); 7927 image_error ("Unknown error (%s)", img->spec, Qnil);
7928 break; 7928 break;
7929 } 7929 }
7930 } 7930 }
8026 int rc; 8026 int rc;
8027 8027
8028 color.red = r; 8028 color.red = r;
8029 color.green = g; 8029 color.green = g;
8030 color.blue = b; 8030 color.blue = b;
8031 8031
8032 cmap = FRAME_X_COLORMAP (f); 8032 cmap = FRAME_X_COLORMAP (f);
8033 rc = x_alloc_nearest_color (f, cmap, &color); 8033 rc = x_alloc_nearest_color (f, cmap, &color);
8034 8034
8035 if (rc) 8035 if (rc)
8036 { 8036 {
8037 ++ct_colors_allocated; 8037 ++ct_colors_allocated;
8038 8038
8039 p = (struct ct_color *) xmalloc (sizeof *p); 8039 p = (struct ct_color *) xmalloc (sizeof *p);
8040 p->r = r; 8040 p->r = r;
8041 p->g = g; 8041 p->g = g;
8042 p->b = b; 8042 p->b = b;
8043 p->pixel = color.pixel; 8043 p->pixel = color.pixel;
8079 rc = x_alloc_nearest_color (f, cmap, &color); 8079 rc = x_alloc_nearest_color (f, cmap, &color);
8080 8080
8081 if (rc) 8081 if (rc)
8082 { 8082 {
8083 ++ct_colors_allocated; 8083 ++ct_colors_allocated;
8084 8084
8085 p = (struct ct_color *) xmalloc (sizeof *p); 8085 p = (struct ct_color *) xmalloc (sizeof *p);
8086 p->r = color.red; 8086 p->r = color.red;
8087 p->g = color.green; 8087 p->g = color.green;
8088 p->b = color.blue; 8088 p->b = color.blue;
8089 p->pixel = pixel; 8089 p->pixel = pixel;
8091 ct_table[i] = p; 8091 ct_table[i] = p;
8092 } 8092 }
8093 else 8093 else
8094 return FRAME_FOREGROUND_PIXEL (f); 8094 return FRAME_FOREGROUND_PIXEL (f);
8095 } 8095 }
8096 8096
8097 return p->pixel; 8097 return p->pixel;
8098 } 8098 }
8099 8099
8100 8100
8101 /* Value is a vector of all pixel colors contained in the color table, 8101 /* Value is a vector of all pixel colors contained in the color table,
8117 else 8117 else
8118 { 8118 {
8119 colors = (unsigned long *) xmalloc (ct_colors_allocated 8119 colors = (unsigned long *) xmalloc (ct_colors_allocated
8120 * sizeof *colors); 8120 * sizeof *colors);
8121 *n = ct_colors_allocated; 8121 *n = ct_colors_allocated;
8122 8122
8123 for (i = j = 0; i < CT_SIZE; ++i) 8123 for (i = j = 0; i < CT_SIZE; ++i)
8124 for (p = ct_table[i]; p; p = p->next) 8124 for (p = ct_table[i]; p; p = p->next)
8125 colors[j++] = p->pixel; 8125 colors[j++] = p->pixel;
8126 } 8126 }
8127 8127
8192 were an easy and portable way to circumvent XGetPixel. */ 8192 were an easy and portable way to circumvent XGetPixel. */
8193 p = colors; 8193 p = colors;
8194 for (y = 0; y < img->height; ++y) 8194 for (y = 0; y < img->height; ++y)
8195 { 8195 {
8196 XColor *row = p; 8196 XColor *row = p;
8197 8197
8198 for (x = 0; x < img->width; ++x, ++p) 8198 for (x = 0; x < img->width; ++x, ++p)
8199 p->pixel = XGetPixel (ximg, x, y); 8199 p->pixel = XGetPixel (ximg, x, y);
8200 8200
8201 if (rgb_p) 8201 if (rgb_p)
8202 x_query_colors (f, row, img->width); 8202 x_query_colors (f, row, img->width);
8219 { 8219 {
8220 int x, y; 8220 int x, y;
8221 XImage *oimg; 8221 XImage *oimg;
8222 Pixmap pixmap; 8222 Pixmap pixmap;
8223 XColor *p; 8223 XColor *p;
8224 8224
8225 init_color_table (); 8225 init_color_table ();
8226 8226
8227 x_create_x_image_and_pixmap (f, img->width, img->height, 0, 8227 x_create_x_image_and_pixmap (f, img->width, img->height, 0,
8228 &oimg, &pixmap); 8228 &oimg, &pixmap);
8229 p = colors; 8229 p = colors;
8230 for (y = 0; y < img->height; ++y) 8230 for (y = 0; y < img->height; ++y)
8231 for (x = 0; x < img->width; ++x, ++p) 8231 for (x = 0; x < img->width; ++x, ++p)
8248 8248
8249 /* On frame F, perform edge-detection on image IMG. 8249 /* On frame F, perform edge-detection on image IMG.
8250 8250
8251 MATRIX is a nine-element array specifying the transformation 8251 MATRIX is a nine-element array specifying the transformation
8252 matrix. See emboss_matrix for an example. 8252 matrix. See emboss_matrix for an example.
8253 8253
8254 COLOR_ADJUST is a color adjustment added to each pixel of the 8254 COLOR_ADJUST is a color adjustment added to each pixel of the
8255 outgoing image. */ 8255 outgoing image. */
8256 8256
8257 static void 8257 static void
8258 x_detect_edges (f, img, matrix, color_adjust) 8258 x_detect_edges (f, img, matrix, color_adjust)
8276 p = COLOR (new, 0, y); 8276 p = COLOR (new, 0, y);
8277 p->red = p->green = p->blue = 0xffff/2; 8277 p->red = p->green = p->blue = 0xffff/2;
8278 p = COLOR (new, img->width - 1, y); 8278 p = COLOR (new, img->width - 1, y);
8279 p->red = p->green = p->blue = 0xffff/2; 8279 p->red = p->green = p->blue = 0xffff/2;
8280 } 8280 }
8281 8281
8282 for (x = 1; x < img->width - 1; ++x) 8282 for (x = 1; x < img->width - 1; ++x)
8283 { 8283 {
8284 p = COLOR (new, x, 0); 8284 p = COLOR (new, x, 0);
8285 p->red = p->green = p->blue = 0xffff/2; 8285 p->red = p->green = p->blue = 0xffff/2;
8286 p = COLOR (new, x, img->height - 1); 8286 p = COLOR (new, x, img->height - 1);
8288 } 8288 }
8289 8289
8290 for (y = 1; y < img->height - 1; ++y) 8290 for (y = 1; y < img->height - 1; ++y)
8291 { 8291 {
8292 p = COLOR (new, 1, y); 8292 p = COLOR (new, 1, y);
8293 8293
8294 for (x = 1; x < img->width - 1; ++x, ++p) 8294 for (x = 1; x < img->width - 1; ++x, ++p)
8295 { 8295 {
8296 int r, g, b, y1, x1; 8296 int r, g, b, y1, x1;
8297 8297
8298 r = g = b = i = 0; 8298 r = g = b = i = 0;
8361 struct image *img; 8361 struct image *img;
8362 Lisp_Object matrix, color_adjust; 8362 Lisp_Object matrix, color_adjust;
8363 { 8363 {
8364 int i = 0; 8364 int i = 0;
8365 int trans[9]; 8365 int trans[9];
8366 8366
8367 if (CONSP (matrix)) 8367 if (CONSP (matrix))
8368 { 8368 {
8369 for (i = 0; 8369 for (i = 0;
8370 i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix)); 8370 i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix));
8371 ++i, matrix = XCDR (matrix)) 8371 ++i, matrix = XCDR (matrix))
8481 ~0, ZPixmap); 8481 ~0, ZPixmap);
8482 8482
8483 /* Determine the background color of ximg. If HOW is `(R G B)' 8483 /* Determine the background color of ximg. If HOW is `(R G B)'
8484 take that as color. Otherwise, use the image's background color. */ 8484 take that as color. Otherwise, use the image's background color. */
8485 use_img_background = 1; 8485 use_img_background = 1;
8486 8486
8487 if (CONSP (how)) 8487 if (CONSP (how))
8488 { 8488 {
8489 int rgb[3], i; 8489 int rgb[3], i;
8490 8490
8491 for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i) 8491 for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i)
8500 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); 8500 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
8501 bg = x_alloc_image_color (f, img, build_string (color_name), 0); 8501 bg = x_alloc_image_color (f, img, build_string (color_name), 0);
8502 use_img_background = 0; 8502 use_img_background = 0;
8503 } 8503 }
8504 } 8504 }
8505 8505
8506 if (use_img_background) 8506 if (use_img_background)
8507 bg = four_corners_best (ximg, img->width, img->height); 8507 bg = four_corners_best (ximg, img->width, img->height);
8508 8508
8509 /* Set all bits in mask_img to 1 whose color in ximg is different 8509 /* Set all bits in mask_img to 1 whose color in ximg is different
8510 from the background color bg. */ 8510 from the background color bg. */
8517 8517
8518 /* Put mask_img into img->mask. */ 8518 /* Put mask_img into img->mask. */
8519 x_put_x_image (f, mask_img, img->mask, img->width, img->height); 8519 x_put_x_image (f, mask_img, img->mask, img->width, img->height);
8520 x_destroy_x_image (mask_img); 8520 x_destroy_x_image (mask_img);
8521 XDestroyImage (ximg); 8521 XDestroyImage (ximg);
8522 8522
8523 return 1; 8523 return 1;
8524 } 8524 }
8525 8525
8526 8526
8527 8527
8590 static int 8590 static int
8591 pbm_image_p (object) 8591 pbm_image_p (object)
8592 Lisp_Object object; 8592 Lisp_Object object;
8593 { 8593 {
8594 struct image_keyword fmt[PBM_LAST]; 8594 struct image_keyword fmt[PBM_LAST];
8595 8595
8596 bcopy (pbm_format, fmt, sizeof fmt); 8596 bcopy (pbm_format, fmt, sizeof fmt);
8597 8597
8598 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)) 8598 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm))
8599 return 0; 8599 return 0;
8600 8600
8601 /* Must specify either :data or :file. */ 8601 /* Must specify either :data or :file. */
8602 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1; 8602 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1;
8641 } 8641 }
8642 8642
8643 8643
8644 /* Load PBM image IMG for use on frame F. */ 8644 /* Load PBM image IMG for use on frame F. */
8645 8645
8646 static int 8646 static int
8647 pbm_load (f, img) 8647 pbm_load (f, img)
8648 struct frame *f; 8648 struct frame *f;
8649 struct image *img; 8649 struct image *img;
8650 { 8650 {
8651 int raw_p, x, y; 8651 int raw_p, x, y;
8704 switch (*p++) 8704 switch (*p++)
8705 { 8705 {
8706 case '1': 8706 case '1':
8707 raw_p = 0, type = PBM_MONO; 8707 raw_p = 0, type = PBM_MONO;
8708 break; 8708 break;
8709 8709
8710 case '2': 8710 case '2':
8711 raw_p = 0, type = PBM_GRAY; 8711 raw_p = 0, type = PBM_GRAY;
8712 break; 8712 break;
8713 8713
8714 case '3': 8714 case '3':
8716 break; 8716 break;
8717 8717
8718 case '4': 8718 case '4':
8719 raw_p = 1, type = PBM_MONO; 8719 raw_p = 1, type = PBM_MONO;
8720 break; 8720 break;
8721 8721
8722 case '5': 8722 case '5':
8723 raw_p = 1, type = PBM_GRAY; 8723 raw_p = 1, type = PBM_GRAY;
8724 break; 8724 break;
8725 8725
8726 case '6': 8726 case '6':
8727 raw_p = 1, type = PBM_COLOR; 8727 raw_p = 1, type = PBM_COLOR;
8728 break; 8728 break;
8729 8729
8730 default: 8730 default:
8741 { 8741 {
8742 max_color_idx = pbm_scan_number (&p, end); 8742 max_color_idx = pbm_scan_number (&p, end);
8743 if (raw_p && max_color_idx > 255) 8743 if (raw_p && max_color_idx > 255)
8744 max_color_idx = 255; 8744 max_color_idx = 255;
8745 } 8745 }
8746 8746
8747 if (width < 0 8747 if (width < 0
8748 || height < 0 8748 || height < 0
8749 || (type != PBM_MONO && max_color_idx < 0)) 8749 || (type != PBM_MONO && max_color_idx < 0))
8750 goto error; 8750 goto error;
8751 8751
8752 if (!x_create_x_image_and_pixmap (f, width, height, 0, 8752 if (!x_create_x_image_and_pixmap (f, width, height, 0,
8753 &ximg, &img->pixmap)) 8753 &ximg, &img->pixmap))
8754 goto error; 8754 goto error;
8755 8755
8756 /* Initialize the color hash table. */ 8756 /* Initialize the color hash table. */
8757 init_color_table (); 8757 init_color_table ();
8758 8758
8759 if (type == PBM_MONO) 8759 if (type == PBM_MONO)
8760 { 8760 {
8764 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 8764 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
8765 8765
8766 /* Parse the image specification. */ 8766 /* Parse the image specification. */
8767 bcopy (pbm_format, fmt, sizeof fmt); 8767 bcopy (pbm_format, fmt, sizeof fmt);
8768 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); 8768 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);
8769 8769
8770 /* Get foreground and background colors, maybe allocate colors. */ 8770 /* Get foreground and background colors, maybe allocate colors. */
8771 if (fmt[PBM_FOREGROUND].count 8771 if (fmt[PBM_FOREGROUND].count
8772 && STRINGP (fmt[PBM_FOREGROUND].value)) 8772 && STRINGP (fmt[PBM_FOREGROUND].value))
8773 fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg); 8773 fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
8774 if (fmt[PBM_BACKGROUND].count 8774 if (fmt[PBM_BACKGROUND].count
8776 { 8776 {
8777 bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg); 8777 bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
8778 img->background = bg; 8778 img->background = bg;
8779 img->background_valid = 1; 8779 img->background_valid = 1;
8780 } 8780 }
8781 8781
8782 for (y = 0; y < height; ++y) 8782 for (y = 0; y < height; ++y)
8783 for (x = 0; x < width; ++x) 8783 for (x = 0; x < width; ++x)
8784 { 8784 {
8785 if (raw_p) 8785 if (raw_p)
8786 { 8786 {
8799 { 8799 {
8800 for (y = 0; y < height; ++y) 8800 for (y = 0; y < height; ++y)
8801 for (x = 0; x < width; ++x) 8801 for (x = 0; x < width; ++x)
8802 { 8802 {
8803 int r, g, b; 8803 int r, g, b;
8804 8804
8805 if (type == PBM_GRAY) 8805 if (type == PBM_GRAY)
8806 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end); 8806 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
8807 else if (raw_p) 8807 else if (raw_p)
8808 { 8808 {
8809 r = *p++; 8809 r = *p++;
8814 { 8814 {
8815 r = pbm_scan_number (&p, end); 8815 r = pbm_scan_number (&p, end);
8816 g = pbm_scan_number (&p, end); 8816 g = pbm_scan_number (&p, end);
8817 b = pbm_scan_number (&p, end); 8817 b = pbm_scan_number (&p, end);
8818 } 8818 }
8819 8819
8820 if (r < 0 || g < 0 || b < 0) 8820 if (r < 0 || g < 0 || b < 0)
8821 { 8821 {
8822 xfree (ximg->data); 8822 xfree (ximg->data);
8823 ximg->data = NULL; 8823 ximg->data = NULL;
8824 XDestroyImage (ximg); 8824 XDestroyImage (ximg);
8825 image_error ("Invalid pixel value in image `%s'", 8825 image_error ("Invalid pixel value in image `%s'",
8826 img->spec, Qnil); 8826 img->spec, Qnil);
8827 goto error; 8827 goto error;
8828 } 8828 }
8829 8829
8830 /* RGB values are now in the range 0..max_color_idx. 8830 /* RGB values are now in the range 0..max_color_idx.
8831 Scale this to the range 0..0xffff supported by X. */ 8831 Scale this to the range 0..0xffff supported by X. */
8832 r = (double) r * 65535 / max_color_idx; 8832 r = (double) r * 65535 / max_color_idx;
8833 g = (double) g * 65535 / max_color_idx; 8833 g = (double) g * 65535 / max_color_idx;
8834 b = (double) b * 65535 / max_color_idx; 8834 b = (double) b * 65535 / max_color_idx;
8835 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); 8835 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
8836 } 8836 }
8837 } 8837 }
8838 8838
8839 /* Store in IMG->colors the colors allocated for the image, and 8839 /* Store in IMG->colors the colors allocated for the image, and
8840 free the color table. */ 8840 free the color table. */
8841 img->colors = colors_in_color_table (&img->ncolors); 8841 img->colors = colors_in_color_table (&img->ncolors);
8842 free_color_table (); 8842 free_color_table ();
8843 8843
8844 /* Maybe fill in the background field while we have ximg handy. */ 8844 /* Maybe fill in the background field while we have ximg handy. */
8845 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 8845 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8846 IMAGE_BACKGROUND (img, f, ximg); 8846 IMAGE_BACKGROUND (img, f, ximg);
8847 8847
8848 /* Put the image into a pixmap. */ 8848 /* Put the image into a pixmap. */
8849 x_put_x_image (f, ximg, img->pixmap, width, height); 8849 x_put_x_image (f, ximg, img->pixmap, width, height);
8850 x_destroy_x_image (ximg); 8850 x_destroy_x_image (ximg);
8851 8851
8852 img->width = width; 8852 img->width = width;
8853 img->height = height; 8853 img->height = height;
8854 8854
8855 UNGCPRO; 8855 UNGCPRO;
8856 xfree (contents); 8856 xfree (contents);
8928 png_image_p (object) 8928 png_image_p (object)
8929 Lisp_Object object; 8929 Lisp_Object object;
8930 { 8930 {
8931 struct image_keyword fmt[PNG_LAST]; 8931 struct image_keyword fmt[PNG_LAST];
8932 bcopy (png_format, fmt, sizeof fmt); 8932 bcopy (png_format, fmt, sizeof fmt);
8933 8933
8934 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)) 8934 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng))
8935 return 0; 8935 return 0;
8936 8936
8937 /* Must specify either the :data or :file keyword. */ 8937 /* Must specify either the :data or :file keyword. */
8938 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; 8938 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1;
8985 struct png_memory_storage *tbr 8985 struct png_memory_storage *tbr
8986 = (struct png_memory_storage *) png_get_io_ptr (png_ptr); 8986 = (struct png_memory_storage *) png_get_io_ptr (png_ptr);
8987 8987
8988 if (length > tbr->len - tbr->index) 8988 if (length > tbr->len - tbr->index)
8989 png_error (png_ptr, "Read error"); 8989 png_error (png_ptr, "Read error");
8990 8990
8991 bcopy (tbr->bytes + tbr->index, data, length); 8991 bcopy (tbr->bytes + tbr->index, data, length);
8992 tbr->index = tbr->index + length; 8992 tbr->index = tbr->index + length;
8993 } 8993 }
8994 8994
8995 /* Load PNG image IMG for use on frame F. Value is non-zero if 8995 /* Load PNG image IMG for use on frame F. Value is non-zero if
9127 png_set_sig_bytes (png_ptr, sizeof sig); 9127 png_set_sig_bytes (png_ptr, sizeof sig);
9128 png_read_info (png_ptr, info_ptr); 9128 png_read_info (png_ptr, info_ptr);
9129 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 9129 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
9130 &interlace_type, NULL, NULL); 9130 &interlace_type, NULL, NULL);
9131 9131
9132 /* If image contains simply transparency data, we prefer to 9132 /* If image contains simply transparency data, we prefer to
9133 construct a clipping mask. */ 9133 construct a clipping mask. */
9134 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) 9134 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
9135 transparent_p = 1; 9135 transparent_p = 1;
9136 else 9136 else
9137 transparent_p = 0; 9137 transparent_p = 0;
9138 9138
9139 /* This function is easier to write if we only have to handle 9139 /* 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 9140 one data format: RGB or RGBA with 8 bits per channel. Let's
9141 transform other formats into that format. */ 9141 transform other formats into that format. */
9142 9142
9143 /* Strip more than 8 bits per channel. */ 9143 /* Strip more than 8 bits per channel. */
9144 if (bit_depth == 16) 9144 if (bit_depth == 16)
9147 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel 9147 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel
9148 if available. */ 9148 if available. */
9149 png_set_expand (png_ptr); 9149 png_set_expand (png_ptr);
9150 9150
9151 /* Convert grayscale images to RGB. */ 9151 /* Convert grayscale images to RGB. */
9152 if (color_type == PNG_COLOR_TYPE_GRAY 9152 if (color_type == PNG_COLOR_TYPE_GRAY
9153 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 9153 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
9154 png_set_gray_to_rgb (png_ptr); 9154 png_set_gray_to_rgb (png_ptr);
9155 9155
9156 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2); 9156 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2);
9157 9157
9196 png_set_background (png_ptr, &user_bg, 9196 png_set_background (png_ptr, &user_bg,
9197 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 9197 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
9198 } 9198 }
9199 } 9199 }
9200 else if (png_get_bKGD (png_ptr, info_ptr, &image_bg)) 9200 else if (png_get_bKGD (png_ptr, info_ptr, &image_bg))
9201 /* Image contains a background color with which to 9201 /* Image contains a background color with which to
9202 combine the image. */ 9202 combine the image. */
9203 png_set_background (png_ptr, image_bg, 9203 png_set_background (png_ptr, image_bg,
9204 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); 9204 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
9205 else 9205 else
9206 { 9206 {
9207 /* Image does not contain a background color with which 9207 /* Image does not contain a background color with which
9208 to combine the image data via an alpha channel. Use 9208 to combine the image data via an alpha channel. Use
9209 the frame's background instead. */ 9209 the frame's background instead. */
9210 XColor color; 9210 XColor color;
9211 Colormap cmap; 9211 Colormap cmap;
9212 png_color_16 frame_background; 9212 png_color_16 frame_background;
9213 9213
9251 if (fp) 9251 if (fp)
9252 { 9252 {
9253 fclose (fp); 9253 fclose (fp);
9254 fp = NULL; 9254 fp = NULL;
9255 } 9255 }
9256 9256
9257 /* Create the X image and pixmap. */ 9257 /* Create the X image and pixmap. */
9258 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, 9258 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
9259 &img->pixmap)) 9259 &img->pixmap))
9260 goto error; 9260 goto error;
9261 9261
9262 /* Create an image and pixmap serving as mask if the PNG image 9262 /* Create an image and pixmap serving as mask if the PNG image
9263 contains an alpha channel. */ 9263 contains an alpha channel. */
9264 if (channels == 4 9264 if (channels == 4
9265 && !transparent_p 9265 && !transparent_p
9266 && !x_create_x_image_and_pixmap (f, width, height, 1, 9266 && !x_create_x_image_and_pixmap (f, width, height, 1,
9287 g = *p++ << 8; 9287 g = *p++ << 8;
9288 b = *p++ << 8; 9288 b = *p++ << 8;
9289 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); 9289 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
9290 9290
9291 /* An alpha channel, aka mask channel, associates variable 9291 /* An alpha channel, aka mask channel, associates variable
9292 transparency with an image. Where other image formats 9292 transparency with an image. Where other image formats
9293 support binary transparency---fully transparent or fully 9293 support binary transparency---fully transparent or fully
9294 opaque---PNG allows up to 254 levels of partial transparency. 9294 opaque---PNG allows up to 254 levels of partial transparency.
9295 The PNG library implements partial transparency by combining 9295 The PNG library implements partial transparency by combining
9296 the image with a specified background color. 9296 the image with a specified background color.
9297 9297
9298 I'm not sure how to handle this here nicely: because the 9298 I'm not sure how to handle this here nicely: because the
9299 background on which the image is displayed may change, for 9299 background on which the image is displayed may change, for
9300 real alpha channel support, it would be necessary to create 9300 real alpha channel support, it would be necessary to create
9301 a new image for each possible background. 9301 a new image for each possible background.
9302 9302
9303 What I'm doing now is that a mask is created if we have 9303 What I'm doing now is that a mask is created if we have
9304 boolean transparency information. Otherwise I'm using 9304 boolean transparency information. Otherwise I'm using
9305 the frame's background color to combine the image with. */ 9305 the frame's background color to combine the image with. */
9306 9306
9442 static int 9442 static int
9443 jpeg_image_p (object) 9443 jpeg_image_p (object)
9444 Lisp_Object object; 9444 Lisp_Object object;
9445 { 9445 {
9446 struct image_keyword fmt[JPEG_LAST]; 9446 struct image_keyword fmt[JPEG_LAST];
9447 9447
9448 bcopy (jpeg_format, fmt, sizeof fmt); 9448 bcopy (jpeg_format, fmt, sizeof fmt);
9449 9449
9450 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)) 9450 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg))
9451 return 0; 9451 return 0;
9452 9452
9453 /* Must specify either the :data or :file keyword. */ 9453 /* Must specify either the :data or :file keyword. */
9454 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; 9454 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1;
9515 9515
9516 if (src) 9516 if (src)
9517 { 9517 {
9518 if (num_bytes > src->bytes_in_buffer) 9518 if (num_bytes > src->bytes_in_buffer)
9519 ERREXIT (cinfo, JERR_INPUT_EOF); 9519 ERREXIT (cinfo, JERR_INPUT_EOF);
9520 9520
9521 src->bytes_in_buffer -= num_bytes; 9521 src->bytes_in_buffer -= num_bytes;
9522 src->next_input_byte += num_bytes; 9522 src->next_input_byte += num_bytes;
9523 } 9523 }
9524 } 9524 }
9525 9525
9553 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 9553 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
9554 sizeof (struct jpeg_source_mgr)); 9554 sizeof (struct jpeg_source_mgr));
9555 src = (struct jpeg_source_mgr *) cinfo->src; 9555 src = (struct jpeg_source_mgr *) cinfo->src;
9556 src->next_input_byte = data; 9556 src->next_input_byte = data;
9557 } 9557 }
9558 9558
9559 src = (struct jpeg_source_mgr *) cinfo->src; 9559 src = (struct jpeg_source_mgr *) cinfo->src;
9560 src->init_source = our_init_source; 9560 src->init_source = our_init_source;
9561 src->fill_input_buffer = our_fill_input_buffer; 9561 src->fill_input_buffer = our_fill_input_buffer;
9562 src->skip_input_data = our_skip_input_data; 9562 src->skip_input_data = our_skip_input_data;
9563 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ 9563 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */
9568 9568
9569 9569
9570 /* Load image IMG for use on frame F. Patterned after example.c 9570 /* Load image IMG for use on frame F. Patterned after example.c
9571 from the JPEG lib. */ 9571 from the JPEG lib. */
9572 9572
9573 static int 9573 static int
9574 jpeg_load (f, img) 9574 jpeg_load (f, img)
9575 struct frame *f; 9575 struct frame *f;
9576 struct image *img; 9576 struct image *img;
9577 { 9577 {
9578 struct jpeg_decompress_struct cinfo; 9578 struct jpeg_decompress_struct cinfo;
9601 { 9601 {
9602 image_error ("Cannot find image file `%s'", specified_file, Qnil); 9602 image_error ("Cannot find image file `%s'", specified_file, Qnil);
9603 UNGCPRO; 9603 UNGCPRO;
9604 return 0; 9604 return 0;
9605 } 9605 }
9606 9606
9607 fp = fopen (SDATA (file), "r"); 9607 fp = fopen (SDATA (file), "r");
9608 if (fp == NULL) 9608 if (fp == NULL)
9609 { 9609 {
9610 image_error ("Cannot open `%s'", file, Qnil); 9610 image_error ("Cannot open `%s'", file, Qnil);
9611 UNGCPRO; 9611 UNGCPRO;
9615 9615
9616 /* Customize libjpeg's error handling to call my_error_exit when an 9616 /* Customize libjpeg's error handling to call my_error_exit when an
9617 error is detected. This function will perform a longjmp. */ 9617 error is detected. This function will perform a longjmp. */
9618 cinfo.err = jpeg_std_error (&mgr.pub); 9618 cinfo.err = jpeg_std_error (&mgr.pub);
9619 mgr.pub.error_exit = my_error_exit; 9619 mgr.pub.error_exit = my_error_exit;
9620 9620
9621 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 9621 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
9622 { 9622 {
9623 if (rc == 1) 9623 if (rc == 1)
9624 { 9624 {
9625 /* Called from my_error_exit. Display a JPEG error. */ 9625 /* Called from my_error_exit. Display a JPEG error. */
9626 char buffer[JMSG_LENGTH_MAX]; 9626 char buffer[JMSG_LENGTH_MAX];
9627 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer); 9627 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer);
9628 image_error ("Error reading JPEG image `%s': %s", img->spec, 9628 image_error ("Error reading JPEG image `%s': %s", img->spec,
9629 build_string (buffer)); 9629 build_string (buffer));
9630 } 9630 }
9631 9631
9632 /* Close the input file and destroy the JPEG object. */ 9632 /* Close the input file and destroy the JPEG object. */
9633 if (fp) 9633 if (fp)
9634 fclose ((FILE *) fp); 9634 fclose ((FILE *) fp);
9635 jpeg_destroy_decompress (&cinfo); 9635 jpeg_destroy_decompress (&cinfo);
9636 9636
9637 /* If we already have an XImage, free that. */ 9637 /* If we already have an XImage, free that. */
9638 x_destroy_x_image (ximg); 9638 x_destroy_x_image (ximg);
9639 9639
9640 /* Free pixmap and colors. */ 9640 /* Free pixmap and colors. */
9641 x_clear_image (f, img); 9641 x_clear_image (f, img);
9642 9642
9643 UNGCPRO; 9643 UNGCPRO;
9644 return 0; 9644 return 0;
9645 } 9645 }
9646 9646
9647 /* Create the JPEG decompression object. Let it read from fp. 9647 /* Create the JPEG decompression object. Let it read from fp.
9687 a default color, and we don't have to care about which colors 9687 a default color, and we don't have to care about which colors
9688 can be freed safely, and which can't. */ 9688 can be freed safely, and which can't. */
9689 init_color_table (); 9689 init_color_table ();
9690 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors 9690 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
9691 * sizeof *colors); 9691 * sizeof *colors);
9692 9692
9693 for (i = 0; i < cinfo.actual_number_of_colors; ++i) 9693 for (i = 0; i < cinfo.actual_number_of_colors; ++i)
9694 { 9694 {
9695 /* Multiply RGB values with 255 because X expects RGB values 9695 /* Multiply RGB values with 255 because X expects RGB values
9696 in the range 0..0xffff. */ 9696 in the range 0..0xffff. */
9697 int r = cinfo.colormap[ir][i] << 8; 9697 int r = cinfo.colormap[ir][i] << 8;
9723 fclose ((FILE *) fp); 9723 fclose ((FILE *) fp);
9724 9724
9725 /* Maybe fill in the background field while we have ximg handy. */ 9725 /* Maybe fill in the background field while we have ximg handy. */
9726 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 9726 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
9727 IMAGE_BACKGROUND (img, f, ximg); 9727 IMAGE_BACKGROUND (img, f, ximg);
9728 9728
9729 /* Put the image into the pixmap. */ 9729 /* Put the image into the pixmap. */
9730 x_put_x_image (f, ximg, img->pixmap, width, height); 9730 x_put_x_image (f, ximg, img->pixmap, width, height);
9731 x_destroy_x_image (ximg); 9731 x_destroy_x_image (ximg);
9732 UNGCPRO; 9732 UNGCPRO;
9733 return 1; 9733 return 1;
9804 tiff_image_p (object) 9804 tiff_image_p (object)
9805 Lisp_Object object; 9805 Lisp_Object object;
9806 { 9806 {
9807 struct image_keyword fmt[TIFF_LAST]; 9807 struct image_keyword fmt[TIFF_LAST];
9808 bcopy (tiff_format, fmt, sizeof fmt); 9808 bcopy (tiff_format, fmt, sizeof fmt);
9809 9809
9810 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)) 9810 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff))
9811 return 0; 9811 return 0;
9812 9812
9813 /* Must specify either the :data or :file keyword. */ 9813 /* Must specify either the :data or :file keyword. */
9814 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; 9814 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
9815 } 9815 }
9816 9816
9817 9817
9871 switch (whence) 9871 switch (whence)
9872 { 9872 {
9873 case SEEK_SET: /* Go from beginning of source. */ 9873 case SEEK_SET: /* Go from beginning of source. */
9874 idx = off; 9874 idx = off;
9875 break; 9875 break;
9876 9876
9877 case SEEK_END: /* Go from end of source. */ 9877 case SEEK_END: /* Go from end of source. */
9878 idx = src->len + off; 9878 idx = src->len + off;
9879 break; 9879 break;
9880 9880
9881 case SEEK_CUR: /* Go from current position. */ 9881 case SEEK_CUR: /* Go from current position. */
9882 idx = src->index + off; 9882 idx = src->index + off;
9883 break; 9883 break;
9884 9884
9885 default: /* Invalid `whence'. */ 9885 default: /* Invalid `whence'. */
9886 return -1; 9886 return -1;
9887 } 9887 }
9888 9888
9889 if (idx > src->len || idx < 0) 9889 if (idx > src->len || idx < 0)
9890 return -1; 9890 return -1;
9891 9891
9892 src->index = idx; 9892 src->index = idx;
9893 return src->index; 9893 return src->index;
9894 } 9894 }
9895 9895
9896 9896
9937 const char *title, *format; 9937 const char *title, *format;
9938 va_list ap; 9938 va_list ap;
9939 { 9939 {
9940 char buf[512]; 9940 char buf[512];
9941 int len; 9941 int len;
9942 9942
9943 len = sprintf (buf, "TIFF error: %s ", title); 9943 len = sprintf (buf, "TIFF error: %s ", title);
9944 vsprintf (buf + len, format, ap); 9944 vsprintf (buf + len, format, ap);
9945 add_to_log (buf, Qnil, Qnil); 9945 add_to_log (buf, Qnil, Qnil);
9946 } 9946 }
9947 9947
9951 const char *title, *format; 9951 const char *title, *format;
9952 va_list ap; 9952 va_list ap;
9953 { 9953 {
9954 char buf[512]; 9954 char buf[512];
9955 int len; 9955 int len;
9956 9956
9957 len = sprintf (buf, "TIFF warning: %s ", title); 9957 len = sprintf (buf, "TIFF warning: %s ", title);
9958 vsprintf (buf + len, format, ap); 9958 vsprintf (buf + len, format, ap);
9959 add_to_log (buf, Qnil, Qnil); 9959 add_to_log (buf, Qnil, Qnil);
9960 } 9960 }
9961 9961
9994 { 9994 {
9995 image_error ("Cannot find image file `%s'", file, Qnil); 9995 image_error ("Cannot find image file `%s'", file, Qnil);
9996 UNGCPRO; 9996 UNGCPRO;
9997 return 0; 9997 return 0;
9998 } 9998 }
9999 9999
10000 /* Try to open the image file. */ 10000 /* Try to open the image file. */
10001 tiff = TIFFOpen (SDATA (file), "r"); 10001 tiff = TIFFOpen (SDATA (file), "r");
10002 if (tiff == NULL) 10002 if (tiff == NULL)
10003 { 10003 {
10004 image_error ("Cannot open `%s'", file, Qnil); 10004 image_error ("Cannot open `%s'", file, Qnil);
10033 /* Get width and height of the image, and allocate a raster buffer 10033 /* Get width and height of the image, and allocate a raster buffer
10034 of width x height 32-bit values. */ 10034 of width x height 32-bit values. */
10035 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); 10035 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
10036 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); 10036 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
10037 buf = (uint32 *) xmalloc (width * height * sizeof *buf); 10037 buf = (uint32 *) xmalloc (width * height * sizeof *buf);
10038 10038
10039 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); 10039 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
10040 TIFFClose (tiff); 10040 TIFFClose (tiff);
10041 if (!rc) 10041 if (!rc)
10042 { 10042 {
10043 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); 10043 image_error ("Error reading TIFF image `%s'", img->spec, Qnil);
10059 10059
10060 /* Process the pixel raster. Origin is in the lower-left corner. */ 10060 /* Process the pixel raster. Origin is in the lower-left corner. */
10061 for (y = 0; y < height; ++y) 10061 for (y = 0; y < height; ++y)
10062 { 10062 {
10063 uint32 *row = buf + y * width; 10063 uint32 *row = buf + y * width;
10064 10064
10065 for (x = 0; x < width; ++x) 10065 for (x = 0; x < width; ++x)
10066 { 10066 {
10067 uint32 abgr = row[x]; 10067 uint32 abgr = row[x];
10068 int r = TIFFGetR (abgr) << 8; 10068 int r = TIFFGetR (abgr) << 8;
10069 int g = TIFFGetG (abgr) << 8; 10069 int g = TIFFGetG (abgr) << 8;
10070 int b = TIFFGetB (abgr) << 8; 10070 int b = TIFFGetB (abgr) << 8;
10071 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); 10071 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
10072 } 10072 }
10073 } 10073 }
10074 10074
10075 /* Remember the colors allocated for the image. Free the color table. */ 10075 /* Remember the colors allocated for the image. Free the color table. */
10076 img->colors = colors_in_color_table (&img->ncolors); 10076 img->colors = colors_in_color_table (&img->ncolors);
10077 free_color_table (); 10077 free_color_table ();
10078 10078
10079 img->width = width; 10079 img->width = width;
10080 img->height = height; 10080 img->height = height;
10081 10081
10082 /* Maybe fill in the background field while we have ximg handy. */ 10082 /* Maybe fill in the background field while we have ximg handy. */
10083 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 10083 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
10165 gif_image_p (object) 10165 gif_image_p (object)
10166 Lisp_Object object; 10166 Lisp_Object object;
10167 { 10167 {
10168 struct image_keyword fmt[GIF_LAST]; 10168 struct image_keyword fmt[GIF_LAST];
10169 bcopy (gif_format, fmt, sizeof fmt); 10169 bcopy (gif_format, fmt, sizeof fmt);
10170 10170
10171 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)) 10171 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif))
10172 return 0; 10172 return 0;
10173 10173
10174 /* Must specify either the :data or :file keyword. */ 10174 /* Must specify either the :data or :file keyword. */
10175 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; 10175 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
10176 } 10176 }
10177 10177
10178 10178
10243 { 10243 {
10244 image_error ("Cannot find image file `%s'", specified_file, Qnil); 10244 image_error ("Cannot find image file `%s'", specified_file, Qnil);
10245 UNGCPRO; 10245 UNGCPRO;
10246 return 0; 10246 return 0;
10247 } 10247 }
10248 10248
10249 /* Open the GIF file. */ 10249 /* Open the GIF file. */
10250 gif = DGifOpenFileName (SDATA (file)); 10250 gif = DGifOpenFileName (SDATA (file));
10251 if (gif == NULL) 10251 if (gif == NULL)
10252 { 10252 {
10253 image_error ("Cannot open `%s'", file, Qnil); 10253 image_error ("Cannot open `%s'", file, Qnil);
10301 { 10301 {
10302 DGifCloseFile (gif); 10302 DGifCloseFile (gif);
10303 UNGCPRO; 10303 UNGCPRO;
10304 return 0; 10304 return 0;
10305 } 10305 }
10306 10306
10307 /* Allocate colors. */ 10307 /* Allocate colors. */
10308 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; 10308 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
10309 if (!gif_color_map) 10309 if (!gif_color_map)
10310 gif_color_map = gif->SColorMap; 10310 gif_color_map = gif->SColorMap;
10311 init_color_table (); 10311 init_color_table ();
10312 bzero (pixel_colors, sizeof pixel_colors); 10312 bzero (pixel_colors, sizeof pixel_colors);
10313 10313
10314 for (i = 0; i < gif_color_map->ColorCount; ++i) 10314 for (i = 0; i < gif_color_map->ColorCount; ++i)
10315 { 10315 {
10316 int r = gif_color_map->Colors[i].Red << 8; 10316 int r = gif_color_map->Colors[i].Red << 8;
10317 int g = gif_color_map->Colors[i].Green << 8; 10317 int g = gif_color_map->Colors[i].Green << 8;
10318 int b = gif_color_map->Colors[i].Blue << 8; 10318 int b = gif_color_map->Colors[i].Blue << 8;
10321 10321
10322 img->colors = colors_in_color_table (&img->ncolors); 10322 img->colors = colors_in_color_table (&img->ncolors);
10323 free_color_table (); 10323 free_color_table ();
10324 10324
10325 /* Clear the part of the screen image that are not covered by 10325 /* Clear the part of the screen image that are not covered by
10326 the image from the GIF file. Full animated GIF support 10326 the image from the GIF file. Full animated GIF support
10327 requires more than can be done here (see the gif89 spec, 10327 requires more than can be done here (see the gif89 spec,
10328 disposal methods). Let's simply assume that the part 10328 disposal methods). Let's simply assume that the part
10329 not covered by a sub-image is in the frame's background color. */ 10329 not covered by a sub-image is in the frame's background color. */
10330 image_top = gif->SavedImages[ino].ImageDesc.Top; 10330 image_top = gif->SavedImages[ino].ImageDesc.Top;
10331 image_left = gif->SavedImages[ino].ImageDesc.Left; 10331 image_left = gif->SavedImages[ino].ImageDesc.Left;
10350 10350
10351 /* Read the GIF image into the X image. We use a local variable 10351 /* Read the GIF image into the X image. We use a local variable
10352 `raster' here because RasterBits below is a char *, and invites 10352 `raster' here because RasterBits below is a char *, and invites
10353 problems with bytes >= 0x80. */ 10353 problems with bytes >= 0x80. */
10354 raster = (unsigned char *) gif->SavedImages[ino].RasterBits; 10354 raster = (unsigned char *) gif->SavedImages[ino].RasterBits;
10355 10355
10356 if (gif->SavedImages[ino].ImageDesc.Interlace) 10356 if (gif->SavedImages[ino].ImageDesc.Interlace)
10357 { 10357 {
10358 static int interlace_start[] = {0, 4, 2, 1}; 10358 static int interlace_start[] = {0, 4, 2, 1};
10359 static int interlace_increment[] = {8, 8, 4, 2}; 10359 static int interlace_increment[] = {8, 8, 4, 2};
10360 int pass; 10360 int pass;
10368 { 10368 {
10369 row = interlace_start[++pass]; 10369 row = interlace_start[++pass];
10370 while (row >= image_height) 10370 while (row >= image_height)
10371 row = interlace_start[++pass]; 10371 row = interlace_start[++pass];
10372 } 10372 }
10373 10373
10374 for (x = 0; x < image_width; x++) 10374 for (x = 0; x < image_width; x++)
10375 { 10375 {
10376 int i = raster[(y * image_width) + x]; 10376 int i = raster[(y * image_width) + x];
10377 XPutPixel (ximg, x + image_left, row + image_top, 10377 XPutPixel (ximg, x + image_left, row + image_top,
10378 pixel_colors[i]); 10378 pixel_colors[i]);
10379 } 10379 }
10380 10380
10381 row += interlace_increment[pass]; 10381 row += interlace_increment[pass];
10382 } 10382 }
10383 } 10383 }
10384 else 10384 else
10385 { 10385 {
10388 { 10388 {
10389 int i = raster[y * image_width + x]; 10389 int i = raster[y * image_width + x];
10390 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); 10390 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
10391 } 10391 }
10392 } 10392 }
10393 10393
10394 DGifCloseFile (gif); 10394 DGifCloseFile (gif);
10395 10395
10396 /* Maybe fill in the background field while we have ximg handy. */ 10396 /* Maybe fill in the background field while we have ximg handy. */
10397 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 10397 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
10398 IMAGE_BACKGROUND (img, f, ximg); 10398 IMAGE_BACKGROUND (img, f, ximg);
10399 10399
10400 /* Put the image into the pixmap, then free the X image and its buffer. */ 10400 /* 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); 10401 x_put_x_image (f, ximg, img->pixmap, width, height);
10402 x_destroy_x_image (ximg); 10402 x_destroy_x_image (ximg);
10403 10403
10404 UNGCPRO; 10404 UNGCPRO;
10405 return 1; 10405 return 1;
10406 } 10406 }
10407 10407
10408 #endif /* HAVE_GIF != 0 */ 10408 #endif /* HAVE_GIF != 0 */
10498 Lisp_Object object; 10498 Lisp_Object object;
10499 { 10499 {
10500 struct image_keyword fmt[GS_LAST]; 10500 struct image_keyword fmt[GS_LAST];
10501 Lisp_Object tem; 10501 Lisp_Object tem;
10502 int i; 10502 int i;
10503 10503
10504 bcopy (gs_format, fmt, sizeof fmt); 10504 bcopy (gs_format, fmt, sizeof fmt);
10505 10505
10506 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)) 10506 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript))
10507 return 0; 10507 return 0;
10508 10508
10509 /* Bounding box must be a list or vector containing 4 integers. */ 10509 /* Bounding box must be a list or vector containing 4 integers. */
10510 tem = fmt[GS_BOUNDING_BOX].value; 10510 tem = fmt[GS_BOUNDING_BOX].value;
10566 if (!img->pixmap) 10566 if (!img->pixmap)
10567 { 10567 {
10568 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil); 10568 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
10569 return 0; 10569 return 0;
10570 } 10570 }
10571 10571
10572 /* Call the loader to fill the pixmap. It returns a process object 10572 /* Call the loader to fill the pixmap. It returns a process object
10573 if successful. We do not record_unwind_protect here because 10573 if successful. We do not record_unwind_protect here because
10574 other places in redisplay like calling window scroll functions 10574 other places in redisplay like calling window scroll functions
10575 don't either. Let the Lisp loader use `unwind-protect' instead. */ 10575 don't either. Let the Lisp loader use `unwind-protect' instead. */
10576 GCPRO2 (window_and_pixmap_id, pixel_colors); 10576 GCPRO2 (window_and_pixmap_id, pixel_colors);
10577 10577
10578 sprintf (buffer, "%lu %lu", 10578 sprintf (buffer, "%lu %lu",
10579 (unsigned long) FRAME_X_WINDOW (f), 10579 (unsigned long) FRAME_X_WINDOW (f),
10580 (unsigned long) img->pixmap); 10580 (unsigned long) img->pixmap);
10581 window_and_pixmap_id = build_string (buffer); 10581 window_and_pixmap_id = build_string (buffer);
10582 10582
10583 sprintf (buffer, "%lu %lu", 10583 sprintf (buffer, "%lu %lu",
10584 FRAME_FOREGROUND_PIXEL (f), 10584 FRAME_FOREGROUND_PIXEL (f),
10585 FRAME_BACKGROUND_PIXEL (f)); 10585 FRAME_BACKGROUND_PIXEL (f));
10586 pixel_colors = build_string (buffer); 10586 pixel_colors = build_string (buffer);
10587 10587
10588 XSETFRAME (frame, f); 10588 XSETFRAME (frame, f);
10589 loader = image_spec_value (img->spec, QCloader, NULL); 10589 loader = image_spec_value (img->spec, QCloader, NULL);
10590 if (NILP (loader)) 10590 if (NILP (loader))
10591 loader = intern ("gs-load-image"); 10591 loader = intern ("gs-load-image");
10592 10592
10620 10620
10621 /* Should someone in between have cleared the image cache, for 10621 /* Should someone in between have cleared the image cache, for
10622 instance, give up. */ 10622 instance, give up. */
10623 if (i == c->used) 10623 if (i == c->used)
10624 return; 10624 return;
10625 10625
10626 /* Kill the GS process. We should have found PIXMAP in the image 10626 /* Kill the GS process. We should have found PIXMAP in the image
10627 cache and its image should contain a process object. */ 10627 cache and its image should contain a process object. */
10628 img = c->images[i]; 10628 img = c->images[i];
10629 xassert (PROCESSP (img->data.lisp_val)); 10629 xassert (PROCESSP (img->data.lisp_val));
10630 Fkill_process (img->data.lisp_val, Qnil); 10630 Fkill_process (img->data.lisp_val, Qnil);
10644 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap, 10644 ximg = XGetImage (FRAME_X_DISPLAY (f), img->pixmap,
10645 0, 0, img->width, img->height, ~0, ZPixmap); 10645 0, 0, img->width, img->height, ~0, ZPixmap);
10646 if (ximg) 10646 if (ximg)
10647 { 10647 {
10648 int x, y; 10648 int x, y;
10649 10649
10650 /* Initialize the color table. */ 10650 /* Initialize the color table. */
10651 init_color_table (); 10651 init_color_table ();
10652 10652
10653 /* For each pixel of the image, look its color up in the 10653 /* For each pixel of the image, look its color up in the
10654 color table. After having done so, the color table will 10654 color table. After having done so, the color table will
10655 contain an entry for each color used by the image. */ 10655 contain an entry for each color used by the image. */
10656 for (y = 0; y < img->height; ++y) 10656 for (y = 0; y < img->height; ++y)
10657 for (x = 0; x < img->width; ++x) 10657 for (x = 0; x < img->width; ++x)
10676 #endif 10676 #endif
10677 } 10677 }
10678 else 10678 else
10679 image_error ("Cannot get X image of `%s'; colors will not be freed", 10679 image_error ("Cannot get X image of `%s'; colors will not be freed",
10680 img->spec, Qnil); 10680 img->spec, Qnil);
10681 10681
10682 UNBLOCK_INPUT; 10682 UNBLOCK_INPUT;
10683 } 10683 }
10684 10684
10685 /* Now that we have the pixmap, compute mask and transform the 10685 /* Now that we have the pixmap, compute mask and transform the
10686 image if requested. */ 10686 image if requested. */
10779 tmp_data = NULL; 10779 tmp_data = NULL;
10780 10780
10781 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 10781 rc = XGetWindowProperty (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
10782 prop_atom, 0, bytes_remaining, 10782 prop_atom, 0, bytes_remaining,
10783 False, XA_STRING, 10783 False, XA_STRING,
10784 &actual_type, &actual_format, 10784 &actual_type, &actual_format,
10785 &actual_size, &bytes_remaining, 10785 &actual_size, &bytes_remaining,
10786 (unsigned char **) &tmp_data); 10786 (unsigned char **) &tmp_data);
10787 if (rc == Success && tmp_data) 10787 if (rc == Success && tmp_data)
10788 prop_value = make_string (tmp_data, size); 10788 prop_value = make_string (tmp_data, size);
10789 10789
10790 XFree (tmp_data); 10790 XFree (tmp_data);
10829 void 10829 void
10830 start_hourglass () 10830 start_hourglass ()
10831 { 10831 {
10832 EMACS_TIME delay; 10832 EMACS_TIME delay;
10833 int secs, usecs = 0; 10833 int secs, usecs = 0;
10834 10834
10835 cancel_hourglass (); 10835 cancel_hourglass ();
10836 10836
10837 if (INTEGERP (Vhourglass_delay) 10837 if (INTEGERP (Vhourglass_delay)
10838 && XINT (Vhourglass_delay) > 0) 10838 && XINT (Vhourglass_delay) > 0)
10839 secs = XFASTINT (Vhourglass_delay); 10839 secs = XFASTINT (Vhourglass_delay);
10845 secs = XFASTINT (tem); 10845 secs = XFASTINT (tem);
10846 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000; 10846 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
10847 } 10847 }
10848 else 10848 else
10849 secs = DEFAULT_HOURGLASS_DELAY; 10849 secs = DEFAULT_HOURGLASS_DELAY;
10850 10850
10851 EMACS_SET_SECS_USECS (delay, secs, usecs); 10851 EMACS_SET_SECS_USECS (delay, secs, usecs);
10852 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 10852 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
10853 show_hourglass, NULL); 10853 show_hourglass, NULL);
10854 } 10854 }
10855 10855
10863 if (hourglass_atimer) 10863 if (hourglass_atimer)
10864 { 10864 {
10865 cancel_atimer (hourglass_atimer); 10865 cancel_atimer (hourglass_atimer);
10866 hourglass_atimer = NULL; 10866 hourglass_atimer = NULL;
10867 } 10867 }
10868 10868
10869 if (hourglass_shown_p) 10869 if (hourglass_shown_p)
10870 hide_hourglass (); 10870 hide_hourglass ();
10871 } 10871 }
10872 10872
10873 10873
10889 hourglass_atimer = NULL; 10889 hourglass_atimer = NULL;
10890 10890
10891 if (!hourglass_shown_p) 10891 if (!hourglass_shown_p)
10892 { 10892 {
10893 Lisp_Object rest, frame; 10893 Lisp_Object rest, frame;
10894 10894
10895 BLOCK_INPUT; 10895 BLOCK_INPUT;
10896 10896
10897 FOR_EACH_FRAME (rest, frame) 10897 FOR_EACH_FRAME (rest, frame)
10898 { 10898 {
10899 struct frame *f = XFRAME (frame); 10899 struct frame *f = XFRAME (frame);
10900 10900
10901 if (FRAME_LIVE_P (f) && FRAME_X_P (f) && FRAME_X_DISPLAY (f)) 10901 if (FRAME_LIVE_P (f) && FRAME_X_P (f) && FRAME_X_DISPLAY (f))
10902 { 10902 {
10903 Display *dpy = FRAME_X_DISPLAY (f); 10903 Display *dpy = FRAME_X_DISPLAY (f);
10904 10904
10905 #ifdef USE_X_TOOLKIT 10905 #ifdef USE_X_TOOLKIT
10906 if (f->output_data.x->widget) 10906 if (f->output_data.x->widget)
10907 #else 10907 #else
10908 if (FRAME_OUTER_WINDOW (f)) 10908 if (FRAME_OUTER_WINDOW (f))
10909 #endif 10909 #endif
10910 { 10910 {
10911 f->output_data.x->hourglass_p = 1; 10911 f->output_data.x->hourglass_p = 1;
10912 10912
10913 if (!f->output_data.x->hourglass_window) 10913 if (!f->output_data.x->hourglass_window)
10914 { 10914 {
10915 unsigned long mask = CWCursor; 10915 unsigned long mask = CWCursor;
10916 XSetWindowAttributes attrs; 10916 XSetWindowAttributes attrs;
10917 10917
10918 attrs.cursor = f->output_data.x->hourglass_cursor; 10918 attrs.cursor = f->output_data.x->hourglass_cursor;
10919 10919
10920 f->output_data.x->hourglass_window 10920 f->output_data.x->hourglass_window
10921 = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f), 10921 = XCreateWindow (dpy, FRAME_OUTER_WINDOW (f),
10922 0, 0, 32000, 32000, 0, 0, 10922 0, 0, 32000, 32000, 0, 0,
10923 InputOnly, 10923 InputOnly,
10924 CopyFromParent, 10924 CopyFromParent,
10925 mask, &attrs); 10925 mask, &attrs);
10926 } 10926 }
10927 10927
10928 XMapRaised (dpy, f->output_data.x->hourglass_window); 10928 XMapRaised (dpy, f->output_data.x->hourglass_window);
10929 XFlush (dpy); 10929 XFlush (dpy);
10930 } 10930 }
10931 } 10931 }
10932 } 10932 }
10949 10949
10950 BLOCK_INPUT; 10950 BLOCK_INPUT;
10951 FOR_EACH_FRAME (rest, frame) 10951 FOR_EACH_FRAME (rest, frame)
10952 { 10952 {
10953 struct frame *f = XFRAME (frame); 10953 struct frame *f = XFRAME (frame);
10954 10954
10955 if (FRAME_X_P (f) 10955 if (FRAME_X_P (f)
10956 /* Watch out for newly created frames. */ 10956 /* Watch out for newly created frames. */
10957 && f->output_data.x->hourglass_window) 10957 && f->output_data.x->hourglass_window)
10958 { 10958 {
10959 XUnmapWindow (FRAME_X_DISPLAY (f), 10959 XUnmapWindow (FRAME_X_DISPLAY (f),
10978 10978
10979 static Lisp_Object x_create_tip_frame P_ ((struct x_display_info *, 10979 static Lisp_Object x_create_tip_frame P_ ((struct x_display_info *,
10980 Lisp_Object, Lisp_Object)); 10980 Lisp_Object, Lisp_Object));
10981 static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object, 10981 static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
10982 Lisp_Object, int, int, int *, int *)); 10982 Lisp_Object, int, int, int *, int *));
10983 10983
10984 /* The frame of a currently visible tooltip. */ 10984 /* The frame of a currently visible tooltip. */
10985 10985
10986 Lisp_Object tip_frame; 10986 Lisp_Object tip_frame;
10987 10987
10988 /* If non-nil, a timer started that hides the last tooltip when it 10988 /* If non-nil, a timer started that hides the last tooltip when it
11011 if (EQ (deleted, Qt)) 11011 if (EQ (deleted, Qt))
11012 { 11012 {
11013 tip_window = None; 11013 tip_window = None;
11014 tip_frame = Qnil; 11014 tip_frame = Qnil;
11015 } 11015 }
11016 11016
11017 return deleted; 11017 return deleted;
11018 } 11018 }
11019 11019
11020 11020
11021 /* Create a frame for a tooltip on the display described by DPYINFO. 11021 /* Create a frame for a tooltip on the display described by DPYINFO.
11075 set_buffer_internal_1 (XBUFFER (buffer)); 11075 set_buffer_internal_1 (XBUFFER (buffer));
11076 current_buffer->truncate_lines = Qnil; 11076 current_buffer->truncate_lines = Qnil;
11077 Ferase_buffer (); 11077 Ferase_buffer ();
11078 Finsert (1, &text); 11078 Finsert (1, &text);
11079 set_buffer_internal_1 (old_buffer); 11079 set_buffer_internal_1 (old_buffer);
11080 11080
11081 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 11081 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
11082 record_unwind_protect (unwind_create_tip_frame, frame); 11082 record_unwind_protect (unwind_create_tip_frame, frame);
11083 11083
11084 /* By setting the output method, we're essentially saying that 11084 /* By setting the output method, we're essentially saying that
11085 the frame is live, as per FRAME_LIVE_P. If we get a signal 11085 the frame is live, as per FRAME_LIVE_P. If we get a signal
11111 /* These colors will be set anyway later, but it's important 11111 /* These colors will be set anyway later, but it's important
11112 to get the color reference counts right, so initialize them! */ 11112 to get the color reference counts right, so initialize them! */
11113 { 11113 {
11114 Lisp_Object black; 11114 Lisp_Object black;
11115 struct gcpro gcpro1; 11115 struct gcpro gcpro1;
11116 11116
11117 black = build_string ("black"); 11117 black = build_string ("black");
11118 GCPRO1 (black); 11118 GCPRO1 (black);
11119 f->output_data.x->foreground_pixel 11119 f->output_data.x->foreground_pixel
11120 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f)); 11120 = x_decode_color (f, black, BLACK_PIX_DEFAULT (f));
11121 f->output_data.x->background_pixel 11121 f->output_data.x->background_pixel
11161 if (STRINGP (tem)) 11161 if (STRINGP (tem))
11162 font = x_new_fontset (f, SDATA (tem)); 11162 font = x_new_fontset (f, SDATA (tem));
11163 else 11163 else
11164 font = x_new_font (f, SDATA (font)); 11164 font = x_new_font (f, SDATA (font));
11165 } 11165 }
11166 11166
11167 /* Try out a font which we hope has bold and italic variations. */ 11167 /* Try out a font which we hope has bold and italic variations. */
11168 if (!STRINGP (font)) 11168 if (!STRINGP (font))
11169 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); 11169 font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");
11170 if (!STRINGP (font)) 11170 if (!STRINGP (font))
11171 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); 11171 font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");
11186 "font", "Font", RES_TYPE_STRING); 11186 "font", "Font", RES_TYPE_STRING);
11187 } 11187 }
11188 11188
11189 x_default_parameter (f, parms, Qborder_width, make_number (2), 11189 x_default_parameter (f, parms, Qborder_width, make_number (2),
11190 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 11190 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
11191 11191
11192 /* This defaults to 2 in order to match xterm. We recognize either 11192 /* This defaults to 2 in order to match xterm. We recognize either
11193 internalBorderWidth or internalBorder (which is what xterm calls 11193 internalBorderWidth or internalBorder (which is what xterm calls
11194 it). */ 11194 it). */
11195 if (NILP (Fassq (Qinternal_border_width, parms))) 11195 if (NILP (Fassq (Qinternal_border_width, parms)))
11196 { 11196 {
11224 which calls change_frame_size, which calls Fset_window_buffer, 11224 which calls change_frame_size, which calls Fset_window_buffer,
11225 which runs hooks, which call Fvertical_motion. At the end, we 11225 which runs hooks, which call Fvertical_motion. At the end, we
11226 end up in init_iterator with a null face cache, which should not 11226 end up in init_iterator with a null face cache, which should not
11227 happen. */ 11227 happen. */
11228 init_frame_faces (f); 11228 init_frame_faces (f);
11229 11229
11230 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window; 11230 f->output_data.x->parent_desc = FRAME_X_DISPLAY_INFO (f)->root_window;
11231 window_prompting = x_figure_window_size (f, parms); 11231 window_prompting = x_figure_window_size (f, parms);
11232 11232
11233 if (window_prompting & XNegative) 11233 if (window_prompting & XNegative)
11234 { 11234 {
11247 11247
11248 f->output_data.x->size_hint_flags = window_prompting; 11248 f->output_data.x->size_hint_flags = window_prompting;
11249 { 11249 {
11250 XSetWindowAttributes attrs; 11250 XSetWindowAttributes attrs;
11251 unsigned long mask; 11251 unsigned long mask;
11252 11252
11253 BLOCK_INPUT; 11253 BLOCK_INPUT;
11254 mask = CWBackPixel | CWOverrideRedirect | CWEventMask; 11254 mask = CWBackPixel | CWOverrideRedirect | CWEventMask;
11255 if (DoesSaveUnders (dpyinfo->screen)) 11255 if (DoesSaveUnders (dpyinfo->screen))
11256 mask |= CWSaveUnder; 11256 mask |= CWSaveUnder;
11257 11257
11258 /* Window managers look at the override-redirect flag to determine 11258 /* Window managers look at the override-redirect flag to determine
11259 whether or net to give windows a decoration (Xlib spec, chapter 11259 whether or net to give windows a decoration (Xlib spec, chapter
11260 3.2.8). */ 11260 3.2.8). */
11261 attrs.override_redirect = True; 11261 attrs.override_redirect = True;
11262 attrs.save_under = True; 11262 attrs.save_under = True;
11291 width = f->width; 11291 width = f->width;
11292 height = f->height; 11292 height = f->height;
11293 f->height = 0; 11293 f->height = 0;
11294 SET_FRAME_WIDTH (f, 0); 11294 SET_FRAME_WIDTH (f, 0);
11295 change_frame_size (f, height, width, 1, 0, 0); 11295 change_frame_size (f, height, width, 1, 0, 0);
11296 11296
11297 /* Add `tooltip' frame parameter's default value. */ 11297 /* Add `tooltip' frame parameter's default value. */
11298 if (NILP (Fframe_parameter (frame, intern ("tooltip")))) 11298 if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
11299 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), 11299 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
11300 Qnil)); 11300 Qnil));
11301 11301
11302 /* Set up faces after all frame parameters are known. This call 11302 /* Set up faces after all frame parameters are known. This call
11303 also merges in face attributes specified for new frames. 11303 also merges in face attributes specified for new frames.
11304 11304
11305 Frame parameters may be changed if .Xdefaults contains 11305 Frame parameters may be changed if .Xdefaults contains
11306 specifications for the default font. For example, if there is an 11306 specifications for the default font. For example, if there is an
11311 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color); 11311 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
11312 11312
11313 /* Set tip_frame here, so that */ 11313 /* Set tip_frame here, so that */
11314 tip_frame = frame; 11314 tip_frame = frame;
11315 call1 (Qface_set_after_frame_default, frame); 11315 call1 (Qface_set_after_frame_default, frame);
11316 11316
11317 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color))) 11317 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
11318 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg), 11318 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
11319 Qnil)); 11319 Qnil));
11320 } 11320 }
11321 11321
11322 f->no_split = 1; 11322 f->no_split = 1;
11323 11323
11324 UNGCPRO; 11324 UNGCPRO;
11325 11325
11326 /* It is now ok to make the frame official even if we get an error 11326 /* It is now ok to make the frame official even if we get an error
11359 { 11359 {
11360 Lisp_Object left, top; 11360 Lisp_Object left, top;
11361 int win_x, win_y; 11361 int win_x, win_y;
11362 Window root, child; 11362 Window root, child;
11363 unsigned pmask; 11363 unsigned pmask;
11364 11364
11365 /* User-specified position? */ 11365 /* User-specified position? */
11366 left = Fcdr (Fassq (Qleft, parms)); 11366 left = Fcdr (Fassq (Qleft, parms));
11367 top = Fcdr (Fassq (Qtop, parms)); 11367 top = Fcdr (Fassq (Qtop, parms));
11368 11368
11369 /* Move the tooltip window where the mouse pointer is. Resize and 11369 /* Move the tooltip window where the mouse pointer is. Resize and
11370 show it. */ 11370 show it. */
11371 if (!INTEGERP (left) || !INTEGERP (top)) 11371 if (!INTEGERP (left) || !INTEGERP (top))
11372 { 11372 {
11373 BLOCK_INPUT; 11373 BLOCK_INPUT;
11432 struct text_pos pos; 11432 struct text_pos pos;
11433 int i, width, height; 11433 int i, width, height;
11434 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 11434 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
11435 int old_windows_or_buffers_changed = windows_or_buffers_changed; 11435 int old_windows_or_buffers_changed = windows_or_buffers_changed;
11436 int count = SPECPDL_INDEX (); 11436 int count = SPECPDL_INDEX ();
11437 11437
11438 specbind (Qinhibit_redisplay, Qt); 11438 specbind (Qinhibit_redisplay, Qt);
11439 11439
11440 GCPRO4 (string, parms, frame, timeout); 11440 GCPRO4 (string, parms, frame, timeout);
11441 11441
11442 CHECK_STRING (string); 11442 CHECK_STRING (string);
11443 f = check_x_frame (frame); 11443 f = check_x_frame (frame);
11444 if (NILP (timeout)) 11444 if (NILP (timeout))
11445 timeout = make_number (5); 11445 timeout = make_number (5);
11446 else 11446 else
11447 CHECK_NATNUM (timeout); 11447 CHECK_NATNUM (timeout);
11448 11448
11449 if (NILP (dx)) 11449 if (NILP (dx))
11450 dx = make_number (5); 11450 dx = make_number (5);
11451 else 11451 else
11452 CHECK_NUMBER (dx); 11452 CHECK_NUMBER (dx);
11453 11453
11454 if (NILP (dy)) 11454 if (NILP (dy))
11455 dy = make_number (-10); 11455 dy = make_number (-10);
11456 else 11456 else
11457 CHECK_NUMBER (dy); 11457 CHECK_NUMBER (dy);
11458 11458
11468 if (EQ (frame, last_frame) 11468 if (EQ (frame, last_frame)
11469 && !NILP (Fequal (last_string, string)) 11469 && !NILP (Fequal (last_string, string))
11470 && !NILP (Fequal (last_parms, parms))) 11470 && !NILP (Fequal (last_parms, parms)))
11471 { 11471 {
11472 struct frame *f = XFRAME (tip_frame); 11472 struct frame *f = XFRAME (tip_frame);
11473 11473
11474 /* Only DX and DY have changed. */ 11474 /* Only DX and DY have changed. */
11475 if (!NILP (tip_timer)) 11475 if (!NILP (tip_timer))
11476 { 11476 {
11477 Lisp_Object timer = tip_timer; 11477 Lisp_Object timer = tip_timer;
11478 tip_timer = Qnil; 11478 tip_timer = Qnil;
11515 f = XFRAME (frame); 11515 f = XFRAME (frame);
11516 11516
11517 /* Set up the frame's root window. */ 11517 /* Set up the frame's root window. */
11518 w = XWINDOW (FRAME_ROOT_WINDOW (f)); 11518 w = XWINDOW (FRAME_ROOT_WINDOW (f));
11519 w->left = w->top = make_number (0); 11519 w->left = w->top = make_number (0);
11520 11520
11521 if (CONSP (Vx_max_tooltip_size) 11521 if (CONSP (Vx_max_tooltip_size)
11522 && INTEGERP (XCAR (Vx_max_tooltip_size)) 11522 && INTEGERP (XCAR (Vx_max_tooltip_size))
11523 && XINT (XCAR (Vx_max_tooltip_size)) > 0 11523 && XINT (XCAR (Vx_max_tooltip_size)) > 0
11524 && INTEGERP (XCDR (Vx_max_tooltip_size)) 11524 && INTEGERP (XCDR (Vx_max_tooltip_size))
11525 && XINT (XCDR (Vx_max_tooltip_size)) > 0) 11525 && XINT (XCDR (Vx_max_tooltip_size)) > 0)
11530 else 11530 else
11531 { 11531 {
11532 w->width = make_number (80); 11532 w->width = make_number (80);
11533 w->height = make_number (40); 11533 w->height = make_number (40);
11534 } 11534 }
11535 11535
11536 f->window_width = XINT (w->width); 11536 f->window_width = XINT (w->width);
11537 adjust_glyphs (f); 11537 adjust_glyphs (f);
11538 w->pseudo_window_p = 1; 11538 w->pseudo_window_p = 1;
11539 11539
11540 /* Display the tooltip text in a temporary buffer. */ 11540 /* Display the tooltip text in a temporary buffer. */
11568 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1]; 11568 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
11569 row_width = row->pixel_width - last->pixel_width; 11569 row_width = row->pixel_width - last->pixel_width;
11570 } 11570 }
11571 else 11571 else
11572 row_width = row->pixel_width; 11572 row_width = row->pixel_width;
11573 11573
11574 height += row->height; 11574 height += row->height;
11575 width = max (width, row_width); 11575 width = max (width, row_width);
11576 } 11576 }
11577 11577
11578 /* Add the frame's internal border to the width and height the X 11578 /* Add the frame's internal border to the width and height the X
11587 BLOCK_INPUT; 11587 BLOCK_INPUT;
11588 XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 11588 XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
11589 root_x, root_y, width, height); 11589 root_x, root_y, width, height);
11590 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); 11590 XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f));
11591 UNBLOCK_INPUT; 11591 UNBLOCK_INPUT;
11592 11592
11593 /* Draw into the window. */ 11593 /* Draw into the window. */
11594 w->must_be_updated_p = 1; 11594 w->must_be_updated_p = 1;
11595 update_single_window (w, 1); 11595 update_single_window (w, 1);
11596 11596
11597 /* Restore original current buffer. */ 11597 /* Restore original current buffer. */
11618 struct gcpro gcpro1, gcpro2; 11618 struct gcpro gcpro1, gcpro2;
11619 11619
11620 /* Return quickly if nothing to do. */ 11620 /* Return quickly if nothing to do. */
11621 if (NILP (tip_timer) && NILP (tip_frame)) 11621 if (NILP (tip_timer) && NILP (tip_frame))
11622 return Qnil; 11622 return Qnil;
11623 11623
11624 frame = tip_frame; 11624 frame = tip_frame;
11625 timer = tip_timer; 11625 timer = tip_timer;
11626 GCPRO2 (frame, timer); 11626 GCPRO2 (frame, timer);
11627 tip_frame = tip_timer = deleted = Qnil; 11627 tip_frame = tip_timer = deleted = Qnil;
11628 11628
11629 count = SPECPDL_INDEX (); 11629 count = SPECPDL_INDEX ();
11630 specbind (Qinhibit_redisplay, Qt); 11630 specbind (Qinhibit_redisplay, Qt);
11631 specbind (Qinhibit_quit, Qt); 11631 specbind (Qinhibit_quit, Qt);
11632 11632
11633 if (!NILP (timer)) 11633 if (!NILP (timer))
11634 call1 (Qcancel_timer, timer); 11634 call1 (Qcancel_timer, timer);
11635 11635
11636 if (FRAMEP (frame)) 11636 if (FRAMEP (frame))
11637 { 11637 {
11730 /* Create the dialog with PROMPT as title, using DIR as initial 11730 /* Create the dialog with PROMPT as title, using DIR as initial
11731 directory and using "*" as pattern. */ 11731 directory and using "*" as pattern. */
11732 dir = Fexpand_file_name (dir, Qnil); 11732 dir = Fexpand_file_name (dir, Qnil);
11733 dir_xmstring = XmStringCreateLocalized (SDATA (dir)); 11733 dir_xmstring = XmStringCreateLocalized (SDATA (dir));
11734 pattern_xmstring = XmStringCreateLocalized ("*"); 11734 pattern_xmstring = XmStringCreateLocalized ("*");
11735 11735
11736 XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac; 11736 XtSetArg (al[ac], XmNtitle, SDATA (prompt)); ++ac;
11737 XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac; 11737 XtSetArg (al[ac], XmNdirectory, dir_xmstring); ++ac;
11738 XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac; 11738 XtSetArg (al[ac], XmNpattern, pattern_xmstring); ++ac;
11739 XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac; 11739 XtSetArg (al[ac], XmNresizePolicy, XmRESIZE_GROW); ++ac;
11740 XtSetArg (al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ++ac; 11740 XtSetArg (al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ++ac;
11753 11753
11754 /* Disable the help button since we can't display help. */ 11754 /* Disable the help button since we can't display help. */
11755 help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON); 11755 help = XmFileSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON);
11756 XtSetSensitive (help, False); 11756 XtSetSensitive (help, False);
11757 11757
11758 /* Mark OK button as default. */ 11758 /* Mark OK button as default. */
11759 XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON), 11759 XtVaSetValues (XmFileSelectionBoxGetChild (dialog, XmDIALOG_OK_BUTTON),
11760 XmNshowAsDefault, True, NULL); 11760 XmNshowAsDefault, True, NULL);
11761 11761
11762 /* If MUSTMATCH is non-nil, disable the file entry field of the 11762 /* If MUSTMATCH is non-nil, disable the file entry field of the
11763 dialog, so that the user must select a file from the files list 11763 dialog, so that the user must select a file from the files list
11813 /* Get the result. */ 11813 /* Get the result. */
11814 if (result == XmCR_OK) 11814 if (result == XmCR_OK)
11815 { 11815 {
11816 XmString text; 11816 XmString text;
11817 String data; 11817 String data;
11818 11818
11819 XtVaGetValues (dialog, XmNtextString, &text, NULL); 11819 XtVaGetValues (dialog, XmNtextString, &text, NULL);
11820 XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data); 11820 XmStringGetLtoR (text, XmFONTLIST_DEFAULT_TAG, &data);
11821 XmStringFree (text); 11821 XmStringFree (text);
11822 file = build_string (data); 11822 file = build_string (data);
11823 XtFree (data); 11823 XtFree (data);
11832 UNGCPRO; 11832 UNGCPRO;
11833 11833
11834 /* Make "Cancel" equivalent to C-g. */ 11834 /* Make "Cancel" equivalent to C-g. */
11835 if (NILP (file)) 11835 if (NILP (file))
11836 Fsignal (Qquit, Qnil); 11836 Fsignal (Qquit, Qnil);
11837 11837
11838 return unbind_to (count, file); 11838 return unbind_to (count, file);
11839 } 11839 }
11840 11840
11841 #endif /* USE_MOTIF */ 11841 #endif /* USE_MOTIF */
11842 11842
11856 Lisp_Object file = Qnil; 11856 Lisp_Object file = Qnil;
11857 int count = specpdl_ptr - specpdl; 11857 int count = specpdl_ptr - specpdl;
11858 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; 11858 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
11859 char *cdef_file; 11859 char *cdef_file;
11860 char *cprompt; 11860 char *cprompt;
11861 11861
11862 GCPRO5 (prompt, dir, default_filename, mustmatch, file); 11862 GCPRO5 (prompt, dir, default_filename, mustmatch, file);
11863 CHECK_STRING (prompt); 11863 CHECK_STRING (prompt);
11864 CHECK_STRING (dir); 11864 CHECK_STRING (dir);
11865 11865
11866 /* Prevent redisplay. */ 11866 /* Prevent redisplay. */
11872 cdef_file = SDATA (default_filename); 11872 cdef_file = SDATA (default_filename);
11873 else 11873 else
11874 cdef_file = SDATA (dir); 11874 cdef_file = SDATA (dir);
11875 11875
11876 fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch)); 11876 fn = xg_get_file_name (f, SDATA (prompt), cdef_file, ! NILP (mustmatch));
11877 11877
11878 if (fn) 11878 if (fn)
11879 { 11879 {
11880 file = build_string (fn); 11880 file = build_string (fn);
11881 xfree (fn); 11881 xfree (fn);
11882 } 11882 }
11885 UNGCPRO; 11885 UNGCPRO;
11886 11886
11887 /* Make "Cancel" equivalent to C-g. */ 11887 /* Make "Cancel" equivalent to C-g. */
11888 if (NILP (file)) 11888 if (NILP (file))
11889 Fsignal (Qquit, Qnil); 11889 Fsignal (Qquit, Qnil);
11890 11890
11891 return unbind_to (count, file); 11891 return unbind_to (count, file);
11892 } 11892 }
11893 11893
11894 #endif /* USE_GTK */ 11894 #endif /* USE_GTK */
11895 11895
11936 if (!XkbQueryExtension (dpy, &op, &event, &error, &major, &minor)) 11936 if (!XkbQueryExtension (dpy, &op, &event, &error, &major, &minor))
11937 { 11937 {
11938 UNBLOCK_INPUT; 11938 UNBLOCK_INPUT;
11939 return Qnil; 11939 return Qnil;
11940 } 11940 }
11941 11941
11942 have_keys = Qnil; 11942 have_keys = Qnil;
11943 kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd); 11943 kb = XkbGetMap (dpy, XkbAllMapComponentsMask, XkbUseCoreKbd);
11944 if (kb) 11944 if (kb)
11945 { 11945 {
11946 int delete_keycode = 0, backspace_keycode = 0, i; 11946 int delete_keycode = 0, backspace_keycode = 0, i;
11963 11963
11964 XkbFreeNames (kb, 0, True); 11964 XkbFreeNames (kb, 0, True);
11965 } 11965 }
11966 11966
11967 XkbFreeClientMap (kb, 0, True); 11967 XkbFreeClientMap (kb, 0, True);
11968 11968
11969 if (delete_keycode 11969 if (delete_keycode
11970 && backspace_keycode 11970 && backspace_keycode
11971 && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode 11971 && XKeysymToKeycode (dpy, XK_Delete) == delete_keycode
11972 && XKeysymToKeycode (dpy, XK_BackSpace) == backspace_keycode) 11972 && XKeysymToKeycode (dpy, XK_BackSpace) == backspace_keycode)
11973 have_keys = Qt; 11973 have_keys = Qt;
12093 staticpro (&QCmatrix); 12093 staticpro (&QCmatrix);
12094 QCcolor_adjustment = intern (":color-adjustment"); 12094 QCcolor_adjustment = intern (":color-adjustment");
12095 staticpro (&QCcolor_adjustment); 12095 staticpro (&QCcolor_adjustment);
12096 QCmask = intern (":mask"); 12096 QCmask = intern (":mask");
12097 staticpro (&QCmask); 12097 staticpro (&QCmask);
12098 12098
12099 Qface_set_after_frame_default = intern ("face-set-after-frame-default"); 12099 Qface_set_after_frame_default = intern ("face-set-after-frame-default");
12100 staticpro (&Qface_set_after_frame_default); 12100 staticpro (&Qface_set_after_frame_default);
12101 12101
12102 Fput (Qundefined_color, Qerror_conditions, 12102 Fput (Qundefined_color, Qerror_conditions,
12103 Fcons (Qundefined_color, Fcons (Qerror, Qnil))); 12103 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
12161 Vx_hourglass_pointer_shape = Qnil; 12161 Vx_hourglass_pointer_shape = Qnil;
12162 12162
12163 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, 12163 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
12164 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); 12164 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
12165 display_hourglass_p = 1; 12165 display_hourglass_p = 1;
12166 12166
12167 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, 12167 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
12168 doc: /* *Seconds to wait before displaying an hourglass pointer. 12168 doc: /* *Seconds to wait before displaying an hourglass pointer.
12169 Value must be an integer or float. */); 12169 Value must be an integer or float. */);
12170 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); 12170 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
12171 12171
12197 12197
12198 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size, 12198 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
12199 doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS). 12199 doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
12200 Text larger than this is clipped. */); 12200 Text larger than this is clipped. */);
12201 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40)); 12201 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
12202 12202
12203 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, 12203 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
12204 doc: /* Non-nil if no X window manager is in use. 12204 doc: /* Non-nil if no X window manager is in use.
12205 Emacs doesn't try to figure this out; this is always nil 12205 Emacs doesn't try to figure this out; this is always nil
12206 unless you set it to something else. */); 12206 unless you set it to something else. */);
12207 /* We don't have any way to find this out, so set it to nil 12207 /* We don't have any way to find this out, so set it to nil
12266 defsubr (&Sx_close_connection); 12266 defsubr (&Sx_close_connection);
12267 defsubr (&Sx_display_list); 12267 defsubr (&Sx_display_list);
12268 defsubr (&Sx_synchronize); 12268 defsubr (&Sx_synchronize);
12269 defsubr (&Sx_focus_frame); 12269 defsubr (&Sx_focus_frame);
12270 defsubr (&Sx_backspace_delete_keys_p); 12270 defsubr (&Sx_backspace_delete_keys_p);
12271 12271
12272 /* Setting callback functions for fontset handler. */ 12272 /* Setting callback functions for fontset handler. */
12273 get_font_info_func = x_get_font_info; 12273 get_font_info_func = x_get_font_info;
12274 12274
12275 #if 0 /* This function pointer doesn't seem to be used anywhere. 12275 #if 0 /* This function pointer doesn't seem to be used anywhere.
12276 And the pointer assigned has the wrong type, anyway. */ 12276 And the pointer assigned has the wrong type, anyway. */
12277 list_fonts_func = x_list_fonts; 12277 list_fonts_func = x_list_fonts;
12278 #endif 12278 #endif
12279 12279
12280 load_font_func = x_load_font; 12280 load_font_func = x_load_font;
12281 find_ccl_program_func = x_find_ccl_program; 12281 find_ccl_program_func = x_find_ccl_program;
12282 query_font_func = x_query_font; 12282 query_font_func = x_query_font;
12283 set_frame_fontset_func = x_set_font; 12283 set_frame_fontset_func = x_set_font;
12284 check_window_system_func = check_x; 12284 check_window_system_func = check_x;
12315 12315
12316 #if HAVE_XPM 12316 #if HAVE_XPM
12317 Qxpm = intern ("xpm"); 12317 Qxpm = intern ("xpm");
12318 staticpro (&Qxpm); 12318 staticpro (&Qxpm);
12319 #endif 12319 #endif
12320 12320
12321 #if HAVE_JPEG 12321 #if HAVE_JPEG
12322 Qjpeg = intern ("jpeg"); 12322 Qjpeg = intern ("jpeg");
12323 staticpro (&Qjpeg); 12323 staticpro (&Qjpeg);
12324 #endif 12324 #endif
12325 12325
12326 #if HAVE_TIFF 12326 #if HAVE_TIFF
12327 Qtiff = intern ("tiff"); 12327 Qtiff = intern ("tiff");
12328 staticpro (&Qtiff); 12328 staticpro (&Qtiff);
12329 #endif 12329 #endif
12330 12330
12331 #if HAVE_GIF 12331 #if HAVE_GIF
12332 Qgif = intern ("gif"); 12332 Qgif = intern ("gif");
12333 staticpro (&Qgif); 12333 staticpro (&Qgif);
12334 #endif 12334 #endif
12364 void 12364 void
12365 init_xfns () 12365 init_xfns ()
12366 { 12366 {
12367 image_types = NULL; 12367 image_types = NULL;
12368 Vimage_types = Qnil; 12368 Vimage_types = Qnil;
12369 12369
12370 define_image_type (&xbm_type); 12370 define_image_type (&xbm_type);
12371 define_image_type (&gs_type); 12371 define_image_type (&gs_type);
12372 define_image_type (&pbm_type); 12372 define_image_type (&pbm_type);
12373 12373
12374 #if HAVE_XPM 12374 #if HAVE_XPM
12375 define_image_type (&xpm_type); 12375 define_image_type (&xpm_type);
12376 #endif 12376 #endif
12377 12377
12378 #if HAVE_JPEG 12378 #if HAVE_JPEG
12379 define_image_type (&jpeg_type); 12379 define_image_type (&jpeg_type);
12380 #endif 12380 #endif
12381 12381
12382 #if HAVE_TIFF 12382 #if HAVE_TIFF
12383 define_image_type (&tiff_type); 12383 define_image_type (&tiff_type);
12384 #endif 12384 #endif
12385 12385
12386 #if HAVE_GIF 12386 #if HAVE_GIF
12387 define_image_type (&gif_type); 12387 define_image_type (&gif_type);
12388 #endif 12388 #endif
12389 12389
12390 #if HAVE_PNG 12390 #if HAVE_PNG
12391 define_image_type (&png_type); 12391 define_image_type (&png_type);
12392 #endif 12392 #endif
12393 } 12393 }
12394 12394