/[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.104 by mituharu, Tue Mar 15 07:47:25 2005 UTC revision 1.105 by mituharu, Wed Mar 16 03:29:13 2005 UTC
# Line 290  static void x_update_begin P_ ((struct f Line 290  static void x_update_begin P_ ((struct f
290  static void x_update_window_begin P_ ((struct window *));  static void x_update_window_begin P_ ((struct window *));
291  static void x_after_update_window_line P_ ((struct glyph_row *));  static void x_after_update_window_line P_ ((struct glyph_row *));
292    
 void activate_scroll_bars (FRAME_PTR);  
 void deactivate_scroll_bars (FRAME_PTR);  
   
293  static int is_emacs_window (WindowPtr);  static int is_emacs_window (WindowPtr);
294    
295  int x_bitmap_icon (struct frame *, Lisp_Object);  int x_bitmap_icon (struct frame *, Lisp_Object);
# Line 350  mac_set_backcolor (unsigned long color) Line 347  mac_set_backcolor (unsigned long color)
347     commands.  Assume that the graphic port has already been set.  */     commands.  Assume that the graphic port has already been set.  */
348    
349  static void  static void
350  mac_set_colors (GC gc)  mac_set_colors (gc, bg_save)
351         GC gc;
352         RGBColor *bg_save;
353  {  {
354      if (bg_save)
355        GetBackColor (bg_save);
356    mac_set_forecolor (gc->foreground);    mac_set_forecolor (gc->foreground);
357    mac_set_backcolor (gc->background);    mac_set_backcolor (gc->background);
358  }  }
# Line 365  XDrawLine (display, w, gc, x1, y1, x2, y Line 366  XDrawLine (display, w, gc, x1, y1, x2, y
366       GC gc;       GC gc;
367       int x1, y1, x2, y2;       int x1, y1, x2, y2;
368  {  {
369      RGBColor old_bg;
370    
371    SetPortWindowPort (w);    SetPortWindowPort (w);
372    
373    mac_set_colors (gc);    mac_set_colors (gc, &old_bg);
374    
375    MoveTo (x1, y1);    MoveTo (x1, y1);
376    LineTo (x2, y2);    LineTo (x2, y2);
377    
378      RGBBackColor (&old_bg);
379  }  }
380    
381  void  void
# Line 386  mac_draw_line_to_pixmap (display, p, gc, Line 391  mac_draw_line_to_pixmap (display, p, gc,
391    GetGWorld (&old_port, &old_gdh);    GetGWorld (&old_port, &old_gdh);
392    SetGWorld (p, NULL);    SetGWorld (p, NULL);
393    
394    mac_set_colors (gc);    mac_set_colors (gc, NULL);
395    
396    LockPixels (GetGWorldPixMap (p));    LockPixels (GetGWorldPixMap (p));
397    MoveTo (x1, y1);    MoveTo (x1, y1);
# Line 409  XClearArea (display, w, x, y, width, hei Line 414  XClearArea (display, w, x, y, width, hei
414    struct mac_output *mwp = (mac_output *) GetWRefCon (w);    struct mac_output *mwp = (mac_output *) GetWRefCon (w);
415    Rect r;    Rect r;
416    XGCValues xgc;    XGCValues xgc;
417      RGBColor old_bg;
418    
419    xgc.foreground = mwp->x_compatible.foreground_pixel;    xgc.foreground = mwp->x_compatible.foreground_pixel;
420    xgc.background = mwp->x_compatible.background_pixel;    xgc.background = mwp->x_compatible.background_pixel;
421    
422    SetPortWindowPort (w);    SetPortWindowPort (w);
423    
424    mac_set_colors (&xgc);    mac_set_colors (&xgc, &old_bg);
425    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
426    
427    EraseRect (&r);    EraseRect (&r);
428    
429      RGBBackColor (&old_bg);
430  }  }
431    
432  /* Mac version of XClearWindow.  */  /* Mac version of XClearWindow.  */
# Line 436  XClearWindow (display, w) Line 444  XClearWindow (display, w)
444    
445    SetPortWindowPort (w);    SetPortWindowPort (w);
446    
447    mac_set_colors (&xgc);    mac_set_colors (&xgc, NULL);
448    
449  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
450    {    {
# Line 464  mac_draw_bitmap (display, w, gc, x, y, w Line 472  mac_draw_bitmap (display, w, gc, x, y, w
472  {  {
473    BitMap bitmap;    BitMap bitmap;
474    Rect r;    Rect r;
475      RGBColor old_bg;
476    
477    bitmap.rowBytes = sizeof(unsigned short);    bitmap.rowBytes = sizeof(unsigned short);
478    bitmap.baseAddr = (char *)bits;    bitmap.baseAddr = (char *)bits;
# Line 471  mac_draw_bitmap (display, w, gc, x, y, w Line 480  mac_draw_bitmap (display, w, gc, x, y, w
480    
481    SetPortWindowPort (w);    SetPortWindowPort (w);
482    
483    mac_set_colors (gc);    mac_set_colors (gc, &old_bg);
484    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
485    
486  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 483  mac_draw_bitmap (display, w, gc, x, y, w Line 492  mac_draw_bitmap (display, w, gc, x, y, w
492    CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,    CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
493              overlay_p ? srcOr : srcCopy, 0);              overlay_p ? srcOr : srcCopy, 0);
494  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
495    
496      RGBBackColor (&old_bg);
497  }  }
498    
499    
# Line 631  XFillRectangle (display, w, gc, x, y, wi Line 642  XFillRectangle (display, w, gc, x, y, wi
642       unsigned int width, height;       unsigned int width, height;
643  {  {
644    Rect r;    Rect r;
645      RGBColor old_bg;
646    
647    SetPortWindowPort (w);    SetPortWindowPort (w);
648    
649    mac_set_colors (gc);    mac_set_colors (gc, &old_bg);
650    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
651    
652    PaintRect (&r); /* using foreground color of gc */    PaintRect (&r); /* using foreground color of gc */
653    
654      RGBBackColor (&old_bg);
655  }  }
656    
657    
# Line 656  mac_fill_rectangle_to_pixmap (display, p Line 670  mac_fill_rectangle_to_pixmap (display, p
670    
671    GetGWorld (&old_port, &old_gdh);    GetGWorld (&old_port, &old_gdh);
672    SetGWorld (p, NULL);    SetGWorld (p, NULL);
673    mac_set_colors (gc);    mac_set_colors (gc, NULL);
674    SetRect (&r, x, y, x + width, y + height);    SetRect (&r, x, y, x + width, y + height);
675    
676    LockPixels (GetGWorldPixMap (p));    LockPixels (GetGWorldPixMap (p));
# Line 679  mac_draw_rectangle (display, w, gc, x, y Line 693  mac_draw_rectangle (display, w, gc, x, y
693       unsigned int width, height;       unsigned int width, height;
694  {  {
695    Rect r;    Rect r;
696      RGBColor old_bg;
697    
698    SetPortWindowPort (w);    SetPortWindowPort (w);
699    
700    mac_set_colors (gc);    mac_set_colors (gc, &old_bg);
701    SetRect (&r, x, y, x + width + 1, y + height + 1);    SetRect (&r, x, y, x + width + 1, y + height + 1);
702    
703    FrameRect (&r); /* using foreground color of gc */    FrameRect (&r); /* using foreground color of gc */
704    
705      RGBBackColor (&old_bg);
706  }  }
707    
708    
# Line 706  mac_draw_rectangle_to_pixmap (display, p Line 723  mac_draw_rectangle_to_pixmap (display, p
723    
724    GetGWorld (&old_port, &old_gdh);    GetGWorld (&old_port, &old_gdh);
725    SetGWorld (p, NULL);    SetGWorld (p, NULL);
726    mac_set_colors (gc);    mac_set_colors (gc, NULL);
727    SetRect (&r, x, y, x + width + 1, y + height + 1);    SetRect (&r, x, y, x + width + 1, y + height + 1);
728    
729    LockPixels (GetGWorldPixMap (p));    LockPixels (GetGWorldPixMap (p));
# Line 728  mac_draw_string_common (display, w, gc, Line 745  mac_draw_string_common (display, w, gc,
745       char *buf;       char *buf;
746       int nchars, mode, bytes_per_char;       int nchars, mode, bytes_per_char;
747  {  {
748      RGBColor old_bg;
749    
750    SetPortWindowPort (w);    SetPortWindowPort (w);
751  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
752    UInt32 textFlags, savedFlags;    UInt32 textFlags, savedFlags;
# Line 737  mac_draw_string_common (display, w, gc, Line 756  mac_draw_string_common (display, w, gc,
756    }    }
757  #endif  #endif
758    
759    mac_set_colors (gc);    mac_set_colors (gc, &old_bg);
760    
761    TextFont (gc->font->mac_fontnum);    TextFont (gc->font->mac_fontnum);
762    TextSize (gc->font->mac_fontsize);    TextSize (gc->font->mac_fontsize);
# Line 746  mac_draw_string_common (display, w, gc, Line 765  mac_draw_string_common (display, w, gc,
765    
766    MoveTo (x, y);    MoveTo (x, y);
767    DrawText (buf, 0, nchars * bytes_per_char);    DrawText (buf, 0, nchars * bytes_per_char);
768    
769      RGBBackColor (&old_bg);
770  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020  #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
771    if (!NILP(Vmac_use_core_graphics))    if (!NILP(Vmac_use_core_graphics))
772      SwapQDTextFlags(savedFlags);      SwapQDTextFlags(savedFlags);
# Line 933  mac_scroll_area (display, w, gc, src_x, Line 954  mac_scroll_area (display, w, gc, src_x,
954    
955    SetPort (w);    SetPort (w);
956  #if 0  #if 0
957    mac_set_colors (gc);    mac_set_colors (gc, NULL);
958  #endif  #endif
959    
960    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);
# Line 955  mac_scroll_area (display, w, gc, src_x, Line 976  mac_scroll_area (display, w, gc, src_x,
976    BackColor (whiteColor);    BackColor (whiteColor);
977    CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);    CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
978    
979    mac_set_colors (gc);    mac_set_colors (gc, NULL);
980  #endif  #endif
981  #endif /* not TARGET_API_MAC_CARBON */  #endif /* not TARGET_API_MAC_CARBON */
982  }  }
# Line 1395  x_update_end (f) Line 1416  x_update_end (f)
1416    FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;    FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1417    
1418    BLOCK_INPUT;    BLOCK_INPUT;
   /* Reset the background color of Mac OS Window to that of the frame after  
      update so that it is used by Mac Toolbox to clear the update region before  
      an update event is generated.  */  
   SetPortWindowPort (FRAME_MAC_WINDOW (f));  
   
   mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));  
   
