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

Diff of /emacs/src/macterm.c

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

revision 1.109 by mituharu, Thu Apr 14 09:26:22 2005 UTC revision 1.110 by mituharu, Sat Apr 16 03:05:15 2005 UTC
# Line 95  Boston, MA 02111-1307, USA.  */ Line 95  Boston, MA 02111-1307, USA.  */
95                          : controlKey)                          : controlKey)
96  #define macAltKey      (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)  #define macAltKey      (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
97    
98    #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
99    
100    
101  /* Non-nil means Emacs uses toolkit scroll bars.  */  /* Non-nil means Emacs uses toolkit scroll bars.  */
# Line 110  Lisp_Object Vmac_use_core_graphics; Line 111  Lisp_Object Vmac_use_core_graphics;
111    
112  static int any_help_event_p;  static int any_help_event_p;
113    
114  /* Non-zero means autoselect window with the mouse cursor.  */  /* Last window where we saw the mouse.  Used by mouse-autoselect-window.  */
115    static Lisp_Object last_window;
 int x_autoselect_window_p;  
116    
117  /* Non-zero means make use of UNDERLINE_POSITION font properties.  */  /* Non-zero means make use of UNDERLINE_POSITION font properties.  */
118    
# Line 273  static void x_font_min_bounds P_ ((XFont Line 273  static void x_font_min_bounds P_ ((XFont
273  static int x_compute_min_glyph_bounds P_ ((struct frame *));  static int x_compute_min_glyph_bounds P_ ((struct frame *));
274  static void x_update_end P_ ((struct frame *));  static void x_update_end P_ ((struct frame *));
275  static void XTframe_up_to_date P_ ((struct frame *));  static void XTframe_up_to_date P_ ((struct frame *));
 static void XTreassert_line_highlight P_ ((int, int));  
 static void x_change_line_highlight P_ ((int, int, int, int));  
276  static void XTset_terminal_modes P_ ((void));  static void XTset_terminal_modes P_ ((void));
277  static void XTreset_terminal_modes P_ ((void));  static void XTreset_terminal_modes P_ ((void));
278  static void x_clear_frame P_ ((void));  static void x_clear_frame P_ ((void));
279  static void frame_highlight P_ ((struct frame *));  static void frame_highlight P_ ((struct frame *));
280  static void frame_unhighlight P_ ((struct frame *));  static void frame_unhighlight P_ ((struct frame *));
281  static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));  static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
282    static void mac_focus_changed P_ ((int, struct mac_display_info *,
283                                       struct frame *, struct input_event *));
284    static void x_detect_focus_change P_ ((struct mac_display_info *,
285                                           EventRecord *, struct input_event *));
286  static void XTframe_rehighlight P_ ((struct frame *));  static void XTframe_rehighlight P_ ((struct frame *));
287  static void x_frame_rehighlight P_ ((struct x_display_info *));  static void x_frame_rehighlight P_ ((struct x_display_info *));
288  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));  static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
# Line 1198  XSetFont (display, gc, font) Line 1200  XSetFont (display, gc, font)
1200  }  }
1201    
1202    
 static void  
 XTextExtents16 (XFontStruct *font, XChar2b *text, int nchars,  
                      int *direction,int *font_ascent,  
                      int *font_descent, XCharStruct *cs)  
 {  
   /* MAC_TODO: Use GetTextMetrics to do this and inline it below. */  
 }  
   
   
