diff options
| author | YAMAMOTO Mitsuharu | 2005-07-18 05:40:30 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-07-18 05:40:30 +0000 |
| commit | e4f5e01926ad4b189f60f6b793dd1d90164b582e (patch) | |
| tree | af63baad23f279ffb16957efe00c561f714b69f1 /src | |
| parent | 623cc1d8d781db82df256a4bc20ac3affcd81161 (diff) | |
| download | emacs-e4f5e01926ad4b189f60f6b793dd1d90164b582e.tar.gz emacs-e4f5e01926ad4b189f60f6b793dd1d90164b582e.zip | |
(x_bitmap_icon, x_make_frame_visible): Remove declarations.
(XSetFont): Add declaration.
(mac_set_forecolor, mac_set_backcolor, mac_set_colors): Remove
functions.
(GC_FORE_COLOR, GC_BACK_COLOR, GC_FONT, MAC_WINDOW_NORMAL_GC): New
defines.
(XDrawLine, mac_draw_line_to_pixmap, XClearWindow)
(mac_draw_bitmap, XCreatePixmapFromBitmapData, XFillRectangle)
(mac_draw_rectangle, mac_draw_string_common, mac_scroll_area): Use
them.
(mac_erase_rectangle): New function.
(XClearArea, x_draw_fringe_bitmap, x_clear_glyph_string_rect)
(x_draw_stretch_glyph_string): Use it.
(XChangeGC, XCreateGC, XGetGCValues, XSetForeground)
(XSetBackground, XSetFont): Adjust for new GC implementation.
(x_draw_fringe_bitmap, x_draw_box_rect): Use GC to set colors.
(XTset_vertical_scroll_bar): Clear area under scroll bar.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 300 |
1 files changed, 136 insertions, 164 deletions
diff --git a/src/macterm.c b/src/macterm.c index 22471f46e8c..6ab26985afa 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -259,14 +259,19 @@ static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *, | |||
| 259 | Lisp_Object *, Lisp_Object *, | 259 | Lisp_Object *, Lisp_Object *, |
| 260 | unsigned long *)); | 260 | unsigned long *)); |
| 261 | 261 | ||
| 262 | static int is_emacs_window (WindowPtr); | 262 | static int is_emacs_window P_ ((WindowPtr)); |
| 263 | 263 | ||
| 264 | int x_bitmap_icon (struct frame *, Lisp_Object); | 264 | static void XSetFont P_ ((Display *, GC, XFontStruct *)); |
| 265 | void x_make_frame_visible (struct frame *); | ||
| 266 | 265 | ||
| 267 | /* Defined in macmenu.h. */ | 266 | /* Defined in macmenu.h. */ |
| 268 | extern void menubar_selection_callback (FRAME_PTR, int); | 267 | extern void menubar_selection_callback (FRAME_PTR, int); |
| 269 | 268 | ||
| 269 | #define GC_FORE_COLOR(gc) (&(gc)->fore_color) | ||
| 270 | #define GC_BACK_COLOR(gc) (&(gc)->back_color) | ||
| 271 | #define GC_FONT(gc) ((gc)->xgcv.font) | ||
| 272 | #define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc) | ||
| 273 | |||
| 274 | |||
| 270 | /* X display function emulation */ | 275 | /* X display function emulation */ |
| 271 | 276 | ||
| 272 | void | 277 | void |
| @@ -278,51 +283,6 @@ XFreePixmap (display, pixmap) | |||
| 278 | } | 283 | } |
| 279 | 284 | ||
| 280 | 285 | ||
| 281 | /* Set foreground color for subsequent QuickDraw commands. Assume | ||
| 282 | graphic port has already been set. */ | ||
| 283 | |||
| 284 | static void | ||
| 285 | mac_set_forecolor (unsigned long color) | ||
| 286 | { | ||
| 287 | RGBColor fg_color; | ||
| 288 | |||
| 289 | fg_color.red = RED16_FROM_ULONG (color); | ||
| 290 | fg_color.green = GREEN16_FROM_ULONG (color); | ||
| 291 | fg_color.blue = BLUE16_FROM_ULONG (color); | ||
| 292 | |||
| 293 | RGBForeColor (&fg_color); | ||
| 294 | } | ||
| 295 | |||
| 296 | |||
| 297 | /* Set background color for subsequent QuickDraw commands. Assume | ||
| 298 | graphic port has already been set. */ | ||
| 299 | |||
| 300 | static void | ||
| 301 | mac_set_backcolor (unsigned long color) | ||
| 302 | { | ||
| 303 | RGBColor bg_color; | ||
| 304 | |||
| 305 | bg_color.red = RED16_FROM_ULONG (color); | ||
| 306 | bg_color.green = GREEN16_FROM_ULONG (color); | ||
| 307 | bg_color.blue = BLUE16_FROM_ULONG (color); | ||
| 308 | |||
| 309 | RGBBackColor (&bg_color); | ||
| 310 | } | ||
| 311 | |||
| 312 | /* Set foreground and background color for subsequent QuickDraw | ||
| 313 | commands. Assume that the graphic port has already been set. */ | ||
| 314 | |||
| 315 | static void | ||
| 316 | mac_set_colors (gc, bg_save) | ||
| 317 | GC gc; | ||
| 318 | RGBColor *bg_save; | ||
| 319 | { | ||
| 320 | if (bg_save) | ||
| 321 | GetBackColor (bg_save); | ||
| 322 | mac_set_forecolor (gc->foreground); | ||
| 323 | mac_set_backcolor (gc->background); | ||
| 324 | } | ||
| 325 | |||
| 326 | /* Mac version of XDrawLine. */ | 286 | /* Mac version of XDrawLine. */ |
| 327 | 287 | ||
| 328 | static void | 288 | static void |
| @@ -332,16 +292,12 @@ XDrawLine (display, w, gc, x1, y1, x2, y2) | |||
| 332 | GC gc; | 292 | GC gc; |
| 333 | int x1, y1, x2, y2; | 293 | int x1, y1, x2, y2; |
| 334 | { | 294 | { |
| 335 | RGBColor old_bg; | ||
| 336 | |||
| 337 | SetPortWindowPort (w); | 295 | SetPortWindowPort (w); |
| 338 | 296 | ||
| 339 | mac_set_colors (gc, &old_bg); | 297 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 340 | 298 | ||
| 341 | MoveTo (x1, y1); | 299 | MoveTo (x1, y1); |
| 342 | LineTo (x2, y2); | 300 | LineTo (x2, y2); |
| 343 | |||
| 344 | RGBBackColor (&old_bg); | ||
| 345 | } | 301 | } |
| 346 | 302 | ||
| 347 | void | 303 | void |
| @@ -357,7 +313,7 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) | |||
| 357 | GetGWorld (&old_port, &old_gdh); | 313 | GetGWorld (&old_port, &old_gdh); |
| 358 | SetGWorld (p, NULL); | 314 | SetGWorld (p, NULL); |
| 359 | 315 | ||
| 360 | mac_set_colors (gc, NULL); | 316 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 361 | 317 | ||
| 362 | LockPixels (GetGWorldPixMap (p)); | 318 | LockPixels (GetGWorldPixMap (p)); |
| 363 | MoveTo (x1, y1); | 319 | MoveTo (x1, y1); |
| @@ -367,32 +323,38 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) | |||
| 367 | SetGWorld (old_port, old_gdh); | 323 | SetGWorld (old_port, old_gdh); |
| 368 | } | 324 | } |
| 369 | 325 | ||
| 370 | /* Mac version of XClearArea. */ | ||
| 371 | 326 | ||
| 372 | void | 327 | static void |
| 373 | XClearArea (display, w, x, y, width, height, exposures) | 328 | mac_erase_rectangle (w, gc, x, y, width, height) |
| 374 | Display *display; | ||
| 375 | WindowPtr w; | 329 | WindowPtr w; |
| 330 | GC gc; | ||
| 376 | int x, y; | 331 | int x, y; |
| 377 | unsigned int width, height; | 332 | unsigned int width, height; |
| 378 | int exposures; | ||
| 379 | { | 333 | { |
| 380 | struct mac_output *mwp = (mac_output *) GetWRefCon (w); | ||
| 381 | Rect r; | 334 | Rect r; |
| 382 | XGCValues xgc; | ||
| 383 | RGBColor old_bg; | ||
| 384 | |||
| 385 | xgc.foreground = mwp->x_compatible.foreground_pixel; | ||
| 386 | xgc.background = mwp->x_compatible.background_pixel; | ||
| 387 | 335 | ||
| 388 | SetPortWindowPort (w); | 336 | SetPortWindowPort (w); |
| 389 | 337 | ||
| 390 | mac_set_colors (&xgc, &old_bg); | 338 | RGBBackColor (GC_BACK_COLOR (gc)); |
| 391 | SetRect (&r, x, y, x + width, y + height); | 339 | SetRect (&r, x, y, x + width, y + height); |
| 392 | 340 | ||
| 393 | EraseRect (&r); | 341 | EraseRect (&r); |
| 394 | 342 | ||
| 395 | RGBBackColor (&old_bg); | 343 | RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); |
| 344 | } | ||
| 345 | |||
| 346 | |||
| 347 | /* Mac version of XClearArea. */ | ||
| 348 | |||
| 349 | void | ||
| 350 | XClearArea (display, w, x, y, width, height, exposures) | ||
| 351 | Display *display; | ||
| 352 | WindowPtr w; | ||
| 353 | int x, y; | ||
| 354 | unsigned int width, height; | ||
| 355 | int exposures; | ||
| 356 | { | ||
| 357 | mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height); | ||
| 396 | } | 358 | } |
| 397 | 359 | ||
| 398 | /* Mac version of XClearWindow. */ | 360 | /* Mac version of XClearWindow. */ |
| @@ -402,15 +364,9 @@ XClearWindow (display, w) | |||
| 402 | Display *display; | 364 | Display *display; |
| 403 | WindowPtr w; | 365 | WindowPtr w; |
| 404 | { | 366 | { |
| 405 | struct mac_output *mwp = (mac_output *) GetWRefCon (w); | ||
| 406 | XGCValues xgc; | ||
| 407 | |||
| 408 | xgc.foreground = mwp->x_compatible.foreground_pixel; | ||
| 409 | xgc.background = mwp->x_compatible.background_pixel; | ||
| 410 | |||
| 411 | SetPortWindowPort (w); | 367 | SetPortWindowPort (w); |
| 412 | 368 | ||
| 413 | mac_set_colors (&xgc, NULL); | 369 | RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); |
| 414 | 370 | ||
| 415 | #if TARGET_API_MAC_CARBON | 371 | #if TARGET_API_MAC_CARBON |
| 416 | { | 372 | { |
| @@ -438,7 +394,6 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) | |||
| 438 | { | 394 | { |
| 439 | BitMap bitmap; | 395 | BitMap bitmap; |
| 440 | Rect r; | 396 | Rect r; |
| 441 | RGBColor old_bg; | ||
| 442 | 397 | ||
| 443 | bitmap.rowBytes = sizeof(unsigned short); | 398 | bitmap.rowBytes = sizeof(unsigned short); |
| 444 | bitmap.baseAddr = (char *)bits; | 399 | bitmap.baseAddr = (char *)bits; |
| @@ -446,7 +401,8 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) | |||
| 446 | 401 | ||
| 447 | SetPortWindowPort (w); | 402 | SetPortWindowPort (w); |
| 448 | 403 | ||
| 449 | mac_set_colors (gc, &old_bg); | 404 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 405 | RGBBackColor (GC_BACK_COLOR (gc)); | ||
| 450 | SetRect (&r, x, y, x + width, y + height); | 406 | SetRect (&r, x, y, x + width, y + height); |
| 451 | 407 | ||
| 452 | #if TARGET_API_MAC_CARBON | 408 | #if TARGET_API_MAC_CARBON |
| @@ -459,7 +415,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) | |||
| 459 | overlay_p ? srcOr : srcCopy, 0); | 415 | overlay_p ? srcOr : srcCopy, 0); |
| 460 | #endif /* not TARGET_API_MAC_CARBON */ | 416 | #endif /* not TARGET_API_MAC_CARBON */ |
| 461 | 417 | ||
| 462 | RGBBackColor (&old_bg); | 418 | RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); |
| 463 | } | 419 | } |
| 464 | 420 | ||
| 465 | 421 | ||
| @@ -565,12 +521,16 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth) | |||
| 565 | char *data; | 521 | char *data; |
| 566 | unsigned int width, height; | 522 | unsigned int width, height; |
| 567 | unsigned long fg, bg; | 523 | unsigned long fg, bg; |
| 568 | unsigned int depth; /* not used */ | 524 | unsigned int depth; |
| 569 | { | 525 | { |
| 570 | Pixmap pixmap; | 526 | Pixmap pixmap; |
| 571 | BitMap bitmap; | 527 | BitMap bitmap; |
| 572 | CGrafPtr old_port; | 528 | CGrafPtr old_port; |
| 573 | GDHandle old_gdh; | 529 | GDHandle old_gdh; |
| 530 | static GC gc = NULL; /* not reentrant */ | ||
| 531 | |||
| 532 | if (gc == NULL) | ||
| 533 | gc = XCreateGC (display, w, 0, NULL); | ||
| 574 | 534 | ||
| 575 | pixmap = XCreatePixmap (display, w, width, height, depth); | 535 | pixmap = XCreatePixmap (display, w, width, height, depth); |
| 576 | if (pixmap == NULL) | 536 | if (pixmap == NULL) |
| @@ -579,8 +539,10 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth) | |||
| 579 | GetGWorld (&old_port, &old_gdh); | 539 | GetGWorld (&old_port, &old_gdh); |
| 580 | SetGWorld (pixmap, NULL); | 540 | SetGWorld (pixmap, NULL); |
| 581 | mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); | 541 | mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); |
| 582 | mac_set_forecolor (fg); | 542 | XSetForeground (display, gc, fg); |
| 583 | mac_set_backcolor (bg); | 543 | XSetBackground (display, gc, bg); |
| 544 | RGBForeColor (GC_FORE_COLOR (gc)); | ||
| 545 | RGBBackColor (GC_BACK_COLOR (gc)); | ||
| 584 | LockPixels (GetGWorldPixMap (pixmap)); | 546 | LockPixels (GetGWorldPixMap (pixmap)); |
| 585 | #if TARGET_API_MAC_CARBON | 547 | #if TARGET_API_MAC_CARBON |
| 586 | CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap), | 548 | CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap), |
| @@ -608,16 +570,13 @@ XFillRectangle (display, w, gc, x, y, width, height) | |||
| 608 | unsigned int width, height; | 570 | unsigned int width, height; |
| 609 | { | 571 | { |
| 610 | Rect r; | 572 | Rect r; |
| 611 | RGBColor old_bg; | ||
| 612 | 573 | ||
| 613 | SetPortWindowPort (w); | 574 | SetPortWindowPort (w); |
| 614 | 575 | ||
| 615 | mac_set_colors (gc, &old_bg); | 576 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 616 | SetRect (&r, x, y, x + width, y + height); | 577 | SetRect (&r, x, y, x + width, y + height); |
| 617 | 578 | ||
| 618 | PaintRect (&r); /* using foreground color of gc */ | 579 | PaintRect (&r); /* using foreground color of gc */ |
| 619 | |||
| 620 | RGBBackColor (&old_bg); | ||
| 621 | } | 580 | } |
| 622 | 581 | ||
| 623 | 582 | ||
| @@ -636,7 +595,7 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 636 | 595 | ||
| 637 | GetGWorld (&old_port, &old_gdh); | 596 | GetGWorld (&old_port, &old_gdh); |
| 638 | SetGWorld (p, NULL); | 597 | SetGWorld (p, NULL); |
| 639 | mac_set_colors (gc, NULL); | 598 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 640 | SetRect (&r, x, y, x + width, y + height); | 599 | SetRect (&r, x, y, x + width, y + height); |
| 641 | 600 | ||
| 642 | LockPixels (GetGWorldPixMap (p)); | 601 | LockPixels (GetGWorldPixMap (p)); |
| @@ -659,16 +618,13 @@ mac_draw_rectangle (display, w, gc, x, y, width, height) | |||
| 659 | unsigned int width, height; | 618 | unsigned int width, height; |
| 660 | { | 619 | { |
| 661 | Rect r; | 620 | Rect r; |
| 662 | RGBColor old_bg; | ||
| 663 | 621 | ||
| 664 | SetPortWindowPort (w); | 622 | SetPortWindowPort (w); |
| 665 | 623 | ||
| 666 | mac_set_colors (gc, &old_bg); | 624 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 667 | SetRect (&r, x, y, x + width + 1, y + height + 1); | 625 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| 668 | 626 | ||
| 669 | FrameRect (&r); /* using foreground color of gc */ | 627 | FrameRect (&r); /* using foreground color of gc */ |
| 670 | |||
| 671 | RGBBackColor (&old_bg); | ||
| 672 | } | 628 | } |
| 673 | 629 | ||
| 674 | 630 | ||
| @@ -689,7 +645,7 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 689 | 645 | ||
| 690 | GetGWorld (&old_port, &old_gdh); | 646 | GetGWorld (&old_port, &old_gdh); |
| 691 | SetGWorld (p, NULL); | 647 | SetGWorld (p, NULL); |
| 692 | mac_set_colors (gc, NULL); | 648 | RGBForeColor (GC_FORE_COLOR (gc)); |
| 693 | SetRect (&r, x, y, x + width + 1, y + height + 1); | 649 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| 694 | 650 | ||
| 695 | LockPixels (GetGWorldPixMap (p)); | 651 | LockPixels (GetGWorldPixMap (p)); |
| @@ -711,9 +667,6 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, | |||
| 711 | char *buf; | 667 | char *buf; |
| 712 | int nchars, mode, bytes_per_char; | 668 | int nchars, mode, bytes_per_char; |
| 713 | { | 669 | { |
| 714 | RGBColor old_bg; | ||
| 715 | |||
| 716 | SetPortWindowPort (w); | ||
| 717 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | 670 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
| 718 | UInt32 textFlags, savedFlags; | 671 | UInt32 textFlags, savedFlags; |
| 719 | if (!NILP(Vmac_use_core_graphics)) { | 672 | if (!NILP(Vmac_use_core_graphics)) { |
| @@ -722,17 +675,22 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, | |||
| 722 | } | 675 | } |
| 723 | #endif | 676 | #endif |
| 724 | 677 | ||
| 725 | mac_set_colors (gc, &old_bg); | 678 | SetPortWindowPort (w); |
| 679 | |||
| 680 | RGBForeColor (GC_FORE_COLOR (gc)); | ||
| 681 | if (mode != srcOr) | ||
| 682 | RGBBackColor (GC_BACK_COLOR (gc)); | ||
| 726 | 683 | ||
| 727 | TextFont (gc->font->mac_fontnum); | 684 | TextFont (GC_FONT (gc)->mac_fontnum); |
| 728 | TextSize (gc->font->mac_fontsize); | 685 | TextSize (GC_FONT (gc)->mac_fontsize); |
| 729 | TextFace (gc->font->mac_fontface); | 686 | TextFace (GC_FONT (gc)->mac_fontface); |
| 730 | TextMode (mode); | 687 | TextMode (mode); |
| 731 | 688 | ||
| 732 | MoveTo (x, y); | 689 | MoveTo (x, y); |
| 733 | DrawText (buf, 0, nchars * bytes_per_char); | 690 | DrawText (buf, 0, nchars * bytes_per_char); |
| 734 | 691 | ||
| 735 | RGBBackColor (&old_bg); | 692 | if (mode != srcOr) |
| 693 | RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); | ||
| 736 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | 694 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
| 737 | if (!NILP(Vmac_use_core_graphics)) | 695 | if (!NILP(Vmac_use_core_graphics)) |
| 738 | SwapQDTextFlags(savedFlags); | 696 | SwapQDTextFlags(savedFlags); |
| @@ -911,7 +869,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) | |||
| 911 | BackColor (whiteColor); | 869 | BackColor (whiteColor); |
| 912 | CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); | 870 | CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); |
| 913 | 871 | ||
| 914 | mac_set_colors (gc, NULL); | 872 | RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); |
| 915 | #endif /* not TARGET_API_MAC_CARBON */ | 873 | #endif /* not TARGET_API_MAC_CARBON */ |
| 916 | } | 874 | } |
| 917 | 875 | ||
| @@ -1001,28 +959,37 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y, | |||
| 1001 | /* Mac replacement for XChangeGC. */ | 959 | /* Mac replacement for XChangeGC. */ |
| 1002 | 960 | ||
| 1003 | static void | 961 | static void |
| 1004 | XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, | 962 | XChangeGC (display, gc, mask, xgcv) |
| 1005 | XGCValues *xgcv) | 963 | Display *display; |
| 964 | GC gc; | ||
| 965 | unsigned long mask; | ||
| 966 | XGCValues *xgcv; | ||
| 1006 | { | 967 | { |
| 1007 | if (mask & GCForeground) | 968 | if (mask & GCForeground) |
| 1008 | gc->foreground = xgcv->foreground; | 969 | XSetForeground (display, gc, xgcv->foreground); |
| 1009 | if (mask & GCBackground) | 970 | if (mask & GCBackground) |
| 1010 | gc->background = xgcv->background; | 971 | XSetBackground (display, gc, xgcv->background); |
| 1011 | if (mask & GCFont) | 972 | if (mask & GCFont) |
| 1012 | gc->font = xgcv->font; | 973 | XSetFont (display, gc, xgcv->font); |
| 1013 | } | 974 | } |
| 1014 | 975 | ||
| 1015 | 976 | ||
| 1016 | /* Mac replacement for XCreateGC. */ | 977 | /* Mac replacement for XCreateGC. */ |
| 1017 | 978 | ||
| 1018 | XGCValues * | 979 | GC |
| 1019 | XCreateGC (void * ignore, Window window, unsigned long mask, | 980 | XCreateGC (display, window, mask, xgcv) |
| 1020 | XGCValues *xgcv) | 981 | Display *display; |
| 982 | Window window; | ||
| 983 | unsigned long mask; | ||
| 984 | XGCValues *xgcv; | ||
| 1021 | { | 985 | { |
| 1022 | XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); | 986 | GC gc = xmalloc (sizeof (*gc)); |
| 1023 | bzero (gc, sizeof (XGCValues)); | ||
| 1024 | 987 | ||
| 1025 | XChangeGC (ignore, gc, mask, xgcv); | 988 | if (gc) |
| 989 | { | ||
| 990 | bzero (gc, sizeof (*gc)); | ||
| 991 | XChangeGC (display, gc, mask, xgcv); | ||
| 992 | } | ||
| 1026 | 993 | ||
| 1027 | return gc; | 994 | return gc; |
| 1028 | } | 995 | } |
| @@ -1042,10 +1009,18 @@ XFreeGC (display, gc) | |||
| 1042 | /* Mac replacement for XGetGCValues. */ | 1009 | /* Mac replacement for XGetGCValues. */ |
| 1043 | 1010 | ||
| 1044 | static void | 1011 | static void |
| 1045 | XGetGCValues (void* ignore, XGCValues *gc, | 1012 | XGetGCValues (display, gc, mask, xgcv) |
| 1046 | unsigned long mask, XGCValues *xgcv) | 1013 | Display *display; |
| 1014 | GC gc; | ||
| 1015 | unsigned long mask; | ||
| 1016 | XGCValues *xgcv; | ||
| 1047 | { | 1017 | { |
| 1048 | XChangeGC (ignore, xgcv, mask, gc); | 1018 | if (mask & GCForeground) |
| 1019 | xgcv->foreground = gc->xgcv.foreground; | ||
| 1020 | if (mask & GCBackground) | ||
| 1021 | xgcv->background = gc->xgcv.background; | ||
| 1022 | if (mask & GCFont) | ||
| 1023 | xgcv->font = gc->xgcv.font; | ||
| 1049 | } | 1024 | } |
| 1050 | 1025 | ||
| 1051 | 1026 | ||
| @@ -1057,7 +1032,13 @@ XSetForeground (display, gc, color) | |||
| 1057 | GC gc; | 1032 | GC gc; |
| 1058 | unsigned long color; | 1033 | unsigned long color; |
| 1059 | { | 1034 | { |
| 1060 | gc->foreground = color; | 1035 | if (gc->xgcv.foreground != color) |
| 1036 | { | ||
| 1037 | gc->xgcv.foreground = color; | ||
| 1038 | gc->fore_color.red = RED16_FROM_ULONG (color); | ||
| 1039 | gc->fore_color.green = GREEN16_FROM_ULONG (color); | ||
| 1040 | gc->fore_color.blue = BLUE16_FROM_ULONG (color); | ||
| 1041 | } | ||
| 1061 | } | 1042 | } |
| 1062 | 1043 | ||
| 1063 | 1044 | ||
| @@ -1069,7 +1050,25 @@ XSetBackground (display, gc, color) | |||
| 1069 | GC gc; | 1050 | GC gc; |
| 1070 | unsigned long color; | 1051 | unsigned long color; |
| 1071 | { | 1052 | { |
| 1072 | gc->background = color; | 1053 | if (gc->xgcv.background != color) |
| 1054 | { | ||
| 1055 | gc->xgcv.background = color; | ||
| 1056 | gc->back_color.red = RED16_FROM_ULONG (color); | ||
| 1057 | gc->back_color.green = GREEN16_FROM_ULONG (color); | ||
| 1058 | gc->back_color.blue = BLUE16_FROM_ULONG (color); | ||
| 1059 | } | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | |||
| 1063 | /* Mac replacement for XSetFont. */ | ||
| 1064 | |||
| 1065 | static void | ||
| 1066 | XSetFont (display, gc, font) | ||
| 1067 | Display *display; | ||
| 1068 | GC gc; | ||
| 1069 | XFontStruct *font; | ||
| 1070 | { | ||
| 1071 | gc->xgcv.font = font; | ||
| 1073 | } | 1072 | } |
| 1074 | 1073 | ||
| 1075 | 1074 | ||
| @@ -1116,19 +1115,6 @@ XSetWindowBackground (display, w, color) | |||
| 1116 | #endif | 1115 | #endif |
| 1117 | } | 1116 | } |
| 1118 | 1117 | ||
| 1119 | |||
| 1120 | /* Mac replacement for XSetFont. */ | ||
| 1121 | |||
| 1122 | static void | ||
| 1123 | XSetFont (display, gc, font) | ||
| 1124 | Display *display; | ||
| 1125 | GC gc; | ||
| 1126 | XFontStruct *font; | ||
| 1127 | { | ||
| 1128 | gc->font = font; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | |||
| 1132 | /* x_sync is a no-op on Mac. */ | 1118 | /* x_sync is a no-op on Mac. */ |
| 1133 | void | 1119 | void |
| 1134 | x_sync (f) | 1120 | x_sync (f) |
| @@ -1439,7 +1425,6 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 1439 | struct frame *f = XFRAME (WINDOW_FRAME (w)); | 1425 | struct frame *f = XFRAME (WINDOW_FRAME (w)); |
| 1440 | Display *display = FRAME_MAC_DISPLAY (f); | 1426 | Display *display = FRAME_MAC_DISPLAY (f); |
| 1441 | WindowPtr window = FRAME_MAC_WINDOW (f); | 1427 | WindowPtr window = FRAME_MAC_WINDOW (f); |
| 1442 | XGCValues gcv; | ||
| 1443 | GC gc = f->output_data.mac->normal_gc; | 1428 | GC gc = f->output_data.mac->normal_gc; |
| 1444 | struct face *face = p->face; | 1429 | struct face *face = p->face; |
| 1445 | int rowY; | 1430 | int rowY; |
| @@ -1463,9 +1448,6 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 1463 | 1448 | ||
| 1464 | if (p->bx >= 0 && !p->overlay_p) | 1449 | if (p->bx >= 0 && !p->overlay_p) |
| 1465 | { | 1450 | { |
| 1466 | XGCValues gcv; | ||
| 1467 | gcv.foreground = face->background; | ||
| 1468 | |||
| 1469 | #if 0 /* MAC_TODO: stipple */ | 1451 | #if 0 /* MAC_TODO: stipple */ |
| 1470 | /* In case the same realized face is used for fringes and | 1452 | /* In case the same realized face is used for fringes and |
| 1471 | for something displayed in the text (e.g. face `region' on | 1453 | for something displayed in the text (e.g. face `region' on |
| @@ -1477,9 +1459,7 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 1477 | XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); | 1459 | XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); |
| 1478 | #endif | 1460 | #endif |
| 1479 | 1461 | ||
| 1480 | XFillRectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | 1462 | mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny); |
| 1481 | &gcv, | ||
| 1482 | p->bx, p->by, p->nx, p->ny); | ||
| 1483 | 1463 | ||
| 1484 | #if 0 /* MAC_TODO: stipple */ | 1464 | #if 0 /* MAC_TODO: stipple */ |
| 1485 | if (!face->stipple) | 1465 | if (!face->stipple) |
| @@ -1490,15 +1470,17 @@ x_draw_fringe_bitmap (w, row, p) | |||
| 1490 | if (p->which) | 1470 | if (p->which) |
| 1491 | { | 1471 | { |
| 1492 | unsigned short *bits = p->bits + p->dh; | 1472 | unsigned short *bits = p->bits + p->dh; |
| 1473 | XGCValues gcv; | ||
| 1493 | 1474 | ||
| 1494 | gcv.foreground = (p->cursor_p | 1475 | XGetGCValues (display, face->gc, GCForeground, &gcv); |
| 1495 | ? (p->overlay_p ? face->background | 1476 | XSetForeground (display, face->gc, |
| 1496 | : f->output_data.mac->cursor_pixel) | 1477 | (p->cursor_p |
| 1497 | : face->foreground); | 1478 | ? (p->overlay_p ? face->background |
| 1498 | gcv.background = face->background; | 1479 | : f->output_data.mac->cursor_pixel) |
| 1499 | 1480 | : face->foreground)); | |
| 1500 | mac_draw_bitmap (display, window, &gcv, p->x, p->y, | 1481 | mac_draw_bitmap (display, window, face->gc, p->x, p->y, |
| 1501 | p->wd, p->h, bits, p->overlay_p); | 1482 | p->wd, p->h, bits, p->overlay_p); |
| 1483 | XSetForeground (display, face->gc, gcv.foreground); | ||
| 1502 | } | 1484 | } |
| 1503 | 1485 | ||
| 1504 | mac_reset_clipping (display, window); | 1486 | mac_reset_clipping (display, window); |
| @@ -1973,10 +1955,7 @@ x_clear_glyph_string_rect (s, x, y, w, h) | |||
| 1973 | struct glyph_string *s; | 1955 | struct glyph_string *s; |
| 1974 | int x, y, w, h; | 1956 | int x, y, w, h; |
| 1975 | { | 1957 | { |
| 1976 | XGCValues xgcv; | 1958 | mac_erase_rectangle (s->window, s->gc, x, y, w, h); |
| 1977 | |||
| 1978 | xgcv.foreground = s->gc->background; | ||
| 1979 | XFillRectangle (s->display, s->window, &xgcv, x, y, w, h); | ||
| 1980 | } | 1959 | } |
| 1981 | 1960 | ||
| 1982 | 1961 | ||
| @@ -2564,27 +2543,29 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width, | |||
| 2564 | { | 2543 | { |
| 2565 | XGCValues xgcv; | 2544 | XGCValues xgcv; |
| 2566 | 2545 | ||
| 2567 | xgcv.foreground = s->face->box_color; | 2546 | XGetGCValues (s->display, s->gc, GCForeground, &xgcv); |
| 2547 | XSetForeground (s->display, s->gc, s->face->box_color); | ||
| 2568 | mac_set_clip_rectangle (s->display, s->window, clip_rect); | 2548 | mac_set_clip_rectangle (s->display, s->window, clip_rect); |
| 2569 | 2549 | ||
| 2570 | /* Top. */ | 2550 | /* Top. */ |
| 2571 | XFillRectangle (s->display, s->window, &xgcv, | 2551 | XFillRectangle (s->display, s->window, s->gc, |
| 2572 | left_x, top_y, right_x - left_x + 1, width); | 2552 | left_x, top_y, right_x - left_x + 1, width); |
| 2573 | 2553 | ||
| 2574 | /* Left. */ | 2554 | /* Left. */ |
| 2575 | if (left_p) | 2555 | if (left_p) |
| 2576 | XFillRectangle (s->display, s->window, &xgcv, | 2556 | XFillRectangle (s->display, s->window, s->gc, |
| 2577 | left_x, top_y, width, bottom_y - top_y + 1); | 2557 | left_x, top_y, width, bottom_y - top_y + 1); |
| 2578 | 2558 | ||
| 2579 | /* Bottom. */ | 2559 | /* Bottom. */ |
| 2580 | XFillRectangle (s->display, s->window, &xgcv, | 2560 | XFillRectangle (s->display, s->window, s->gc, |
| 2581 | left_x, bottom_y - width + 1, right_x - left_x + 1, width); | 2561 | left_x, bottom_y - width + 1, right_x - left_x + 1, width); |
| 2582 | 2562 | ||
| 2583 | /* Right. */ | 2563 | /* Right. */ |
| 2584 | if (right_p) | 2564 | if (right_p) |
| 2585 | XFillRectangle (s->display, s->window, &xgcv, | 2565 | XFillRectangle (s->display, s->window, s->gc, |
| 2586 | right_x - width + 1, top_y, width, bottom_y - top_y + 1); | 2566 | right_x - width + 1, top_y, width, bottom_y - top_y + 1); |
| 2587 | 2567 | ||
| 2568 | XSetForeground (s->display, s->gc, xgcv.foreground); | ||
| 2588 | mac_reset_clipping (s->display, s->window); | 2569 | mac_reset_clipping (s->display, s->window); |
| 2589 | } | 2570 | } |
| 2590 | 2571 | ||
| @@ -3003,13 +2984,7 @@ x_draw_stretch_glyph_string (s) | |||
| 3003 | } | 2984 | } |
| 3004 | else | 2985 | else |
| 3005 | #endif /* MAC_TODO */ | 2986 | #endif /* MAC_TODO */ |
| 3006 | { | 2987 | mac_erase_rectangle (s->window, gc, x, y, w, h); |
| 3007 | XGCValues xgcv; | ||
| 3008 | XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv); | ||
| 3009 | XSetForeground (s->display, gc, xgcv.background); | ||
| 3010 | XFillRectangle (s->display, s->window, gc, x, y, w, h); | ||
| 3011 | XSetForeground (s->display, gc, xgcv.foreground); | ||
| 3012 | } | ||
| 3013 | 2988 | ||
| 3014 | mac_reset_clipping (s->display, s->window); | 2989 | mac_reset_clipping (s->display, s->window); |
| 3015 | } | 2990 | } |
| @@ -4560,13 +4535,10 @@ XTset_vertical_scroll_bar (w, portion, whole, position) | |||
| 4560 | && XINT (bar->width) == sb_width | 4535 | && XINT (bar->width) == sb_width |
| 4561 | && XINT (bar->height) == height)) | 4536 | && XINT (bar->height) == height)) |
| 4562 | { | 4537 | { |
| 4563 | /* Clear areas not covered by the scroll bar because it's not as | 4538 | /* Since toolkit scroll bars are smaller than the space reserved |
| 4564 | wide as the area reserved for it . This makes sure a | 4539 | for them on the frame, we have to clear "under" them. */ |
| 4565 | previous mode line display is cleared after C-x 2 C-x 1, for | ||
| 4566 | example. */ | ||
| 4567 | int area_width = WINDOW_SCROLL_BAR_AREA_WIDTH (w); | ||
| 4568 | XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | 4540 | XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), |
| 4569 | left, top, area_width, height, 0); | 4541 | left, top, width, height, 0); |
| 4570 | 4542 | ||
| 4571 | #if 0 | 4543 | #if 0 |
| 4572 | if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f)) | 4544 | if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f)) |