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

Diff of /emacs/src/macfns.c

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

revision 1.24.4.1 by handa, Fri Apr 16 12:50:48 2004 UTC revision 1.24.4.2 by miles, Mon Jun 28 07:29:22 2004 UTC
# Line 1  Line 1 
1  /* Graphical user interface functions for Mac OS.  /* Graphical user interface functions for Mac OS.
2     Copyright (C) 2000, 2001 Free Software Foundation, Inc.     Copyright (C) 2000, 2001, 2004 Free Software Foundation, Inc.
3    
4  This file is part of GNU Emacs.  This file is part of GNU Emacs.
5    
# Line 42  Boston, MA 02111-1307, USA.  */ Line 42  Boston, MA 02111-1307, USA.  */
42  #include "epaths.h"  #include "epaths.h"
43  #include "termhooks.h"  #include "termhooks.h"
44  #include "coding.h"  #include "coding.h"
 #include "ccl.h"  
45  #include "systime.h"  #include "systime.h"
46    
47  /* #include "bitmaps/gray.xbm" */  /* #include "bitmaps/gray.xbm" */
# Line 59  static unsigned char gray_bits[] = { Line 58  static unsigned char gray_bits[] = {
58    
59  #include <stdlib.h>  #include <stdlib.h>
60  #include <string.h>  #include <string.h>
 #ifndef MAC_OSX  
 #include <alloca.h>  
 #endif  
   
 #ifdef MAC_OSX  
 #include <QuickTime/QuickTime.h>  
 #else /* not MAC_OSX */  
 #include <Windows.h>  
 #include <Gestalt.h>  
 #include <TextUtils.h>  
 #endif /* not MAC_OSX */  
61    
62  /*extern void free_frame_menubar ();  /*extern void free_frame_menubar ();
63  extern double atof ();  extern double atof ();
# Line 2580  This function is an internal primitive-- Line 2568  This function is an internal primitive--
2568    f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));    f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
2569    bzero (f->output_data.mac, sizeof (struct mac_output));    bzero (f->output_data.mac, sizeof (struct mac_output));
2570    FRAME_FONTSET (f) = -1;    FRAME_FONTSET (f) = -1;
   f->output_data.mac->scroll_bar_foreground_pixel = -1;  
   f->output_data.mac->scroll_bar_background_pixel = -1;  
2571    record_unwind_protect (unwind_create_frame, frame);    record_unwind_protect (unwind_create_frame, frame);
2572    
2573    f->icon_name    f->icon_name
# Line 2598  This function is an internal primitive-- Line 2584  This function is an internal primitive--
2584    
2585    if (!NILP (parent))    if (!NILP (parent))
2586      {      {
2587        f->output_data.mac->parent_desc = (Window) parent;        f->output_data.mac->parent_desc = (Window) XFASTINT (parent);
2588        f->output_data.mac->explicit_parent = 1;        f->output_data.mac->explicit_parent = 1;
2589      }      }
2590    else    else
# Line 2708  This function is an internal primitive-- Line 2694  This function is an internal primitive--
2694    
2695    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),    x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1),
2696                         "menuBar", "MenuBar", RES_TYPE_NUMBER);                         "menuBar", "MenuBar", RES_TYPE_NUMBER);
2697    x_default_parameter (f, parms, Qtool_bar_lines, make_number (0),    x_default_parameter (f, parms, Qtool_bar_lines, make_number (1),
2698                         "toolBar", "ToolBar", RES_TYPE_NUMBER);                         "toolBar", "ToolBar", RES_TYPE_NUMBER);
2699    x_default_parameter (f, parms, Qbuffer_predicate, Qnil,    x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
2700                         "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);                         "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
# Line 2717  This function is an internal primitive-- Line 2703  This function is an internal primitive--
2703    
2704    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2705    
2706    /* MAC_TODO: specify 1 below when toolbars are implemented.  */  #if TARGET_API_MAC_CARBON
2707    window_prompting = x_figure_window_size (f, parms, 0);    f->output_data.mac->text_cursor = kThemeIBeamCursor;
2708      f->output_data.mac->nontext_cursor = kThemeArrowCursor;
2709      f->output_data.mac->modeline_cursor = kThemeArrowCursor;
2710      f->output_data.mac->hand_cursor = kThemePointingHandCursor;
2711      f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
2712      f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
2713    #else
2714      f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
2715      f->output_data.mac->nontext_cursor = &arrow_cursor;
2716      f->output_data.mac->modeline_cursor = &arrow_cursor;
2717      f->output_data.mac->hand_cursor = &arrow_cursor;
2718      f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
2719      f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
2720    #endif
2721    
2722      /* Compute the size of the window.  */
2723      window_prompting = x_figure_window_size (f, parms, 1);
2724    
2725    tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);    tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2726    f->no_split = minibuffer_only || EQ (tem, Qt);    f->no_split = minibuffer_only || EQ (tem, Qt);
2727    
   /* Create the window. Add the tool-bar height to the initial frame  
      height so that the user gets a text display area of the size he  
      specified with -g or via the registry. Later changes of the  
      tool-bar height don't change the frame size. This is done so that  
      users can create tall Emacs frames without having to guess how  
      tall the tool-bar will get. */  
   FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f);  
   