1203  /* x_sync is a no-op on Mac.  */  /* x_sync is a no-op on Mac.  */
1204  void  void
1205  x_sync (f)  x_sync (f)
# Line 3494  static void Line 3487  static void
3487  frame_highlight (f)  frame_highlight (f)
3488       struct frame *f;       struct frame *f;
3489  {  {
3490      OSErr err;
3491      ControlRef root_control;
3492    
3493      BLOCK_INPUT;
3494      err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3495      if (err == noErr)
3496        ActivateControl (root_control);
3497      UNBLOCK_INPUT;
3498    x_update_cursor (f, 1);    x_update_cursor (f, 1);
3499  }  }
3500    
# Line 3501  static void Line 3502  static void
3502  frame_unhighlight (f)  frame_unhighlight (f)
3503       struct frame *f;       struct frame *f;
3504  {  {
3505      OSErr err;
3506      ControlRef root_control;
3507    
3508      BLOCK_INPUT;
3509      err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3510      if (err == noErr)
3511        DeactivateControl (root_control);
3512      UNBLOCK_INPUT;
3513    x_update_cursor (f, 1);    x_update_cursor (f, 1);
3514  }  }
3515    
# Line 3543  x_new_focus_frame (dpyinfo, frame) Line 3552  x_new_focus_frame (dpyinfo, frame)
3552    x_frame_rehighlight (dpyinfo);    x_frame_rehighlight (dpyinfo);
3553  }  }
3554    
3555    /* Handle FocusIn and FocusOut state changes for FRAME.
3556       If FRAME has focus and there exists more than one frame, puts
3557       a FOCUS_IN_EVENT into *BUFP.  */
3558    
3559    static void
3560    mac_focus_changed (type, dpyinfo, frame, bufp)
3561         int type;
3562         struct mac_display_info *dpyinfo;
3563         struct frame *frame;
3564         struct input_event *bufp;
3565    {
3566      if (type == activeFlag)
3567        {
3568          if (dpyinfo->x_focus_event_frame != frame)
3569            {
3570              x_new_focus_frame (dpyinfo, frame);
3571              dpyinfo->x_focus_event_frame = frame;
3572    
3573              /* Don't stop displaying the initial startup message
3574                 for a switch-frame event we don't need.  */
3575              if (GC_NILP (Vterminal_frame)
3576                  && GC_CONSP (Vframe_list)
3577                  && !GC_NILP (XCDR (Vframe_list)))
3578                {
3579                  bufp->kind = FOCUS_IN_EVENT;
3580                  XSETFRAME (bufp->frame_or_window, frame);
3581                }
3582            }
3583        }
3584      else
3585        {
3586          if (dpyinfo->x_focus_event_frame == frame)
3587            {
3588              dpyinfo->x_focus_event_frame = 0;
3589              x_new_focus_frame (dpyinfo, 0);
3590            }
3591        }
3592    }
3593    
3594    /* The focus may have changed.  Figure out if it is a real focus change,
3595       by checking both FocusIn/Out and Enter/LeaveNotify events.
3596    
3597       Returns FOCUS_IN_EVENT event in *BUFP. */
3598    
3599    static void
3600    x_detect_focus_change (dpyinfo, event, bufp)
3601         struct mac_display_info *dpyinfo;
3602         EventRecord *event;
3603         struct input_event *bufp;
3604    {
3605      struct frame *frame;
3606    
3607      frame = mac_window_to_frame ((WindowPtr) event->message);
3608      if (! frame)
3609        return;
3610    
3611      /* On Mac, this is only called from focus events, so no switch needed.  */
3612      mac_focus_changed ((event->modifiers & activeFlag),
3613                         dpyinfo, frame, bufp);
3614    }
3615    
3616    
3617  /* Handle an event saying the mouse has moved out of an Emacs frame.  */  /* Handle an event saying the mouse has moved out of an Emacs frame.  */
3618    
3619  void  void
# Line 3980  remember_mouse_glyph (f1, gx, gy) Line 4051  remember_mouse_glyph (f1, gx, gy)
4051  }  }
4052    
4053    
4054  static WindowPtr  static struct frame *
4055  front_emacs_window ()  mac_focus_frame (dpyinfo)
4056         struct mac_display_info *dpyinfo;
4057  {  {
4058  #if TARGET_API_MAC_CARBON    if (dpyinfo->x_focus_frame)
4059    WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true);      return dpyinfo->x_focus_frame;
4060      else
4061    while (wp && !is_emacs_window (wp))      /* Mac version may get events, such as a menu bar click, even when
4062      wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true);         all the frames are invisible.  In this case, we regard the
4063  #else         event came to the selected frame.  */
4064    WindowPtr wp = FrontWindow ();      return SELECTED_FRAME ();
   
   while (wp && (wp == tip_window || !is_emacs_window (wp)))  
     wp = GetNextWindow (wp);  
 #endif  
   
   return wp;  
4065  }  }
4066    
 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)  
