/[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.3.2.7 by miles, Tue Jul 6 09:14:36 2004 UTC revision 1.3.2.8 by miles, Tue Jul 6 09:31:29 2004 UTC
# 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 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 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");  
3745      if (! STRINGP (font))      if (! STRINGP (font))
3746        font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1");        font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
     if (! STRINGP (font))  
       /* This was formerly the first thing tried, but it finds too many fonts  
          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    {    {
     XSetWindowAttributes attrs;  
     unsigned long mask;  
   
3806      BLOCK_INPUT;      BLOCK_INPUT;
3807      mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask;      Rect r;
3808      /* Window managers looks at the override-redirect flag to  
3809         determine whether or net to give windows a decoration (Xlib      SetRect (&r, 0, 0, 1, 1);
3810         3.2.8).  */      if (CreateNewWindow (kHelpWindowClass,
3811      attrs.override_redirect = True;                           kWindowNoActivatesAttribute
3812      attrs.save_under = True;                           | kWindowIgnoreClicksAttribute,
3813      attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f);                           &r, &tip_window) == noErr)
3814      /* Arrange for getting MapNotify and UnmapNotify events.  */        {
3815      attrs.event_mask = StructureNotifyMask;          FRAME_MAC_WINDOW (f) = tip_window;
3816      tip_window          SetWRefCon (tip_window, (long) f->output_data.mac);
3817        = FRAME_W32_WINDOW (f)          /* so that update events can find this mac_output struct */
3818        = XCreateWindow (FRAME_W32_DISPLAY (f),          f->output_data.mac->mFP = f;
3819                         FRAME_W32_DISPLAY_INFO (f)->root_window,          ShowWindow (tip_window);
3820                         /* x, y, width, height */        }
                        0, 0, 1, 1,  
                        /* Border.  */  
                        1,  
                        CopyFromParent, InputOutput, CopyFromParent,  
                        mask, &attrs);  
3821      UNBLOCK_INPUT;      UNBLOCK_INPUT;
3822    }    }
3823    
# Line 3813  x_create_tip_frame (dpyinfo, parms) Line 3835  x_create_tip_frame (dpyinfo, parms)
3835       FRAME_LINES (f).  */       FRAME_LINES (f).  */
3836    width = FRAME_COLS (f);    width = FRAME_COLS (f);
3837    height = FRAME_LINES (f);    height = FRAME_LINES (f);
   FRAME_LINES (f) = 0;  