1419  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
1420    EnableScreenUpdates ();    EnableScreenUpdates ();
1421  #endif  #endif
# Line 4471  XTjudge_scroll_bars (f) Line 4485  XTjudge_scroll_bars (f)
4485  }  }
4486    
4487    
 void  
 activate_scroll_bars (frame)  
      FRAME_PTR frame;  
 {  
   Lisp_Object bar;  
   ControlHandle ch;  
   
   bar = FRAME_SCROLL_BARS (frame);  
   while (! NILP (bar))  
     {  
       ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));  
 #if 1 /* TARGET_API_MAC_CARBON */  
       ActivateControl (ch);  
 #else  
       SetControlMaximum (ch,  
                          VERTICAL_SCROLL_BAR_TOP_RANGE (frame,  
                                                         XINT (XSCROLL_BAR (bar)  
                                                               ->height)) - 1);  
 #endif  
       bar = XSCROLL_BAR (bar)->next;  
     }  
 }  
   
   
 void  
 deactivate_scroll_bars (frame)  
      FRAME_PTR frame;  
 {  
   Lisp_Object bar;  
   ControlHandle ch;  
   
   bar = FRAME_SCROLL_BARS (frame);  
   while (! NILP (bar))  
     {  
       ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));  
 #if 1 /* TARGET_API_MAC_CARBON */  
       DeactivateControl (ch);  
 #else  
       SetControlMaximum (ch, -1);  
 #endif  
       bar = XSCROLL_BAR (bar)->next;  
     }  
 }  
   