4067    
4068  /* Return the current position of the mouse.  /* Return the current position of the mouse.
4069     *fp should be a frame which indicates which display to ask about.     *fp should be a frame which indicates which display to ask about.
# Line 4031  XTmouse_position (fp, insist, bar_window Line 4096  XTmouse_position (fp, insist, bar_window
4096  {  {
4097    Point mouse_pos;    Point mouse_pos;
4098    int ignore1, ignore2;    int ignore1, ignore2;
4099    WindowPtr wp = front_emacs_window ();    struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
4100    struct frame *f;    WindowPtr wp = FRAME_MAC_WINDOW (f);
4101    Lisp_Object frame, tail;    Lisp_Object frame, tail;
4102    
   if (is_emacs_window(wp))  
     f = mac_window_to_frame (wp);  
   
4103    BLOCK_INPUT;    BLOCK_INPUT;
4104    
4105    if (! NILP (last_mouse_scroll_bar) && insist == 0)    if (! NILP (last_mouse_scroll_bar) && insist == 0)
# Line 4604  x_scroll_bar_report_motion (fp, bar_wind Line 4666  x_scroll_bar_report_motion (fp, bar_wind
4666       unsigned long *time;       unsigned long *time;
4667  {  {
4668    struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);    struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4669    WindowPtr wp = front_emacs_window ();    ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4670    #if TARGET_API_MAC_CARBON
4671      WindowPtr wp = GetControlOwner (ch);
4672    #else
4673      WindowPtr wp = (*ch)->contrlOwner;
4674    #endif
4675    Point mouse_pos;    Point mouse_pos;
4676    struct frame *f = mac_window_to_frame (wp);    struct frame *f = mac_window_to_frame (wp);
4677    int win_y, top_range;    int win_y, top_range;
# Line 5050  x_new_fontset (f, fontsetname) Line 5117  x_new_fontset (f, fontsetname)
5117      return Qnil;      return Qnil;
5118    
5119    /* Since x_new_font doesn't update any fontset information, do it now.  */    /* Since x_new_font doesn't update any fontset information, do it now.  */
5120    FRAME_FONTSET(f) = fontset;    FRAME_FONTSET (f) = fontset;
5121    
5122    return build_string (fontsetname);    return build_string (fontsetname);
5123  }  }
# Line 5498  x_make_frame_invisible (f) Line 5565  x_make_frame_invisible (f)
5565    
5566    BLOCK_INPUT;    BLOCK_INPUT;
5567    
5568      /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
5569         that the current position of the window is user-specified, rather than
5570         program-specified, so that when the window is mapped again, it will be
5571         placed at the same location, without forcing the user to position it
5572         by hand again (they have already done that once for this window.)  */
5573      x_wm_set_size_hint (f, (long) 0, 1);
5574    
5575    HideWindow (FRAME_MAC_WINDOW (f));    HideWindow (FRAME_MAC_WINDOW (f));
5576    
5577    /* We can't distinguish this from iconification    /* We can't distinguish this from iconification
# Line 7454  do_app_resume () Line 7528  do_app_resume ()
7528  {  {
7529    /* Window-activate events will do the job. */    /* Window-activate events will do the job. */
7530  #if 0  #if 0
   WindowPtr wp;  
   struct frame *f;  
   
   wp = front_emacs_window ();  
   if (wp)  
     {  
       f = mac_window_to_frame (wp);  
   
       if (f)  
         {  
           x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);  
           activate_scroll_bars (f);  
         }  
     }  
   
7531    app_is_suspended = false;    app_is_suspended = false;
7532    app_sleep_time = WNE_SLEEP_AT_RESUME;    app_sleep_time = WNE_SLEEP_AT_RESUME;
7533  #endif  #endif
# Line 7479  do_app_suspend () Line 7538  do_app_suspend ()
7538  {  {
7539    /* Window-deactivate events will do the job. */    /* Window-deactivate events will do the job. */
7540  #if 0  #if 0
   WindowPtr wp;  
   struct frame *f;  
   
   wp = front_emacs_window ();  
   if (wp)  
     {  
       f = mac_window_to_frame (wp);  
   
       if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)  
         {  
           x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);  
           deactivate_scroll_bars (f);  
         }  
     }  
   