2728    /* mac_window (f, window_prompting, minibuffer_only); */    /* mac_window (f, window_prompting, minibuffer_only); */
2729    make_mac_frame (f);    make_mac_frame (f);
2730    
2731    x_icon (f, parms);    x_icon (f, parms);
   
2732    x_make_gc (f);    x_make_gc (f);
2733    
2734    /* Now consider the frame official.  */    /* Now consider the frame official.  */
# Line 2754  This function is an internal primitive-- Line 2747  This function is an internal primitive--
2747    x_default_parameter (f, parms, Qcursor_type, Qbox,    x_default_parameter (f, parms, Qcursor_type, Qbox,
2748                         "cursorType", "CursorType", RES_TYPE_SYMBOL);                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
2749    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,    x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
2750                         "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);                         "scrollBarWidth", "ScrollBarWidth",
2751                           RES_TYPE_NUMBER);
2752    
2753    /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.    /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2754       Change will not be effected unless different from the current       Change will not be effected unless different from the current
# Line 2762  This function is an internal primitive-- Line 2756  This function is an internal primitive--
2756    width = FRAME_COLS (f);    width = FRAME_COLS (f);
2757    height = FRAME_LINES (f);    height = FRAME_LINES (f);
2758    
   FRAME_LINES (f) = 0;  
2759    SET_FRAME_COLS (f, 0);    SET_FRAME_COLS (f, 0);
2760      FRAME_LINES (f) = 0;
2761    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
2762    
   /* Set up faces after all frame parameters are known.  */  
   call1 (Qface_set_after_frame_default, frame);  
   
2763  #if 0 /* MAC_TODO: when we have window manager hints */  #if 0 /* MAC_TODO: when we have window manager hints */
2764    /* Tell the server what size and position, etc, we want, and how    /* Tell the server what size and position, etc, we want, and how
2765       badly we want them.  This should be done after we have the menu       badly we want them.  This should be done after we have the menu
# Line 2948  If omitted or nil, that stands for the s Line 2939  If omitted or nil, that stands for the s
2939  {  {
2940    struct mac_display_info *dpyinfo = check_x_display_info (display);    struct mac_display_info *dpyinfo = check_x_display_info (display);
2941    
2942    /* MAC_TODO: check whether this is right */    /* We force 24+ bit depths to 24-bit to prevent an overflow.  */
2943    return make_number (dpyinfo->n_planes >= 8 ? 256 : 1 << dpyinfo->n_planes - 1);    return make_number (1 << min (dpyinfo->n_planes, 24));
2944  }  }
2945    
2946  DEFUN ("x-server-max-request-size", Fx_server_max_request_size,  DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
# Line 3025  If omitted or nil, that stands for the s Line 3016  If omitted or nil, that stands for the s
3016    /* MAC_TODO: this is an approximation, and only of the main display */    /* MAC_TODO: this is an approximation, and only of the main display */
3017    
3018    struct mac_display_info *dpyinfo = check_x_display_info (display);    struct mac_display_info *dpyinfo = check_x_display_info (display);
   short h, v;  
3019    
3020    ScreenRes (&h, &v);    return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy));
   
   return make_number ((int) (v / 72.0 * 25.4));  
3021  }  }
3022    
3023  DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,  DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
# Line 3043  If omitted or nil, that stands for the s Line 3031  If omitted or nil, that stands for the s
3031    /* MAC_TODO: this is an approximation, and only of the main display */    /* MAC_TODO: this is an approximation, and only of the main display */
3032    
3033    struct mac_display_info *dpyinfo = check_x_display_info (display);    struct mac_display_info *dpyinfo = check_x_display_info (display);
   short h, v;  
   
   ScreenRes (&h, &v);  
