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

Diff of /emacs/src/w32fns.c

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

revision 1.123.2.16 by rms, Wed Oct 23 17:41:38 2002 UTC revision 1.123.2.17 by lektu, Mon Nov 11 07:33:45 2002 UTC
# Line 60  extern double atof (); Line 60  extern double atof ();
60  extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);  extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state);
61  extern int quit_char;  extern int quit_char;
62    
 /* A definition of XColor for non-X frames.  */  
 #ifndef HAVE_X_WINDOWS  
 typedef struct {  
   unsigned long pixel;  
   unsigned short red, green, blue;  
   char flags;  
   char pad;  
 } XColor;  
 #endif  
   
63  extern char *lispy_function_keys[];  extern char *lispy_function_keys[];
64    
65  /* The gray bitmap `bitmaps/gray'.  This is done because w32term.c uses  /* The gray bitmap `bitmaps/gray'.  This is done because w32term.c uses
# Line 284  static W32Msg saved_mouse_move_msg; Line 274  static W32Msg saved_mouse_move_msg;
274  static unsigned mouse_move_timer;  static unsigned mouse_move_timer;
275    
276  /* W95 mousewheel handler */  /* W95 mousewheel handler */
277  unsigned int msh_mousewheel = 0;          unsigned int msh_mousewheel = 0;
278    
279  #define MOUSE_BUTTON_ID 1  #define MOUSE_BUTTON_ID 1
280  #define MOUSE_MOVE_ID   2  #define MOUSE_MOVE_ID   2
# Line 319  check_w32 () Line 309  check_w32 ()
309    
310  /* Nonzero if we can use mouse menus.  /* Nonzero if we can use mouse menus.
311     You should not call this unless HAVE_MENUS is defined.  */     You should not call this unless HAVE_MENUS is defined.  */
312      
313  int  int
314  have_menus_p ()  have_menus_p ()
315  {  {
# Line 355  check_x_display_info (frame) Line 345  check_x_display_info (frame)
345    if (NILP (frame))    if (NILP (frame))
346      {      {
347        struct frame *sf = XFRAME (selected_frame);        struct frame *sf = XFRAME (selected_frame);
348          
349        if (FRAME_W32_P (sf) && FRAME_LIVE_P (sf))        if (FRAME_W32_P (sf) && FRAME_LIVE_P (sf))
350          return FRAME_W32_DISPLAY_INFO (sf);          return FRAME_W32_DISPLAY_INFO (sf);
351        else        else
# Line 564  x_create_bitmap_from_file (f, file) Line 554  x_create_bitmap_from_file (f, file)
554    if (hinst == NULL)    if (hinst == NULL)
555        return -1;        return -1;
556    
557      
558    result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),    result = XReadBitmapFile (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
559                              filename, &width, &height, &bitmap, &xhot, &yhot);                              filename, &width, &height, &bitmap, &xhot, &yhot);
560    if (result != BitmapSuccess)    if (result != BitmapSuccess)
# Line 805  x_set_frame_parameters (f, alist) Line 795  x_set_frame_parameters (f, alist)
795    /* Process foreground_color and background_color before anything else.    /* Process foreground_color and background_color before anything else.
796       They are independent of other properties, but other properties (e.g.,       They are independent of other properties, but other properties (e.g.,
797       cursor_color) are dependent upon them.  */       cursor_color) are dependent upon them.  */
798    for (p = 0; p < i; p++)    for (p = 0; p < i; p++)
799      {      {
800        Lisp_Object prop, val;        Lisp_Object prop, val;
801    
# Line 1002  x_real_positions (f, xptr, yptr) Line 992  x_real_positions (f, xptr, yptr)
992    
993    {    {
994        RECT rect;        RECT rect;
995          
996        GetClientRect(FRAME_W32_WINDOW(f), &rect);        GetClientRect(FRAME_W32_WINDOW(f), &rect);
997        AdjustWindowRect(&rect, f->output_data.w32->dwStyle, FRAME_EXTERNAL_MENU_BAR(f));        AdjustWindowRect(&rect, f->output_data.w32->dwStyle, FRAME_EXTERNAL_MENU_BAR(f));
998          
999        pt.x = rect.left;        pt.x = rect.left;
1000        pt.y = rect.top;        pt.y = rect.top;
1001    }    }
# Line 1146  where R,G,B are numbers between 0 and 25 Line 1136  where R,G,B are numbers between 0 and 25
1136  }  }
1137    
1138  /* The default colors for the w32 color map */  /* The default colors for the w32 color map */
1139  typedef struct colormap_t  typedef struct colormap_t
1140  {  {
1141    char *name;    char *name;
1142    COLORREF colorref;    COLORREF colorref;
1143  } colormap_t;  } colormap_t;
1144    
1145  colormap_t w32_color_map[] =  colormap_t w32_color_map[] =
1146  {  {
1147    {"snow"                      , PALETTERGB (255,250,250)},    {"snow"                      , PALETTERGB (255,250,250)},
1148    {"ghost white"               , PALETTERGB (248,248,255)},    {"ghost white"               , PALETTERGB (248,248,255)},
# Line 1403  DEFUN ("w32-default-color-map", Fw32_def Line 1393  DEFUN ("w32-default-color-map", Fw32_def
1393    int i;    int i;
1394    colormap_t *pc = w32_color_map;    colormap_t *pc = w32_color_map;
1395    Lisp_Object cmap;    Lisp_Object cmap;
1396      
1397    BLOCK_INPUT;    BLOCK_INPUT;
1398      
1399    cmap = Qnil;    cmap = Qnil;
1400      
1401    for (i = 0; i < sizeof (w32_color_map) / sizeof (w32_color_map[0]);    for (i = 0; i < sizeof (w32_color_map) / sizeof (w32_color_map[0]);
1402         pc++, i++)         pc++, i++)
1403      cmap = Fcons (Fcons (build_string (pc->name),      cmap = Fcons (Fcons (build_string (pc->name),
1404                           make_number (pc->colorref)),                           make_number (pc->colorref)),
1405                    cmap);                    cmap);
1406      
1407    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1408      
1409    return (cmap);    return (cmap);
1410  }  }
1411    
1412  Lisp_Object  Lisp_Object
1413  w32_to_x_color (rgb)  w32_to_x_color (rgb)
1414       Lisp_Object rgb;       Lisp_Object rgb;
1415  {  {
1416    Lisp_Object color;    Lisp_Object color;
1417      
1418    CHECK_NUMBER (rgb, 0);    CHECK_NUMBER (rgb, 0);
1419      
1420    BLOCK_INPUT;    BLOCK_INPUT;
1421      
1422    color = Frassq (rgb, Vw32_color_map);    color = Frassq (rgb, Vw32_color_map);
1423      
1424    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1425      
1426    if (!NILP (color))    if (!NILP (color))
1427      return (Fcar (color));      return (Fcar (color));
1428    else    else
# Line 1471  w32_color_map_lookup (colorname) Line 1461  w32_color_map_lookup (colorname)
1461    return ret;    return ret;
1462  }  }
1463    
1464  COLORREF  COLORREF
1465  x_to_w32_color (colorname)  x_to_w32_color (colorname)
1466       char * colorname;       char * colorname;
1467  {  {
# Line 1485  x_to_w32_color (colorname) Line 1475  x_to_w32_color (colorname)
1475        char *color;        char *color;
1476        int size;        int size;
1477        color = colorname + 1;        color = colorname + 1;
1478          
1479        size = strlen(color);        size = strlen(color);
1480        if (size == 3 || size == 6 || size == 9 || size == 12)        if (size == 3 || size == 6 || size == 9 || size == 12)
1481          {          {
# Line 1494  x_to_w32_color (colorname) Line 1484  x_to_w32_color (colorname)
1484            pos = 0;            pos = 0;
1485            size /= 3;            size /= 3;
1486            colorval = 0;            colorval = 0;
1487              
1488            for (i = 0; i < 3; i++)            for (i = 0; i < 3; i++)
1489              {              {
1490                char *end;                char *end;
# Line 1550  x_to_w32_color (colorname) Line 1540  x_to_w32_color (colorname)
1540          {          {
1541            char *end;            char *end;
1542            unsigned long value;            unsigned long value;
1543              
1544            /* The check for 'x' in the following conditional takes into            /* The check for 'x' in the following conditional takes into
1545               account the fact that strtol allows a "0x" in front of               account the fact that strtol allows a "0x" in front of
1546               our numbers, and we don't.  */               our numbers, and we don't.  */
# Line 1637  x_to_w32_color (colorname) Line 1627  x_to_w32_color (colorname)
1627       RGB.  */       RGB.  */
1628    
1629    /* If we fail to lookup the color name in w32_color_map, then check the    /* If we fail to lookup the color name in w32_color_map, then check the
1630       colorname to see if it can be crudely approximated: If the X color       colorname to see if it can be crudely approximated: If the X color
1631       ends in a number (e.g., "darkseagreen2"), strip the number and       ends in a number (e.g., "darkseagreen2"), strip the number and
1632       return the result of looking up the base color name.  */       return the result of looking up the base color name.  */
1633    ret = w32_color_map_lookup (colorname);    ret = w32_color_map_lookup (colorname);
1634    if (NILP (ret))    if (NILP (ret))
1635      {      {
1636        int len = strlen (colorname);        int len = strlen (colorname);
1637    
1638        if (isdigit (colorname[len - 1]))        if (isdigit (colorname[len - 1]))
1639          {          {
1640            char *ptr, *approx = alloca (len + 1);            char *ptr, *approx = alloca (len + 1);
1641    
1642            strcpy (approx, colorname);            strcpy (approx, colorname);
1643            ptr = &approx[len - 1];            ptr = &approx[len - 1];
1644            while (ptr > approx && isdigit (*ptr))            while (ptr > approx && isdigit (*ptr))
1645                *ptr-- = '\0';                *ptr-- = '\0';
1646    
1647            ret = w32_color_map_lookup (approx);            ret = w32_color_map_lookup (approx);
1648          }          }
1649      }      }
1650      
1651    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1652    return ret;    return ret;
1653  }  }
# Line 1812  w32_defined_color (f, color, color_def, Line 1802  w32_defined_color (f, color, color_def,
1802    
1803    tem = x_to_w32_color (color);    tem = x_to_w32_color (color);
1804    
1805    if (!NILP (tem))    if (!NILP (tem))
1806      {      {
1807        if (f)        if (f)
1808          {          {
# Line 1829  w32_defined_color (f, color, color_def, Line 1819  w32_defined_color (f, color, color_def,
1819              one_w32_display_info.color_list;              one_w32_display_info.color_list;
1820            struct w32_palette_entry ** prev =            struct w32_palette_entry ** prev =
1821              &one_w32_display_info.color_list;              &one_w32_display_info.color_list;
1822          
1823            /* check if color is already mapped */            /* check if color is already mapped */
1824            while (entry)            while (entry)
1825              {              {
# Line 1865  w32_defined_color (f, color, color_def, Line 1855  w32_defined_color (f, color, color_def,
1855    
1856        return 1;        return 1;
1857      }      }
1858    else    else
1859      {      {
1860        return 0;        return 0;
1861      }      }
# Line 2048  x_set_mouse_color (f, arg, oldval) Line 2038  x_set_mouse_color (f, arg, oldval)
2038    else    else
2039      hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);      hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch);
2040    x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");    x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s");
2041      
2042    x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");    x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s");
2043    if (!EQ (Qnil, Vx_mode_pointer_shape))    if (!EQ (Qnil, Vx_mode_pointer_shape))
2044      {      {
# Line 2131  x_set_mouse_color (f, arg, oldval) Line 2121  x_set_mouse_color (f, arg, oldval)
2121        && f->output_data.w32->modeline_cursor != 0)        && f->output_data.w32->modeline_cursor != 0)
2122      XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);      XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor);
2123    f->output_data.w32->modeline_cursor = mode_cursor;    f->output_data.w32->modeline_cursor = mode_cursor;
2124      
2125    if (cross_cursor != f->output_data.w32->cross_cursor    if (cross_cursor != f->output_data.w32->cross_cursor
2126        && f->output_data.w32->cross_cursor != 0)        && f->output_data.w32->cross_cursor != 0)
2127      XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor);      XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->cross_cursor);
# Line 2161  x_set_cursor_color (f, arg, oldval) Line 2151  x_set_cursor_color (f, arg, oldval)
2151      fore_pixel = FRAME_BACKGROUND_PIXEL (f);      fore_pixel = FRAME_BACKGROUND_PIXEL (f);
2152    
2153    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));    pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
2154      
2155    /* Make sure that the cursor color differs from the background color.  */    /* Make sure that the cursor color differs from the background color.  */
2156    if (pixel == FRAME_BACKGROUND_PIXEL (f))    if (pixel == FRAME_BACKGROUND_PIXEL (f))
2157      {      {
# Line 2231  x_specified_cursor_type (arg, width) Line 2221  x_specified_cursor_type (arg, width)
2221       int *width;       int *width;
2222  {  {
2223    enum text_cursor_kinds type;    enum text_cursor_kinds type;
2224      
2225    if (EQ (arg, Qbar))    if (EQ (arg, Qbar))
2226      {      {
2227        type = BAR_CURSOR;        type = BAR_CURSOR;
# Line 2262  x_set_cursor_type (f, arg, oldval) Line 2252  x_set_cursor_type (f, arg, oldval)
2252       Lisp_Object arg, oldval;       Lisp_Object arg, oldval;
2253  {  {
2254    int width;    int width;
2255      
2256    FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width);    FRAME_DESIRED_CURSOR (f) = x_specified_cursor_type (arg, &width);
2257    f->output_data.w32->cursor_width = width;    f->output_data.w32->cursor_width = width;
2258    
# Line 2281  x_set_icon_type (f, arg, oldval) Line 2271  x_set_icon_type (f, arg, oldval)
2271    if (NILP (arg) && NILP (oldval))    if (NILP (arg) && NILP (oldval))
2272      return;      return;
2273    
2274    if (STRINGP (arg) && STRINGP (oldval)    if (STRINGP (arg) && STRINGP (oldval)
2275        && EQ (Fstring_equal (oldval, arg), Qt))        && EQ (Fstring_equal (oldval, arg), Qt))
2276      return;      return;
2277    
# Line 2386  x_set_font (f, arg, oldval) Line 2376  x_set_font (f, arg, oldval)
2376              ? x_new_fontset (f, XSTRING (fontset_name)->data)              ? x_new_fontset (f, XSTRING (fontset_name)->data)
2377              : x_new_font (f, XSTRING (arg)->data));              : x_new_font (f, XSTRING (arg)->data));
2378    UNBLOCK_INPUT;    UNBLOCK_INPUT;
2379      
2380    if (EQ (result, Qnil))    if (EQ (result, Qnil))
2381      error ("Font `%s' is not defined", XSTRING (arg)->data);      error ("Font `%s' is not defined", XSTRING (arg)->data);
2382    else if (EQ (result, Qt))    else if (EQ (result, Qt))
# Line 2641  x_set_name (f, name, explicit) Line 2631  x_set_name (f, name, explicit)
2631       Lisp_Object name;       Lisp_Object name;
2632       int explicit;       int explicit;
2633  {  {
2634    /* Make sure that requests from lisp code override requests from    /* Make sure that requests from lisp code override requests from
2635       Emacs redisplay code.  */       Emacs redisplay code.  */
2636    if (explicit)    if (explicit)
2637      {      {
# Line 2789  x_set_vertical_scroll_bars (f, arg, oldv Line 2779  x_set_vertical_scroll_bars (f, arg, oldv
2779          /* Put scroll bars on the right by default, as is conventional          /* Put scroll bars on the right by default, as is conventional
2780             on MS-Windows.  */             on MS-Windows.  */
2781          EQ (Qleft, arg)          EQ (Qleft, arg)
2782          ? vertical_scroll_bar_left          ? vertical_scroll_bar_left
2783          : vertical_scroll_bar_right;          : vertical_scroll_bar_right;
2784    
2785        /* We set this parameter before creating the window for the        /* We set this parameter before creating the window for the
# Line 2830  x_set_scroll_bar_width (f, arg, oldval) Line 2820  x_set_scroll_bar_width (f, arg, oldval)
2820      }      }
2821    change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);    change_frame_size (f, 0, FRAME_WIDTH (f), 0, 0, 0);
2822    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.hpos = 0;
2823    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;    XWINDOW (FRAME_SELECTED_WINDOW (f))->cursor.x = 0;
2824  }  }
2825    
2826  /* Subroutines of creating an frame.  */  /* Subroutines of creating an frame.  */
# Line 3060  w32_get_arg (alist, param, attribute, cl Line 3050  w32_get_arg (alist, param, attribute, cl
3050                if (!strcmp (XSTRING (tem)->data, "on")                if (!strcmp (XSTRING (tem)->data, "on")
3051                    || !strcmp (XSTRING (tem)->data, "true"))                    || !strcmp (XSTRING (tem)->data, "true"))
3052                  return Qt;                  return Qt;
3053                else                else
3054                  return Qnil;                  return Qnil;
3055    
3056              case RES_TYPE_STRING:              case RES_TYPE_STRING:
# Line 3308  x_figure_window_size (f, parms) Line 3298  x_figure_window_size (f, parms)
3298    
3299  extern LRESULT CALLBACK w32_wnd_proc ();  extern LRESULT CALLBACK w32_wnd_proc ();
3300    
3301  BOOL  BOOL
3302  w32_init_class (hinst)  w32_init_class (hinst)
3303       HINSTANCE hinst;       HINSTANCE hinst;
3304  {  {
# Line 3328  w32_init_class (hinst) Line 3318  w32_init_class (hinst)
3318    return (RegisterClass (&wc));    return (RegisterClass (&wc));
3319  }  }
3320    
3321  HWND  HWND
3322  w32_createscrollbar (f, bar)  w32_createscrollbar (f, bar)
3323       struct frame *f;       struct frame *f;
3324       struct scroll_bar * bar;       struct scroll_bar * bar;
# Line 3336  w32_createscrollbar (f, bar) Line 3326  w32_createscrollbar (f, bar)
3326    return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,    return (CreateWindow ("SCROLLBAR", "", SBS_VERT | WS_CHILD | WS_VISIBLE,
3327                          /* Position and size of scroll bar.  */                          /* Position and size of scroll bar.  */
3328                          XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM,                          XINT(bar->left) + VERTICAL_SCROLL_BAR_WIDTH_TRIM,
3329                          XINT(bar->top),                          XINT(bar->top),
3330                          XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,                          XINT(bar->width) - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
3331                          XINT(bar->height),                          XINT(bar->height),
3332                          FRAME_W32_WINDOW (f),                          FRAME_W32_WINDOW (f),
# Line 3345  w32_createscrollbar (f, bar) Line 3335  w32_createscrollbar (f, bar)
3335                          NULL));                          NULL));
3336  }  }
3337    
3338  void  void
3339  w32_createwindow (f)  w32_createwindow (f)
3340       struct frame *f;       struct frame *f;
3341  {  {
# Line 3355  w32_createwindow (f) Line 3345  w32_createwindow (f)
3345    rect.left = rect.top = 0;    rect.left = rect.top = 0;
3346    rect.right = PIXEL_WIDTH (f);    rect.right = PIXEL_WIDTH (f);
3347    rect.bottom = PIXEL_HEIGHT (f);    rect.bottom = PIXEL_HEIGHT (f);
3348          
3349    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
3350                      FRAME_EXTERNAL_MENU_BAR (f));                      FRAME_EXTERNAL_MENU_BAR (f));
3351      
3352    /* Do first time app init */    /* Do first time app init */
3353      
3354    if (!hprevinst)    if (!hprevinst)
3355      {      {
3356        w32_init_class (hinst);        w32_init_class (hinst);
3357      }      }
3358      
3359    FRAME_W32_WINDOW (f) = hwnd    FRAME_W32_WINDOW (f) = hwnd
3360      = CreateWindow (EMACS_CLASS,      = CreateWindow (EMACS_CLASS,
3361                      f->namebuf,                      f->namebuf,
# Line 3389  w32_createwindow (f) Line 3379  w32_createwindow (f)
3379    
3380        /* Enable drag-n-drop.  */        /* Enable drag-n-drop.  */
3381        DragAcceptFiles (hwnd, TRUE);        DragAcceptFiles (hwnd, TRUE);
3382          
3383        /* Do this to discard the default setting specified by our parent. */        /* Do this to discard the default setting specified by our parent. */
3384        ShowWindow (hwnd, SW_HIDE);        ShowWindow (hwnd, SW_HIDE);
3385      }      }
3386  }  }
3387    
3388  void  void
3389  my_post_msg (wmsg, hwnd, msg, wParam, lParam)  my_post_msg (wmsg, hwnd, msg, wParam, lParam)
3390       W32Msg * wmsg;       W32Msg * wmsg;
3391       HWND hwnd;       HWND hwnd;
# Line 3492  record_keyup (unsigned int wparam, unsig Line 3482  record_keyup (unsigned int wparam, unsig
3482  }  }
3483    
3484  /* Emacs can lose focus while a modifier key has been pressed.  When  /* Emacs can lose focus while a modifier key has been pressed.  When
3485     it regains focus, be conservative and clear all modifiers since     it regains focus, be conservative and clear all modifiers since
3486     we cannot reconstruct the left and right modifier state.  */     we cannot reconstruct the left and right modifier state.  */
3487  static void  static void
3488  reset_modifiers ()  reset_modifiers ()
# Line 3547  sync_modifiers () Line 3537  sync_modifiers ()
3537    if (!modifiers_recorded)    if (!modifiers_recorded)
3538      return;      return;
3539    
3540    if (!(GetKeyState (VK_CONTROL) & 0x8000))    if (!(GetKeyState (VK_CONTROL) & 0x8000))
3541      modifiers[EMACS_RCONTROL] = modifiers[EMACS_LCONTROL] = 0;      modifiers[EMACS_RCONTROL] = modifiers[EMACS_LCONTROL] = 0;
3542    
3543    if (!(GetKeyState (VK_MENU) & 0x8000))    if (!(GetKeyState (VK_MENU) & 0x8000))
3544      modifiers[EMACS_RMENU] = modifiers[EMACS_LMENU] = 0;      modifiers[EMACS_RMENU] = modifiers[EMACS_LMENU] = 0;
3545  }  }
3546    
# Line 3760  w32_msg_pump (deferred_msg * msg_buf) Line 3750  w32_msg_pump (deferred_msg * msg_buf)
3750    HWND focus_window;    HWND focus_window;
3751    
3752    msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);    msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
3753      
3754    while (GetMessage (&msg, NULL, 0, 0))    while (GetMessage (&msg, NULL, 0, 0))
3755      {      {
3756        if (msg.hwnd == NULL)        if (msg.hwnd == NULL)
# Line 3950  cancel_all_deferred_msgs () Line 3940  cancel_all_deferred_msgs ()
3940    PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0);    PostThreadMessage (dwWindowsThreadId, WM_NULL, 0, 0);
3941  }  }
3942    
3943  DWORD  DWORD
3944  w32_msg_worker (dw)  w32_msg_worker (dw)
3945       DWORD dw;       DWORD dw;
3946  {  {
# Line 3958  w32_msg_worker (dw) Line 3948  w32_msg_worker (dw)
3948    deferred_msg dummy_buf;    deferred_msg dummy_buf;
3949    
3950    /* Ensure our message queue is created */    /* Ensure our message queue is created */
3951      
3952    PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);    PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
3953      
3954    if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))    if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
3955      abort ();      abort ();
3956    
# Line 4039  post_character_message (hwnd, msg, wPara Line 4029  post_character_message (hwnd, msg, wPara
4029    
4030  /* Main window procedure */  /* Main window procedure */
4031    
4032  LRESULT CALLBACK  LRESULT CALLBACK
4033  w32_wnd_proc (hwnd, msg, wParam, lParam)  w32_wnd_proc (hwnd, msg, wParam, lParam)
4034       HWND hwnd;       HWND hwnd;
4035       UINT msg;       UINT msg;
# Line 4068  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4058  w32_wnd_proc (hwnd, msg, wParam, lParam)
4058       w32_clear_rect, because these functions must obtain a DC handle       w32_clear_rect, because these functions must obtain a DC handle
4059       from the frame struct using get_frame_dc which is thread-aware.  */       from the frame struct using get_frame_dc which is thread-aware.  */
4060    
4061    switch (msg)    switch (msg)
4062      {      {
4063      case WM_ERASEBKGND:      case WM_ERASEBKGND:
4064        f = x_window_to_frame (dpyinfo, hwnd);        f = x_window_to_frame (dpyinfo, hwnd);
# Line 4137  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4127  w32_wnd_proc (hwnd, msg, wParam, lParam)
4127              leave_crit ();              leave_crit ();
4128    
4129              my_post_msg (&wmsg, hwnd, msg, wParam, lParam);              my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4130              
4131              return 0;              return 0;
4132            }            }
4133    
# Line 4257  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4247  w32_wnd_proc (hwnd, msg, wParam, lParam)
4247              return 0;              return 0;
4248            break;            break;
4249          case VK_MENU:          case VK_MENU:
4250            if (NILP (Vw32_pass_alt_to_system))            if (NILP (Vw32_pass_alt_to_system))
4251              /* Prevent DefWindowProc from activating the menu bar if an              /* Prevent DefWindowProc from activating the menu bar if an
4252                 Alt key is pressed and released by itself.  */                 Alt key is pressed and released by itself.  */
4253              return 0;              return 0;
4254            windows_translate = 1;            windows_translate = 1;
4255            break;            break;
4256          case VK_CAPITAL:          case VK_CAPITAL:
4257            /* Decide whether to treat as modifier or function key.  */            /* Decide whether to treat as modifier or function key.  */
4258            if (NILP (Vw32_enable_caps_lock))            if (NILP (Vw32_enable_caps_lock))
4259              goto disable_lock_key;              goto disable_lock_key;
# Line 4300  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4290  w32_wnd_proc (hwnd, msg, wParam, lParam)
4290                                    w32_get_key_modifiers (wParam, lParam));                                    w32_get_key_modifiers (wParam, lParam));
4291            windows_translate = 1;            windows_translate = 1;
4292            break;            break;
4293          case VK_CONTROL:          case VK_CONTROL:
4294          case VK_SHIFT:          case VK_SHIFT:
4295          case VK_PROCESSKEY:  /* Generated by IME.  */          case VK_PROCESSKEY:  /* Generated by IME.  */
4296            windows_translate = 1;            windows_translate = 1;
# Line 4358  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4348  w32_wnd_proc (hwnd, msg, wParam, lParam)
4348                        int add;                        int add;
4349                        int isdead = 0;                        int isdead = 0;
4350                        KEY_EVENT_RECORD key;                        KEY_EVENT_RECORD key;
4351                      
4352                        key.bKeyDown = TRUE;                        key.bKeyDown = TRUE;
4353                        key.wRepeatCount = 1;                        key.wRepeatCount = 1;
4354                        key.wVirtualKeyCode = wParam;                        key.wVirtualKeyCode = wParam;
# Line 4399  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4389  w32_wnd_proc (hwnd, msg, wParam, lParam)
4389          }          }
4390    
4391        /* Fall through */        /* Fall through */
4392          
4393      case WM_SYSCHAR:      case WM_SYSCHAR:
4394      case WM_CHAR:      case WM_CHAR:
4395        post_character_message (hwnd, msg, wParam, lParam,        post_character_message (hwnd, msg, wParam, lParam,
# Line 4530  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4520  w32_wnd_proc (hwnd, msg, wParam, lParam)
4520            {            {
4521              if (up) ReleaseCapture ();              if (up) ReleaseCapture ();
4522              else SetCapture (hwnd);              else SetCapture (hwnd);
4523              button = (button == 0) ? LMOUSE :              button = (button == 0) ? LMOUSE :
4524                ((button == 1) ? MMOUSE  : RMOUSE);                ((button == 1) ? MMOUSE  : RMOUSE);
4525              if (up)              if (up)
4526                button_state &= ~button;                button_state &= ~button;
# Line 4538  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4528  w32_wnd_proc (hwnd, msg, wParam, lParam)
4528                button_state |= button;                button_state |= button;
4529            }            }
4530        }        }
4531          
4532        wmsg.dwModifiers = w32_get_modifiers ();        wmsg.dwModifiers = w32_get_modifiers ();
4533        my_post_msg (&wmsg, hwnd, msg, wParam, lParam);        my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4534        return 0;        return 0;
# Line 4552  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4542  w32_wnd_proc (hwnd, msg, wParam, lParam)
4542            my_post_msg (&wmsg, hwnd, msg, wParam, lParam);            my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4543            return 0;            return 0;
4544          }          }
4545      
4546        /* Hang onto mouse move and scroll messages for a bit, to avoid        /* Hang onto mouse move and scroll messages for a bit, to avoid
4547           sending such events to Emacs faster than it can process them.           sending such events to Emacs faster than it can process them.
4548           If we get more events before the timer from the first message           If we get more events before the timer from the first message
# Line 4570  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4560  w32_wnd_proc (hwnd, msg, wParam, lParam)
4560        saved_mouse_move_msg.msg.lParam = lParam;        saved_mouse_move_msg.msg.lParam = lParam;
4561        saved_mouse_move_msg.msg.time = GetMessageTime ();        saved_mouse_move_msg.msg.time = GetMessageTime ();
4562        saved_mouse_move_msg.dwModifiers = w32_get_modifiers ();        saved_mouse_move_msg.dwModifiers = w32_get_modifiers ();
4563      
4564        return 0;        return 0;
4565    
4566      case WM_MOUSEWHEEL:      case WM_MOUSEWHEEL:
# Line 4606  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4596  w32_wnd_proc (hwnd, msg, wParam, lParam)
4596            mouse_move_timer = 0;            mouse_move_timer = 0;
4597          }          }
4598        return 0;        return 0;
4599      
4600      case WM_NCACTIVATE:      case WM_NCACTIVATE:
4601        /* Windows doesn't send us focus messages when putting up and        /* Windows doesn't send us focus messages when putting up and
4602           taking down a system popup dialog as for Ctrl-Alt-Del on Windows 95.           taking down a system popup dialog as for Ctrl-Alt-Del on Windows 95.
# Line 4800  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4790  w32_wnd_proc (hwnd, msg, wParam, lParam)
4790    
4791          wp.length = sizeof (WINDOWPLACEMENT);          wp.length = sizeof (WINDOWPLACEMENT);
4792          GetWindowPlacement (hwnd, &wp);          GetWindowPlacement (hwnd, &wp);
4793            
4794          if (wp.showCmd != SW_SHOWMINIMIZED && (lppos->flags & SWP_NOSIZE) == 0)          if (wp.showCmd != SW_SHOWMINIMIZED && (lppos->flags & SWP_NOSIZE) == 0)
4795            {            {
4796              RECT rect;              RECT rect;
# Line 4811  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4801  w32_wnd_proc (hwnd, msg, wParam, lParam)
4801              DWORD internal_border;              DWORD internal_border;
4802              DWORD scrollbar_extra;              DWORD scrollbar_extra;
4803              RECT wr;              RECT wr;
4804                
4805              wp.length = sizeof(wp);              wp.length = sizeof(wp);
4806              GetWindowRect (hwnd, &wr);              GetWindowRect (hwnd, &wr);
4807                
4808              enter_crit ();              enter_crit ();
4809                
4810              font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX);              font_width = GetWindowLong (hwnd, WND_FONTWIDTH_INDEX);
4811              line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX);              line_height = GetWindowLong (hwnd, WND_LINEHEIGHT_INDEX);
4812              internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX);              internal_border = GetWindowLong (hwnd, WND_BORDER_INDEX);
4813              scrollbar_extra = GetWindowLong (hwnd, WND_SCROLLBAR_INDEX);              scrollbar_extra = GetWindowLong (hwnd, WND_SCROLLBAR_INDEX);
4814                
4815              leave_crit ();              leave_crit ();
4816                
4817              memset (&rect, 0, sizeof (rect));              memset (&rect, 0, sizeof (rect));
4818              AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE),              AdjustWindowRect (&rect, GetWindowLong (hwnd, GWL_STYLE),
4819                                GetMenu (hwnd) != NULL);                                GetMenu (hwnd) != NULL);
4820    
4821              /* Force width and height of client area to be exact              /* Force width and height of client area to be exact
# Line 4836  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4826  w32_wnd_proc (hwnd, msg, wParam, lParam)
4826              hdiff = (lppos->cy - (rect.bottom - rect.top)              hdiff = (lppos->cy - (rect.bottom - rect.top)
4827                       - 2 * internal_border)                       - 2 * internal_border)
4828                % line_height;                % line_height;
4829                
4830              if (wdiff || hdiff)              if (wdiff || hdiff)
4831                {                {
4832                  /* For right/bottom sizing we can just fix the sizes.                    /* For right/bottom sizing we can just fix the sizes.
4833                     However for top/left sizing we will need to fix the X                     However for top/left sizing we will need to fix the X
4834                     and Y positions as well.  */                     and Y positions as well.  */
4835                    
4836                  lppos->cx -= wdiff;                  lppos->cx -= wdiff;
4837                  lppos->cy -= hdiff;                  lppos->cy -= hdiff;
4838                    
4839                  if (wp.showCmd != SW_SHOWMAXIMIZED                  if (wp.showCmd != SW_SHOWMAXIMIZED
4840                      && (lppos->flags & SWP_NOMOVE) == 0)                      && (lppos->flags & SWP_NOMOVE) == 0)
4841                    {                    {
4842                      if (lppos->x != wr.left || lppos->y != wr.top)                      if (lppos->x != wr.left || lppos->y != wr.top)
# Line 4859  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4849  w32_wnd_proc (hwnd, msg, wParam, lParam)
4849                          lppos->flags |= SWP_NOMOVE;                          lppos->flags |= SWP_NOMOVE;
4850                        }                        }
4851                    }                    }
4852                    
4853                  return 0;                  return 0;
4854                }                }
4855            }            }
4856        }        }
4857          
4858        goto dflt;        goto dflt;
4859    
4860      case WM_GETMINMAXINFO:      case WM_GETMINMAXINFO:
# Line 4932  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4922  w32_wnd_proc (hwnd, msg, wParam, lParam)
4922            flags |= TPM_LEFTBUTTON;            flags |= TPM_LEFTBUTTON;
4923          else if (button_state & RMOUSE)          else if (button_state & RMOUSE)
4924            flags |= TPM_RIGHTBUTTON;            flags |= TPM_RIGHTBUTTON;
4925            
4926          /* Remember we did a SetCapture on the initial mouse down event,          /* Remember we did a SetCapture on the initial mouse down event,
4927             so for safety, we make sure the capture is cancelled now.  */             so for safety, we make sure the capture is cancelled now.  */
4928          ReleaseCapture ();          ReleaseCapture ();
# Line 4943  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4933  w32_wnd_proc (hwnd, msg, wParam, lParam)
4933          f = x_window_to_frame (dpyinfo, hwnd);          f = x_window_to_frame (dpyinfo, hwnd);
4934          if (f)          if (f)
4935            f->output_data.w32->menubar_active = 1;            f->output_data.w32->menubar_active = 1;
4936            
4937          if (TrackPopupMenu ((HMENU)wParam, flags, pos->x, pos->y,          if (TrackPopupMenu ((HMENU)wParam, flags, pos->x, pos->y,
4938                              0, hwnd, NULL))                              0, hwnd, NULL))
4939            {            {
4940              MSG amsg;              MSG amsg;
# Line 4977  w32_wnd_proc (hwnd, msg, wParam, lParam) Line 4967  w32_wnd_proc (hwnd, msg, wParam, lParam)
4967            my_post_msg (&wmsg, hwnd, msg, wParam, lParam);            my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4968            return 0;            return 0;
4969          }          }
4970          
4971      dflt:      dflt:
4972        return DefWindowProc (hwnd, msg, wParam, lParam);        return DefWindowProc (hwnd, msg, wParam, lParam);
4973      }      }
4974      
4975    
4976    /* The most common default return code for handled messages is 0.  */    /* The most common default return code for handled messages is 0.  */
4977    return 0;    return 0;
4978  }  }
4979    
4980  void  void
4981  my_create_window (f)  my_create_window (f)
4982       struct frame * f;       struct frame * f;
4983  {  {
# Line 5013  w32_window (f, window_prompting, minibuf Line 5003  w32_window (f, window_prompting, minibuf
5003       for the window manager, so GC relocation won't bother it.       for the window manager, so GC relocation won't bother it.
5004    
5005       Elsewhere we specify the window name for the window manager.  */       Elsewhere we specify the window name for the window manager.  */
5006        
5007    {    {
5008      char *str = (char *) XSTRING (Vx_resource_name)->data;      char *str = (char *) XSTRING (Vx_resource_name)->data;
5009      f->namebuf = (char *) xmalloc (strlen (str) + 1);      f->namebuf = (char *) xmalloc (strlen (str) + 1);
# Line 5137  unwind_create_frame (frame) Line 5127  unwind_create_frame (frame)
5127  #ifdef GLYPH_DEBUG  #ifdef GLYPH_DEBUG
5128        struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);        struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
5129  #endif  #endif
5130          
5131        x_free_frame_resources (f);        x_free_frame_resources (f);
5132    
5133        /* Check that reference counts are indeed correct.  */        /* Check that reference counts are indeed correct.  */
# Line 5146  unwind_create_frame (frame) Line 5136  unwind_create_frame (frame)
5136    
5137        return Qt;        return Qt;
5138      }      }
5139      
5140    return Qnil;    return Qnil;
5141  }  }
5142    
# Line 5310  This function is an internal primitive-- Line 5300  This function is an internal primitive--
5300      if (! STRINGP (font))      if (! STRINGP (font))
5301        font = build_string ("Fixedsys");        font = build_string ("Fixedsys");
5302    
5303      x_default_parameter (f, parms, Qfont, font,      x_default_parameter (f, parms, Qfont, font,
5304                           "font", "Font", RES_TYPE_STRING);                           "font", "Font", RES_TYPE_STRING);
5305    }    }
5306    
# Line 5359  This function is an internal primitive-- Line 5349  This function is an internal primitive--
5349       end up in init_iterator with a null face cache, which should not       end up in init_iterator with a null face cache, which should not
5350       happen.  */       happen.  */
5351    init_frame_faces (f);    init_frame_faces (f);
5352      
5353    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
5354                         "menuBar", "MenuBar", RES_TYPE_NUMBER);                         "menuBar", "MenuBar", RES_TYPE_NUMBER);
5355    x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),    x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),
# Line 5431  This function is an internal primitive-- Line 5421  This function is an internal primitive--
5421    if (FRAME_TOOL_BAR_LINES (f))    if (FRAME_TOOL_BAR_LINES (f))
5422      {      {
5423        int margin, relief, bar_height;        int margin, relief, bar_height;
5424          
5425        relief = (tool_bar_button_relief > 0        relief = (tool_bar_button_relief > 0
5426                  ? tool_bar_button_relief                  ? tool_bar_button_relief
5427                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);                  : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
# Line 5445  This function is an internal primitive-- Line 5435  This function is an internal primitive--
5435          margin = XFASTINT (XCDR (Vtool_bar_button_margin));          margin = XFASTINT (XCDR (Vtool_bar_button_margin));
5436        else        else
5437          margin = 0;          margin = 0;
5438              
5439        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;        bar_height = DEFAULT_TOOL_BAR_IMAGE_HEIGHT + 2 * margin + 2 * relief;
5440        height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);        height += (bar_height + CANON_Y_UNIT (f) - 1) / CANON_Y_UNIT (f);
5441      }      }
# Line 5492  This function is an internal primitive-- Line 5482  This function is an internal primitive--
5482          ;          ;
5483      }      }
5484    UNGCPRO;    UNGCPRO;
5485      
5486    /* Make sure windows on this frame appear in calls to next-window    /* Make sure windows on this frame appear in calls to next-window
5487       and similar functions.  */       and similar functions.  */
5488    Vwindow_list = Qnil;    Vwindow_list = Qnil;
5489      
5490    return unbind_to (count, frame);    return unbind_to (count, frame);
5491  }  }
5492    
# Line 5633  w32_load_system_font (f,fontname,size) Line 5623  w32_load_system_font (f,fontname,size)
5623    
5624      font->hfont = CreateFontIndirect (&lf);      font->hfont = CreateFontIndirect (&lf);
5625    
5626      if (font->hfont == NULL)      if (font->hfont == NULL)
5627        {        {
5628          ok = FALSE;          ok = FALSE;
5629        }        }
5630      else      else
5631        {        {
5632          HDC hdc;          HDC hdc;
5633          HANDLE oldobj;          HANDLE oldobj;
# Line 5806  int size; Line 5796  int size;
5796  }  }
5797    
5798    
5799  void  void
5800  w32_unload_font (dpyinfo, font)  w32_unload_font (dpyinfo, font)
5801       struct w32_display_info *dpyinfo;       struct w32_display_info *dpyinfo;
5802       XFontStruct * font;       XFontStruct * font;
5803  {  {
5804    if (font)    if (font)
5805      {      {
5806        if (font->per_char) xfree (font->per_char);        if (font->per_char) xfree (font->per_char);
5807        if (font->bdf) w32_free_bdf_font (font->bdf);        if (font->bdf) w32_free_bdf_font (font->bdf);
# Line 5844  w32_unload_font (dpyinfo, font) Line 5834  w32_unload_font (dpyinfo, font)
5834   *      )   *      )
5835   */   */
5836    
5837  static LONG  static LONG
5838  x_to_w32_weight (lpw)  x_to_w32_weight (lpw)
5839       char * lpw;       char * lpw;
5840  {  {
# Line 5865  x_to_w32_weight (lpw) Line 5855  x_to_w32_weight (lpw)
5855  }  }
5856    
5857    
5858  static char *  static char *
5859  w32_to_x_weight (fnweight)  w32_to_x_weight (fnweight)
5860       int fnweight;       int fnweight;
5861  {  {
# Line 6052  w32_to_x_charset (fncharset) Line 6042  w32_to_x_charset (fncharset)
6042        sprintf (buf, "*-#%u", fncharset);        sprintf (buf, "*-#%u", fncharset);
6043        return buf;        return buf;
6044      }      }
6045      
6046    {    {
6047      Lisp_Object rest;      Lisp_Object rest;
6048      char * best_match = NULL;      char * best_match = NULL;
# Line 6106  w32_to_x_charset (fncharset) Line 6096  w32_to_x_charset (fncharset)
6096                  int this_enc = atoi (x_charset + 8);                  int this_enc = atoi (x_charset + 8);
6097                  if (this_enc > 0 && this_enc < best_enc)                  if (this_enc > 0 && this_enc < best_enc)
6098                    best_match = x_charset;                    best_match = x_charset;
6099                }                                }
6100            }            }
6101        }        }
6102    
# Line 6212  w32_to_all_x_charsets (fncharset) Line 6202  w32_to_all_x_charsets (fncharset)
6202        sprintf (buf, "*-#%u", fncharset);        sprintf (buf, "*-#%u", fncharset);
6203        return Fcons (build_string (buf), Qnil);        return Fcons (build_string (buf), Qnil);
6204      }      }
6205      
6206    {    {
6207      Lisp_Object rest;      Lisp_Object rest;
6208      /* Look through w32-charset-info-alist for the character set.      /* Look through w32-charset-info-alist for the character set.
# Line 6263  w32_to_all_x_charsets (fncharset) Line 6253  w32_to_all_x_charsets (fncharset)
6253  /* Get the Windows codepage corresponding to the specified font.  The  /* Get the Windows codepage corresponding to the specified font.  The
6254     charset info in the font name is used to look up     charset info in the font name is used to look up
6255     w32-charset-to-codepage-alist.  */     w32-charset-to-codepage-alist.  */
6256  int  int
6257  w32_codepage_for_font (char *fontname)  w32_codepage_for_font (char *fontname)
6258  {  {
6259    Lisp_Object codepage, entry;    Lisp_Object codepage, entry;
# Line 6314  w32_codepage_for_font (char *fontname) Line 6304  w32_codepage_for_font (char *fontname)
6304  }  }
6305    
6306    
6307  static BOOL  static BOOL
6308  w32_to_x_font (lplogfont, lpxstr, len, specific_charset)  w32_to_x_font (lplogfont, lpxstr, len, specific_charset)
6309       LOGFONT * lplogfont;       LOGFONT * lplogfont;
6310       char * lpxstr;       char * lpxstr;
# Line 6397  w32_to_x_font (lplogfont, lpxstr, len, s Line 6387  w32_to_x_font (lplogfont, lpxstr, len, s
6387               ? 'p' : 'c',                            /* spacing */               ? 'p' : 'c',                            /* spacing */
6388               width_pixels,                           /* avg width */               width_pixels,                           /* avg width */
6389               specific_charset ? specific_charset               specific_charset ? specific_charset
6390               : w32_to_x_charset (lplogfont->lfCharSet)               : w32_to_x_charset (lplogfont->lfCharSet)
6391               /* charset registry and encoding */               /* charset registry and encoding */
6392               );               );
6393    
# Line 6405  w32_to_x_font (lplogfont, lpxstr, len, s Line 6395  w32_to_x_font (lplogfont, lpxstr, len, s
6395    return (TRUE);    return (TRUE);
6396  }  }
6397    
6398  static BOOL  static BOOL
6399  x_to_w32_font (lpxstr, lplogfont)  x_to_w32_font (lpxstr, lplogfont)
6400       char * lpxstr;       char * lpxstr;
6401       LOGFONT * lplogfont;       LOGFONT * lplogfont;
# Line 6440  x_to_w32_font (lpxstr, lplogfont) Line 6430  x_to_w32_font (lpxstr, lplogfont)
6430     * format:     * format:
6431     *   "<font name>[:height in pixels[:width in pixels[:weight]]]"     *   "<font name>[:height in pixels[:width in pixels[:weight]]]"
6432     */     */
6433      
6434    if (*lpxstr == '-')    if (*lpxstr == '-')
6435      {      {
6436        int fields, tem;        int fields, tem;
# Line 6708  xlfd_strip_height (char *fontname) Line 6698  xlfd_strip_height (char *fontname)
6698  }  }
6699    
6700  /* Assume parameter 1 is fully qualified, no wildcards. */  /* Assume parameter 1 is fully qualified, no wildcards. */
6701  static BOOL  static BOOL
6702  w32_font_match (fontname, pattern)  w32_font_match (fontname, pattern)
6703      char * fontname;      char * fontname;
6704      char * pattern;      char * pattern;
# Line 6770  w32_font_match (fontname, pattern) Line 6760  w32_font_match (fontname, pattern)
6760     font from each family, the second pass lists all the fonts from     font from each family, the second pass lists all the fonts from
6761     each family.  */     each family.  */
6762    
6763  typedef struct enumfont_t  typedef struct enumfont_t
6764  {  {
6765    HDC hdc;    HDC hdc;
6766    int numFonts;    int numFonts;
# Line 6784  typedef struct enumfont_t Line 6774  typedef struct enumfont_t
6774  static void  static void
6775  enum_font_maybe_add_to_list (enumfont_t *, LOGFONT *, char *, Lisp_Object);  enum_font_maybe_add_to_list (enumfont_t *, LOGFONT *, char *, Lisp_Object);
6776    
6777  static int CALLBACK  static int CALLBACK
6778  enum_font_cb2 (lplf, lptm, FontType, lpef)  enum_font_cb2 (lplf, lptm, FontType, lpef)
6779      ENUMLOGFONT * lplf;      ENUMLOGFONT * lplf;
6780      NEWTEXTMETRIC * lptm;      NEWTEXTMETRIC * lptm;
# Line 6941  enum_font_maybe_add_to_list (lpef, logfo Line 6931  enum_font_maybe_add_to_list (lpef, logfo
6931  }  }
6932    
6933    
6934  static int CALLBACK  static int CALLBACK
6935  enum_font_cb1 (lplf, lptm, FontType, lpef)  enum_font_cb1 (lplf, lptm, FontType, lpef)
6936       ENUMLOGFONT * lplf;       ENUMLOGFONT * lplf;
6937       NEWTEXTMETRIC * lptm;       NEWTEXTMETRIC * lptm;
# Line 7127  w32_list_fonts (f, pattern, size, maxnam Line 7117  w32_list_fonts (f, pattern, size, maxnam
7117    
7118        newlist = second_best = Qnil;        newlist = second_best = Qnil;
7119    
7120        /* Make a list of the fonts that have the right width.  */                  /* Make a list of the fonts that have the right width.  */
7121        for (; CONSP (list); list = XCDR (list))        for (; CONSP (list); list = XCDR (list))
7122          {          {
7123            int found_size;            int found_size;
# Line 7189  w32_list_fonts (f, pattern, size, maxnam Line 7179  w32_list_fonts (f, pattern, size, maxnam
7179              {              {
7180                if (NILP (second_best))                if (NILP (second_best))
7181                  second_best = tem;                  second_best = tem;
7182                      
7183                else if (found_size < size)                else if (found_size < size)
7184                  {                  {
7185                    if (XINT (XCDR (second_best)) > size                    if (XINT (XCDR (second_best)) > size
# Line 7474  If omitted or nil, that stands for the s Line 7464  If omitted or nil, that stands for the s
7464       and because probably is more meaningful on Windows anyway */       and because probably is more meaningful on Windows anyway */
7465    if (cap < 0)    if (cap < 0)
7466      cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24);      cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, 24);
7467      
7468    ReleaseDC (dpyinfo->root_window, hdc);    ReleaseDC (dpyinfo->root_window, hdc);
7469      
7470    return make_number (cap);    return make_number (cap);
7471  }  }
7472    
# Line 7546  If omitted or nil, that stands for the s Line 7536  If omitted or nil, that stands for the s
7536    int cap;    int cap;
7537    
7538    hdc = GetDC (dpyinfo->root_window);    hdc = GetDC (dpyinfo->root_window);
7539      
7540    cap = GetDeviceCaps (hdc, VERTSIZE);    cap = GetDeviceCaps (hdc, VERTSIZE);
7541      
7542    ReleaseDC (dpyinfo->root_window, hdc);    ReleaseDC (dpyinfo->root_window, hdc);
7543      
7544    return make_number (cap);    return make_number (cap);
7545  }  }
7546    
# Line 7568  If omitted or nil, that stands for the s Line 7558  If omitted or nil, that stands for the s
7558    int cap;    int cap;
7559    
7560    hdc = GetDC (dpyinfo->root_window);    hdc = GetDC (dpyinfo->root_window);
7561      
7562    cap = GetDeviceCaps (hdc, HORZSIZE);    cap = GetDeviceCaps (hdc, HORZSIZE);
7563      
7564    ReleaseDC (dpyinfo->root_window, hdc);    ReleaseDC (dpyinfo->root_window, hdc);
7565      
7566    return make_number (cap);    return make_number (cap);
7567  }  }
7568    
# Line 7941  valid_image_p (object) Line 7931  valid_image_p (object)
7931       Lisp_Object object;       Lisp_Object object;
7932  {  {
7933    int valid_p = 0;    int valid_p = 0;
7934      
7935    if (CONSP (object) && EQ (XCAR (object), Qimage))    if (CONSP (object) && EQ (XCAR (object), Qimage))
7936      {      {
7937        Lisp_Object symbol = Fplist_get (XCDR (object), QCtype);        Lisp_Object symbol = Fplist_get (XCDR (object), QCtype);
7938        struct image_type *type = lookup_image_type (symbol);        struct image_type *type = lookup_image_type (symbol);
7939          
7940        if (type)        if (type)
7941          valid_p = type->valid_p (object);          valid_p = type->valid_p (object);
7942      }      }
# Line 8064  parse_image_spec (spec, keywords, nkeywo Line 8054  parse_image_spec (spec, keywords, nkeywo
8054           was found more than once, it's an error.  */           was found more than once, it's an error.  */
8055        keywords[i].value = value;        keywords[i].value = value;
8056        ++keywords[i].count;        ++keywords[i].count;
8057          
8058        if (keywords[i].count > 1)        if (keywords[i].count > 1)
8059          return 0;          return 0;
8060    
# Line 8114  parse_image_spec (spec, keywords, nkeywo Line 8104  parse_image_spec (spec, keywords, nkeywo
8104    
8105          case IMAGE_FUNCTION_VALUE:          case IMAGE_FUNCTION_VALUE:
8106            value = indirect_function (value);            value = indirect_function (value);
8107            if (SUBRP (value)            if (SUBRP (value)
8108                || COMPILEDP (value)                || COMPILEDP (value)
8109                || (CONSP (value) && EQ (XCAR (value), Qlambda)))                || (CONSP (value) && EQ (XCAR (value), Qlambda)))
8110              break;              break;
# Line 8163  image_spec_value (spec, key, found) Line 8153  image_spec_value (spec, key, found)
8153       int *found;       int *found;
8154  {  {
8155    Lisp_Object tail;    Lisp_Object tail;
8156      
8157    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
8158    
8159    for (tail = XCDR (spec);    for (tail = XCDR (spec);
# Line 8177  image_spec_value (spec, key, found) Line 8167  image_spec_value (spec, key, found)
8167            return XCAR (XCDR (tail));            return XCAR (XCDR (tail));
8168          }          }
8169      }      }
8170      
8171    if (found)    if (found)
8172      *found = 0;      *found = 0;
8173    return Qnil;    return Qnil;
8174  }  }
8175        
8176    
8177    
8178    
# Line 8203  make_image (spec, hash) Line 8193  make_image (spec, hash)
8193       unsigned hash;       unsigned hash;
8194  {  {
8195    struct image *img = (struct image *) xmalloc (sizeof *img);    struct image *img = (struct image *) xmalloc (sizeof *img);
8196      
8197    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
8198    bzero (img, sizeof *img);    bzero (img, sizeof *img);
8199    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));    img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
# Line 8264  prepare_image_for_display (f, img) Line 8254  prepare_image_for_display (f, img)
8254    if (img->pixmap == 0 && !img->load_failed_p)    if (img->pixmap == 0 && !img->load_failed_p)
8255      img->load_failed_p = img->type->load (f, img) == 0;      img->load_failed_p = img->type->load (f, img) == 0;
8256  }  }
8257        
8258    
8259  /* Value is the number of pixels for the ascent of image IMG when  /* Value is the number of pixels for the ascent of image IMG when
8260     drawn in face FACE.  */     drawn in face FACE.  */
# Line 8323  x_clear_image (f, img) Line 8313  x_clear_image (f, img)
8313    if (img->ncolors)    if (img->ncolors)
8314      {      {
8315        int class = FRAME_W32_DISPLAY_INFO (f)->visual->class;        int class = FRAME_W32_DISPLAY_INFO (f)->visual->class;
8316          
8317        /* If display has an immutable color map, freeing colors is not        /* If display has an immutable color map, freeing colors is not
8318           necessary and some servers don't allow it.  So don't do it.  */           necessary and some servers don't allow it.  So don't do it.  */
8319        if (class != StaticColor        if (class != StaticColor
# Line 8337  x_clear_image (f, img) Line 8327  x_clear_image (f, img)
8327                         img->ncolors, 0);                         img->ncolors, 0);
8328            UNBLOCK_INPUT;            UNBLOCK_INPUT;
8329          }          }
8330          
8331        xfree (img->colors);        xfree (img->colors);
8332        img->colors = NULL;        img->colors = NULL;
8333        img->ncolors = 0;        img->ncolors = 0;
# Line 8399  make_image_cache () Line 8389  make_image_cache ()
8389  {  {
8390    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);    struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
8391    int size;    int size;
8392      
8393    bzero (c, sizeof *c);    bzero (c, sizeof *c);
8394    c->size = 50;    c->size = 50;
8395    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);    c->images = (struct image **) xmalloc (c->size * sizeof *c->images);
# Line 8424  free_image_cache (f) Line 8414  free_image_cache (f)
8414    
8415        /* Cache should not be referenced by any frame when freed.  */        /* Cache should not be referenced by any frame when freed.  */
8416        xassert (c->refcount == 0);        xassert (c->refcount == 0);
8417          
8418        for (i = 0; i < c->used; ++i)        for (i = 0; i < c->used; ++i)
8419          free_image (f, c->images[i]);          free_image (f, c->images[i]);
8420        xfree (c->images);        xfree (c->images);
# Line 8457  clear_image_cache (f, force_p) Line 8447  clear_image_cache (f, force_p)
8447    
8448        EMACS_GET_TIME (t);        EMACS_GET_TIME (t);
8449        old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);        old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
8450          
8451        for (i = 0; i < c->used; ++i)        for (i = 0; i < c->used; ++i)
8452          {          {
8453            struct image *img = c->images[i];            struct image *img = c->images[i];
# Line 8494  FRAME t means clear the image caches of Line 8484  FRAME t means clear the image caches of
8484    if (EQ (frame, Qt))    if (EQ (frame, Qt))
8485      {      {
8486        Lisp_Object tail;        Lisp_Object tail;
8487          
8488        FOR_EACH_FRAME (tail, frame)        FOR_EACH_FRAME (tail, frame)
8489          if (FRAME_W32_P (XFRAME (frame)))          if (FRAME_W32_P (XFRAME (frame)))
8490            clear_image_cache (XFRAME (frame), 1);            clear_image_cache (XFRAME (frame), 1);
# Line 8525  lookup_image (f, spec) Line 8515  lookup_image (f, spec)
8515       specification.  */       specification.  */
8516    xassert (FRAME_WINDOW_P (f));    xassert (FRAME_WINDOW_P (f));
8517    xassert (valid_image_p (spec));    xassert (valid_image_p (spec));
8518      
8519    GCPRO1 (spec);    GCPRO1 (spec);
8520    
8521    /* Look up SPEC in the hash table of the image cache.  */    /* Look up SPEC in the hash table of the image cache.  */
# Line 8581  lookup_image (f, spec) Line 8571  lookup_image (f, spec)
8571                if (XINT (XCDR (margin)) > 0)                if (XINT (XCDR (margin)) > 0)
8572                  img->vmargin = XFASTINT (XCDR (margin));                  img->vmargin = XFASTINT (XCDR (margin));
8573              }              }
8574              
8575            relief = image_spec_value (spec, QCrelief, NULL);            relief = image_spec_value (spec, QCrelief, NULL);
8576            if (INTEGERP (relief))            if (INTEGERP (relief))
8577              {              {
# Line 8603  lookup_image (f, spec) Line 8593  lookup_image (f, spec)
8593                          image.                          image.
8594                   `:mask nil'                   `:mask nil'
8595                          means remove a mask, if any.  */                          means remove a mask, if any.  */
8596                  
8597                Lisp_Object mask;                Lisp_Object mask;
8598    
8599                mask = image_spec_value (spec, QCheuristic_mask, NULL);                mask = image_spec_value (spec, QCheuristic_mask, NULL);
# Line 8612  lookup_image (f, spec) Line 8602  lookup_image (f, spec)
8602                else                else
8603                  {                  {
8604                    int found_p;                    int found_p;
8605                        
8606                    mask = image_spec_value (spec, QCmask, &found_p);                    mask = image_spec_value (spec, QCmask, &found_p);
8607                      
8608                    if (EQ (mask, Qheuristic))                    if (EQ (mask, Qheuristic))
8609                      x_build_heuristic_mask (f, img, Qt);                      x_build_heuristic_mask (f, img, Qt);
8610                    else if (CONSP (mask)                    else if (CONSP (mask)
# Line 8632  lookup_image (f, spec) Line 8622  lookup_image (f, spec)
8622                      }                      }
8623                  }                  }
8624              }              }
8625              
8626            /* Should we apply an image transformation algorithm?  */            /* Should we apply an image transformation algorithm?  */
8627            if (img->pixmap)            if (img->pixmap)
8628              {              {
# Line 8665  lookup_image (f, spec) Line 8655  lookup_image (f, spec)
8655    /* We're using IMG, so set its timestamp to `now'.  */    /* We're using IMG, so set its timestamp to `now'.  */
8656    EMACS_GET_TIME (now);    EMACS_GET_TIME (now);
8657    img->timestamp = EMACS_SECS (now);    img->timestamp = EMACS_SECS (now);
8658      
8659    UNGCPRO;    UNGCPRO;
8660      
8661    /* Value is the image id.  */    /* Value is the image id.  */
8662    return img->id;    return img->id;
8663  }  }
# Line 8821  x_put_x_image (f, ximg, pixmap, width, h Line 8811  x_put_x_image (f, ximg, pixmap, width, h
8811       Pixmap pixmap;       Pixmap pixmap;
8812  {  {
8813    GC gc;    GC gc;
8814      
8815    xassert (interrupt_input_blocked);    xassert (interrupt_input_blocked);
8816    gc = XCreateGC (NULL, pixmap, 0, NULL);    gc = XCreateGC (NULL, pixmap, 0, NULL);
8817    XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height);    XPutImage (NULL, pixmap, gc, ximg, 0, 0, 0, 0, width, height);
# Line 8855  x_find_image_file (file) Line 8845  x_find_image_file (file)
8845    
8846    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */    /* Try to find FILE in data-directory, then x-bitmap-file-path.  */
8847    fd = openp (search_path, file, "", &file_found, 0);    fd = openp (search_path, file, "", &file_found, 0);
8848      
8849    if (fd == -1)    if (fd == -1)
8850      file_found = Qnil;      file_found = Qnil;
8851    else    else
# Line 8936  enum xbm_token Line 8926  enum xbm_token
8926    XBM_TK_NUMBER    XBM_TK_NUMBER
8927  };  };
8928    
8929      
8930  /* Return non-zero if OBJECT is a valid XBM-type image specification.  /* Return non-zero if OBJECT is a valid XBM-type image specification.
8931     A valid specification is a list starting with the symbol `image'     A valid specification is a list starting with the symbol `image'
8932     The rest of the list is a property list which must contain an     The rest of the list is a property list which must contain an
# Line 8967  xbm_image_p (object) Line 8957  xbm_image_p (object)
8957       Lisp_Object object;       Lisp_Object object;
8958  {  {
8959    struct image_keyword kw[XBM_LAST];    struct image_keyword kw[XBM_LAST];
8960      
8961    bcopy (xbm_format, kw, sizeof kw);    bcopy (xbm_format, kw, sizeof kw);
8962    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))    if (!parse_image_spec (object, kw, XBM_LAST, Qxbm))
8963      return 0;      return 0;
# Line 8993  xbm_image_p (object) Line 8983  xbm_image_p (object)
8983        data = kw[XBM_DATA].value;        data = kw[XBM_DATA].value;
8984        width = XFASTINT (kw[XBM_WIDTH].value);        width = XFASTINT (kw[XBM_WIDTH].value);
8985        height = XFASTINT (kw[XBM_HEIGHT].value);        height = XFASTINT (kw[XBM_HEIGHT].value);
8986          
8987        /* Check type of data, and width and height against contents of        /* Check type of data, and width and height against contents of
8988           data.  */           data.  */
8989        if (VECTORP (data))        if (VECTORP (data))
8990          {          {
8991            int i;            int i;
8992              
8993            /* Number of elements of the vector must be >= height.  */            /* Number of elements of the vector must be >= height.  */
8994            if (XVECTOR (data)->size < height)            if (XVECTOR (data)->size < height)
8995              return 0;              return 0;
# Line 9044  xbm_image_p (object) Line 9034  xbm_image_p (object)
9034    if (kw[XBM_ASCENT].count    if (kw[XBM_ASCENT].count
9035        && XFASTINT (kw[XBM_ASCENT].value) > 100)        && XFASTINT (kw[XBM_ASCENT].value) > 100)
9036      return 0;      return 0;
9037      
9038    return 1;    return 1;
9039  }  }
9040    
# Line 9062  xbm_scan (fp, sval, ival) Line 9052  xbm_scan (fp, sval, ival)
9052       int *ival;       int *ival;
9053  {  {
9054    int c;    int c;
9055      
9056    /* Skip white space.  */    /* Skip white space.  */
9057    while ((c = fgetc (fp)) != EOF && isspace (c))    while ((c = fgetc (fp)) != EOF && isspace (c))
9058      ;      ;
# Line 9072  xbm_scan (fp, sval, ival) Line 9062  xbm_scan (fp, sval, ival)
9062    else if (isdigit (c))    else if (isdigit (c))
9063      {      {
9064        int value = 0, digit;        int value = 0, digit;
9065          
9066        if (c == '0')        if (c == '0')
9067          {          {
9068            c = fgetc (fp);            c = fgetc (fp);
# Line 9156  xbm_read_bitmap_file_data (file, width, Line 9146  xbm_read_bitmap_file_data (file, width,
9146       if (LA1 != (TOKEN))        \       if (LA1 != (TOKEN))        \
9147         goto failure;            \         goto failure;            \
9148       else                       \       else                       \
9149         match ()         match ()
9150    
9151  #define expect_ident(IDENT)                                     \  #define expect_ident(IDENT)                                     \
9152       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \       if (LA1 == XBM_TK_IDENT && strcmp (buffer, (IDENT)) == 0)  \
# Line 9200  xbm_read_bitmap_file_data (file, width, Line 9190  xbm_read_bitmap_file_data (file, width,
9190      {      {
9191        if (strcmp (buffer, "unsigned") == 0)        if (strcmp (buffer, "unsigned") == 0)
9192          {          {
9193            match ();            match ();
9194            expect_ident ("char");            expect_ident ("char");
9195          }          }
9196        else if (strcmp (buffer, "short") == 0)        else if (strcmp (buffer, "short") == 0)
# Line 9215  xbm_read_bitmap_file_data (file, width, Line 9205  xbm_read_bitmap_file_data (file, width,
9205        else        else
9206          goto failure;          goto failure;
9207      }      }
9208    else    else
9209      goto failure;      goto failure;
9210    
9211    expect (XBM_TK_IDENT);    expect (XBM_TK_IDENT);
# Line 9230  xbm_read_bitmap_file_data (file, width, Line 9220  xbm_read_bitmap_file_data (file, width,
9220    
9221    if (v10)    if (v10)
9222      {      {
9223          
9224        for (i = 0; i < nbytes; i += 2)        for (i = 0; i < nbytes; i += 2)
9225          {          {
9226            int val = value;            int val = value;
# Line 9239  xbm_read_bitmap_file_data (file, width, Line 9229  xbm_read_bitmap_file_data (file, width,
9229            *p++ = val;            *p++ = val;
9230            if (!padding_p || ((i + 2) % bytes_per_line))            if (!padding_p || ((i + 2) % bytes_per_line))
9231              *p++ = value >> 8;              *p++ = value >> 8;
9232              
9233            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
9234              match ();              match ();
9235            else            else
# Line 9252  xbm_read_bitmap_file_data (file, width, Line 9242  xbm_read_bitmap_file_data (file, width,
9242          {          {
9243            int val = value;            int val = value;
9244            expect (XBM_TK_NUMBER);            expect (XBM_TK_NUMBER);
9245              
9246            *p++ = val;            *p++ = val;
9247              
9248            if (LA1 == ',' || LA1 == '}')            if (LA1 == ',' || LA1 == '}')
9249              match ();              match ();
9250            else            else
# Line 9266  xbm_read_bitmap_file_data (file, width, Line 9256  xbm_read_bitmap_file_data (file, width,
9256    return 1;    return 1;
9257    
9258   failure:   failure:
9259      
9260    fclose (fp);    fclose (fp);
9261    if (*data)    if (*data)
9262      {      {
# Line 9295  xbm_load_image_from_file (f, img, specif Line 9285  xbm_load_image_from_file (f, img, specif
9285    int success_p = 0;    int success_p = 0;
9286    Lisp_Object file;    Lisp_Object file;
9287    struct gcpro gcpro1;    struct gcpro gcpro1;
9288      
9289    xassert (STRINGP (specified_file));    xassert (STRINGP (specified_file));
9290    file = Qnil;    file = Qnil;
9291    GCPRO1 (file);    GCPRO1 (file);
# Line 9307  xbm_load_image_from_file (f, img, specif Line 9297  xbm_load_image_from_file (f, img, specif
9297        UNGCPRO;        UNGCPRO;
9298        return 0;        return 0;
9299      }      }
9300              
9301    rc = xbm_read_bitmap_file_data (XSTRING (file)->data, &img->width,    rc = xbm_read_bitmap_file_data (XSTRING (file)->data, &img->width,
9302                                    &img->height, &data);                                    &img->height, &data);
9303    if (rc)    if (rc)
# Line 9316  xbm_load_image_from_file (f, img, specif Line 9306  xbm_load_image_from_file (f, img, specif
9306        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);        unsigned long foreground = FRAME_FOREGROUND_PIXEL (f);
9307        unsigned long background = FRAME_BACKGROUND_PIXEL (f);        unsigned long background = FRAME_BACKGROUND_PIXEL (f);
9308        Lisp_Object value;        Lisp_Object value;
9309          
9310        xassert (img->width > 0 && img->height > 0);        xassert (img->width > 0 && img->height > 0);
9311    
9312        /* Get foreground and background colors, maybe allocate colors.  */        /* Get foreground and background colors, maybe allocate colors.  */
9313        value = image_spec_value (img->spec, QCforeground, NULL);        value = image_spec_value (img->spec, QCforeground, NULL);
9314        if (!NILP (value))        if (!NILP (value))
9315          foreground = x_alloc_image_color (f, img, value, foreground);          foreground = x_alloc_image_color (f, img, value, foreground);
9316          
9317        value = image_spec_value (img->spec, QCbackground, NULL);        value = image_spec_value (img->spec, QCbackground, NULL);
9318        if (!NILP (value))        if (!NILP (value))
9319          background = x_alloc_image_color (f, img, value, background);          background = x_alloc_image_color (f, img, value, background);
# Line 9346  xbm_load_image_from_file (f, img, specif Line 9336  xbm_load_image_from_file (f, img, specif
9336          }          }
9337        else        else
9338          success_p = 1;          success_p = 1;
9339          
9340        UNBLOCK_INPUT;        UNBLOCK_INPUT;
9341  #endif  #endif
9342      }      }
# Line 9396  xbm_load (f, img) Line 9386  xbm_load (f, img)
9386        xassert (img->width > 0 && img->height > 0);        xassert (img->width > 0 && img->height > 0);
9387    
9388        BLOCK_INPUT;        BLOCK_INPUT;
9389          
9390        if (fmt[XBM_ASCENT].count)        if (fmt[XBM_ASCENT].count)
9391          img->ascent = XFASTINT (fmt[XBM_ASCENT].value);          img->ascent = XFASTINT (fmt[XBM_ASCENT].value);
9392    
# Line 9415  xbm_load (f, img) Line 9405  xbm_load (f, img)
9405            int i;            int i;
9406            char *p;            char *p;
9407            int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;            int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
9408              
9409            p = bits = (char *) alloca (nbytes * img->height);            p = bits = (char *) alloca (nbytes * img->height);
9410            for (i = 0; i < img->height; ++i, p += nbytes)            for (i = 0; i < img->height; ++i, p += nbytes)
9411              {              {
# Line 9457  xbm_load (f, img) Line 9447  xbm_load (f, img)
9447    
9448    return success_p;    return success_p;
9449  }  }
9450      
9451    
9452    
9453  /***********************************************************************  /***********************************************************************
9454                                XPM images                                XPM images
9455   ***********************************************************************/   ***********************************************************************/
9456    
9457  #if HAVE_XPM  #if HAVE_XPM
9458    
9459  static int xpm_image_p P_ ((Lisp_Object object));  static int xpm_image_p P_ ((Lisp_Object object));
9460  static int xpm_load P_ ((struct frame *f, struct image *img));  static int xpm_load P_ ((struct frame *f, struct image *img));
# Line 9598  xpm_load (f, img) Line 9588  xpm_load (f, img)
9588        Lisp_Object tail;        Lisp_Object tail;
9589        XpmColorSymbol *xpm_syms;        XpmColorSymbol *xpm_syms;
9590        int i, size;        int i, size;
9591          
9592        attrs.valuemask |= XpmColorSymbols;        attrs.valuemask |= XpmColorSymbols;
9593    
9594        /* Count number of symbols.  */        /* Count number of symbols.  */
# Line 9639  xpm_load (f, img) Line 9629  xpm_load (f, img)
9629            UNBLOCK_INPUT;            UNBLOCK_INPUT;
9630            return 0;            return 0;
9631          }          }
9632          
9633        rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f),        rc = XpmReadFileToPixmap (NULL, FRAME_W32_WINDOW (f),
9634                                  XSTRING (file)->data, &img->pixmap, &img->mask,                                  XSTRING (file)->data, &img->pixmap, &img->mask,
9635                                  &attrs);                                  &attrs);
# Line 9679  xpm_load (f, img) Line 9669  xpm_load (f, img)
9669          case XpmOpenFailed:          case XpmOpenFailed:
9670            image_error ("Error opening XPM file (%s)", img->spec, Qnil);            image_error ("Error opening XPM file (%s)", img->spec, Qnil);
9671            break;            break;
9672              
9673          case XpmFileInvalid:          case XpmFileInvalid:
9674            image_error ("Invalid XPM file (%s)", img->spec, Qnil);            image_error ("Invalid XPM file (%s)", img->spec, Qnil);
9675            break;            break;
9676              
9677          case XpmNoMemory:          case XpmNoMemory:
9678            image_error ("Out of memory (%s)", img->spec, Qnil);            image_error ("Out of memory (%s)", img->spec, Qnil);
9679            break;            break;
9680              
9681          case XpmColorFailed:          case XpmColorFailed:
9682            image_error ("Color allocation error (%s)", img->spec, Qnil);            image_error ("Color allocation error (%s)", img->spec, Qnil);
9683            break;            break;
9684              
9685          default:          default:
9686            image_error ("Unknown error (%s)", img->spec, Qnil);            image_error ("Unknown error (%s)", img->spec, Qnil);
9687            break;            break;
# Line 9840  lookup_pixel_color (f, pixel) Line 9830  lookup_pixel_color (f, pixel)
9830        int rc;        int rc;
9831    
9832        BLOCK_INPUT;        BLOCK_INPUT;
9833          
9834        cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));        cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
9835        color.pixel = pixel;        color.pixel = pixel;
9836        XQueryColor (NULL, cmap, &color);        XQueryColor (NULL, cmap, &color);
# Line 9850  lookup_pixel_color (f, pixel) Line 9840  lookup_pixel_color (f, pixel)
9840        if (rc)        if (rc)
9841          {          {
9842            ++ct_colors_allocated;            ++ct_colors_allocated;
9843          
9844            p = (struct ct_color *) xmalloc (sizeof *p);            p = (struct ct_color *) xmalloc (sizeof *p);
9845            p->r = color.red;            p->r = color.red;
9846            p->g = color.green;            p->g = color.green;
# Line 9887  colors_in_color_table (n) Line 9877  colors_in_color_table (n)
9877        colors = (unsigned long *) xmalloc (ct_colors_allocated        colors = (unsigned long *) xmalloc (ct_colors_allocated
9878                                            * sizeof *colors);                                            * sizeof *colors);
9879        *n = ct_colors_allocated;        *n = ct_colors_allocated;
9880          
9881        for (i = j = 0; i < CT_SIZE; ++i)        for (i = j = 0; i < CT_SIZE; ++i)
9882          for (p = ct_table[i]; p; p = p->next)          for (p = ct_table[i]; p; p = p->next)
9883            colors[j++] = p->pixel;            colors[j++] = p->pixel;
# Line 9945  x_laplace_write_row (f, pixels, width, x Line 9935  x_laplace_write_row (f, pixels, width, x
9935       int y;       int y;
9936  {  {
9937    int x;    int x;
9938      
9939    for (x = 0; x < width; ++x)    for (x = 0; x < width; ++x)
9940      XPutPixel (ximg, x, y, pixels[x]);      XPutPixel (ximg, x, y, pixels[x]);
9941  }  }
# Line 10011  x_laplace (f, img) Line 10001  x_laplace (f, img)
10001            int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red;            int r = in[rowa][x].red + mv2 - in[rowb][x + 2].red;
10002            int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green;            int g = in[rowa][x].green + mv2 - in[rowb][x + 2].green;
10003            int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue;            int b = in[rowa][x].blue + mv2 - in[rowb][x + 2].blue;
10004              
10005            out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff,            out[x + 1] = lookup_rgb_color (f, r & 0xffff, g & 0xffff,
10006                                           b & 0xffff);                                           b & 0xffff);
10007          }          }
# Line 10027  x_laplace (f, img) Line 10017  x_laplace (f, img)
10017    /* Free the input image, and free resources of IMG.  */    /* Free the input image, and free resources of IMG.  */
10018    XDestroyImage (ximg);    XDestroyImage (ximg);
10019    x_clear_image (f, img);    x_clear_image (f, img);
10020      
10021    /* Put the output image into pixmap, and destroy it.  */    /* Put the output image into pixmap, and destroy it.  */
10022    x_put_x_image (f, oimg, pixmap, img->width, img->height);    x_put_x_image (f, oimg, pixmap, img->width, img->height);
10023    x_destroy_x_image (oimg);    x_destroy_x_image (oimg);
# Line 10062  x_build_heuristic_mask (f, img, how) Line 10052  x_build_heuristic_mask (f, img, how)
10052    unsigned long bg;    unsigned long bg;
10053    
10054    BLOCK_INPUT;    BLOCK_INPUT;
10055      
10056    /* Create an image and pixmap serving as mask.  */    /* Create an image and pixmap serving as mask.  */
10057    rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,    rc = x_create_x_image_and_pixmap (f, img->width, img->height, 1,
10058                                      &mask_img, &img->mask);                                      &mask_img, &img->mask);
# Line 10080  x_build_heuristic_mask (f, img, how) Line 10070  x_build_heuristic_mask (f, img, how)
10070       take that as color.  Otherwise, try to determine the color       take that as color.  Otherwise, try to determine the color
10071       heuristically. */       heuristically. */
10072    look_at_corners_p = 1;    look_at_corners_p = 1;
10073      
10074    if (CONSP (how))    if (CONSP (how))
10075      {      {
10076        int rgb[3], i = 0;        int rgb[3], i = 0;
# Line 10100  x_build_heuristic_mask (f, img, how) Line 10090  x_build_heuristic_mask (f, img, how)
10090            Colormap cmap;            Colormap cmap;
10091    
10092            sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);            sprintf (color_name, "#%04x%04x%04x", rgb[0], rgb[1], rgb[2]);
10093              
10094            cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));            cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f));
10095            if (XLookupColor (dpy, cmap, color_name, &exact, &color))            if (XLookupColor (dpy, cmap, color_name, &exact, &color))
10096              {              {
# Line 10109  x_build_heuristic_mask (f, img, how) Line 10099  x_build_heuristic_mask (f, img, how)
10099              }              }
10100          }          }
10101      }      }
10102      
10103    if (look_at_corners_p)    if (look_at_corners_p)
10104      {      {
10105        unsigned long corners[4];        unsigned long corners[4];
# Line 10125  x_build_heuristic_mask (f, img, how) Line 10115  x_build_heuristic_mask (f, img, how)
10115        for (i = best_count = 0; i < 4; ++i)        for (i = best_count = 0; i < 4; ++i)
10116          {          {
10117            int j, n;            int j, n;
10118              
10119            for (j = n = 0; j < 4; ++j)            for (j = n = 0; j < 4; ++j)
10120              if (corners[i] == corners[j])              if (corners[i] == corners[j])
10121                ++n;                ++n;
# Line 10145  x_build_heuristic_mask (f, img, how) Line 10135  x_build_heuristic_mask (f, img, how)
10135    x_put_x_image (f, mask_img, img->mask, img->width, img->height);    x_put_x_image (f, mask_img, img->mask, img->width, img->height);
10136    x_destroy_x_image (mask_img);    x_destroy_x_image (mask_img);
10137    XDestroyImage (ximg);    XDestroyImage (ximg);
10138      
10139    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10140  #endif /* TODO */  #endif /* TODO */
10141    
# Line 10216  pbm_image_p (object) Line 10206  pbm_image_p (object)
10206       Lisp_Object object;       Lisp_Object object;
10207  {  {
10208    struct image_keyword fmt[PBM_LAST];    struct image_keyword fmt[PBM_LAST];
10209      
10210    bcopy (pbm_format, fmt, sizeof fmt);    bcopy (pbm_format, fmt, sizeof fmt);
10211      
10212    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)    if (!parse_image_spec (object, fmt, PBM_LAST, Qpbm)
10213        || (fmt[PBM_ASCENT].count        || (fmt[PBM_ASCENT].count
10214            && XFASTINT (fmt[PBM_ASCENT].value) > 100))            && XFASTINT (fmt[PBM_ASCENT].value) > 100))
10215      return 0;      return 0;
10216    
# Line 10298  pbm_read_file (file, size) Line 10288  pbm_read_file (file, size)
10288            buf = NULL;            buf = NULL;
10289          }          }
10290      }      }
10291      
10292    return buf;    return buf;
10293  }  }
10294    
10295    
10296  /* Load PBM image IMG for use on frame F.  */  /* Load PBM image IMG for use on frame F.  */
10297    
10298  static int  static int
10299  pbm_load (f, img)  pbm_load (f, img)
10300       struct frame *f;       struct frame *f;
10301       struct image *img;       struct image *img;
# Line 10368  pbm_load (f, img) Line 10358  pbm_load (f, img)
10358      case '1':      case '1':
10359        raw_p = 0, type = PBM_MONO;        raw_p = 0, type = PBM_MONO;
10360        break;        break;
10361          
10362      case '2':      case '2':
10363        raw_p = 0, type = PBM_GRAY;        raw_p = 0, type = PBM_GRAY;
10364        break;        break;
# Line 10380  pbm_load (f, img) Line 10370  pbm_load (f, img)
10370      case '4':      case '4':
10371        raw_p = 1, type = PBM_MONO;        raw_p = 1, type = PBM_MONO;
10372        break;        break;
10373          
10374      case '5':      case '5':
10375        raw_p = 1, type = PBM_GRAY;        raw_p = 1, type = PBM_GRAY;
10376        break;        break;
10377          
10378      case '6':      case '6':
10379        raw_p = 1, type = PBM_COLOR;        raw_p = 1, type = PBM_COLOR;
10380        break;        break;
# Line 10405  pbm_load (f, img) Line 10395  pbm_load (f, img)
10395        if (raw_p && max_color_idx > 255)        if (raw_p && max_color_idx > 255)
10396          max_color_idx = 255;          max_color_idx = 255;
10397      }      }
10398      
10399    if (width < 0    if (width < 0
10400        || height < 0        || height < 0
10401        || (type != PBM_MONO && max_color_idx < 0))        || (type != PBM_MONO && max_color_idx < 0))
# Line 10418  pbm_load (f, img) Line 10408  pbm_load (f, img)
10408        UNBLOCK_INPUT;        UNBLOCK_INPUT;
10409        goto error;        goto error;
10410      }      }
10411      
10412    /* Initialize the color hash table.  */    /* Initialize the color hash table.  */
10413    init_color_table ();    init_color_table ();
10414    
10415    if (type == PBM_MONO)    if (type == PBM_MONO)
10416      {      {
10417        int c = 0, g;        int c = 0, g;
10418          
10419        for (y = 0; y < height; ++y)        for (y = 0; y < height; ++y)
10420          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
10421            {            {
# Line 10450  pbm_load (f, img) Line 10440  pbm_load (f, img)
10440          for (x = 0; x < width; ++x)          for (x = 0; x < width; ++x)
10441            {            {
10442              int r, g, b;              int r, g, b;
10443                
10444              if (type == PBM_GRAY)              if (type == PBM_GRAY)
10445                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);                r = g = b = raw_p ? *p++ : pbm_scan_number (&p, end);
10446              else if (raw_p)              else if (raw_p)
# Line 10465  pbm_load (f, img) Line 10455  pbm_load (f, img)
10455                  g = pbm_scan_number (&p, end);                  g = pbm_scan_number (&p, end);
10456                  b = pbm_scan_number (&p, end);                  b = pbm_scan_number (&p, end);
10457                }                }
10458                
10459              if (r < 0 || g < 0 || b < 0)              if (r < 0 || g < 0 || b < 0)
10460                {                {
10461                  xfree (ximg->data);                  xfree (ximg->data);
# Line 10476  pbm_load (f, img) Line 10466  pbm_load (f, img)
10466                               img->spec, Qnil);                               img->spec, Qnil);
10467                  goto error;                  goto error;
10468                }                }
10469                
10470              /* RGB values are now in the range 0..max_color_idx.              /* RGB values are now in the range 0..max_color_idx.
10471                 Scale this to the range 0..0xffff supported by X.  */                 Scale this to the range 0..0xffff supported by X.  */
10472              r = (double) r * 65535 / max_color_idx;              r = (double) r * 65535 / max_color_idx;
# Line 10485  pbm_load (f, img) Line 10475  pbm_load (f, img)
10475              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));              XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
10476            }            }
10477      }      }
10478      
10479    /* Store in IMG->colors the colors allocated for the image, and    /* Store in IMG->colors the colors allocated for the image, and
10480       free the color table.  */       free the color table.  */
10481    img->colors = colors_in_color_table (&img->ncolors);    img->colors = colors_in_color_table (&img->ncolors);
10482    free_color_table ();    free_color_table ();
10483      
10484    /* Put the image into a pixmap.  */    /* Put the image into a pixmap.  */
10485    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
10486    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
10487    UNBLOCK_INPUT;    UNBLOCK_INPUT;
10488          
10489    img->width = width;    img->width = width;
10490    img->height = height;    img->height = height;
10491    
# Line 10573  png_image_p (object) Line 10563  png_image_p (object)
10563  {  {
10564    struct image_keyword fmt[PNG_LAST];    struct image_keyword fmt[PNG_LAST];
10565    bcopy (png_format, fmt, sizeof fmt);    bcopy (png_format, fmt, sizeof fmt);
10566      
10567    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)    if (!parse_image_spec (object, fmt, PNG_LAST, Qpng)
10568        || (fmt[PNG_ASCENT].count        || (fmt[PNG_ASCENT].count
10569            && XFASTINT (fmt[PNG_ASCENT].value) > 100))            && XFASTINT (fmt[PNG_ASCENT].value) > 100))
10570      return 0;      return 0;
10571    
# Line 10632  png_read_from_memory (png_ptr, data, len Line 10622  png_read_from_memory (png_ptr, data, len
10622    
10623    if (length > tbr->len - tbr->index)    if (length > tbr->len - tbr->index)
10624      png_error (png_ptr, "Read error");      png_error (png_ptr, "Read error");
10625      
10626    bcopy (tbr->bytes + tbr->index, data, length);    bcopy (tbr->bytes + tbr->index, data, length);
10627    tbr->index = tbr->index + length;    tbr->index = tbr->index + length;
10628  }  }
# Line 10775  png_load (f, img) Line 10765  png_load (f, img)
10765    png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,    png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
10766                  &interlace_type, NULL, NULL);                  &interlace_type, NULL, NULL);
10767    
10768    /* If image contains simply transparency data, we prefer to    /* If image contains simply transparency data, we prefer to
10769       construct a clipping mask.  */       construct a clipping mask.  */
10770    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))    if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
10771      transparent_p = 1;      transparent_p = 1;
10772    else    else
10773      transparent_p = 0;      transparent_p = 0;
10774    
10775    /* This function is easier to write if we only have to handle    /* This function is easier to write if we only have to handle
10776       one data format: RGB or RGBA with 8 bits per channel.  Let's       one data format: RGB or RGBA with 8 bits per channel.  Let's
10777       transform other formats into that format.  */       transform other formats into that format.  */
10778    
# Line 10795  png_load (f, img) Line 10785  png_load (f, img)
10785    png_set_expand (png_ptr);    png_set_expand (png_ptr);
10786    
10787    /* Convert grayscale images to RGB.  */    /* Convert grayscale images to RGB.  */
10788    if (color_type == PNG_COLOR_TYPE_GRAY    if (color_type == PNG_COLOR_TYPE_GRAY
10789        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)        || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
10790      png_set_gray_to_rgb (png_ptr);      png_set_gray_to_rgb (png_ptr);
10791    
# Line 10826  png_load (f, img) Line 10816  png_load (f, img)
10816        png_color_16 *image_background;        png_color_16 *image_background;
10817    
10818        if (png_get_bKGD (png_ptr, info_ptr, &image_background))        if (png_get_bKGD (png_ptr, info_ptr, &image_background))
10819          /* Image contains a background color with which to          /* Image contains a background color with which to
10820             combine the image.  */             combine the image.  */
10821          png_set_background (png_ptr, image_background,          png_set_background (png_ptr, image_background,
10822                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);                              PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
10823        else        else
10824          {          {
10825            /* Image does not contain a background color with which            /* Image does not contain a background color with which
10826               to combine the image data via an alpha channel.  Use               to combine the image data via an alpha channel.  Use
10827               the frame's background instead.  */               the frame's background instead.  */
10828            XColor color;            XColor color;
10829            Colormap cmap;            Colormap cmap;
# Line 10893  png_load (f, img) Line 10883  png_load (f, img)
10883        UNBLOCK_INPUT;        UNBLOCK_INPUT;
10884        goto error;        goto error;
10885      }      }
10886      
10887    /* Create an image and pixmap serving as mask if the PNG image    /* Create an image and pixmap serving as mask if the PNG image
10888       contains an alpha channel.  */       contains an alpha channel.  */
10889    if (channels == 4    if (channels == 4
# Line 10925  png_load (f, img) Line 10915  png_load (f, img)
10915            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));            XPutPixel (ximg, x, y, lookup_rgb_color (f, r, g, b));
10916    
10917            /* An alpha channel, aka mask channel, associates variable            /* An alpha channel, aka mask channel, associates variable
10918               transparency with an image.  Where other image formats               transparency with an image.  Where other image formats
10919               support binary transparency---fully transparent or fully               support binary transparency---fully transparent or fully
10920               opaque---PNG allows up to 254 levels of partial transparency.               opaque---PNG allows up to 254 levels of partial transparency.
10921               The PNG library implements partial transparency by combining               The PNG library implements partial transparency by combining
10922               the image with a specified background color.               the image with a specified background color.
10923    
10924               I'm not sure how to handle this here nicely: because the               I'm not sure how to handle this here nicely: because the
10925               background on which the image is displayed may change, for               background on which the image is displayed may change, for
10926               real alpha channel support, it would be necessary to create               real alpha channel support, it would be necessary to create
10927               a new image for each possible background.                 a new image for each possible background.
10928    
10929               What I'm doing now is that a mask is created if we have               What I'm doing now is that a mask is created if we have
10930               boolean transparency information.  Otherwise I'm using               boolean transparency information.  Otherwise I'm using
# Line 11058  jpeg_image_p (object) Line 11048  jpeg_image_p (object)
11048       Lisp_Object object;       Lisp_Object object;
11049  {  {
11050    struct image_keyword fmt[JPEG_LAST];    struct image_keyword fmt[JPEG_LAST];
11051      
11052    bcopy (jpeg_format, fmt, sizeof fmt);    bcopy (jpeg_format, fmt, sizeof fmt);
11053      
11054    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)    if (!parse_image_spec (object, fmt, JPEG_LAST, Qjpeg)
11055        || (fmt[JPEG_ASCENT].count        || (fmt[JPEG_ASCENT].count
11056            && XFASTINT (fmt[JPEG_ASCENT].value) > 100))            && XFASTINT (fmt[JPEG_ASCENT].value) > 100))
11057      return 0;      return 0;
11058    
# Line 11131  our_skip_input_data (cinfo, num_bytes) Line 11121  our_skip_input_data (cinfo, num_bytes)
11121      {      {
11122        if (num_bytes > src->bytes_in_buffer)        if (num_bytes > src->bytes_in_buffer)
11123          ERREXIT (cinfo, JERR_INPUT_EOF);          ERREXIT (cinfo, JERR_INPUT_EOF);
11124          
11125        src->bytes_in_buffer -= num_bytes;        src->bytes_in_buffer -= num_bytes;
11126        src->next_input_byte += num_bytes;        src->next_input_byte += num_bytes;
11127      }      }
# Line 11169  jpeg_memory_src (cinfo, data, len) Line 11159  jpeg_memory_src (cinfo, data, len)
11159        src = (struct jpeg_source_mgr *) cinfo->src;        src = (struct jpeg_source_mgr *) cinfo->src;
11160        src->next_input_byte = data;        src->next_input_byte = data;
11161      }      }
11162      
11163    src = (struct jpeg_source_mgr *) cinfo->src;    src = (struct jpeg_source_mgr *) cinfo->src;
11164    src->init_source = our_init_source;    src->init_source = our_init_source;
11165    src->fill_input_buffer = our_fill_input_buffer;    src->fill_input_buffer = our_fill_input_buffer;
# Line 11184  jpeg_memory_src (cinfo, data, len) Line 11174  jpeg_memory_src (cinfo, data, len)
11174  /* Load image IMG for use on frame F.  Patterned after example.c  /* Load image IMG for use on frame F.  Patterned after example.c
11175     from the JPEG lib.  */     from the JPEG lib.  */
11176    
11177  static int  static int
11178  jpeg_load (f, img)  jpeg_load (f, img)
11179       struct frame *f;       struct frame *f;
11180       struct image *img;       struct image *img;
# Line 11217  jpeg_load (f, img) Line 11207  jpeg_load (f, img)
11207            UNGCPRO;            UNGCPRO;
11208            return 0;            return 0;
11209          }          }
11210      
11211        fp = fopen (XSTRING (file)->data, "r");        fp = fopen (XSTRING (file)->data, "r");
11212        if (fp == NULL)        if (fp == NULL)
11213          {          {
# Line 11226  jpeg_load (f, img) Line 11216  jpeg_load (f, img)
11216            return 0;            return 0;
11217          }          }
11218      }      }
11219      
11220    /* Customize libjpeg's error handling to call my_error_exit when an    /* Customize libjpeg's error handling to call my_error_exit when an
11221       error is detected. This function will perform a longjmp. */       error is detected. This function will perform a longjmp. */
11222    mgr.pub.error_exit = my_error_exit;    mgr.pub.error_exit = my_error_exit;
11223    cinfo.err = jpeg_std_error (&mgr.pub);    cinfo.err = jpeg_std_error (&mgr.pub);
11224      
11225    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)    if ((rc = setjmp (mgr.setjmp_buffer)) != 0)
11226      {      {
11227        if (rc == 1)        if (rc == 1)
# Line 11242  jpeg_load (f, img) Line 11232  jpeg_load (f, img)
11232            image_error ("Error reading JPEG image `%s': %s", img->spec,            image_error ("Error reading JPEG image `%s': %s", img->spec,
11233                         build_string (buffer));                         build_string (buffer));
11234          }          }
11235              
11236        /* Close the input file and destroy the JPEG object.  */        /* Close the input file and destroy the JPEG object.  */
11237        if (fp)        if (fp)
11238          fclose (fp);          fclose (fp);
11239        jpeg_destroy_decompress (&cinfo);        jpeg_destroy_decompress (&cinfo);
11240    
11241        BLOCK_INPUT;        BLOCK_INPUT;
11242          
11243        /* If we already have an XImage, free that.  */        /* If we already have an XImage, free that.  */
11244        x_destroy_x_image (ximg);        x_destroy_x_image (ximg);
11245    
11246        /* Free pixmap and colors.  */        /* Free pixmap and colors.  */
11247        x_clear_image (f, img);        x_clear_image (f, img);
11248          
11249        UNBLOCK_INPUT;        UNBLOCK_INPUT;
11250        UNGCPRO;        UNGCPRO;
11251        return 0;        return 0;
# Line 11312  jpeg_load (f, img) Line 11302  jpeg_load (f, img)
11302      init_color_table ();      init_color_table ();
11303      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors      colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
11304                                         * sizeof *colors);                                         * sizeof *colors);
11305      
11306      for (i = 0; i < cinfo.actual_number_of_colors; ++i)      for (i = 0; i < cinfo.actual_number_of_colors; ++i)
11307        {        {
11308          /* Multiply RGB values with 255 because X expects RGB values          /* Multiply RGB values with 255 because X expects RGB values
# Line 11344  jpeg_load (f, img) Line 11334  jpeg_load (f, img)
11334    jpeg_destroy_decompress (&cinfo);    jpeg_destroy_decompress (&cinfo);
11335    if (fp)    if (fp)
11336      fclose (fp);      fclose (fp);
11337      
11338    /* Put the image into the pixmap.  */    /* Put the image into the pixmap.  */
11339    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
11340    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
# Line 11422  tiff_image_p (object) Line 11412  tiff_image_p (object)
11412  {  {
11413    struct image_keyword fmt[TIFF_LAST];    struct image_keyword fmt[TIFF_LAST];
11414    bcopy (tiff_format, fmt, sizeof fmt);    bcopy (tiff_format, fmt, sizeof fmt);
11415      
11416    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)    if (!parse_image_spec (object, fmt, TIFF_LAST, Qtiff)
11417        || (fmt[TIFF_ASCENT].count        || (fmt[TIFF_ASCENT].count
11418            && XFASTINT (fmt[TIFF_ASCENT].value) > 100))            && XFASTINT (fmt[TIFF_ASCENT].value) > 100))
11419      return 0;      return 0;
11420      
11421    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
11422    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;    return fmt[TIFF_FILE].count + fmt[TIFF_DATA].count == 1;
11423  }  }
# Line 11488  tiff_seek_in_memory (data, off, whence) Line 11478  tiff_seek_in_memory (data, off, whence)
11478      case SEEK_SET:              /* Go from beginning of source.  */      case SEEK_SET:              /* Go from beginning of source.  */
11479        idx = off;        idx = off;
11480        break;        break;
11481          
11482      case SEEK_END:              /* Go from end of source.  */      case SEEK_END:              /* Go from end of source.  */
11483        idx = src->len + off;        idx = src->len + off;
11484        break;        break;
11485          
11486      case SEEK_CUR:              /* Go from current position.  */      case SEEK_CUR:              /* Go from current position.  */
11487        idx = src->index + off;        idx = src->index + off;
11488        break;        break;
11489          
11490      default:                    /* Invalid `whence'.   */      default:                    /* Invalid `whence'.   */
11491        return -1;        return -1;
11492      }      }
11493      
11494    if (idx > src->len || idx < 0)    if (idx > src->len || idx < 0)
11495      return -1;      return -1;
11496      
11497    src->index = idx;    src->index = idx;
11498    return src->index;    return src->index;
11499  }  }
# Line 11575  tiff_load (f, img) Line 11565  tiff_load (f, img)
11565            UNGCPRO;            UNGCPRO;
11566            return 0;            return 0;
11567          }          }
11568      
11569        /* Try to open the image file.  */        /* Try to open the image file.  */
11570        tiff = TIFFOpen (XSTRING (file)->data, "r");        tiff = TIFFOpen (XSTRING (file)->data, "r");
11571        if (tiff == NULL)        if (tiff == NULL)
# Line 11614  tiff_load (f, img) Line 11604  tiff_load (f, img)
11604    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);    TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width);
11605    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);    TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height);
11606    buf = (uint32 *) xmalloc (width * height * sizeof *buf);    buf = (uint32 *) xmalloc (width * height * sizeof *buf);
11607      
11608    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);    rc = TIFFReadRGBAImage (tiff, width, height, buf, 0);
11609    TIFFClose (tiff);    TIFFClose (tiff);
11610    if (!rc)    if (!rc)
# Line 11643  tiff_load (f, img) Line 11633  tiff_load (f, img)
11633    for (y = 0; y < height; ++y)    for (y = 0; y < height; ++y)
11634      {      {
11635        uint32 *row = buf + y * width;        uint32 *row = buf + y * width;
11636          
11637        for (x = 0; x < width; ++x)        for (x = 0; x < width; ++x)
11638          {          {
11639            uint32 abgr = row[x];            uint32 abgr = row[x];
11640            int r = TIFFGetR (abgr) << 8;            int r = TIFFGetR (abgr) << 8;
11641            int g = TIFFGetG (abgr) << 8;            int g = TIFFGetG (abgr) << 8;
11642            int b = TIFFGetB (abgr) << 8;            int b = TIFFGetB (abgr) << 8;
11643            XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));            XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b));
11644          }          }
11645      }      }
11646    
# Line 11663  tiff_load (f, img) Line 11653  tiff_load (f, img)
11653    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
11654    xfree (buf);    xfree (buf);
11655    UNBLOCK_INPUT;    UNBLOCK_INPUT;
11656          
11657    img->width = width;    img->width = width;
11658    img->height = height;    img->height = height;
11659    
# Line 11741  gif_image_p (object) Line 11731  gif_image_p (object)
11731  {  {
11732    struct image_keyword fmt[GIF_LAST];    struct image_keyword fmt[GIF_LAST];
11733    bcopy (gif_format, fmt, sizeof fmt);    bcopy (gif_format, fmt, sizeof fmt);
11734      
11735    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)    if (!parse_image_spec (object, fmt, GIF_LAST, Qgif)
11736        || (fmt[GIF_ASCENT].count        || (fmt[GIF_ASCENT].count
11737            && XFASTINT (fmt[GIF_ASCENT].value) > 100))            && XFASTINT (fmt[GIF_ASCENT].value) > 100))
11738      return 0;      return 0;
11739      
11740    /* Must specify either the :data or :file keyword.  */    /* Must specify either the :data or :file keyword.  */
11741    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;    return fmt[GIF_FILE].count + fmt[GIF_DATA].count == 1;
11742  }  }
# Line 11819  gif_load (f, img) Line 11809  gif_load (f, img)
11809            UNGCPRO;            UNGCPRO;
11810            return 0;            return 0;
11811          }          }
11812      
11813        /* Open the GIF file.  */        /* Open the GIF file.  */
11814        gif = DGifOpenFileName (XSTRING (file)->data);        gif = DGifOpenFileName (XSTRING (file)->data);
11815        if (gif == NULL)        if (gif == NULL)
# Line 11880  gif_load (f, img) Line 11870  gif_load (f, img)
11870        UNGCPRO;        UNGCPRO;
11871        return 0;        return 0;
11872      }      }
11873      
11874    /* Allocate colors.  */    /* Allocate colors.  */
11875    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;    gif_color_map = gif->SavedImages[ino].ImageDesc.ColorMap;
11876    if (!gif_color_map)    if (!gif_color_map)
11877      gif_color_map = gif->SColorMap;      gif_color_map = gif->SColorMap;
11878    init_color_table ();    init_color_table ();
11879    bzero (pixel_colors, sizeof pixel_colors);    bzero (pixel_colors, sizeof pixel_colors);
11880      
11881    for (i = 0; i < gif_color_map->ColorCount; ++i)    for (i = 0; i < gif_color_map->ColorCount; ++i)
11882      {      {
11883        int r = gif_color_map->Colors[i].Red << 8;        int r = gif_color_map->Colors[i].Red << 8;
# Line 11900  gif_load (f, img) Line 11890  gif_load (f, img)
11890    free_color_table ();    free_color_table ();
11891    
11892    /* Clear the part of the screen image that are not covered by    /* Clear the part of the screen image that are not covered by
11893       the image from the GIF file.  Full animated GIF support       the image from the GIF file.  Full animated GIF support
11894       requires more than can be done here (see the gif89 spec,       requires more than can be done here (see the gif89 spec,
11895       disposal methods).  Let's simply assume that the part       disposal methods).  Let's simply assume that the part
11896       not covered by a sub-image is in the frame's background color.  */       not covered by a sub-image is in the frame's background color.  */
# Line 11947  gif_load (f, img) Line 11937  gif_load (f, img)
11937                while (row >= image_height)                while (row >= image_height)
11938                  row = interlace_start[++pass];                  row = interlace_start[++pass];
11939              }              }
11940              
11941            for (x = 0; x < image_width; x++)            for (x = 0; x < image_width; x++)
11942              {              {
11943                int i = raster[(y * image_width) + x];                int i = raster[(y * image_width) + x];
11944                XPutPixel (ximg, x + image_left, row + image_top,                XPutPixel (ximg, x + image_left, row + image_top,
11945                           pixel_colors[i]);                           pixel_colors[i]);
11946              }              }
11947              
11948            row += interlace_increment[pass];            row += interlace_increment[pass];
11949          }          }
11950      }      }
# Line 11967  gif_load (f, img) Line 11957  gif_load (f, img)
11957              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);              XPutPixel (ximg, x + image_left, y + image_top, pixel_colors[i]);
11958            }            }
11959      }      }
11960      
11961    DGifCloseFile (gif);    DGifCloseFile (gif);
11962      
11963    /* Put the image into the pixmap, then free the X image and its buffer.  */    /* Put the image into the pixmap, then free the X image and its buffer.  */
11964    x_put_x_image (f, ximg, img->pixmap, width, height);    x_put_x_image (f, ximg, img->pixmap, width, height);
11965    x_destroy_x_image (ximg);    x_destroy_x_image (ximg);
11966    UNBLOCK_INPUT;    UNBLOCK_INPUT;
11967          
11968    UNGCPRO;    UNGCPRO;
11969    return 1;    return 1;
11970  }  }
# Line 12071  gs_image_p (object) Line 12061  gs_image_p (object)
12061    struct image_keyword fmt[GS_LAST];    struct image_keyword fmt[GS_LAST];
12062    Lisp_Object tem;    Lisp_Object tem;
12063    int i;    int i;
12064      
12065    bcopy (gs_format, fmt, sizeof fmt);    bcopy (gs_format, fmt, sizeof fmt);
12066      
12067    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)    if (!parse_image_spec (object, fmt, GS_LAST, Qpostscript)
12068        || (fmt[GS_ASCENT].count        || (fmt[GS_ASCENT].count
12069            && XFASTINT (fmt[GS_ASCENT].value) > 100))            && XFASTINT (fmt[GS_ASCENT].value) > 100))
12070      return 0;      return 0;
12071    
# Line 12143  gs_load (f, img) Line 12133  gs_load (f, img)
12133        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);        image_error ("Unable to create pixmap for `%s'", img->spec, Qnil);
12134        return 0;        return 0;
12135      }      }
12136        
12137    /* Call the loader to fill the pixmap.  It returns a process object    /* Call the loader to fill the pixmap.  It returns a process object
12138       if successful.  We do not record_unwind_protect here because       if successful.  We do not record_unwind_protect here because
12139       other places in redisplay like calling window scroll functions       other places in redisplay like calling window scroll functions
# Line 12154  gs_load (f, img) Line 12144  gs_load (f, img)
12144             (unsigned long) FRAME_W32_WINDOW (f),             (unsigned long) FRAME_W32_WINDOW (f),
12145             (unsigned long) img->pixmap);             (unsigned long) img->pixmap);
12146    window_and_pixmap_id = build_string (buffer);    window_and_pixmap_id = build_string (buffer);
12147      
12148    sprintf (buffer, "%lu %lu",    sprintf (buffer, "%lu %lu",
12149             FRAME_FOREGROUND_PIXEL (f),             FRAME_FOREGROUND_PIXEL (f),
12150             FRAME_BACKGROUND_PIXEL (f));             FRAME_BACKGROUND_PIXEL (f));
12151    pixel_colors = build_string (buffer);    pixel_colors = build_string (buffer);
12152      
12153    XSETFRAME (frame, f);    XSETFRAME (frame, f);
12154    loader = image_spec_value (img->spec, QCloader, NULL);    loader = image_spec_value (img->spec, QCloader, NULL);
12155    if (NILP (loader))    if (NILP (loader))
# Line 12217  x_kill_gs_process (pixmap, f) Line 12207  x_kill_gs_process (pixmap, f)
12207        if (ximg)        if (ximg)
12208          {          {
12209            int x, y;            int x, y;
12210              
12211            /* Initialize the color table.  */            /* Initialize the color table.  */
12212            init_color_table ();            init_color_table ();
12213          
12214            /* For each pixel of the image, look its color up in the            /* For each pixel of the image, look its color up in the
12215               color table.  After having done so, the color table will               color table.  After having done so, the color table will
12216               contain an entry for each color used by the image.  */               contain an entry for each color used by the image.  */
# Line 12253  x_kill_gs_process (pixmap, f) Line 12243  x_kill_gs_process (pixmap, f)
12243        else        else
12244          image_error ("Cannot get X image of `%s'; colors will not be freed",          image_error ("Cannot get X image of `%s'; colors will not be freed",
12245                       img->spec, Qnil);                       img->spec, Qnil);
12246          
12247        UNBLOCK_INPUT;        UNBLOCK_INPUT;
12248      }      }
12249  }  }
# Line 12359  value.") Line 12349  value.")
12349        rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),        rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
12350                                 prop_atom, 0, bytes_remaining,                                 prop_atom, 0, bytes_remaining,
12351                                 False, XA_STRING,                                 False, XA_STRING,
12352                                 &actual_type, &actual_format,                                 &actual_type, &actual_format,
12353                                 &actual_size, &bytes_remaining,                                 &actual_size, &bytes_remaining,
12354                                 (unsigned char **) &tmp_data);                                 (unsigned char **) &tmp_data);
12355        if (rc == Success)        if (rc == Success)
12356          prop_value = make_string (tmp_data, size);          prop_value = make_string (tmp_data, size);
# Line 12414  start_hourglass () Line 12404  start_hourglass ()
12404  #if 0 /* TODO: cursor shape changes.  */  #if 0 /* TODO: cursor shape changes.  */
12405    EMACS_TIME delay;    EMACS_TIME delay;
12406    int secs, usecs = 0;    int secs, usecs = 0;
12407      
12408    cancel_hourglass ();    cancel_hourglass ();
12409    
12410    if (INTEGERP (Vhourglass_delay)    if (INTEGERP (Vhourglass_delay)
# Line 12430  start_hourglass () Line 12420  start_hourglass ()
12420      }      }
12421    else    else
12422      secs = DEFAULT_HOURGLASS_DELAY;      secs = DEFAULT_HOURGLASS_DELAY;
12423      
12424    EMACS_SET_SECS_USECS (delay, secs, usecs);    EMACS_SET_SECS_USECS (delay, secs, usecs);
12425    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,    hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
12426                                     show_hourglass, NULL);                                     show_hourglass, NULL);
# Line 12449  cancel_hourglass () Line 12439  cancel_hourglass ()
12439        cancel_atimer (hourglass_atimer);        cancel_atimer (hourglass_atimer);
12440        hourglass_atimer = NULL;        hourglass_atimer = NULL;
12441      }      }
12442      
12443    if (hourglass_shown_p)    if (hourglass_shown_p)
12444      hide_hourglass ();      hide_hourglass ();
12445  }  }
# Line 12476  show_hourglass (timer) Line 12466  show_hourglass (timer)
12466    if (!hourglass_shown_p)    if (!hourglass_shown_p)
12467      {      {
12468        Lisp_Object rest, frame;        Lisp_Object rest, frame;
12469      
12470        BLOCK_INPUT;        BLOCK_INPUT;
12471      
12472        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
12473          if (FRAME_W32_P (XFRAME (frame)))          if (FRAME_W32_P (XFRAME (frame)))
12474            {            {
12475              struct frame *f = XFRAME (frame);              struct frame *f = XFRAME (frame);
12476            
12477              f->output_data.w32->hourglass_p = 1;              f->output_data.w32->hourglass_p = 1;
12478            
12479              if (!f->output_data.w32->hourglass_window)              if (!f->output_data.w32->hourglass_window)
12480                {                {
12481                  unsigned long mask = CWCursor;                  unsigned long mask = CWCursor;
12482                  XSetWindowAttributes attrs;                  XSetWindowAttributes attrs;
12483                
12484                  attrs.cursor = f->output_data.w32->hourglass_cursor;                  attrs.cursor = f->output_data.w32->hourglass_cursor;
12485                
12486                  f->output_data.w32->hourglass_window                  f->output_data.w32->hourglass_window
12487                    = XCreateWindow (FRAME_X_DISPLAY (f),                    = XCreateWindow (FRAME_X_DISPLAY (f),
12488                                     FRAME_OUTER_WINDOW (f),                                     FRAME_OUTER_WINDOW (f),
# Line 12501  show_hourglass (timer) Line 12491  show_hourglass (timer)
12491                                     CopyFromParent,                                     CopyFromParent,
12492                                     mask, &attrs);                                     mask, &attrs);
12493                }                }
12494            
12495              XMapRaised (FRAME_X_DISPLAY (f),              XMapRaised (FRAME_X_DISPLAY (f),
12496                          f->output_data.w32->hourglass_window);                          f->output_data.w32->hourglass_window);
12497              XFlush (FRAME_X_DISPLAY (f));              XFlush (FRAME_X_DISPLAY (f));
# Line 12528  hide_hourglass () Line 12518  hide_hourglass ()
12518        FOR_EACH_FRAME (rest, frame)        FOR_EACH_FRAME (rest, frame)
12519          {          {
12520            struct frame *f = XFRAME (frame);            struct frame *f = XFRAME (frame);
12521          
12522            if (FRAME_W32_P (f)            if (FRAME_W32_P (f)
12523                /* Watch out for newly created frames.  */                /* Watch out for newly created frames.  */
12524                && f->output_data.x->hourglass_window)                && f->output_data.x->hourglass_window)
# Line 12556  hide_hourglass () Line 12546  hide_hourglass ()
12546    
12547  static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *,  static Lisp_Object x_create_tip_frame P_ ((struct w32_display_info *,
12548                                             Lisp_Object));                                             Lisp_Object));
12549        
12550  /* The frame of a currently visible tooltip, or null.  */  /* The frame of a currently visible tooltip, or null.  */
12551    
12552  Lisp_Object tip_frame;  Lisp_Object tip_frame;
# Line 12579  unwind_create_tip_frame (frame) Line 12569  unwind_create_tip_frame (frame)
12569        tip_window = NULL;        tip_window = NULL;
12570        tip_frame = Qnil;        tip_frame = Qnil;
12571      }      }
12572      
12573    return deleted;    return deleted;
12574  }  }
12575    
# Line 12686  x_create_tip_frame (dpyinfo, parms) Line 12676  x_create_tip_frame (dpyinfo, parms)
12676          else          else
12677            font = x_new_font (f, XSTRING (font)->data);            font = x_new_font (f, XSTRING (font)->data);
12678        }        }
12679        
12680      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
12681      if (!STRINGP (font))      if (!STRINGP (font))
12682        font = x_new_font (f, "-*-courier new-normal-r-*-*-*-100-*-*-*-*-iso8859-1");        font = x_new_font (f, "-*-courier new-normal-r-*-*-*-100-*-*-*-*-iso8859-1");
# Line 12711  x_create_tip_frame (dpyinfo, parms) Line 12701  x_create_tip_frame (dpyinfo, parms)
12701    
12702    x_default_parameter (f, parms, Qborder_width, make_number (2),    x_default_parameter (f, parms, Qborder_width, make_number (2),
12703                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
12704      
12705    /* This defaults to 2 in order to match xterm.  We recognize either    /* This defaults to 2 in order to match xterm.  We recognize either
12706       internalBorderWidth or internalBorder (which is what xterm calls       internalBorderWidth or internalBorder (which is what xterm calls
12707       it).  */       it).  */
# Line 12749  x_create_tip_frame (dpyinfo, parms) Line 12739  x_create_tip_frame (dpyinfo, parms)
12739       end up in init_iterator with a null face cache, which should not       end up in init_iterator with a null face cache, which should not
12740       happen.  */       happen.  */
12741    init_frame_faces (f);    init_frame_faces (f);
12742      
12743    f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;    f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;
12744    window_prompting = x_figure_window_size (f, parms);    window_prompting = x_figure_window_size (f, parms);
12745    
# Line 12772  x_create_tip_frame (dpyinfo, parms) Line 12762  x_create_tip_frame (dpyinfo, parms)
12762    {    {
12763      XSetWindowAttributes attrs;      XSetWindowAttributes attrs;
12764      unsigned long mask;      unsigned long mask;
12765        
12766      BLOCK_INPUT;      BLOCK_INPUT;
12767      mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;      mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;
12768      /* Window managers looks at the override-redirect flag to      /* Window managers looks at the override-redirect flag to
# Line 12868  DY added (default is 10).") Line 12858  DY added (default is 10).")
12858    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
12859    int old_windows_or_buffers_changed = windows_or_buffers_changed;    int old_windows_or_buffers_changed = windows_or_buffers_changed;
12860    int count = specpdl_ptr - specpdl;    int count = specpdl_ptr - specpdl;
12861      
12862    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
12863    
12864    GCPRO4 (string, parms, frame, timeout);    GCPRO4 (string, parms, frame, timeout);
# Line 12884  DY added (default is 10).") Line 12874  DY added (default is 10).")
12874      dx = make_number (5);      dx = make_number (5);
12875    else    else
12876      CHECK_NUMBER (dx, 5);      CHECK_NUMBER (dx, 5);
12877      
12878    if (NILP (dy))    if (NILP (dy))
12879      dy = make_number (-10);      dy = make_number (-10);
12880    else    else
# Line 12904  DY added (default is 10).") Line 12894  DY added (default is 10).")
12894            && !NILP (Fequal (last_parms, parms)))            && !NILP (Fequal (last_parms, parms)))
12895          {          {
12896            struct frame *f = XFRAME (tip_frame);            struct frame *f = XFRAME (tip_frame);
12897              
12898            /* Only DX and DY have changed.  */            /* Only DX and DY have changed.  */
12899            if (!NILP (tip_timer))            if (!NILP (tip_timer))
12900              {              {
# Line 12993  DY added (default is 10).") Line 12983  DY added (default is 10).")
12983          }          }
12984        else        else
12985          row_width = row->pixel_width;          row_width = row->pixel_width;
12986          
12987        height += row->height;        height += row->height;
12988        width = max (width, row_width);        width = max (width, row_width);
12989      }      }
# Line 13045  Value is t is tooltip was open, nil othe Line 13035  Value is t is tooltip was open, nil othe
13035    /* Return quickly if nothing to do.  */    /* Return quickly if nothing to do.  */
13036    if (NILP (tip_timer) && NILP (tip_frame))    if (NILP (tip_timer) && NILP (tip_frame))
13037      return Qnil;      return Qnil;
13038      
13039    frame = tip_frame;    frame = tip_frame;
13040    timer = tip_timer;    timer = tip_timer;
13041    GCPRO2 (frame, timer);    GCPRO2 (frame, timer);
13042    tip_frame = tip_timer = deleted = Qnil;    tip_frame = tip_timer = deleted = Qnil;
13043      
13044    count = BINDING_STACK_SIZE ();    count = BINDING_STACK_SIZE ();
13045    specbind (Qinhibit_redisplay, Qt);    specbind (Qinhibit_redisplay, Qt);
13046    specbind (Qinhibit_quit, Qt);    specbind (Qinhibit_quit, Qt);
13047      
13048    if (!NILP (timer))    if (!NILP (timer))
13049      call1 (Qcancel_timer, timer);      call1 (Qcancel_timer, timer);
13050    
# Line 13203  DEFUN ("lookup-image", Flookup_image, Sl Line 13193  DEFUN ("lookup-image", Flookup_image, Sl
13193       Lisp_Object spec;       Lisp_Object spec;
13194  {  {
13195    int id = -1;    int id = -1;
13196      
13197    if (valid_image_p (spec))    if (valid_image_p (spec))
13198      id = lookup_image (SELECTED_FRAME (), spec);      id = lookup_image (SELECTED_FRAME (), spec);
13199    
# Line 13774  When nil, Emacs will translate the alt k Line 13764  When nil, Emacs will translate the alt k
13764                 "If non-zero, the virtual key code for an alternative quit key.");                 "If non-zero, the virtual key code for an alternative quit key.");
13765    XSETINT (Vw32_quit_key, 0);    XSETINT (Vw32_quit_key, 0);
13766    
13767    DEFVAR_LISP ("w32-pass-lwindow-to-system",    DEFVAR_LISP ("w32-pass-lwindow-to-system",
13768                 &Vw32_pass_lwindow_to_system,                 &Vw32_pass_lwindow_to_system,
13769                 "Non-nil if the left \"Windows\" key is passed on to Windows.\n\                 "Non-nil if the left \"Windows\" key is passed on to Windows.\n\
13770  When non-nil, the Start menu is opened by tapping the key.");  When non-nil, the Start menu is opened by tapping the key.");
13771    Vw32_pass_lwindow_to_system = Qt;    Vw32_pass_lwindow_to_system = Qt;
13772    
13773    DEFVAR_LISP ("w32-pass-rwindow-to-system",    DEFVAR_LISP ("w32-pass-rwindow-to-system",
13774                 &Vw32_pass_rwindow_to_system,                 &Vw32_pass_rwindow_to_system,
13775                 "Non-nil if the right \"Windows\" key is passed on to Windows.\n\                 "Non-nil if the right \"Windows\" key is passed on to Windows.\n\
13776  When non-nil, the Start menu is opened by tapping the key.");  When non-nil, the Start menu is opened by tapping the key.");
# Line 13798  acting on \"Windows\" key events when `w Line 13788  acting on \"Windows\" key events when `w
13788       means that this hack won't interfere with any real key code.  */       means that this hack won't interfere with any real key code.  */
13789    Vw32_phantom_key_code = 255;    Vw32_phantom_key_code = 255;
13790    
13791    DEFVAR_LISP ("w32-enable-num-lock",    DEFVAR_LISP ("w32-enable-num-lock",
13792                 &Vw32_enable_num_lock,                 &Vw32_enable_num_lock,
13793                 "Non-nil if Num Lock should act normally.\n\                 "Non-nil if Num Lock should act normally.\n\
13794  Set to nil to see Num Lock as the key `kp-numlock'.");  Set to nil to see Num Lock as the key `kp-numlock'.");
13795    Vw32_enable_num_lock = Qt;    Vw32_enable_num_lock = Qt;
13796    
13797    DEFVAR_LISP ("w32-enable-caps-lock",    DEFVAR_LISP ("w32-enable-caps-lock",
13798                 &Vw32_enable_caps_lock,                 &Vw32_enable_caps_lock,
13799                 "Non-nil if Caps Lock should act normally.\n\                 "Non-nil if Caps Lock should act normally.\n\
13800  Set to nil to see Caps Lock as the key `capslock'.");  Set to nil to see Caps Lock as the key `capslock'.");
# Line 13901  or when you set the mouse color."); Line 13891  or when you set the mouse color.");
13891    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,    DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
13892      "Non-zero means Emacs displays an hourglass pointer on window systems.");      "Non-zero means Emacs displays an hourglass pointer on window systems.");
13893    display_hourglass_p = 1;    display_hourglass_p = 1;
13894      
13895    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,    DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
13896       "*Seconds to wait before displaying an hourglass pointer.\n\       "*Seconds to wait before displaying an hourglass pointer.\n\
13897  Value must be an integer or float.");  Value must be an integer or float.");
# Line 14154  versions of Windows) characters."); Line 14144  versions of Windows) characters.");
14144    Qxpm = intern ("xpm");    Qxpm = intern ("xpm");
14145    staticpro (&Qxpm);    staticpro (&Qxpm);
14146  #endif  #endif
14147      
14148  #if HAVE_JPEG  #if HAVE_JPEG
14149    Qjpeg = intern ("jpeg");    Qjpeg = intern ("jpeg");
14150    staticpro (&Qjpeg);    staticpro (&Qjpeg);
14151  #endif  #endif
14152    
14153  #if HAVE_TIFF  #if HAVE_TIFF
14154    Qtiff = intern ("tiff");    Qtiff = intern ("tiff");
14155    staticpro (&Qtiff);    staticpro (&Qtiff);
14156  #endif  #endif
14157    
14158  #if HAVE_GIF  #if HAVE_GIF
14159    Qgif = intern ("gif");    Qgif = intern ("gif");
# Line 14208  init_xfns () Line 14198  init_xfns ()
14198    define_image_type (&xbm_type);    define_image_type (&xbm_type);
14199    define_image_type (&gs_type);    define_image_type (&gs_type);
14200    define_image_type (&pbm_type);    define_image_type (&pbm_type);
14201      
14202  #if HAVE_XPM  #if HAVE_XPM
14203    define_image_type (&xpm_type);    define_image_type (&xpm_type);
14204  #endif  #endif
14205      
14206  #if HAVE_JPEG  #if HAVE_JPEG
14207    define_image_type (&jpeg_type);    define_image_type (&jpeg_type);
14208  #endif  #endif
14209      
14210  #if HAVE_TIFF  #if HAVE_TIFF
14211    define_image_type (&tiff_type);    define_image_type (&tiff_type);
14212  #endif  #endif
14213      
14214  #if HAVE_GIF  #if HAVE_GIF
14215    define_image_type (&gif_type);    define_image_type (&gif_type);
14216  #endif  #endif
14217      
14218  #if HAVE_PNG  #if HAVE_PNG
14219    define_image_type (&png_type);    define_image_type (&png_type);
14220  #endif  #endif
# Line 14233  init_xfns () Line 14223  init_xfns ()
14223    
14224  #undef abort  #undef abort
14225    
14226  void  void
14227  w32_abort()  w32_abort()
14228  {  {
14229    int button;    int button;

Legend:
Removed from v.1.123.2.16  
changed lines
  Added in v.1.123.2.17

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