3838    SET_FRAME_COLS (f, 0);    SET_FRAME_COLS (f, 0);
3839      FRAME_LINES (f) = 0;
3840    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
3841    
3842    /* Add `tooltip' frame parameter's default value. */    /* Add `tooltip' frame parameter's default value. */
# Line 3822  x_create_tip_frame (dpyinfo, parms) Line 3844  x_create_tip_frame (dpyinfo, parms)
3844      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),      Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
3845                                              Qnil));                                              Qnil));
3846    
3847      /* Set up faces after all frame parameters are known.  This call
3848         also merges in face attributes specified for new frames.
3849    
3850         Frame parameters may be changed if .Xdefaults contains
3851         specifications for the default font.  For example, if there is an
3852         `Emacs.default.attributeBackground: pink', the `background-color'
3853         attribute of the frame get's set, which let's the internal border
3854         of the tooltip frame appear in pink.  Prevent this.  */
3855      {
3856        Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
3857    
3858        /* Set tip_frame here, so that */
3859        tip_frame = frame;
3860        call1 (Qface_set_after_frame_default, frame);
3861    
3862        if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
3863          Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
3864                                                  Qnil));
3865      }
3866    
3867    f->no_split = 1;    f->no_split = 1;
3868    
3869    UNGCPRO;    UNGCPRO;
# Line 3833  x_create_tip_frame (dpyinfo, parms) Line 3875  x_create_tip_frame (dpyinfo, parms)
3875    
3876    /* Now that the frame is official, it counts as a reference to    /* Now that the frame is official, it counts as a reference to
3877       its display.  */       its display.  */
3878    FRAME_W32_DISPLAY_INFO (f)->reference_count++;    FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
3879    
3880      /* Setting attributes of faces of the tooltip frame from resources
3881         and similar will increment face_change_count, which leads to the
3882         clearing of all current matrices.  Since this isn't necessary
3883         here, avoid it by resetting face_change_count to the value it
3884         had before we created the tip frame.  */
3885      face_change_count = face_change_count_before;
3886    
3887      /* Discard the unwind_protect.  */
3888    return unbind_to (count, frame);    return unbind_to (count, frame);
3889  #endif /* MAC_TODO */  }
3890    return Qnil;  
3891    
3892    /* Compute where to display tip frame F.  PARMS is the list of frame
3893       parameters for F.  DX and DY are specified offsets from the current
3894       location of the mouse.  WIDTH and HEIGHT are the width and height
3895       of the tooltip.  Return coordinates relative to the root window of
3896       the display in *ROOT_X, and *ROOT_Y.  */
3897    
3898    static void
3899    compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
3900         struct frame *f;
3901         Lisp_Object parms, dx, dy;
3902         int width, height;
3903         int *root_x, *root_y;
3904    {
3905      Lisp_Object left, top;
3906    
3907      /* User-specified position?  */
3908      left = Fcdr (Fassq (Qleft, parms));
3909      top  = Fcdr (Fassq (Qtop, parms));
3910    
3911      /* Move the tooltip window where the mouse pointer is.  Resize and
3912         show it.  */
3913      if (!INTEGERP (left) || !INTEGERP (top))
3914        {
3915          Point mouse_pos;
3916    
3917          BLOCK_INPUT;
3918          GetMouse (&mouse_pos);
3919          LocalToGlobal (&mouse_pos);
3920          *root_x = mouse_pos.h;
3921          *root_y = mouse_pos.v;
3922          UNBLOCK_INPUT;
3923        }
3924    
3925      if (INTEGERP (top))
3926        *root_y = XINT (top);
3927      else if (*root_y + XINT (dy) - height < 0)
3928        *root_y -= XINT (dy);
3929      else
3930        {
3931          *root_y -= height;
3932          *root_y += XINT (dy);
3933        }
3934    
3935      if (INTEGERP (left))
3936        *root_x = XINT (left);
3937      else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width)
3938        /* It fits to the right of the pointer.  */
3939        *root_x += XINT (dx);
3940      else if (width + XINT (dx) <= *root_x)
3941        /* It fits to the left of the pointer.  */
3942        *root_x -= width + XINT (dx);
3943      else
3944        /* Put it left-justified on the screen -- it ought to fit that way.  */
3945        *root_x = 0;
3946  }  }
3947    
3948    
3949  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,
3950         doc : /* Show STRING in a "tooltip" window on frame FRAME.         doc: /* Show STRING in a "tooltip" window on frame FRAME.
3951  A tooltip window is a small window displaying a string.  A tooltip window is a small X window displaying a string.
3952    
3953  FRAME nil or omitted means use the selected frame.  FRAME nil or omitted means use the selected frame.
3954    
# Line 3859  displayed at the mouse position, with of Line 3964  displayed at the mouse position, with of
3964  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
3965  parameter is specified, it determines the y-position of the tooltip  parameter is specified, it determines the y-position of the tooltip
3966  window, otherwise it is displayed at the mouse position, with offset  window, otherwise it is displayed at the mouse position, with offset
3967  DY added (default is 10).  */)  DY added (default is -10).
3968    (string, frame, parms, timeout, dx, dy)  
3969    A tooltip's maximum size is specified by `x-max-tooltip-size'.
3970    Text larger than the specified size is clipped.  */)
3971         (string, frame, parms, timeout, dx, dy)
3972       Lisp_Object string, frame, parms, timeout, dx, dy;       Lisp_Object string, frame, parms, timeout, dx, dy;
3973  {  {
3974    struct frame *f;    struct frame *f;
3975    struct window *w;    struct window *w;
3976    Window root, child;    int root_x, root_y;
   Lisp_Object buffer, top, left;  
3977    struct buffer *old_buffer;    struct buffer *old_buffer;
3978    struct text_pos pos;    struct text_pos pos;
3979    int i, width, height;    int i, width, height;
   int root_x, root_y, win_x, win_y;  
   unsigned pmask;  
3980    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3981    int old_windows_or_buffers_changed = windows_or_buffers_changed;    int old_windows_or_buffers_changed = windows_or_buffers_changed;
3982    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
# Line 3920  DY added (default is 10).  */) Line 4025  DY added (default is 10).  */)
4025                call1 (Qcancel_timer, timer);                call1 (Qcancel_timer, timer);
4026              }              }
4027    
 #if 0 /* MAC_TODO : Mac specifics */  