3034    
3035    return make_number ((int) (h / 72.0 * 25.4));    return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx));
3036  }  }
3037    
3038  DEFUN ("x-display-backing-store", Fx_display_backing_store,  DEFUN ("x-display-backing-store", Fx_display_backing_store,
# Line 3595  hide_hourglass () Line 3580  hide_hourglass ()
3580   ***********************************************************************/   ***********************************************************************/
3581    
3582  static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,  static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
3583                                             Lisp_Object));                                             Lisp_Object, Lisp_Object));
3584    static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
3585                                    Lisp_Object, int, int, int *, int *));
3586    
3587  /* The frame of a currently visible tooltip, or null.  */  /* The frame of a currently visible tooltip.  */
3588    
3589  Lisp_Object tip_frame;  Lisp_Object tip_frame;
3590    
# Line 3612  Window tip_window; Line 3599  Window tip_window;
3599    
3600  Lisp_Object last_show_tip_args;  Lisp_Object last_show_tip_args;
3601    
3602    /* Maximum size for tooltips; a cons (COLUMNS . ROWS).  */
3603    
3604    Lisp_Object Vx_max_tooltip_size;
3605    
3606    
3607    static Lisp_Object
3608    unwind_create_tip_frame (frame)
3609         Lisp_Object frame;
3610    {
3611      Lisp_Object deleted;
3612    
3613      deleted = unwind_create_frame (frame);
3614      if (EQ (deleted, Qt))
3615        {
3616          tip_window = NULL;
3617          tip_frame = Qnil;
3618        }
3619    
3620      return deleted;
3621    }
3622    
3623    
3624  /* Create a frame for a tooltip on the display described by DPYINFO.  /* Create a frame for a tooltip on the display described by DPYINFO.
3625     PARMS is a list of frame parameters.  Value is the frame.  */     PARMS is a list of frame parameters.  TEXT is the string to
3626       display in the tip frame.  Value is the frame.
3627    
3628       Note that functions called here, esp. x_default_parameter can
3629       signal errors, for instance when a specified color name is
3630       undefined.  We have to make sure that we're in a consistent state
3631       when this happens.  */
3632    
3633  static Lisp_Object  static Lisp_Object
3634  x_create_tip_frame (dpyinfo, parms)  x_create_tip_frame (dpyinfo, parms, text)
3635       struct mac_display_info *dpyinfo;       struct mac_display_info *dpyinfo;
3636       Lisp_Object parms;       Lisp_Object parms, text;
3637  {  {
 #if 0 /* MAC_TODO : Mac version */  
3638    struct frame *f;    struct frame *f;
3639    Lisp_Object frame, tem;    Lisp_Object frame, tem;
3640    Lisp_Object name;    Lisp_Object name;
# Line 3629  x_create_tip_frame (dpyinfo, parms) Line 3643  x_create_tip_frame (dpyinfo, parms)
3643    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
3644    struct gcpro gcpro1, gcpro2, gcpro3;    struct gcpro gcpro1, gcpro2, gcpro3;
3645    struct kboard *kb;    struct kboard *kb;
3646      int face_change_count_before = face_change_count;
3647      Lisp_Object buffer;
3648      struct buffer *old_buffer;
3649    
3650    check_x ();    check_mac ();
3651    
3652    /* Use this general default value to start with until we know if    /* Use this general default value to start with until we know if
3653       this frame has a specified name.  */       this frame has a specified name.  */
# Line 3643  x_create_tip_frame (dpyinfo, parms) Line 3660  x_create_tip_frame (dpyinfo, parms)
3660  #endif  #endif
3661    
3662    /* Get the name of the frame to use for resource lookup.  */    /* Get the name of the frame to use for resource lookup.  */
3663    name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);    name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
3664    if (!STRINGP (name)    if (!STRINGP (name)
3665        && !EQ (name, Qunbound)        && !EQ (name, Qunbound)
3666        && !NILP (name))        && !NILP (name))
# Line 3652  x_create_tip_frame (dpyinfo, parms) Line 3669  x_create_tip_frame (dpyinfo, parms)
3669    
3670    frame = Qnil;    frame = Qnil;
3671    GCPRO3 (parms, name, frame);    GCPRO3 (parms, name, frame);
3672    tip_frame = f = make_frame (1);    f = make_frame (1);
3673    XSETFRAME (frame, f);    XSETFRAME (frame, f);
3674    
3675      buffer = Fget_buffer_create (build_string (" *tip*"));
3676      Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
3677      old_buffer = current_buffer;
3678      set_buffer_internal_1 (XBUFFER (buffer));
3679      current_buffer->truncate_lines = Qnil;
3680      specbind (Qinhibit_read_only, Qt);
3681      specbind (Qinhibit_modification_hooks, Qt);
3682      Ferase_buffer ();
3683      Finsert (1, &text);
3684      set_buffer_internal_1 (old_buffer);
3685    
3686    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;    FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3687      record_unwind_protect (unwind_create_tip_frame, frame);
3688    
3689    f->output_method = output_w32;    /* By setting the output method, we're essentially saying that
3690    f->output_data.w32 =       the frame is live, as per FRAME_LIVE_P.  If we get a signal
3691      (struct w32_output *) xmalloc (sizeof (struct w32_output));       from this point on, x_destroy_window might screw up reference
3692    bzero (f->output_data.w32, sizeof (struct w32_output));       counts etc.  */
3693  #if 0    f->output_method = output_mac;
3694    f->output_data.w32->icon_bitmap = -1;    f->output_data.mac =
3695  #endif      (struct mac_output *) xmalloc (sizeof (struct mac_output));
3696    FRAME_FONTSET (f) = -1;    bzero (f->output_data.mac, sizeof (struct mac_output));
3697    
3698      FRAME_FONTSET (f)  = -1;
3699    f->icon_name = Qnil;    f->icon_name = Qnil;
3700    
3701    #if 0 /* GLYPH_DEBUG TODO: image support.  */
3702      image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
3703      dpyinfo_refcount = dpyinfo->reference_count;
3704    #endif /* GLYPH_DEBUG */
3705  #ifdef MULTI_KBOARD  #ifdef MULTI_KBOARD
3706    FRAME_KBOARD (f) = kb;    FRAME_KBOARD (f) = kb;
3707  #endif  #endif
3708    f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3709    f->output_data.w32->explicit_parent = 0;    f->output_data.mac->explicit_parent = 0;
3710    
3711    /* Set the name; the functions to which we pass f expect the name to    /* Set the name; the functions to which we pass f expect the name to
3712       be set.  */       be set.  */
3713    if (EQ (name, Qunbound) || NILP (name))    if (EQ (name, Qunbound) || NILP (name))
3714      {      {
3715        f->name = build_string (dpyinfo->x_id_name);        f->name = build_string (dpyinfo->mac_id_name);
3716        f->explicit_name = 0;        f->explicit_name = 0;
3717      }      }
3718    else    else
# Line 3687  x_create_tip_frame (dpyinfo, parms) Line 3723  x_create_tip_frame (dpyinfo, parms)
3723        specbind (Qx_resource_name, name);        specbind (Qx_resource_name, name);
3724      }      }
3725    
3726    /* Extract the window parameters from the supplied values    /* Extract the window parameters from the supplied values that are
3727       that are needed to determine window geometry.  */       needed to determine window geometry.  */
3728    {    {
3729      Lisp_Object font;      Lisp_Object font;
3730    
3731      font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);      font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
3732    
3733      BLOCK_INPUT;      BLOCK_INPUT;
3734      /* First, try whatever font the caller has specified.  */      /* First, try whatever font the caller has specified.  */
# Line 3706  x_create_tip_frame (dpyinfo, parms) Line 3742  x_create_tip_frame (dpyinfo, parms)
3742        }        }
3743    
3744      /* Try out a font which we hope has bold and italic variations.  */      /* Try out a font which we hope has bold and italic variations.  */
     if (!STRINGP (font))  
       font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1");  
     if (!STRINGP (font))  
       font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");  
     if (! STRINGP (font))  
       font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");  