7541    app_is_suspended = true;    app_is_suspended = true;
7542    app_sleep_time = WNE_SLEEP_AT_SUSPEND;    app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7543  #endif  #endif
# Line 7501  do_app_suspend () Line 7545  do_app_suspend ()
7545    
7546    
7547  static void  static void
 do_mouse_moved (mouse_pos, f)  
      Point mouse_pos;  
      FRAME_PTR *f;  
 {  
   WindowPtr wp = front_emacs_window ();  
   struct x_display_info *dpyinfo;  
   
   if (wp)  
     {  
       *f = mac_window_to_frame (wp);  
       dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);  
   
       if (dpyinfo->mouse_face_hidden)  
         {  
           dpyinfo->mouse_face_hidden = 0;  
           clear_mouse_face (dpyinfo);  
         }  
   
       SetPortWindowPort (wp);  
   
       GlobalToLocal (&mouse_pos);  
   
       if (dpyinfo->grabbed && tracked_scroll_bar)  
         x_scroll_bar_note_movement (tracked_scroll_bar,  
                                     mouse_pos.v  
                                     - XINT (tracked_scroll_bar->top),  
                                     TickCount() * (1000 / 60));  
       else  
         note_mouse_movement (*f, &mouse_pos);  
     }  
 }  
   
   
 static void  
