/[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.3.2.13 by miles, Tue Jul 6 09:14:36 2004 UTC revision 1.3.2.14 by miles, Tue Jul 6 09:31:30 2004 UTC
# Line 53  Boston, MA 02111-1307, USA.  */ Line 53  Boston, MA 02111-1307, USA.  */
53  #if defined (__MRC__) || (__MSL__ >= 0x6000)  #if defined (__MRC__) || (__MSL__ >= 0x6000)
54  #include <ControlDefinitions.h>  #include <ControlDefinitions.h>
55  #endif  #endif
 #include <Gestalt.h>  
56    
57  #if __profile__  #if __profile__
58  #include <profiler.h>  #include <profiler.h>
# Line 196  static Lisp_Object last_mouse_scroll_bar Line 195  static Lisp_Object last_mouse_scroll_bar
195    
196  static Time last_mouse_movement_time;  static Time last_mouse_movement_time;
197    
 enum mouse_tracking_type {  
   mouse_tracking_none,  
   mouse_tracking_mouse_movement,  
   mouse_tracking_scroll_bar  
 };  
   
 enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none;  
   
198  struct scroll_bar *tracked_scroll_bar = NULL;  struct scroll_bar *tracked_scroll_bar = NULL;
199    
200  /* Incremented by XTread_socket whenever it really tries to read  /* Incremented by XTread_socket whenever it really tries to read
# Line 364  XDrawLine (display, w, gc, x1, y1, x2, y Line 355  XDrawLine (display, w, gc, x1, y1, x2, y
355       GC gc;       GC gc;
356       int x1, y1, x2, y2;       int x1, y1, x2, y2;
357  {  {
358  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
359    
360    mac_set_colors (gc);    mac_set_colors (gc);
361    
# Line 416  XClearArea (display, w, x, y, width, hei Line 403  XClearArea (display, w, x, y, width, hei
403    xgc.foreground = mwp->x_compatible.foreground_pixel;    xgc.foreground = mwp->x_compatible.foreground_pixel;
404    xgc.background = mwp->x_compatible.background_pixel;    xgc.background = mwp->x_compatible.background_pixel;
405    
406  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
407    
408    mac_set_colors (&xgc);    mac_set_colors (&xgc);
409    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
# Line 441  XClearWindow (display, w) Line 424  XClearWindow (display, w)
424    xgc.foreground = mwp->x_compatible.foreground_pixel;    xgc.foreground = mwp->x_compatible.foreground_pixel;
425    xgc.background = mwp->x_compatible.background_pixel;    xgc.background = mwp->x_compatible.background_pixel;
426    
427  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
428    
429    mac_set_colors (&xgc);    mac_set_colors (&xgc);
430    
# Line 480  mac_draw_bitmap (display, w, gc, x, y, w Line 459  mac_draw_bitmap (display, w, gc, x, y, w
459    bitmap.baseAddr = (char *)bits;    bitmap.baseAddr = (char *)bits;
460    SetRect (&(bitmap.bounds), 0, 0, width, height);    SetRect (&(bitmap.bounds), 0, 0, width, height);
461    
462  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
463    
464    mac_set_colors (gc);    mac_set_colors (gc);
465    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
# Line 509  mac_set_clip_rectangle (display, w, r) Line 484  mac_set_clip_rectangle (display, w, r)
484       WindowPtr w;       WindowPtr w;
485       Rect *r;       Rect *r;
486  {  {
487  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
488    
489    ClipRect (r);    ClipRect (r);
490  }  }
# Line 528  mac_reset_clipping (display, w) Line 499  mac_reset_clipping (display, w)
499  {  {
500    Rect r;    Rect r;
501    
502  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
503    
504    SetRect (&r, -32767, -32767, 32767, 32767);    SetRect (&r, -32767, -32767, 32767, 32767);
505    ClipRect (&r);    ClipRect (&r);
# Line 601  XCreatePixmap (display, w, width, height Line 568  XCreatePixmap (display, w, width, height
568    Rect r;    Rect r;
569    QDErr err;    QDErr err;
570    
571  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
572    
573    SetRect (&r, 0, 0, width, height);    SetRect (&r, 0, 0, width, height);
574    err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0);    err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0);
# Line 666  XFillRectangle (display, w, gc, x, y, wi Line 629  XFillRectangle (display, w, gc, x, y, wi
629  {  {
630    Rect r;    Rect r;
631    
632  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
633    
634    mac_set_colors (gc);    mac_set_colors (gc);
635    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
# Line 716  mac_draw_rectangle (display, w, gc, x, y Line 675  mac_draw_rectangle (display, w, gc, x, y
675  {  {
676    Rect r;    Rect r;
677    
678  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
679    
680    mac_set_colors (gc);    mac_set_colors (gc);
681    SetRect (&r, x, y, x + width + 1, y + height + 1);    SetRect (&r, x, y, x + width + 1, y + height + 1);
# Line 766  mac_draw_string_common (display, w, gc, Line 721  mac_draw_string_common (display, w, gc,
721       char *buf;       char *buf;
722       int nchars, mode, bytes_per_char;       int nchars, mode, bytes_per_char;
723  {  {
724  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
725    
726    mac_set_colors (gc);    mac_set_colors (gc);
727    
# Line 861  mac_copy_area (display, src, dest, gc, s Line 812  mac_copy_area (display, src, dest, gc, s
812  {  {
813    Rect src_r, dest_r;    Rect src_r, dest_r;
814    
815  #if TARGET_API_MAC_CARBON    SetPortWindowPort (dest);
   SetPort (GetWindowPort (dest));  
 #else  
   SetPort (dest);  
 #endif  
816    
817    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
818    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
# Line 901  mac_copy_area_with_mask (display, src, m Line 848  mac_copy_area_with_mask (display, src, m
848  {  {
849    Rect src_r, dest_r;    Rect src_r, dest_r;
850    
851  #if TARGET_API_MAC_CARBON    SetPortWindowPort (dest);
   SetPort (GetWindowPort (dest));  
 #else  
   SetPort (dest);  
 #endif  
852    
853    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
854    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
# Line 965  mac_scroll_area (display, w, gc, src_x, Line 908  mac_scroll_area (display, w, gc, src_x,
908    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
909    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);    SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
910    
911    SetPort (GetWindowPort (w));    SetPortWindowPort (w);
912    
913    ForeColor (blackColor);    ForeColor (blackColor);
914    BackColor (whiteColor);    BackColor (whiteColor);
# Line 1290  x_update_window_begin (w) Line 1233  x_update_window_begin (w)
1233          {          {
1234            int i;            int i;
1235    
1236            for (i = 0; i < w->desired_matrix->nrows; ++i)            for (i = 0; i < w->desired_matrix->nrows; ++i)
1237              if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))              if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
1238                break;                break;
1239    
# Line 1385  x_update_end (f) Line 1328  x_update_end (f)
1328    /* Reset the background color of Mac OS Window to that of the frame after    /* Reset the background color of Mac OS Window to that of the frame after
1329       update so that it is used by Mac Toolbox to clear the update region before       update so that it is used by Mac Toolbox to clear the update region before
1330       an update event is generated.  */       an update event is generated.  */
1331  #if TARGET_API_MAC_CARBON    SetPortWindowPort (FRAME_MAC_WINDOW (f));
   SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));  
 #else  
   SetPort (FRAME_MAC_WINDOW (f));  
 #endif  
1332    
1333    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1334    
# Line 3745  construct_mouse_click (result, event, f) Line 3684  construct_mouse_click (result, event, f)
3684    
3685    mouseLoc = event->where;    mouseLoc = event->where;
3686    
3687  #if TARGET_API_MAC_CARBON    SetPortWindowPort (FRAME_MAC_WINDOW (f));
   SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));  
 #else  
   SetPort (FRAME_MAC_WINDOW (f));  
 #endif  