4028            BLOCK_INPUT;            BLOCK_INPUT;
4029            compute_tip_xy (f, parms, dx, dy, &root_x, &root_y);            compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
4030            XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),                            FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
4031                         root_x, root_y - FRAME_PIXEL_HEIGHT (f));            MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4032            UNBLOCK_INPUT;            UNBLOCK_INPUT;
 #endif /* MAC_TODO */  
4033            goto start_timer;            goto start_timer;
4034          }          }
4035      }      }
# Line 3953  DY added (default is 10).  */) Line 4056  DY added (default is 10).  */)
4056    
4057    /* Create a frame for the tooltip, and record it in the global    /* Create a frame for the tooltip, and record it in the global
4058       variable tip_frame.  */       variable tip_frame.  */
4059    frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms);    frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string);
4060    f = XFRAME (frame);    f = XFRAME (frame);
4061    
4062    /* 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.  */  
4063    w = XWINDOW (FRAME_ROOT_WINDOW (f));    w = XWINDOW (FRAME_ROOT_WINDOW (f));
4064    w->left_col = w->top_line = make_number (0);    w->left_col = w->top_line = make_number (0);
4065    w->total_cols = make_number (80);  
4066    w->total_lines = make_number (40);    if (CONSP (Vx_max_tooltip_size)
4067          && INTEGERP (XCAR (Vx_max_tooltip_size))
4068          && XINT (XCAR (Vx_max_tooltip_size)) > 0
4069          && INTEGERP (XCDR (Vx_max_tooltip_size))
4070          && XINT (XCDR (Vx_max_tooltip_size)) > 0)
4071        {
4072          w->total_cols = XCAR (Vx_max_tooltip_size);
4073          w->total_lines = XCDR (Vx_max_tooltip_size);
4074        }
4075      else
4076        {
4077          w->total_cols = make_number (80);
4078          w->total_lines = make_number (40);
4079        }
4080    
4081      FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
4082    adjust_glyphs (f);    adjust_glyphs (f);
4083    w->pseudo_window_p = 1;    w->pseudo_window_p = 1;
4084    
4085    /* 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);  
4086    old_buffer = current_buffer;    old_buffer = current_buffer;
4087    set_buffer_internal_1 (XBUFFER (buffer));    set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
4088    Ferase_buffer ();    current_buffer->truncate_lines = Qnil;
   Finsert (1, &string);  
4089    clear_glyph_matrix (w->desired_matrix);    clear_glyph_matrix (w->desired_matrix);
4090    clear_glyph_matrix (w->current_matrix);    clear_glyph_matrix (w->current_matrix);
4091    SET_TEXT_POS (pos, BEGV, BEGV_BYTE);    SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
# Line 3993  DY added (default is 10).  */) Line 4106  DY added (default is 10).  */)
4106        /* Let the row go over the full width of the frame.  */        /* Let the row go over the full width of the frame.  */
4107        row->full_width_p = 1;        row->full_width_p = 1;
4108    
4109        /* 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
4110           the cursor there.  Don't include the width of this glyph.  */           the cursor there.  Don't include the width of this glyph.  */
4111        if (row->used[TEXT_AREA])        if (row->used[TEXT_AREA])
4112          {          {
# Line 4014  DY added (default is 10).  */) Line 4127  DY added (default is 10).  */)
4127    
4128    /* Move the tooltip window where the mouse pointer is.  Resize and    /* Move the tooltip window where the mouse pointer is.  Resize and
4129       show it.  */       show it.  */
4130  #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);  
4131    
4132    BLOCK_INPUT;    BLOCK_INPUT;
4133    XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window,    MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4134                   &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask);    SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
4135    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));  
4136    UNBLOCK_INPUT;    UNBLOCK_INPUT;
 #endif /* MAC_TODO */  