4488  /* Handle a mouse click on the scroll bar BAR.  If *EMACS_EVENT's kind  /* Handle a mouse click on the scroll bar BAR.  If *EMACS_EVENT's kind
4489     is set to something other than NO_EVENT, it is enqueued.     is set to something other than NO_EVENT, it is enqueued.
4490    
# Line 4845  mac_define_frame_cursor (f, cursor) Line 4815  mac_define_frame_cursor (f, cursor)
4815       struct frame *f;       struct frame *f;
4816       Cursor cursor;       Cursor cursor;
4817  {  {
 #if TARGET_API_MAC_CARBON  
4818    SetThemeCursor (cursor);    SetThemeCursor (cursor);
 #else  
   SetCursor (*cursor);  
 #endif  
4819  }  }
4820    
4821    
# Line 5274  x_set_window_size (f, change_gravity, co Line 5240  x_set_window_size (f, change_gravity, co
5240    x_wm_set_size_hint (f, (long) 0, 0);    x_wm_set_size_hint (f, (long) 0, 0);
5241    
5242    SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);    SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0);
5243    #if TARGET_API_MAC_CARBON
5244      if (f->output_data.mac->hourglass_control)
5245        MoveControl (f->output_data.mac->hourglass_control,
5246                     pixelwidth - HOURGLASS_WIDTH, 0);
5247    #endif
5248    
5249    /* Now, strictly speaking, we can't be sure that this is accurate,    /* Now, strictly speaking, we can't be sure that this is accurate,
5250       but the window manager will get around to dealing with the size       but the window manager will get around to dealing with the size
# Line 7185  Lisp_Object drag_and_drop_file_list; Line 7156  Lisp_Object drag_and_drop_file_list;
7156    
7157  Point saved_menu_event_location;  Point saved_menu_event_location;
7158    
 #if !TARGET_API_MAC_CARBON  
 /* Place holder for the default arrow cursor.  */  
 CursPtr arrow_cursor;  
 #endif  
   