3688    
3689    GlobalToLocal (&mouseLoc);    GlobalToLocal (&mouseLoc);
3690    XSETINT (result->x, mouseLoc.h);    XSETINT (result->x, mouseLoc.h);
# Line 3778  note_mouse_movement (frame, pos) Line 3713  note_mouse_movement (frame, pos)
3713       FRAME_PTR frame;       FRAME_PTR frame;
3714       Point *pos;       Point *pos;
3715  {  {
3716      struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
3717  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
3718    Rect r;    Rect r;
3719  #endif  #endif
# Line 3792  note_mouse_movement (frame, pos) Line 3728  note_mouse_movement (frame, pos)
3728    if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))    if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))
3729  #endif  #endif
3730      {      {
3731        frame->mouse_moved = 1;        if (frame == dpyinfo->mouse_face_mouse_frame)
3732        last_mouse_scroll_bar = Qnil;          /* This case corresponds to LeaveNotify in X11.  */
3733        note_mouse_highlight (frame, -1, -1);          {
3734              /* If we move outside the frame, then we're certainly no
3735                 longer on any text in the frame.  */
3736              clear_mouse_face (dpyinfo);
3737              dpyinfo->mouse_face_mouse_frame = 0;
3738              if (!dpyinfo->grabbed)
3739                rif->define_frame_cursor (frame,
3740                                          frame->output_data.mac->nontext_cursor);
3741            }
3742      }      }
3743    /* Has the mouse moved off the glyph it was on at the last sighting?  */    /* Has the mouse moved off the glyph it was on at the last sighting?  */
3744    else if (pos->h < last_mouse_glyph.left    else if (pos->h < last_mouse_glyph.left
# Line 3942  remember_mouse_glyph (f1, gx, gy) Line 3886  remember_mouse_glyph (f1, gx, gy)
3886  }  }
3887    
3888    
3889    static WindowPtr
3890    mac_front_window ()
3891    {
3892    #if TARGET_API_MAC_CARBON
3893      return GetFrontWindowOfClass (kDocumentWindowClass, true);
3894    #else
3895      WindowPtr front_window = FrontWindow ();
3896    
3897      if (tip_window && front_window == tip_window)
3898        return GetNextWindow (front_window);
3899      else
3900        return front_window;
3901    #endif
3902    }
3903    
3904    #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
3905    
3906  /* Return the current position of the mouse.  /* Return the current position of the mouse.
3907     *fp should be a frame which indicates which display to ask about.     *fp should be a frame which indicates which display to ask about.
3908    
# Line 3973  XTmouse_position (fp, insist, bar_window Line 3934  XTmouse_position (fp, insist, bar_window
3934  {  {
3935    Point mouse_pos;    Point mouse_pos;
3936    int ignore1, ignore2;    int ignore1, ignore2;
3937    WindowPtr wp = FrontWindow ();    WindowPtr wp = mac_front_window ();
3938    struct frame *f;    struct frame *f;
3939    Lisp_Object frame, tail;    Lisp_Object frame, tail;
3940    
3941    if (is_emacs_window(wp))    if (is_emacs_window(wp))
3942      f = ((mac_output *) GetWRefCon (wp))->mFP;      f = mac_window_to_frame (wp);
3943    
3944    BLOCK_INPUT;    BLOCK_INPUT;
3945    
# Line 3992  XTmouse_position (fp, insist, bar_window Line 3953  XTmouse_position (fp, insist, bar_window
3953    
3954        last_mouse_scroll_bar = Qnil;        last_mouse_scroll_bar = Qnil;
3955    
3956  #if TARGET_API_MAC_CARBON        SetPortWindowPort (wp);
       SetPort (GetWindowPort (wp));  
 #else  
       SetPort (wp);  
 #endif  
3957    
3958        GetMouse (&mouse_pos);        GetMouse (&mouse_pos);
3959    
# Line 4491  x_scroll_bar_handle_click (bar, part_cod Line 4448  x_scroll_bar_handle_click (bar, part_cod
4448       EventRecord *er;       EventRecord *er;
4449       struct input_event *bufp;       struct input_event *bufp;
4450  {  {
4451      int win_y, top_range;
4452    
4453    if (! GC_WINDOWP (bar->window))    if (! GC_WINDOWP (bar->window))
4454      abort ();      abort ();
4455    
# Line 4525  x_scroll_bar_handle_click (bar, part_cod Line 4484  x_scroll_bar_handle_click (bar, part_cod
4484        bufp->part = scroll_bar_handle;        bufp->part = scroll_bar_handle;
4485        break;        break;
4486      }      }
4487    
4488      win_y = XINT (bufp->y) - XINT (bar->top);
4489      top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
4490    
4491      win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
4492    
4493      win_y -= 24;
4494    
4495      if (! NILP (bar->dragging))
4496        win_y -= XINT (bar->dragging);
4497    
4498      if (win_y < 0)
4499        win_y = 0;
4500      if (win_y > top_range)
4501        win_y = top_range;
4502    
4503      XSETINT (bufp->x, win_y);
4504      XSETINT (bufp->y, top_range);
4505  }  }
4506    
4507    
# Line 4574  x_scroll_bar_report_motion (fp, bar_wind Line 4551  x_scroll_bar_report_motion (fp, bar_wind
4551       unsigned long *time;       unsigned long *time;
4552  {  {
4553    struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);    struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4554    WindowPtr wp = FrontWindow ();    WindowPtr wp = mac_front_window ();
4555    Point mouse_pos;    Point mouse_pos;
4556    struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;    struct frame *f = mac_window_to_frame (wp);
4557    int win_y, top_range;    int win_y, top_range;
4558    
4559  #if TARGET_API_MAC_CARBON    SetPortWindowPort (wp);
   SetPort (GetWindowPort (wp));  
 #else  
   SetPort (wp);  
 #endif  
4560    
4561    GetMouse (&mouse_pos);    GetMouse (&mouse_pos);
4562    
# Line 4810  mac_define_frame_cursor (f, cursor) Line 4783  mac_define_frame_cursor (f, cursor)
4783       struct frame *f;       struct frame *f;
4784       Cursor cursor;       Cursor cursor;
4785  {  {
4786    /* MAC TODO */  #if TARGET_API_MAC_CARBON
4787      SetThemeCursor (cursor);
4788    #else
4789      SetCursor (*cursor);
4790    #endif
4791  }  }
4792    
4793    
# Line 5078  x_calc_absolute_position (f) Line 5055  x_calc_absolute_position (f)
5055        GrafPtr savePort;        GrafPtr savePort;
5056        GetPort (&savePort);        GetPort (&savePort);
5057    
5058  #if TARGET_API_MAC_CARBON        SetPortWindowPort (FRAME_MAC_WINDOW (f));
       SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));  
 #else  
       SetPort (FRAME_MAC_WINDOW (f));  
 #endif  