7548  do_apple_menu (SInt16 menu_item)  do_apple_menu (SInt16 menu_item)
7549  {  {
7550  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
# Line 7570  do_menu_choice (SInt32 menu_choice) Line 7580  do_menu_choice (SInt32 menu_choice)
7580    
7581      default:      default:
7582        {        {
7583          struct frame *f = mac_window_to_frame (front_emacs_window ());          struct frame *f = mac_focus_frame (&one_mac_display_info);
7584          MenuHandle menu = GetMenuHandle (menu_id);          MenuHandle menu = GetMenuHandle (menu_id);
7585          if (menu)          if (menu)
7586            {            {
# Line 7648  do_zoom_window (WindowPtr w, int zoom_in Line 7658  do_zoom_window (WindowPtr w, int zoom_in
7658    Point top_left;    Point top_left;
7659    int w_title_height, columns, rows, width, height;    int w_title_height, columns, rows, width, height;
7660    struct frame *f = mac_window_to_frame (w);    struct frame *f = mac_window_to_frame (w);
7661      struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
7662    
7663  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
7664    {    {
7665      Point standard_size;      Point standard_size;
7666    
7667      standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);      standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
7668      standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height;      standard_size.v = dpyinfo->height;
7669    
7670      if (IsWindowInStandardState (w, &standard_size, &zoom_rect))      if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
7671        zoom_in_or_out = inZoomIn;        zoom_in_or_out = inZoomIn;
# Line 7710  do_zoom_window (WindowPtr w, int zoom_in Line 7721  do_zoom_window (WindowPtr w, int zoom_in
7721          = zoom_rect;          = zoom_rect;
7722      }      }
7723    
7724    ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ());    ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
7725    
7726    SetPort (save_port);    SetPort (save_port);
7727  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
# Line 8576  XTread_socket (sd, expected, hold_quit) Line 8587  XTread_socket (sd, expected, hold_quit)
8587                {                {
8588                  SInt32 delta;                  SInt32 delta;
8589                  Point point;                  Point point;
8590                  WindowPtr window_ptr = front_emacs_window ();                  struct frame *f = mac_focus_frame (dpyinfo);
8591                    WindowPtr window_ptr;
8592    
8593                  if (!IsValidWindowPtr (window_ptr))                  if (!f)
8594                    {                    {
8595                        /* Beep if wheel move occurs when all the frames
8596                           are invisible.  */
8597                      SysBeep(1);                      SysBeep(1);
8598                      break;                      break;
8599                    }                    }
# Line 8595  XTread_socket (sd, expected, hold_quit) Line 8609  XTread_socket (sd, expected, hold_quit)
8609                  inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)                  inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8610                                    | ((delta < 0) ? down_modifier                                    | ((delta < 0) ? down_modifier
8611                                       : up_modifier));                                       : up_modifier));
8612                    window_ptr = FRAME_MAC_WINDOW (f);
8613                  SetPortWindowPort (window_ptr);                  SetPortWindowPort (window_ptr);
8614                  GlobalToLocal (&point);                  GlobalToLocal (&point);
8615                  XSETINT (inev.x, point.h);                  XSETINT (inev.x, point.h);
# Line 8653  XTread_socket (sd, expected, hold_quit) Line 8668  XTread_socket (sd, expected, hold_quit)
8668              switch (part_code)              switch (part_code)
8669                {                {
8670                case inMenuBar:                case inMenuBar:
8671                  f = mac_window_to_frame (front_emacs_window ());                  f = mac_focus_frame (dpyinfo);
8672                  saved_menu_event_location = er.where;                  saved_menu_event_location = er.where;
8673                  inev.kind = MENU_BAR_ACTIVATE_EVENT;                  inev.kind = MENU_BAR_ACTIVATE_EVENT;
8674                  XSETFRAME (inev.frame_or_window, f);                  XSETFRAME (inev.frame_or_window, f);
8675                  break;                  break;
8676    
8677                case inContent:                case inContent:
8678                  if (window_ptr != front_emacs_window ())                  if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo)))
8679                    SelectWindow (window_ptr);                    SelectWindow (window_ptr);
8680                  else                  else
8681                    {                    {
# Line 8851  XTread_socket (sd, expected, hold_quit) Line 8866  XTread_socket (sd, expected, hold_quit)
8866                help_echo_string = help_echo_object = help_echo_window = Qnil;                help_echo_string = help_echo_object = help_echo_window = Qnil;
8867                help_echo_pos = -1;                help_echo_pos = -1;
8868    
8869                do_mouse_moved (er.where, &f);                if (dpyinfo->grabbed && last_mouse_frame
8870                      && FRAME_LIVE_P (last_mouse_frame))
8871                    f = last_mouse_frame;
8872                  else
8873                    f = dpyinfo->x_focus_frame;
8874    
8875                  if (dpyinfo->mouse_face_hidden)
8876                    {
8877                      dpyinfo->mouse_face_hidden = 0;
8878                      clear_mouse_face (dpyinfo);
8879                    }
8880    
8881                  if (f)
8882                    {
8883                      WindowPtr wp = FRAME_MAC_WINDOW (f);
8884                      Point mouse_pos = er.where;
8885    
8886                      SetPortWindowPort (wp);
8887    
8888                      GlobalToLocal (&mouse_pos);
8889    
8890                      if (dpyinfo->grabbed && tracked_scroll_bar)
8891                        x_scroll_bar_note_movement (tracked_scroll_bar,
8892                                                    mouse_pos.v
8893                                                    - XINT (tracked_scroll_bar->top),
8894                                                    TickCount() * (1000 / 60));
8895                      else
8896                        {
8897                          /* Generate SELECT_WINDOW_EVENTs when needed.  */
8898                          if (mouse_autoselect_window)
8899                            {
8900                              Lisp_Object window;
8901    
8902                              window = window_from_coordinates (f,
8903                                                                mouse_pos.h,
8904                                                                mouse_pos.v,
8905                                                                0, 0, 0, 0);
8906    
8907                              /* Window will be selected only when it is
8908                                 not selected now and last mouse movement
8909                                 event was not in it.  Minibuffer window
8910                                 will be selected iff it is active.  */
8911                              if (WINDOWP (window)
8912                                  && !EQ (window, last_window)
8913                                  && !EQ (window, selected_window))
8914                                {
8915                                  inev.kind = SELECT_WINDOW_EVENT;
8916                                  inev.frame_or_window = window;
8917                                }
8918    
8919                              last_window=window;
8920                            }
8921                          note_mouse_movement (f, &mouse_pos);
8922                        }
8923                    }
8924    
8925                /* If the contents of the global variable                /* If the contents of the global variable
8926                   help_echo_string has changed, generate a                   help_echo_string has changed, generate a
# Line 8865  XTread_socket (sd, expected, hold_quit) Line 8934  XTread_socket (sd, expected, hold_quit)
8934          case activateEvt:          case activateEvt:
8935            {            {
8936              WindowPtr window_ptr = (WindowPtr) er.message;              WindowPtr window_ptr = (WindowPtr) er.message;
             ControlRef root_control;  
8937    
8938  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8939              if (SendEventToEventTarget (eventRef, toolbox_dispatcher)              if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
# Line 8881  XTread_socket (sd, expected, hold_quit) Line 8949  XTread_socket (sd, expected, hold_quit)
8949              if (!is_emacs_window (window_ptr))              if (!is_emacs_window (window_ptr))
8950                break;                break;
8951    
             f = mac_window_to_frame (window_ptr);  
             GetRootControl (window_ptr, &root_control);  
   
8952              if ((er.modifiers & activeFlag) != 0)              if ((er.modifiers & activeFlag) != 0)
8953                {                {
8954                  /* A window has been activated */                  /* A window has been activated */
8955                  Point mouse_loc = er.where;                  Point mouse_loc = er.where;
8956    
8957                  x_new_focus_frame (dpyinfo, f);                  x_detect_focus_change (dpyinfo, &er, &inev);
                 ActivateControl (root_control);  
8958    
8959                  SetPortWindowPort (window_ptr);                  SetPortWindowPort (window_ptr);
8960                  GlobalToLocal (&mouse_loc);                  GlobalToLocal (&mouse_loc);
# Line 8904  XTread_socket (sd, expected, hold_quit) Line 8968  XTread_socket (sd, expected, hold_quit)
8968                  /* A window has been deactivated */                  /* A window has been deactivated */
8969                  dpyinfo->grabbed = 0;                  dpyinfo->grabbed = 0;
8970    
8971                  if (f == dpyinfo->x_focus_frame)                  x_detect_focus_change (dpyinfo, &er, &inev);
                   {  
                     x_new_focus_frame (dpyinfo, 0);  
                     DeactivateControl (root_control);  
                   }  
   
8972    
8973                    f = mac_window_to_frame (window_ptr);
8974                  if (f == dpyinfo->mouse_face_mouse_frame)                  if (f == dpyinfo->mouse_face_mouse_frame)
8975                    {                    {
8976                      /* If we move outside the frame, then we're                      /* If we move outside the frame, then we're
# Line 8951  XTread_socket (sd, expected, hold_quit) Line 9011  XTread_socket (sd, expected, hold_quit)
9011                  break;                  break;
9012  #endif  #endif
9013    
9014  #if TARGET_API_MAC_CARBON              if (dpyinfo->x_focus_frame == NULL)
             if (!IsValidWindowPtr (front_emacs_window ()))  
9015                {                {
9016                    /* Beep if keyboard input occurs when all the frames
9017                       are invisible.  */
9018                  SysBeep (1);                  SysBeep (1);
9019                  break;                  break;
9020                }                }
9021  #endif  
9022              {              {
9023                static SInt16 last_key_script = -1;                static SInt16 last_key_script = -1;
9024                SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);                SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
# Line 8965  XTread_socket (sd, expected, hold_quit) Line 9026  XTread_socket (sd, expected, hold_quit)
9026                if (last_key_script != current_key_script)                if (last_key_script != current_key_script)
9027                  {                  {
9028                    struct input_event event;                    struct input_event event;
9029                      
9030                    EVENT_INIT (event);                    EVENT_INIT (event);
9031                    event.kind = LANGUAGE_CHANGE_EVENT;                    event.kind = LANGUAGE_CHANGE_EVENT;
9032                    event.arg = Qnil;                    event.arg = Qnil;
# Line 9009  XTread_socket (sd, expected, hold_quit) Line 9070  XTread_socket (sd, expected, hold_quit)
9070                      unsigned long some_state = 0;                      unsigned long some_state = 0;
9071                      inev.code = KeyTranslate (kchr_ptr, new_keycode,                      inev.code = KeyTranslate (kchr_ptr, new_keycode,
9072                                                &some_state) & 0xff;                                                &some_state) & 0xff;
9073                    } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey))                    }
9074              {                  else if (!NILP (Vmac_option_modifier)
9075                  /* When using the option key as an emacs modifier, convert                           && (er.modifiers & optionKey))
9076                     the pressed key code back to one without the Mac option                    {
9077                     modifier applied. */                      /* When using the option key as an emacs modifier,
9078                  int new_modifiers = er.modifiers & ~optionKey;                         convert the pressed key code back to one
9079                  int new_keycode = keycode | new_modifiers;                         without the Mac option modifier applied. */
9080                  Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);                      int new_modifiers = er.modifiers & ~optionKey;
9081                  unsigned long some_state = 0;                      int new_keycode = keycode | new_modifiers;
9082                  inev.code = KeyTranslate (kchr_ptr, new_keycode,                      Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9083                                            &some_state) & 0xff;                      unsigned long some_state = 0;
9084              }                      inev.code = KeyTranslate (kchr_ptr, new_keycode,
9085                                                  &some_state) & 0xff;
9086                      }
9087                  else                  else
9088                    inev.code = er.message & charCodeMask;                    inev.code = er.message & charCodeMask;
9089                  inev.kind = ASCII_KEYSTROKE_EVENT;                  inev.kind = ASCII_KEYSTROKE_EVENT;
# Line 9032  XTread_socket (sd, expected, hold_quit) Line 9095  XTread_socket (sd, expected, hold_quit)
9095  #else  #else
9096            inev.modifiers = mac_to_emacs_modifiers (er.modifiers);            inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9097  #endif  #endif
9098            XSETFRAME (inev.frame_or_window,            XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
                      mac_window_to_frame (front_emacs_window ()));  
9099            inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */            inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
9100            break;            break;
9101    
# Line 9046  XTread_socket (sd, expected, hold_quit) Line 9108  XTread_socket (sd, expected, hold_quit)
9108               constuct_drag_n_drop in w32term.c.  */               constuct_drag_n_drop in w32term.c.  */
9109            if (!NILP (drag_and_drop_file_list))            if (!NILP (drag_and_drop_file_list))
9110              {              {
9111                struct frame *f = NULL;                struct frame *f = mac_focus_frame (dpyinfo);
9112                WindowPtr wp;                WindowPtr wp;
9113                Lisp_Object frame;                Lisp_Object frame;
9114    
               wp = front_emacs_window ();  
   
               if (!wp)  
                 {  
                   struct frame *f = XFRAME (XCAR (Vframe_list));  
                   CollapseWindow (FRAME_MAC_WINDOW (f), false);  
                   wp = front_emacs_window ();  
                 }  
   
               if (wp)  
                 f = mac_window_to_frame (wp);  
   
9115                inev.kind = DRAG_N_DROP_EVENT;                inev.kind = DRAG_N_DROP_EVENT;
9116                inev.code = 0;                inev.code = 0;
9117                inev.timestamp = er.when * (1000 / 60);                inev.timestamp = er.when * (1000 / 60);
# Line 9078  XTread_socket (sd, expected, hold_quit) Line 9128  XTread_socket (sd, expected, hold_quit)
9128                XSETFRAME (frame, f);                XSETFRAME (frame, f);
9129                inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);                inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
9130    
9131    #if 0
9132                /* Regardless of whether Emacs was suspended or in the                /* Regardless of whether Emacs was suspended or in the
9133                   foreground, ask it to redraw its entire screen.                   foreground, ask it to redraw its entire screen.
9134                   Otherwise parts of the screen can be left in an                   Otherwise parts of the screen can be left in an
9135                   inconsistent state.  */                   inconsistent state.  */
9136                  wp = FRAME_MAC_WINDOW (f);
9137                if (wp)                if (wp)
9138  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
9139                  {                  {
# Line 9093  XTread_socket (sd, expected, hold_quit) Line 9145  XTread_socket (sd, expected, hold_quit)
9145  #else /* not TARGET_API_MAC_CARBON */  #else /* not TARGET_API_MAC_CARBON */
9146                  InvalRect (&(wp->portRect));                  InvalRect (&(wp->portRect));
9147  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
9148    #endif
9149              }              }
9150          default:          default:
9151            break;            break;
# Line 9572  mac_check_for_quit_char () Line 9625  mac_check_for_quit_char ()
9625        e.arg = Qnil;        e.arg = Qnil;
9626        e.modifiers = NULL;        e.modifiers = NULL;
9627        e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);        e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
9628        XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ()));        XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info));
9629        /* Remove event from queue to prevent looping. */        /* Remove event from queue to prevent looping. */
9630        RemoveEventFromQueue (GetMainEventQueue (), event);        RemoveEventFromQueue (GetMainEventQueue (), event);
9631        ReleaseEvent (event);        ReleaseEvent (event);
# Line 9765  syms_of_macterm () Line 9818  syms_of_macterm ()
9818    Qeuc_kr = intern ("euc-kr");    Qeuc_kr = intern ("euc-kr");
9819    staticpro (&Qeuc_kr);    staticpro (&Qeuc_kr);
9820    
   DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p,  
     doc: /* *Non-nil means autoselect window with mouse pointer.  */);  
   x_autoselect_window_p = 0;  
   
9821    DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,    DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
9822                 doc: /* If not nil, Emacs uses toolkit scroll bars.  */);                 doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
9823    Vx_toolkit_scroll_bars = Qt;    Vx_toolkit_scroll_bars = Qt;

Legend:
Removed from v.1.109  
changed lines
  Added in v.1.110

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