3745      if (! STRINGP (font))      if (! STRINGP (font))
3746        /* This was formerly the first thing tried, but it finds too many fonts        font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
          and takes too long.  */  
       font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1");  
3747      /* If those didn't work, look for something which will at least work.  */      /* If those didn't work, look for something which will at least work.  */
3748      if (! STRINGP (font))      if (! STRINGP (font))
3749        font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1");        font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
3750        if (! STRINGP (font))
3751          font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
3752      UNBLOCK_INPUT;      UNBLOCK_INPUT;
3753      if (! STRINGP (font))      if (! STRINGP (font))
3754        font = build_string ("fixed");        error ("Cannot find any usable font");
3755    
3756      x_default_parameter (f, parms, Qfont, font,      x_default_parameter (f, parms, Qfont, font,
3757                           "font", "Font", RES_TYPE_STRING);                           "font", "Font", RES_TYPE_STRING);
# Line 3737  x_create_tip_frame (dpyinfo, parms) Line 3767  x_create_tip_frame (dpyinfo, parms)
3767      {      {
3768        Lisp_Object value;        Lisp_Object value;
3769    
3770        value = w32_get_arg (parms, Qinternal_border_width,        value = mac_get_arg (parms, Qinternal_border_width,
3771                           "internalBorder", "internalBorder", RES_TYPE_NUMBER);                           "internalBorder", "internalBorder", RES_TYPE_NUMBER);
3772        if (! EQ (value, Qunbound))        if (! EQ (value, Qunbound))
3773          parms = Fcons (Fcons (Qinternal_border_width, value),          parms = Fcons (Fcons (Qinternal_border_width, value),
# Line 3768  x_create_tip_frame (dpyinfo, parms) Line 3798  x_create_tip_frame (dpyinfo, parms)
3798       happen.  */       happen.  */
3799    init_frame_faces (f);    init_frame_faces (f);
3800    
3801    f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window;    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3802    
3803    window_prompting = x_figure_window_size (f, parms, 0);    window_prompting = x_figure_window_size (f, parms, 0);
3804    
3805    {    {
3806      XSetWindowAttributes attrs;      Rect r;
     unsigned long mask;  
3807    
3808      BLOCK_INPUT;      BLOCK_INPUT;
3809      mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;      SetRect (&r, 0, 0, 1, 1);
3810      /* Window managers looks at the override-redirect flag to      if (CreateNewWindow (kHelpWindowClass,
3811         determine whether or net to give windows a decoration (Xlib  #ifdef MAC_OS_X_VERSION_10_2
3812         3.2.8).  */                           kWindowIgnoreClicksAttribute |
3813      attrs.override_redirect = True;  #endif
3814      attrs.save_under = True;                           kWindowNoActivatesAttribute,
3815      attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);                           &r, &tip_window) == noErr)
3816      /* Arrange for getting MapNotify and UnmapNotify events.  */        {
3817      attrs.event_mask = StructureNotifyMask;          FRAME_MAC_WINDOW (f) = tip_window;
3818      tip_window          SetWRefCon (tip_window, (long) f->output_data.mac);
3819        = FRAME_W32_WINDOW (f)          /* so that update events can find this mac_output struct */
3820        = XCreateWindow (FRAME_W32_DISPLAY (f),          f->output_data.mac->mFP = f;
3821                         FRAME_W32_DISPLAY_INFO (f)->root_window,          ShowWindow (tip_window);
3822                         /* x, y, width, height */        }
                        0, 0, 1, 1,  
                        /* Border.  */  
                        1,  
                        CopyFromParent, InputOutput, CopyFromParent,  
                        mask, &attrs);  
3823      UNBLOCK_INPUT;      UNBLOCK_INPUT;
3824    }    }
3825    
# Line 3813  x_create_tip_frame (dpyinfo, parms) Line 3837  x_create_tip_frame (dpyinfo, parms)
3837       FRAME_LINES (f).  */       FRAME_LINES (f).  */
3838    width = FRAME_COLS (f);    width = FRAME_COLS (f);
3839    height = FRAME_LINES (f);    height = FRAME_LINES (f);
   FRAME_LINES (f) = 0;  
3840    SET_FRAME_COLS (f, 0);    SET_FRAME_COLS (f, 0);
3841      FRAME_LINES (f) = 0;
3842    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
3843    
3844    /* Add `tooltip' frame parameter's default value. */    /* Add `tooltip' frame parameter's default value. */
# Line 3822  x_create_tip_frame (dpyinfo, parms) Line 3846  x_create_tip_frame (dpyinfo, parms)
3846      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
3847                                              Qnil));                                              Qnil));
3848    
3849      /* Set up faces after all frame parameters are known.  This call
3850         also merges in face attributes specified for new frames.
3851    
3852         Frame parameters may be changed if .Xdefaults contains
3853         specifications for the default font.  For example, if there is an
3854         `Emacs.default.attributeBackground: pink', the `background-color'
3855         attribute of the frame get's set, which let's the internal border
3856         of the tooltip frame appear in pink.  Prevent this.  */
3857      {
3858        Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
3859    
3860        /* Set tip_frame here, so that */
3861        tip_frame = frame;
3862        call1 (Qface_set_after_frame_default, frame);
3863    
3864        if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
3865          Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
3866                                                  Qnil));
3867      }
3868    
3869    f->no_split = 1;    f->no_split = 1;
3870    
3871    UNGCPRO;    UNGCPRO;
# Line 3833  x_create_tip_frame (dpyinfo, parms) Line 3877  x_create_tip_frame (dpyinfo, parms)
3877    
3878    /* Now that the frame is official, it counts as a reference to    /* Now that the frame is official, it counts as a reference to
3879       its display.  */       its display.  */
3880    FRAME_W32_DISPLAY_INFO (f)->reference_count++;    FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
3881    
3882      /* Setting attributes of faces of the tooltip frame from resources
3883         and similar will increment face_change_count, which leads to the
3884         clearing of all current matrices.  Since this isn't necessary
3885         here, avoid it by resetting face_change_count to the value it
3886         had before we created the tip frame.  */
3887      face_change_count = face_change_count_before;
3888    
3889      /* Discard the unwind_protect.  */
3890    return unbind_to (count, frame);    return unbind_to (count, frame);
3891  #endif /* MAC_TODO */  }
3892    return Qnil;  
3893    
3894    /* Compute where to display tip frame F.  PARMS is the list of frame
3895       parameters for F.  DX and DY are specified offsets from the current
3896       location of the mouse.  WIDTH and HEIGHT are the width and height
3897       of the tooltip.  Return coordinates relative to the root window of
3898       the display in *ROOT_X, and *ROOT_Y.  */
3899    
3900    static void
3901    compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
3902         struct frame *f;
3903         Lisp_Object parms, dx, dy;
3904         int width, height;
3905         int *root_x, *root_y;
3906    {
3907      Lisp_Object left, top;
3908    
3909      /* User-specified position?  */
3910      left = Fcdr (Fassq (Qleft, parms));
3911      top  = Fcdr (Fassq (Qtop, parms));
3912    
3913      /* Move the tooltip window where the mouse pointer is.  Resize and
3914         show it.  */
3915      if (!INTEGERP (left) || !INTEGERP (top))
3916        {
3917          Point mouse_pos;
3918    
3919          BLOCK_INPUT;
3920          GetMouse (&mouse_pos);
3921          LocalToGlobal (&mouse_pos);
3922          *root_x = mouse_pos.h;
3923          *root_y = mouse_pos.v;
3924          UNBLOCK_INPUT;
3925        }
3926    
3927      if (INTEGERP (top))
3928        *root_y = XINT (top);
3929      else if (*root_y + XINT (dy) - height < 0)
3930        *root_y -= XINT (dy);
3931      else
3932        {
3933          *root_y -= height;
3934          *root_y += XINT (dy);
3935        }
3936    
3937      if (INTEGERP (left))
3938        *root_x = XINT (left);
3939      else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width)
3940        /* It fits to the right of the pointer.  */
3941        *root_x += XINT (dx);
3942      else if (width + XINT (dx) <= *root_x)
3943        /* It fits to the left of the pointer.  */
3944        *root_x -= width + XINT (dx);
3945      else
3946        /* Put it left-justified on the screen -- it ought to fit that way.  */
3947        *root_x = 0;
3948  }  }
3949    
3950    
3951  DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,  DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
3952         doc : /* Show STRING in a "tooltip" window on frame FRAME.         doc: /* Show STRING in a "tooltip" window on frame FRAME.
3953  A tooltip window is a small window displaying a string.  A tooltip window is a small X window displaying a string.
3954    
3955  FRAME nil or omitted means use the selected frame.  FRAME nil or omitted means use the selected frame.
3956    
# Line 3859  displayed at the mouse position, with of Line 3966  displayed at the mouse position, with of
3966  DX isn't specified).  Likewise for the y-position; if a `top' frame  DX isn't specified).  Likewise for the y-position; if a `top' frame
3967  parameter is specified, it determines the y-position of the tooltip  parameter is specified, it determines the y-position of the tooltip
3968  window, otherwise it is displayed at the mouse position, with offset  window, otherwise it is displayed at the mouse position, with offset
3969  DY added (default is 10).  */)  DY added (default is -10).
3970    (string, frame, parms, timeout, dx, dy)  
3971    A tooltip's maximum size is specified by `x-max-tooltip-size'.
3972    Text larger than the specified size is clipped.  */)
3973         (string, frame, parms, timeout, dx, dy)
3974       Lisp_Object string, frame, parms, timeout, dx, dy;       Lisp_Object string, frame, parms, timeout, dx, dy;
3975  {  {
3976    struct frame *f;    struct frame *f;
3977    struct window *w;    struct window *w;
3978    Window root, child;    int root_x, root_y;
   Lisp_Object buffer, top, left;  
3979    struct buffer *old_buffer;    struct buffer *old_buffer;
3980    struct text_pos pos;    struct text_pos pos;
3981    int i, width, height;    int i, width, height;
   int root_x, root_y, win_x, win_y;  
   unsigned pmask;  
3982    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3983    int old_windows_or_buffers_changed = windows_or_buffers_changed;    int old_windows_or_buffers_changed = windows_or_buffers_changed;
3984    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
# Line 3920  DY added (default is 10).  */) Line 4027  DY added (default is 10).  */)
4027                call1 (Qcancel_timer, timer);                call1 (Qcancel_timer, timer);
4028              }              }
4029    
 #if 0 /* MAC_TODO : Mac specifics */  