7159  /* Apple Events */  /* Apple Events */
7160  static void init_required_apple_events (void);  static void init_required_apple_events (void);
7161  static pascal OSErr  static pascal OSErr
# Line 7392  do_init_managers (void) Line 7358  do_init_managers (void)
7358    InitCursor ();    InitCursor ();
7359    
7360  #if !TARGET_API_MAC_CARBON  #if !TARGET_API_MAC_CARBON
   arrow_cursor = &qd.arrow;  
   
7361    /* set up some extra stack space for use by emacs */    /* set up some extra stack space for use by emacs */
7362    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));    SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
7363    
# Line 7454  do_window_update (WindowPtr win) Line 7418  do_window_update (WindowPtr win)
7418              RgnHandle region = NewRgn ();              RgnHandle region = NewRgn ();
7419    
7420              GetPortVisibleRegion (GetWindowPort (win), region);              GetPortVisibleRegion (GetWindowPort (win), region);
             UpdateControls (win, region);  
7421              GetRegionBounds (region, &r);              GetRegionBounds (region, &r);
7422                expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7423                UpdateControls (win, region);
7424              DisposeRgn (region);              DisposeRgn (region);
7425            }            }
7426  #else  #else
           UpdateControls (win, win->visRgn);  
7427            r = (*win->visRgn)->rgnBBox;            r = (*win->visRgn)->rgnBBox;
 #endif  
7428            expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);            expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7429              UpdateControls (win, win->visRgn);
7430    #endif
7431    
7432            handling_window_update = 0;            handling_window_update = 0;
7433          }          }
# Line 7955  mac_handle_window_event (next_handler, e Line 7920  mac_handle_window_event (next_handler, e
7920       EventRef event;       EventRef event;
7921       void *data;       void *data;
7922  {  {
   extern Lisp_Object Qcontrol;  
   
7923    WindowPtr wp;    WindowPtr wp;
7924    OSStatus result;    OSStatus result;
7925    UInt32 attributes;    UInt32 attributes;
# Line 8226  mac_do_track_drag (DragTrackingMessage m Line 8189  mac_do_track_drag (DragTrackingMessage m
8189            Rect r;            Rect r;
8190            struct frame *f = mac_window_to_frame (window);            struct frame *f = mac_window_to_frame (window);
8191    
           mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));  
8192            GetWindowPortBounds (window, &r);            GetWindowPortBounds (window, &r);
8193            OffsetRect (&r, -r.left, -r.top);            OffsetRect (&r, -r.left, -r.top);
8194            RectRgn (hilite_rgn, &r);            RectRgn (hilite_rgn, &r);
# Line 8244  mac_do_track_drag (DragTrackingMessage m Line 8206  mac_do_track_drag (DragTrackingMessage m
8206          {          {
8207            struct frame *f = mac_window_to_frame (window);            struct frame *f = mac_window_to_frame (window);
8208    
           mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));  
