# HG changeset patch # User YAMAMOTO Mitsuharu # Date 1110943753 0 # Node ID 5a3fa411c7138d412fbd68b01e790b7f0e537ad0 # Parent 005d5b72126b7d551efb73e36d09e2c0ae8f92a9 (activate_scroll_bars, deactivate_scroll_bars): Remove functions and declarations. (mac_set_colors): Take argument for saving background color. All callers changed. (XDrawLine, XClearArea, mac_draw_bitmap, XFillRectangle) (mac_draw_rectangle, mac_draw_string_common): Save and Restore background color. (x_update_end, mac_do_track_drag): Don't reset background color. (mac_define_frame_cursor) [!TARGET_API_MAC_CARBON]: Use SetThemeCursor. (x_set_window_size) [TARGET_API_MAC_CARBON]: Move progress indicator control to the upper-right corner of the window. (arrow_cursor) [!TARGET_API_MAC_CARBON]: Remove variable. (do_init_managers) [!TARGET_API_MAC_CARBON]: Don't initialize it. (do_window_update): Update controls after updating content area. (mac_handle_window_event): Remove unused extern. (XTread_socket): Check both control handle and control part code to determine whether a scroll bar is clicked. Activate/deactivate root control instead of contained scroll bar controls. (make_mac_terminal_frame): Use ThemeCursor constants. diff -r 005d5b72126b -r 5a3fa411c713 src/macterm.c --- a/src/macterm.c Wed Mar 16 03:27:38 2005 +0000 +++ b/src/macterm.c Wed Mar 16 03:29:13 2005 +0000 @@ -290,9 +290,6 @@ static void x_update_window_begin P_ ((struct window *)); static void x_after_update_window_line P_ ((struct glyph_row *)); -void activate_scroll_bars (FRAME_PTR); -void deactivate_scroll_bars (FRAME_PTR); - static int is_emacs_window (WindowPtr); int x_bitmap_icon (struct frame *, Lisp_Object); @@ -350,8 +347,12 @@ commands. Assume that the graphic port has already been set. */ static void -mac_set_colors (GC gc) -{ +mac_set_colors (gc, bg_save) + GC gc; + RGBColor *bg_save; +{ + if (bg_save) + GetBackColor (bg_save); mac_set_forecolor (gc->foreground); mac_set_backcolor (gc->background); } @@ -365,12 +366,16 @@ GC gc; int x1, y1, x2, y2; { + RGBColor old_bg; + SetPortWindowPort (w); - mac_set_colors (gc); + mac_set_colors (gc, &old_bg); MoveTo (x1, y1); LineTo (x2, y2); + + RGBBackColor (&old_bg); } void @@ -386,7 +391,7 @@ GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); - mac_set_colors (gc); + mac_set_colors (gc, NULL); LockPixels (GetGWorldPixMap (p)); MoveTo (x1, y1); @@ -409,16 +414,19 @@ struct mac_output *mwp = (mac_output *) GetWRefCon (w); Rect r; XGCValues xgc; + RGBColor old_bg; xgc.foreground = mwp->x_compatible.foreground_pixel; xgc.background = mwp->x_compatible.background_pixel; SetPortWindowPort (w); - mac_set_colors (&xgc); + mac_set_colors (&xgc, &old_bg); SetRect (&r, x, y, x + width, y + height); EraseRect (&r); + + RGBBackColor (&old_bg); } /* Mac version of XClearWindow. */ @@ -436,7 +444,7 @@ SetPortWindowPort (w); - mac_set_colors (&xgc); + mac_set_colors (&xgc, NULL); #if TARGET_API_MAC_CARBON { @@ -464,6 +472,7 @@ { BitMap bitmap; Rect r; + RGBColor old_bg; bitmap.rowBytes = sizeof(unsigned short); bitmap.baseAddr = (char *)bits; @@ -471,7 +480,7 @@ SetPortWindowPort (w); - mac_set_colors (gc); + mac_set_colors (gc, &old_bg); SetRect (&r, x, y, x + width, y + height); #if TARGET_API_MAC_CARBON @@ -483,6 +492,8 @@ CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0); #endif /* not TARGET_API_MAC_CARBON */ + + RGBBackColor (&old_bg); } @@ -631,13 +642,16 @@ unsigned int width, height; { Rect r; + RGBColor old_bg; SetPortWindowPort (w); - mac_set_colors (gc); + mac_set_colors (gc, &old_bg); SetRect (&r, x, y, x + width, y + height); PaintRect (&r); /* using foreground color of gc */ + + RGBBackColor (&old_bg); } @@ -656,7 +670,7 @@ GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); - mac_set_colors (gc); + mac_set_colors (gc, NULL); SetRect (&r, x, y, x + width, y + height); LockPixels (GetGWorldPixMap (p)); @@ -679,13 +693,16 @@ unsigned int width, height; { Rect r; + RGBColor old_bg; SetPortWindowPort (w); - mac_set_colors (gc); + mac_set_colors (gc, &old_bg); SetRect (&r, x, y, x + width + 1, y + height + 1); FrameRect (&r); /* using foreground color of gc */ + + RGBBackColor (&old_bg); } @@ -706,7 +723,7 @@ GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); - mac_set_colors (gc); + mac_set_colors (gc, NULL); SetRect (&r, x, y, x + width + 1, y + height + 1); LockPixels (GetGWorldPixMap (p)); @@ -728,6 +745,8 @@ char *buf; int nchars, mode, bytes_per_char; { + RGBColor old_bg; + SetPortWindowPort (w); #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 UInt32 textFlags, savedFlags; @@ -737,7 +756,7 @@ } #endif - mac_set_colors (gc); + mac_set_colors (gc, &old_bg); TextFont (gc->font->mac_fontnum); TextSize (gc->font->mac_fontsize); @@ -746,6 +765,8 @@ MoveTo (x, y); DrawText (buf, 0, nchars * bytes_per_char); + + RGBBackColor (&old_bg); #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 if (!NILP(Vmac_use_core_graphics)) SwapQDTextFlags(savedFlags); @@ -933,7 +954,7 @@ SetPort (w); #if 0 - mac_set_colors (gc); + mac_set_colors (gc, NULL); #endif SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); @@ -955,7 +976,7 @@ BackColor (whiteColor); CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); - mac_set_colors (gc); + mac_set_colors (gc, NULL); #endif #endif /* not TARGET_API_MAC_CARBON */ } @@ -1395,13 +1416,6 @@ FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0; 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)); - #if TARGET_API_MAC_CARBON EnableScreenUpdates (); #endif @@ -4471,50 +4485,6 @@ } -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; - } -} - /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind is set to something other than NO_EVENT, it is enqueued. @@ -4845,11 +4815,7 @@ struct frame *f; Cursor cursor; { -#if TARGET_API_MAC_CARBON SetThemeCursor (cursor); -#else - SetCursor (*cursor); -#endif } @@ -5274,6 +5240,11 @@ x_wm_set_size_hint (f, (long) 0, 0); SizeWindow (FRAME_MAC_WINDOW (f), pixelwidth, pixelheight, 0); +#if TARGET_API_MAC_CARBON + if (f->output_data.mac->hourglass_control) + MoveControl (f->output_data.mac->hourglass_control, + pixelwidth - HOURGLASS_WIDTH, 0); +#endif /* Now, strictly speaking, we can't be sure that this is accurate, but the window manager will get around to dealing with the size @@ -7185,11 +7156,6 @@ Point saved_menu_event_location; -#if !TARGET_API_MAC_CARBON -/* Place holder for the default arrow cursor. */ -CursPtr arrow_cursor; -#endif - /* Apple Events */ static void init_required_apple_events (void); static pascal OSErr @@ -7392,8 +7358,6 @@ InitCursor (); #if !TARGET_API_MAC_CARBON - arrow_cursor = &qd.arrow; - /* set up some extra stack space for use by emacs */ SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); @@ -7454,15 +7418,16 @@ RgnHandle region = NewRgn (); GetPortVisibleRegion (GetWindowPort (win), region); + GetRegionBounds (region, &r); + expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); UpdateControls (win, region); - GetRegionBounds (region, &r); DisposeRgn (region); } #else + r = (*win->visRgn)->rgnBBox; + expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); UpdateControls (win, win->visRgn); - r = (*win->visRgn)->rgnBBox; -#endif - expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); +#endif handling_window_update = 0; } @@ -7955,8 +7920,6 @@ EventRef event; void *data; { - extern Lisp_Object Qcontrol; - WindowPtr wp; OSStatus result; UInt32 attributes; @@ -8226,7 +8189,6 @@ Rect r; struct frame *f = mac_window_to_frame (window); - mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); GetWindowPortBounds (window, &r); OffsetRect (&r, -r.left, -r.top); RectRgn (hilite_rgn, &r); @@ -8244,7 +8206,6 @@ { struct frame *f = mac_window_to_frame (window); - mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); HideDragHilite (theDrag); SetThemeCursor (kThemeArrowCursor); } @@ -8736,12 +8697,9 @@ /* ticks to milliseconds */ if (dpyinfo->grabbed && tracked_scroll_bar -#if TARGET_API_MAC_CARBON - || ch != 0 -#else - || control_part_code != 0 -#endif - ) + /* control_part_code becomes kControlNoPart if + a progress indicator is clicked. */ + || ch != 0 && control_part_code != kControlNoPart) { struct scroll_bar *bar; @@ -8910,6 +8868,7 @@ case activateEvt: { WindowPtr window_ptr = (WindowPtr) er.message; + ControlRef root_control; #if USE_CARBON_EVENTS if (SendEventToEventTarget (eventRef, toolbox_dispatcher) @@ -8926,6 +8885,7 @@ break; f = mac_window_to_frame (window_ptr); + GetRootControl (window_ptr, &root_control); if ((er.modifiers & activeFlag) != 0) { @@ -8933,7 +8893,7 @@ Point mouse_loc = er.where; x_new_focus_frame (dpyinfo, f); - activate_scroll_bars (f); + ActivateControl (root_control); SetPortWindowPort (window_ptr); GlobalToLocal (&mouse_loc); @@ -8950,7 +8910,7 @@ if (f == dpyinfo->x_focus_frame) { x_new_focus_frame (dpyinfo, 0); - deactivate_scroll_bars (f); + DeactivateControl (root_control); } @@ -9288,21 +9248,12 @@ f->output_data.mac->mouse_pixel = 0xff00ff; f->output_data.mac->cursor_foreground_pixel = 0x0000ff; -#if TARGET_API_MAC_CARBON f->output_data.mac->text_cursor = kThemeIBeamCursor; f->output_data.mac->nontext_cursor = kThemeArrowCursor; f->output_data.mac->modeline_cursor = kThemeArrowCursor; f->output_data.mac->hand_cursor = kThemePointingHandCursor; f->output_data.mac->hourglass_cursor = kThemeWatchCursor; 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 FRAME_FONTSET (f) = -1; f->output_data.mac->explicit_parent = 0;