5059    
5060  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
5061        {        {
# Line 5457  x_free_frame_resources (f) Line 5430  x_free_frame_resources (f)
5430       struct frame *f;       struct frame *f;
5431  {  {
5432    struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);    struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
5433      WindowPtr wp = FRAME_MAC_WINDOW (f);
5434    
5435    BLOCK_INPUT;    BLOCK_INPUT;
5436    
5437    DisposeWindow (FRAME_MAC_WINDOW (f));    DisposeWindow (wp);
5438      if (wp == tip_window)
5439        /* Neither WaitNextEvent nor ReceiveNextEvent receives `window
5440           closed' event.  So we reset tip_window here.  */
5441        tip_window = NULL;
5442    
5443    free_frame_menubar (f);    free_frame_menubar (f);
5444    
# Line 6984  Lisp_Object drag_and_drop_file_list; Line 6962  Lisp_Object drag_and_drop_file_list;
6962    
6963  Point saved_menu_event_location;  Point saved_menu_event_location;
6964    
6965    #if !TARGET_API_MAC_CARBON
6966    /* Place holder for the default arrow cursor.  */
6967    CursPtr arrow_cursor;
6968    #endif
6969    
6970  /* Apple Events */  /* Apple Events */
6971  static void init_required_apple_events (void);  static void init_required_apple_events (void);
6972  static pascal OSErr  static pascal OSErr
# Line 7170  do_init_managers (void) Line 7153  do_init_managers (void)
7153    InitCursor ();    InitCursor ();
7154    
7155  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
7156      arrow_cursor = &qd.arrow;
7157    
7158    /* set up some extra stack space for use by emacs */    /* set up some extra stack space for use by emacs */
7159    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
7160    
# Line 7198  do_check_ram_size (void) Line 7183  do_check_ram_size (void)
7183  static void  static void
7184  do_window_update (WindowPtr win)  do_window_update (WindowPtr win)
7185  {  {
7186    struct mac_output *mwp = (mac_output *) GetWRefCon (win);    struct frame *f = mac_window_to_frame (win);
7187    struct frame *f = mwp->mFP;  
7188      if (win == tip_window)
7189        /* The tooltip has been drawn already.  Avoid the
7190           SET_FRAME_GARBAGED below.  */
7191        return;
7192    
7193    if (f)    if (f)
7194      {      {
# Line 7250  is_emacs_window (WindowPtr win) Line 7239  is_emacs_window (WindowPtr win)
7239  static void  static void
7240  do_window_activate (WindowPtr win)  do_window_activate (WindowPtr win)
7241  {  {
   mac_output *mwp;  
7242    struct frame *f;    struct frame *f;
7243    
7244    if (is_emacs_window (win))    if (is_emacs_window (win))
7245      {      {
7246        mwp = (mac_output *) GetWRefCon (win);        f = mac_window_to_frame (win);
       f = mwp->mFP;  
7247    
7248        if (f)        if (f)
7249          {          {
# Line 7269  do_window_activate (WindowPtr win) Line 7256  do_window_activate (WindowPtr win)
7256  static void  static void
7257  do_window_deactivate (WindowPtr win)  do_window_deactivate (WindowPtr win)
7258  {  {
   mac_output *mwp;  
7259    struct frame *f;    struct frame *f;
7260    
7261    if (is_emacs_window (win))    if (is_emacs_window (win))
7262      {      {
7263        mwp = (mac_output *) GetWRefCon (win);        f = mac_window_to_frame (win);
       f = mwp->mFP;  
7264    
7265        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7266          {          {
# Line 7289  static void Line 7274  static void
7274  do_app_resume ()  do_app_resume ()
7275  {  {
7276    WindowPtr wp;    WindowPtr wp;
   mac_output *mwp;  
7277    struct frame *f;    struct frame *f;
7278    
7279    wp = FrontWindow();    wp = mac_front_window ();
7280    if (is_emacs_window (wp))    if (is_emacs_window (wp))
7281      {      {
7282        mwp = (mac_output *) GetWRefCon (wp);        f = mac_window_to_frame (wp);
       f = mwp->mFP;  
7283    
7284        if (f)        if (f)
7285          {          {
# Line 7313  static void Line 7296  static void
7296  do_app_suspend ()  do_app_suspend ()
7297  {  {
7298    WindowPtr wp;    WindowPtr wp;
   mac_output *mwp;  
7299    struct frame *f;    struct frame *f;
7300    
7301    wp = FrontWindow();    wp = mac_front_window ();
7302    if (is_emacs_window (wp))    if (is_emacs_window (wp))
7303      {      {
7304        mwp = (mac_output *) GetWRefCon (wp);        f = mac_window_to_frame (wp);
       f = mwp->mFP;  
7305    
7306        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)        if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7307          {          {
# Line 7335  do_app_suspend () Line 7316  do_app_suspend ()
7316    
7317    
7318  static void  static void
7319  do_mouse_moved (Point mouse_pos)  do_mouse_moved (mouse_pos, f)
7320         Point mouse_pos;
7321         FRAME_PTR *f;
7322  {  {
7323    WindowPtr wp = FrontWindow ();    WindowPtr wp = mac_front_window ();
7324    struct frame *f;    struct x_display_info *dpyinfo;
7325    
7326    if (is_emacs_window (wp))    if (is_emacs_window (wp))
7327      {      {
7328        f = ((mac_output *) GetWRefCon (wp))->mFP;        *f = mac_window_to_frame (wp);
7329          dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
 #if TARGET_API_MAC_CARBON  
       SetPort (GetWindowPort (wp));  
 #else  
       SetPort (wp);  
 #endif  
7330    
7331        GlobalToLocal (&mouse_pos);        if (dpyinfo->mouse_face_hidden)
7332            {
7333              dpyinfo->mouse_face_hidden = 0;
7334              clear_mouse_face (dpyinfo);
7335            }
7336    
7337        note_mouse_movement (f, &mouse_pos);        SetPortWindowPort (wp);
     }  
 }  
7338    
7339          GlobalToLocal (&mouse_pos);
7340    
7341  static void        if (dpyinfo->grabbed && tracked_scroll_bar)
7342  do_os_event (EventRecord *erp)          x_scroll_bar_note_movement (tracked_scroll_bar,
7343  {                                      mouse_pos.v
7344    switch((erp->message >> 24) & 0x000000FF)                                      - XINT (tracked_scroll_bar->top),
7345      {                                      TickCount() * (1000 / 60));
     case suspendResumeMessage:  
       if((erp->message & resumeFlag) == 1)  
         do_app_resume ();  
7346        else        else
7347          do_app_suspend ();          note_mouse_movement (*f, &mouse_pos);
       break;  
   
     case mouseMovedMessage:  
       do_mouse_moved (erp->where);  
       break;  
7348      }      }
7349  }  }
7350    
 static void  
 do_events (EventRecord *erp)  
 {  
   switch (erp->what)  
     {  
     case updateEvt:  
       do_window_update ((WindowPtr) erp->message);  
       break;  
   
     case osEvt:  
       do_os_event (erp);  
       break;  
   
     case activateEvt:  
       if ((erp->modifiers & activeFlag) != 0)  
         do_window_activate ((WindowPtr) erp->message);  
       else  
         do_window_deactivate ((WindowPtr) erp->message);  
       break;  
     }  
 }  
7351    
7352  static void  static void
7353  do_apple_menu (SInt16 menu_item)  do_apple_menu (SInt16 menu_item)
# Line 7433  do_menu_choice (SInt32 menu_choice) Line 7385  do_menu_choice (SInt32 menu_choice)
7385    
7386      default:      default:
7387        {        {
7388          WindowPtr wp = FrontWindow ();          struct frame *f = mac_window_to_frame (mac_front_window ());
         struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;  
7389          MenuHandle menu = GetMenuHandle (menu_id);          MenuHandle menu = GetMenuHandle (menu_id);
7390          if (menu)          if (menu)
7391            {            {
# Line 7459  do_grow_window (WindowPtr w, EventRecord Line 7410  do_grow_window (WindowPtr w, EventRecord
7410    long grow_size;    long grow_size;
7411    Rect limit_rect;    Rect limit_rect;
7412    int rows, columns;    int rows, columns;
7413    mac_output *mwp = (mac_output *) GetWRefCon (w);    struct frame *f = mac_window_to_frame (w);
   struct frame *f = mwp->mFP;  
7414    
7415    SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);    SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);
7416    
# Line 7489  do_zoom_window (WindowPtr w, int zoom_in Line 7439  do_zoom_window (WindowPtr w, int zoom_in
7439    Rect zoom_rect, port_rect;    Rect zoom_rect, port_rect;
7440    Point top_left;    Point top_left;
7441    int w_title_height, columns, rows, width, height, dummy, x, y;    int w_title_height, columns, rows, width, height, dummy, x, y;
7442    mac_output *mwp = (mac_output *) GetWRefCon (w);    struct frame *f = mac_window_to_frame (w);
   struct frame *f = mwp->mFP;  
7443    
7444    GetPort (&save_port);    GetPort (&save_port);
7445    
7446  #if TARGET_API_MAC_CARBON    SetPortWindowPort (w);
   SetPort (GetWindowPort (w));  
 #else  
   SetPort (w);  
 #endif  
7447    
7448    /* Clear window to avoid flicker.  */    /* Clear window to avoid flicker.  */
7449  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 7551  do_zoom_window (WindowPtr w, int zoom_in Line 7496  do_zoom_window (WindowPtr w, int zoom_in
7496      }      }
7497  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
7498    
7499    ZoomWindow (w, zoom_in_or_out, w == FrontWindow ());    ZoomWindow (w, zoom_in_or_out, w == mac_front_window ());
7500    
7501    /* retrieve window size and update application values */    /* retrieve window size and update application values */
7502  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 7561  do_zoom_window (WindowPtr w, int zoom_in Line 7506  do_zoom_window (WindowPtr w, int zoom_in
7506  #endif  #endif
7507    rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);    rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);
7508    columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);    columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);
7509    x_set_window_size (mwp->mFP, 0, columns, rows);    x_set_window_size (f, 0, columns, rows);
7510    
7511    SetPort (save_port);    SetPort (save_port);
7512  }  }
# Line 7892  mac_do_receive_drag (WindowPtr window, v Line 7837  mac_do_receive_drag (WindowPtr window, v
7837      {      {
7838        struct input_event event;        struct input_event event;
7839        Lisp_Object frame;        Lisp_Object frame;
7840        struct frame *f = ((mac_output *) GetWRefCon(window))->mFP;        struct frame *f = mac_window_to_frame (window);
7841        SetPort (GetWindowPort (window));        SetPortWindowPort (window);
7842        GlobalToLocal (&mouse);        GlobalToLocal (&mouse);
7843    
7844        event.kind = DRAG_N_DROP_EVENT;        event.kind = DRAG_N_DROP_EVENT;
# Line 8067  keycode_to_xkeysym (int keyCode, int *xK Line 8012  keycode_to_xkeysym (int keyCode, int *xK
8012  /* Emacs calls this whenever it wants to read an input event from the  /* Emacs calls this whenever it wants to read an input event from the
8013     user. */     user. */
8014  int  int
8015  XTread_socket (int sd, int expected, struct input_event *hold_quit)  XTread_socket (sd, expected, hold_quit)
8016         int sd, expected;
8017         struct input_event *hold_quit;
8018  {  {
8019    struct input_event inev;    struct input_event inev;
8020    int count = 0;    int count = 0;
8021  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
   OSStatus rneResult;  
8022    EventRef eventRef;    EventRef eventRef;
8023    EventMouseButton mouseBtn;    EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
8024    #else
8025      EventMask event_mask;
8026  #endif  #endif
8027    EventRecord er;    EventRecord er;
8028    int the_modifiers;    struct mac_display_info *dpyinfo = &one_mac_display_info;
   EventMask event_mask;  
8029    
 #if 0  
8030    if (interrupt_input_blocked)    if (interrupt_input_blocked)
8031      {      {
8032        interrupt_input_pending = 1;        interrupt_input_pending = 1;
8033        return -1;        return -1;
8034      }      }
 #endif  
8035    
8036    interrupt_input_pending = 0;    interrupt_input_pending = 0;
8037    BLOCK_INPUT;    BLOCK_INPUT;
# Line 8108  XTread_socket (int sd, int expected, str Line 8053  XTread_socket (int sd, int expected, str
8053    if (terminate_flag)    if (terminate_flag)
8054      Fkill_emacs (make_number (1));      Fkill_emacs (make_number (1));
8055    
8056    /* It is necessary to set this (additional) argument slot of an  #if !USE_CARBON_EVENTS
      event to nil because keyboard.c protects incompletely processed  
      event from being garbage collected by placing them in the  
      kbd_buffer_gcpro vector.  */  
   EVENT_INIT (inev);  
   inev.kind = NO_EVENT;  
   inev.arg = Qnil;  
   
8057    event_mask = everyEvent;    event_mask = everyEvent;
8058    if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))    if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8059      event_mask -= highLevelEventMask;      event_mask -= highLevelEventMask;
8060    
8061      while (WaitNextEvent (event_mask, &er,
8062                            (expected ? app_sleep_time : 0L), NULL))
8063    #else
8064      while (!ReceiveNextEvent (0, NULL,
8065                                (expected ? TicksToEventTime (app_sleep_time) : 0),
8066                                kEventRemoveFromQueue, &eventRef))
8067    #endif /* !USE_CARBON_EVENTS */
8068        {
8069          int do_help = 0;
8070          struct frame *f;
8071    
8072          expected = 0;
8073    
8074          /* It is necessary to set this (additional) argument slot of an
8075             event to nil because keyboard.c protects incompletely
8076             processed event from being garbage collected by placing them
8077             in the kbd_buffer_gcpro vector.  */
8078          EVENT_INIT (inev);
8079          inev.kind = NO_EVENT;
8080          inev.arg = Qnil;
8081    
8082  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
   rneResult = ReceiveNextEvent (0, NULL,  
                                 expected  
                                 ? TicksToEventTime (app_sleep_time)  
                                 : 0,  
                                 kEventRemoveFromQueue, &eventRef);  
   if (!rneResult)  
     {  
8083        /* Handle new events */        /* Handle new events */
8084        if (!mac_convert_event_ref (eventRef, &er))        if (!mac_convert_event_ref (eventRef, &er))
8085          switch (GetEventClass (eventRef))          switch (GetEventClass (eventRef))
# Line 8137  XTread_socket (int sd, int expected, str Line 8089  XTread_socket (int sd, int expected, str
8089                {                {
8090                  SInt32 delta;                  SInt32 delta;
8091                  Point point;                  Point point;
8092                  WindowPtr window_ptr = FrontNonFloatingWindow ();                  WindowPtr window_ptr = mac_front_window ();
8093                  struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);  
8094                  if (!IsValidWindowPtr (window_ptr))                  if (!IsValidWindowPtr (window_ptr))
8095                    {                    {
8096                      SysBeep(1);                      SysBeep(1);
8097                      UNBLOCK_INPUT;                      break;
                     return 0;  
8098                    }                    }
8099    
8100                  GetEventParameter(eventRef, kEventParamMouseWheelDelta,                  GetEventParameter(eventRef, kEventParamMouseWheelDelta,
# Line 8154  XTread_socket (int sd, int expected, str Line 8105  XTread_socket (int sd, int expected, str
8105                                    NULL, &point);                                    NULL, &point);
8106                  inev.kind = WHEEL_EVENT;                  inev.kind = WHEEL_EVENT;
8107                  inev.code = 0;                  inev.code = 0;
8108                  inev.modifiers = (mac_event_to_emacs_modifiers(eventRef)                  inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8109                                    | ((delta < 0) ? down_modifier                                    | ((delta < 0) ? down_modifier
8110                                       : up_modifier));                                       : up_modifier));
8111                  SetPort (GetWindowPort (window_ptr));                  SetPortWindowPort (window_ptr);
8112                  GlobalToLocal (&point);                  GlobalToLocal (&point);
8113                  XSETINT (inev.x, point.h);                  XSETINT (inev.x, point.h);
8114                  XSETINT (inev.y, point.v);                  XSETINT (inev.y, point.v);
8115                  XSETFRAME (inev.frame_or_window, mwp->mFP);                  XSETFRAME (inev.frame_or_window,
8116                               mac_window_to_frame (window_ptr));
8117                  inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);                  inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
8118                }                }
8119              else              else
8120                SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());                SendEventToEventTarget (eventRef, toolbox_dispatcher);
8121    
8122              break;              break;
8123            default:            default:
8124              /* Send the event to the appropriate receiver.  */              /* Send the event to the appropriate receiver.  */
8125              SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());              SendEventToEventTarget (eventRef, toolbox_dispatcher);
8126            }            }
8127        else        else
 #else  
   if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL))  
8128  #endif /* USE_CARBON_EVENTS */  #endif /* USE_CARBON_EVENTS */
8129      switch (er.what)        switch (er.what)
       {  
       case mouseDown:  
       case mouseUp:  
8130          {          {
8131            WindowPtr window_ptr = FrontWindow ();          case mouseDown:
8132            SInt16 part_code;          case mouseUp:
8133              {
8134                WindowPtr window_ptr;
8135                SInt16 part_code;
8136                int tool_bar_p = 0;
8137    
8138                if (dpyinfo->grabbed && last_mouse_frame
8139                    && FRAME_LIVE_P (last_mouse_frame))
8140                  {
8141                    window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
8142                    part_code = inContent;
8143                  }
8144                else
8145                  {
8146                    window_ptr = FrontWindow ();
8147                    if (tip_window && window_ptr == tip_window)
8148                      {
8149                        HideWindow (tip_window);
8150                        window_ptr = FrontWindow ();
8151                      }
8152    
8153  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8154            /* This is needed to send mouse events like aqua window buttons                  /* This is needed to send mouse events like aqua
8155               to the correct handler.  */                     window buttons to the correct handler.  */
8156            if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) {                  if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8157              break;                      != eventNotHandledErr)
8158            }                    break;
8159    
8160            if (!is_emacs_window(window_ptr))                  if (!is_emacs_window (window_ptr))
8161              break;                    break;
8162  #endif  #endif
8163                    part_code = FindWindow (er.where, &window_ptr);
8164                  }
8165    
8166            if (mouse_tracking_in_progress == mouse_tracking_scroll_bar              switch (part_code)
8167                && er.what == mouseUp)                {
8168              {                case inMenuBar:
8169                struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr);                  if (er.what == mouseDown)
8170                Point mouse_loc = er.where;                    {
8171                        f = mac_window_to_frame (mac_front_window ());
8172                        saved_menu_event_location = er.where;
8173                        inev.kind = MENU_BAR_ACTIVATE_EVENT;
8174                        XSETFRAME (inev.frame_or_window, f);
8175                      }
8176                    break;
8177    
8178                /* Convert to local coordinates of new window.  */                case inContent:
8179  #if TARGET_API_MAC_CARBON                  if (window_ptr != mac_front_window ())
8180                SetPort (GetWindowPort (window_ptr));                    SelectWindow (window_ptr);
8181  #else                  else
8182                SetPort (window_ptr);                    {
8183  #endif                      SInt16 control_part_code;
8184                        ControlHandle ch;
8185                        Point mouse_loc = er.where;
8186    
8187                GlobalToLocal (&mouse_loc);                      f = mac_window_to_frame (window_ptr);
8188                        /* convert to local coordinates of new window */
8189                        SetPortWindowPort (window_ptr);
8190    
8191  #if USE_CARBON_EVENTS                      GlobalToLocal (&mouse_loc);
8192                inev.code = mac_get_mouse_btn (eventRef);  #if TARGET_API_MAC_CARBON
8193                        ch = FindControlUnderMouse (mouse_loc, window_ptr,
8194                                                    &control_part_code);
8195  #else  #else
8196                inev.code = mac_get_emulate_btn (er.modifiers);                      control_part_code = FindControl (mouse_loc, window_ptr,
8197                                                         &ch);
8198  #endif  #endif
8199                inev.kind = SCROLL_BAR_CLICK_EVENT;  
               inev.frame_or_window = tracked_scroll_bar->window;  
               inev.part = scroll_bar_handle;  
8200  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8201                inev.modifiers = mac_event_to_emacs_modifiers (eventRef);                      inev.code = mac_get_mouse_btn (eventRef);
8202                        inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8203  #else  #else
8204                inev.modifiers = mac_to_emacs_modifiers (er.modifiers);                      inev.code = mac_get_emulated_btn (er.modifiers);
8205                        inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8206  #endif  #endif
8207                inev.modifiers |= up_modifier;                      XSETINT (inev.x, mouse_loc.h);
8208                inev.timestamp = er.when * (1000 / 60);                      XSETINT (inev.y, mouse_loc.v);
8209                  /* ticks to milliseconds */                      inev.timestamp = er.when * (1000 / 60);
8210                        /* ticks to milliseconds */
               XSETINT (inev.x, XFASTINT (tracked_scroll_bar->left) + 2);  
               XSETINT (inev.y, mouse_loc.v - 24);  
               tracked_scroll_bar->dragging = Qnil;  
               mouse_tracking_in_progress = mouse_tracking_none;  
               tracked_scroll_bar = NULL;  
               break;  
             }  
   
           part_code = FindWindow (er.where, &window_ptr);  
   
           switch (part_code)  
             {  
             case inMenuBar:  
               if (er.what == mouseDown)  
                 {  
                   struct frame *f = ((mac_output *)  
                                      GetWRefCon (FrontWindow ()))->mFP;  
                   saved_menu_event_location = er.where;  
                   inev.kind = MENU_BAR_ACTIVATE_EVENT;  
                   XSETFRAME (inev.frame_or_window, f);  
                 }  
               break;  
   
             case inContent:  
               if (window_ptr != FrontWindow ())  
                 SelectWindow (window_ptr);  
               else  
                 {  
                   SInt16 control_part_code;  
                   ControlHandle ch;  
                   struct mac_output *mwp = (mac_output *)  
                     GetWRefCon (window_ptr);  
                   Point mouse_loc = er.where;  
8211    
8212                    /* convert to local coordinates of new window */                      if (dpyinfo->grabbed && tracked_scroll_bar
8213  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
8214                    SetPort (GetWindowPort (window_ptr));                          || ch != 0
8215  #else  #else
8216                    SetPort (window_ptr);                          || control_part_code != 0
8217  #endif  #endif
8218                            )
8219                          {
8220                            struct scroll_bar *bar;
8221    
8222                            if (dpyinfo->grabbed && tracked_scroll_bar)
8223                              {
8224                                bar = tracked_scroll_bar;
8225                                control_part_code = kControlIndicatorPart;
8226                              }
8227                            else
8228                              bar = (struct scroll_bar *) GetControlReference (ch);
8229                            x_scroll_bar_handle_click (bar, control_part_code,
8230                                                       &er, &inev);
8231                            if (er.what == mouseDown
8232                                && control_part_code == kControlIndicatorPart)
8233                              tracked_scroll_bar = bar;
8234                            else
8235                              tracked_scroll_bar = NULL;
8236                          }
8237                        else
8238                          {
8239                            Lisp_Object window;
8240                            int x = mouse_loc.h;
8241                            int y = mouse_loc.v;
8242    
8243                            window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
8244                            if (EQ (window, f->tool_bar_window))
8245                              {
8246                                if (er.what == mouseDown)
8247                                  handle_tool_bar_click (f, x, y, 1, 0);
8248                                else
8249                                  handle_tool_bar_click (f, x, y, 0,
8250                                                         inev.modifiers);
8251                                tool_bar_p = 1;
8252                              }
8253                            else
8254                              {
8255                                XSETFRAME (inev.frame_or_window, f);
8256                                inev.kind = MOUSE_CLICK_EVENT;
8257                              }
8258                          }
8259    
8260                        if (er.what == mouseDown)
8261                          {
8262                            dpyinfo->grabbed |= (1 << inev.code);
8263                            last_mouse_frame = f;
8264                            /* Ignore any mouse motion that happened
8265                               before this event; any subsequent
8266                               mouse-movement Emacs events should reflect
8267                               only motion after the ButtonPress.  */
8268                            if (f != 0)
8269                              f->mouse_moved = 0;
8270    
8271                            if (!tool_bar_p)
8272                              last_tool_bar_item = -1;
8273                          }
8274                        else
8275                          {
8276                            if (dpyinfo->grabbed & (1 << inev.code) == 0)
8277                              /* If a button is released though it was not
8278                                 previously pressed, that would be because
8279                                 of multi-button emulation.  */
8280                              dpyinfo->grabbed = 0;
8281                            else
8282                              dpyinfo->grabbed &= ~(1 << inev.code);
8283                          }
8284    
8285                        switch (er.what)
8286                          {
8287                          case mouseDown:
8288                            inev.modifiers |= down_modifier;
8289                            break;
8290                          case mouseUp:
8291                            inev.modifiers |= up_modifier;
8292                            break;
8293                          }
8294                      }
8295                    break;
8296    
8297                    GlobalToLocal (&mouse_loc);                case inDrag:
8298  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
8299                    ch = FindControlUnderMouse (mouse_loc, window_ptr,                  if (er.what == mouseDown)
8300                                                &control_part_code);                    {
8301  #else                      BitMap bm;
                   control_part_code = FindControl (mouse_loc, window_ptr, &ch);  
 #endif  
8302    
8303  #if USE_CARBON_EVENTS                      GetQDGlobalsScreenBits (&bm);
8304                    inev.code = mac_get_mouse_btn (eventRef);                      DragWindow (window_ptr, er.where, &bm.bounds);
8305  #else                    }
8306                    inev.code = mac_get_emulate_btn (er.modifiers);  #else /* not TARGET_API_MAC_CARBON */
8307  #endif                  DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
8308                    XSETINT (inev.x, mouse_loc.h);  #endif /* not TARGET_API_MAC_CARBON */
8309                    XSETINT (inev.y, mouse_loc.v);                  break;
                   inev.timestamp = er.when * (1000 / 60);  
                     /* ticks to milliseconds */  
8310    
8311  #if TARGET_API_MAC_CARBON                case inGoAway:
8312                    if (ch != 0)                  if (TrackGoAway (window_ptr, er.where))
8313  #else                    {
8314                    if (control_part_code != 0)                      inev.kind = DELETE_WINDOW_EVENT;
8315  #endif                      XSETFRAME (inev.frame_or_window,
8316                      {                                 mac_window_to_frame (window_ptr));
8317                        struct scroll_bar *bar = (struct scroll_bar *)                    }
8318                          GetControlReference (ch);                  break;
                       x_scroll_bar_handle_click (bar, control_part_code, &er,  
                                                  &inev);  
                       if (er.what == mouseDown  
                           && control_part_code == kControlIndicatorPart)  
                         {  
                           mouse_tracking_in_progress  
                             = mouse_tracking_scroll_bar;  
                           tracked_scroll_bar = bar;  
                         }  
                       else  
                         {  
                           mouse_tracking_in_progress = mouse_tracking_none;  
                           tracked_scroll_bar = NULL;  
                         }  
                     }  
                   else  
                     {  
                       Lisp_Object window;  
                       int x = mouse_loc.h;  
                       int y = mouse_loc.v;  
   
                       XSETFRAME (inev.frame_or_window, mwp->mFP);  
                       if (er.what == mouseDown)  
                         mouse_tracking_in_progress  
                           = mouse_tracking_mouse_movement;  
                       else  
                         mouse_tracking_in_progress = mouse_tracking_none;  
                       window = window_from_coordinates (mwp->mFP, x, y, 0, 0, 0, 1);  
8319    
8320                        if (EQ (window, mwp->mFP->tool_bar_window))                  /* window resize handling added --ben */
8321                          {                case inGrow:
8322                            if (er.what == mouseDown)                  if (er.what == mouseDown)
8323                              handle_tool_bar_click (mwp->mFP, x, y, 1, 0);                    {
8324                            else                      do_grow_window(window_ptr, &er);
8325                              handle_tool_bar_click (mwp->mFP, x, y, 0,                      break;
8326                      }
8327    
8328                    /* window zoom handling added --ben */
8329                  case inZoomIn:
8330                  case inZoomOut:
8331                    if (TrackBox (window_ptr, er.where, part_code))
8332                      do_zoom_window (window_ptr, part_code);
8333                    break;
8334    
8335                  default:
8336                    break;
8337                  }
8338              }
8339              break;
8340    
8341            case updateEvt:
8342  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8343                                                     mac_event_to_emacs_modifiers (eventRef)            if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8344  #else                != eventNotHandledErr)
8345                                                     er.modifiers              break;
8346  #endif  #endif
8347                                                     );            do_window_update ((WindowPtr) er.message);
8348                            break;            break;
                         }  
                       else  
                         inev.kind = MOUSE_CLICK_EVENT;  
                     }  
8349    
8350            case osEvt:
8351  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8352                    inev.modifiers = mac_event_to_emacs_modifiers (eventRef);            if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8353  #else                != eventNotHandledErr)
8354                    inev.modifiers = mac_to_emacs_modifiers (er.modifiers);              break;
8355  #endif  #endif
8356              switch ((er.message >> 24) & 0x000000FF)
8357                {
8358                case suspendResumeMessage:
8359                  if ((er.message & resumeFlag) == 1)
8360                    do_app_resume ();
8361                  else
8362                    do_app_suspend ();
8363                  break;
8364    
8365                    switch (er.what)              case mouseMovedMessage:
8366                      {                previous_help_echo_string = help_echo_string;
8367                      case mouseDown:                help_echo_string = help_echo_object = help_echo_window = Qnil;
8368                        inev.modifiers |= down_modifier;                help_echo_pos = -1;
8369                        break;  
8370                      case mouseUp:                do_mouse_moved (er.where, &f);
8371                        inev.modifiers |= up_modifier;  
8372                        break;                /* If the contents of the global variable
8373                      }                   help_echo_string has changed, generate a
8374                  }                   HELP_EVENT.  */
8375                  if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
8376                    do_help = 1;
8377                break;                break;
8378                }
8379              break;
8380    
8381              case inDrag:          case activateEvt:
8382  #if TARGET_API_MAC_CARBON            {
8383                if (er.what == mouseDown)              WindowPtr window_ptr = (WindowPtr) er.message;
                 {  
                   BitMap bm;  
8384    
8385                    GetQDGlobalsScreenBits (&bm);  #if USE_CARBON_EVENTS
8386                    DragWindow (window_ptr, er.where, &bm.bounds);              if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8387                  }                  != eventNotHandledErr)
 #else /* not TARGET_API_MAC_CARBON */  
               DragWindow (window_ptr, er.where, &qd.screenBits.bounds);  
 #endif /* not TARGET_API_MAC_CARBON */  
8388                break;                break;
8389    #endif
8390                if (window_ptr == tip_window)
8391                  {
8392                    HideWindow (tip_window);
8393                    break;
8394                  }
8395    
8396              case inGoAway:              if ((er.modifiers & activeFlag) != 0)
8397                if (TrackGoAway (window_ptr, er.where))                {
8398                  {                  Point mouse_loc = er.where;
                   inev.kind = DELETE_WINDOW_EVENT;  
                   XSETFRAME (inev.frame_or_window,  
                              ((mac_output *) GetWRefCon (window_ptr))->mFP);  
                 }  
               break;  
8399    
8400              /* window resize handling added --ben */                  do_window_activate (window_ptr);
             case inGrow:  
               if (er.what == mouseDown)  
                 {  
                   do_grow_window(window_ptr, &er);  
                   break;  
                 }  
8401    
8402              /* window zoom handling added --ben */                  SetPortWindowPort (window_ptr);
8403              case inZoomIn:                  GlobalToLocal (&mouse_loc);
8404              case inZoomOut:                  /* activateEvt counts as mouse movement,
8405                if (TrackBox (window_ptr, er.where, part_code))                     so update things that depend on mouse position.  */
8406                  do_zoom_window (window_ptr, part_code);                  note_mouse_movement (mac_window_to_frame (window_ptr),
8407                break;                                       &mouse_loc);
8408                  }
8409                else
8410                  {
8411                    do_window_deactivate (window_ptr);
8412    
8413              default:                  f = mac_window_to_frame (window_ptr);
8414                break;                  if (f == dpyinfo->mouse_face_mouse_frame)
8415              }                    {
8416          }                      /* If we move outside the frame, then we're
8417          break;                         certainly no longer on any text in the
8418                           frame.  */
8419                        clear_mouse_face (dpyinfo);
8420                        dpyinfo->mouse_face_mouse_frame = 0;
8421                      }
8422    
8423        case updateEvt:                  /* Generate a nil HELP_EVENT to cancel a help-echo.
8424        case osEvt:                     Do it only if there's something to cancel.
8425        case activateEvt:                     Otherwise, the startup message is cleared when the
8426  #if USE_CARBON_EVENTS                     mouse leaves the frame.  */
8427          if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()))                  if (any_help_event_p)
8428  #endif                    do_help = -1;
8429          do_events (&er);                }
8430          break;            }
8431              break;
8432    
8433        case keyDown:          case keyDown:
8434        case autoKey:          case autoKey:
8435          {            {
8436            int keycode = (er.message & keyCodeMask) >> 8;              int keycode = (er.message & keyCodeMask) >> 8;
8437            int xkeysym;              int xkeysym;
8438    
8439  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8440            /* When using Carbon Events, we need to pass raw keyboard events              /* When using Carbon Events, we need to pass raw keyboard
8441               to the TSM ourselves.  If TSM handles it, it will pass back                 events to the TSM ourselves.  If TSM handles it, it
8442               noErr, otherwise it will pass back "eventNotHandledErr" and                 will pass back noErr, otherwise it will pass back
8443               we can process it normally.   */                 "eventNotHandledErr" and we can process it
8444            if ((!NILP (Vmac_pass_command_to_system)                 normally.  */
8445                 || !(er.modifiers & cmdKey))              if ((!NILP (Vmac_pass_command_to_system)
8446                && (!NILP (Vmac_pass_control_to_system)                   || !(er.modifiers & cmdKey))
8447                    || !(er.modifiers & controlKey)))                  && (!NILP (Vmac_pass_control_to_system)
8448              {                      || !(er.modifiers & controlKey)))
8449                OSStatus err;                if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8450                err = SendEventToEventTarget (eventRef,                    != eventNotHandledErr)
                                             GetEventDispatcherTarget ());  
               if (err != eventNotHandledErr)  
8451                  break;                  break;
             }  
8452  #endif  #endif
8453    
8454            if (!IsValidWindowPtr (FrontNonFloatingWindow ()))  #if TARGET_API_MAC_CARBON
8455              {              if (!IsValidWindowPtr (mac_front_window ()))
8456                SysBeep (1);                {
8457                UNBLOCK_INPUT;                  SysBeep (1);
8458                return 0;                  break;
8459              }                }
8460    #endif
           ObscureCursor ();  
   
           if (keycode_to_xkeysym (keycode, &xkeysym))  
             {  
               inev.code = 0xff00 | xkeysym;  
               inev.kind = NON_ASCII_KEYSTROKE_EVENT;  
             }  
           else  
             {  
               if (er.modifiers & (controlKey |  
                                   (NILP (Vmac_command_key_is_meta) ? optionKey  
                                    : cmdKey)))  
                 {  
                   /* This code comes from Keyboard Resource, Appendix  
                      C of IM - Text.  This is necessary since shift is  
                      ignored in KCHR table translation when option or  
                      command is pressed.  It also does not translate  
                      correctly control-shift chars like C-% so mask off  
                      shift here also */  
                   int new_modifiers = er.modifiers & 0xe600;  
                   /* mask off option and command */  
                   int new_keycode = keycode | new_modifiers;  
                   Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);  
                   unsigned long some_state = 0;  
                   inev.code = KeyTranslate (kchr_ptr, new_keycode,  
                                             &some_state) & 0xff;  
                 }  
               else  
                 inev.code = er.message & charCodeMask;  
               inev.kind = ASCII_KEYSTROKE_EVENT;  
             }  
         }  
8461    
8462          /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil,              ObscureCursor ();
            convert non-ASCII characters typed at the Mac keyboard  
            (presumed to be in the Mac Roman encoding) to iso-latin-1  
            encoding before they are passed to Emacs.  This enables the  
            Mac keyboard to be used to enter non-ASCII iso-latin-1  
            characters directly.  */  
         if (mac_keyboard_text_encoding != kTextEncodingMacRoman  
             && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)  
           {  
             static TECObjectRef converter = NULL;  
             OSStatus the_err = noErr;  
             OSStatus convert_status = noErr;  
8463    
8464              if (converter ==  NULL)              if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
8465                {                {
8466                  the_err = TECCreateConverter (&converter,                  clear_mouse_face (dpyinfo);
8467                                                kTextEncodingMacRoman,                  dpyinfo->mouse_face_hidden = 1;
                                               mac_keyboard_text_encoding);  
                 current_mac_keyboard_text_encoding  
                   = mac_keyboard_text_encoding;  
8468                }                }
8469              else if (mac_keyboard_text_encoding  
8470                       != current_mac_keyboard_text_encoding)              if (keycode_to_xkeysym (keycode, &xkeysym))
8471                {                {
8472                  /* Free the converter for the current encoding before                  inev.code = 0xff00 | xkeysym;
8473                     creating a new one.  */                  inev.kind = NON_ASCII_KEYSTROKE_EVENT;
                 TECDisposeConverter (converter);  
                 the_err = TECCreateConverter (&converter,  
                                               kTextEncodingMacRoman,  
                                               mac_keyboard_text_encoding);  
                 current_mac_keyboard_text_encoding  
                   = mac_keyboard_text_encoding;  
8474                }                }
8475                else
             if (the_err == noErr)  
8476                {                {
8477                  unsigned char ch = inev.code;                  if (er.modifiers & (controlKey |
8478                  ByteCount actual_input_length, actual_output_length;                                      (NILP (Vmac_command_key_is_meta) ? optionKey
8479                  unsigned char outch;                                       : cmdKey)))
8480                      {
8481                  convert_status = TECConvertText (converter, &ch, 1,                      /* This code comes from Keyboard Resource,
8482                                                   &actual_input_length,                         Appendix C of IM - Text.  This is necessary
8483                                                   &outch, 1,                         since shift is ignored in KCHR table
8484                                                   &actual_output_length);                         translation when option or command is pressed.
8485                  if (convert_status == noErr                         It also does not translate correctly
8486                      && actual_input_length == 1                         control-shift chars like C-% so mask off shift
8487                      && actual_output_length == 1)                         here also */
8488                    inev.code = outch;                      int new_modifiers = er.modifiers & 0xe600;
8489                        /* mask off option and command */
8490                        int new_keycode = keycode | new_modifiers;
8491                        Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8492                        unsigned long some_state = 0;
8493                        inev.code = KeyTranslate (kchr_ptr, new_keycode,
8494                                                  &some_state) & 0xff;
8495                      }
8496                    else
8497                      inev.code = er.message & charCodeMask;
8498                    inev.kind = ASCII_KEYSTROKE_EVENT;
8499                }                }
8500            }            }
8501    
8502              /* If variable mac-convert-keyboard-input-to-latin-1 is
8503                 non-nil, convert non-ASCII characters typed at the Mac
8504                 keyboard (presumed to be in the Mac Roman encoding) to
8505                 iso-latin-1 encoding before they are passed to Emacs.
8506                 This enables the Mac keyboard to be used to enter
8507                 non-ASCII iso-latin-1 characters directly.  */
8508              if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8509                  && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8510                {
8511                  static TECObjectRef converter = NULL;
8512                  OSStatus the_err = noErr;
8513                  OSStatus convert_status = noErr;
8514    
8515                  if (converter ==  NULL)
8516                    {
8517                      the_err = TECCreateConverter (&converter,
8518                                                    kTextEncodingMacRoman,
8519                                                    mac_keyboard_text_encoding);
8520                      current_mac_keyboard_text_encoding
8521                        = mac_keyboard_text_encoding;
8522                    }
8523                  else if (mac_keyboard_text_encoding
8524                           != current_mac_keyboard_text_encoding)
8525                    {
8526                      /* Free the converter for the current encoding
8527                         before creating a new one.  */
8528                      TECDisposeConverter (converter);
8529                      the_err = TECCreateConverter (&converter,
8530                                                    kTextEncodingMacRoman,
8531                                                    mac_keyboard_text_encoding);
8532                      current_mac_keyboard_text_encoding
8533                        = mac_keyboard_text_encoding;
8534                    }
8535    
8536                  if (the_err == noErr)
8537                    {
8538                      unsigned char ch = inev.code;
8539                      ByteCount actual_input_length, actual_output_length;
8540                      unsigned char outch;
8541    
8542                      convert_status = TECConvertText (converter, &ch, 1,
8543                                                       &actual_input_length,
8544                                                       &outch, 1,
8545                                                       &actual_output_length);
8546                      if (convert_status == noErr
8547                          && actual_input_length == 1
8548                          && actual_output_length == 1)
8549                        inev.code = outch;
8550                    }
8551                }
8552    
8553  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8554          inev.modifiers = mac_event_to_emacs_modifiers (eventRef);            inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8555  #else  #else
8556          inev.modifiers = mac_to_emacs_modifiers (er.modifiers);            inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8557  #endif  #endif
8558              XSETFRAME (inev.frame_or_window,
8559                         mac_window_to_frame (mac_front_window ()));
8560              inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
8561              break;
8562    
8563          {          case kHighLevelEvent:
8564            mac_output *mwp            drag_and_drop_file_list = Qnil;
             = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());  
           XSETFRAME (inev.frame_or_window, mwp->mFP);  
         }  
   
         inev.timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */  
         break;  
   
       case kHighLevelEvent:  
         drag_and_drop_file_list = Qnil;  
8565    
8566          AEProcessAppleEvent(&er);            AEProcessAppleEvent(&er);
8567    
8568          /* Build a DRAG_N_DROP_EVENT type event as is done in            /* Build a DRAG_N_DROP_EVENT type event as is done in
8569             constuct_drag_n_drop in w32term.c.  */               constuct_drag_n_drop in w32term.c.  */
8570          if (!NILP (drag_and_drop_file_list))            if (!NILP (drag_and_drop_file_list))
8571            {              {
8572              struct frame *f = NULL;                struct frame *f = NULL;
8573              WindowPtr wp;                WindowPtr wp;
8574              Lisp_Object frame;                Lisp_Object frame;
8575    
8576              wp = FrontNonFloatingWindow ();                wp = mac_front_window ();
8577    
8578              if (!wp)                if (!wp)
8579                {                  {
8580                  struct frame *f = XFRAME (XCAR (Vframe_list));                    struct frame *f = XFRAME (XCAR (Vframe_list));
8581                  CollapseWindow (FRAME_MAC_WINDOW (f), false);                    CollapseWindow (FRAME_MAC_WINDOW (f), false);
8582                  wp = FrontNonFloatingWindow ();                    wp = mac_front_window ();
8583                }                  }
8584    
8585              if (wp && is_emacs_window(wp))                if (wp && is_emacs_window (wp))
8586                  f = ((mac_output *) GetWRefCon (wp))->mFP;                  f = mac_window_to_frame (wp);
8587    
8588              inev.kind = DRAG_N_DROP_EVENT;                inev.kind = DRAG_N_DROP_EVENT;
8589              inev.code = 0;                inev.code = 0;
8590              inev.timestamp = er.when * (1000 / 60);                inev.timestamp = er.when * (1000 / 60);
8591                /* ticks to milliseconds */                /* ticks to milliseconds */
8592  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8593              inev.modifiers = mac_event_to_emacs_modifiers (eventRef);                inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8594  #else  #else
8595              inev.modifiers = mac_to_emacs_modifiers (er.modifiers);                inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8596  #endif  #endif
8597    
8598              XSETINT (inev.x, 0);                XSETINT (inev.x, 0);
8599              XSETINT (inev.y, 0);                XSETINT (inev.y, 0);
8600    
8601              XSETFRAME (frame, f);                XSETFRAME (frame, f);
8602              inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);                inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
8603    
8604              /* Regardless of whether Emacs was suspended or in the                /* Regardless of whether Emacs was suspended or in the
8605                 foreground, ask it to redraw its entire screen.                   foreground, ask it to redraw its entire screen.
8606                 Otherwise parts of the screen can be left in an                   Otherwise parts of the screen can be left in an
8607                 inconsistent state.  */                   inconsistent state.  */
8608              if (wp)                if (wp)
8609  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
8610                {                  {
8611                  Rect r;                    Rect r;
8612    
8613                  GetWindowPortBounds (wp, &r);                    GetWindowPortBounds (wp, &r);
8614                  InvalWindowRect (wp, &r);                    InvalWindowRect (wp, &r);
8615                }                  }
8616  #else /* not TARGET_API_MAC_CARBON */  #else /* not TARGET_API_MAC_CARBON */
8617                InvalRect (&(wp->portRect));                  InvalRect (&(wp->portRect));
8618  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
8619            }              }
8620        default:          default:
8621          break;            break;
8622        }          }
8623  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8624        ReleaseEvent (eventRef);        ReleaseEvent (eventRef);
     }  
8625  #endif  #endif
8626    
8627          if (inev.kind != NO_EVENT)
8628            {
8629              kbd_buffer_store_event_hold (&inev, hold_quit);
8630              count++;
8631            }
8632    
8633          if (do_help
8634              && !(hold_quit && hold_quit->kind != NO_EVENT))
8635            {
8636              Lisp_Object frame;
8637    
8638              if (f)
8639                XSETFRAME (frame, f);
8640              else
8641                frame = Qnil;
8642    
8643              if (do_help > 0)
8644                {
8645                  any_help_event_p = 1;
8646                  gen_help_event (help_echo_string, frame, help_echo_window,
8647                                  help_echo_object, help_echo_pos);
8648                }
8649              else
8650                {
8651                  help_echo_string = Qnil;
8652                  gen_help_event (Qnil, frame, Qnil, Qnil, 0);
8653                }
8654              count++;
8655            }
8656    
8657        }
8658    
8659    /* If the focus was just given to an autoraising frame,    /* If the focus was just given to an autoraising frame,
8660       raise it now.  */       raise it now.  */
8661    /* ??? This ought to be able to handle more than one such frame.  */    /* ??? This ought to be able to handle more than one such frame.  */
# Line 8620  XTread_socket (int sd, int expected, str Line 8669  XTread_socket (int sd, int expected, str
8669    check_alarm ();  /* simulate the handling of a SIGALRM */    check_alarm ();  /* simulate the handling of a SIGALRM */
8670  #endif  #endif
8671    
   {  
     static Point old_mouse_pos = { -1, -1 };  
   
     if (app_is_suspended)  
       {  
         old_mouse_pos.h = -1;  
         old_mouse_pos.v = -1;  
       }  
     else  
       {  
         Point mouse_pos;  
         WindowPtr wp;  
         struct frame *f;  
         Lisp_Object bar;  
         struct scroll_bar *sb;  
   
         wp = FrontWindow ();  
         if (is_emacs_window (wp))  
           {  
             f = ((mac_output *) GetWRefCon (wp))->mFP;  
   
 #if TARGET_API_MAC_CARBON  
             SetPort (GetWindowPort (wp));  
 #else  
             SetPort (wp);  
 #endif  
   
             GetMouse (&mouse_pos);  
   
             if (!EqualPt (mouse_pos, old_mouse_pos))  
               {  
                 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar  
                     && 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);  
   
                 old_mouse_pos = mouse_pos;  
               }  
           }  
       }  
   }  
   
   if (inev.kind != NO_EVENT)  
     {  
       kbd_buffer_store_event_hold (&inev, hold_quit);  
       count++;  
     }  
   
8672    UNBLOCK_INPUT;    UNBLOCK_INPUT;
8673    return count;    return count;
8674  }  }
# Line 8700  __convert_from_newlines (unsigned char * Line 8697  __convert_from_newlines (unsigned char *
8697     ROWS Macintosh window, using font with name FONTNAME and size     ROWS Macintosh window, using font with name FONTNAME and size
8698     FONTSIZE.  */     FONTSIZE.  */
8699  void  void
8700  NewMacWindow (FRAME_PTR fp)  make_mac_frame (FRAME_PTR fp)
8701  {  {
8702    mac_output *mwp;    mac_output *mwp;
8703  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 8719  NewMacWindow (FRAME_PTR fp) Line 8716  NewMacWindow (FRAME_PTR fp)
8716        making_terminal_window = 0;        making_terminal_window = 0;
8717      }      }
8718    else    else
8719      if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))      {
8720        abort ();  #if TARGET_API_MAC_CARBON
8721          Rect r;
8722    
8723          SetRect (&r, 0, 0, 1, 1);
8724          if (CreateNewWindow (kDocumentWindowClass,
8725                               kWindowStandardDocumentAttributes
8726                               /* | kWindowToolbarButtonAttribute */,
8727                               &r, &mwp->mWP) != noErr)
8728    #else
8729          if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
8730    #endif
8731            abort ();
8732        }
8733    
8734    SetWRefCon (mwp->mWP, (long) mwp);    SetWRefCon (mwp->mWP, (long) mwp);
8735      /* so that update events can find this mac_output struct */      /* so that update events can find this mac_output struct */
8736    mwp->mFP = fp;  /* point back to emacs frame */    mwp->mFP = fp;  /* point back to emacs frame */
8737    
8738  #if TARGET_API_MAC_CARBON    SetPortWindowPort (mwp->mWP);
   SetPort (GetWindowPort (mwp->mWP));  
 #else  
   SetPort (mwp->mWP);  
 #endif  
   
   mwp->fontset = -1;  
8739    
8740    SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);    SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);
   ShowWindow (mwp->mWP);  
   
8741  }  }
8742    
8743    
8744  void  void
8745  make_mac_frame (struct frame *f)  make_mac_terminal_frame (struct frame *f)
8746  {  {
8747    FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;    Lisp_Object frame;
8748    
8749      XSETFRAME (frame, f);
8750    
8751      f->output_method = output_mac;
8752      f->output_data.mac = (struct mac_output *)
8753        xmalloc (sizeof (struct mac_output));
8754      bzero (f->output_data.mac, sizeof (struct mac_output));
8755    
8756      XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
8757    
8758      FRAME_COLS (f) = 96;
8759      FRAME_LINES (f) = 4;
8760    
8761      FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8762      FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8763    
8764    NewMacWindow(f);    FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
8765    
8766    f->output_data.mac->cursor_pixel = 0;    f->output_data.mac->cursor_pixel = 0;
8767    f->output_data.mac->border_pixel = 0x00ff00;    f->output_data.mac->border_pixel = 0x00ff00;
# Line 8753  make_mac_frame (struct frame *f) Line 8769  make_mac_frame (struct frame *f)
8769    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
8770    
8771    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;  
8772    f->output_data.mac->explicit_parent = 0;    f->output_data.mac->explicit_parent = 0;
8773    f->left_pos = 4;    f->left_pos = 4;
8774    f->top_pos = 4;    f->top_pos = 4;
# Line 8762  make_mac_frame (struct frame *f) Line 8776  make_mac_frame (struct frame *f)
8776    
8777    f->internal_border_width = 0;    f->internal_border_width = 0;
8778    
   f->output_method = output_mac;  
   
8779    f->auto_raise = 1;    f->auto_raise = 1;
8780    f->auto_lower = 1;    f->auto_lower = 1;
8781    
8782    f->new_text_cols = 0;    f->new_text_cols = 0;
8783    f->new_text_lines = 0;    f->new_text_lines = 0;
 }  
   
 void  
 make_mac_terminal_frame (struct frame *f)  
 {  
   Lisp_Object frame;  
   
   XSETFRAME (frame, f);  
   
   f->output_method = output_mac;  
   f->output_data.mac = (struct mac_output *)  
     xmalloc (sizeof (struct mac_output));  
   bzero (f->output_data.mac, sizeof (struct mac_output));  
   FRAME_FONTSET (f) = -1;  
   f->output_data.mac->scroll_bar_foreground_pixel = -1;  
   f->output_data.mac->scroll_bar_background_pixel = -1;  
   
   XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);  
   
   FRAME_COLS (f) = 96;  
   FRAME_LINES (f) = 4;  
   
   FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;  
   FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;  
8784    
8785    make_mac_frame (f);    make_mac_frame (f);
8786    
# Line 8810  make_mac_terminal_frame (struct frame *f Line 8798  make_mac_terminal_frame (struct frame *f
8798    Fmodify_frame_parameters (frame,    Fmodify_frame_parameters (frame,
8799                              Fcons (Fcons (Qbackground_color,                              Fcons (Fcons (Qbackground_color,
8800                                            build_string ("white")), Qnil));                                            build_string ("white")), Qnil));
8801    
8802      ShowWindow (f->output_data.mac->mWP);
8803  }  }
8804    
8805    
# Line 8864  mac_initialize_display_info () Line 8854  mac_initialize_display_info ()
8854    dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;    dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
8855    dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;    dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
8856    dpyinfo->mouse_face_window = Qnil;    dpyinfo->mouse_face_window = Qnil;
8857      dpyinfo->mouse_face_overlay = Qnil;
8858      dpyinfo->mouse_face_hidden = 0;
8859  }  }
8860    
8861  struct mac_display_info *  struct mac_display_info *
# Line 9020  mac_check_for_quit_char () Line 9012  mac_check_for_quit_char ()
9012    if (event)    if (event)
9013      {      {
9014        struct input_event e;        struct input_event e;
9015        struct mac_output *mwp =  
         (mac_output *) GetWRefCon (FrontNonFloatingWindow ());  
9016        /* Use an input_event to emulate what the interrupt handler does. */        /* Use an input_event to emulate what the interrupt handler does. */
9017        EVENT_INIT (e);        EVENT_INIT (e);
9018        e.kind = ASCII_KEYSTROKE_EVENT;        e.kind = ASCII_KEYSTROKE_EVENT;
# Line 9029  mac_check_for_quit_char () Line 9020  mac_check_for_quit_char ()
9020        e.arg = Qnil;        e.arg = Qnil;
9021        e.modifiers = NULL;        e.modifiers = NULL;
9022        e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);        e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
9023        XSETFRAME (e.frame_or_window, mwp->mFP);        XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ()));
9024        /* Remove event from queue to prevent looping. */        /* Remove event from queue to prevent looping. */
9025        RemoveEventFromQueue (GetMainEventQueue (), event);        RemoveEventFromQueue (GetMainEventQueue (), event);
9026        ReleaseEvent (event);        ReleaseEvent (event);

Legend:
Removed from v.1.3.2.13  
changed lines
  Added in v.1.3.2.14

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