8209            HideDragHilite (theDrag);            HideDragHilite (theDrag);
8210            SetThemeCursor (kThemeArrowCursor);            SetThemeCursor (kThemeArrowCursor);
8211          }          }
# Line 8736  XTread_socket (sd, expected, hold_quit) Line 8697  XTread_socket (sd, expected, hold_quit)
8697                      /* ticks to milliseconds */                      /* ticks to milliseconds */
8698    
8699                      if (dpyinfo->grabbed && tracked_scroll_bar                      if (dpyinfo->grabbed && tracked_scroll_bar
8700  #if TARGET_API_MAC_CARBON                          /* control_part_code becomes kControlNoPart if
8701                          || ch != 0                             a progress indicator is clicked.  */
8702  #else                          || ch != 0 && control_part_code != kControlNoPart)
                         || control_part_code != 0  
 #endif  
                         )  
8703                        {                        {
8704                          struct scroll_bar *bar;                          struct scroll_bar *bar;
8705    
# Line 8910  XTread_socket (sd, expected, hold_quit) Line 8868  XTread_socket (sd, expected, hold_quit)
8868          case activateEvt:          case activateEvt:
8869            {            {
8870              WindowPtr window_ptr = (WindowPtr) er.message;              WindowPtr window_ptr = (WindowPtr) er.message;
8871                ControlRef root_control;
8872    
8873  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8874              if (SendEventToEventTarget (eventRef, toolbox_dispatcher)              if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
# Line 8926  XTread_socket (sd, expected, hold_quit) Line 8885  XTread_socket (sd, expected, hold_quit)
8885                break;                break;
8886    
8887              f = mac_window_to_frame (window_ptr);              f = mac_window_to_frame (window_ptr);
8888                GetRootControl (window_ptr, &root_control);
8889    
8890              if ((er.modifiers & activeFlag) != 0)              if ((er.modifiers & activeFlag) != 0)
8891                {                {
# Line 8933  XTread_socket (sd, expected, hold_quit) Line 8893  XTread_socket (sd, expected, hold_quit)
8893                  Point mouse_loc = er.where;                  Point mouse_loc = er.where;
8894    
8895                  x_new_focus_frame (dpyinfo, f);                  x_new_focus_frame (dpyinfo, f);
8896                  activate_scroll_bars (f);                  ActivateControl (root_control);
8897    
8898                  SetPortWindowPort (window_ptr);                  SetPortWindowPort (window_ptr);
8899                  GlobalToLocal (&mouse_loc);                  GlobalToLocal (&mouse_loc);
# Line 8950  XTread_socket (sd, expected, hold_quit) Line 8910  XTread_socket (sd, expected, hold_quit)
8910                  if (f == dpyinfo->x_focus_frame)                  if (f == dpyinfo->x_focus_frame)
8911                    {                    {
8912                      x_new_focus_frame (dpyinfo, 0);                      x_new_focus_frame (dpyinfo, 0);
8913                      deactivate_scroll_bars (f);                      DeactivateControl (root_control);
8914                    }                    }
8915    
8916    
# Line 9288  make_mac_terminal_frame (struct frame *f Line 9248  make_mac_terminal_frame (struct frame *f
9248    f->output_data.mac->mouse_pixel = 0xff00ff;    f->output_data.mac->mouse_pixel = 0xff00ff;
9249    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
9250    
 #if TARGET_API_MAC_CARBON  
9251    f->output_data.mac->text_cursor = kThemeIBeamCursor;    f->output_data.mac->text_cursor = kThemeIBeamCursor;
9252    f->output_data.mac->nontext_cursor = kThemeArrowCursor;    f->output_data.mac->nontext_cursor = kThemeArrowCursor;
9253    f->output_data.mac->modeline_cursor = kThemeArrowCursor;    f->output_data.mac->modeline_cursor = kThemeArrowCursor;
9254    f->output_data.mac->hand_cursor = kThemePointingHandCursor;    f->output_data.mac->hand_cursor = kThemePointingHandCursor;
9255    f->output_data.mac->hourglass_cursor = kThemeWatchCursor;    f->output_data.mac->hourglass_cursor = kThemeWatchCursor;
9256    f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;    f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor;
 #else  
   f->output_data.mac->text_cursor = GetCursor (iBeamCursor);  
   f->output_data.mac->nontext_cursor = &arrow_cursor;  
   f->output_data.mac->modeline_cursor = &arrow_cursor;  
   f->output_data.mac->hand_cursor = &arrow_cursor;  
   f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);  
   f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;  
 #endif  
9257    
9258    FRAME_FONTSET (f) = -1;    FRAME_FONTSET (f) = -1;
9259    f->output_data.mac->explicit_parent = 0;    f->output_data.mac->explicit_parent = 0;

Legend:
Removed from v.1.104  
changed lines
  Added in v.1.105

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