4137    
4138    /* Draw into the window.  */    /* Draw into the window.  */
4139    w->must_be_updated_p = 1;    w->must_be_updated_p = 1;
# Line 4046  DY added (default is 10).  */) Line 4155  DY added (default is 10).  */)
4155    
4156  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,
4157         doc: /* Hide the current tooltip window, if there is any.         doc: /* Hide the current tooltip window, if there is any.
4158  Value is t is tooltip was open, nil otherwise.  */)  Value is t if tooltip was open, nil otherwise.  */)
4159    ()       ()
4160  {  {
4161    int count;    int count;
4162    Lisp_Object deleted, frame, timer;    Lisp_Object deleted, frame, timer;
# Line 4249  syms_of_macfns () Line 4358  syms_of_macfns ()
4358    staticpro (&Qsuppress_icon);    staticpro (&Qsuppress_icon);
4359    Qundefined_color = intern ("undefined-color");    Qundefined_color = intern ("undefined-color");
4360    staticpro (&Qundefined_color);    staticpro (&Qundefined_color);
4361    /* This is the end of symbol initialization.  */    Qcancel_timer = intern ("cancel-timer");
4362      staticpro (&Qcancel_timer);
4363    
4364    Qhyper = intern ("hyper");    Qhyper = intern ("hyper");
4365    staticpro (&Qhyper);    staticpro (&Qhyper);
# Line 4265  syms_of_macfns () Line 4375  syms_of_macfns ()
4375    staticpro (&Qcontrol);    staticpro (&Qcontrol);
4376    Qshift = intern ("shift");    Qshift = intern ("shift");
4377    staticpro (&Qshift);    staticpro (&Qshift);
4378      /* This is the end of symbol initialization.  */
4379    
4380    /* Text property `display' should be nonsticky by default.  */    /* Text property `display' should be nonsticky by default.  */
4381    Vtext_property_default_nonsticky    Vtext_property_default_nonsticky
# Line 4314  or when you set the mouse color.  */); Line 4425  or when you set the mouse color.  */);
4425                 doc: /* A string indicating the foreground color of the cursor box.  */);                 doc: /* A string indicating the foreground color of the cursor box.  */);
4426    Vx_cursor_fore_pixel = Qnil;    Vx_cursor_fore_pixel = Qnil;
4427    
4428      DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
4429        doc: /* Maximum size for tooltips.  Value is a pair (COLUMNS . ROWS).
4430    Text larger than this is clipped.  */);
4431      Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
4432    
4433    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,    DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4434                 doc: /* Non-nil if no window manager is in use.                 doc: /* Non-nil if no window manager is in use.
4435  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 4502  Chinese, Japanese, and Korean.  */);
4502    tip_frame = Qnil;    tip_frame = Qnil;
4503    staticpro (&tip_frame);    staticpro (&tip_frame);
4504    
4505      last_show_tip_args = Qnil;
4506      staticpro (&last_show_tip_args);
4507    
4508  #if 0 /* MAC_TODO */  #if 0 /* MAC_TODO */
4509    defsubr (&Sx_file_dialog);    defsubr (&Sx_file_dialog);
4510  #endif  #endif

Legend:
Removed from v.1.3.2.7  
changed lines
  Added in v.1.3.2.8

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