From: YAMAMOTO Mitsuharu Date: Wed, 16 Mar 2005 03:29:13 +0000 (+0000) Subject: (activate_scroll_bars, deactivate_scroll_bars): Remove functions and X-Git-Tag: ttn-vms-21-2-B4~1790 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b69efa2333a8096506c84add62caf1d2084a20a5;p=emacs.git (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 --git a/src/macterm.c b/src/macterm.c index 0700779bded..9af39dcb1fd 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -290,9 +290,6 @@ static void x_update_begin P_ ((struct frame *)); 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 @@ mac_set_backcolor (unsigned long color) 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 @@ XDrawLine (display, w, gc, x1, y1, x2, y2) 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 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) 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 @@ XClearArea (display, w, x, y, width, height, exposures) 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 @@ XClearWindow (display, w) SetPortWindowPort (w); - mac_set_colors (&xgc); + mac_set_colors (&xgc, NULL); #if TARGET_API_MAC_CARBON { @@ -464,6 +472,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) { BitMap bitmap; Rect r; + RGBColor old_bg; bitmap.rowBytes = sizeof(unsigned short); bitmap.baseAddr = (char *)bits; @@ -471,7 +480,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) 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 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) 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 @@ XFillRectangle (display, w, gc, x, y, width, height) 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 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) 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 @@ mac_draw_rectangle (display, w, gc, x, y, width, height) 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 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height) 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 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 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 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, } #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 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 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 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 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 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 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 @@ x_update_end (f) 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 @@ XTjudge_scroll_bars (f) } -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 @@ mac_define_frame_cursor (f, cursor) struct frame *f; Cursor cursor; { -#if TARGET_API_MAC_CARBON SetThemeCursor (cursor); -#else - SetCursor (*cursor); -#endif } @@ -5274,6 +5240,11 @@ x_set_window_size (f, change_gravity, cols, rows) 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 @@ Lisp_Object drag_and_drop_file_list; 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 @@ do_init_managers (void) 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 @@ do_window_update (WindowPtr win) RgnHandle region = NewRgn (); GetPortVisibleRegion (GetWindowPort (win), region); - UpdateControls (win, region); GetRegionBounds (region, &r); + expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); + UpdateControls (win, region); DisposeRgn (region); } #else - UpdateControls (win, win->visRgn); r = (*win->visRgn)->rgnBBox; -#endif expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); + UpdateControls (win, win->visRgn); +#endif handling_window_update = 0; } @@ -7955,8 +7920,6 @@ mac_handle_window_event (next_handler, event, data) EventRef event; void *data; { - extern Lisp_Object Qcontrol; - WindowPtr wp; OSStatus result; UInt32 attributes; @@ -8226,7 +8189,6 @@ mac_do_track_drag (DragTrackingMessage message, WindowPtr window, 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 @@ mac_do_track_drag (DragTrackingMessage message, WindowPtr window, { struct frame *f = mac_window_to_frame (window); - mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); HideDragHilite (theDrag); SetThemeCursor (kThemeArrowCursor); } @@ -8736,12 +8697,9 @@ XTread_socket (sd, expected, hold_quit) /* 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 @@ XTread_socket (sd, expected, hold_quit) case activateEvt: { WindowPtr window_ptr = (WindowPtr) er.message; + ControlRef root_control; #if USE_CARBON_EVENTS if (SendEventToEventTarget (eventRef, toolbox_dispatcher) @@ -8926,6 +8885,7 @@ XTread_socket (sd, expected, hold_quit) break; f = mac_window_to_frame (window_ptr); + GetRootControl (window_ptr, &root_control); if ((er.modifiers & activeFlag) != 0) { @@ -8933,7 +8893,7 @@ XTread_socket (sd, expected, hold_quit) 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 @@ XTread_socket (sd, expected, hold_quit) if (f == dpyinfo->x_focus_frame) { x_new_focus_frame (dpyinfo, 0); - deactivate_scroll_bars (f); + DeactivateControl (root_control); } @@ -9288,21 +9248,12 @@ make_mac_terminal_frame (struct frame *f) 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;