comparison src/w32fns.c @ 47942:080b4586492b

Fix typo in comment.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 18 Oct 2002 10:09:43 +0000
parents 755c4233cfba
children af143d9ed38e
comparison
equal deleted inserted replaced
47941:df5fb1f2c113 47942:080b4586492b
294 /* Window that is tracking the mouse. */ 294 /* Window that is tracking the mouse. */
295 static HWND track_mouse_window; 295 static HWND track_mouse_window;
296 FARPROC track_mouse_event_fn; 296 FARPROC track_mouse_event_fn;
297 297
298 /* W95 mousewheel handler */ 298 /* W95 mousewheel handler */
299 unsigned int msh_mousewheel = 0; 299 unsigned int msh_mousewheel = 0;
300 300
301 /* Timers */ 301 /* Timers */
302 #define MOUSE_BUTTON_ID 1 302 #define MOUSE_BUTTON_ID 1
303 #define MOUSE_MOVE_ID 2 303 #define MOUSE_MOVE_ID 2
304 #define MENU_FREE_ID 3 304 #define MENU_FREE_ID 3
344 error ("MS-Windows not in use or not initialized"); 344 error ("MS-Windows not in use or not initialized");
345 } 345 }
346 346
347 /* Nonzero if we can use mouse menus. 347 /* Nonzero if we can use mouse menus.
348 You should not call this unless HAVE_MENUS is defined. */ 348 You should not call this unless HAVE_MENUS is defined. */
349 349
350 int 350 int
351 have_menus_p () 351 have_menus_p ()
352 { 352 {
353 return w32_in_use; 353 return w32_in_use;
354 } 354 }
369 if (! FRAME_W32_P (f)) 369 if (! FRAME_W32_P (f))
370 error ("non-w32 frame used"); 370 error ("non-w32 frame used");
371 return f; 371 return f;
372 } 372 }
373 373
374 /* Let the user specify an display with a frame. 374 /* Let the user specify a display with a frame.
375 nil stands for the selected frame--or, if that is not a w32 frame, 375 nil stands for the selected frame--or, if that is not a w32 frame,
376 the first display on the list. */ 376 the first display on the list. */
377 377
378 static struct w32_display_info * 378 static struct w32_display_info *
379 check_x_display_info (frame) 379 check_x_display_info (frame)
380 Lisp_Object frame; 380 Lisp_Object frame;
381 { 381 {
382 if (NILP (frame)) 382 if (NILP (frame))
383 { 383 {
384 struct frame *sf = XFRAME (selected_frame); 384 struct frame *sf = XFRAME (selected_frame);
385 385
386 if (FRAME_W32_P (sf) && FRAME_LIVE_P (sf)) 386 if (FRAME_W32_P (sf) && FRAME_LIVE_P (sf))
387 return FRAME_W32_DISPLAY_INFO (sf); 387 return FRAME_W32_DISPLAY_INFO (sf);
388 else 388 else
389 return &one_w32_display_info; 389 return &one_w32_display_info;
390 } 390 }
588 hinst = LoadLibraryEx (filename, NULL, LOAD_LIBRARY_AS_DATAFILE); 588 hinst = LoadLibraryEx (filename, NULL, LOAD_LIBRARY_AS_DATAFILE);
589 589
590 if (hinst == NULL) 590 if (hinst == NULL)
591 return -1; 591 return -1;
592 592
593 593
594 result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), 594 result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
595 filename, &width, &height, &bitmap, &xhot, &yhot); 595 filename, &width, &height, &bitmap, &xhot, &yhot);
596 if (result != BitmapSuccess) 596 if (result != BitmapSuccess)
597 return -1; 597 return -1;
598 598
861 861
862 /* Process foreground_color and background_color before anything else. 862 /* Process foreground_color and background_color before anything else.
863 They are independent of other properties, but other properties (e.g., 863 They are independent of other properties, but other properties (e.g.,
864 cursor_color) are dependent upon them. */ 864 cursor_color) are dependent upon them. */
865 /* Process default font as well, since fringe widths depends on it. */ 865 /* Process default font as well, since fringe widths depends on it. */
866 for (p = 0; p < i; p++) 866 for (p = 0; p < i; p++)
867 { 867 {
868 Lisp_Object prop, val; 868 Lisp_Object prop, val;
869 869
870 prop = parms[p]; 870 prop = parms[p];
871 val = values[p]; 871 val = values[p];
880 fullscreen_is_being_set |= EQ (prop, Qfullscreen); 880 fullscreen_is_being_set |= EQ (prop, Qfullscreen);
881 881
882 if (NILP (Fequal (val, old_value))) 882 if (NILP (Fequal (val, old_value)))
883 { 883 {
884 store_frame_param (f, prop, val); 884 store_frame_param (f, prop, val);
885 885
886 param_index = Fget (prop, Qx_frame_parameter); 886 param_index = Fget (prop, Qx_frame_parameter);
887 if (NATNUMP (param_index) 887 if (NATNUMP (param_index)
888 && (XFASTINT (param_index) 888 && (XFASTINT (param_index)
889 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0]))) 889 < sizeof (x_frame_parms)/sizeof (x_frame_parms[0])))
890 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value); 890 (*x_frame_parms[XINT (param_index)].setter)(f, val, old_value);
976 Here we first get the width, height and position that applies to 976 Here we first get the width, height and position that applies to
977 fullscreen. We then move the frame to the appropriate 977 fullscreen. We then move the frame to the appropriate
978 position. Resize of the frame is taken care of in the code after 978 position. Resize of the frame is taken care of in the code after
979 this if-statement. */ 979 this if-statement. */
980 int new_left, new_top; 980 int new_left, new_top;
981 981
982 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left); 982 x_fullscreen_adjust (f, &width, &height, &new_top, &new_left);
983 x_fullscreen_move (f, new_top, new_left); 983 x_fullscreen_move (f, new_top, new_left);
984 } 984 }
985 985
986 /* Don't set these parameters unless they've been explicitly 986 /* Don't set these parameters unless they've been explicitly
1243 1243
1244 return cmap; 1244 return cmap;
1245 } 1245 }
1246 1246
1247 /* The default colors for the w32 color map */ 1247 /* The default colors for the w32 color map */
1248 typedef struct colormap_t 1248 typedef struct colormap_t
1249 { 1249 {
1250 char *name; 1250 char *name;
1251 COLORREF colorref; 1251 COLORREF colorref;
1252 } colormap_t; 1252 } colormap_t;
1253 1253
1254 colormap_t w32_color_map[] = 1254 colormap_t w32_color_map[] =
1255 { 1255 {
1256 {"snow" , PALETTERGB (255,250,250)}, 1256 {"snow" , PALETTERGB (255,250,250)},
1257 {"ghost white" , PALETTERGB (248,248,255)}, 1257 {"ghost white" , PALETTERGB (248,248,255)},
1258 {"GhostWhite" , PALETTERGB (248,248,255)}, 1258 {"GhostWhite" , PALETTERGB (248,248,255)},
1259 {"white smoke" , PALETTERGB (245,245,245)}, 1259 {"white smoke" , PALETTERGB (245,245,245)},
1500 () 1500 ()
1501 { 1501 {
1502 int i; 1502 int i;
1503 colormap_t *pc = w32_color_map; 1503 colormap_t *pc = w32_color_map;
1504 Lisp_Object cmap; 1504 Lisp_Object cmap;
1505 1505
1506 BLOCK_INPUT; 1506 BLOCK_INPUT;
1507 1507
1508 cmap = Qnil; 1508 cmap = Qnil;
1509 1509
1510 for (i = 0; i < sizeof (w32_color_map) / sizeof (w32_color_map[0]); 1510 for (i = 0; i < sizeof (w32_color_map) / sizeof (w32_color_map[0]);
1511 pc++, i++) 1511 pc++, i++)
1512 cmap = Fcons (Fcons (build_string (pc->name), 1512 cmap = Fcons (Fcons (build_string (pc->name),
1513 make_number (pc->colorref)), 1513 make_number (pc->colorref)),
1514 cmap); 1514 cmap);
1515 1515
1516 UNBLOCK_INPUT; 1516 UNBLOCK_INPUT;
1517 1517
1518 return (cmap); 1518 return (cmap);
1519 } 1519 }
1520 1520
1521 Lisp_Object 1521 Lisp_Object
1522 w32_to_x_color (rgb) 1522 w32_to_x_color (rgb)
1523 Lisp_Object rgb; 1523 Lisp_Object rgb;
1524 { 1524 {
1525 Lisp_Object color; 1525 Lisp_Object color;
1526 1526
1527 CHECK_NUMBER (rgb); 1527 CHECK_NUMBER (rgb);
1528 1528
1529 BLOCK_INPUT; 1529 BLOCK_INPUT;
1530 1530
1531 color = Frassq (rgb, Vw32_color_map); 1531 color = Frassq (rgb, Vw32_color_map);
1532 1532
1533 UNBLOCK_INPUT; 1533 UNBLOCK_INPUT;
1534 1534
1535 if (!NILP (color)) 1535 if (!NILP (color))
1536 return (Fcar (color)); 1536 return (Fcar (color));
1537 else 1537 else
1538 return Qnil; 1538 return Qnil;
1539 } 1539 }
1568 UNBLOCK_INPUT; 1568 UNBLOCK_INPUT;
1569 1569
1570 return ret; 1570 return ret;
1571 } 1571 }
1572 1572
1573 COLORREF 1573 COLORREF
1574 x_to_w32_color (colorname) 1574 x_to_w32_color (colorname)
1575 char * colorname; 1575 char * colorname;
1576 { 1576 {
1577 register Lisp_Object ret = Qnil; 1577 register Lisp_Object ret = Qnil;
1578 1578
1582 { 1582 {
1583 /* Could be an old-style RGB Device specification. */ 1583 /* Could be an old-style RGB Device specification. */
1584 char *color; 1584 char *color;
1585 int size; 1585 int size;
1586 color = colorname + 1; 1586 color = colorname + 1;
1587 1587
1588 size = strlen(color); 1588 size = strlen(color);
1589 if (size == 3 || size == 6 || size == 9 || size == 12) 1589 if (size == 3 || size == 6 || size == 9 || size == 12)
1590 { 1590 {
1591 UINT colorval; 1591 UINT colorval;
1592 int i, pos; 1592 int i, pos;
1593 pos = 0; 1593 pos = 0;
1594 size /= 3; 1594 size /= 3;
1595 colorval = 0; 1595 colorval = 0;
1596 1596
1597 for (i = 0; i < 3; i++) 1597 for (i = 0; i < 3; i++)
1598 { 1598 {
1599 char *end; 1599 char *end;
1600 char t; 1600 char t;
1601 unsigned long value; 1601 unsigned long value;
1647 color = colorname + 4; 1647 color = colorname + 4;
1648 for (i = 0; i < 3; i++) 1648 for (i = 0; i < 3; i++)
1649 { 1649 {
1650 char *end; 1650 char *end;
1651 unsigned long value; 1651 unsigned long value;
1652 1652
1653 /* The check for 'x' in the following conditional takes into 1653 /* The check for 'x' in the following conditional takes into
1654 account the fact that strtol allows a "0x" in front of 1654 account the fact that strtol allows a "0x" in front of
1655 our numbers, and we don't. */ 1655 our numbers, and we don't. */
1656 if (!isxdigit(color[0]) || color[1] == 'x') 1656 if (!isxdigit(color[0]) || color[1] == 'x')
1657 break; 1657 break;
1710 if (errno == ERANGE) 1710 if (errno == ERANGE)
1711 break; 1711 break;
1712 if (value < 0.0 || value > 1.0) 1712 if (value < 0.0 || value > 1.0)
1713 break; 1713 break;
1714 val = (UINT)(0x100 * value); 1714 val = (UINT)(0x100 * value);
1715 /* We used 0x100 instead of 0xFF to give an continuous 1715 /* We used 0x100 instead of 0xFF to give a continuous
1716 range between 0.0 and 1.0 inclusive. The next statement 1716 range between 0.0 and 1.0 inclusive. The next statement
1717 fixes the 1.0 case. */ 1717 fixes the 1.0 case. */
1718 if (val == 0x100) 1718 if (val == 0x100)
1719 val = 0xFF; 1719 val = 0xFF;
1720 colorval |= (val << pos); 1720 colorval |= (val << pos);
1734 /* I am not going to attempt to handle any of the CIE color schemes 1734 /* I am not going to attempt to handle any of the CIE color schemes
1735 or TekHVC, since I don't know the algorithms for conversion to 1735 or TekHVC, since I don't know the algorithms for conversion to
1736 RGB. */ 1736 RGB. */
1737 1737
1738 /* If we fail to lookup the color name in w32_color_map, then check the 1738 /* If we fail to lookup the color name in w32_color_map, then check the
1739 colorname to see if it can be crudely approximated: If the X color 1739 colorname to see if it can be crudely approximated: If the X color
1740 ends in a number (e.g., "darkseagreen2"), strip the number and 1740 ends in a number (e.g., "darkseagreen2"), strip the number and
1741 return the result of looking up the base color name. */ 1741 return the result of looking up the base color name. */
1742 ret = w32_color_map_lookup (colorname); 1742 ret = w32_color_map_lookup (colorname);
1743 if (NILP (ret)) 1743 if (NILP (ret))
1744 { 1744 {
1745 int len = strlen (colorname); 1745 int len = strlen (colorname);
1746 1746
1747 if (isdigit (colorname[len - 1])) 1747 if (isdigit (colorname[len - 1]))
1748 { 1748 {
1749 char *ptr, *approx = alloca (len + 1); 1749 char *ptr, *approx = alloca (len + 1);
1750 1750
1751 strcpy (approx, colorname); 1751 strcpy (approx, colorname);
1752 ptr = &approx[len - 1]; 1752 ptr = &approx[len - 1];
1753 while (ptr > approx && isdigit (*ptr)) 1753 while (ptr > approx && isdigit (*ptr))
1754 *ptr-- = '\0'; 1754 *ptr-- = '\0';
1755 1755
1756 ret = w32_color_map_lookup (approx); 1756 ret = w32_color_map_lookup (approx);
1757 } 1757 }
1758 } 1758 }
1759 1759
1760 UNBLOCK_INPUT; 1760 UNBLOCK_INPUT;
1761 return ret; 1761 return ret;
1762 } 1762 }
1763 1763
1764 1764
1909 register Lisp_Object tem; 1909 register Lisp_Object tem;
1910 COLORREF w32_color_ref; 1910 COLORREF w32_color_ref;
1911 1911
1912 tem = x_to_w32_color (color); 1912 tem = x_to_w32_color (color);
1913 1913
1914 if (!NILP (tem)) 1914 if (!NILP (tem))
1915 { 1915 {
1916 if (f) 1916 if (f)
1917 { 1917 {
1918 /* Apply gamma correction. */ 1918 /* Apply gamma correction. */
1919 w32_color_ref = XUINT (tem); 1919 w32_color_ref = XUINT (tem);
1926 { 1926 {
1927 struct w32_palette_entry * entry = 1927 struct w32_palette_entry * entry =
1928 one_w32_display_info.color_list; 1928 one_w32_display_info.color_list;
1929 struct w32_palette_entry ** prev = 1929 struct w32_palette_entry ** prev =
1930 &one_w32_display_info.color_list; 1930 &one_w32_display_info.color_list;
1931 1931
1932 /* check if color is already mapped */ 1932 /* check if color is already mapped */
1933 while (entry) 1933 while (entry)
1934 { 1934 {
1935 if (W32_COLOR (entry->entry) == XUINT (tem)) 1935 if (W32_COLOR (entry->entry) == XUINT (tem))
1936 break; 1936 break;
1962 color_def->green = GetGValue (w32_color_ref); 1962 color_def->green = GetGValue (w32_color_ref);
1963 color_def->blue = GetBValue (w32_color_ref); 1963 color_def->blue = GetBValue (w32_color_ref);
1964 1964
1965 return 1; 1965 return 1;
1966 } 1966 }
1967 else 1967 else
1968 { 1968 {
1969 return 0; 1969 return 0;
1970 } 1970 }
1971 } 1971 }
1972 1972
2164 XINT (Vx_hourglass_pointer_shape)); 2164 XINT (Vx_hourglass_pointer_shape));
2165 } 2165 }
2166 else 2166 else
2167 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch); 2167 hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);
2168 x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s"); 2168 x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");
2169 2169
2170 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s"); 2170 x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
2171 if (!EQ (Qnil, Vx_mode_pointer_shape)) 2171 if (!EQ (Qnil, Vx_mode_pointer_shape))
2172 { 2172 {
2173 CHECK_NUMBER (Vx_mode_pointer_shape); 2173 CHECK_NUMBER (Vx_mode_pointer_shape);
2174 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), 2174 mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f),
2247 2247
2248 if (mode_cursor != f->output_data.w32->modeline_cursor 2248 if (mode_cursor != f->output_data.w32->modeline_cursor
2249 && f->output_data.w32->modeline_cursor != 0) 2249 && f->output_data.w32->modeline_cursor != 0)
2250 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor); 2250 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);
2251 f->output_data.w32->modeline_cursor = mode_cursor; 2251 f->output_data.w32->modeline_cursor = mode_cursor;
2252 2252
2253 if (cross_cursor != f->output_data.w32->cross_cursor 2253 if (cross_cursor != f->output_data.w32->cross_cursor
2254 && f->output_data.w32->cross_cursor != 0) 2254 && f->output_data.w32->cross_cursor != 0)
2255 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor); 2255 XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor);
2256 f->output_data.w32->cross_cursor = cross_cursor; 2256 f->output_data.w32->cross_cursor = cross_cursor;
2257 2257
2277 WHITE_PIX_DEFAULT (f)); 2277 WHITE_PIX_DEFAULT (f));
2278 else 2278 else
2279 fore_pixel = FRAME_BACKGROUND_PIXEL (f); 2279 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
2280 2280
2281 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); 2281 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2282 2282
2283 /* Make sure that the cursor color differs from the background color. */ 2283 /* Make sure that the cursor color differs from the background color. */
2284 if (pixel == FRAME_BACKGROUND_PIXEL (f)) 2284 if (pixel == FRAME_BACKGROUND_PIXEL (f))
2285 { 2285 {
2286 pixel = f->output_data.w32->mouse_pixel; 2286 pixel = f->output_data.w32->mouse_pixel;
2287 if (pixel == fore_pixel) 2287 if (pixel == fore_pixel)
2310 update_face_from_frame_parameter (f, Qcursor_color, arg); 2310 update_face_from_frame_parameter (f, Qcursor_color, arg);
2311 } 2311 }
2312 2312
2313 /* Set the border-color of frame F to pixel value PIX. 2313 /* Set the border-color of frame F to pixel value PIX.
2314 Note that this does not fully take effect if done before 2314 Note that this does not fully take effect if done before
2315 F has an window. */ 2315 F has a window. */
2316 void 2316 void
2317 x_set_border_pixel (f, pix) 2317 x_set_border_pixel (f, pix)
2318 struct frame *f; 2318 struct frame *f;
2319 int pix; 2319 int pix;
2320 { 2320 {
2367 int result; 2367 int result;
2368 2368
2369 if (NILP (arg) && NILP (oldval)) 2369 if (NILP (arg) && NILP (oldval))
2370 return; 2370 return;
2371 2371
2372 if (STRINGP (arg) && STRINGP (oldval) 2372 if (STRINGP (arg) && STRINGP (oldval)
2373 && EQ (Fstring_equal (oldval, arg), Qt)) 2373 && EQ (Fstring_equal (oldval, arg), Qt))
2374 return; 2374 return;
2375 2375
2376 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval)) 2376 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval))
2377 return; 2377 return;
2472 BLOCK_INPUT; 2472 BLOCK_INPUT;
2473 result = (STRINGP (fontset_name) 2473 result = (STRINGP (fontset_name)
2474 ? x_new_fontset (f, SDATA (fontset_name)) 2474 ? x_new_fontset (f, SDATA (fontset_name))
2475 : x_new_font (f, SDATA (arg))); 2475 : x_new_font (f, SDATA (arg)));
2476 UNBLOCK_INPUT; 2476 UNBLOCK_INPUT;
2477 2477
2478 if (EQ (result, Qnil)) 2478 if (EQ (result, Qnil))
2479 error ("Font `%s' is not defined", SDATA (arg)); 2479 error ("Font `%s' is not defined", SDATA (arg));
2480 else if (EQ (result, Qt)) 2480 else if (EQ (result, Qt))
2481 error ("The characters of the given font have varying widths"); 2481 error ("The characters of the given font have varying widths");
2482 else if (STRINGP (result)) 2482 else if (STRINGP (result))
2739 x_set_name (f, name, explicit) 2739 x_set_name (f, name, explicit)
2740 struct frame *f; 2740 struct frame *f;
2741 Lisp_Object name; 2741 Lisp_Object name;
2742 int explicit; 2742 int explicit;
2743 { 2743 {
2744 /* Make sure that requests from lisp code override requests from 2744 /* Make sure that requests from lisp code override requests from
2745 Emacs redisplay code. */ 2745 Emacs redisplay code. */
2746 if (explicit) 2746 if (explicit)
2747 { 2747 {
2748 /* If we're switching from explicit to implicit, we had better 2748 /* If we're switching from explicit to implicit, we had better
2749 update the mode lines and thereby update the title. */ 2749 update the mode lines and thereby update the title. */
2887 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = NILP (arg) ? 2887 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = NILP (arg) ?
2888 vertical_scroll_bar_none : 2888 vertical_scroll_bar_none :
2889 /* Put scroll bars on the right by default, as is conventional 2889 /* Put scroll bars on the right by default, as is conventional
2890 on MS-Windows. */ 2890 on MS-Windows. */
2891 EQ (Qleft, arg) 2891 EQ (Qleft, arg)
2892 ? vertical_scroll_bar_left 2892 ? vertical_scroll_bar_left
2893 : vertical_scroll_bar_right; 2893 : vertical_scroll_bar_right;
2894 2894
2895 /* We set this parameter before creating the window for the 2895 /* We set this parameter before creating the window for the
2896 frame, so we can get the geometry right from the start. 2896 frame, so we can get the geometry right from the start.
2897 However, if the window hasn't been created yet, we shouldn't 2897 However, if the window hasn't been created yet, we shouldn't
2928 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f)); 2928 x_set_window_size (f, 0, FRAME_WIDTH (f), FRAME_HEIGHT (f));
2929 do_pending_window_change (0); 2929 do_pending_window_change (0);
2930 } 2930 }
2931 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0); 2931 change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
2932 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0; 2932 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
2933 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0; 2933 XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
2934 } 2934 }
2935 2935
2936 /* Subroutines of creating an frame. */ 2936 /* Subroutines of creating a frame. */
2937 2937
2938 /* Make sure that Vx_resource_name is set to a reasonable value. 2938 /* Make sure that Vx_resource_name is set to a reasonable value.
2939 Fix it up, or set it to `emacs' if it is too hopeless. */ 2939 Fix it up, or set it to `emacs' if it is too hopeless. */
2940 2940
2941 static void 2941 static void
3158 case RES_TYPE_BOOLEAN: 3158 case RES_TYPE_BOOLEAN:
3159 tem = Fdowncase (tem); 3159 tem = Fdowncase (tem);
3160 if (!strcmp (SDATA (tem), "on") 3160 if (!strcmp (SDATA (tem), "on")
3161 || !strcmp (SDATA (tem), "true")) 3161 || !strcmp (SDATA (tem), "true"))
3162 return Qt; 3162 return Qt;
3163 else 3163 else
3164 return Qnil; 3164 return Qnil;
3165 3165
3166 case RES_TYPE_STRING: 3166 case RES_TYPE_STRING:
3167 return tem; 3167 return tem;
3168 3168
3423 3423
3424 3424
3425 3425
3426 extern LRESULT CALLBACK w32_wnd_proc (); 3426 extern LRESULT CALLBACK w32_wnd_proc ();
3427 3427
3428 BOOL 3428 BOOL
3429 w32_init_class (hinst) 3429 w32_init_class (hinst)
3430 HINSTANCE hinst; 3430 HINSTANCE hinst;
3431 { 3431 {
3432 WNDCLASS wc; 3432 WNDCLASS wc;
3433 3433
3443 wc.lpszClassName = EMACS_CLASS; 3443 wc.lpszClassName = EMACS_CLASS;
3444 3444
3445 return (RegisterClass (&wc)); 3445 return (RegisterClass (&wc));
3446 } 3446 }
3447 3447
3448 HWND 3448 HWND
3449 w32_createscrollbar (f, bar) 3449 w32_createscrollbar (f, bar)
3450 struct frame *f; 3450 struct frame *f;
3451 struct scroll_bar * bar; 3451 struct scroll_bar * bar;
3452 { 3452 {
3453 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE, 3453 return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
3454 /* Position and size of scroll bar. */ 3454 /* Position and size of scroll bar. */
3455 XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM, 3455 XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
3456 XINT(bar->top), 3456 XINT(bar->top),
3457 XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 3457 XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
3458 XINT(bar->height), 3458 XINT(bar->height),
3459 FRAME_W32_WINDOW (f), 3459 FRAME_W32_WINDOW (f),
3460 NULL, 3460 NULL,
3461 hinst, 3461 hinst,
3462 NULL)); 3462 NULL));
3463 } 3463 }
3464 3464
3465 void 3465 void
3466 w32_createwindow (f) 3466 w32_createwindow (f)
3467 struct frame *f; 3467 struct frame *f;
3468 { 3468 {
3469 HWND hwnd; 3469 HWND hwnd;
3470 RECT rect; 3470 RECT rect;
3471 3471
3472 rect.left = rect.top = 0; 3472 rect.left = rect.top = 0;
3473 rect.right = PIXEL_WIDTH (f); 3473 rect.right = PIXEL_WIDTH (f);
3474 rect.bottom = PIXEL_HEIGHT (f); 3474 rect.bottom = PIXEL_HEIGHT (f);
3475 3475
3476 AdjustWindowRect (&rect, f->output_data.w32->dwStyle, 3476 AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
3477 FRAME_EXTERNAL_MENU_BAR (f)); 3477 FRAME_EXTERNAL_MENU_BAR (f));
3478 3478
3479 /* Do first time app init */ 3479 /* Do first time app init */
3480 3480
3481 if (!hprevinst) 3481 if (!hprevinst)
3482 { 3482 {
3483 w32_init_class (hinst); 3483 w32_init_class (hinst);
3484 } 3484 }
3485 3485
3486 FRAME_W32_WINDOW (f) = hwnd 3486 FRAME_W32_WINDOW (f) = hwnd
3487 = CreateWindow (EMACS_CLASS, 3487 = CreateWindow (EMACS_CLASS,
3488 f->namebuf, 3488 f->namebuf,
3489 f->output_data.w32->dwStyle | WS_CLIPCHILDREN, 3489 f->output_data.w32->dwStyle | WS_CLIPCHILDREN,
3490 f->output_data.w32->left_pos, 3490 f->output_data.w32->left_pos,
3504 SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, f->output_data.w32->vertical_scroll_bar_extra); 3504 SetWindowLong (hwnd, WND_SCROLLBAR_INDEX, f->output_data.w32->vertical_scroll_bar_extra);
3505 SetWindowLong (hwnd, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL (f)); 3505 SetWindowLong (hwnd, WND_BACKGROUND_INDEX, FRAME_BACKGROUND_PIXEL (f));
3506 3506
3507 /* Enable drag-n-drop. */ 3507 /* Enable drag-n-drop. */
3508 DragAcceptFiles (hwnd, TRUE); 3508 DragAcceptFiles (hwnd, TRUE);
3509 3509
3510 /* Do this to discard the default setting specified by our parent. */ 3510 /* Do this to discard the default setting specified by our parent. */
3511 ShowWindow (hwnd, SW_HIDE); 3511 ShowWindow (hwnd, SW_HIDE);
3512 } 3512 }
3513 } 3513 }
3514 3514
3515 void 3515 void
3516 my_post_msg (wmsg, hwnd, msg, wParam, lParam) 3516 my_post_msg (wmsg, hwnd, msg, wParam, lParam)
3517 W32Msg * wmsg; 3517 W32Msg * wmsg;
3518 HWND hwnd; 3518 HWND hwnd;
3519 UINT msg; 3519 UINT msg;
3520 WPARAM wParam; 3520 WPARAM wParam;
3607 3607
3608 modifiers[i] = 0; 3608 modifiers[i] = 0;
3609 } 3609 }
3610 3610
3611 /* Emacs can lose focus while a modifier key has been pressed. When 3611 /* Emacs can lose focus while a modifier key has been pressed. When
3612 it regains focus, be conservative and clear all modifiers since 3612 it regains focus, be conservative and clear all modifiers since
3613 we cannot reconstruct the left and right modifier state. */ 3613 we cannot reconstruct the left and right modifier state. */
3614 static void 3614 static void
3615 reset_modifiers () 3615 reset_modifiers ()
3616 { 3616 {
3617 SHORT ctrl, alt; 3617 SHORT ctrl, alt;
3662 sync_modifiers () 3662 sync_modifiers ()
3663 { 3663 {
3664 if (!modifiers_recorded) 3664 if (!modifiers_recorded)
3665 return; 3665 return;
3666 3666
3667 if (!(GetKeyState (VK_CONTROL) & 0x8000)) 3667 if (!(GetKeyState (VK_CONTROL) & 0x8000))
3668 modifiers[EMACS_RCONTROL] = modifiers[EMACS_LCONTROL] = 0; 3668 modifiers[EMACS_RCONTROL] = modifiers[EMACS_LCONTROL] = 0;
3669 3669
3670 if (!(GetKeyState (VK_MENU) & 0x8000)) 3670 if (!(GetKeyState (VK_MENU) & 0x8000))
3671 modifiers[EMACS_RMENU] = modifiers[EMACS_LMENU] = 0; 3671 modifiers[EMACS_RMENU] = modifiers[EMACS_LMENU] = 0;
3672 } 3672 }
3673 3673
3674 static int 3674 static int
3675 modifier_set (int vkey) 3675 modifier_set (int vkey)
3875 MSG msg; 3875 MSG msg;
3876 int result; 3876 int result;
3877 HWND focus_window; 3877 HWND focus_window;
3878 3878
3879 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL); 3879 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
3880 3880
3881 while (GetMessage (&msg, NULL, 0, 0)) 3881 while (GetMessage (&msg, NULL, 0, 0))
3882 { 3882 {
3883 if (msg.hwnd == NULL) 3883 if (msg.hwnd == NULL)
3884 { 3884 {
3885 switch (msg.message) 3885 switch (msg.message)
4065 4065
4066 /* Ensure input thread is woken so it notices the completion. */ 4066 /* Ensure input thread is woken so it notices the completion. */
4067 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0); 4067 PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0);
4068 } 4068 }
4069 4069
4070 DWORD 4070 DWORD
4071 w32_msg_worker (dw) 4071 w32_msg_worker (dw)
4072 DWORD dw; 4072 DWORD dw;
4073 { 4073 {
4074 MSG msg; 4074 MSG msg;
4075 deferred_msg dummy_buf; 4075 deferred_msg dummy_buf;
4076 4076
4077 /* Ensure our message queue is created */ 4077 /* Ensure our message queue is created */
4078 4078
4079 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE); 4079 PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
4080 4080
4081 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 4081 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
4082 abort (); 4082 abort ();
4083 4083
4084 memset (&dummy_buf, 0, sizeof (dummy_buf)); 4084 memset (&dummy_buf, 0, sizeof (dummy_buf));
4085 dummy_buf.w32msg.msg.hwnd = NULL; 4085 dummy_buf.w32msg.msg.hwnd = NULL;
4154 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4154 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4155 } 4155 }
4156 4156
4157 /* Main window procedure */ 4157 /* Main window procedure */
4158 4158
4159 LRESULT CALLBACK 4159 LRESULT CALLBACK
4160 w32_wnd_proc (hwnd, msg, wParam, lParam) 4160 w32_wnd_proc (hwnd, msg, wParam, lParam)
4161 HWND hwnd; 4161 HWND hwnd;
4162 UINT msg; 4162 UINT msg;
4163 WPARAM wParam; 4163 WPARAM wParam;
4164 LPARAM lParam; 4164 LPARAM lParam;
4183 4183
4184 It is also safe to use functions that make GDI calls, such as 4184 It is also safe to use functions that make GDI calls, such as
4185 w32_clear_rect, because these functions must obtain a DC handle 4185 w32_clear_rect, because these functions must obtain a DC handle
4186 from the frame struct using get_frame_dc which is thread-aware. */ 4186 from the frame struct using get_frame_dc which is thread-aware. */
4187 4187
4188 switch (msg) 4188 switch (msg)
4189 { 4189 {
4190 case WM_ERASEBKGND: 4190 case WM_ERASEBKGND:
4191 f = x_window_to_frame (dpyinfo, hwnd); 4191 f = x_window_to_frame (dpyinfo, hwnd);
4192 if (f) 4192 if (f)
4193 { 4193 {
4252 #endif 4252 #endif
4253 EndPaint (hwnd, &paintStruct); 4253 EndPaint (hwnd, &paintStruct);
4254 leave_crit (); 4254 leave_crit ();
4255 4255
4256 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4256 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4257 4257
4258 return 0; 4258 return 0;
4259 } 4259 }
4260 4260
4261 /* If GetUpdateRect returns 0 (meaning there is no update 4261 /* If GetUpdateRect returns 0 (meaning there is no update
4262 region), assume the whole window needs to be repainted. */ 4262 region), assume the whole window needs to be repainted. */
4372 case VK_APPS: 4372 case VK_APPS:
4373 if (!NILP (Vw32_apps_modifier)) 4373 if (!NILP (Vw32_apps_modifier))
4374 return 0; 4374 return 0;
4375 break; 4375 break;
4376 case VK_MENU: 4376 case VK_MENU:
4377 if (NILP (Vw32_pass_alt_to_system)) 4377 if (NILP (Vw32_pass_alt_to_system))
4378 /* Prevent DefWindowProc from activating the menu bar if an 4378 /* Prevent DefWindowProc from activating the menu bar if an
4379 Alt key is pressed and released by itself. */ 4379 Alt key is pressed and released by itself. */
4380 return 0; 4380 return 0;
4381 windows_translate = 1; 4381 windows_translate = 1;
4382 break; 4382 break;
4383 case VK_CAPITAL: 4383 case VK_CAPITAL:
4384 /* Decide whether to treat as modifier or function key. */ 4384 /* Decide whether to treat as modifier or function key. */
4385 if (NILP (Vw32_enable_caps_lock)) 4385 if (NILP (Vw32_enable_caps_lock))
4386 goto disable_lock_key; 4386 goto disable_lock_key;
4387 windows_translate = 1; 4387 windows_translate = 1;
4388 break; 4388 break;
4415 input event. */ 4415 input event. */
4416 post_character_message (hwnd, msg, wParam, lParam, 4416 post_character_message (hwnd, msg, wParam, lParam,
4417 w32_get_key_modifiers (wParam, lParam)); 4417 w32_get_key_modifiers (wParam, lParam));
4418 windows_translate = 1; 4418 windows_translate = 1;
4419 break; 4419 break;
4420 case VK_CONTROL: 4420 case VK_CONTROL:
4421 case VK_SHIFT: 4421 case VK_SHIFT:
4422 case VK_PROCESSKEY: /* Generated by IME. */ 4422 case VK_PROCESSKEY: /* Generated by IME. */
4423 windows_translate = 1; 4423 windows_translate = 1;
4424 break; 4424 break;
4425 case VK_CANCEL: 4425 case VK_CANCEL:
4473 base character (ie. translating the base key plus 4473 base character (ie. translating the base key plus
4474 shift modifier). */ 4474 shift modifier). */
4475 int add; 4475 int add;
4476 int isdead = 0; 4476 int isdead = 0;
4477 KEY_EVENT_RECORD key; 4477 KEY_EVENT_RECORD key;
4478 4478
4479 key.bKeyDown = TRUE; 4479 key.bKeyDown = TRUE;
4480 key.wRepeatCount = 1; 4480 key.wRepeatCount = 1;
4481 key.wVirtualKeyCode = wParam; 4481 key.wVirtualKeyCode = wParam;
4482 key.wVirtualScanCode = (lParam & 0xFF0000) >> 16; 4482 key.wVirtualScanCode = (lParam & 0xFF0000) >> 16;
4483 key.uChar.AsciiChar = 0; 4483 key.uChar.AsciiChar = 0;
4514 TranslateMessage (&windows_msg); 4514 TranslateMessage (&windows_msg);
4515 goto dflt; 4515 goto dflt;
4516 } 4516 }
4517 4517
4518 /* Fall through */ 4518 /* Fall through */
4519 4519
4520 case WM_SYSCHAR: 4520 case WM_SYSCHAR:
4521 case WM_CHAR: 4521 case WM_CHAR:
4522 post_character_message (hwnd, msg, wParam, lParam, 4522 post_character_message (hwnd, msg, wParam, lParam,
4523 w32_get_key_modifiers (wParam, lParam)); 4523 w32_get_key_modifiers (wParam, lParam));
4524 break; 4524 break;
4650 4650
4651 if (parse_button (msg, HIWORD (wParam), &button, &up)) 4651 if (parse_button (msg, HIWORD (wParam), &button, &up))
4652 { 4652 {
4653 if (up) ReleaseCapture (); 4653 if (up) ReleaseCapture ();
4654 else SetCapture (hwnd); 4654 else SetCapture (hwnd);
4655 button = (button == 0) ? LMOUSE : 4655 button = (button == 0) ? LMOUSE :
4656 ((button == 1) ? MMOUSE : RMOUSE); 4656 ((button == 1) ? MMOUSE : RMOUSE);
4657 if (up) 4657 if (up)
4658 button_state &= ~button; 4658 button_state &= ~button;
4659 else 4659 else
4660 button_state |= button; 4660 button_state |= button;
4661 } 4661 }
4662 } 4662 }
4663 4663
4664 wmsg.dwModifiers = w32_get_modifiers (); 4664 wmsg.dwModifiers = w32_get_modifiers ();
4665 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4665 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4666 4666
4667 /* Need to return true for XBUTTON messages, false for others, 4667 /* Need to return true for XBUTTON messages, false for others,
4668 to indicate that we processed the message. */ 4668 to indicate that we processed the message. */
4691 { 4691 {
4692 wmsg.dwModifiers = w32_get_modifiers (); 4692 wmsg.dwModifiers = w32_get_modifiers ();
4693 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4693 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4694 return 0; 4694 return 0;
4695 } 4695 }
4696 4696
4697 /* Hang onto mouse move and scroll messages for a bit, to avoid 4697 /* Hang onto mouse move and scroll messages for a bit, to avoid
4698 sending such events to Emacs faster than it can process them. 4698 sending such events to Emacs faster than it can process them.
4699 If we get more events before the timer from the first message 4699 If we get more events before the timer from the first message
4700 expires, we just replace the first message. */ 4700 expires, we just replace the first message. */
4701 4701
4709 saved_mouse_move_msg.msg.message = msg; 4709 saved_mouse_move_msg.msg.message = msg;
4710 saved_mouse_move_msg.msg.wParam = wParam; 4710 saved_mouse_move_msg.msg.wParam = wParam;
4711 saved_mouse_move_msg.msg.lParam = lParam; 4711 saved_mouse_move_msg.msg.lParam = lParam;
4712 saved_mouse_move_msg.msg.time = GetMessageTime (); 4712 saved_mouse_move_msg.msg.time = GetMessageTime ();
4713 saved_mouse_move_msg.dwModifiers = w32_get_modifiers (); 4713 saved_mouse_move_msg.dwModifiers = w32_get_modifiers ();
4714 4714
4715 return 0; 4715 return 0;
4716 4716
4717 case WM_MOUSEWHEEL: 4717 case WM_MOUSEWHEEL:
4718 wmsg.dwModifiers = w32_get_modifiers (); 4718 wmsg.dwModifiers = w32_get_modifiers ();
4719 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4719 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4757 w32_free_menu_strings (hwnd); 4757 w32_free_menu_strings (hwnd);
4758 f->output_data.w32->menubar_active = 0; 4758 f->output_data.w32->menubar_active = 0;
4759 } 4759 }
4760 } 4760 }
4761 return 0; 4761 return 0;
4762 4762
4763 case WM_NCACTIVATE: 4763 case WM_NCACTIVATE:
4764 /* Windows doesn't send us focus messages when putting up and 4764 /* Windows doesn't send us focus messages when putting up and
4765 taking down a system popup dialog as for Ctrl-Alt-Del on Windows 95. 4765 taking down a system popup dialog as for Ctrl-Alt-Del on Windows 95.
4766 The only indication we get that something happened is receiving 4766 The only indication we get that something happened is receiving
4767 this message afterwards. So this is a good time to reset our 4767 this message afterwards. So this is a good time to reset our
4961 { 4961 {
4962 f->output_data.w32->menu_command_in_progress = 1; 4962 f->output_data.w32->menu_command_in_progress = 1;
4963 if (menu_free_timer) 4963 if (menu_free_timer)
4964 { 4964 {
4965 KillTimer (hwnd, menu_free_timer); 4965 KillTimer (hwnd, menu_free_timer);
4966 menu_free_timer = 0; 4966 menu_free_timer = 0;
4967 } 4967 }
4968 } 4968 }
4969 case WM_MOVE: 4969 case WM_MOVE:
4970 case WM_SIZE: 4970 case WM_SIZE:
4971 command: 4971 command:
4986 WINDOWPLACEMENT wp; 4986 WINDOWPLACEMENT wp;
4987 LPWINDOWPOS lppos = (WINDOWPOS *) lParam; 4987 LPWINDOWPOS lppos = (WINDOWPOS *) lParam;
4988 4988
4989 wp.length = sizeof (WINDOWPLACEMENT); 4989 wp.length = sizeof (WINDOWPLACEMENT);
4990 GetWindowPlacement (hwnd, &wp); 4990 GetWindowPlacement (hwnd, &wp);
4991 4991
4992 if (wp.showCmd != SW_SHOWMINIMIZED && (lppos->flags & SWP_NOSIZE) == 0) 4992 if (wp.showCmd != SW_SHOWMINIMIZED && (lppos->flags & SWP_NOSIZE) == 0)
4993 { 4993 {
4994 RECT rect; 4994 RECT rect;
4995 int wdiff; 4995 int wdiff;
4996 int hdiff; 4996 int hdiff;
4997 DWORD font_width; 4997 DWORD font_width;
4998 DWORD line_height; 4998 DWORD line_height;
4999 DWORD internal_border; 4999 DWORD internal_border;
5000 DWORD scrollbar_extra; 5000 DWORD scrollbar_extra;
5001 RECT wr; 5001 RECT wr;
5002 5002
5003 wp.length = sizeof(wp); 5003 wp.length = sizeof(wp);
5004 GetWindowRect (hwnd, &wr); 5004 GetWindowRect (hwnd, &wr);
5005 5005
5006 enter_crit (); 5006 enter_crit ();
5007 5007
5008 font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX); 5008 font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX);
5009 line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX); 5009 line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX);
5010 internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX); 5010 internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX);
5011 scrollbar_extra = GetWindowLong (hwnd, WND_SCROLLBAR_INDEX); 5011 scrollbar_extra = GetWindowLong (hwnd, WND_SCROLLBAR_INDEX);
5012 5012
5013 leave_crit (); 5013 leave_crit ();
5014 5014
5015 memset (&rect, 0, sizeof (rect)); 5015 memset (&rect, 0, sizeof (rect));
5016 AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE), 5016 AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE),
5017 GetMenu (hwnd) != NULL); 5017 GetMenu (hwnd) != NULL);
5018 5018
5019 /* Force width and height of client area to be exact 5019 /* Force width and height of client area to be exact
5020 multiples of the character cell dimensions. */ 5020 multiples of the character cell dimensions. */
5021 wdiff = (lppos->cx - (rect.right - rect.left) 5021 wdiff = (lppos->cx - (rect.right - rect.left)
5022 - 2 * internal_border - scrollbar_extra) 5022 - 2 * internal_border - scrollbar_extra)
5023 % font_width; 5023 % font_width;
5024 hdiff = (lppos->cy - (rect.bottom - rect.top) 5024 hdiff = (lppos->cy - (rect.bottom - rect.top)
5025 - 2 * internal_border) 5025 - 2 * internal_border)
5026 % line_height; 5026 % line_height;
5027 5027
5028 if (wdiff || hdiff) 5028 if (wdiff || hdiff)
5029 { 5029 {
5030 /* For right/bottom sizing we can just fix the sizes. 5030 /* For right/bottom sizing we can just fix the sizes.
5031 However for top/left sizing we will need to fix the X 5031 However for top/left sizing we will need to fix the X
5032 and Y positions as well. */ 5032 and Y positions as well. */
5033 5033
5034 lppos->cx -= wdiff; 5034 lppos->cx -= wdiff;
5035 lppos->cy -= hdiff; 5035 lppos->cy -= hdiff;
5036 5036
5037 if (wp.showCmd != SW_SHOWMAXIMIZED 5037 if (wp.showCmd != SW_SHOWMAXIMIZED
5038 && (lppos->flags & SWP_NOMOVE) == 0) 5038 && (lppos->flags & SWP_NOMOVE) == 0)
5039 { 5039 {
5040 if (lppos->x != wr.left || lppos->y != wr.top) 5040 if (lppos->x != wr.left || lppos->y != wr.top)
5041 { 5041 {
5042 lppos->x += wdiff; 5042 lppos->x += wdiff;
5045 else 5045 else
5046 { 5046 {
5047 lppos->flags |= SWP_NOMOVE; 5047 lppos->flags |= SWP_NOMOVE;
5048 } 5048 }
5049 } 5049 }
5050 5050
5051 return 0; 5051 return 0;
5052 } 5052 }
5053 } 5053 }
5054 } 5054 }
5055 5055
5056 goto dflt; 5056 goto dflt;
5057 5057
5058 case WM_GETMINMAXINFO: 5058 case WM_GETMINMAXINFO:
5059 /* Hack to correct bug that allows Emacs frames to be resized 5059 /* Hack to correct bug that allows Emacs frames to be resized
5060 below the Minimum Tracking Size. */ 5060 below the Minimum Tracking Size. */
5128 unneccesarily, as it confuses screen reader software. */ 5128 unneccesarily, as it confuses screen reader software. */
5129 w32_system_caret_hwnd = hwnd; 5129 w32_system_caret_hwnd = hwnd;
5130 CreateCaret (hwnd, NULL, 0, 5130 CreateCaret (hwnd, NULL, 0,
5131 w32_system_caret_height); 5131 w32_system_caret_height);
5132 } 5132 }
5133 5133
5134 if (!SetCaretPos (w32_system_caret_x, w32_system_caret_y)) 5134 if (!SetCaretPos (w32_system_caret_x, w32_system_caret_y))
5135 return 0; 5135 return 0;
5136 /* Ensure visible caret gets turned on when requested. */ 5136 /* Ensure visible caret gets turned on when requested. */
5137 else if (w32_use_visible_system_caret 5137 else if (w32_use_visible_system_caret
5138 && w32_visible_system_caret_hwnd != hwnd) 5138 && w32_visible_system_caret_hwnd != hwnd)
5159 flags = TPM_CENTERALIGN; 5159 flags = TPM_CENTERALIGN;
5160 if (button_state & LMOUSE) 5160 if (button_state & LMOUSE)
5161 flags |= TPM_LEFTBUTTON; 5161 flags |= TPM_LEFTBUTTON;
5162 else if (button_state & RMOUSE) 5162 else if (button_state & RMOUSE)
5163 flags |= TPM_RIGHTBUTTON; 5163 flags |= TPM_RIGHTBUTTON;
5164 5164
5165 /* Remember we did a SetCapture on the initial mouse down event, 5165 /* Remember we did a SetCapture on the initial mouse down event,
5166 so for safety, we make sure the capture is cancelled now. */ 5166 so for safety, we make sure the capture is cancelled now. */
5167 ReleaseCapture (); 5167 ReleaseCapture ();
5168 button_state = 0; 5168 button_state = 0;
5169 5169
5170 /* Use menubar_active to indicate that WM_INITMENU is from 5170 /* Use menubar_active to indicate that WM_INITMENU is from
5171 TrackPopupMenu below, and should be ignored. */ 5171 TrackPopupMenu below, and should be ignored. */
5172 f = x_window_to_frame (dpyinfo, hwnd); 5172 f = x_window_to_frame (dpyinfo, hwnd);
5173 if (f) 5173 if (f)
5174 f->output_data.w32->menubar_active = 1; 5174 f->output_data.w32->menubar_active = 1;
5175 5175
5176 if (TrackPopupMenu ((HMENU)wParam, flags, pos->x, pos->y, 5176 if (TrackPopupMenu ((HMENU)wParam, flags, pos->x, pos->y,
5177 0, hwnd, NULL)) 5177 0, hwnd, NULL))
5178 { 5178 {
5179 MSG amsg; 5179 MSG amsg;
5180 /* Eat any mouse messages during popupmenu */ 5180 /* Eat any mouse messages during popupmenu */
5181 while (PeekMessage (&amsg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST, 5181 while (PeekMessage (&amsg, hwnd, WM_MOUSEFIRST, WM_MOUSELAST,
5204 { 5204 {
5205 wmsg.dwModifiers = w32_get_modifiers (); 5205 wmsg.dwModifiers = w32_get_modifiers ();
5206 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 5206 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
5207 return 0; 5207 return 0;
5208 } 5208 }
5209 5209
5210 dflt: 5210 dflt:
5211 return DefWindowProc (hwnd, msg, wParam, lParam); 5211 return DefWindowProc (hwnd, msg, wParam, lParam);
5212 } 5212 }
5213 5213
5214 5214
5215 /* The most common default return code for handled messages is 0. */ 5215 /* The most common default return code for handled messages is 0. */
5216 return 0; 5216 return 0;
5217 } 5217 }
5218 5218
5219 void 5219 void
5220 my_create_window (f) 5220 my_create_window (f)
5221 struct frame * f; 5221 struct frame * f;
5222 { 5222 {
5223 MSG msg; 5223 MSG msg;
5224 5224
5230 5230
5231 /* Create a tooltip window. Unlike my_create_window, we do not do this 5231 /* Create a tooltip window. Unlike my_create_window, we do not do this
5232 indirectly via the Window thread, as we do not need to process Window 5232 indirectly via the Window thread, as we do not need to process Window
5233 messages for the tooltip. Creating tooltips indirectly also creates 5233 messages for the tooltip. Creating tooltips indirectly also creates
5234 deadlocks when tooltips are created for menu items. */ 5234 deadlocks when tooltips are created for menu items. */
5235 void 5235 void
5236 my_create_tip_window (f) 5236 my_create_tip_window (f)
5237 struct frame *f; 5237 struct frame *f;
5238 { 5238 {
5239 RECT rect; 5239 RECT rect;
5240 5240
5287 /* Use the resource name as the top-level window name 5287 /* Use the resource name as the top-level window name
5288 for looking up resources. Make a non-Lisp copy 5288 for looking up resources. Make a non-Lisp copy
5289 for the window manager, so GC relocation won't bother it. 5289 for the window manager, so GC relocation won't bother it.
5290 5290
5291 Elsewhere we specify the window name for the window manager. */ 5291 Elsewhere we specify the window name for the window manager. */
5292 5292
5293 { 5293 {
5294 char *str = (char *) SDATA (Vx_resource_name); 5294 char *str = (char *) SDATA (Vx_resource_name);
5295 f->namebuf = (char *) xmalloc (strlen (str) + 1); 5295 f->namebuf = (char *) xmalloc (strlen (str) + 1);
5296 strcpy (f->namebuf, str); 5296 strcpy (f->namebuf, str);
5297 } 5297 }
5411 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame)) 5411 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
5412 { 5412 {
5413 #ifdef GLYPH_DEBUG 5413 #ifdef GLYPH_DEBUG
5414 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 5414 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
5415 #endif 5415 #endif
5416 5416
5417 x_free_frame_resources (f); 5417 x_free_frame_resources (f);
5418 5418
5419 /* Check that reference counts are indeed correct. */ 5419 /* Check that reference counts are indeed correct. */
5420 xassert (dpyinfo->reference_count == dpyinfo_refcount); 5420 xassert (dpyinfo->reference_count == dpyinfo_refcount);
5421 xassert (dpyinfo->image_cache->refcount == image_cache_refcount); 5421 xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
5422 5422
5423 return Qt; 5423 return Qt;
5424 } 5424 }
5425 5425
5426 return Qnil; 5426 return Qnil;
5427 } 5427 }
5428 5428
5429 5429
5430 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 5430 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
5584 font = x_new_font (f, "-*-Fixedsys-normal-r-*-*-12-*-*-*-c-*-iso8859-1"); 5584 font = x_new_font (f, "-*-Fixedsys-normal-r-*-*-12-*-*-*-c-*-iso8859-1");
5585 UNBLOCK_INPUT; 5585 UNBLOCK_INPUT;
5586 if (! STRINGP (font)) 5586 if (! STRINGP (font))
5587 font = build_string ("Fixedsys"); 5587 font = build_string ("Fixedsys");
5588 5588
5589 x_default_parameter (f, parms, Qfont, font, 5589 x_default_parameter (f, parms, Qfont, font,
5590 "font", "Font", RES_TYPE_STRING); 5590 "font", "Font", RES_TYPE_STRING);
5591 } 5591 }
5592 5592
5593 x_default_parameter (f, parms, Qborder_width, make_number (2), 5593 x_default_parameter (f, parms, Qborder_width, make_number (2),
5594 "borderWidth", "BorderWidth", RES_TYPE_NUMBER); 5594 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
5637 which calls change_frame_size, which calls Fset_window_buffer, 5637 which calls change_frame_size, which calls Fset_window_buffer,
5638 which runs hooks, which call Fvertical_motion. At the end, we 5638 which runs hooks, which call Fvertical_motion. At the end, we
5639 end up in init_iterator with a null face cache, which should not 5639 end up in init_iterator with a null face cache, which should not
5640 happen. */ 5640 happen. */
5641 init_frame_faces (f); 5641 init_frame_faces (f);
5642 5642
5643 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), 5643 x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
5644 "menuBar", "MenuBar", RES_TYPE_NUMBER); 5644 "menuBar", "MenuBar", RES_TYPE_NUMBER);
5645 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), 5645 x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
5646 "toolBar", "ToolBar", RES_TYPE_NUMBER); 5646 "toolBar", "ToolBar", RES_TYPE_NUMBER);
5647 5647
5662 tall Emacs frames without having to guess how tall the tool-bar 5662 tall Emacs frames without having to guess how tall the tool-bar
5663 will get. */ 5663 will get. */
5664 if (FRAME_TOOL_BAR_LINES (f)) 5664 if (FRAME_TOOL_BAR_LINES (f))
5665 { 5665 {
5666 int margin, relief, bar_height; 5666 int margin, relief, bar_height;
5667 5667
5668 relief = (tool_bar_button_relief >= 0 5668 relief = (tool_bar_button_relief >= 0
5669 ? tool_bar_button_relief 5669 ? tool_bar_button_relief
5670 : DEFAULT_TOOL_BAR_BUTTON_RELIEF); 5670 : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
5671 5671
5672 if (INTEGERP (Vtool_bar_button_margin) 5672 if (INTEGERP (Vtool_bar_button_margin)
5676 && INTEGERP (XCDR (Vtool_bar_button_margin)) 5676 && INTEGERP (XCDR (Vtool_bar_button_margin))
5677 && XINT (XCDR (Vtool_bar_button_margin)) > 0) 5677 && XINT (XCDR (Vtool_bar_button_margin)) > 0)
5678 margin = XFASTINT (XCDR (Vtool_bar_button_margin)); 5678 margin = XFASTINT (XCDR (Vtool_bar_button_margin));
5679 else 5679 else
5680 margin = 0; 5680 margin = 0;
5681 5681
5682 bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief; 5682 bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
5683 f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f); 5683 f->height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
5684 } 5684 }
5685 5685
5686 window_prompting = x_figure_window_size (f, parms); 5686 window_prompting = x_figure_window_size (f, parms);
5774 else 5774 else
5775 /* Must have been Qnil. */ 5775 /* Must have been Qnil. */
5776 ; 5776 ;
5777 } 5777 }
5778 UNGCPRO; 5778 UNGCPRO;
5779 5779
5780 /* Make sure windows on this frame appear in calls to next-window 5780 /* Make sure windows on this frame appear in calls to next-window
5781 and similar functions. */ 5781 and similar functions. */
5782 Vwindow_list = Qnil; 5782 Vwindow_list = Qnil;
5783 5783
5784 return unbind_to (count, frame); 5784 return unbind_to (count, frame);
5785 } 5785 }
5786 5786
5787 /* FRAME is used only to get a handle on the X display. We don't pass the 5787 /* FRAME is used only to get a handle on the X display. We don't pass the
5788 display info directly because we're called from frame.c, which doesn't 5788 display info directly because we're called from frame.c, which doesn't
5915 5915
5916 BLOCK_INPUT; 5916 BLOCK_INPUT;
5917 5917
5918 font->hfont = CreateFontIndirect (&lf); 5918 font->hfont = CreateFontIndirect (&lf);
5919 5919
5920 if (font->hfont == NULL) 5920 if (font->hfont == NULL)
5921 { 5921 {
5922 ok = FALSE; 5922 ok = FALSE;
5923 } 5923 }
5924 else 5924 else
5925 { 5925 {
5926 HDC hdc; 5926 HDC hdc;
5927 HANDLE oldobj; 5927 HANDLE oldobj;
5928 5928
5929 codepage = w32_codepage_for_font (fontname); 5929 codepage = w32_codepage_for_font (fontname);
6088 6088
6089 return w32_load_system_font(f, fontname, size); 6089 return w32_load_system_font(f, fontname, size);
6090 } 6090 }
6091 6091
6092 6092
6093 void 6093 void
6094 w32_unload_font (dpyinfo, font) 6094 w32_unload_font (dpyinfo, font)
6095 struct w32_display_info *dpyinfo; 6095 struct w32_display_info *dpyinfo;
6096 XFontStruct * font; 6096 XFontStruct * font;
6097 { 6097 {
6098 if (font) 6098 if (font)
6099 { 6099 {
6100 if (font->per_char) xfree (font->per_char); 6100 if (font->per_char) xfree (font->per_char);
6101 if (font->bdf) w32_free_bdf_font (font->bdf); 6101 if (font->bdf) w32_free_bdf_font (font->bdf);
6102 6102
6103 if (font->hfont) DeleteObject(font->hfont); 6103 if (font->hfont) DeleteObject(font->hfont);
6126 * (registry "[^-]+") 6126 * (registry "[^-]+")
6127 * (encoding "[^-]+") 6127 * (encoding "[^-]+")
6128 * ) 6128 * )
6129 */ 6129 */
6130 6130
6131 static LONG 6131 static LONG
6132 x_to_w32_weight (lpw) 6132 x_to_w32_weight (lpw)
6133 char * lpw; 6133 char * lpw;
6134 { 6134 {
6135 if (!lpw) return (FW_DONTCARE); 6135 if (!lpw) return (FW_DONTCARE);
6136 6136
6147 else 6147 else
6148 return FW_DONTCARE; 6148 return FW_DONTCARE;
6149 } 6149 }
6150 6150
6151 6151
6152 static char * 6152 static char *
6153 w32_to_x_weight (fnweight) 6153 w32_to_x_weight (fnweight)
6154 int fnweight; 6154 int fnweight;
6155 { 6155 {
6156 if (fnweight >= FW_HEAVY) return "heavy"; 6156 if (fnweight >= FW_HEAVY) return "heavy";
6157 if (fnweight >= FW_EXTRABOLD) return "extrabold"; 6157 if (fnweight >= FW_EXTRABOLD) return "extrabold";
6334 default: 6334 default:
6335 /* Encode numerical value of unknown charset. */ 6335 /* Encode numerical value of unknown charset. */
6336 sprintf (buf, "*-#%u", fncharset); 6336 sprintf (buf, "*-#%u", fncharset);
6337 return buf; 6337 return buf;
6338 } 6338 }
6339 6339
6340 { 6340 {
6341 Lisp_Object rest; 6341 Lisp_Object rest;
6342 char * best_match = NULL; 6342 char * best_match = NULL;
6343 6343
6344 /* Look through w32-charset-info-alist for the character set. 6344 /* Look through w32-charset-info-alist for the character set.
6388 { 6388 {
6389 int best_enc = atoi (best_match + 8); 6389 int best_enc = atoi (best_match + 8);
6390 int this_enc = atoi (x_charset + 8); 6390 int this_enc = atoi (x_charset + 8);
6391 if (this_enc > 0 && this_enc < best_enc) 6391 if (this_enc > 0 && this_enc < best_enc)
6392 best_match = x_charset; 6392 best_match = x_charset;
6393 } 6393 }
6394 } 6394 }
6395 } 6395 }
6396 6396
6397 /* If no match, encode the numeric value. */ 6397 /* If no match, encode the numeric value. */
6398 if (!best_match) 6398 if (!best_match)
6495 default: 6495 default:
6496 /* Encode numerical value of unknown charset. */ 6496 /* Encode numerical value of unknown charset. */
6497 sprintf (buf, "*-#%u", fncharset); 6497 sprintf (buf, "*-#%u", fncharset);
6498 return Fcons (build_string (buf), Qnil); 6498 return Fcons (build_string (buf), Qnil);
6499 } 6499 }
6500 6500
6501 { 6501 {
6502 Lisp_Object rest; 6502 Lisp_Object rest;
6503 /* Look through w32-charset-info-alist for the character set. 6503 /* Look through w32-charset-info-alist for the character set.
6504 Only return charsets for codepages which are installed. 6504 Only return charsets for codepages which are installed.
6505 6505
6546 } 6546 }
6547 6547
6548 /* Get the Windows codepage corresponding to the specified font. The 6548 /* Get the Windows codepage corresponding to the specified font. The
6549 charset info in the font name is used to look up 6549 charset info in the font name is used to look up
6550 w32-charset-to-codepage-alist. */ 6550 w32-charset-to-codepage-alist. */
6551 int 6551 int
6552 w32_codepage_for_font (char *fontname) 6552 w32_codepage_for_font (char *fontname)
6553 { 6553 {
6554 Lisp_Object codepage, entry; 6554 Lisp_Object codepage, entry;
6555 char *charset_str, *charset, *end; 6555 char *charset_str, *charset, *end;
6556 6556
6597 else 6597 else
6598 return CP_UNKNOWN; 6598 return CP_UNKNOWN;
6599 } 6599 }
6600 6600
6601 6601
6602 static BOOL 6602 static BOOL
6603 w32_to_x_font (lplogfont, lpxstr, len, specific_charset) 6603 w32_to_x_font (lplogfont, lpxstr, len, specific_charset)
6604 LOGFONT * lplogfont; 6604 LOGFONT * lplogfont;
6605 char * lpxstr; 6605 char * lpxstr;
6606 int len; 6606 int len;
6607 char * specific_charset; 6607 char * specific_charset;
6680 display_resy, /* resy */ 6680 display_resy, /* resy */
6681 ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH) 6681 ((lplogfont->lfPitchAndFamily & 0x3) == VARIABLE_PITCH)
6682 ? 'p' : 'c', /* spacing */ 6682 ? 'p' : 'c', /* spacing */
6683 width_pixels, /* avg width */ 6683 width_pixels, /* avg width */
6684 specific_charset ? specific_charset 6684 specific_charset ? specific_charset
6685 : w32_to_x_charset (lplogfont->lfCharSet) 6685 : w32_to_x_charset (lplogfont->lfCharSet)
6686 /* charset registry and encoding */ 6686 /* charset registry and encoding */
6687 ); 6687 );
6688 6688
6689 lpxstr[len - 1] = 0; /* just to be sure */ 6689 lpxstr[len - 1] = 0; /* just to be sure */
6690 return (TRUE); 6690 return (TRUE);
6691 } 6691 }
6692 6692
6693 static BOOL 6693 static BOOL
6694 x_to_w32_font (lpxstr, lplogfont) 6694 x_to_w32_font (lpxstr, lplogfont)
6695 char * lpxstr; 6695 char * lpxstr;
6696 LOGFONT * lplogfont; 6696 LOGFONT * lplogfont;
6697 { 6697 {
6698 struct coding_system coding; 6698 struct coding_system coding;
6723 /* Provide a simple escape mechanism for specifying Windows font names 6723 /* Provide a simple escape mechanism for specifying Windows font names
6724 * directly -- if font spec does not beginning with '-', assume this 6724 * directly -- if font spec does not beginning with '-', assume this
6725 * format: 6725 * format:
6726 * "<font name>[:height in pixels[:width in pixels[:weight]]]" 6726 * "<font name>[:height in pixels[:width in pixels[:weight]]]"
6727 */ 6727 */
6728 6728
6729 if (*lpxstr == '-') 6729 if (*lpxstr == '-')
6730 { 6730 {
6731 int fields, tem; 6731 int fields, tem;
6732 char name[50], weight[20], slant, pitch, pixels[10], height[10], 6732 char name[50], weight[20], slant, pitch, pixels[10], height[10],
6733 width[10], resy[10], remainder[50]; 6733 width[10], resy[10], remainder[50];
6991 6991
6992 return pixel_height; 6992 return pixel_height;
6993 } 6993 }
6994 6994
6995 /* Assume parameter 1 is fully qualified, no wildcards. */ 6995 /* Assume parameter 1 is fully qualified, no wildcards. */
6996 static BOOL 6996 static BOOL
6997 w32_font_match (fontname, pattern) 6997 w32_font_match (fontname, pattern)
6998 char * fontname; 6998 char * fontname;
6999 char * pattern; 6999 char * pattern;
7000 { 7000 {
7001 char *regex = alloca (strlen (pattern) * 2 + 3); 7001 char *regex = alloca (strlen (pattern) * 2 + 3);
7053 7053
7054 In both cases, there are two passes made. The first pass gets one 7054 In both cases, there are two passes made. The first pass gets one
7055 font from each family, the second pass lists all the fonts from 7055 font from each family, the second pass lists all the fonts from
7056 each family. */ 7056 each family. */
7057 7057
7058 typedef struct enumfont_t 7058 typedef struct enumfont_t
7059 { 7059 {
7060 HDC hdc; 7060 HDC hdc;
7061 int numFonts; 7061 int numFonts;
7062 LOGFONT logfont; 7062 LOGFONT logfont;
7063 XFontStruct *size_ref; 7063 XFontStruct *size_ref;
7068 7068
7069 static void 7069 static void
7070 enum_font_maybe_add_to_list (enumfont_t *, LOGFONT *, char *, Lisp_Object); 7070 enum_font_maybe_add_to_list (enumfont_t *, LOGFONT *, char *, Lisp_Object);
7071 7071
7072 7072
7073 static int CALLBACK 7073 static int CALLBACK
7074 enum_font_cb2 (lplf, lptm, FontType, lpef) 7074 enum_font_cb2 (lplf, lptm, FontType, lpef)
7075 ENUMLOGFONT * lplf; 7075 ENUMLOGFONT * lplf;
7076 NEWTEXTMETRIC * lptm; 7076 NEWTEXTMETRIC * lptm;
7077 int FontType; 7077 int FontType;
7078 enumfont_t * lpef; 7078 enumfont_t * lpef;
7224 } 7224 }
7225 } 7225 }
7226 } 7226 }
7227 7227
7228 7228
7229 static int CALLBACK 7229 static int CALLBACK
7230 enum_font_cb1 (lplf, lptm, FontType, lpef) 7230 enum_font_cb1 (lplf, lptm, FontType, lpef)
7231 ENUMLOGFONT * lplf; 7231 ENUMLOGFONT * lplf;
7232 NEWTEXTMETRIC * lptm; 7232 NEWTEXTMETRIC * lptm;
7233 int FontType; 7233 int FontType;
7234 enumfont_t * lpef; 7234 enumfont_t * lpef;
7411 label_cached: 7411 label_cached:
7412 if (NILP (list)) continue; /* Try the remaining alternatives. */ 7412 if (NILP (list)) continue; /* Try the remaining alternatives. */
7413 7413
7414 newlist = second_best = Qnil; 7414 newlist = second_best = Qnil;
7415 7415
7416 /* Make a list of the fonts that have the right width. */ 7416 /* Make a list of the fonts that have the right width. */
7417 for (; CONSP (list); list = XCDR (list)) 7417 for (; CONSP (list); list = XCDR (list))
7418 { 7418 {
7419 int found_size; 7419 int found_size;
7420 tem = XCAR (list); 7420 tem = XCAR (list);
7421 7421
7473 no exact match is found. */ 7473 no exact match is found. */
7474 else if (found_size > 0) 7474 else if (found_size > 0)
7475 { 7475 {
7476 if (NILP (second_best)) 7476 if (NILP (second_best))
7477 second_best = tem; 7477 second_best = tem;
7478 7478
7479 else if (found_size < size) 7479 else if (found_size < size)
7480 { 7480 {
7481 if (XINT (XCDR (second_best)) > size 7481 if (XINT (XCDR (second_best)) > size
7482 || XINT (XCDR (second_best)) < found_size) 7482 || XINT (XCDR (second_best)) < found_size)
7483 second_best = tem; 7483 second_best = tem;
7759 7759
7760 /* We force 24+ bit depths to 24-bit, both to prevent an overflow 7760 /* We force 24+ bit depths to 24-bit, both to prevent an overflow
7761 and because probably is more meaningful on Windows anyway */ 7761 and because probably is more meaningful on Windows anyway */
7762 if (cap < 0) 7762 if (cap < 0)
7763 cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24); 7763 cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24);
7764 7764
7765 ReleaseDC (dpyinfo->root_window, hdc); 7765 ReleaseDC (dpyinfo->root_window, hdc);
7766 7766
7767 return make_number (cap); 7767 return make_number (cap);
7768 } 7768 }
7769 7769
7770 DEFUN ("x-server-max-request-size", Fx_server_max_request_size, 7770 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
7771 Sx_server_max_request_size, 7771 Sx_server_max_request_size,
7833 struct w32_display_info *dpyinfo = check_x_display_info (display); 7833 struct w32_display_info *dpyinfo = check_x_display_info (display);
7834 HDC hdc; 7834 HDC hdc;
7835 int cap; 7835 int cap;
7836 7836
7837 hdc = GetDC (dpyinfo->root_window); 7837 hdc = GetDC (dpyinfo->root_window);
7838 7838
7839 cap = GetDeviceCaps (hdc, VERTSIZE); 7839 cap = GetDeviceCaps (hdc, VERTSIZE);
7840 7840
7841 ReleaseDC (dpyinfo->root_window, hdc); 7841 ReleaseDC (dpyinfo->root_window, hdc);
7842 7842
7843 return make_number (cap); 7843 return make_number (cap);
7844 } 7844 }
7845 7845
7846 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, 7846 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
7847 doc: /* Returns the width in millimeters of DISPLAY. 7847 doc: /* Returns the width in millimeters of DISPLAY.
7855 7855
7856 HDC hdc; 7856 HDC hdc;
7857 int cap; 7857 int cap;
7858 7858
7859 hdc = GetDC (dpyinfo->root_window); 7859 hdc = GetDC (dpyinfo->root_window);
7860 7860
7861 cap = GetDeviceCaps (hdc, HORZSIZE); 7861 cap = GetDeviceCaps (hdc, HORZSIZE);
7862 7862
7863 ReleaseDC (dpyinfo->root_window, hdc); 7863 ReleaseDC (dpyinfo->root_window, hdc);
7864 7864
7865 return make_number (cap); 7865 return make_number (cap);
7866 } 7866 }
7867 7867
7868 DEFUN ("x-display-backing-store", Fx_display_backing_store, 7868 DEFUN ("x-display-backing-store", Fx_display_backing_store,
7869 Sx_display_backing_store, 0, 1, 0, 7869 Sx_display_backing_store, 0, 1, 0,
8224 int 8224 int
8225 valid_image_p (object) 8225 valid_image_p (object)
8226 Lisp_Object object; 8226 Lisp_Object object;
8227 { 8227 {
8228 int valid_p = 0; 8228 int valid_p = 0;
8229 8229
8230 if (CONSP (object) && EQ (XCAR (object), Qimage)) 8230 if (CONSP (object) && EQ (XCAR (object), Qimage))
8231 { 8231 {
8232 Lisp_Object tem; 8232 Lisp_Object tem;
8233 8233
8234 for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem)) 8234 for (tem = XCDR (object); CONSP (tem); tem = XCDR (tem))
8359 8359
8360 /* Record that we recognized the keyword. If a keywords 8360 /* Record that we recognized the keyword. If a keywords
8361 was found more than once, it's an error. */ 8361 was found more than once, it's an error. */
8362 keywords[i].value = value; 8362 keywords[i].value = value;
8363 ++keywords[i].count; 8363 ++keywords[i].count;
8364 8364
8365 if (keywords[i].count > 1) 8365 if (keywords[i].count > 1)
8366 return 0; 8366 return 0;
8367 8367
8368 /* Check type of value against allowed type. */ 8368 /* Check type of value against allowed type. */
8369 switch (keywords[i].type) 8369 switch (keywords[i].type)
8414 case IMAGE_DONT_CHECK_VALUE_TYPE: 8414 case IMAGE_DONT_CHECK_VALUE_TYPE:
8415 break; 8415 break;
8416 8416
8417 case IMAGE_FUNCTION_VALUE: 8417 case IMAGE_FUNCTION_VALUE:
8418 value = indirect_function (value); 8418 value = indirect_function (value);
8419 if (SUBRP (value) 8419 if (SUBRP (value)
8420 || COMPILEDP (value) 8420 || COMPILEDP (value)
8421 || (CONSP (value) && EQ (XCAR (value), Qlambda))) 8421 || (CONSP (value) && EQ (XCAR (value), Qlambda)))
8422 break; 8422 break;
8423 return 0; 8423 return 0;
8424 8424
8463 image_spec_value (spec, key, found) 8463 image_spec_value (spec, key, found)
8464 Lisp_Object spec, key; 8464 Lisp_Object spec, key;
8465 int *found; 8465 int *found;
8466 { 8466 {
8467 Lisp_Object tail; 8467 Lisp_Object tail;
8468 8468
8469 xassert (valid_image_p (spec)); 8469 xassert (valid_image_p (spec));
8470 8470
8471 for (tail = XCDR (spec); 8471 for (tail = XCDR (spec);
8472 CONSP (tail) && CONSP (XCDR (tail)); 8472 CONSP (tail) && CONSP (XCDR (tail));
8473 tail = XCDR (XCDR (tail))) 8473 tail = XCDR (XCDR (tail)))
8477 if (found) 8477 if (found)
8478 *found = 1; 8478 *found = 1;
8479 return XCAR (XCDR (tail)); 8479 return XCAR (XCDR (tail));
8480 } 8480 }
8481 } 8481 }
8482 8482
8483 if (found) 8483 if (found)
8484 *found = 0; 8484 *found = 0;
8485 return Qnil; 8485 return Qnil;
8486 } 8486 }
8487 8487
8488 8488
8489 DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0, 8489 DEFUN ("image-size", Fimage_size, Simage_size, 1, 3, 0,
8490 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT). 8490 doc: /* Return the size of image SPEC as pair (WIDTH . HEIGHT).
8491 PIXELS non-nil means return the size in pixels, otherwise return the 8491 PIXELS non-nil means return the size in pixels, otherwise return the
8492 size in canonical character units. 8492 size in canonical character units.
8503 struct frame *f = check_x_frame (frame); 8503 struct frame *f = check_x_frame (frame);
8504 int id = lookup_image (f, spec); 8504 int id = lookup_image (f, spec);
8505 struct image *img = IMAGE_FROM_ID (f, id); 8505 struct image *img = IMAGE_FROM_ID (f, id);
8506 int width = img->width + 2 * img->hmargin; 8506 int width = img->width + 2 * img->hmargin;
8507 int height = img->height + 2 * img->vmargin; 8507 int height = img->height + 2 * img->vmargin;
8508 8508
8509 if (NILP (pixels)) 8509 if (NILP (pixels))
8510 size = Fcons (make_float ((double) width / CANON_X_UNIT (f)), 8510 size = Fcons (make_float ((double) width / CANON_X_UNIT (f)),
8511 make_float ((double) height / CANON_Y_UNIT (f))); 8511 make_float ((double) height / CANON_Y_UNIT (f)));
8512 else 8512 else
8513 size = Fcons (make_number (width), make_number (height)); 8513 size = Fcons (make_number (width), make_number (height));
8559 make_image (spec, hash) 8559 make_image (spec, hash)
8560 Lisp_Object spec; 8560 Lisp_Object spec;
8561 unsigned hash; 8561 unsigned hash;
8562 { 8562 {
8563 struct image *img = (struct image *) xmalloc (sizeof *img); 8563 struct image *img = (struct image *) xmalloc (sizeof *img);
8564 8564
8565 xassert (valid_image_p (spec)); 8565 xassert (valid_image_p (spec));
8566 bzero (img, sizeof *img); 8566 bzero (img, sizeof *img);
8567 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL)); 8567 img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
8568 xassert (img->type != NULL); 8568 xassert (img->type != NULL);
8569 img->spec = spec; 8569 img->spec = spec;
8620 /* If IMG doesn't have a pixmap yet, load it now, using the image 8620 /* If IMG doesn't have a pixmap yet, load it now, using the image
8621 type dependent loader function. */ 8621 type dependent loader function. */
8622 if (img->pixmap == 0 && !img->load_failed_p) 8622 if (img->pixmap == 0 && !img->load_failed_p)
8623 img->load_failed_p = img->type->load (f, img) == 0; 8623 img->load_failed_p = img->type->load (f, img) == 0;
8624 } 8624 }
8625 8625
8626 8626
8627 /* Value is the number of pixels for the ascent of image IMG when 8627 /* Value is the number of pixels for the ascent of image IMG when
8628 drawn in face FACE. */ 8628 drawn in face FACE. */
8629 8629
8630 int 8630 int
8671 8671
8672 /* Choose the most frequently found color as background. */ 8672 /* Choose the most frequently found color as background. */
8673 for (i = best_count = 0; i < 4; ++i) 8673 for (i = best_count = 0; i < 4; ++i)
8674 { 8674 {
8675 int j, n; 8675 int j, n;
8676 8676
8677 for (j = n = 0; j < 4; ++j) 8677 for (j = n = 0; j < 4; ++j)
8678 if (corners[i] == corners[j]) 8678 if (corners[i] == corners[j])
8679 ++n; 8679 ++n;
8680 8680
8681 if (n > best_count) 8681 if (n > best_count)
8791 { 8791 {
8792 DeleteObject (img->mask); 8792 DeleteObject (img->mask);
8793 img->mask = NULL; 8793 img->mask = NULL;
8794 img->background_transparent_valid = 0; 8794 img->background_transparent_valid = 0;
8795 } 8795 }
8796 8796
8797 if (colors_p && img->ncolors) 8797 if (colors_p && img->ncolors)
8798 { 8798 {
8799 #if 0 /* TODO: color table support. */ 8799 #if 0 /* TODO: color table support. */
8800 x_free_colors (f, img->colors, img->ncolors); 8800 x_free_colors (f, img->colors, img->ncolors);
8801 #endif 8801 #endif
8823 if (img->ncolors) 8823 if (img->ncolors)
8824 { 8824 {
8825 #if 0 /* TODO: color table support */ 8825 #if 0 /* TODO: color table support */
8826 8826
8827 int class = FRAME_W32_DISPLAY_INFO (f)->visual->class; 8827 int class = FRAME_W32_DISPLAY_INFO (f)->visual->class;
8828 8828
8829 /* If display has an immutable color map, freeing colors is not 8829 /* If display has an immutable color map, freeing colors is not
8830 necessary and some servers don't allow it. So don't do it. */ 8830 necessary and some servers don't allow it. So don't do it. */
8831 if (class != StaticColor 8831 if (class != StaticColor
8832 && class != StaticGray 8832 && class != StaticGray
8833 && class != TrueColor) 8833 && class != TrueColor)
8838 XFreeColors (FRAME_W32_DISPLAY (f), cmap, img->colors, 8838 XFreeColors (FRAME_W32_DISPLAY (f), cmap, img->colors,
8839 img->ncolors, 0); 8839 img->ncolors, 0);
8840 UNBLOCK_INPUT; 8840 UNBLOCK_INPUT;
8841 } 8841 }
8842 #endif 8842 #endif
8843 8843
8844 xfree (img->colors); 8844 xfree (img->colors);
8845 img->colors = NULL; 8845 img->colors = NULL;
8846 img->ncolors = 0; 8846 img->ncolors = 0;
8847 } 8847 }
8848 } 8848 }
8897 struct image_cache * 8897 struct image_cache *
8898 make_image_cache () 8898 make_image_cache ()
8899 { 8899 {
8900 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c); 8900 struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
8901 int size; 8901 int size;
8902 8902
8903 bzero (c, sizeof *c); 8903 bzero (c, sizeof *c);
8904 c->size = 50; 8904 c->size = 50;
8905 c->images = (struct image **) xmalloc (c->size * sizeof *c->images); 8905 c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
8906 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; 8906 size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
8907 c->buckets = (struct image **) xmalloc (size); 8907 c->buckets = (struct image **) xmalloc (size);
8922 { 8922 {
8923 int i; 8923 int i;
8924 8924
8925 /* Cache should not be referenced by any frame when freed. */ 8925 /* Cache should not be referenced by any frame when freed. */
8926 xassert (c->refcount == 0); 8926 xassert (c->refcount == 0);
8927 8927
8928 for (i = 0; i < c->used; ++i) 8928 for (i = 0; i < c->used; ++i)
8929 free_image (f, c->images[i]); 8929 free_image (f, c->images[i]);
8930 xfree (c->images); 8930 xfree (c->images);
8931 xfree (c); 8931 xfree (c);
8932 xfree (c->buckets); 8932 xfree (c->buckets);
8955 unsigned long old; 8955 unsigned long old;
8956 int i, nfreed; 8956 int i, nfreed;
8957 8957
8958 EMACS_GET_TIME (t); 8958 EMACS_GET_TIME (t);
8959 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); 8959 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
8960 8960
8961 /* Block input so that we won't be interrupted by a SIGIO 8961 /* Block input so that we won't be interrupted by a SIGIO
8962 while being in an inconsistent state. */ 8962 while being in an inconsistent state. */
8963 BLOCK_INPUT; 8963 BLOCK_INPUT;
8964 8964
8965 for (i = nfreed = 0; i < c->used; ++i) 8965 for (i = nfreed = 0; i < c->used; ++i)
8966 { 8966 {
8967 struct image *img = c->images[i]; 8967 struct image *img = c->images[i];
8968 if (img != NULL 8968 if (img != NULL
8969 && (force_p || (img->timestamp < old))) 8969 && (force_p || (img->timestamp < old)))
8978 case, current matrices may still contain references to 8978 case, current matrices may still contain references to
8979 images freed above. So, clear these matrices. */ 8979 images freed above. So, clear these matrices. */
8980 if (nfreed) 8980 if (nfreed)
8981 { 8981 {
8982 Lisp_Object tail, frame; 8982 Lisp_Object tail, frame;
8983 8983
8984 FOR_EACH_FRAME (tail, frame) 8984 FOR_EACH_FRAME (tail, frame)
8985 { 8985 {
8986 struct frame *f = XFRAME (frame); 8986 struct frame *f = XFRAME (frame);
8987 if (FRAME_W32_P (f) 8987 if (FRAME_W32_P (f)
8988 && FRAME_X_IMAGE_CACHE (f) == c) 8988 && FRAME_X_IMAGE_CACHE (f) == c)
9006 Lisp_Object frame; 9006 Lisp_Object frame;
9007 { 9007 {
9008 if (EQ (frame, Qt)) 9008 if (EQ (frame, Qt))
9009 { 9009 {
9010 Lisp_Object tail; 9010 Lisp_Object tail;
9011 9011
9012 FOR_EACH_FRAME (tail, frame) 9012 FOR_EACH_FRAME (tail, frame)
9013 if (FRAME_W32_P (XFRAME (frame))) 9013 if (FRAME_W32_P (XFRAME (frame)))
9014 clear_image_cache (XFRAME (frame), 1); 9014 clear_image_cache (XFRAME (frame), 1);
9015 } 9015 }
9016 else 9016 else
9034 { 9034 {
9035 Lisp_Object conversion, spec; 9035 Lisp_Object conversion, spec;
9036 Lisp_Object mask; 9036 Lisp_Object mask;
9037 9037
9038 spec = img->spec; 9038 spec = img->spec;
9039 9039
9040 /* `:heuristic-mask t' 9040 /* `:heuristic-mask t'
9041 `:mask heuristic' 9041 `:mask heuristic'
9042 means build a mask heuristically. 9042 means build a mask heuristically.
9043 `:heuristic-mask (R G B)' 9043 `:heuristic-mask (R G B)'
9044 `:mask (heuristic (R G B))' 9044 `:mask (heuristic (R G B))'
9045 means build a mask from color (R G B) in the 9045 means build a mask from color (R G B) in the
9046 image. 9046 image.
9047 `:mask nil' 9047 `:mask nil'
9048 means remove a mask, if any. */ 9048 means remove a mask, if any. */
9049 9049
9050 mask = image_spec_value (spec, QCheuristic_mask, NULL); 9050 mask = image_spec_value (spec, QCheuristic_mask, NULL);
9051 if (!NILP (mask)) 9051 if (!NILP (mask))
9052 x_build_heuristic_mask (f, img, mask); 9052 x_build_heuristic_mask (f, img, mask);
9053 else 9053 else
9054 { 9054 {
9055 int found_p; 9055 int found_p;
9056 9056
9057 mask = image_spec_value (spec, QCmask, &found_p); 9057 mask = image_spec_value (spec, QCmask, &found_p);
9058 9058
9059 if (EQ (mask, Qheuristic)) 9059 if (EQ (mask, Qheuristic))
9060 x_build_heuristic_mask (f, img, Qt); 9060 x_build_heuristic_mask (f, img, Qt);
9061 else if (CONSP (mask) 9061 else if (CONSP (mask)
9062 && EQ (XCAR (mask), Qheuristic)) 9062 && EQ (XCAR (mask), Qheuristic))
9063 { 9063 {
9070 { 9070 {
9071 DeleteObject (img->mask); 9071 DeleteObject (img->mask);
9072 img->mask = NULL; 9072 img->mask = NULL;
9073 } 9073 }
9074 } 9074 }
9075 9075
9076 9076
9077 /* Should we apply an image transformation algorithm? */ 9077 /* Should we apply an image transformation algorithm? */
9078 conversion = image_spec_value (spec, QCconversion, NULL); 9078 conversion = image_spec_value (spec, QCconversion, NULL);
9079 if (EQ (conversion, Qdisabled)) 9079 if (EQ (conversion, Qdisabled))
9080 x_disable_image (f, img); 9080 x_disable_image (f, img);
9081 else if (EQ (conversion, Qlaplace)) 9081 else if (EQ (conversion, Qlaplace))
9114 9114
9115 /* F must be a window-system frame, and SPEC must be a valid image 9115 /* F must be a window-system frame, and SPEC must be a valid image
9116 specification. */ 9116 specification. */
9117 xassert (FRAME_WINDOW_P (f)); 9117 xassert (FRAME_WINDOW_P (f));
9118 xassert (valid_image_p (spec)); 9118 xassert (valid_image_p (spec));
9119 9119
9120 GCPRO1 (spec); 9120 GCPRO1 (spec);
9121 9121
9122 /* Look up SPEC in the hash table of the image cache. */ 9122 /* Look up SPEC in the hash table of the image cache. */
9123 hash = sxhash (spec, 0); 9123 hash = sxhash (spec, 0);
9124 i = hash % IMAGE_CACHE_BUCKETS_SIZE; 9124 i = hash % IMAGE_CACHE_BUCKETS_SIZE;
9173 if (XINT (XCAR (margin)) > 0) 9173 if (XINT (XCAR (margin)) > 0)
9174 img->hmargin = XFASTINT (XCAR (margin)); 9174 img->hmargin = XFASTINT (XCAR (margin));
9175 if (XINT (XCDR (margin)) > 0) 9175 if (XINT (XCDR (margin)) > 0)
9176 img->vmargin = XFASTINT (XCDR (margin)); 9176 img->vmargin = XFASTINT (XCDR (margin));
9177 } 9177 }
9178 9178
9179 relief = image_spec_value (spec, QCrelief, NULL); 9179 relief = image_spec_value (spec, QCrelief, NULL);
9180 if (INTEGERP (relief)) 9180 if (INTEGERP (relief))
9181 { 9181 {
9182 img->relief = XINT (relief); 9182 img->relief = XINT (relief);
9183 img->hmargin += abs (img->relief); 9183 img->hmargin += abs (img->relief);
9207 } 9207 }
9208 9208
9209 /* We're using IMG, so set its timestamp to `now'. */ 9209 /* We're using IMG, so set its timestamp to `now'. */
9210 EMACS_GET_TIME (now); 9210 EMACS_GET_TIME (now);
9211 img->timestamp = EMACS_SECS (now); 9211 img->timestamp = EMACS_SECS (now);
9212 9212
9213 UNGCPRO; 9213 UNGCPRO;
9214 9214
9215 /* Value is the image id. */ 9215 /* Value is the image id. */
9216 return img->id; 9216 return img->id;
9217 } 9217 }
9218 9218
9219 9219
9434 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path); 9434 search_path = Fcons (Vdata_directory, Vx_bitmap_file_path);
9435 GCPRO2 (file_found, search_path); 9435 GCPRO2 (file_found, search_path);
9436 9436
9437 /* Try to find FILE in data-directory, then x-bitmap-file-path. */ 9437 /* Try to find FILE in data-directory, then x-bitmap-file-path. */
9438 fd = openp (search_path, file, Qnil, &file_found, Qnil); 9438 fd = openp (search_path, file, Qnil, &file_found, Qnil);
9439 9439
9440 if (fd == -1) 9440 if (fd == -1)
9441 file_found = Qnil; 9441 file_found = Qnil;
9442 else 9442 else
9443 close (fd); 9443 close (fd);
9444 9444
9476 { 9476 {
9477 xfree (buf); 9477 xfree (buf);
9478 buf = NULL; 9478 buf = NULL;
9479 } 9479 }
9480 } 9480 }
9481 9481
9482 return buf; 9482 return buf;
9483 } 9483 }
9484 9484
9485 9485
9486 9486
9555 { 9555 {
9556 XBM_TK_IDENT = 256, 9556 XBM_TK_IDENT = 256,
9557 XBM_TK_NUMBER 9557 XBM_TK_NUMBER
9558 }; 9558 };
9559 9559
9560 9560
9561 /* Return non-zero if OBJECT is a valid XBM-type image specification. 9561 /* Return non-zero if OBJECT is a valid XBM-type image specification.
9562 A valid specification is a list starting with the symbol `image' 9562 A valid specification is a list starting with the symbol `image'
9563 The rest of the list is a property list which must contain an 9563 The rest of the list is a property list which must contain an
9564 entry `:type xbm.. 9564 entry `:type xbm..
9565 9565
9590 static int 9590 static int
9591 xbm_image_p (object) 9591 xbm_image_p (object)
9592 Lisp_Object object; 9592 Lisp_Object object;
9593 { 9593 {
9594 struct image_keyword kw[XBM_LAST]; 9594 struct image_keyword kw[XBM_LAST];
9595 9595
9596 bcopy (xbm_format, kw, sizeof kw); 9596 bcopy (xbm_format, kw, sizeof kw);
9597 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm)) 9597 if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
9598 return 0; 9598 return 0;
9599 9599
9600 xassert (EQ (kw[XBM_TYPE].value, Qxbm)); 9600 xassert (EQ (kw[XBM_TYPE].value, Qxbm));
9622 return 0; 9622 return 0;
9623 9623
9624 data = kw[XBM_DATA].value; 9624 data = kw[XBM_DATA].value;
9625 width = XFASTINT (kw[XBM_WIDTH].value); 9625 width = XFASTINT (kw[XBM_WIDTH].value);
9626 height = XFASTINT (kw[XBM_HEIGHT].value); 9626 height = XFASTINT (kw[XBM_HEIGHT].value);
9627 9627
9628 /* Check type of data, and width and height against contents of 9628 /* Check type of data, and width and height against contents of
9629 data. */ 9629 data. */
9630 if (VECTORP (data)) 9630 if (VECTORP (data))
9631 { 9631 {
9632 int i; 9632 int i;
9633 9633
9634 /* Number of elements of the vector must be >= height. */ 9634 /* Number of elements of the vector must be >= height. */
9635 if (XVECTOR (data)->size < height) 9635 if (XVECTOR (data)->size < height)
9636 return 0; 9636 return 0;
9637 9637
9638 /* Each string or bool-vector in data must be large enough 9638 /* Each string or bool-vector in data must be large enough
9698 if (*s >= end) 9698 if (*s >= end)
9699 c = 0; 9699 c = 0;
9700 else if (isdigit (c)) 9700 else if (isdigit (c))
9701 { 9701 {
9702 int value = 0, digit; 9702 int value = 0, digit;
9703 9703
9704 if (c == '0' && *s < end) 9704 if (c == '0' && *s < end)
9705 { 9705 {
9706 c = *(*s)++; 9706 c = *(*s)++;
9707 if (c == 'x' || c == 'X') 9707 if (c == 'x' || c == 'X')
9708 { 9708 {
9836 9836
9837 #define expect(TOKEN) \ 9837 #define expect(TOKEN) \
9838 if (LA1 != (TOKEN)) \ 9838 if (LA1 != (TOKEN)) \
9839 goto failure; \ 9839 goto failure; \
9840 else \ 9840 else \
9841 match () 9841 match ()
9842 9842
9843 #define expect_ident(IDENT) \ 9843 #define expect_ident(IDENT) \
9844 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \ 9844 if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0) \
9845 match (); \ 9845 match (); \
9846 else \ 9846 else \
9879 expect_ident ("static"); 9879 expect_ident ("static");
9880 if (LA1 == XBM_TK_IDENT) 9880 if (LA1 == XBM_TK_IDENT)
9881 { 9881 {
9882 if (strcmp (buffer, "unsigned") == 0) 9882 if (strcmp (buffer, "unsigned") == 0)
9883 { 9883 {
9884 match (); 9884 match ();
9885 expect_ident ("char"); 9885 expect_ident ("char");
9886 } 9886 }
9887 else if (strcmp (buffer, "short") == 0) 9887 else if (strcmp (buffer, "short") == 0)
9888 { 9888 {
9889 match (); 9889 match ();
9894 else if (strcmp (buffer, "char") == 0) 9894 else if (strcmp (buffer, "char") == 0)
9895 match (); 9895 match ();
9896 else 9896 else
9897 goto failure; 9897 goto failure;
9898 } 9898 }
9899 else 9899 else
9900 goto failure; 9900 goto failure;
9901 9901
9902 expect (XBM_TK_IDENT); 9902 expect (XBM_TK_IDENT);
9903 expect ('['); 9903 expect ('[');
9904 expect (']'); 9904 expect (']');
9917 expect (XBM_TK_NUMBER); 9917 expect (XBM_TK_NUMBER);
9918 9918
9919 *p++ = val; 9919 *p++ = val;
9920 if (!padding_p || ((i + 2) % bytes_per_line)) 9920 if (!padding_p || ((i + 2) % bytes_per_line))
9921 *p++ = value >> 8; 9921 *p++ = value >> 8;
9922 9922
9923 if (LA1 == ',' || LA1 == '}') 9923 if (LA1 == ',' || LA1 == '}')
9924 match (); 9924 match ();
9925 else 9925 else
9926 goto failure; 9926 goto failure;
9927 } 9927 }
9930 { 9930 {
9931 for (i = 0; i < nbytes; ++i) 9931 for (i = 0; i < nbytes; ++i)
9932 { 9932 {
9933 int val = value; 9933 int val = value;
9934 expect (XBM_TK_NUMBER); 9934 expect (XBM_TK_NUMBER);
9935 9935
9936 *p++ = val; 9936 *p++ = val;
9937 9937
9938 if (LA1 == ',' || LA1 == '}') 9938 if (LA1 == ',' || LA1 == '}')
9939 match (); 9939 match ();
9940 else 9940 else
9971 char *contents, *end; 9971 char *contents, *end;
9972 { 9972 {
9973 int rc; 9973 int rc;
9974 unsigned char *data; 9974 unsigned char *data;
9975 int success_p = 0; 9975 int success_p = 0;
9976 9976
9977 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data); 9977 rc = xbm_read_bitmap_data (contents, end, &img->width, &img->height, &data);
9978 if (rc) 9978 if (rc)
9979 { 9979 {
9980 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f); 9980 unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
9981 unsigned long background = FRAME_BACKGROUND_PIXEL (f); 9981 unsigned long background = FRAME_BACKGROUND_PIXEL (f);
9982 Lisp_Object value; 9982 Lisp_Object value;
9983 9983
9984 xassert (img->width > 0 && img->height > 0); 9984 xassert (img->width > 0 && img->height > 0);
9985 9985
9986 /* Get foreground and background colors, maybe allocate colors. */ 9986 /* Get foreground and background colors, maybe allocate colors. */
9987 value = image_spec_value (img->spec, QCforeground, NULL); 9987 value = image_spec_value (img->spec, QCforeground, NULL);
9988 if (!NILP (value)) 9988 if (!NILP (value))
10026 (SDATA (data) 10026 (SDATA (data)
10027 + SBYTES (data)), 10027 + SBYTES (data)),
10028 &w, &h, NULL)); 10028 &w, &h, NULL));
10029 } 10029 }
10030 10030
10031 10031
10032 /* Fill image IMG which is used on frame F with pixmap data. Value is 10032 /* Fill image IMG which is used on frame F with pixmap data. Value is
10033 non-zero if successful. */ 10033 non-zero if successful. */
10034 10034
10035 static int 10035 static int
10036 xbm_load (f, img) 10036 xbm_load (f, img)
10118 if (VECTORP (data)) 10118 if (VECTORP (data))
10119 { 10119 {
10120 int i; 10120 int i;
10121 char *p; 10121 char *p;
10122 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR; 10122 int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
10123 10123
10124 p = bits = (char *) alloca (nbytes * img->height); 10124 p = bits = (char *) alloca (nbytes * img->height);
10125 for (i = 0; i < img->height; ++i, p += nbytes) 10125 for (i = 0; i < img->height; ++i, p += nbytes)
10126 { 10126 {
10127 Lisp_Object line = XVECTOR (data)->contents[i]; 10127 Lisp_Object line = XVECTOR (data)->contents[i];
10128 if (STRINGP (line)) 10128 if (STRINGP (line))
10153 } 10153 }
10154 } 10154 }
10155 10155
10156 return success_p; 10156 return success_p;
10157 } 10157 }
10158 10158
10159 10159
10160 10160
10161 /*********************************************************************** 10161 /***********************************************************************
10162 XPM images 10162 XPM images
10163 ***********************************************************************/ 10163 ***********************************************************************/
10164 10164
10165 #if HAVE_XPM 10165 #if HAVE_XPM
10166 10166
10167 static int xpm_image_p P_ ((Lisp_Object object)); 10167 static int xpm_image_p P_ ((Lisp_Object object));
10168 static int xpm_load P_ ((struct frame *f, struct image *img)); 10168 static int xpm_load P_ ((struct frame *f, struct image *img));
10169 static int xpm_valid_color_symbols_p P_ ((Lisp_Object)); 10169 static int xpm_valid_color_symbols_p P_ ((Lisp_Object));
10170 10170
10298 if (CONSP (color_symbols)) 10298 if (CONSP (color_symbols))
10299 { 10299 {
10300 Lisp_Object tail; 10300 Lisp_Object tail;
10301 XpmColorSymbol *xpm_syms; 10301 XpmColorSymbol *xpm_syms;
10302 int i, size; 10302 int i, size;
10303 10303
10304 attrs.valuemask |= XpmColorSymbols; 10304 attrs.valuemask |= XpmColorSymbols;
10305 10305
10306 /* Count number of symbols. */ 10306 /* Count number of symbols. */
10307 attrs.numsymbols = 0; 10307 attrs.numsymbols = 0;
10308 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail)) 10308 for (tail = color_symbols; CONSP (tail); tail = XCDR (tail))
10339 { 10339 {
10340 image_error ("Cannot find image file `%s'", specified_file, Qnil); 10340 image_error ("Cannot find image file `%s'", specified_file, Qnil);
10341 UNBLOCK_INPUT; 10341 UNBLOCK_INPUT;
10342 return 0; 10342 return 0;
10343 } 10343 }
10344 10344
10345 rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f), 10345 rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f),
10346 SDATA (file), &img->pixmap, &img->mask, 10346 SDATA (file), &img->pixmap, &img->mask,
10347 &attrs); 10347 &attrs);
10348 } 10348 }
10349 else 10349 else
10379 switch (rc) 10379 switch (rc)
10380 { 10380 {
10381 case XpmOpenFailed: 10381 case XpmOpenFailed:
10382 image_error ("Error opening XPM file (%s)", img->spec, Qnil); 10382 image_error ("Error opening XPM file (%s)", img->spec, Qnil);
10383 break; 10383 break;
10384 10384
10385 case XpmFileInvalid: 10385 case XpmFileInvalid:
10386 image_error ("Invalid XPM file (%s)", img->spec, Qnil); 10386 image_error ("Invalid XPM file (%s)", img->spec, Qnil);
10387 break; 10387 break;
10388 10388
10389 case XpmNoMemory: 10389 case XpmNoMemory:
10390 image_error ("Out of memory (%s)", img->spec, Qnil); 10390 image_error ("Out of memory (%s)", img->spec, Qnil);
10391 break; 10391 break;
10392 10392
10393 case XpmColorFailed: 10393 case XpmColorFailed:
10394 image_error ("Color allocation error (%s)", img->spec, Qnil); 10394 image_error ("Color allocation error (%s)", img->spec, Qnil);
10395 break; 10395 break;
10396 10396
10397 default: 10397 default:
10398 image_error ("Unknown error (%s)", img->spec, Qnil); 10398 image_error ("Unknown error (%s)", img->spec, Qnil);
10399 break; 10399 break;
10400 } 10400 }
10401 } 10401 }
10540 XColor color; 10540 XColor color;
10541 Colormap cmap; 10541 Colormap cmap;
10542 int rc; 10542 int rc;
10543 10543
10544 BLOCK_INPUT; 10544 BLOCK_INPUT;
10545 10545
10546 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); 10546 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
10547 color.pixel = pixel; 10547 color.pixel = pixel;
10548 XQueryColor (NULL, cmap, &color); 10548 XQueryColor (NULL, cmap, &color);
10549 rc = x_alloc_nearest_color (f, cmap, &color); 10549 rc = x_alloc_nearest_color (f, cmap, &color);
10550 UNBLOCK_INPUT; 10550 UNBLOCK_INPUT;
10551 10551
10552 if (rc) 10552 if (rc)
10553 { 10553 {
10554 ++ct_colors_allocated; 10554 ++ct_colors_allocated;
10555 10555
10556 p = (struct ct_color *) xmalloc (sizeof *p); 10556 p = (struct ct_color *) xmalloc (sizeof *p);
10557 p->r = color.red; 10557 p->r = color.red;
10558 p->g = color.green; 10558 p->g = color.green;
10559 p->b = color.blue; 10559 p->b = color.blue;
10560 p->pixel = pixel; 10560 p->pixel = pixel;
10587 else 10587 else
10588 { 10588 {
10589 colors = (unsigned long *) xmalloc (ct_colors_allocated 10589 colors = (unsigned long *) xmalloc (ct_colors_allocated
10590 * sizeof *colors); 10590 * sizeof *colors);
10591 *n = ct_colors_allocated; 10591 *n = ct_colors_allocated;
10592 10592
10593 for (i = j = 0; i < CT_SIZE; ++i) 10593 for (i = j = 0; i < CT_SIZE; ++i)
10594 for (p = ct_table[i]; p; p = p->next) 10594 for (p = ct_table[i]; p; p = p->next)
10595 colors[j++] = p->pixel; 10595 colors[j++] = p->pixel;
10596 } 10596 }
10597 10597
10663 were an easy and portable way to circumvent XGetPixel. */ 10663 were an easy and portable way to circumvent XGetPixel. */
10664 p = colors; 10664 p = colors;
10665 for (y = 0; y < img->height; ++y) 10665 for (y = 0; y < img->height; ++y)
10666 { 10666 {
10667 XColor *row = p; 10667 XColor *row = p;
10668 10668
10669 for (x = 0; x < img->width; ++x, ++p) 10669 for (x = 0; x < img->width; ++x, ++p)
10670 p->pixel = XGetPixel (ximg, x, y); 10670 p->pixel = XGetPixel (ximg, x, y);
10671 10671
10672 if (rgb_p) 10672 if (rgb_p)
10673 x_query_colors (f, row, img->width); 10673 x_query_colors (f, row, img->width);
10753 10753
10754 /* On frame F, perform edge-detection on image IMG. 10754 /* On frame F, perform edge-detection on image IMG.
10755 10755
10756 MATRIX is a nine-element array specifying the transformation 10756 MATRIX is a nine-element array specifying the transformation
10757 matrix. See emboss_matrix for an example. 10757 matrix. See emboss_matrix for an example.
10758 10758
10759 COLOR_ADJUST is a color adjustment added to each pixel of the 10759 COLOR_ADJUST is a color adjustment added to each pixel of the
10760 outgoing image. */ 10760 outgoing image. */
10761 10761
10762 static void 10762 static void
10763 x_detect_edges (f, img, matrix, color_adjust) 10763 x_detect_edges (f, img, matrix, color_adjust)
10781 p = COLOR (new, 0, y); 10781 p = COLOR (new, 0, y);
10782 p->red = p->green = p->blue = 0xffff/2; 10782 p->red = p->green = p->blue = 0xffff/2;
10783 p = COLOR (new, img->width - 1, y); 10783 p = COLOR (new, img->width - 1, y);
10784 p->red = p->green = p->blue = 0xffff/2; 10784 p->red = p->green = p->blue = 0xffff/2;
10785 } 10785 }
10786 10786
10787 for (x = 1; x < img->width - 1; ++x) 10787 for (x = 1; x < img->width - 1; ++x)
10788 { 10788 {
10789 p = COLOR (new, x, 0); 10789 p = COLOR (new, x, 0);
10790 p->red = p->green = p->blue = 0xffff/2; 10790 p->red = p->green = p->blue = 0xffff/2;
10791 p = COLOR (new, x, img->height - 1); 10791 p = COLOR (new, x, img->height - 1);
10793 } 10793 }
10794 10794
10795 for (y = 1; y < img->height - 1; ++y) 10795 for (y = 1; y < img->height - 1; ++y)
10796 { 10796 {
10797 p = COLOR (new, 1, y); 10797 p = COLOR (new, 1, y);
10798 10798
10799 for (x = 1; x < img->width - 1; ++x, ++p) 10799 for (x = 1; x < img->width - 1; ++x, ++p)
10800 { 10800 {
10801 int r, g, b, y1, x1; 10801 int r, g, b, y1, x1;
10802 10802
10803 r = g = b = i = 0; 10803 r = g = b = i = 0;
10867 struct image *img; 10867 struct image *img;
10868 Lisp_Object matrix, color_adjust; 10868 Lisp_Object matrix, color_adjust;
10869 { 10869 {
10870 int i = 0; 10870 int i = 0;
10871 int trans[9]; 10871 int trans[9];
10872 10872
10873 if (CONSP (matrix)) 10873 if (CONSP (matrix))
10874 { 10874 {
10875 for (i = 0; 10875 for (i = 0;
10876 i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix)); 10876 i < 9 && CONSP (matrix) && NUMBERP (XCAR (matrix));
10877 ++i, matrix = XCDR (matrix)) 10877 ++i, matrix = XCDR (matrix))
10990 ~0, ZPixmap); 10990 ~0, ZPixmap);
10991 10991
10992 /* Determine the background color of ximg. If HOW is `(R G B)' 10992 /* Determine the background color of ximg. If HOW is `(R G B)'
10993 take that as color. Otherwise, use the image's background color. */ 10993 take that as color. Otherwise, use the image's background color. */
10994 use_img_background = 1; 10994 use_img_background = 1;
10995 10995
10996 if (CONSP (how)) 10996 if (CONSP (how))
10997 { 10997 {
10998 int rgb[3], i; 10998 int rgb[3], i;
10999 10999
11000 for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i) 11000 for (i = 0; i < 3 && CONSP (how) && NATNUMP (XCAR (how)); ++i)
11009 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]); 11009 sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
11010 bg = x_alloc_image_color (f, img, build_string (color_name), 0); 11010 bg = x_alloc_image_color (f, img, build_string (color_name), 0);
11011 use_img_background = 0; 11011 use_img_background = 0;
11012 } 11012 }
11013 } 11013 }
11014 11014
11015 if (use_img_background) 11015 if (use_img_background)
11016 bg = four_corners_best (ximg, img->width, img->height); 11016 bg = four_corners_best (ximg, img->width, img->height);
11017 11017
11018 /* Set all bits in mask_img to 1 whose color in ximg is different 11018 /* Set all bits in mask_img to 1 whose color in ximg is different
11019 from the background color bg. */ 11019 from the background color bg. */
11101 static int 11101 static int
11102 pbm_image_p (object) 11102 pbm_image_p (object)
11103 Lisp_Object object; 11103 Lisp_Object object;
11104 { 11104 {
11105 struct image_keyword fmt[PBM_LAST]; 11105 struct image_keyword fmt[PBM_LAST];
11106 11106
11107 bcopy (pbm_format, fmt, sizeof fmt); 11107 bcopy (pbm_format, fmt, sizeof fmt);
11108 11108
11109 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm) 11109 if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)
11110 || (fmt[PBM_ASCENT].count 11110 || (fmt[PBM_ASCENT].count
11111 && XFASTINT (fmt[PBM_ASCENT].value) > 100)) 11111 && XFASTINT (fmt[PBM_ASCENT].value) > 100))
11112 return 0; 11112 return 0;
11113 11113
11114 /* Must specify either :data or :file. */ 11114 /* Must specify either :data or :file. */
11115 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1; 11115 return fmt[PBM_DATA].count + fmt[PBM_FILE].count == 1;
11183 { 11183 {
11184 xfree (buf); 11184 xfree (buf);
11185 buf = NULL; 11185 buf = NULL;
11186 } 11186 }
11187 } 11187 }
11188 11188
11189 return buf; 11189 return buf;
11190 } 11190 }
11191 11191
11192 11192
11193 /* Load PBM image IMG for use on frame F. */ 11193 /* Load PBM image IMG for use on frame F. */
11194 11194
11195 static int 11195 static int
11196 pbm_load (f, img) 11196 pbm_load (f, img)
11197 struct frame *f; 11197 struct frame *f;
11198 struct image *img; 11198 struct image *img;
11199 { 11199 {
11200 int raw_p, x, y; 11200 int raw_p, x, y;
11253 switch (*p++) 11253 switch (*p++)
11254 { 11254 {
11255 case '1': 11255 case '1':
11256 raw_p = 0, type = PBM_MONO; 11256 raw_p = 0, type = PBM_MONO;
11257 break; 11257 break;
11258 11258
11259 case '2': 11259 case '2':
11260 raw_p = 0, type = PBM_GRAY; 11260 raw_p = 0, type = PBM_GRAY;
11261 break; 11261 break;
11262 11262
11263 case '3': 11263 case '3':
11265 break; 11265 break;
11266 11266
11267 case '4': 11267 case '4':
11268 raw_p = 1, type = PBM_MONO; 11268 raw_p = 1, type = PBM_MONO;
11269 break; 11269 break;
11270 11270
11271 case '5': 11271 case '5':
11272 raw_p = 1, type = PBM_GRAY; 11272 raw_p = 1, type = PBM_GRAY;
11273 break; 11273 break;
11274 11274
11275 case '6': 11275 case '6':
11276 raw_p = 1, type = PBM_COLOR; 11276 raw_p = 1, type = PBM_COLOR;
11277 break; 11277 break;
11278 11278
11279 default: 11279 default:
11290 { 11290 {
11291 max_color_idx = pbm_scan_number (&p, end); 11291 max_color_idx = pbm_scan_number (&p, end);
11292 if (raw_p && max_color_idx > 255) 11292 if (raw_p && max_color_idx > 255)
11293 max_color_idx = 255; 11293 max_color_idx = 255;
11294 } 11294 }
11295 11295
11296 if (width < 0 11296 if (width < 0
11297 || height < 0 11297 || height < 0
11298 || (type != PBM_MONO && max_color_idx < 0)) 11298 || (type != PBM_MONO && max_color_idx < 0))
11299 goto error; 11299 goto error;
11300 11300
11314 unsigned long bg = FRAME_BACKGROUND_PIXEL (f); 11314 unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
11315 11315
11316 /* Parse the image specification. */ 11316 /* Parse the image specification. */
11317 bcopy (pbm_format, fmt, sizeof fmt); 11317 bcopy (pbm_format, fmt, sizeof fmt);
11318 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm); 11318 parse_image_spec (img->spec, fmt, PBM_LAST, Qpbm);
11319 11319
11320 /* Get foreground and background colors, maybe allocate colors. */ 11320 /* Get foreground and background colors, maybe allocate colors. */
11321 if (fmt[PBM_FOREGROUND].count 11321 if (fmt[PBM_FOREGROUND].count
11322 && STRINGP (fmt[PBM_FOREGROUND].value)) 11322 && STRINGP (fmt[PBM_FOREGROUND].value))
11323 fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg); 11323 fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
11324 if (fmt[PBM_BACKGROUND].count 11324 if (fmt[PBM_BACKGROUND].count
11349 { 11349 {
11350 for (y = 0; y < height; ++y) 11350 for (y = 0; y < height; ++y)
11351 for (x = 0; x < width; ++x) 11351 for (x = 0; x < width; ++x)
11352 { 11352 {
11353 int r, g, b; 11353 int r, g, b;
11354 11354
11355 if (type == PBM_GRAY) 11355 if (type == PBM_GRAY)
11356 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end); 11356 r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
11357 else if (raw_p) 11357 else if (raw_p)
11358 { 11358 {
11359 r = *p++; 11359 r = *p++;
11364 { 11364 {
11365 r = pbm_scan_number (&p, end); 11365 r = pbm_scan_number (&p, end);
11366 g = pbm_scan_number (&p, end); 11366 g = pbm_scan_number (&p, end);
11367 b = pbm_scan_number (&p, end); 11367 b = pbm_scan_number (&p, end);
11368 } 11368 }
11369 11369
11370 if (r < 0 || g < 0 || b < 0) 11370 if (r < 0 || g < 0 || b < 0)
11371 { 11371 {
11372 x_destroy_x_image (ximg); 11372 x_destroy_x_image (ximg);
11373 image_error ("Invalid pixel value in image `%s'", 11373 image_error ("Invalid pixel value in image `%s'",
11374 img->spec, Qnil); 11374 img->spec, Qnil);
11375 goto error; 11375 goto error;
11376 } 11376 }
11377 11377
11378 /* RGB values are now in the range 0..max_color_idx. 11378 /* RGB values are now in the range 0..max_color_idx.
11379 Scale this to the range 0..0xff supported by W32. */ 11379 Scale this to the range 0..0xff supported by W32. */
11380 r = (int) ((double) r * 255 / max_color_idx); 11380 r = (int) ((double) r * 255 / max_color_idx);
11381 g = (int) ((double) g * 255 / max_color_idx); 11381 g = (int) ((double) g * 255 / max_color_idx);
11382 b = (int) ((double) b * 255 / max_color_idx); 11382 b = (int) ((double) b * 255 / max_color_idx);
11396 free_color_table (); 11396 free_color_table ();
11397 #endif 11397 #endif
11398 /* Maybe fill in the background field while we have ximg handy. */ 11398 /* Maybe fill in the background field while we have ximg handy. */
11399 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 11399 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
11400 IMAGE_BACKGROUND (img, f, ximg); 11400 IMAGE_BACKGROUND (img, f, ximg);
11401 11401
11402 /* Put the image into a pixmap. */ 11402 /* Put the image into a pixmap. */
11403 x_put_x_image (f, ximg, img->pixmap, width, height); 11403 x_put_x_image (f, ximg, img->pixmap, width, height);
11404 x_destroy_x_image (ximg); 11404 x_destroy_x_image (ximg);
11405 11405
11406 img->width = width; 11406 img->width = width;
11407 img->height = height; 11407 img->height = height;
11408 11408
11409 UNGCPRO; 11409 UNGCPRO;
11410 xfree (contents); 11410 xfree (contents);
11481 png_image_p (object) 11481 png_image_p (object)
11482 Lisp_Object object; 11482 Lisp_Object object;
11483 { 11483 {
11484 struct image_keyword fmt[PNG_LAST]; 11484 struct image_keyword fmt[PNG_LAST];
11485 bcopy (png_format, fmt, sizeof fmt); 11485 bcopy (png_format, fmt, sizeof fmt);
11486 11486
11487 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng) 11487 if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)
11488 || (fmt[PNG_ASCENT].count 11488 || (fmt[PNG_ASCENT].count
11489 && XFASTINT (fmt[PNG_ASCENT].value) > 100)) 11489 && XFASTINT (fmt[PNG_ASCENT].value) > 100))
11490 return 0; 11490 return 0;
11491 11491
11492 /* Must specify either the :data or :file keyword. */ 11492 /* Must specify either the :data or :file keyword. */
11493 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1; 11493 return fmt[PNG_FILE].count + fmt[PNG_DATA].count == 1;
11540 struct png_memory_storage *tbr 11540 struct png_memory_storage *tbr
11541 = (struct png_memory_storage *) png_get_io_ptr (png_ptr); 11541 = (struct png_memory_storage *) png_get_io_ptr (png_ptr);
11542 11542
11543 if (length > tbr->len - tbr->index) 11543 if (length > tbr->len - tbr->index)
11544 png_error (png_ptr, "Read error"); 11544 png_error (png_ptr, "Read error");
11545 11545
11546 bcopy (tbr->bytes + tbr->index, data, length); 11546 bcopy (tbr->bytes + tbr->index, data, length);
11547 tbr->index = tbr->index + length; 11547 tbr->index = tbr->index + length;
11548 } 11548 }
11549 11549
11550 /* Load PNG image IMG for use on frame F. Value is non-zero if 11550 /* Load PNG image IMG for use on frame F. Value is non-zero if
11683 png_set_sig_bytes (png_ptr, sizeof sig); 11683 png_set_sig_bytes (png_ptr, sizeof sig);
11684 png_read_info (png_ptr, info_ptr); 11684 png_read_info (png_ptr, info_ptr);
11685 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 11685 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
11686 &interlace_type, NULL, NULL); 11686 &interlace_type, NULL, NULL);
11687 11687
11688 /* If image contains simply transparency data, we prefer to 11688 /* If image contains simply transparency data, we prefer to
11689 construct a clipping mask. */ 11689 construct a clipping mask. */
11690 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) 11690 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
11691 transparent_p = 1; 11691 transparent_p = 1;
11692 else 11692 else
11693 transparent_p = 0; 11693 transparent_p = 0;
11694 11694
11695 /* This function is easier to write if we only have to handle 11695 /* This function is easier to write if we only have to handle
11696 one data format: RGB or RGBA with 8 bits per channel. Let's 11696 one data format: RGB or RGBA with 8 bits per channel. Let's
11697 transform other formats into that format. */ 11697 transform other formats into that format. */
11698 11698
11699 /* Strip more than 8 bits per channel. */ 11699 /* Strip more than 8 bits per channel. */
11700 if (bit_depth == 16) 11700 if (bit_depth == 16)
11703 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel 11703 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel
11704 if available. */ 11704 if available. */
11705 png_set_expand (png_ptr); 11705 png_set_expand (png_ptr);
11706 11706
11707 /* Convert grayscale images to RGB. */ 11707 /* Convert grayscale images to RGB. */
11708 if (color_type == PNG_COLOR_TYPE_GRAY 11708 if (color_type == PNG_COLOR_TYPE_GRAY
11709 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) 11709 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
11710 png_set_gray_to_rgb (png_ptr); 11710 png_set_gray_to_rgb (png_ptr);
11711 11711
11712 /* The value 2.2 is a guess for PC monitors from PNG example.c. */ 11712 /* The value 2.2 is a guess for PC monitors from PNG example.c. */
11713 gamma_str = getenv ("SCREEN_GAMMA"); 11713 gamma_str = getenv ("SCREEN_GAMMA");
11754 png_set_background (png_ptr, &user_bg, 11754 png_set_background (png_ptr, &user_bg,
11755 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); 11755 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0);
11756 } 11756 }
11757 } 11757 }
11758 else if (png_get_bKGD (png_ptr, info_ptr, &image_background)) 11758 else if (png_get_bKGD (png_ptr, info_ptr, &image_background))
11759 /* Image contains a background color with which to 11759 /* Image contains a background color with which to
11760 combine the image. */ 11760 combine the image. */
11761 png_set_background (png_ptr, image_background, 11761 png_set_background (png_ptr, image_background,
11762 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); 11762 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
11763 else 11763 else
11764 { 11764 {
11765 /* Image does not contain a background color with which 11765 /* Image does not contain a background color with which
11766 to combine the image data via an alpha channel. Use 11766 to combine the image data via an alpha channel. Use
11767 the frame's background instead. */ 11767 the frame's background instead. */
11768 XColor color; 11768 XColor color;
11769 Colormap cmap; 11769 Colormap cmap;
11770 png_color_16 frame_background; 11770 png_color_16 frame_background;
11771 11771
11814 11814
11815 /* Create the X image and pixmap. */ 11815 /* Create the X image and pixmap. */
11816 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, 11816 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg,
11817 &img->pixmap)) 11817 &img->pixmap))
11818 goto error; 11818 goto error;
11819 11819
11820 /* Create an image and pixmap serving as mask if the PNG image 11820 /* Create an image and pixmap serving as mask if the PNG image
11821 contains an alpha channel. */ 11821 contains an alpha channel. */
11822 if (channels == 4 11822 if (channels == 4
11823 && !transparent_p 11823 && !transparent_p
11824 && !x_create_x_image_and_pixmap (f, width, height, 1, 11824 && !x_create_x_image_and_pixmap (f, width, height, 1,
11845 g = *p++ << 8; 11845 g = *p++ << 8;
11846 b = *p++ << 8; 11846 b = *p++ << 8;
11847 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b)); 11847 XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
11848 11848
11849 /* An alpha channel, aka mask channel, associates variable 11849 /* An alpha channel, aka mask channel, associates variable
11850 transparency with an image. Where other image formats 11850 transparency with an image. Where other image formats
11851 support binary transparency---fully transparent or fully 11851 support binary transparency---fully transparent or fully
11852 opaque---PNG allows up to 254 levels of partial transparency. 11852 opaque---PNG allows up to 254 levels of partial transparency.
11853 The PNG library implements partial transparency by combining 11853 The PNG library implements partial transparency by combining
11854 the image with a specified background color. 11854 the image with a specified background color.
11855 11855
11856 I'm not sure how to handle this here nicely: because the 11856 I'm not sure how to handle this here nicely: because the
11857 background on which the image is displayed may change, for 11857 background on which the image is displayed may change, for
11858 real alpha channel support, it would be necessary to create 11858 real alpha channel support, it would be necessary to create
11859 a new image for each possible background. 11859 a new image for each possible background.
11860 11860
11861 What I'm doing now is that a mask is created if we have 11861 What I'm doing now is that a mask is created if we have
11862 boolean transparency information. Otherwise I'm using 11862 boolean transparency information. Otherwise I'm using
11863 the frame's background color to combine the image with. */ 11863 the frame's background color to combine the image with. */
11864 11864
12000 static int 12000 static int
12001 jpeg_image_p (object) 12001 jpeg_image_p (object)
12002 Lisp_Object object; 12002 Lisp_Object object;
12003 { 12003 {
12004 struct image_keyword fmt[JPEG_LAST]; 12004 struct image_keyword fmt[JPEG_LAST];
12005 12005
12006 bcopy (jpeg_format, fmt, sizeof fmt); 12006 bcopy (jpeg_format, fmt, sizeof fmt);
12007 12007
12008 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg) 12008 if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)
12009 || (fmt[JPEG_ASCENT].count 12009 || (fmt[JPEG_ASCENT].count
12010 && XFASTINT (fmt[JPEG_ASCENT].value) > 100)) 12010 && XFASTINT (fmt[JPEG_ASCENT].value) > 100))
12011 return 0; 12011 return 0;
12012 12012
12013 /* Must specify either the :data or :file keyword. */ 12013 /* Must specify either the :data or :file keyword. */
12014 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1; 12014 return fmt[JPEG_FILE].count + fmt[JPEG_DATA].count == 1;
12073 12073
12074 if (src) 12074 if (src)
12075 { 12075 {
12076 if (num_bytes > src->bytes_in_buffer) 12076 if (num_bytes > src->bytes_in_buffer)
12077 ERREXIT (cinfo, JERR_INPUT_EOF); 12077 ERREXIT (cinfo, JERR_INPUT_EOF);
12078 12078
12079 src->bytes_in_buffer -= num_bytes; 12079 src->bytes_in_buffer -= num_bytes;
12080 src->next_input_byte += num_bytes; 12080 src->next_input_byte += num_bytes;
12081 } 12081 }
12082 } 12082 }
12083 12083
12111 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 12111 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
12112 sizeof (struct jpeg_source_mgr)); 12112 sizeof (struct jpeg_source_mgr));
12113 src = (struct jpeg_source_mgr *) cinfo->src; 12113 src = (struct jpeg_source_mgr *) cinfo->src;
12114 src->next_input_byte = data; 12114 src->next_input_byte = data;
12115 } 12115 }
12116 12116
12117 src = (struct jpeg_source_mgr *) cinfo->src; 12117 src = (struct jpeg_source_mgr *) cinfo->src;
12118 src->init_source = our_init_source; 12118 src->init_source = our_init_source;
12119 src->fill_input_buffer = our_fill_input_buffer; 12119 src->fill_input_buffer = our_fill_input_buffer;
12120 src->skip_input_data = our_skip_input_data; 12120 src->skip_input_data = our_skip_input_data;
12121 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */ 12121 src->resync_to_restart = jpeg_resync_to_restart; /* Use default method. */
12126 12126
12127 12127
12128 /* Load image IMG for use on frame F. Patterned after example.c 12128 /* Load image IMG for use on frame F. Patterned after example.c
12129 from the JPEG lib. */ 12129 from the JPEG lib. */
12130 12130
12131 static int 12131 static int
12132 jpeg_load (f, img) 12132 jpeg_load (f, img)
12133 struct frame *f; 12133 struct frame *f;
12134 struct image *img; 12134 struct image *img;
12135 { 12135 {
12136 struct jpeg_decompress_struct cinfo; 12136 struct jpeg_decompress_struct cinfo;
12159 { 12159 {
12160 image_error ("Cannot find image file `%s'", specified_file, Qnil); 12160 image_error ("Cannot find image file `%s'", specified_file, Qnil);
12161 UNGCPRO; 12161 UNGCPRO;
12162 return 0; 12162 return 0;
12163 } 12163 }
12164 12164
12165 fp = fopen (SDATA (file), "r"); 12165 fp = fopen (SDATA (file), "r");
12166 if (fp == NULL) 12166 if (fp == NULL)
12167 { 12167 {
12168 image_error ("Cannot open `%s'", file, Qnil); 12168 image_error ("Cannot open `%s'", file, Qnil);
12169 UNGCPRO; 12169 UNGCPRO;
12170 return 0; 12170 return 0;
12171 } 12171 }
12172 } 12172 }
12173 12173
12174 /* Customize libjpeg's error handling to call my_error_exit when an 12174 /* Customize libjpeg's error handling to call my_error_exit when an
12175 error is detected. This function will perform a longjmp. */ 12175 error is detected. This function will perform a longjmp. */
12176 cinfo.err = jpeg_std_error (&mgr.pub); 12176 cinfo.err = jpeg_std_error (&mgr.pub);
12177 mgr.pub.error_exit = my_error_exit; 12177 mgr.pub.error_exit = my_error_exit;
12178 12178
12179 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 12179 if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
12180 { 12180 {
12181 if (rc == 1) 12181 if (rc == 1)
12182 { 12182 {
12183 /* Called from my_error_exit. Display a JPEG error. */ 12183 /* Called from my_error_exit. Display a JPEG error. */
12184 char buffer[JMSG_LENGTH_MAX]; 12184 char buffer[JMSG_LENGTH_MAX];
12185 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer); 12185 cinfo.err->format_message ((j_common_ptr) &cinfo, buffer);
12186 image_error ("Error reading JPEG image `%s': %s", img->spec, 12186 image_error ("Error reading JPEG image `%s': %s", img->spec,
12187 build_string (buffer)); 12187 build_string (buffer));
12188 } 12188 }
12189 12189
12190 /* Close the input file and destroy the JPEG object. */ 12190 /* Close the input file and destroy the JPEG object. */
12191 if (fp) 12191 if (fp)
12192 fclose (fp); 12192 fclose (fp);
12193 jpeg_destroy_decompress (&cinfo); 12193 jpeg_destroy_decompress (&cinfo);
12194 12194
12195 /* If we already have an XImage, free that. */ 12195 /* If we already have an XImage, free that. */
12196 x_destroy_x_image (ximg); 12196 x_destroy_x_image (ximg);
12197 12197
12198 /* Free pixmap and colors. */ 12198 /* Free pixmap and colors. */
12199 x_clear_image (f, img); 12199 x_clear_image (f, img);
12200 12200
12201 UNGCPRO; 12201 UNGCPRO;
12202 return 0; 12202 return 0;
12203 } 12203 }
12204 12204
12205 /* Create the JPEG decompression object. Let it read from fp. 12205 /* Create the JPEG decompression object. Let it read from fp.
12246 a default color, and we don't have to care about which colors 12246 a default color, and we don't have to care about which colors
12247 can be freed safely, and which can't. */ 12247 can be freed safely, and which can't. */
12248 init_color_table (); 12248 init_color_table ();
12249 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors 12249 colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
12250 * sizeof *colors); 12250 * sizeof *colors);
12251 12251
12252 for (i = 0; i < cinfo.actual_number_of_colors; ++i) 12252 for (i = 0; i < cinfo.actual_number_of_colors; ++i)
12253 { 12253 {
12254 /* Multiply RGB values with 255 because X expects RGB values 12254 /* Multiply RGB values with 255 because X expects RGB values
12255 in the range 0..0xffff. */ 12255 in the range 0..0xffff. */
12256 int r = cinfo.colormap[ir][i] << 8; 12256 int r = cinfo.colormap[ir][i] << 8;
12278 /* Clean up. */ 12278 /* Clean up. */
12279 jpeg_finish_decompress (&cinfo); 12279 jpeg_finish_decompress (&cinfo);
12280 jpeg_destroy_decompress (&cinfo); 12280 jpeg_destroy_decompress (&cinfo);
12281 if (fp) 12281 if (fp)
12282 fclose (fp); 12282 fclose (fp);
12283 12283
12284 /* Maybe fill in the background field while we have ximg handy. */ 12284 /* Maybe fill in the background field while we have ximg handy. */
12285 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 12285 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
12286 IMAGE_BACKGROUND (img, f, ximg); 12286 IMAGE_BACKGROUND (img, f, ximg);
12287 12287
12288 /* Put the image into the pixmap. */ 12288 /* Put the image into the pixmap. */
12289 x_put_x_image (f, ximg, img->pixmap, width, height); 12289 x_put_x_image (f, ximg, img->pixmap, width, height);
12290 x_destroy_x_image (ximg); 12290 x_destroy_x_image (ximg);
12291 UNBLOCK_INPUT; 12291 UNBLOCK_INPUT;
12292 UNGCPRO; 12292 UNGCPRO;
12364 tiff_image_p (object) 12364 tiff_image_p (object)
12365 Lisp_Object object; 12365 Lisp_Object object;
12366 { 12366 {
12367 struct image_keyword fmt[TIFF_LAST]; 12367 struct image_keyword fmt[TIFF_LAST];
12368 bcopy (tiff_format, fmt, sizeof fmt); 12368 bcopy (tiff_format, fmt, sizeof fmt);
12369 12369
12370 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff) 12370 if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)
12371 || (fmt[TIFF_ASCENT].count 12371 || (fmt[TIFF_ASCENT].count
12372 && XFASTINT (fmt[TIFF_ASCENT].value) > 100)) 12372 && XFASTINT (fmt[TIFF_ASCENT].value) > 100))
12373 return 0; 12373 return 0;
12374 12374
12375 /* Must specify either the :data or :file keyword. */ 12375 /* Must specify either the :data or :file keyword. */
12376 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1; 12376 return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
12377 } 12377 }
12378 12378
12379 12379
12430 switch (whence) 12430 switch (whence)
12431 { 12431 {
12432 case SEEK_SET: /* Go from beginning of source. */ 12432 case SEEK_SET: /* Go from beginning of source. */
12433 idx = off; 12433 idx = off;
12434 break; 12434 break;
12435 12435
12436 case SEEK_END: /* Go from end of source. */ 12436 case SEEK_END: /* Go from end of source. */
12437 idx = src->len + off; 12437 idx = src->len + off;
12438 break; 12438 break;
12439 12439
12440 case SEEK_CUR: /* Go from current position. */ 12440 case SEEK_CUR: /* Go from current position. */
12441 idx = src->index + off; 12441 idx = src->index + off;
12442 break; 12442 break;
12443 12443
12444 default: /* Invalid `whence'. */ 12444 default: /* Invalid `whence'. */
12445 return -1; 12445 return -1;
12446 } 12446 }
12447 12447
12448 if (idx > src->len || idx < 0) 12448 if (idx > src->len || idx < 0)
12449 return -1; 12449 return -1;
12450 12450
12451 src->index = idx; 12451 src->index = idx;
12452 return src->index; 12452 return src->index;
12453 } 12453 }
12454 12454
12455 static int 12455 static int
12492 const char *title, *format; 12492 const char *title, *format;
12493 va_list ap; 12493 va_list ap;
12494 { 12494 {
12495 char buf[512]; 12495 char buf[512];
12496 int len; 12496 int len;
12497 12497
12498 len = sprintf (buf, "TIFF error: %s ", title); 12498 len = sprintf (buf, "TIFF error: %s ", title);
12499 vsprintf (buf + len, format, ap); 12499 vsprintf (buf + len, format, ap);
12500 add_to_log (buf, Qnil, Qnil); 12500 add_to_log (buf, Qnil, Qnil);
12501 } 12501 }
12502 12502
12506 const char *title, *format; 12506 const char *title, *format;
12507 va_list ap; 12507 va_list ap;
12508 { 12508 {
12509 char buf[512]; 12509 char buf[512];
12510 int len; 12510 int len;
12511 12511
12512 len = sprintf (buf, "TIFF warning: %s ", title); 12512 len = sprintf (buf, "TIFF warning: %s ", title);
12513 vsprintf (buf + len, format, ap); 12513 vsprintf (buf + len, format, ap);
12514 add_to_log (buf, Qnil, Qnil); 12514 add_to_log (buf, Qnil, Qnil);
12515 } 12515 }
12516 12516
12549 { 12549 {
12550 image_error ("Cannot find image file `%s'", file, Qnil); 12550 image_error ("Cannot find image file `%s'", file, Qnil);
12551 UNGCPRO; 12551 UNGCPRO;
12552 return 0; 12552 return 0;
12553 } 12553 }
12554 12554
12555 /* Try to open the image file. */ 12555 /* Try to open the image file. */
12556 tiff = TIFFOpen (SDATA (file), "r"); 12556 tiff = TIFFOpen (SDATA (file), "r");
12557 if (tiff == NULL) 12557 if (tiff == NULL)
12558 { 12558 {
12559 image_error ("Cannot open `%s'", file, Qnil); 12559 image_error ("Cannot open `%s'", file, Qnil);
12588 /* Get width and height of the image, and allocate a raster buffer 12588 /* Get width and height of the image, and allocate a raster buffer
12589 of width x height 32-bit values. */ 12589 of width x height 32-bit values. */
12590 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); 12590 TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
12591 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); 12591 TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
12592 buf = (uint32 *) xmalloc (width * height * sizeof *buf); 12592 buf = (uint32 *) xmalloc (width * height * sizeof *buf);
12593 12593
12594 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); 12594 rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
12595 TIFFClose (tiff); 12595 TIFFClose (tiff);
12596 if (!rc) 12596 if (!rc)
12597 { 12597 {
12598 image_error ("Error reading TIFF image `%s'", img->spec, Qnil); 12598 image_error ("Error reading TIFF image `%s'", img->spec, Qnil);
12614 12614
12615 /* Process the pixel raster. Origin is in the lower-left corner. */ 12615 /* Process the pixel raster. Origin is in the lower-left corner. */
12616 for (y = 0; y < height; ++y) 12616 for (y = 0; y < height; ++y)
12617 { 12617 {
12618 uint32 *row = buf + y * width; 12618 uint32 *row = buf + y * width;
12619 12619
12620 for (x = 0; x < width; ++x) 12620 for (x = 0; x < width; ++x)
12621 { 12621 {
12622 uint32 abgr = row[x]; 12622 uint32 abgr = row[x];
12623 int r = TIFFGetR (abgr) << 8; 12623 int r = TIFFGetR (abgr) << 8;
12624 int g = TIFFGetG (abgr) << 8; 12624 int g = TIFFGetG (abgr) << 8;
12625 int b = TIFFGetB (abgr) << 8; 12625 int b = TIFFGetB (abgr) << 8;
12626 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); 12626 XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
12627 } 12627 }
12628 } 12628 }
12629 12629
12630 /* Remember the colors allocated for the image. Free the color table. */ 12630 /* Remember the colors allocated for the image. Free the color table. */
12631 img->colors = colors_in_color_table (&img->ncolors); 12631 img->colors = colors_in_color_table (&img->ncolors);
12719 gif_image_p (object) 12719 gif_image_p (object)
12720 Lisp_Object object; 12720 Lisp_Object object;
12721 { 12721 {
12722 struct image_keyword fmt[GIF_LAST]; 12722 struct image_keyword fmt[GIF_LAST];
12723 bcopy (gif_format, fmt, sizeof fmt); 12723 bcopy (gif_format, fmt, sizeof fmt);
12724 12724
12725 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif) 12725 if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)
12726 || (fmt[GIF_ASCENT].count 12726 || (fmt[GIF_ASCENT].count
12727 && XFASTINT (fmt[GIF_ASCENT].value) > 100)) 12727 && XFASTINT (fmt[GIF_ASCENT].value) > 100))
12728 return 0; 12728 return 0;
12729 12729
12730 /* Must specify either the :data or :file keyword. */ 12730 /* Must specify either the :data or :file keyword. */
12731 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1; 12731 return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
12732 } 12732 }
12733 12733
12734 /* Reading a GIF image from memory 12734 /* Reading a GIF image from memory
12797 { 12797 {
12798 image_error ("Cannot find image file `%s'", specified_file, Qnil); 12798 image_error ("Cannot find image file `%s'", specified_file, Qnil);
12799 UNGCPRO; 12799 UNGCPRO;
12800 return 0; 12800 return 0;
12801 } 12801 }
12802 12802
12803 /* Open the GIF file. */ 12803 /* Open the GIF file. */
12804 gif = DGifOpenFileName (SDATA (file)); 12804 gif = DGifOpenFileName (SDATA (file));
12805 if (gif == NULL) 12805 if (gif == NULL)
12806 { 12806 {
12807 image_error ("Cannot open `%s'", file, Qnil); 12807 image_error ("Cannot open `%s'", file, Qnil);
12855 { 12855 {
12856 DGifCloseFile (gif); 12856 DGifCloseFile (gif);
12857 UNGCPRO; 12857 UNGCPRO;
12858 return 0; 12858 return 0;
12859 } 12859 }
12860 12860
12861 /* Allocate colors. */ 12861 /* Allocate colors. */
12862 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap; 12862 gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
12863 if (!gif_color_map) 12863 if (!gif_color_map)
12864 gif_color_map = gif->SColorMap; 12864 gif_color_map = gif->SColorMap;
12865 init_color_table (); 12865 init_color_table ();
12866 bzero (pixel_colors, sizeof pixel_colors); 12866 bzero (pixel_colors, sizeof pixel_colors);
12867 12867
12868 for (i = 0; i < gif_color_map->ColorCount; ++i) 12868 for (i = 0; i < gif_color_map->ColorCount; ++i)
12869 { 12869 {
12870 int r = gif_color_map->Colors[i].Red << 8; 12870 int r = gif_color_map->Colors[i].Red << 8;
12871 int g = gif_color_map->Colors[i].Green << 8; 12871 int g = gif_color_map->Colors[i].Green << 8;
12872 int b = gif_color_map->Colors[i].Blue << 8; 12872 int b = gif_color_map->Colors[i].Blue << 8;
12875 12875
12876 img->colors = colors_in_color_table (&img->ncolors); 12876 img->colors = colors_in_color_table (&img->ncolors);
12877 free_color_table (); 12877 free_color_table ();
12878 12878
12879 /* Clear the part of the screen image that are not covered by 12879 /* Clear the part of the screen image that are not covered by
12880 the image from the GIF file. Full animated GIF support 12880 the image from the GIF file. Full animated GIF support
12881 requires more than can be done here (see the gif89 spec, 12881 requires more than can be done here (see the gif89 spec,
12882 disposal methods). Let's simply assume that the part 12882 disposal methods). Let's simply assume that the part
12883 not covered by a sub-image is in the frame's background color. */ 12883 not covered by a sub-image is in the frame's background color. */
12884 image_top = gif->SavedImages[ino].ImageDesc.Top; 12884 image_top = gif->SavedImages[ino].ImageDesc.Top;
12885 image_left = gif->SavedImages[ino].ImageDesc.Left; 12885 image_left = gif->SavedImages[ino].ImageDesc.Left;
12922 { 12922 {
12923 row = interlace_start[++pass]; 12923 row = interlace_start[++pass];
12924 while (row >= image_height) 12924 while (row >= image_height)
12925 row = interlace_start[++pass]; 12925 row = interlace_start[++pass];
12926 } 12926 }
12927 12927
12928 for (x = 0; x < image_width; x++) 12928 for (x = 0; x < image_width; x++)
12929 { 12929 {
12930 int i = raster[(y * image_width) + x]; 12930 int i = raster[(y * image_width) + x];
12931 XPutPixel (ximg, x + image_left, row + image_top, 12931 XPutPixel (ximg, x + image_left, row + image_top,
12932 pixel_colors[i]); 12932 pixel_colors[i]);
12933 } 12933 }
12934 12934
12935 row += interlace_increment[pass]; 12935 row += interlace_increment[pass];
12936 } 12936 }
12937 } 12937 }
12938 else 12938 else
12939 { 12939 {
12942 { 12942 {
12943 int i = raster[y* image_width + x]; 12943 int i = raster[y* image_width + x];
12944 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]); 12944 XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
12945 } 12945 }
12946 } 12946 }
12947 12947
12948 DGifCloseFile (gif); 12948 DGifCloseFile (gif);
12949 12949
12950 /* Maybe fill in the background field while we have ximg handy. */ 12950 /* Maybe fill in the background field while we have ximg handy. */
12951 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 12951 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
12952 IMAGE_BACKGROUND (img, f, ximg); 12952 IMAGE_BACKGROUND (img, f, ximg);
12953 12953
12954 /* Put the image into the pixmap, then free the X image and its buffer. */ 12954 /* Put the image into the pixmap, then free the X image and its buffer. */
12955 x_put_x_image (f, ximg, img->pixmap, width, height); 12955 x_put_x_image (f, ximg, img->pixmap, width, height);
12956 x_destroy_x_image (ximg); 12956 x_destroy_x_image (ximg);
12957 12957
12958 UNGCPRO; 12958 UNGCPRO;
12959 return 1; 12959 return 1;
12960 } 12960 }
12961 12961
12962 #endif /* HAVE_GIF != 0 */ 12962 #endif /* HAVE_GIF != 0 */
13053 Lisp_Object object; 13053 Lisp_Object object;
13054 { 13054 {
13055 struct image_keyword fmt[GS_LAST]; 13055 struct image_keyword fmt[GS_LAST];
13056 Lisp_Object tem; 13056 Lisp_Object tem;
13057 int i; 13057 int i;
13058 13058
13059 bcopy (gs_format, fmt, sizeof fmt); 13059 bcopy (gs_format, fmt, sizeof fmt);
13060 13060
13061 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript) 13061 if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)
13062 || (fmt[GS_ASCENT].count 13062 || (fmt[GS_ASCENT].count
13063 && XFASTINT (fmt[GS_ASCENT].value) > 100)) 13063 && XFASTINT (fmt[GS_ASCENT].value) > 100))
13064 return 0; 13064 return 0;
13065 13065
13066 /* Bounding box must be a list or vector containing 4 integers. */ 13066 /* Bounding box must be a list or vector containing 4 integers. */
13067 tem = fmt[GS_BOUNDING_BOX].value; 13067 tem = fmt[GS_BOUNDING_BOX].value;
13125 if (!img->pixmap) 13125 if (!img->pixmap)
13126 { 13126 {
13127 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil); 13127 image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
13128 return 0; 13128 return 0;
13129 } 13129 }
13130 13130
13131 /* Call the loader to fill the pixmap. It returns a process object 13131 /* Call the loader to fill the pixmap. It returns a process object
13132 if successful. We do not record_unwind_protect here because 13132 if successful. We do not record_unwind_protect here because
13133 other places in redisplay like calling window scroll functions 13133 other places in redisplay like calling window scroll functions
13134 don't either. Let the Lisp loader use `unwind-protect' instead. */ 13134 don't either. Let the Lisp loader use `unwind-protect' instead. */
13135 GCPRO2 (window_and_pixmap_id, pixel_colors); 13135 GCPRO2 (window_and_pixmap_id, pixel_colors);
13136 13136
13137 sprintf (buffer, "%lu %lu", 13137 sprintf (buffer, "%lu %lu",
13138 (unsigned long) FRAME_W32_WINDOW (f), 13138 (unsigned long) FRAME_W32_WINDOW (f),
13139 (unsigned long) img->pixmap); 13139 (unsigned long) img->pixmap);
13140 window_and_pixmap_id = build_string (buffer); 13140 window_and_pixmap_id = build_string (buffer);
13141 13141
13142 sprintf (buffer, "%lu %lu", 13142 sprintf (buffer, "%lu %lu",
13143 FRAME_FOREGROUND_PIXEL (f), 13143 FRAME_FOREGROUND_PIXEL (f),
13144 FRAME_BACKGROUND_PIXEL (f)); 13144 FRAME_BACKGROUND_PIXEL (f));
13145 pixel_colors = build_string (buffer); 13145 pixel_colors = build_string (buffer);
13146 13146
13147 XSETFRAME (frame, f); 13147 XSETFRAME (frame, f);
13148 loader = image_spec_value (img->spec, QCloader, NULL); 13148 loader = image_spec_value (img->spec, QCloader, NULL);
13149 if (NILP (loader)) 13149 if (NILP (loader))
13150 loader = intern ("gs-load-image"); 13150 loader = intern ("gs-load-image");
13151 13151
13203 ximg = XGetImage (FRAME_W32_DISPLAY (f), img->pixmap, 13203 ximg = XGetImage (FRAME_W32_DISPLAY (f), img->pixmap,
13204 0, 0, img->width, img->height, ~0, ZPixmap); 13204 0, 0, img->width, img->height, ~0, ZPixmap);
13205 if (ximg) 13205 if (ximg)
13206 { 13206 {
13207 int x, y; 13207 int x, y;
13208 13208
13209 /* Initialize the color table. */ 13209 /* Initialize the color table. */
13210 init_color_table (); 13210 init_color_table ();
13211 13211
13212 /* For each pixel of the image, look its color up in the 13212 /* For each pixel of the image, look its color up in the
13213 color table. After having done so, the color table will 13213 color table. After having done so, the color table will
13214 contain an entry for each color used by the image. */ 13214 contain an entry for each color used by the image. */
13215 for (y = 0; y < img->height; ++y) 13215 for (y = 0; y < img->height; ++y)
13216 for (x = 0; x < img->width; ++x) 13216 for (x = 0; x < img->width; ++x)
13236 #endif 13236 #endif
13237 } 13237 }
13238 else 13238 else
13239 image_error ("Cannot get X image of `%s'; colors will not be freed", 13239 image_error ("Cannot get X image of `%s'; colors will not be freed",
13240 img->spec, Qnil); 13240 img->spec, Qnil);
13241 13241
13242 UNBLOCK_INPUT; 13242 UNBLOCK_INPUT;
13243 } 13243 }
13244 13244
13245 /* Now that we have the pixmap, compute mask and transform the 13245 /* Now that we have the pixmap, compute mask and transform the
13246 image if requested. */ 13246 image if requested. */
13348 tmp_data = NULL; 13348 tmp_data = NULL;
13349 13349
13350 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), 13350 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
13351 prop_atom, 0, bytes_remaining, 13351 prop_atom, 0, bytes_remaining,
13352 False, XA_STRING, 13352 False, XA_STRING,
13353 &actual_type, &actual_format, 13353 &actual_type, &actual_format,
13354 &actual_size, &bytes_remaining, 13354 &actual_size, &bytes_remaining,
13355 (unsigned char **) &tmp_data); 13355 (unsigned char **) &tmp_data);
13356 if (rc == Success) 13356 if (rc == Success)
13357 prop_value = make_string (tmp_data, size); 13357 prop_value = make_string (tmp_data, size);
13358 13358
13359 XFree (tmp_data); 13359 XFree (tmp_data);
13403 start_hourglass () 13403 start_hourglass ()
13404 { 13404 {
13405 #if 0 /* TODO: cursor shape changes. */ 13405 #if 0 /* TODO: cursor shape changes. */
13406 EMACS_TIME delay; 13406 EMACS_TIME delay;
13407 int secs, usecs = 0; 13407 int secs, usecs = 0;
13408 13408
13409 cancel_hourglass (); 13409 cancel_hourglass ();
13410 13410
13411 if (INTEGERP (Vhourglass_delay) 13411 if (INTEGERP (Vhourglass_delay)
13412 && XINT (Vhourglass_delay) > 0) 13412 && XINT (Vhourglass_delay) > 0)
13413 secs = XFASTINT (Vhourglass_delay); 13413 secs = XFASTINT (Vhourglass_delay);
13419 secs = XFASTINT (tem); 13419 secs = XFASTINT (tem);
13420 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000; 13420 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
13421 } 13421 }
13422 else 13422 else
13423 secs = DEFAULT_HOURGLASS_DELAY; 13423 secs = DEFAULT_HOURGLASS_DELAY;
13424 13424
13425 EMACS_SET_SECS_USECS (delay, secs, usecs); 13425 EMACS_SET_SECS_USECS (delay, secs, usecs);
13426 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 13426 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
13427 show_hourglass, NULL); 13427 show_hourglass, NULL);
13428 #endif 13428 #endif
13429 } 13429 }
13438 if (hourglass_atimer) 13438 if (hourglass_atimer)
13439 { 13439 {
13440 cancel_atimer (hourglass_atimer); 13440 cancel_atimer (hourglass_atimer);
13441 hourglass_atimer = NULL; 13441 hourglass_atimer = NULL;
13442 } 13442 }
13443 13443
13444 if (hourglass_shown_p) 13444 if (hourglass_shown_p)
13445 hide_hourglass (); 13445 hide_hourglass ();
13446 } 13446 }
13447 13447
13448 13448
13465 hourglass_atimer = NULL; 13465 hourglass_atimer = NULL;
13466 13466
13467 if (!hourglass_shown_p) 13467 if (!hourglass_shown_p)
13468 { 13468 {
13469 Lisp_Object rest, frame; 13469 Lisp_Object rest, frame;
13470 13470
13471 BLOCK_INPUT; 13471 BLOCK_INPUT;
13472 13472
13473 FOR_EACH_FRAME (rest, frame) 13473 FOR_EACH_FRAME (rest, frame)
13474 if (FRAME_W32_P (XFRAME (frame))) 13474 if (FRAME_W32_P (XFRAME (frame)))
13475 { 13475 {
13476 struct frame *f = XFRAME (frame); 13476 struct frame *f = XFRAME (frame);
13477 13477
13478 f->output_data.w32->hourglass_p = 1; 13478 f->output_data.w32->hourglass_p = 1;
13479 13479
13480 if (!f->output_data.w32->hourglass_window) 13480 if (!f->output_data.w32->hourglass_window)
13481 { 13481 {
13482 unsigned long mask = CWCursor; 13482 unsigned long mask = CWCursor;
13483 XSetWindowAttributes attrs; 13483 XSetWindowAttributes attrs;
13484 13484
13485 attrs.cursor = f->output_data.w32->hourglass_cursor; 13485 attrs.cursor = f->output_data.w32->hourglass_cursor;
13486 13486
13487 f->output_data.w32->hourglass_window 13487 f->output_data.w32->hourglass_window
13488 = XCreateWindow (FRAME_X_DISPLAY (f), 13488 = XCreateWindow (FRAME_X_DISPLAY (f),
13489 FRAME_OUTER_WINDOW (f), 13489 FRAME_OUTER_WINDOW (f),
13490 0, 0, 32000, 32000, 0, 0, 13490 0, 0, 32000, 32000, 0, 0,
13491 InputOnly, 13491 InputOnly,
13492 CopyFromParent, 13492 CopyFromParent,
13493 mask, &attrs); 13493 mask, &attrs);
13494 } 13494 }
13495 13495
13496 XMapRaised (FRAME_X_DISPLAY (f), 13496 XMapRaised (FRAME_X_DISPLAY (f),
13497 f->output_data.w32->hourglass_window); 13497 f->output_data.w32->hourglass_window);
13498 XFlush (FRAME_X_DISPLAY (f)); 13498 XFlush (FRAME_X_DISPLAY (f));
13499 } 13499 }
13500 13500
13517 13517
13518 BLOCK_INPUT; 13518 BLOCK_INPUT;
13519 FOR_EACH_FRAME (rest, frame) 13519 FOR_EACH_FRAME (rest, frame)
13520 { 13520 {
13521 struct frame *f = XFRAME (frame); 13521 struct frame *f = XFRAME (frame);
13522 13522
13523 if (FRAME_W32_P (f) 13523 if (FRAME_W32_P (f)
13524 /* Watch out for newly created frames. */ 13524 /* Watch out for newly created frames. */
13525 && f->output_data.x->hourglass_window) 13525 && f->output_data.x->hourglass_window)
13526 { 13526 {
13527 XUnmapWindow (FRAME_X_DISPLAY (f), 13527 XUnmapWindow (FRAME_X_DISPLAY (f),
13547 13547
13548 static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *, 13548 static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *,
13549 Lisp_Object, Lisp_Object)); 13549 Lisp_Object, Lisp_Object));
13550 static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object, 13550 static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
13551 Lisp_Object, int, int, int *, int *)); 13551 Lisp_Object, int, int, int *, int *));
13552 13552
13553 /* The frame of a currently visible tooltip. */ 13553 /* The frame of a currently visible tooltip. */
13554 13554
13555 Lisp_Object tip_frame; 13555 Lisp_Object tip_frame;
13556 13556
13557 /* If non-nil, a timer started that hides the last tooltip when it 13557 /* If non-nil, a timer started that hides the last tooltip when it
13580 if (EQ (deleted, Qt)) 13580 if (EQ (deleted, Qt))
13581 { 13581 {
13582 tip_window = NULL; 13582 tip_window = NULL;
13583 tip_frame = Qnil; 13583 tip_frame = Qnil;
13584 } 13584 }
13585 13585
13586 return deleted; 13586 return deleted;
13587 } 13587 }
13588 13588
13589 13589
13590 /* Create a frame for a tooltip on the display described by DPYINFO. 13590 /* Create a frame for a tooltip on the display described by DPYINFO.
13646 set_buffer_internal_1 (XBUFFER (buffer)); 13646 set_buffer_internal_1 (XBUFFER (buffer));
13647 current_buffer->truncate_lines = Qnil; 13647 current_buffer->truncate_lines = Qnil;
13648 Ferase_buffer (); 13648 Ferase_buffer ();
13649 Finsert (1, &text); 13649 Finsert (1, &text);
13650 set_buffer_internal_1 (old_buffer); 13650 set_buffer_internal_1 (old_buffer);
13651 13651
13652 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; 13652 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
13653 record_unwind_protect (unwind_create_tip_frame, frame); 13653 record_unwind_protect (unwind_create_tip_frame, frame);
13654 13654
13655 /* By setting the output method, we're essentially saying that 13655 /* By setting the output method, we're essentially saying that
13656 the frame is live, as per FRAME_LIVE_P. If we get a signal 13656 the frame is live, as per FRAME_LIVE_P. If we get a signal
13704 if (STRINGP (tem)) 13704 if (STRINGP (tem))
13705 font = x_new_fontset (f, SDATA (tem)); 13705 font = x_new_fontset (f, SDATA (tem));
13706 else 13706 else
13707 font = x_new_font (f, SDATA (font)); 13707 font = x_new_font (f, SDATA (font));
13708 } 13708 }
13709 13709
13710 /* Try out a font which we hope has bold and italic variations. */ 13710 /* Try out a font which we hope has bold and italic variations. */
13711 if (!STRINGP (font)) 13711 if (!STRINGP (font))
13712 font = x_new_font (f, "-*-Courier New-normal-r-*-*-*-100-*-*-c-*-iso8859-1"); 13712 font = x_new_font (f, "-*-Courier New-normal-r-*-*-*-100-*-*-c-*-iso8859-1");
13713 if (! STRINGP (font)) 13713 if (! STRINGP (font))
13714 font = x_new_font (f, "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1"); 13714 font = x_new_font (f, "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1");
13814 13814
13815 /* Add `tooltip' frame parameter's default value. */ 13815 /* Add `tooltip' frame parameter's default value. */
13816 if (NILP (Fframe_parameter (frame, intern ("tooltip")))) 13816 if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
13817 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), 13817 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
13818 Qnil)); 13818 Qnil));
13819 13819
13820 /* Set up faces after all frame parameters are known. This call 13820 /* Set up faces after all frame parameters are known. This call
13821 also merges in face attributes specified for new frames. 13821 also merges in face attributes specified for new frames.
13822 13822
13823 Frame parameters may be changed if .Xdefaults contains 13823 Frame parameters may be changed if .Xdefaults contains
13824 specifications for the default font. For example, if there is an 13824 specifications for the default font. For example, if there is an
13829 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color); 13829 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
13830 13830
13831 /* Set tip_frame here, so that */ 13831 /* Set tip_frame here, so that */
13832 tip_frame = frame; 13832 tip_frame = frame;
13833 call1 (Qface_set_after_frame_default, frame); 13833 call1 (Qface_set_after_frame_default, frame);
13834 13834
13835 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color))) 13835 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
13836 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg), 13836 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
13837 Qnil)); 13837 Qnil));
13838 } 13838 }
13839 13839
13840 f->no_split = 1; 13840 f->no_split = 1;
13841 13841
13842 UNGCPRO; 13842 UNGCPRO;
13843 13843
13844 /* It is now ok to make the frame official even if we get an error 13844 /* It is now ok to make the frame official even if we get an error
13874 Lisp_Object parms, dx, dy; 13874 Lisp_Object parms, dx, dy;
13875 int width, height; 13875 int width, height;
13876 int *root_x, *root_y; 13876 int *root_x, *root_y;
13877 { 13877 {
13878 Lisp_Object left, top; 13878 Lisp_Object left, top;
13879 13879
13880 /* User-specified position? */ 13880 /* User-specified position? */
13881 left = Fcdr (Fassq (Qleft, parms)); 13881 left = Fcdr (Fassq (Qleft, parms));
13882 top = Fcdr (Fassq (Qtop, parms)); 13882 top = Fcdr (Fassq (Qtop, parms));
13883 13883
13884 /* Move the tooltip window where the mouse pointer is. Resize and 13884 /* Move the tooltip window where the mouse pointer is. Resize and
13885 show it. */ 13885 show it. */
13886 if (!INTEGERP (left) || !INTEGERP (top)) 13886 if (!INTEGERP (left) || !INTEGERP (top))
13887 { 13887 {
13888 POINT pt; 13888 POINT pt;
13950 struct text_pos pos; 13950 struct text_pos pos;
13951 int i, width, height; 13951 int i, width, height;
13952 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 13952 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
13953 int old_windows_or_buffers_changed = windows_or_buffers_changed; 13953 int old_windows_or_buffers_changed = windows_or_buffers_changed;
13954 int count = SPECPDL_INDEX (); 13954 int count = SPECPDL_INDEX ();
13955 13955
13956 specbind (Qinhibit_redisplay, Qt); 13956 specbind (Qinhibit_redisplay, Qt);
13957 13957
13958 GCPRO4 (string, parms, frame, timeout); 13958 GCPRO4 (string, parms, frame, timeout);
13959 13959
13960 CHECK_STRING (string); 13960 CHECK_STRING (string);
13966 13966
13967 if (NILP (dx)) 13967 if (NILP (dx))
13968 dx = make_number (5); 13968 dx = make_number (5);
13969 else 13969 else
13970 CHECK_NUMBER (dx); 13970 CHECK_NUMBER (dx);
13971 13971
13972 if (NILP (dy)) 13972 if (NILP (dy))
13973 dy = make_number (-10); 13973 dy = make_number (-10);
13974 else 13974 else
13975 CHECK_NUMBER (dy); 13975 CHECK_NUMBER (dy);
13976 13976
13986 if (EQ (frame, last_frame) 13986 if (EQ (frame, last_frame)
13987 && !NILP (Fequal (last_string, string)) 13987 && !NILP (Fequal (last_string, string))
13988 && !NILP (Fequal (last_parms, parms))) 13988 && !NILP (Fequal (last_parms, parms)))
13989 { 13989 {
13990 struct frame *f = XFRAME (tip_frame); 13990 struct frame *f = XFRAME (tip_frame);
13991 13991
13992 /* Only DX and DY have changed. */ 13992 /* Only DX and DY have changed. */
13993 if (!NILP (tip_timer)) 13993 if (!NILP (tip_timer))
13994 { 13994 {
13995 Lisp_Object timer = tip_timer; 13995 Lisp_Object timer = tip_timer;
13996 tip_timer = Qnil; 13996 tip_timer = Qnil;
14061 else 14061 else
14062 { 14062 {
14063 w->width = make_number (80); 14063 w->width = make_number (80);
14064 w->height = make_number (40); 14064 w->height = make_number (40);
14065 } 14065 }
14066 14066
14067 f->window_width = XINT (w->width); 14067 f->window_width = XINT (w->width);
14068 adjust_glyphs (f); 14068 adjust_glyphs (f);
14069 w->pseudo_window_p = 1; 14069 w->pseudo_window_p = 1;
14070 14070
14071 /* Display the tooltip text in a temporary buffer. */ 14071 /* Display the tooltip text in a temporary buffer. */
14102 row_width = row->pixel_width - last->pixel_width; 14102 row_width = row->pixel_width - last->pixel_width;
14103 } 14103 }
14104 else 14104 else
14105 #endif 14105 #endif
14106 row_width = row->pixel_width; 14106 row_width = row->pixel_width;
14107 14107
14108 /* TODO: find why tips do not draw along baseline as instructed. */ 14108 /* TODO: find why tips do not draw along baseline as instructed. */
14109 height += row->height; 14109 height += row->height;
14110 width = max (width, row_width); 14110 width = max (width, row_width);
14111 } 14111 }
14112 14112
14174 struct gcpro gcpro1, gcpro2; 14174 struct gcpro gcpro1, gcpro2;
14175 14175
14176 /* Return quickly if nothing to do. */ 14176 /* Return quickly if nothing to do. */
14177 if (NILP (tip_timer) && NILP (tip_frame)) 14177 if (NILP (tip_timer) && NILP (tip_frame))
14178 return Qnil; 14178 return Qnil;
14179 14179
14180 frame = tip_frame; 14180 frame = tip_frame;
14181 timer = tip_timer; 14181 timer = tip_timer;
14182 GCPRO2 (frame, timer); 14182 GCPRO2 (frame, timer);
14183 tip_frame = tip_timer = deleted = Qnil; 14183 tip_frame = tip_timer = deleted = Qnil;
14184 14184
14185 count = SPECPDL_INDEX (); 14185 count = SPECPDL_INDEX ();
14186 specbind (Qinhibit_redisplay, Qt); 14186 specbind (Qinhibit_redisplay, Qt);
14187 specbind (Qinhibit_quit, Qt); 14187 specbind (Qinhibit_quit, Qt);
14188 14188
14189 if (!NILP (timer)) 14189 if (!NILP (timer))
14190 call1 (Qcancel_timer, timer); 14190 call1 (Qcancel_timer, timer);
14191 14191
14192 if (FRAMEP (frame)) 14192 if (FRAMEP (frame))
14193 { 14193 {
14951 14951
14952 DEFVAR_INT ("w32-quit-key", &Vw32_quit_key, 14952 DEFVAR_INT ("w32-quit-key", &Vw32_quit_key,
14953 doc: /* If non-zero, the virtual key code for an alternative quit key. */); 14953 doc: /* If non-zero, the virtual key code for an alternative quit key. */);
14954 XSETINT (Vw32_quit_key, 0); 14954 XSETINT (Vw32_quit_key, 0);
14955 14955
14956 DEFVAR_LISP ("w32-pass-lwindow-to-system", 14956 DEFVAR_LISP ("w32-pass-lwindow-to-system",
14957 &Vw32_pass_lwindow_to_system, 14957 &Vw32_pass_lwindow_to_system,
14958 doc: /* Non-nil if the left \"Windows\" key is passed on to Windows. 14958 doc: /* Non-nil if the left \"Windows\" key is passed on to Windows.
14959 When non-nil, the Start menu is opened by tapping the key. */); 14959 When non-nil, the Start menu is opened by tapping the key. */);
14960 Vw32_pass_lwindow_to_system = Qt; 14960 Vw32_pass_lwindow_to_system = Qt;
14961 14961
14962 DEFVAR_LISP ("w32-pass-rwindow-to-system", 14962 DEFVAR_LISP ("w32-pass-rwindow-to-system",
14963 &Vw32_pass_rwindow_to_system, 14963 &Vw32_pass_rwindow_to_system,
14964 doc: /* Non-nil if the right \"Windows\" key is passed on to Windows. 14964 doc: /* Non-nil if the right \"Windows\" key is passed on to Windows.
14965 When non-nil, the Start menu is opened by tapping the key. */); 14965 When non-nil, the Start menu is opened by tapping the key. */);
14966 Vw32_pass_rwindow_to_system = Qt; 14966 Vw32_pass_rwindow_to_system = Qt;
14967 14967
14975 `w32-pass-rwindow-to-system' is nil. */); 14975 `w32-pass-rwindow-to-system' is nil. */);
14976 /* Although 255 is technically not a valid key code, it works and 14976 /* Although 255 is technically not a valid key code, it works and
14977 means that this hack won't interfere with any real key code. */ 14977 means that this hack won't interfere with any real key code. */
14978 Vw32_phantom_key_code = 255; 14978 Vw32_phantom_key_code = 255;
14979 14979
14980 DEFVAR_LISP ("w32-enable-num-lock", 14980 DEFVAR_LISP ("w32-enable-num-lock",
14981 &Vw32_enable_num_lock, 14981 &Vw32_enable_num_lock,
14982 doc: /* Non-nil if Num Lock should act normally. 14982 doc: /* Non-nil if Num Lock should act normally.
14983 Set to nil to see Num Lock as the key `kp-numlock'. */); 14983 Set to nil to see Num Lock as the key `kp-numlock'. */);
14984 Vw32_enable_num_lock = Qt; 14984 Vw32_enable_num_lock = Qt;
14985 14985
14986 DEFVAR_LISP ("w32-enable-caps-lock", 14986 DEFVAR_LISP ("w32-enable-caps-lock",
14987 &Vw32_enable_caps_lock, 14987 &Vw32_enable_caps_lock,
14988 doc: /* Non-nil if Caps Lock should act normally. 14988 doc: /* Non-nil if Caps Lock should act normally.
14989 Set to nil to see Caps Lock as the key `capslock'. */); 14989 Set to nil to see Caps Lock as the key `capslock'. */);
14990 Vw32_enable_caps_lock = Qt; 14990 Vw32_enable_caps_lock = Qt;
14991 14991
15088 Vx_hourglass_pointer_shape = Qnil; 15088 Vx_hourglass_pointer_shape = Qnil;
15089 15089
15090 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, 15090 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
15091 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); 15091 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
15092 display_hourglass_p = 1; 15092 display_hourglass_p = 1;
15093 15093
15094 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, 15094 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
15095 doc: /* *Seconds to wait before displaying an hourglass pointer. 15095 doc: /* *Seconds to wait before displaying an hourglass pointer.
15096 Value must be an integer or float. */); 15096 Value must be an integer or float. */);
15097 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); 15097 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
15098 15098
15116 15116
15117 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size, 15117 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
15118 doc: /* Maximum size for tooltips. 15118 doc: /* Maximum size for tooltips.
15119 Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */); 15119 Value is a pair (COLUMNS . ROWS). Text larger than this is clipped. */);
15120 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40)); 15120 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
15121 15121
15122 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, 15122 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
15123 doc: /* Non-nil if no window manager is in use. 15123 doc: /* Non-nil if no window manager is in use.
15124 Emacs doesn't try to figure this out; this is always nil 15124 Emacs doesn't try to figure this out; this is always nil
15125 unless you set it to something else. */); 15125 unless you set it to something else. */);
15126 /* We don't have any way to find this out, so set it to nil 15126 /* We don't have any way to find this out, so set it to nil
15347 15347
15348 #if HAVE_XPM 15348 #if HAVE_XPM
15349 Qxpm = intern ("xpm"); 15349 Qxpm = intern ("xpm");
15350 staticpro (&Qxpm); 15350 staticpro (&Qxpm);
15351 #endif 15351 #endif
15352 15352
15353 #if HAVE_JPEG 15353 #if HAVE_JPEG
15354 Qjpeg = intern ("jpeg"); 15354 Qjpeg = intern ("jpeg");
15355 staticpro (&Qjpeg); 15355 staticpro (&Qjpeg);
15356 #endif 15356 #endif
15357 15357
15358 #if HAVE_TIFF 15358 #if HAVE_TIFF
15359 Qtiff = intern ("tiff"); 15359 Qtiff = intern ("tiff");
15360 staticpro (&Qtiff); 15360 staticpro (&Qtiff);
15361 #endif 15361 #endif
15362 15362
15363 #if HAVE_GIF 15363 #if HAVE_GIF
15364 Qgif = intern ("gif"); 15364 Qgif = intern ("gif");
15365 staticpro (&Qgif); 15365 staticpro (&Qgif);
15366 #endif 15366 #endif
15404 define_image_type (&pbm_type); 15404 define_image_type (&pbm_type);
15405 define_image_type (&xbm_type); 15405 define_image_type (&xbm_type);
15406 #if 0 /* TODO : Image support for W32 */ 15406 #if 0 /* TODO : Image support for W32 */
15407 define_image_type (&gs_type); 15407 define_image_type (&gs_type);
15408 #endif 15408 #endif
15409 15409
15410 #if HAVE_XPM 15410 #if HAVE_XPM
15411 define_image_type (&xpm_type); 15411 define_image_type (&xpm_type);
15412 #endif 15412 #endif
15413 15413
15414 #if HAVE_JPEG 15414 #if HAVE_JPEG
15415 define_image_type (&jpeg_type); 15415 define_image_type (&jpeg_type);
15416 #endif 15416 #endif
15417 15417
15418 #if HAVE_TIFF 15418 #if HAVE_TIFF
15419 define_image_type (&tiff_type); 15419 define_image_type (&tiff_type);
15420 #endif 15420 #endif
15421 15421
15422 #if HAVE_GIF 15422 #if HAVE_GIF
15423 define_image_type (&gif_type); 15423 define_image_type (&gif_type);
15424 #endif 15424 #endif
15425 15425
15426 #if HAVE_PNG 15426 #if HAVE_PNG
15427 define_image_type (&png_type); 15427 define_image_type (&png_type);
15428 #endif 15428 #endif
15429 } 15429 }
15430 15430
15431 #undef abort 15431 #undef abort
15432 15432
15433 void 15433 void
15434 w32_abort() 15434 w32_abort()
15435 { 15435 {
15436 int button; 15436 int button;
15437 button = MessageBox (NULL, 15437 button = MessageBox (NULL,
15438 "A fatal error has occurred!\n\n" 15438 "A fatal error has occurred!\n\n"