diff options
| author | Steven Tamm | 2004-05-30 00:18:41 +0000 |
|---|---|---|
| committer | Steven Tamm | 2004-05-30 00:18:41 +0000 |
| commit | 50bf76732ba3cd84d56185685e58604dd139ba94 (patch) | |
| tree | 1f86ade4b3d5ac94add211e8ffbb8690941033fc /src/macterm.c | |
| parent | f2f82fa491294e51620ef6eddfd03912e28e2936 (diff) | |
| download | emacs-50bf76732ba3cd84d56185685e58604dd139ba94.tar.gz emacs-50bf76732ba3cd84d56185685e58604dd139ba94.zip | |
Support Tooltips with the Carbon emacs port.
Some code cleanup using helper macros.
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 1327 |
1 files changed, 659 insertions, 668 deletions
diff --git a/src/macterm.c b/src/macterm.c index 9523acce79d..54a2fce792d 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -53,7 +53,6 @@ Boston, MA 02111-1307, USA. */ | |||
| 53 | #if defined (__MRC__) || (__MSL__ >= 0x6000) | 53 | #if defined (__MRC__) || (__MSL__ >= 0x6000) |
| 54 | #include <ControlDefinitions.h> | 54 | #include <ControlDefinitions.h> |
| 55 | #endif | 55 | #endif |
| 56 | #include <Gestalt.h> | ||
| 57 | 56 | ||
| 58 | #if __profile__ | 57 | #if __profile__ |
| 59 | #include <profiler.h> | 58 | #include <profiler.h> |
| @@ -196,14 +195,6 @@ static Lisp_Object last_mouse_scroll_bar; | |||
| 196 | 195 | ||
| 197 | static Time last_mouse_movement_time; | 196 | static Time last_mouse_movement_time; |
| 198 | 197 | ||
| 199 | enum mouse_tracking_type { | ||
| 200 | mouse_tracking_none, | ||
| 201 | mouse_tracking_mouse_movement, | ||
| 202 | mouse_tracking_scroll_bar | ||
| 203 | }; | ||
| 204 | |||
| 205 | enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none; | ||
| 206 | |||
| 207 | struct scroll_bar *tracked_scroll_bar = NULL; | 198 | struct scroll_bar *tracked_scroll_bar = NULL; |
| 208 | 199 | ||
| 209 | /* Incremented by XTread_socket whenever it really tries to read | 200 | /* Incremented by XTread_socket whenever it really tries to read |
| @@ -364,11 +355,7 @@ XDrawLine (display, w, gc, x1, y1, x2, y2) | |||
| 364 | GC gc; | 355 | GC gc; |
| 365 | int x1, y1, x2, y2; | 356 | int x1, y1, x2, y2; |
| 366 | { | 357 | { |
| 367 | #if TARGET_API_MAC_CARBON | 358 | SetPortWindowPort (w); |
| 368 | SetPort (GetWindowPort (w)); | ||
| 369 | #else | ||
| 370 | SetPort (w); | ||
| 371 | #endif | ||
| 372 | 359 | ||
| 373 | mac_set_colors (gc); | 360 | mac_set_colors (gc); |
| 374 | 361 | ||
| @@ -416,11 +403,7 @@ XClearArea (display, w, x, y, width, height, exposures) | |||
| 416 | xgc.foreground = mwp->x_compatible.foreground_pixel; | 403 | xgc.foreground = mwp->x_compatible.foreground_pixel; |
| 417 | xgc.background = mwp->x_compatible.background_pixel; | 404 | xgc.background = mwp->x_compatible.background_pixel; |
| 418 | 405 | ||
| 419 | #if TARGET_API_MAC_CARBON | 406 | SetPortWindowPort (w); |
| 420 | SetPort (GetWindowPort (w)); | ||
| 421 | #else | ||
| 422 | SetPort (w); | ||
| 423 | #endif | ||
| 424 | 407 | ||
| 425 | mac_set_colors (&xgc); | 408 | mac_set_colors (&xgc); |
| 426 | SetRect (&r, x, y, x + width, y + height); | 409 | SetRect (&r, x, y, x + width, y + height); |
| @@ -441,11 +424,7 @@ XClearWindow (display, w) | |||
| 441 | xgc.foreground = mwp->x_compatible.foreground_pixel; | 424 | xgc.foreground = mwp->x_compatible.foreground_pixel; |
| 442 | xgc.background = mwp->x_compatible.background_pixel; | 425 | xgc.background = mwp->x_compatible.background_pixel; |
| 443 | 426 | ||
| 444 | #if TARGET_API_MAC_CARBON | 427 | SetPortWindowPort (w); |
| 445 | SetPort (GetWindowPort (w)); | ||
| 446 | #else | ||
| 447 | SetPort (w); | ||
| 448 | #endif | ||
| 449 | 428 | ||
| 450 | mac_set_colors (&xgc); | 429 | mac_set_colors (&xgc); |
| 451 | 430 | ||
| @@ -480,11 +459,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) | |||
| 480 | bitmap.baseAddr = (char *)bits; | 459 | bitmap.baseAddr = (char *)bits; |
| 481 | SetRect (&(bitmap.bounds), 0, 0, width, height); | 460 | SetRect (&(bitmap.bounds), 0, 0, width, height); |
| 482 | 461 | ||
| 483 | #if TARGET_API_MAC_CARBON | 462 | SetPortWindowPort (w); |
| 484 | SetPort (GetWindowPort (w)); | ||
| 485 | #else | ||
| 486 | SetPort (w); | ||
| 487 | #endif | ||
| 488 | 463 | ||
| 489 | mac_set_colors (gc); | 464 | mac_set_colors (gc); |
| 490 | SetRect (&r, x, y, x + width, y + height); | 465 | SetRect (&r, x, y, x + width, y + height); |
| @@ -509,11 +484,7 @@ mac_set_clip_rectangle (display, w, r) | |||
| 509 | WindowPtr w; | 484 | WindowPtr w; |
| 510 | Rect *r; | 485 | Rect *r; |
| 511 | { | 486 | { |
| 512 | #if TARGET_API_MAC_CARBON | 487 | SetPortWindowPort (w); |
| 513 | SetPort (GetWindowPort (w)); | ||
| 514 | #else | ||
| 515 | SetPort (w); | ||
| 516 | #endif | ||
| 517 | 488 | ||
| 518 | ClipRect (r); | 489 | ClipRect (r); |
| 519 | } | 490 | } |
| @@ -528,11 +499,7 @@ mac_reset_clipping (display, w) | |||
| 528 | { | 499 | { |
| 529 | Rect r; | 500 | Rect r; |
| 530 | 501 | ||
| 531 | #if TARGET_API_MAC_CARBON | 502 | SetPortWindowPort (w); |
| 532 | SetPort (GetWindowPort (w)); | ||
| 533 | #else | ||
| 534 | SetPort (w); | ||
| 535 | #endif | ||
| 536 | 503 | ||
| 537 | SetRect (&r, -32767, -32767, 32767, 32767); | 504 | SetRect (&r, -32767, -32767, 32767, 32767); |
| 538 | ClipRect (&r); | 505 | ClipRect (&r); |
| @@ -601,11 +568,7 @@ XCreatePixmap (display, w, width, height, depth) | |||
| 601 | Rect r; | 568 | Rect r; |
| 602 | QDErr err; | 569 | QDErr err; |
| 603 | 570 | ||
| 604 | #if TARGET_API_MAC_CARBON | 571 | SetPortWindowPort (w); |
| 605 | SetPort (GetWindowPort (w)); | ||
| 606 | #else | ||
| 607 | SetPort (w); | ||
| 608 | #endif | ||
| 609 | 572 | ||
| 610 | SetRect (&r, 0, 0, width, height); | 573 | SetRect (&r, 0, 0, width, height); |
| 611 | err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); | 574 | err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); |
| @@ -666,11 +629,7 @@ XFillRectangle (display, w, gc, x, y, width, height) | |||
| 666 | { | 629 | { |
| 667 | Rect r; | 630 | Rect r; |
| 668 | 631 | ||
| 669 | #if TARGET_API_MAC_CARBON | 632 | SetPortWindowPort (w); |
| 670 | SetPort (GetWindowPort (w)); | ||
| 671 | #else | ||
| 672 | SetPort (w); | ||
| 673 | #endif | ||
| 674 | 633 | ||
| 675 | mac_set_colors (gc); | 634 | mac_set_colors (gc); |
| 676 | SetRect (&r, x, y, x + width, y + height); | 635 | SetRect (&r, x, y, x + width, y + height); |
| @@ -716,11 +675,7 @@ mac_draw_rectangle (display, w, gc, x, y, width, height) | |||
| 716 | { | 675 | { |
| 717 | Rect r; | 676 | Rect r; |
| 718 | 677 | ||
| 719 | #if TARGET_API_MAC_CARBON | 678 | SetPortWindowPort (w); |
| 720 | SetPort (GetWindowPort (w)); | ||
| 721 | #else | ||
| 722 | SetPort (w); | ||
| 723 | #endif | ||
| 724 | 679 | ||
| 725 | mac_set_colors (gc); | 680 | mac_set_colors (gc); |
| 726 | SetRect (&r, x, y, x + width + 1, y + height + 1); | 681 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| @@ -766,11 +721,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, | |||
| 766 | char *buf; | 721 | char *buf; |
| 767 | int nchars, mode, bytes_per_char; | 722 | int nchars, mode, bytes_per_char; |
| 768 | { | 723 | { |
| 769 | #if TARGET_API_MAC_CARBON | 724 | SetPortWindowPort (w); |
| 770 | SetPort (GetWindowPort (w)); | ||
| 771 | #else | ||
| 772 | SetPort (w); | ||
| 773 | #endif | ||
| 774 | 725 | ||
| 775 | mac_set_colors (gc); | 726 | mac_set_colors (gc); |
| 776 | 727 | ||
| @@ -861,11 +812,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x, | |||
| 861 | { | 812 | { |
| 862 | Rect src_r, dest_r; | 813 | Rect src_r, dest_r; |
| 863 | 814 | ||
| 864 | #if TARGET_API_MAC_CARBON | 815 | SetPortWindowPort (dest); |
| 865 | SetPort (GetWindowPort (dest)); | ||
| 866 | #else | ||
| 867 | SetPort (dest); | ||
| 868 | #endif | ||
| 869 | 816 | ||
| 870 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 817 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 871 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 818 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| @@ -901,11 +848,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, | |||
| 901 | { | 848 | { |
| 902 | Rect src_r, dest_r; | 849 | Rect src_r, dest_r; |
| 903 | 850 | ||
| 904 | #if TARGET_API_MAC_CARBON | 851 | SetPortWindowPort (dest); |
| 905 | SetPort (GetWindowPort (dest)); | ||
| 906 | #else | ||
| 907 | SetPort (dest); | ||
| 908 | #endif | ||
| 909 | 852 | ||
| 910 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 853 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 911 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 854 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| @@ -965,7 +908,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) | |||
| 965 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 908 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 966 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 909 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| 967 | 910 | ||
| 968 | SetPort (GetWindowPort (w)); | 911 | SetPortWindowPort (w); |
| 969 | 912 | ||
| 970 | ForeColor (blackColor); | 913 | ForeColor (blackColor); |
| 971 | BackColor (whiteColor); | 914 | BackColor (whiteColor); |
| @@ -1290,7 +1233,7 @@ x_update_window_begin (w) | |||
| 1290 | { | 1233 | { |
| 1291 | int i; | 1234 | int i; |
| 1292 | 1235 | ||
| 1293 | for (i = 0; i < w->desired_matrix->nrows; ++i) | 1236 | for (i = 0; i < w->desired_matrix->nrows; ++i) |
| 1294 | if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) | 1237 | if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) |
| 1295 | break; | 1238 | break; |
| 1296 | 1239 | ||
| @@ -1385,11 +1328,7 @@ x_update_end (f) | |||
| 1385 | /* Reset the background color of Mac OS Window to that of the frame after | 1328 | /* Reset the background color of Mac OS Window to that of the frame after |
| 1386 | update so that it is used by Mac Toolbox to clear the update region before | 1329 | update so that it is used by Mac Toolbox to clear the update region before |
| 1387 | an update event is generated. */ | 1330 | an update event is generated. */ |
| 1388 | #if TARGET_API_MAC_CARBON | 1331 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 1389 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 1390 | #else | ||
| 1391 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 1392 | #endif | ||
| 1393 | 1332 | ||
| 1394 | mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); | 1333 | mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); |
| 1395 | 1334 | ||
| @@ -3745,11 +3684,7 @@ construct_mouse_click (result, event, f) | |||
| 3745 | 3684 | ||
| 3746 | mouseLoc = event->where; | 3685 | mouseLoc = event->where; |
| 3747 | 3686 | ||
| 3748 | #if TARGET_API_MAC_CARBON | 3687 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 3749 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 3750 | #else | ||
| 3751 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 3752 | #endif | ||
| 3753 | 3688 | ||
| 3754 | GlobalToLocal (&mouseLoc); | 3689 | GlobalToLocal (&mouseLoc); |
| 3755 | XSETINT (result->x, mouseLoc.h); | 3690 | XSETINT (result->x, mouseLoc.h); |
| @@ -3778,6 +3713,7 @@ note_mouse_movement (frame, pos) | |||
| 3778 | FRAME_PTR frame; | 3713 | FRAME_PTR frame; |
| 3779 | Point *pos; | 3714 | Point *pos; |
| 3780 | { | 3715 | { |
| 3716 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame); | ||
| 3781 | #if TARGET_API_MAC_CARBON | 3717 | #if TARGET_API_MAC_CARBON |
| 3782 | Rect r; | 3718 | Rect r; |
| 3783 | #endif | 3719 | #endif |
| @@ -3792,9 +3728,17 @@ note_mouse_movement (frame, pos) | |||
| 3792 | if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) | 3728 | if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) |
| 3793 | #endif | 3729 | #endif |
| 3794 | { | 3730 | { |
| 3795 | frame->mouse_moved = 1; | 3731 | if (frame == dpyinfo->mouse_face_mouse_frame) |
| 3796 | last_mouse_scroll_bar = Qnil; | 3732 | /* This case corresponds to LeaveNotify in X11. */ |
| 3797 | note_mouse_highlight (frame, -1, -1); | 3733 | { |
| 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 | } | ||
| 3798 | } | 3742 | } |
| 3799 | /* Has the mouse moved off the glyph it was on at the last sighting? */ | 3743 | /* Has the mouse moved off the glyph it was on at the last sighting? */ |
| 3800 | else if (pos->h < last_mouse_glyph.left | 3744 | else if (pos->h < last_mouse_glyph.left |
| @@ -3942,6 +3886,23 @@ remember_mouse_glyph (f1, gx, gy) | |||
| 3942 | } | 3886 | } |
| 3943 | 3887 | ||
| 3944 | 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 | |||
| 3945 | /* Return the current position of the mouse. | 3906 | /* Return the current position of the mouse. |
| 3946 | *fp should be a frame which indicates which display to ask about. | 3907 | *fp should be a frame which indicates which display to ask about. |
| 3947 | 3908 | ||
| @@ -3973,12 +3934,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 3973 | { | 3934 | { |
| 3974 | Point mouse_pos; | 3935 | Point mouse_pos; |
| 3975 | int ignore1, ignore2; | 3936 | int ignore1, ignore2; |
| 3976 | WindowPtr wp = FrontWindow (); | 3937 | WindowPtr wp = mac_front_window (); |
| 3977 | struct frame *f; | 3938 | struct frame *f; |
| 3978 | Lisp_Object frame, tail; | 3939 | Lisp_Object frame, tail; |
| 3979 | 3940 | ||
| 3980 | if (is_emacs_window(wp)) | 3941 | if (is_emacs_window(wp)) |
| 3981 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 3942 | f = mac_window_to_frame (wp); |
| 3982 | 3943 | ||
| 3983 | BLOCK_INPUT; | 3944 | BLOCK_INPUT; |
| 3984 | 3945 | ||
| @@ -3992,11 +3953,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 3992 | 3953 | ||
| 3993 | last_mouse_scroll_bar = Qnil; | 3954 | last_mouse_scroll_bar = Qnil; |
| 3994 | 3955 | ||
| 3995 | #if TARGET_API_MAC_CARBON | 3956 | SetPortWindowPort (wp); |
| 3996 | SetPort (GetWindowPort (wp)); | ||
| 3997 | #else | ||
| 3998 | SetPort (wp); | ||
| 3999 | #endif | ||
| 4000 | 3957 | ||
| 4001 | GetMouse (&mouse_pos); | 3958 | GetMouse (&mouse_pos); |
| 4002 | 3959 | ||
| @@ -4491,6 +4448,8 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) | |||
| 4491 | EventRecord *er; | 4448 | EventRecord *er; |
| 4492 | struct input_event *bufp; | 4449 | struct input_event *bufp; |
| 4493 | { | 4450 | { |
| 4451 | int win_y, top_range; | ||
| 4452 | |||
| 4494 | if (! GC_WINDOWP (bar->window)) | 4453 | if (! GC_WINDOWP (bar->window)) |
| 4495 | abort (); | 4454 | abort (); |
| 4496 | 4455 | ||
| @@ -4525,6 +4484,24 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) | |||
| 4525 | bufp->part = scroll_bar_handle; | 4484 | bufp->part = scroll_bar_handle; |
| 4526 | break; | 4485 | break; |
| 4527 | } | 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); | ||
| 4528 | } | 4505 | } |
| 4529 | 4506 | ||
| 4530 | 4507 | ||
| @@ -4574,16 +4551,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) | |||
| 4574 | unsigned long *time; | 4551 | unsigned long *time; |
| 4575 | { | 4552 | { |
| 4576 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 4553 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); |
| 4577 | WindowPtr wp = FrontWindow (); | 4554 | WindowPtr wp = mac_front_window (); |
| 4578 | Point mouse_pos; | 4555 | Point mouse_pos; |
| 4579 | struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | 4556 | struct frame *f = mac_window_to_frame (wp); |
| 4580 | int win_y, top_range; | 4557 | int win_y, top_range; |
| 4581 | 4558 | ||
| 4582 | #if TARGET_API_MAC_CARBON | 4559 | SetPortWindowPort (wp); |
| 4583 | SetPort (GetWindowPort (wp)); | ||
| 4584 | #else | ||
| 4585 | SetPort (wp); | ||
| 4586 | #endif | ||
| 4587 | 4560 | ||
| 4588 | GetMouse (&mouse_pos); | 4561 | GetMouse (&mouse_pos); |
| 4589 | 4562 | ||
| @@ -4810,7 +4783,11 @@ mac_define_frame_cursor (f, cursor) | |||
| 4810 | struct frame *f; | 4783 | struct frame *f; |
| 4811 | Cursor cursor; | 4784 | Cursor cursor; |
| 4812 | { | 4785 | { |
| 4813 | /* MAC TODO */ | 4786 | #if TARGET_API_MAC_CARBON |
| 4787 | SetThemeCursor (cursor); | ||
| 4788 | #else | ||
| 4789 | SetCursor (*cursor); | ||
| 4790 | #endif | ||
| 4814 | } | 4791 | } |
| 4815 | 4792 | ||
| 4816 | 4793 | ||
| @@ -5078,11 +5055,7 @@ x_calc_absolute_position (f) | |||
| 5078 | GrafPtr savePort; | 5055 | GrafPtr savePort; |
| 5079 | GetPort (&savePort); | 5056 | GetPort (&savePort); |
| 5080 | 5057 | ||
| 5081 | #if TARGET_API_MAC_CARBON | 5058 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 5082 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 5083 | #else | ||
| 5084 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 5085 | #endif | ||
| 5086 | 5059 | ||
| 5087 | #if TARGET_API_MAC_CARBON | 5060 | #if TARGET_API_MAC_CARBON |
| 5088 | { | 5061 | { |
| @@ -5457,10 +5430,15 @@ x_free_frame_resources (f) | |||
| 5457 | struct frame *f; | 5430 | struct frame *f; |
| 5458 | { | 5431 | { |
| 5459 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); | 5432 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); |
| 5433 | WindowPtr wp = FRAME_MAC_WINDOW (f); | ||
| 5460 | 5434 | ||
| 5461 | BLOCK_INPUT; | 5435 | BLOCK_INPUT; |
| 5462 | 5436 | ||
| 5463 | DisposeWindow (FRAME_MAC_WINDOW (f)); | 5437 | 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; | ||
| 5464 | 5442 | ||
| 5465 | free_frame_menubar (f); | 5443 | free_frame_menubar (f); |
| 5466 | 5444 | ||
| @@ -6984,6 +6962,11 @@ Lisp_Object drag_and_drop_file_list; | |||
| 6984 | 6962 | ||
| 6985 | Point saved_menu_event_location; | 6963 | Point saved_menu_event_location; |
| 6986 | 6964 | ||
| 6965 | #if !TARGET_API_MAC_CARBON | ||
| 6966 | /* Place holder for the default arrow cursor. */ | ||
| 6967 | CursPtr arrow_cursor; | ||
| 6968 | #endif | ||
| 6969 | |||
| 6987 | /* Apple Events */ | 6970 | /* Apple Events */ |
| 6988 | static void init_required_apple_events (void); | 6971 | static void init_required_apple_events (void); |
| 6989 | static pascal OSErr | 6972 | static pascal OSErr |
| @@ -7170,6 +7153,8 @@ do_init_managers (void) | |||
| 7170 | InitCursor (); | 7153 | InitCursor (); |
| 7171 | 7154 | ||
| 7172 | #if !TARGET_API_MAC_CARBON | 7155 | #if !TARGET_API_MAC_CARBON |
| 7156 | arrow_cursor = &qd.arrow; | ||
| 7157 | |||
| 7173 | /* set up some extra stack space for use by emacs */ | 7158 | /* set up some extra stack space for use by emacs */ |
| 7174 | SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); | 7159 | SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); |
| 7175 | 7160 | ||
| @@ -7198,8 +7183,12 @@ do_check_ram_size (void) | |||
| 7198 | static void | 7183 | static void |
| 7199 | do_window_update (WindowPtr win) | 7184 | do_window_update (WindowPtr win) |
| 7200 | { | 7185 | { |
| 7201 | struct mac_output *mwp = (mac_output *) GetWRefCon (win); | 7186 | struct frame *f = mac_window_to_frame (win); |
| 7202 | struct frame *f = mwp->mFP; | 7187 | |
| 7188 | if (win == tip_window) | ||
| 7189 | /* The tooltip has been drawn already. Avoid the | ||
| 7190 | SET_FRAME_GARBAGED below. */ | ||
| 7191 | return; | ||
| 7203 | 7192 | ||
| 7204 | if (f) | 7193 | if (f) |
| 7205 | { | 7194 | { |
| @@ -7250,13 +7239,11 @@ is_emacs_window (WindowPtr win) | |||
| 7250 | static void | 7239 | static void |
| 7251 | do_window_activate (WindowPtr win) | 7240 | do_window_activate (WindowPtr win) |
| 7252 | { | 7241 | { |
| 7253 | mac_output *mwp; | ||
| 7254 | struct frame *f; | 7242 | struct frame *f; |
| 7255 | 7243 | ||
| 7256 | if (is_emacs_window (win)) | 7244 | if (is_emacs_window (win)) |
| 7257 | { | 7245 | { |
| 7258 | mwp = (mac_output *) GetWRefCon (win); | 7246 | f = mac_window_to_frame (win); |
| 7259 | f = mwp->mFP; | ||
| 7260 | 7247 | ||
| 7261 | if (f) | 7248 | if (f) |
| 7262 | { | 7249 | { |
| @@ -7269,13 +7256,11 @@ do_window_activate (WindowPtr win) | |||
| 7269 | static void | 7256 | static void |
| 7270 | do_window_deactivate (WindowPtr win) | 7257 | do_window_deactivate (WindowPtr win) |
| 7271 | { | 7258 | { |
| 7272 | mac_output *mwp; | ||
| 7273 | struct frame *f; | 7259 | struct frame *f; |
| 7274 | 7260 | ||
| 7275 | if (is_emacs_window (win)) | 7261 | if (is_emacs_window (win)) |
| 7276 | { | 7262 | { |
| 7277 | mwp = (mac_output *) GetWRefCon (win); | 7263 | f = mac_window_to_frame (win); |
| 7278 | f = mwp->mFP; | ||
| 7279 | 7264 | ||
| 7280 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | 7265 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) |
| 7281 | { | 7266 | { |
| @@ -7289,14 +7274,12 @@ static void | |||
| 7289 | do_app_resume () | 7274 | do_app_resume () |
| 7290 | { | 7275 | { |
| 7291 | WindowPtr wp; | 7276 | WindowPtr wp; |
| 7292 | mac_output *mwp; | ||
| 7293 | struct frame *f; | 7277 | struct frame *f; |
| 7294 | 7278 | ||
| 7295 | wp = FrontWindow(); | 7279 | wp = mac_front_window (); |
| 7296 | if (is_emacs_window (wp)) | 7280 | if (is_emacs_window (wp)) |
| 7297 | { | 7281 | { |
| 7298 | mwp = (mac_output *) GetWRefCon (wp); | 7282 | f = mac_window_to_frame (wp); |
| 7299 | f = mwp->mFP; | ||
| 7300 | 7283 | ||
| 7301 | if (f) | 7284 | if (f) |
| 7302 | { | 7285 | { |
| @@ -7313,14 +7296,12 @@ static void | |||
| 7313 | do_app_suspend () | 7296 | do_app_suspend () |
| 7314 | { | 7297 | { |
| 7315 | WindowPtr wp; | 7298 | WindowPtr wp; |
| 7316 | mac_output *mwp; | ||
| 7317 | struct frame *f; | 7299 | struct frame *f; |
| 7318 | 7300 | ||
| 7319 | wp = FrontWindow(); | 7301 | wp = mac_front_window (); |
| 7320 | if (is_emacs_window (wp)) | 7302 | if (is_emacs_window (wp)) |
| 7321 | { | 7303 | { |
| 7322 | mwp = (mac_output *) GetWRefCon (wp); | 7304 | f = mac_window_to_frame (wp); |
| 7323 | f = mwp->mFP; | ||
| 7324 | 7305 | ||
| 7325 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | 7306 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) |
| 7326 | { | 7307 | { |
| @@ -7335,67 +7316,38 @@ do_app_suspend () | |||
| 7335 | 7316 | ||
| 7336 | 7317 | ||
| 7337 | static void | 7318 | static void |
| 7338 | do_mouse_moved (Point mouse_pos) | 7319 | do_mouse_moved (mouse_pos, f) |
| 7320 | Point mouse_pos; | ||
| 7321 | FRAME_PTR *f; | ||
| 7339 | { | 7322 | { |
| 7340 | WindowPtr wp = FrontWindow (); | 7323 | WindowPtr wp = mac_front_window (); |
| 7341 | struct frame *f; | 7324 | struct x_display_info *dpyinfo; |
| 7342 | 7325 | ||
| 7343 | if (is_emacs_window (wp)) | 7326 | if (is_emacs_window (wp)) |
| 7344 | { | 7327 | { |
| 7345 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 7328 | *f = mac_window_to_frame (wp); |
| 7329 | dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); | ||
| 7346 | 7330 | ||
| 7347 | #if TARGET_API_MAC_CARBON | 7331 | if (dpyinfo->mouse_face_hidden) |
| 7348 | SetPort (GetWindowPort (wp)); | 7332 | { |
| 7349 | #else | 7333 | dpyinfo->mouse_face_hidden = 0; |
| 7350 | SetPort (wp); | 7334 | clear_mouse_face (dpyinfo); |
| 7351 | #endif | 7335 | } |
| 7352 | |||
| 7353 | GlobalToLocal (&mouse_pos); | ||
| 7354 | 7336 | ||
| 7355 | note_mouse_movement (f, &mouse_pos); | 7337 | SetPortWindowPort (wp); |
| 7356 | } | ||
| 7357 | } | ||
| 7358 | 7338 | ||
| 7339 | GlobalToLocal (&mouse_pos); | ||
| 7359 | 7340 | ||
| 7360 | static void | 7341 | if (dpyinfo->grabbed && tracked_scroll_bar) |
| 7361 | do_os_event (EventRecord *erp) | 7342 | x_scroll_bar_note_movement (tracked_scroll_bar, |
| 7362 | { | 7343 | mouse_pos.v |
| 7363 | switch((erp->message >> 24) & 0x000000FF) | 7344 | - XINT (tracked_scroll_bar->top), |
| 7364 | { | 7345 | TickCount() * (1000 / 60)); |
| 7365 | case suspendResumeMessage: | ||
| 7366 | if((erp->message & resumeFlag) == 1) | ||
| 7367 | do_app_resume (); | ||
| 7368 | else | 7346 | else |
| 7369 | do_app_suspend (); | 7347 | note_mouse_movement (*f, &mouse_pos); |
| 7370 | break; | ||
| 7371 | |||
| 7372 | case mouseMovedMessage: | ||
| 7373 | do_mouse_moved (erp->where); | ||
| 7374 | break; | ||
| 7375 | } | 7348 | } |
| 7376 | } | 7349 | } |
| 7377 | 7350 | ||
| 7378 | static void | ||
| 7379 | do_events (EventRecord *erp) | ||
| 7380 | { | ||
| 7381 | switch (erp->what) | ||
| 7382 | { | ||
| 7383 | case updateEvt: | ||
| 7384 | do_window_update ((WindowPtr) erp->message); | ||
| 7385 | break; | ||
| 7386 | |||
| 7387 | case osEvt: | ||
| 7388 | do_os_event (erp); | ||
| 7389 | break; | ||
| 7390 | |||
| 7391 | case activateEvt: | ||
| 7392 | if ((erp->modifiers & activeFlag) != 0) | ||
| 7393 | do_window_activate ((WindowPtr) erp->message); | ||
| 7394 | else | ||
| 7395 | do_window_deactivate ((WindowPtr) erp->message); | ||
| 7396 | break; | ||
| 7397 | } | ||
| 7398 | } | ||
| 7399 | 7351 | ||
| 7400 | static void | 7352 | static void |
| 7401 | do_apple_menu (SInt16 menu_item) | 7353 | do_apple_menu (SInt16 menu_item) |
| @@ -7433,8 +7385,7 @@ do_menu_choice (SInt32 menu_choice) | |||
| 7433 | 7385 | ||
| 7434 | default: | 7386 | default: |
| 7435 | { | 7387 | { |
| 7436 | WindowPtr wp = FrontWindow (); | 7388 | struct frame *f = mac_window_to_frame (mac_front_window ()); |
| 7437 | struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | ||
| 7438 | MenuHandle menu = GetMenuHandle (menu_id); | 7389 | MenuHandle menu = GetMenuHandle (menu_id); |
| 7439 | if (menu) | 7390 | if (menu) |
| 7440 | { | 7391 | { |
| @@ -7459,8 +7410,7 @@ do_grow_window (WindowPtr w, EventRecord *e) | |||
| 7459 | long grow_size; | 7410 | long grow_size; |
| 7460 | Rect limit_rect; | 7411 | Rect limit_rect; |
| 7461 | int rows, columns; | 7412 | int rows, columns; |
| 7462 | mac_output *mwp = (mac_output *) GetWRefCon (w); | 7413 | struct frame *f = mac_window_to_frame (w); |
| 7463 | struct frame *f = mwp->mFP; | ||
| 7464 | 7414 | ||
| 7465 | SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); | 7415 | SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); |
| 7466 | 7416 | ||
| @@ -7489,16 +7439,11 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7489 | Rect zoom_rect, port_rect; | 7439 | Rect zoom_rect, port_rect; |
| 7490 | Point top_left; | 7440 | Point top_left; |
| 7491 | int w_title_height, columns, rows, width, height, dummy, x, y; | 7441 | int w_title_height, columns, rows, width, height, dummy, x, y; |
| 7492 | mac_output *mwp = (mac_output *) GetWRefCon (w); | 7442 | struct frame *f = mac_window_to_frame (w); |
| 7493 | struct frame *f = mwp->mFP; | ||
| 7494 | 7443 | ||
| 7495 | GetPort (&save_port); | 7444 | GetPort (&save_port); |
| 7496 | 7445 | ||
| 7497 | #if TARGET_API_MAC_CARBON | 7446 | SetPortWindowPort (w); |
| 7498 | SetPort (GetWindowPort (w)); | ||
| 7499 | #else | ||
| 7500 | SetPort (w); | ||
| 7501 | #endif | ||
| 7502 | 7447 | ||
| 7503 | /* Clear window to avoid flicker. */ | 7448 | /* Clear window to avoid flicker. */ |
| 7504 | #if TARGET_API_MAC_CARBON | 7449 | #if TARGET_API_MAC_CARBON |
| @@ -7551,7 +7496,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7551 | } | 7496 | } |
| 7552 | #endif /* not TARGET_API_MAC_CARBON */ | 7497 | #endif /* not TARGET_API_MAC_CARBON */ |
| 7553 | 7498 | ||
| 7554 | ZoomWindow (w, zoom_in_or_out, w == FrontWindow ()); | 7499 | ZoomWindow (w, zoom_in_or_out, w == mac_front_window ()); |
| 7555 | 7500 | ||
| 7556 | /* retrieve window size and update application values */ | 7501 | /* retrieve window size and update application values */ |
| 7557 | #if TARGET_API_MAC_CARBON | 7502 | #if TARGET_API_MAC_CARBON |
| @@ -7561,7 +7506,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7561 | #endif | 7506 | #endif |
| 7562 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); | 7507 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); |
| 7563 | columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); | 7508 | columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); |
| 7564 | x_set_window_size (mwp->mFP, 0, columns, rows); | 7509 | x_set_window_size (f, 0, columns, rows); |
| 7565 | 7510 | ||
| 7566 | SetPort (save_port); | 7511 | SetPort (save_port); |
| 7567 | } | 7512 | } |
| @@ -7892,8 +7837,8 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | |||
| 7892 | { | 7837 | { |
| 7893 | struct input_event event; | 7838 | struct input_event event; |
| 7894 | Lisp_Object frame; | 7839 | Lisp_Object frame; |
| 7895 | struct frame *f = ((mac_output *) GetWRefCon(window))->mFP; | 7840 | struct frame *f = mac_window_to_frame (window); |
| 7896 | SetPort (GetWindowPort (window)); | 7841 | SetPortWindowPort (window); |
| 7897 | GlobalToLocal (&mouse); | 7842 | GlobalToLocal (&mouse); |
| 7898 | 7843 | ||
| 7899 | event.kind = DRAG_N_DROP_EVENT; | 7844 | event.kind = DRAG_N_DROP_EVENT; |
| @@ -8067,26 +8012,26 @@ keycode_to_xkeysym (int keyCode, int *xKeySym) | |||
| 8067 | /* Emacs calls this whenever it wants to read an input event from the | 8012 | /* Emacs calls this whenever it wants to read an input event from the |
| 8068 | user. */ | 8013 | user. */ |
| 8069 | int | 8014 | int |
| 8070 | XTread_socket (int sd, int expected, struct input_event *hold_quit) | 8015 | XTread_socket (sd, expected, hold_quit) |
| 8016 | int sd, expected; | ||
| 8017 | struct input_event *hold_quit; | ||
| 8071 | { | 8018 | { |
| 8072 | struct input_event inev; | 8019 | struct input_event inev; |
| 8073 | int count = 0; | 8020 | int count = 0; |
| 8074 | #if USE_CARBON_EVENTS | 8021 | #if USE_CARBON_EVENTS |
| 8075 | OSStatus rneResult; | ||
| 8076 | EventRef eventRef; | 8022 | EventRef eventRef; |
| 8077 | EventMouseButton mouseBtn; | 8023 | EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget (); |
| 8024 | #else | ||
| 8025 | EventMask event_mask; | ||
| 8078 | #endif | 8026 | #endif |
| 8079 | EventRecord er; | 8027 | EventRecord er; |
| 8080 | int the_modifiers; | 8028 | struct mac_display_info *dpyinfo = &one_mac_display_info; |
| 8081 | EventMask event_mask; | ||
| 8082 | 8029 | ||
| 8083 | #if 0 | ||
| 8084 | if (interrupt_input_blocked) | 8030 | if (interrupt_input_blocked) |
| 8085 | { | 8031 | { |
| 8086 | interrupt_input_pending = 1; | 8032 | interrupt_input_pending = 1; |
| 8087 | return -1; | 8033 | return -1; |
| 8088 | } | 8034 | } |
| 8089 | #endif | ||
| 8090 | 8035 | ||
| 8091 | interrupt_input_pending = 0; | 8036 | interrupt_input_pending = 0; |
| 8092 | BLOCK_INPUT; | 8037 | BLOCK_INPUT; |
| @@ -8108,26 +8053,33 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8108 | if (terminate_flag) | 8053 | if (terminate_flag) |
| 8109 | Fkill_emacs (make_number (1)); | 8054 | Fkill_emacs (make_number (1)); |
| 8110 | 8055 | ||
| 8111 | /* It is necessary to set this (additional) argument slot of an | 8056 | #if !USE_CARBON_EVENTS |
| 8112 | event to nil because keyboard.c protects incompletely processed | ||
| 8113 | event from being garbage collected by placing them in the | ||
| 8114 | kbd_buffer_gcpro vector. */ | ||
| 8115 | EVENT_INIT (inev); | ||
| 8116 | inev.kind = NO_EVENT; | ||
| 8117 | inev.arg = Qnil; | ||
| 8118 | |||
| 8119 | event_mask = everyEvent; | 8057 | event_mask = everyEvent; |
| 8120 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) | 8058 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) |
| 8121 | event_mask -= highLevelEventMask; | 8059 | event_mask -= highLevelEventMask; |
| 8122 | 8060 | ||
| 8123 | #if USE_CARBON_EVENTS | 8061 | while (WaitNextEvent (event_mask, &er, |
| 8124 | rneResult = ReceiveNextEvent (0, NULL, | 8062 | (expected ? app_sleep_time : 0L), NULL)) |
| 8125 | expected | 8063 | #else |
| 8126 | ? TicksToEventTime (app_sleep_time) | 8064 | while (!ReceiveNextEvent (0, NULL, |
| 8127 | : 0, | 8065 | (expected ? TicksToEventTime (app_sleep_time) : 0), |
| 8128 | kEventRemoveFromQueue, &eventRef); | 8066 | kEventRemoveFromQueue, &eventRef)) |
| 8129 | if (!rneResult) | 8067 | #endif /* !USE_CARBON_EVENTS */ |
| 8130 | { | 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 | ||
| 8131 | /* Handle new events */ | 8083 | /* Handle new events */ |
| 8132 | if (!mac_convert_event_ref (eventRef, &er)) | 8084 | if (!mac_convert_event_ref (eventRef, &er)) |
| 8133 | switch (GetEventClass (eventRef)) | 8085 | switch (GetEventClass (eventRef)) |
| @@ -8137,13 +8089,12 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8137 | { | 8089 | { |
| 8138 | SInt32 delta; | 8090 | SInt32 delta; |
| 8139 | Point point; | 8091 | Point point; |
| 8140 | WindowPtr window_ptr = FrontNonFloatingWindow (); | 8092 | WindowPtr window_ptr = mac_front_window (); |
| 8141 | struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 8093 | |
| 8142 | if (!IsValidWindowPtr (window_ptr)) | 8094 | if (!IsValidWindowPtr (window_ptr)) |
| 8143 | { | 8095 | { |
| 8144 | SysBeep(1); | 8096 | SysBeep(1); |
| 8145 | UNBLOCK_INPUT; | 8097 | break; |
| 8146 | return 0; | ||
| 8147 | } | 8098 | } |
| 8148 | 8099 | ||
| 8149 | GetEventParameter(eventRef, kEventParamMouseWheelDelta, | 8100 | GetEventParameter(eventRef, kEventParamMouseWheelDelta, |
| @@ -8154,459 +8105,557 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8154 | NULL, &point); | 8105 | NULL, &point); |
| 8155 | inev.kind = WHEEL_EVENT; | 8106 | inev.kind = WHEEL_EVENT; |
| 8156 | inev.code = 0; | 8107 | inev.code = 0; |
| 8157 | inev.modifiers = (mac_event_to_emacs_modifiers(eventRef) | 8108 | inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) |
| 8158 | | ((delta < 0) ? down_modifier | 8109 | | ((delta < 0) ? down_modifier |
| 8159 | : up_modifier)); | 8110 | : up_modifier)); |
| 8160 | SetPort (GetWindowPort (window_ptr)); | 8111 | SetPortWindowPort (window_ptr); |
| 8161 | GlobalToLocal (&point); | 8112 | GlobalToLocal (&point); |
| 8162 | XSETINT (inev.x, point.h); | 8113 | XSETINT (inev.x, point.h); |
| 8163 | XSETINT (inev.y, point.v); | 8114 | XSETINT (inev.y, point.v); |
| 8164 | XSETFRAME (inev.frame_or_window, mwp->mFP); | 8115 | XSETFRAME (inev.frame_or_window, |
| 8116 | mac_window_to_frame (window_ptr)); | ||
| 8165 | inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); | 8117 | inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); |
| 8166 | } | 8118 | } |
| 8167 | else | 8119 | else |
| 8168 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 8120 | SendEventToEventTarget (eventRef, toolbox_dispatcher); |
| 8169 | 8121 | ||
| 8170 | break; | 8122 | break; |
| 8171 | default: | 8123 | default: |
| 8172 | /* Send the event to the appropriate receiver. */ | 8124 | /* Send the event to the appropriate receiver. */ |
| 8173 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 8125 | SendEventToEventTarget (eventRef, toolbox_dispatcher); |
| 8174 | } | 8126 | } |
| 8175 | else | 8127 | else |
| 8176 | #else | ||
| 8177 | if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) | ||
| 8178 | #endif /* USE_CARBON_EVENTS */ | 8128 | #endif /* USE_CARBON_EVENTS */ |
| 8179 | switch (er.what) | 8129 | switch (er.what) |
| 8180 | { | ||
| 8181 | case mouseDown: | ||
| 8182 | case mouseUp: | ||
| 8183 | { | 8130 | { |
| 8184 | WindowPtr window_ptr = FrontWindow (); | 8131 | case mouseDown: |
| 8185 | SInt16 part_code; | 8132 | 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 | } | ||
| 8186 | 8152 | ||
| 8187 | #if USE_CARBON_EVENTS | 8153 | #if USE_CARBON_EVENTS |
| 8188 | /* This is needed to send mouse events like aqua window buttons | 8154 | /* This is needed to send mouse events like aqua |
| 8189 | to the correct handler. */ | 8155 | window buttons to the correct handler. */ |
| 8190 | if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { | 8156 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8191 | break; | 8157 | != eventNotHandledErr) |
| 8192 | } | 8158 | break; |
| 8193 | 8159 | ||
| 8194 | if (!is_emacs_window(window_ptr)) | 8160 | if (!is_emacs_window (window_ptr)) |
| 8195 | break; | 8161 | break; |
| 8196 | #endif | 8162 | #endif |
| 8163 | part_code = FindWindow (er.where, &window_ptr); | ||
| 8164 | } | ||
| 8165 | |||
| 8166 | switch (part_code) | ||
| 8167 | { | ||
| 8168 | case inMenuBar: | ||
| 8169 | if (er.what == mouseDown) | ||
| 8170 | { | ||
| 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; | ||
| 8197 | 8177 | ||
| 8198 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | 8178 | case inContent: |
| 8199 | && er.what == mouseUp) | 8179 | if (window_ptr != mac_front_window ()) |
| 8200 | { | 8180 | SelectWindow (window_ptr); |
| 8201 | struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 8181 | else |
| 8202 | Point mouse_loc = er.where; | 8182 | { |
| 8183 | SInt16 control_part_code; | ||
| 8184 | ControlHandle ch; | ||
| 8185 | Point mouse_loc = er.where; | ||
| 8186 | |||
| 8187 | f = mac_window_to_frame (window_ptr); | ||
| 8188 | /* convert to local coordinates of new window */ | ||
| 8189 | SetPortWindowPort (window_ptr); | ||
| 8203 | 8190 | ||
| 8204 | /* Convert to local coordinates of new window. */ | 8191 | GlobalToLocal (&mouse_loc); |
| 8205 | #if TARGET_API_MAC_CARBON | 8192 | #if TARGET_API_MAC_CARBON |
| 8206 | SetPort (GetWindowPort (window_ptr)); | 8193 | ch = FindControlUnderMouse (mouse_loc, window_ptr, |
| 8194 | &control_part_code); | ||
| 8207 | #else | 8195 | #else |
| 8208 | SetPort (window_ptr); | 8196 | control_part_code = FindControl (mouse_loc, window_ptr, |
| 8197 | &ch); | ||
| 8209 | #endif | 8198 | #endif |
| 8210 | 8199 | ||
| 8211 | GlobalToLocal (&mouse_loc); | ||
| 8212 | |||
| 8213 | #if USE_CARBON_EVENTS | 8200 | #if USE_CARBON_EVENTS |
| 8214 | inev.code = mac_get_mouse_btn (eventRef); | 8201 | inev.code = mac_get_mouse_btn (eventRef); |
| 8202 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | ||
| 8215 | #else | 8203 | #else |
| 8216 | inev.code = mac_get_emulate_btn (er.modifiers); | 8204 | inev.code = mac_get_emulated_btn (er.modifiers); |
| 8205 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | ||
| 8217 | #endif | 8206 | #endif |
| 8218 | inev.kind = SCROLL_BAR_CLICK_EVENT; | 8207 | XSETINT (inev.x, mouse_loc.h); |
| 8219 | inev.frame_or_window = tracked_scroll_bar->window; | 8208 | XSETINT (inev.y, mouse_loc.v); |
| 8220 | inev.part = scroll_bar_handle; | 8209 | inev.timestamp = er.when * (1000 / 60); |
| 8221 | #if USE_CARBON_EVENTS | 8210 | /* ticks to milliseconds */ |
| 8222 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8211 | |
| 8212 | if (dpyinfo->grabbed && tracked_scroll_bar | ||
| 8213 | #if TARGET_API_MAC_CARBON | ||
| 8214 | || ch != 0 | ||
| 8223 | #else | 8215 | #else |
| 8224 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8216 | || control_part_code != 0 |
| 8225 | #endif | 8217 | #endif |
| 8226 | inev.modifiers |= up_modifier; | 8218 | ) |
| 8227 | inev.timestamp = er.when * (1000 / 60); | 8219 | { |
| 8228 | /* ticks to milliseconds */ | 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; | ||
| 8229 | 8296 | ||
| 8230 | XSETINT (inev.x, XFASTINT (tracked_scroll_bar->left) + 2); | 8297 | case inDrag: |
| 8231 | XSETINT (inev.y, mouse_loc.v - 24); | 8298 | #if TARGET_API_MAC_CARBON |
| 8232 | tracked_scroll_bar->dragging = Qnil; | 8299 | if (er.what == mouseDown) |
| 8233 | mouse_tracking_in_progress = mouse_tracking_none; | 8300 | { |
| 8234 | tracked_scroll_bar = NULL; | 8301 | BitMap bm; |
| 8235 | break; | ||
| 8236 | } | ||
| 8237 | 8302 | ||
| 8238 | part_code = FindWindow (er.where, &window_ptr); | 8303 | GetQDGlobalsScreenBits (&bm); |
| 8304 | DragWindow (window_ptr, er.where, &bm.bounds); | ||
| 8305 | } | ||
| 8306 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 8307 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | ||
| 8308 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 8309 | break; | ||
| 8239 | 8310 | ||
| 8240 | switch (part_code) | 8311 | case inGoAway: |
| 8241 | { | 8312 | if (TrackGoAway (window_ptr, er.where)) |
| 8242 | case inMenuBar: | 8313 | { |
| 8243 | if (er.what == mouseDown) | 8314 | inev.kind = DELETE_WINDOW_EVENT; |
| 8244 | { | 8315 | XSETFRAME (inev.frame_or_window, |
| 8245 | struct frame *f = ((mac_output *) | 8316 | mac_window_to_frame (window_ptr)); |
| 8246 | GetWRefCon (FrontWindow ()))->mFP; | 8317 | } |
| 8247 | saved_menu_event_location = er.where; | 8318 | break; |
| 8248 | inev.kind = MENU_BAR_ACTIVATE_EVENT; | ||
| 8249 | XSETFRAME (inev.frame_or_window, f); | ||
| 8250 | } | ||
| 8251 | break; | ||
| 8252 | 8319 | ||
| 8253 | case inContent: | 8320 | /* window resize handling added --ben */ |
| 8254 | if (window_ptr != FrontWindow ()) | 8321 | case inGrow: |
| 8255 | SelectWindow (window_ptr); | 8322 | if (er.what == mouseDown) |
| 8256 | else | 8323 | { |
| 8257 | { | 8324 | do_grow_window(window_ptr, &er); |
| 8258 | SInt16 control_part_code; | 8325 | break; |
| 8259 | ControlHandle ch; | 8326 | } |
| 8260 | struct mac_output *mwp = (mac_output *) | ||
| 8261 | GetWRefCon (window_ptr); | ||
| 8262 | Point mouse_loc = er.where; | ||
| 8263 | |||
| 8264 | /* convert to local coordinates of new window */ | ||
| 8265 | #if TARGET_API_MAC_CARBON | ||
| 8266 | SetPort (GetWindowPort (window_ptr)); | ||
| 8267 | #else | ||
| 8268 | SetPort (window_ptr); | ||
| 8269 | #endif | ||
| 8270 | 8327 | ||
| 8271 | GlobalToLocal (&mouse_loc); | 8328 | /* window zoom handling added --ben */ |
| 8272 | #if TARGET_API_MAC_CARBON | 8329 | case inZoomIn: |
| 8273 | ch = FindControlUnderMouse (mouse_loc, window_ptr, | 8330 | case inZoomOut: |
| 8274 | &control_part_code); | 8331 | if (TrackBox (window_ptr, er.where, part_code)) |
| 8275 | #else | 8332 | do_zoom_window (window_ptr, part_code); |
| 8276 | control_part_code = FindControl (mouse_loc, window_ptr, &ch); | 8333 | break; |
| 8277 | #endif | ||
| 8278 | 8334 | ||
| 8279 | #if USE_CARBON_EVENTS | 8335 | default: |
| 8280 | inev.code = mac_get_mouse_btn (eventRef); | 8336 | break; |
| 8281 | #else | 8337 | } |
| 8282 | inev.code = mac_get_emulate_btn (er.modifiers); | 8338 | } |
| 8283 | #endif | 8339 | break; |
| 8284 | XSETINT (inev.x, mouse_loc.h); | ||
| 8285 | XSETINT (inev.y, mouse_loc.v); | ||
| 8286 | inev.timestamp = er.when * (1000 / 60); | ||
| 8287 | /* ticks to milliseconds */ | ||
| 8288 | 8340 | ||
| 8289 | #if TARGET_API_MAC_CARBON | 8341 | case updateEvt: |
| 8290 | if (ch != 0) | ||
| 8291 | #else | ||
| 8292 | if (control_part_code != 0) | ||
| 8293 | #endif | ||
| 8294 | { | ||
| 8295 | struct scroll_bar *bar = (struct scroll_bar *) | ||
| 8296 | GetControlReference (ch); | ||
| 8297 | x_scroll_bar_handle_click (bar, control_part_code, &er, | ||
| 8298 | &inev); | ||
| 8299 | if (er.what == mouseDown | ||
| 8300 | && control_part_code == kControlIndicatorPart) | ||
| 8301 | { | ||
| 8302 | mouse_tracking_in_progress | ||
| 8303 | = mouse_tracking_scroll_bar; | ||
| 8304 | tracked_scroll_bar = bar; | ||
| 8305 | } | ||
| 8306 | else | ||
| 8307 | { | ||
| 8308 | mouse_tracking_in_progress = mouse_tracking_none; | ||
| 8309 | tracked_scroll_bar = NULL; | ||
| 8310 | } | ||
| 8311 | } | ||
| 8312 | else | ||
| 8313 | { | ||
| 8314 | Lisp_Object window; | ||
| 8315 | int x = mouse_loc.h; | ||
| 8316 | int y = mouse_loc.v; | ||
| 8317 | |||
| 8318 | XSETFRAME (inev.frame_or_window, mwp->mFP); | ||
| 8319 | if (er.what == mouseDown) | ||
| 8320 | mouse_tracking_in_progress | ||
| 8321 | = mouse_tracking_mouse_movement; | ||
| 8322 | else | ||
| 8323 | mouse_tracking_in_progress = mouse_tracking_none; | ||
| 8324 | window = window_from_coordinates (mwp->mFP, x, y, 0, 0, 0, 1); | ||
| 8325 | |||
| 8326 | if (EQ (window, mwp->mFP->tool_bar_window)) | ||
| 8327 | { | ||
| 8328 | if (er.what == mouseDown) | ||
| 8329 | handle_tool_bar_click (mwp->mFP, x, y, 1, 0); | ||
| 8330 | else | ||
| 8331 | handle_tool_bar_click (mwp->mFP, x, y, 0, | ||
| 8332 | #if USE_CARBON_EVENTS | 8342 | #if USE_CARBON_EVENTS |
| 8333 | mac_event_to_emacs_modifiers (eventRef) | 8343 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8334 | #else | 8344 | != eventNotHandledErr) |
| 8335 | er.modifiers | 8345 | break; |
| 8336 | #endif | 8346 | #endif |
| 8337 | ); | 8347 | do_window_update ((WindowPtr) er.message); |
| 8338 | break; | 8348 | break; |
| 8339 | } | ||
| 8340 | else | ||
| 8341 | inev.kind = MOUSE_CLICK_EVENT; | ||
| 8342 | } | ||
| 8343 | 8349 | ||
| 8350 | case osEvt: | ||
| 8344 | #if USE_CARBON_EVENTS | 8351 | #if USE_CARBON_EVENTS |
| 8345 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8352 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8346 | #else | 8353 | != eventNotHandledErr) |
| 8347 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8354 | break; |
| 8348 | #endif | 8355 | #endif |
| 8349 | 8356 | switch ((er.message >> 24) & 0x000000FF) | |
| 8350 | switch (er.what) | 8357 | { |
| 8351 | { | 8358 | case suspendResumeMessage: |
| 8352 | case mouseDown: | 8359 | if ((er.message & resumeFlag) == 1) |
| 8353 | inev.modifiers |= down_modifier; | 8360 | do_app_resume (); |
| 8354 | break; | 8361 | else |
| 8355 | case mouseUp: | 8362 | do_app_suspend (); |
| 8356 | inev.modifiers |= up_modifier; | ||
| 8357 | break; | ||
| 8358 | } | ||
| 8359 | } | ||
| 8360 | break; | 8363 | break; |
| 8361 | 8364 | ||
| 8362 | case inDrag: | 8365 | case mouseMovedMessage: |
| 8363 | #if TARGET_API_MAC_CARBON | 8366 | previous_help_echo_string = help_echo_string; |
| 8364 | if (er.what == mouseDown) | 8367 | help_echo_string = help_echo_object = help_echo_window = Qnil; |
| 8365 | { | 8368 | help_echo_pos = -1; |
| 8366 | BitMap bm; | ||
| 8367 | 8369 | ||
| 8368 | GetQDGlobalsScreenBits (&bm); | 8370 | do_mouse_moved (er.where, &f); |
| 8369 | DragWindow (window_ptr, er.where, &bm.bounds); | ||
| 8370 | } | ||
| 8371 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 8372 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | ||
| 8373 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 8374 | break; | ||
| 8375 | 8371 | ||
| 8376 | case inGoAway: | 8372 | /* If the contents of the global variable |
| 8377 | if (TrackGoAway (window_ptr, er.where)) | 8373 | help_echo_string has changed, generate a |
| 8378 | { | 8374 | HELP_EVENT. */ |
| 8379 | inev.kind = DELETE_WINDOW_EVENT; | 8375 | if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) |
| 8380 | XSETFRAME (inev.frame_or_window, | 8376 | do_help = 1; |
| 8381 | ((mac_output *) GetWRefCon (window_ptr))->mFP); | ||
| 8382 | } | ||
| 8383 | break; | ||
| 8384 | |||
| 8385 | /* window resize handling added --ben */ | ||
| 8386 | case inGrow: | ||
| 8387 | if (er.what == mouseDown) | ||
| 8388 | { | ||
| 8389 | do_grow_window(window_ptr, &er); | ||
| 8390 | break; | ||
| 8391 | } | ||
| 8392 | |||
| 8393 | /* window zoom handling added --ben */ | ||
| 8394 | case inZoomIn: | ||
| 8395 | case inZoomOut: | ||
| 8396 | if (TrackBox (window_ptr, er.where, part_code)) | ||
| 8397 | do_zoom_window (window_ptr, part_code); | ||
| 8398 | break; | ||
| 8399 | |||
| 8400 | default: | ||
| 8401 | break; | 8377 | break; |
| 8402 | } | 8378 | } |
| 8403 | } | 8379 | break; |
| 8404 | break; | 8380 | |
| 8381 | case activateEvt: | ||
| 8382 | { | ||
| 8383 | WindowPtr window_ptr = (WindowPtr) er.message; | ||
| 8405 | 8384 | ||
| 8406 | case updateEvt: | ||
| 8407 | case osEvt: | ||
| 8408 | case activateEvt: | ||
| 8409 | #if USE_CARBON_EVENTS | 8385 | #if USE_CARBON_EVENTS |
| 8410 | if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) | 8386 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8387 | != eventNotHandledErr) | ||
| 8388 | break; | ||
| 8411 | #endif | 8389 | #endif |
| 8412 | do_events (&er); | 8390 | if (window_ptr == tip_window) |
| 8413 | break; | 8391 | { |
| 8392 | HideWindow (tip_window); | ||
| 8393 | break; | ||
| 8394 | } | ||
| 8414 | 8395 | ||
| 8415 | case keyDown: | 8396 | if ((er.modifiers & activeFlag) != 0) |
| 8416 | case autoKey: | 8397 | { |
| 8417 | { | 8398 | Point mouse_loc = er.where; |
| 8418 | int keycode = (er.message & keyCodeMask) >> 8; | ||
| 8419 | int xkeysym; | ||
| 8420 | 8399 | ||
| 8421 | #if USE_CARBON_EVENTS | 8400 | do_window_activate (window_ptr); |
| 8422 | /* When using Carbon Events, we need to pass raw keyboard events | ||
| 8423 | to the TSM ourselves. If TSM handles it, it will pass back | ||
| 8424 | noErr, otherwise it will pass back "eventNotHandledErr" and | ||
| 8425 | we can process it normally. */ | ||
| 8426 | if ((!NILP (Vmac_pass_command_to_system) | ||
| 8427 | || !(er.modifiers & cmdKey)) | ||
| 8428 | && (!NILP (Vmac_pass_control_to_system) | ||
| 8429 | || !(er.modifiers & controlKey))) | ||
| 8430 | { | ||
| 8431 | OSStatus err; | ||
| 8432 | err = SendEventToEventTarget (eventRef, | ||
| 8433 | GetEventDispatcherTarget ()); | ||
| 8434 | if (err != eventNotHandledErr) | ||
| 8435 | break; | ||
| 8436 | } | ||
| 8437 | #endif | ||
| 8438 | 8401 | ||
| 8439 | if (!IsValidWindowPtr (FrontNonFloatingWindow ())) | 8402 | SetPortWindowPort (window_ptr); |
| 8440 | { | 8403 | GlobalToLocal (&mouse_loc); |
| 8441 | SysBeep (1); | 8404 | /* activateEvt counts as mouse movement, |
| 8442 | UNBLOCK_INPUT; | 8405 | so update things that depend on mouse position. */ |
| 8443 | return 0; | 8406 | note_mouse_movement (mac_window_to_frame (window_ptr), |
| 8444 | } | 8407 | &mouse_loc); |
| 8408 | } | ||
| 8409 | else | ||
| 8410 | { | ||
| 8411 | do_window_deactivate (window_ptr); | ||
| 8445 | 8412 | ||
| 8446 | ObscureCursor (); | 8413 | f = mac_window_to_frame (window_ptr); |
| 8414 | if (f == dpyinfo->mouse_face_mouse_frame) | ||
| 8415 | { | ||
| 8416 | /* If we move outside the frame, then we're | ||
| 8417 | certainly no longer on any text in the | ||
| 8418 | frame. */ | ||
| 8419 | clear_mouse_face (dpyinfo); | ||
| 8420 | dpyinfo->mouse_face_mouse_frame = 0; | ||
| 8421 | } | ||
| 8447 | 8422 | ||
| 8448 | if (keycode_to_xkeysym (keycode, &xkeysym)) | 8423 | /* Generate a nil HELP_EVENT to cancel a help-echo. |
| 8449 | { | 8424 | Do it only if there's something to cancel. |
| 8450 | inev.code = 0xff00 | xkeysym; | 8425 | Otherwise, the startup message is cleared when the |
| 8451 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; | 8426 | mouse leaves the frame. */ |
| 8452 | } | 8427 | if (any_help_event_p) |
| 8453 | else | 8428 | do_help = -1; |
| 8454 | { | 8429 | } |
| 8455 | if (er.modifiers & (controlKey | | 8430 | } |
| 8456 | (NILP (Vmac_command_key_is_meta) ? optionKey | 8431 | break; |
| 8457 | : cmdKey))) | ||
| 8458 | { | ||
| 8459 | /* This code comes from Keyboard Resource, Appendix | ||
| 8460 | C of IM - Text. This is necessary since shift is | ||
| 8461 | ignored in KCHR table translation when option or | ||
| 8462 | command is pressed. It also does not translate | ||
| 8463 | correctly control-shift chars like C-% so mask off | ||
| 8464 | shift here also */ | ||
| 8465 | int new_modifiers = er.modifiers & 0xe600; | ||
| 8466 | /* mask off option and command */ | ||
| 8467 | int new_keycode = keycode | new_modifiers; | ||
| 8468 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | ||
| 8469 | unsigned long some_state = 0; | ||
| 8470 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | ||
| 8471 | &some_state) & 0xff; | ||
| 8472 | } | ||
| 8473 | else | ||
| 8474 | inev.code = er.message & charCodeMask; | ||
| 8475 | inev.kind = ASCII_KEYSTROKE_EVENT; | ||
| 8476 | } | ||
| 8477 | } | ||
| 8478 | 8432 | ||
| 8479 | /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil, | 8433 | case keyDown: |
| 8480 | convert non-ASCII characters typed at the Mac keyboard | 8434 | case autoKey: |
| 8481 | (presumed to be in the Mac Roman encoding) to iso-latin-1 | ||
| 8482 | encoding before they are passed to Emacs. This enables the | ||
| 8483 | Mac keyboard to be used to enter non-ASCII iso-latin-1 | ||
| 8484 | characters directly. */ | ||
| 8485 | if (mac_keyboard_text_encoding != kTextEncodingMacRoman | ||
| 8486 | && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128) | ||
| 8487 | { | 8435 | { |
| 8488 | static TECObjectRef converter = NULL; | 8436 | int keycode = (er.message & keyCodeMask) >> 8; |
| 8489 | OSStatus the_err = noErr; | 8437 | int xkeysym; |
| 8490 | OSStatus convert_status = noErr; | ||
| 8491 | 8438 | ||
| 8492 | if (converter == NULL) | 8439 | #if USE_CARBON_EVENTS |
| 8440 | /* When using Carbon Events, we need to pass raw keyboard | ||
| 8441 | events to the TSM ourselves. If TSM handles it, it | ||
| 8442 | will pass back noErr, otherwise it will pass back | ||
| 8443 | "eventNotHandledErr" and we can process it | ||
| 8444 | normally. */ | ||
| 8445 | if ((!NILP (Vmac_pass_command_to_system) | ||
| 8446 | || !(er.modifiers & cmdKey)) | ||
| 8447 | && (!NILP (Vmac_pass_control_to_system) | ||
| 8448 | || !(er.modifiers & controlKey))) | ||
| 8449 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | ||
| 8450 | != eventNotHandledErr) | ||
| 8451 | break; | ||
| 8452 | #endif | ||
| 8453 | |||
| 8454 | #if TARGET_API_MAC_CARBON | ||
| 8455 | if (!IsValidWindowPtr (mac_front_window ())) | ||
| 8493 | { | 8456 | { |
| 8494 | the_err = TECCreateConverter (&converter, | 8457 | SysBeep (1); |
| 8495 | kTextEncodingMacRoman, | 8458 | break; |
| 8496 | mac_keyboard_text_encoding); | ||
| 8497 | current_mac_keyboard_text_encoding | ||
| 8498 | = mac_keyboard_text_encoding; | ||
| 8499 | } | 8459 | } |
| 8500 | else if (mac_keyboard_text_encoding | 8460 | #endif |
| 8501 | != current_mac_keyboard_text_encoding) | 8461 | |
| 8462 | ObscureCursor (); | ||
| 8463 | |||
| 8464 | if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) | ||
| 8502 | { | 8465 | { |
| 8503 | /* Free the converter for the current encoding before | 8466 | clear_mouse_face (dpyinfo); |
| 8504 | creating a new one. */ | 8467 | dpyinfo->mouse_face_hidden = 1; |
| 8505 | TECDisposeConverter (converter); | ||
| 8506 | the_err = TECCreateConverter (&converter, | ||
| 8507 | kTextEncodingMacRoman, | ||
| 8508 | mac_keyboard_text_encoding); | ||
| 8509 | current_mac_keyboard_text_encoding | ||
| 8510 | = mac_keyboard_text_encoding; | ||
| 8511 | } | 8468 | } |
| 8512 | 8469 | ||
| 8513 | if (the_err == noErr) | 8470 | if (keycode_to_xkeysym (keycode, &xkeysym)) |
| 8514 | { | 8471 | { |
| 8515 | unsigned char ch = inev.code; | 8472 | inev.code = 0xff00 | xkeysym; |
| 8516 | ByteCount actual_input_length, actual_output_length; | 8473 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; |
| 8517 | unsigned char outch; | 8474 | } |
| 8518 | 8475 | else | |
| 8519 | convert_status = TECConvertText (converter, &ch, 1, | 8476 | { |
| 8520 | &actual_input_length, | 8477 | if (er.modifiers & (controlKey | |
| 8521 | &outch, 1, | 8478 | (NILP (Vmac_command_key_is_meta) ? optionKey |
| 8522 | &actual_output_length); | 8479 | : cmdKey))) |
| 8523 | if (convert_status == noErr | 8480 | { |
| 8524 | && actual_input_length == 1 | 8481 | /* This code comes from Keyboard Resource, |
| 8525 | && actual_output_length == 1) | 8482 | Appendix C of IM - Text. This is necessary |
| 8526 | inev.code = outch; | 8483 | since shift is ignored in KCHR table |
| 8484 | translation when option or command is pressed. | ||
| 8485 | It also does not translate correctly | ||
| 8486 | control-shift chars like C-% so mask off shift | ||
| 8487 | here also */ | ||
| 8488 | 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; | ||
| 8527 | } | 8499 | } |
| 8528 | } | 8500 | } |
| 8529 | 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 | |||
| 8530 | #if USE_CARBON_EVENTS | 8553 | #if USE_CARBON_EVENTS |
| 8531 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8554 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
| 8532 | #else | 8555 | #else |
| 8533 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8556 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 8534 | #endif | 8557 | #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; | ||
| 8535 | 8562 | ||
| 8536 | { | 8563 | case kHighLevelEvent: |
| 8537 | mac_output *mwp | 8564 | drag_and_drop_file_list = Qnil; |
| 8538 | = (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); | ||
| 8539 | XSETFRAME (inev.frame_or_window, mwp->mFP); | ||
| 8540 | } | ||
| 8541 | |||
| 8542 | inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ | ||
| 8543 | break; | ||
| 8544 | |||
| 8545 | case kHighLevelEvent: | ||
| 8546 | drag_and_drop_file_list = Qnil; | ||
| 8547 | 8565 | ||
| 8548 | AEProcessAppleEvent(&er); | 8566 | AEProcessAppleEvent(&er); |
| 8549 | 8567 | ||
| 8550 | /* Build a DRAG_N_DROP_EVENT type event as is done in | 8568 | /* Build a DRAG_N_DROP_EVENT type event as is done in |
| 8551 | constuct_drag_n_drop in w32term.c. */ | 8569 | constuct_drag_n_drop in w32term.c. */ |
| 8552 | if (!NILP (drag_and_drop_file_list)) | 8570 | if (!NILP (drag_and_drop_file_list)) |
| 8553 | { | 8571 | { |
| 8554 | struct frame *f = NULL; | 8572 | struct frame *f = NULL; |
| 8555 | WindowPtr wp; | 8573 | WindowPtr wp; |
| 8556 | Lisp_Object frame; | 8574 | Lisp_Object frame; |
| 8557 | 8575 | ||
| 8558 | wp = FrontNonFloatingWindow (); | 8576 | wp = mac_front_window (); |
| 8559 | 8577 | ||
| 8560 | if (!wp) | 8578 | if (!wp) |
| 8561 | { | 8579 | { |
| 8562 | struct frame *f = XFRAME (XCAR (Vframe_list)); | 8580 | struct frame *f = XFRAME (XCAR (Vframe_list)); |
| 8563 | CollapseWindow (FRAME_MAC_WINDOW (f), false); | 8581 | CollapseWindow (FRAME_MAC_WINDOW (f), false); |
| 8564 | wp = FrontNonFloatingWindow (); | 8582 | wp = mac_front_window (); |
| 8565 | } | 8583 | } |
| 8566 | 8584 | ||
| 8567 | if (wp && is_emacs_window(wp)) | 8585 | if (wp && is_emacs_window (wp)) |
| 8568 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 8586 | f = mac_window_to_frame (wp); |
| 8569 | 8587 | ||
| 8570 | inev.kind = DRAG_N_DROP_EVENT; | 8588 | inev.kind = DRAG_N_DROP_EVENT; |
| 8571 | inev.code = 0; | 8589 | inev.code = 0; |
| 8572 | inev.timestamp = er.when * (1000 / 60); | 8590 | inev.timestamp = er.when * (1000 / 60); |
| 8573 | /* ticks to milliseconds */ | 8591 | /* ticks to milliseconds */ |
| 8574 | #if USE_CARBON_EVENTS | 8592 | #if USE_CARBON_EVENTS |
| 8575 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8593 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
| 8576 | #else | 8594 | #else |
| 8577 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8595 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 8578 | #endif | 8596 | #endif |
| 8579 | 8597 | ||
| 8580 | XSETINT (inev.x, 0); | 8598 | XSETINT (inev.x, 0); |
| 8581 | XSETINT (inev.y, 0); | 8599 | XSETINT (inev.y, 0); |
| 8582 | 8600 | ||
| 8583 | XSETFRAME (frame, f); | 8601 | XSETFRAME (frame, f); |
| 8584 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); | 8602 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); |
| 8585 | 8603 | ||
| 8586 | /* Regardless of whether Emacs was suspended or in the | 8604 | /* Regardless of whether Emacs was suspended or in the |
| 8587 | foreground, ask it to redraw its entire screen. | 8605 | foreground, ask it to redraw its entire screen. |
| 8588 | Otherwise parts of the screen can be left in an | 8606 | Otherwise parts of the screen can be left in an |
| 8589 | inconsistent state. */ | 8607 | inconsistent state. */ |
| 8590 | if (wp) | 8608 | if (wp) |
| 8591 | #if TARGET_API_MAC_CARBON | 8609 | #if TARGET_API_MAC_CARBON |
| 8592 | { | 8610 | { |
| 8593 | Rect r; | 8611 | Rect r; |
| 8594 | 8612 | ||
| 8595 | GetWindowPortBounds (wp, &r); | 8613 | GetWindowPortBounds (wp, &r); |
| 8596 | InvalWindowRect (wp, &r); | 8614 | InvalWindowRect (wp, &r); |
| 8597 | } | 8615 | } |
| 8598 | #else /* not TARGET_API_MAC_CARBON */ | 8616 | #else /* not TARGET_API_MAC_CARBON */ |
| 8599 | InvalRect (&(wp->portRect)); | 8617 | InvalRect (&(wp->portRect)); |
| 8600 | #endif /* not TARGET_API_MAC_CARBON */ | 8618 | #endif /* not TARGET_API_MAC_CARBON */ |
| 8601 | } | 8619 | } |
| 8602 | default: | 8620 | default: |
| 8603 | break; | 8621 | break; |
| 8604 | } | 8622 | } |
| 8605 | #if USE_CARBON_EVENTS | 8623 | #if USE_CARBON_EVENTS |
| 8606 | ReleaseEvent (eventRef); | 8624 | ReleaseEvent (eventRef); |
| 8607 | } | ||
| 8608 | #endif | 8625 | #endif |
| 8609 | 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 | |||
| 8610 | /* If the focus was just given to an autoraising frame, | 8659 | /* If the focus was just given to an autoraising frame, |
| 8611 | raise it now. */ | 8660 | raise it now. */ |
| 8612 | /* ??? This ought to be able to handle more than one such frame. */ | 8661 | /* ??? This ought to be able to handle more than one such frame. */ |
| @@ -8620,58 +8669,6 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8620 | check_alarm (); /* simulate the handling of a SIGALRM */ | 8669 | check_alarm (); /* simulate the handling of a SIGALRM */ |
| 8621 | #endif | 8670 | #endif |
| 8622 | 8671 | ||
| 8623 | { | ||
| 8624 | static Point old_mouse_pos = { -1, -1 }; | ||
| 8625 | |||
| 8626 | if (app_is_suspended) | ||
| 8627 | { | ||
| 8628 | old_mouse_pos.h = -1; | ||
| 8629 | old_mouse_pos.v = -1; | ||
| 8630 | } | ||
| 8631 | else | ||
| 8632 | { | ||
| 8633 | Point mouse_pos; | ||
| 8634 | WindowPtr wp; | ||
| 8635 | struct frame *f; | ||
| 8636 | Lisp_Object bar; | ||
| 8637 | struct scroll_bar *sb; | ||
| 8638 | |||
| 8639 | wp = FrontWindow (); | ||
| 8640 | if (is_emacs_window (wp)) | ||
| 8641 | { | ||
| 8642 | f = ((mac_output *) GetWRefCon (wp))->mFP; | ||
| 8643 | |||
| 8644 | #if TARGET_API_MAC_CARBON | ||
| 8645 | SetPort (GetWindowPort (wp)); | ||
| 8646 | #else | ||
| 8647 | SetPort (wp); | ||
| 8648 | #endif | ||
| 8649 | |||
| 8650 | GetMouse (&mouse_pos); | ||
| 8651 | |||
| 8652 | if (!EqualPt (mouse_pos, old_mouse_pos)) | ||
| 8653 | { | ||
| 8654 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | ||
| 8655 | && tracked_scroll_bar) | ||
| 8656 | x_scroll_bar_note_movement (tracked_scroll_bar, | ||
| 8657 | mouse_pos.v | ||
| 8658 | - XINT (tracked_scroll_bar->top), | ||
| 8659 | TickCount() * (1000 / 60)); | ||
| 8660 | else | ||
| 8661 | note_mouse_movement (f, &mouse_pos); | ||
| 8662 | |||
| 8663 | old_mouse_pos = mouse_pos; | ||
| 8664 | } | ||
| 8665 | } | ||
| 8666 | } | ||
| 8667 | } | ||
| 8668 | |||
| 8669 | if (inev.kind != NO_EVENT) | ||
| 8670 | { | ||
| 8671 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 8672 | count++; | ||
| 8673 | } | ||
| 8674 | |||
| 8675 | UNBLOCK_INPUT; | 8672 | UNBLOCK_INPUT; |
| 8676 | return count; | 8673 | return count; |
| 8677 | } | 8674 | } |
| @@ -8700,7 +8697,7 @@ __convert_from_newlines (unsigned char * p, size_t * n) | |||
| 8700 | ROWS Macintosh window, using font with name FONTNAME and size | 8697 | ROWS Macintosh window, using font with name FONTNAME and size |
| 8701 | FONTSIZE. */ | 8698 | FONTSIZE. */ |
| 8702 | void | 8699 | void |
| 8703 | NewMacWindow (FRAME_PTR fp) | 8700 | make_mac_frame (FRAME_PTR fp) |
| 8704 | { | 8701 | { |
| 8705 | mac_output *mwp; | 8702 | mac_output *mwp; |
| 8706 | #if TARGET_API_MAC_CARBON | 8703 | #if TARGET_API_MAC_CARBON |
| @@ -8719,33 +8716,52 @@ NewMacWindow (FRAME_PTR fp) | |||
| 8719 | making_terminal_window = 0; | 8716 | making_terminal_window = 0; |
| 8720 | } | 8717 | } |
| 8721 | else | 8718 | else |
| 8722 | if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) | 8719 | { |
| 8723 | abort (); | 8720 | #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 | } | ||
| 8724 | 8733 | ||
| 8725 | SetWRefCon (mwp->mWP, (long) mwp); | 8734 | SetWRefCon (mwp->mWP, (long) mwp); |
| 8726 | /* so that update events can find this mac_output struct */ | 8735 | /* so that update events can find this mac_output struct */ |
| 8727 | mwp->mFP = fp; /* point back to emacs frame */ | 8736 | mwp->mFP = fp; /* point back to emacs frame */ |
| 8728 | 8737 | ||
| 8729 | #if TARGET_API_MAC_CARBON | 8738 | SetPortWindowPort (mwp->mWP); |
| 8730 | SetPort (GetWindowPort (mwp->mWP)); | ||
| 8731 | #else | ||
| 8732 | SetPort (mwp->mWP); | ||
| 8733 | #endif | ||
| 8734 | |||
| 8735 | mwp->fontset = -1; | ||
| 8736 | 8739 | ||
| 8737 | SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); | 8740 | SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); |
| 8738 | ShowWindow (mwp->mWP); | ||
| 8739 | |||
| 8740 | } | 8741 | } |
| 8741 | 8742 | ||
| 8742 | 8743 | ||
| 8743 | void | 8744 | void |
| 8744 | make_mac_frame (struct frame *f) | 8745 | make_mac_terminal_frame (struct frame *f) |
| 8745 | { | 8746 | { |
| 8746 | FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; | 8747 | 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); | ||
| 8747 | 8757 | ||
| 8748 | NewMacWindow(f); | 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 | FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; | ||
| 8749 | 8765 | ||
| 8750 | f->output_data.mac->cursor_pixel = 0; | 8766 | f->output_data.mac->cursor_pixel = 0; |
| 8751 | f->output_data.mac->border_pixel = 0x00ff00; | 8767 | f->output_data.mac->border_pixel = 0x00ff00; |
| @@ -8753,8 +8769,6 @@ make_mac_frame (struct frame *f) | |||
| 8753 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; | 8769 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; |
| 8754 | 8770 | ||
| 8755 | FRAME_FONTSET (f) = -1; | 8771 | FRAME_FONTSET (f) = -1; |
| 8756 | f->output_data.mac->scroll_bar_foreground_pixel = -1; | ||
| 8757 | f->output_data.mac->scroll_bar_background_pixel = -1; | ||
| 8758 | f->output_data.mac->explicit_parent = 0; | 8772 | f->output_data.mac->explicit_parent = 0; |
| 8759 | f->left_pos = 4; | 8773 | f->left_pos = 4; |
| 8760 | f->top_pos = 4; | 8774 | f->top_pos = 4; |
| @@ -8762,37 +8776,11 @@ make_mac_frame (struct frame *f) | |||
| 8762 | 8776 | ||
| 8763 | f->internal_border_width = 0; | 8777 | f->internal_border_width = 0; |
| 8764 | 8778 | ||
| 8765 | f->output_method = output_mac; | ||
| 8766 | |||
| 8767 | f->auto_raise = 1; | 8779 | f->auto_raise = 1; |
| 8768 | f->auto_lower = 1; | 8780 | f->auto_lower = 1; |
| 8769 | 8781 | ||
| 8770 | f->new_text_cols = 0; | 8782 | f->new_text_cols = 0; |
| 8771 | f->new_text_lines = 0; | 8783 | f->new_text_lines = 0; |
| 8772 | } | ||
| 8773 | |||
| 8774 | void | ||
| 8775 | make_mac_terminal_frame (struct frame *f) | ||
| 8776 | { | ||
| 8777 | Lisp_Object frame; | ||
| 8778 | |||
| 8779 | XSETFRAME (frame, f); | ||
| 8780 | |||
| 8781 | f->output_method = output_mac; | ||
| 8782 | f->output_data.mac = (struct mac_output *) | ||
| 8783 | xmalloc (sizeof (struct mac_output)); | ||
| 8784 | bzero (f->output_data.mac, sizeof (struct mac_output)); | ||
| 8785 | FRAME_FONTSET (f) = -1; | ||
| 8786 | f->output_data.mac->scroll_bar_foreground_pixel = -1; | ||
| 8787 | f->output_data.mac->scroll_bar_background_pixel = -1; | ||
| 8788 | |||
| 8789 | XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f); | ||
| 8790 | |||
| 8791 | FRAME_COLS (f) = 96; | ||
| 8792 | FRAME_LINES (f) = 4; | ||
| 8793 | |||
| 8794 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; | ||
| 8795 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right; | ||
| 8796 | 8784 | ||
| 8797 | make_mac_frame (f); | 8785 | make_mac_frame (f); |
| 8798 | 8786 | ||
| @@ -8810,6 +8798,8 @@ make_mac_terminal_frame (struct frame *f) | |||
| 8810 | Fmodify_frame_parameters (frame, | 8798 | Fmodify_frame_parameters (frame, |
| 8811 | Fcons (Fcons (Qbackground_color, | 8799 | Fcons (Fcons (Qbackground_color, |
| 8812 | build_string ("white")), Qnil)); | 8800 | build_string ("white")), Qnil)); |
| 8801 | |||
| 8802 | ShowWindow (f->output_data.mac->mWP); | ||
| 8813 | } | 8803 | } |
| 8814 | 8804 | ||
| 8815 | 8805 | ||
| @@ -8864,6 +8854,8 @@ mac_initialize_display_info () | |||
| 8864 | dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; | 8854 | dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; |
| 8865 | dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; | 8855 | dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; |
| 8866 | dpyinfo->mouse_face_window = Qnil; | 8856 | dpyinfo->mouse_face_window = Qnil; |
| 8857 | dpyinfo->mouse_face_overlay = Qnil; | ||
| 8858 | dpyinfo->mouse_face_hidden = 0; | ||
| 8867 | } | 8859 | } |
| 8868 | 8860 | ||
| 8869 | struct mac_display_info * | 8861 | struct mac_display_info * |
| @@ -9020,8 +9012,7 @@ mac_check_for_quit_char () | |||
| 9020 | if (event) | 9012 | if (event) |
| 9021 | { | 9013 | { |
| 9022 | struct input_event e; | 9014 | struct input_event e; |
| 9023 | struct mac_output *mwp = | 9015 | |
| 9024 | (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); | ||
| 9025 | /* Use an input_event to emulate what the interrupt handler does. */ | 9016 | /* Use an input_event to emulate what the interrupt handler does. */ |
| 9026 | EVENT_INIT (e); | 9017 | EVENT_INIT (e); |
| 9027 | e.kind = ASCII_KEYSTROKE_EVENT; | 9018 | e.kind = ASCII_KEYSTROKE_EVENT; |
| @@ -9029,7 +9020,7 @@ mac_check_for_quit_char () | |||
| 9029 | e.arg = Qnil; | 9020 | e.arg = Qnil; |
| 9030 | e.modifiers = NULL; | 9021 | e.modifiers = NULL; |
| 9031 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); | 9022 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); |
| 9032 | XSETFRAME (e.frame_or_window, mwp->mFP); | 9023 | XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ())); |
| 9033 | /* Remove event from queue to prevent looping. */ | 9024 | /* Remove event from queue to prevent looping. */ |
| 9034 | RemoveEventFromQueue (GetMainEventQueue (), event); | 9025 | RemoveEventFromQueue (GetMainEventQueue (), event); |
| 9035 | ReleaseEvent (event); | 9026 | ReleaseEvent (event); |