4030            BLOCK_INPUT;            BLOCK_INPUT;
4031            compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);            compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
4032            XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),                            FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
4033                         root_x, root_y - FRAME_PIXEL_HEIGHT (f));            MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4034            UNBLOCK_INPUT;            UNBLOCK_INPUT;
 #endif /* MAC_TODO */  
4035            goto start_timer;            goto start_timer;
4036          }          }
4037      }      }
# Line 3953  DY added (default is 10).  */) Line 4058  DY added (default is 10).  */)
4058    
4059    /* Create a frame for the tooltip, and record it in the global    /* Create a frame for the tooltip, and record it in the global
4060       variable tip_frame.  */       variable tip_frame.  */
4061    frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms);    frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string);
4062    f = XFRAME (frame);    f = XFRAME (frame);
4063    
4064    /* Set up the frame's root window.  Currently we use a size of 80    /* Set up the frame's root window.  */
      columns x 40 lines.  If someone wants to show a larger tip, he  
      will loose.  I don't think this is a realistic case.  */  
4065    w = XWINDOW (FRAME_ROOT_WINDOW (f));    w = XWINDOW (FRAME_ROOT_WINDOW (f));
4066    w->left_col = w->top_line = make_number (0);    w->left_col = w->top_line = make_number (0);
4067    w->total_cols = make_number (80);  
4068    w->total_lines = make_number (40);    if (CONSP (Vx_max_tooltip_size)
4069          && INTEGERP (XCAR (Vx_max_tooltip_size))
4070          && XINT (XCAR (Vx_max_tooltip_size)) > 0
4071          && INTEGERP (XCDR (Vx_max_tooltip_size))
4072          && XINT (XCDR (Vx_max_tooltip_size)) > 0)
4073        {
4074          w->total_cols = XCAR (Vx_max_tooltip_size);
4075          w->total_lines = XCDR (Vx_max_tooltip_size);
4076        }
4077      else
4078        {
4079          w->total_cols = make_number (80);
4080          w->total_lines = make_number (40);
4081        }
4082    
4083      FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
4084    adjust_glyphs (f);    adjust_glyphs (f);
4085    w->pseudo_window_p = 1;    w->pseudo_window_p = 1;
4086    
4087    /* Display the tooltip text in a temporary buffer.  */    /* Display the tooltip text in a temporary buffer.  */
   buffer = Fget_buffer_create (build_string (" *tip*"));  
   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);  
4088    old_buffer = current_buffer;    old_buffer = current_buffer;
4089    set_buffer_internal_1 (XBUFFER (buffer));    set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
4090    Ferase_buffer ();    current_buffer->truncate_lines = Qnil;
   Finsert (1, &string);  
4091    clear_glyph_matrix (w->desired_matrix);    clear_glyph_matrix (w->desired_matrix);
4092    clear_glyph_matrix (w->current_matrix);    clear_glyph_matrix (w->current_matrix);
4093    SET_TEXT_POS (pos, BEGV, BEGV_BYTE);    SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
# Line 3993  DY added (default is 10).  */) Line 4108  DY added (default is 10).  */)
4108        /* Let the row go over the full width of the frame.  */        /* Let the row go over the full width of the frame.  */
4109        row->full_width_p = 1;        row->full_width_p = 1;
4110    
4111        /* There's a glyph at the end of rows that is use to place        /* There's a glyph at the end of rows that is used to place
4112           the cursor there.  Don't include the width of this glyph.  */           the cursor there.  Don't include the width of this glyph.  */
4113        if (row->used[TEXT_AREA])        if (row->used[TEXT_AREA])
4114          {          {
# Line 4014  DY added (default is 10).  */) Line 4129  DY added (default is 10).  */)
4129    
4130    /* Move the tooltip window where the mouse pointer is.  Resize and    /* Move the tooltip window where the mouse pointer is.  Resize and
4131       show it.  */       show it.  */
4132  #if 0 /* TODO : Mac specifics */    compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
   compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);  
4133    
4134    BLOCK_INPUT;    BLOCK_INPUT;
4135    XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window,    MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4136                   &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);    SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
4137    XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),    BringToFront (FRAME_MAC_WINDOW (f));
                      root_x + 5, root_y - height - 5, width, height);  
   XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));  
4138    UNBLOCK_INPUT;    UNBLOCK_INPUT;
 #endif /* MAC_TODO */  
4139    
4140    /* Draw into the window.  */    /* Draw into the window.  */
4141    w->must_be_updated_p = 1;    w->must_be_updated_p = 1;
# Line 4046  DY added (default is 10).  */) Line 4157  DY added (default is 10).  */)
4157    
4158  DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,  DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
4159         doc: /* Hide the current tooltip window, if there is any.         doc: /* Hide the current tooltip window, if there is any.
4160  Value is t is tooltip was open, nil otherwise.  */)  Value is t if tooltip was open, nil otherwise.  */)
4161    ()       ()
4162  {  {
4163    int count;    int count;
4164    Lisp_Object deleted, frame, timer;    Lisp_Object deleted, frame, timer;
# Line 4249  syms_of_macfns () Line 4360  syms_of_macfns ()
4360    staticpro (&Qsuppress_icon);    staticpro (&Qsuppress_icon);
4361    Qundefined_color = intern ("undefined-color");    Qundefined_color = intern ("undefined-color");
4362    staticpro (&Qundefined_color);    staticpro (&Qundefined_color);
4363    /* This is the end of symbol initialization.  */    Qcancel_timer = intern ("cancel-timer");
4364      staticpro (&Qcancel_timer);
4365    
4366    Qhyper = intern ("hyper");    Qhyper = intern ("hyper");
4367    staticpro (&Qhyper);    staticpro (&Qhyper);
# Line 4265  syms_of_macfns () Line 4377  syms_of_macfns ()
4377    staticpro (&Qcontrol);    staticpro (&Qcontrol);
4378    Qshift = intern ("shift");    Qshift = intern ("shift");
4379    staticpro (&Qshift);    staticpro (&Qshift);
4380      /* This is the end of symbol initialization.  */
4381    
4382    /* Text property `display' should be nonsticky by default.  */    /* Text property `display' should be nonsticky by default.  */
4383    Vtext_property_default_nonsticky    Vtext_property_default_nonsticky
# Line 4314  or when you set the mouse color.  */); Line 4427  or when you set the mouse color.  */);
4427                 doc: /* A string indicating the foreground color of the cursor box.  */);                 doc: /* A string indicating the foreground color of the cursor box.  */);
4428    Vx_cursor_fore_pixel = Qnil;    Vx_cursor_fore_pixel = Qnil;
4429    
4430      DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
4431        doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
4432    Text larger than this is clipped.  */);
4433      Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
4434    
4435    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4436                 doc: /* Non-nil if no window manager is in use.                 doc: /* Non-nil if no window manager is in use.
4437  Emacs doesn't try to figure this out; this is always nil  Emacs doesn't try to figure this out; this is always nil
# Line 4386  Chinese, Japanese, and Korean.  */); Line 4504  Chinese, Japanese, and Korean.  */);
4504    tip_frame = Qnil;    tip_frame = Qnil;
4505    staticpro (&tip_frame);    staticpro (&tip_frame);
4506    
4507      last_show_tip_args = Qnil;
4508      staticpro (&last_show_tip_args);
4509    
4510  #if 0 /* MAC_TODO */  #if 0 /* MAC_TODO */
4511    defsubr (&Sx_file_dialog);    defsubr (&Sx_file_dialog);
4512  #endif  #endif

Legend:
Removed from v.1.24.4.1  
changed lines
  Added in v.1.24.4.2

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