Mercurial > emacs
comparison src/macterm.c @ 83143:9fb10038ca55
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-354
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-355
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-356
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-183
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 31 May 2004 13:48:26 +0000 |
parents | ad01ab3c6f4d f1d6a507dcfd |
children | dbcd0af66869 |
comparison
equal
deleted
inserted
replaced
83142:62cf3d6337a0 | 83143:9fb10038ca55 |
---|---|
51 #include <LowMem.h> | 51 #include <LowMem.h> |
52 #include <Controls.h> | 52 #include <Controls.h> |
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> |
60 #endif | 59 #endif |
61 #endif /* not MAC_OSX */ | 60 #endif /* not MAC_OSX */ |
193 along with the position query. So, we just keep track of the time | 192 along with the position query. So, we just keep track of the time |
194 of the last movement we received, and return that in hopes that | 193 of the last movement we received, and return that in hopes that |
195 it's somewhat accurate. */ | 194 it's somewhat accurate. */ |
196 | 195 |
197 static Time last_mouse_movement_time; | 196 static Time last_mouse_movement_time; |
198 | |
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 | 197 |
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 |
210 events. */ | 201 events. */ |
362 Display *display; | 353 Display *display; |
363 WindowPtr w; | 354 WindowPtr w; |
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 |
375 MoveTo (x1, y1); | 362 MoveTo (x1, y1); |
376 LineTo (x2, y2); | 363 LineTo (x2, y2); |
414 XGCValues xgc; | 401 XGCValues xgc; |
415 | 402 |
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); |
427 | 410 |
428 EraseRect (&r); | 411 EraseRect (&r); |
439 XGCValues xgc; | 422 XGCValues xgc; |
440 | 423 |
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 |
452 #if TARGET_API_MAC_CARBON | 431 #if TARGET_API_MAC_CARBON |
453 { | 432 { |
478 | 457 |
479 bitmap.rowBytes = sizeof(unsigned short); | 458 bitmap.rowBytes = sizeof(unsigned short); |
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); |
491 | 466 |
492 #if TARGET_API_MAC_CARBON | 467 #if TARGET_API_MAC_CARBON |
507 mac_set_clip_rectangle (display, w, r) | 482 mac_set_clip_rectangle (display, w, r) |
508 Display *display; | 483 Display *display; |
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 } |
520 | 491 |
521 | 492 |
526 Display *display; | 497 Display *display; |
527 WindowPtr w; | 498 WindowPtr 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); |
539 } | 506 } |
540 | 507 |
599 { | 566 { |
600 Pixmap pixmap; | 567 Pixmap pixmap; |
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); |
612 if (err != noErr) | 575 if (err != noErr) |
613 return NULL; | 576 return NULL; |
664 int x, y; | 627 int x, y; |
665 unsigned int width, height; | 628 unsigned int 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); |
677 | 636 |
678 PaintRect (&r); /* using foreground color of gc */ | 637 PaintRect (&r); /* using foreground color of gc */ |
714 int x, y; | 673 int x, y; |
715 unsigned int width, height; | 674 unsigned int 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); |
727 | 682 |
728 FrameRect (&r); /* using foreground color of gc */ | 683 FrameRect (&r); /* using foreground color of gc */ |
764 GC gc; | 719 GC gc; |
765 int x, y; | 720 int x, y; |
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 |
777 TextFont (gc->font->mac_fontnum); | 728 TextFont (gc->font->mac_fontnum); |
778 TextSize (gc->font->mac_fontsize); | 729 TextSize (gc->font->mac_fontsize); |
859 unsigned int width, height; | 810 unsigned int width, height; |
860 int dest_x, dest_y; | 811 int dest_x, dest_y; |
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); |
872 | 819 |
873 ForeColor (blackColor); | 820 ForeColor (blackColor); |
899 unsigned int width, height; | 846 unsigned int width, height; |
900 int dest_x, dest_y; | 847 int dest_x, dest_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); |
912 | 855 |
913 ForeColor (blackColor); | 856 ForeColor (blackColor); |
963 Rect gw_r, src_r, dest_r; | 906 Rect gw_r, src_r, dest_r; |
964 | 907 |
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); |
972 | 915 |
973 LockPortBits (GetWindowPort (w)); | 916 LockPortBits (GetWindowPort (w)); |
1288 if (!NILP (display_info->mouse_face_window) | 1231 if (!NILP (display_info->mouse_face_window) |
1289 && w == XWINDOW (display_info->mouse_face_window)) | 1232 && w == XWINDOW (display_info->mouse_face_window)) |
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 |
1297 if (i < w->desired_matrix->nrows) | 1240 if (i < w->desired_matrix->nrows) |
1298 clear_mouse_face (display_info); | 1241 clear_mouse_face (display_info); |
1383 struct frame *f; | 1326 struct frame *f; |
1384 { | 1327 { |
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 |
1396 /* Mouse highlight may be displayed again. */ | 1335 /* Mouse highlight may be displayed again. */ |
1397 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0; | 1336 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0; |
3743 result->timestamp = event->when; | 3682 result->timestamp = event->when; |
3744 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier; | 3683 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier; |
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); |
3756 XSETINT (result->y, mouseLoc.v); | 3691 XSETINT (result->y, mouseLoc.v); |
3757 | 3692 |
3776 static void | 3711 static void |
3777 note_mouse_movement (frame, pos) | 3712 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 |
3784 | 3720 |
3785 last_mouse_movement_time = TickCount () * (1000 / 60); /* to milliseconds */ | 3721 last_mouse_movement_time = TickCount () * (1000 / 60); /* to milliseconds */ |
3790 if (!PtInRect (*pos, GetWindowPortBounds (FRAME_MAC_WINDOW (frame), &r))) | 3726 if (!PtInRect (*pos, GetWindowPortBounds (FRAME_MAC_WINDOW (frame), &r))) |
3791 #else | 3727 #else |
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 |
3801 || pos->h >= last_mouse_glyph.right | 3745 || pos->h >= last_mouse_glyph.right |
3802 || pos->v < last_mouse_glyph.top | 3746 || pos->v < last_mouse_glyph.top |
3940 last_mouse_glyph.bottom = gy + height; | 3884 last_mouse_glyph.bottom = gy + height; |
3941 } | 3885 } |
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 |
3948 If the mouse movement started in a scroll bar, set *fp, *bar_window, | 3909 If the mouse movement started in a scroll bar, set *fp, *bar_window, |
3949 and *part to the frame, window, and scroll bar part that the mouse | 3910 and *part to the frame, window, and scroll bar part that the mouse |
3971 Lisp_Object *x, *y; | 3932 Lisp_Object *x, *y; |
3972 unsigned long *time; | 3933 unsigned long *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 |
3985 if (! NILP (last_mouse_scroll_bar) && insist == 0) | 3946 if (! NILP (last_mouse_scroll_bar) && insist == 0) |
3986 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); | 3947 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); |
3990 FOR_EACH_FRAME (tail, frame) | 3951 FOR_EACH_FRAME (tail, frame) |
3991 XFRAME (frame)->mouse_moved = 0; | 3952 XFRAME (frame)->mouse_moved = 0; |
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 |
4003 pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2, | 3960 pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2, |
4004 &last_mouse_glyph, insist); | 3961 &last_mouse_glyph, insist); |
4489 struct scroll_bar *bar; | 4446 struct scroll_bar *bar; |
4490 int part_code; | 4447 int part_code; |
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 |
4497 bufp->kind = SCROLL_BAR_CLICK_EVENT; | 4456 bufp->kind = SCROLL_BAR_CLICK_EVENT; |
4498 bufp->frame_or_window = bar->window; | 4457 bufp->frame_or_window = bar->window; |
4523 bar->dragging = make_number (0); | 4482 bar->dragging = make_number (0); |
4524 XSETVECTOR (last_mouse_scroll_bar, bar); | 4483 XSETVECTOR (last_mouse_scroll_bar, bar); |
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 |
4531 /* Handle some mouse motion while someone is dragging the scroll bar. | 4508 /* Handle some mouse motion while someone is dragging the scroll bar. |
4532 | 4509 |
4572 enum scroll_bar_part *part; | 4549 enum scroll_bar_part *part; |
4573 Lisp_Object *x, *y; | 4550 Lisp_Object *x, *y; |
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 |
4590 win_y = mouse_pos.v - XINT (bar->top); | 4563 win_y = mouse_pos.v - XINT (bar->top); |
4591 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); | 4564 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); |
4808 static void | 4781 static void |
4809 mac_define_frame_cursor (f, cursor) | 4782 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 |
4817 /* RIF: Clear area on frame F. */ | 4794 /* RIF: Clear area on frame F. */ |
4818 | 4795 |
5076 if (f->output_data.mac->parent_desc != FRAME_MAC_DISPLAY_INFO (f)->root_window) | 5053 if (f->output_data.mac->parent_desc != FRAME_MAC_DISPLAY_INFO (f)->root_window) |
5077 { | 5054 { |
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 { |
5089 Rect r; | 5062 Rect r; |
5090 | 5063 |
5455 void | 5428 void |
5456 x_free_frame_resources (f) | 5429 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 |
5467 if (FRAME_FACE_CACHE (f)) | 5445 if (FRAME_FACE_CACHE (f)) |
5468 free_frame_faces (f); | 5446 free_frame_faces (f); |
6982 | 6960 |
6983 Lisp_Object drag_and_drop_file_list; | 6961 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 |
6990 do_ae_open_application (const AppleEvent *, AppleEvent *, long); | 6973 do_ae_open_application (const AppleEvent *, AppleEvent *, long); |
6991 static pascal OSErr | 6974 static pascal OSErr |
7168 InitDialogs (NULL); | 7151 InitDialogs (NULL); |
7169 #endif /* !TARGET_API_MAC_CARBON */ | 7152 #endif /* !TARGET_API_MAC_CARBON */ |
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 |
7176 /* MaxApplZone must be called for AppleScript to execute more | 7161 /* MaxApplZone must be called for AppleScript to execute more |
7177 complicated scripts */ | 7162 complicated scripts */ |
7196 } | 7181 } |
7197 | 7182 |
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 { |
7206 if (f->async_visible == 0) | 7195 if (f->async_visible == 0) |
7207 { | 7196 { |
7248 } | 7237 } |
7249 | 7238 |
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 { |
7263 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); | 7250 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); |
7264 activate_scroll_bars (f); | 7251 activate_scroll_bars (f); |
7267 } | 7254 } |
7268 | 7255 |
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 { |
7282 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); | 7267 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); |
7283 deactivate_scroll_bars (f); | 7268 deactivate_scroll_bars (f); |
7287 | 7272 |
7288 static void | 7273 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 { |
7303 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); | 7286 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); |
7304 activate_scroll_bars (f); | 7287 activate_scroll_bars (f); |
7311 | 7294 |
7312 static void | 7295 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 { |
7327 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); | 7308 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); |
7328 deactivate_scroll_bars (f); | 7309 deactivate_scroll_bars (f); |
7333 app_sleep_time = WNE_SLEEP_AT_SUSPEND; | 7314 app_sleep_time = WNE_SLEEP_AT_SUSPEND; |
7334 } | 7315 } |
7335 | 7316 |
7336 | 7317 |
7337 static void | 7318 static void |
7338 do_mouse_moved (Point mouse_pos) | 7319 do_mouse_moved (mouse_pos, f) |
7339 { | 7320 Point mouse_pos; |
7340 WindowPtr wp = FrontWindow (); | 7321 FRAME_PTR *f; |
7341 struct frame *f; | 7322 { |
7323 WindowPtr wp = mac_front_window (); | |
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); |
7346 | 7329 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); |
7347 #if TARGET_API_MAC_CARBON | 7330 |
7348 SetPort (GetWindowPort (wp)); | 7331 if (dpyinfo->mouse_face_hidden) |
7349 #else | 7332 { |
7350 SetPort (wp); | 7333 dpyinfo->mouse_face_hidden = 0; |
7351 #endif | 7334 clear_mouse_face (dpyinfo); |
7335 } | |
7336 | |
7337 SetPortWindowPort (wp); | |
7352 | 7338 |
7353 GlobalToLocal (&mouse_pos); | 7339 GlobalToLocal (&mouse_pos); |
7354 | 7340 |
7355 note_mouse_movement (f, &mouse_pos); | 7341 if (dpyinfo->grabbed && tracked_scroll_bar) |
7356 } | 7342 x_scroll_bar_note_movement (tracked_scroll_bar, |
7357 } | 7343 mouse_pos.v |
7358 | 7344 - XINT (tracked_scroll_bar->top), |
7359 | 7345 TickCount() * (1000 / 60)); |
7360 static void | |
7361 do_os_event (EventRecord *erp) | |
7362 { | |
7363 switch((erp->message >> 24) & 0x000000FF) | |
7364 { | |
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; | 7348 } |
7371 | 7349 } |
7372 case mouseMovedMessage: | 7350 |
7373 do_mouse_moved (erp->where); | |
7374 break; | |
7375 } | |
7376 } | |
7377 | |
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) |
7402 { | 7354 { |
7403 #if !TARGET_API_MAC_CARBON | 7355 #if !TARGET_API_MAC_CARBON |
7431 do_apple_menu (menu_item); | 7383 do_apple_menu (menu_item); |
7432 break; | 7384 break; |
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 { |
7441 UInt32 refcon; | 7392 UInt32 refcon; |
7442 | 7393 |
7457 do_grow_window (WindowPtr w, EventRecord *e) | 7408 do_grow_window (WindowPtr w, EventRecord *e) |
7458 { | 7409 { |
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 |
7467 grow_size = GrowWindow (w, e->where, &limit_rect); | 7417 grow_size = GrowWindow (w, e->where, &limit_rect); |
7468 | 7418 |
7487 { | 7437 { |
7488 GrafPtr save_port; | 7438 GrafPtr save_port; |
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 |
7505 { | 7450 { |
7506 Rect r; | 7451 Rect r; |
7549 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState | 7494 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState |
7550 = zoom_rect; | 7495 = zoom_rect; |
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 |
7558 GetWindowPortBounds (w, &port_rect); | 7503 GetWindowPortBounds (w, &port_rect); |
7559 #else | 7504 #else |
7560 port_rect = w->portRect; | 7505 port_rect = w->portRect; |
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 } |
7568 | 7513 |
7569 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ | 7514 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ |
7890 the queue like an interrupt using kbd_buffer_store_event. */ | 7835 the queue like an interrupt using kbd_buffer_store_event. */ |
7891 if (!NILP (drag_and_drop_file_list)) | 7836 if (!NILP (drag_and_drop_file_list)) |
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; |
7900 event.code = 0; | 7845 event.code = 0; |
7901 event.modifiers = 0; | 7846 event.modifiers = 0; |
8065 } | 8010 } |
8066 | 8011 |
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; | 8029 |
8082 | |
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; |
8093 | 8038 |
8094 /* So people can tell when we have read the available input. */ | 8039 /* So people can tell when we have read the available input. */ |
8106 } | 8051 } |
8107 | 8052 |
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 |
8061 while (WaitNextEvent (event_mask, &er, | |
8062 (expected ? app_sleep_time : 0L), NULL)) | |
8063 #else | |
8064 while (!ReceiveNextEvent (0, NULL, | |
8065 (expected ? TicksToEventTime (app_sleep_time) : 0), | |
8066 kEventRemoveFromQueue, &eventRef)) | |
8067 #endif /* !USE_CARBON_EVENTS */ | |
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 | |
8123 #if USE_CARBON_EVENTS | 8082 #if USE_CARBON_EVENTS |
8124 rneResult = ReceiveNextEvent (0, NULL, | |
8125 expected | |
8126 ? TicksToEventTime (app_sleep_time) | |
8127 : 0, | |
8128 kEventRemoveFromQueue, &eventRef); | |
8129 if (!rneResult) | |
8130 { | |
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)) |
8134 { | 8086 { |
8135 case kEventClassMouse: | 8087 case kEventClassMouse: |
8136 if (GetEventKind (eventRef) == kEventMouseWheelMoved) | 8088 if (GetEventKind (eventRef) == kEventMouseWheelMoved) |
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, |
8150 typeSInt32, NULL, sizeof (SInt32), | 8101 typeSInt32, NULL, sizeof (SInt32), |
8151 NULL, &delta); | 8102 NULL, &delta); |
8152 GetEventParameter(eventRef, kEventParamMouseLocation, | 8103 GetEventParameter(eventRef, kEventParamMouseLocation, |
8153 typeQDPoint, NULL, sizeof (Point), | 8104 typeQDPoint, NULL, sizeof (Point), |
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 |
8128 #endif /* USE_CARBON_EVENTS */ | |
8129 switch (er.what) | |
8130 { | |
8131 case mouseDown: | |
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 } | |
8152 | |
8153 #if USE_CARBON_EVENTS | |
8154 /* This is needed to send mouse events like aqua | |
8155 window buttons to the correct handler. */ | |
8156 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | |
8157 != eventNotHandledErr) | |
8158 break; | |
8159 | |
8160 if (!is_emacs_window (window_ptr)) | |
8161 break; | |
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; | |
8177 | |
8178 case inContent: | |
8179 if (window_ptr != mac_front_window ()) | |
8180 SelectWindow (window_ptr); | |
8181 else | |
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); | |
8190 | |
8191 GlobalToLocal (&mouse_loc); | |
8192 #if TARGET_API_MAC_CARBON | |
8193 ch = FindControlUnderMouse (mouse_loc, window_ptr, | |
8194 &control_part_code); | |
8176 #else | 8195 #else |
8177 if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) | 8196 control_part_code = FindControl (mouse_loc, window_ptr, |
8178 #endif /* USE_CARBON_EVENTS */ | 8197 &ch); |
8179 switch (er.what) | 8198 #endif |
8180 { | |
8181 case mouseDown: | |
8182 case mouseUp: | |
8183 { | |
8184 WindowPtr window_ptr = FrontWindow (); | |
8185 SInt16 part_code; | |
8186 | 8199 |
8187 #if USE_CARBON_EVENTS | 8200 #if USE_CARBON_EVENTS |
8188 /* This is needed to send mouse events like aqua window buttons | 8201 inev.code = mac_get_mouse_btn (eventRef); |
8189 to the correct handler. */ | 8202 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
8190 if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { | 8203 #else |
8204 inev.code = mac_get_emulated_btn (er.modifiers); | |
8205 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | |
8206 #endif | |
8207 XSETINT (inev.x, mouse_loc.h); | |
8208 XSETINT (inev.y, mouse_loc.v); | |
8209 inev.timestamp = er.when * (1000 / 60); | |
8210 /* ticks to milliseconds */ | |
8211 | |
8212 if (dpyinfo->grabbed && tracked_scroll_bar | |
8213 #if TARGET_API_MAC_CARBON | |
8214 || ch != 0 | |
8215 #else | |
8216 || control_part_code != 0 | |
8217 #endif | |
8218 ) | |
8219 { | |
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; | |
8296 | |
8297 case inDrag: | |
8298 #if TARGET_API_MAC_CARBON | |
8299 if (er.what == mouseDown) | |
8300 { | |
8301 BitMap bm; | |
8302 | |
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; | |
8310 | |
8311 case inGoAway: | |
8312 if (TrackGoAway (window_ptr, er.where)) | |
8313 { | |
8314 inev.kind = DELETE_WINDOW_EVENT; | |
8315 XSETFRAME (inev.frame_or_window, | |
8316 mac_window_to_frame (window_ptr)); | |
8317 } | |
8318 break; | |
8319 | |
8320 /* window resize handling added --ben */ | |
8321 case inGrow: | |
8322 if (er.what == mouseDown) | |
8323 { | |
8324 do_grow_window(window_ptr, &er); | |
8325 break; | |
8326 } | |
8327 | |
8328 /* window zoom handling added --ben */ | |
8329 case inZoomIn: | |
8330 case inZoomOut: | |
8331 if (TrackBox (window_ptr, er.where, part_code)) | |
8332 do_zoom_window (window_ptr, part_code); | |
8333 break; | |
8334 | |
8335 default: | |
8336 break; | |
8337 } | |
8338 } | |
8339 break; | |
8340 | |
8341 case updateEvt: | |
8342 #if USE_CARBON_EVENTS | |
8343 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | |
8344 != eventNotHandledErr) | |
8191 break; | 8345 break; |
8346 #endif | |
8347 do_window_update ((WindowPtr) er.message); | |
8348 break; | |
8349 | |
8350 case osEvt: | |
8351 #if USE_CARBON_EVENTS | |
8352 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | |
8353 != eventNotHandledErr) | |
8354 break; | |
8355 #endif | |
8356 switch ((er.message >> 24) & 0x000000FF) | |
8357 { | |
8358 case suspendResumeMessage: | |
8359 if ((er.message & resumeFlag) == 1) | |
8360 do_app_resume (); | |
8361 else | |
8362 do_app_suspend (); | |
8363 break; | |
8364 | |
8365 case mouseMovedMessage: | |
8366 previous_help_echo_string = help_echo_string; | |
8367 help_echo_string = help_echo_object = help_echo_window = Qnil; | |
8368 help_echo_pos = -1; | |
8369 | |
8370 do_mouse_moved (er.where, &f); | |
8371 | |
8372 /* If the contents of the global variable | |
8373 help_echo_string has changed, generate a | |
8374 HELP_EVENT. */ | |
8375 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) | |
8376 do_help = 1; | |
8377 break; | |
8378 } | |
8379 break; | |
8380 | |
8381 case activateEvt: | |
8382 { | |
8383 WindowPtr window_ptr = (WindowPtr) er.message; | |
8384 | |
8385 #if USE_CARBON_EVENTS | |
8386 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | |
8387 != eventNotHandledErr) | |
8388 break; | |
8389 #endif | |
8390 if (window_ptr == tip_window) | |
8391 { | |
8392 HideWindow (tip_window); | |
8393 break; | |
8394 } | |
8395 | |
8396 if ((er.modifiers & activeFlag) != 0) | |
8397 { | |
8398 Point mouse_loc = er.where; | |
8399 | |
8400 do_window_activate (window_ptr); | |
8401 | |
8402 SetPortWindowPort (window_ptr); | |
8403 GlobalToLocal (&mouse_loc); | |
8404 /* activateEvt counts as mouse movement, | |
8405 so update things that depend on mouse position. */ | |
8406 note_mouse_movement (mac_window_to_frame (window_ptr), | |
8407 &mouse_loc); | |
8408 } | |
8409 else | |
8410 { | |
8411 do_window_deactivate (window_ptr); | |
8412 | |
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 } | |
8422 | |
8423 /* Generate a nil HELP_EVENT to cancel a help-echo. | |
8424 Do it only if there's something to cancel. | |
8425 Otherwise, the startup message is cleared when the | |
8426 mouse leaves the frame. */ | |
8427 if (any_help_event_p) | |
8428 do_help = -1; | |
8429 } | |
8192 } | 8430 } |
8193 | 8431 break; |
8194 if (!is_emacs_window(window_ptr)) | 8432 |
8195 break; | 8433 case keyDown: |
8196 #endif | 8434 case autoKey: |
8197 | 8435 { |
8198 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | 8436 int keycode = (er.message & keyCodeMask) >> 8; |
8199 && er.what == mouseUp) | 8437 int xkeysym; |
8200 { | 8438 |
8201 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 8439 #if USE_CARBON_EVENTS |
8202 Point mouse_loc = er.where; | 8440 /* When using Carbon Events, we need to pass raw keyboard |
8203 | 8441 events to the TSM ourselves. If TSM handles it, it |
8204 /* Convert to local coordinates of new window. */ | 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 | |
8205 #if TARGET_API_MAC_CARBON | 8454 #if TARGET_API_MAC_CARBON |
8206 SetPort (GetWindowPort (window_ptr)); | 8455 if (!IsValidWindowPtr (mac_front_window ())) |
8456 { | |
8457 SysBeep (1); | |
8458 break; | |
8459 } | |
8460 #endif | |
8461 | |
8462 ObscureCursor (); | |
8463 | |
8464 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) | |
8465 { | |
8466 clear_mouse_face (dpyinfo); | |
8467 dpyinfo->mouse_face_hidden = 1; | |
8468 } | |
8469 | |
8470 if (keycode_to_xkeysym (keycode, &xkeysym)) | |
8471 { | |
8472 inev.code = 0xff00 | xkeysym; | |
8473 inev.kind = NON_ASCII_KEYSTROKE_EVENT; | |
8474 } | |
8475 else | |
8476 { | |
8477 if (er.modifiers & (controlKey | | |
8478 (NILP (Vmac_command_key_is_meta) ? optionKey | |
8479 : cmdKey))) | |
8480 { | |
8481 /* This code comes from Keyboard Resource, | |
8482 Appendix C of IM - Text. This is necessary | |
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; | |
8499 } | |
8500 } | |
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 | |
8553 #if USE_CARBON_EVENTS | |
8554 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | |
8207 #else | 8555 #else |
8208 SetPort (window_ptr); | 8556 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
8209 #endif | 8557 #endif |
8210 | 8558 XSETFRAME (inev.frame_or_window, |
8211 GlobalToLocal (&mouse_loc); | 8559 mac_window_to_frame (mac_front_window ())); |
8212 | 8560 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ |
8213 #if USE_CARBON_EVENTS | 8561 break; |
8214 inev.code = mac_get_mouse_btn (eventRef); | 8562 |
8215 #else | 8563 case kHighLevelEvent: |
8216 inev.code = mac_get_emulate_btn (er.modifiers); | 8564 drag_and_drop_file_list = Qnil; |
8217 #endif | 8565 |
8218 inev.kind = SCROLL_BAR_CLICK_EVENT; | 8566 AEProcessAppleEvent(&er); |
8219 inev.frame_or_window = tracked_scroll_bar->window; | 8567 |
8220 inev.part = scroll_bar_handle; | 8568 /* Build a DRAG_N_DROP_EVENT type event as is done in |
8569 constuct_drag_n_drop in w32term.c. */ | |
8570 if (!NILP (drag_and_drop_file_list)) | |
8571 { | |
8572 struct frame *f = NULL; | |
8573 WindowPtr wp; | |
8574 Lisp_Object frame; | |
8575 | |
8576 wp = mac_front_window (); | |
8577 | |
8578 if (!wp) | |
8579 { | |
8580 struct frame *f = XFRAME (XCAR (Vframe_list)); | |
8581 CollapseWindow (FRAME_MAC_WINDOW (f), false); | |
8582 wp = mac_front_window (); | |
8583 } | |
8584 | |
8585 if (wp && is_emacs_window (wp)) | |
8586 f = mac_window_to_frame (wp); | |
8587 | |
8588 inev.kind = DRAG_N_DROP_EVENT; | |
8589 inev.code = 0; | |
8590 inev.timestamp = er.when * (1000 / 60); | |
8591 /* ticks to milliseconds */ | |
8221 #if USE_CARBON_EVENTS | 8592 #if USE_CARBON_EVENTS |
8222 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8593 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
8223 #else | 8594 #else |
8224 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8595 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
8225 #endif | 8596 #endif |
8226 inev.modifiers |= up_modifier; | 8597 |
8227 inev.timestamp = er.when * (1000 / 60); | 8598 XSETINT (inev.x, 0); |
8228 /* ticks to milliseconds */ | 8599 XSETINT (inev.y, 0); |
8229 | 8600 |
8230 XSETINT (inev.x, XFASTINT (tracked_scroll_bar->left) + 2); | 8601 XSETFRAME (frame, f); |
8231 XSETINT (inev.y, mouse_loc.v - 24); | 8602 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); |
8232 tracked_scroll_bar->dragging = Qnil; | 8603 |
8233 mouse_tracking_in_progress = mouse_tracking_none; | 8604 /* Regardless of whether Emacs was suspended or in the |
8234 tracked_scroll_bar = NULL; | 8605 foreground, ask it to redraw its entire screen. |
8235 break; | 8606 Otherwise parts of the screen can be left in an |
8236 } | 8607 inconsistent state. */ |
8237 | 8608 if (wp) |
8238 part_code = FindWindow (er.where, &window_ptr); | 8609 #if TARGET_API_MAC_CARBON |
8239 | |
8240 switch (part_code) | |
8241 { | |
8242 case inMenuBar: | |
8243 if (er.what == mouseDown) | |
8244 { | 8610 { |
8245 struct frame *f = ((mac_output *) | 8611 Rect r; |
8246 GetWRefCon (FrontWindow ()))->mFP; | 8612 |
8247 saved_menu_event_location = er.where; | 8613 GetWindowPortBounds (wp, &r); |
8248 inev.kind = MENU_BAR_ACTIVATE_EVENT; | 8614 InvalWindowRect (wp, &r); |
8249 XSETFRAME (inev.frame_or_window, f); | |
8250 } | |
8251 break; | |
8252 | |
8253 case inContent: | |
8254 if (window_ptr != FrontWindow ()) | |
8255 SelectWindow (window_ptr); | |
8256 else | |
8257 { | |
8258 SInt16 control_part_code; | |
8259 ControlHandle ch; | |
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 | |
8271 GlobalToLocal (&mouse_loc); | |
8272 #if TARGET_API_MAC_CARBON | |
8273 ch = FindControlUnderMouse (mouse_loc, window_ptr, | |
8274 &control_part_code); | |
8275 #else | |
8276 control_part_code = FindControl (mouse_loc, window_ptr, &ch); | |
8277 #endif | |
8278 | |
8279 #if USE_CARBON_EVENTS | |
8280 inev.code = mac_get_mouse_btn (eventRef); | |
8281 #else | |
8282 inev.code = mac_get_emulate_btn (er.modifiers); | |
8283 #endif | |
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 | |
8289 #if TARGET_API_MAC_CARBON | |
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 | |
8333 mac_event_to_emacs_modifiers (eventRef) | |
8334 #else | |
8335 er.modifiers | |
8336 #endif | |
8337 ); | |
8338 break; | |
8339 } | |
8340 else | |
8341 inev.kind = MOUSE_CLICK_EVENT; | |
8342 } | |
8343 | |
8344 #if USE_CARBON_EVENTS | |
8345 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | |
8346 #else | |
8347 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | |
8348 #endif | |
8349 | |
8350 switch (er.what) | |
8351 { | |
8352 case mouseDown: | |
8353 inev.modifiers |= down_modifier; | |
8354 break; | |
8355 case mouseUp: | |
8356 inev.modifiers |= up_modifier; | |
8357 break; | |
8358 } | |
8359 } | |
8360 break; | |
8361 | |
8362 case inDrag: | |
8363 #if TARGET_API_MAC_CARBON | |
8364 if (er.what == mouseDown) | |
8365 { | |
8366 BitMap bm; | |
8367 | |
8368 GetQDGlobalsScreenBits (&bm); | |
8369 DragWindow (window_ptr, er.where, &bm.bounds); | |
8370 } | 8615 } |
8371 #else /* not TARGET_API_MAC_CARBON */ | 8616 #else /* not TARGET_API_MAC_CARBON */ |
8372 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | 8617 InvalRect (&(wp->portRect)); |
8373 #endif /* not TARGET_API_MAC_CARBON */ | 8618 #endif /* not TARGET_API_MAC_CARBON */ |
8374 break; | |
8375 | |
8376 case inGoAway: | |
8377 if (TrackGoAway (window_ptr, er.where)) | |
8378 { | |
8379 inev.kind = DELETE_WINDOW_EVENT; | |
8380 XSETFRAME (inev.frame_or_window, | |
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; | |
8402 } | 8619 } |
8620 default: | |
8621 break; | |
8403 } | 8622 } |
8404 break; | |
8405 | |
8406 case updateEvt: | |
8407 case osEvt: | |
8408 case activateEvt: | |
8409 #if USE_CARBON_EVENTS | 8623 #if USE_CARBON_EVENTS |
8410 if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) | 8624 ReleaseEvent (eventRef); |
8411 #endif | 8625 #endif |
8412 do_events (&er); | 8626 |
8413 break; | 8627 if (inev.kind != NO_EVENT) |
8414 | |
8415 case keyDown: | |
8416 case autoKey: | |
8417 { | 8628 { |
8418 int keycode = (er.message & keyCodeMask) >> 8; | 8629 kbd_buffer_store_event_hold (&inev, hold_quit); |
8419 int xkeysym; | 8630 count++; |
8420 | 8631 } |
8421 #if USE_CARBON_EVENTS | 8632 |
8422 /* When using Carbon Events, we need to pass raw keyboard events | 8633 if (do_help |
8423 to the TSM ourselves. If TSM handles it, it will pass back | 8634 && !(hold_quit && hold_quit->kind != NO_EVENT)) |
8424 noErr, otherwise it will pass back "eventNotHandledErr" and | 8635 { |
8425 we can process it normally. */ | 8636 Lisp_Object frame; |
8426 if ((!NILP (Vmac_pass_command_to_system) | 8637 |
8427 || !(er.modifiers & cmdKey)) | 8638 if (f) |
8428 && (!NILP (Vmac_pass_control_to_system) | 8639 XSETFRAME (frame, f); |
8429 || !(er.modifiers & controlKey))) | 8640 else |
8641 frame = Qnil; | |
8642 | |
8643 if (do_help > 0) | |
8430 { | 8644 { |
8431 OSStatus err; | 8645 any_help_event_p = 1; |
8432 err = SendEventToEventTarget (eventRef, | 8646 gen_help_event (help_echo_string, frame, help_echo_window, |
8433 GetEventDispatcherTarget ()); | 8647 help_echo_object, help_echo_pos); |
8434 if (err != eventNotHandledErr) | |
8435 break; | |
8436 } | |
8437 #endif | |
8438 | |
8439 if (!IsValidWindowPtr (FrontNonFloatingWindow ())) | |
8440 { | |
8441 SysBeep (1); | |
8442 UNBLOCK_INPUT; | |
8443 return 0; | |
8444 } | |
8445 | |
8446 ObscureCursor (); | |
8447 | |
8448 if (keycode_to_xkeysym (keycode, &xkeysym)) | |
8449 { | |
8450 inev.code = 0xff00 | xkeysym; | |
8451 inev.kind = NON_ASCII_KEYSTROKE_EVENT; | |
8452 } | 8648 } |
8453 else | 8649 else |
8454 { | 8650 { |
8455 if (er.modifiers & (controlKey | | 8651 help_echo_string = Qnil; |
8456 (NILP (Vmac_command_key_is_meta) ? optionKey | 8652 gen_help_event (Qnil, frame, Qnil, Qnil, 0); |
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 } | 8653 } |
8654 count++; | |
8477 } | 8655 } |
8478 | 8656 |
8479 /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil, | 8657 } |
8480 convert non-ASCII characters typed at the Mac keyboard | |
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 { | |
8488 static TECObjectRef converter = NULL; | |
8489 OSStatus the_err = noErr; | |
8490 OSStatus convert_status = noErr; | |
8491 | |
8492 if (converter == NULL) | |
8493 { | |
8494 the_err = TECCreateConverter (&converter, | |
8495 kTextEncodingMacRoman, | |
8496 mac_keyboard_text_encoding); | |
8497 current_mac_keyboard_text_encoding | |
8498 = mac_keyboard_text_encoding; | |
8499 } | |
8500 else if (mac_keyboard_text_encoding | |
8501 != current_mac_keyboard_text_encoding) | |
8502 { | |
8503 /* Free the converter for the current encoding before | |
8504 creating a new one. */ | |
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 } | |
8512 | |
8513 if (the_err == noErr) | |
8514 { | |
8515 unsigned char ch = inev.code; | |
8516 ByteCount actual_input_length, actual_output_length; | |
8517 unsigned char outch; | |
8518 | |
8519 convert_status = TECConvertText (converter, &ch, 1, | |
8520 &actual_input_length, | |
8521 &outch, 1, | |
8522 &actual_output_length); | |
8523 if (convert_status == noErr | |
8524 && actual_input_length == 1 | |
8525 && actual_output_length == 1) | |
8526 inev.code = outch; | |
8527 } | |
8528 } | |
8529 | |
8530 #if USE_CARBON_EVENTS | |
8531 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | |
8532 #else | |
8533 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | |
8534 #endif | |
8535 | |
8536 { | |
8537 mac_output *mwp | |
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 | |
8548 AEProcessAppleEvent(&er); | |
8549 | |
8550 /* Build a DRAG_N_DROP_EVENT type event as is done in | |
8551 constuct_drag_n_drop in w32term.c. */ | |
8552 if (!NILP (drag_and_drop_file_list)) | |
8553 { | |
8554 struct frame *f = NULL; | |
8555 WindowPtr wp; | |
8556 Lisp_Object frame; | |
8557 | |
8558 wp = FrontNonFloatingWindow (); | |
8559 | |
8560 if (!wp) | |
8561 { | |
8562 struct frame *f = XFRAME (XCAR (Vframe_list)); | |
8563 CollapseWindow (FRAME_MAC_WINDOW (f), false); | |
8564 wp = FrontNonFloatingWindow (); | |
8565 } | |
8566 | |
8567 if (wp && is_emacs_window(wp)) | |
8568 f = ((mac_output *) GetWRefCon (wp))->mFP; | |
8569 | |
8570 inev.kind = DRAG_N_DROP_EVENT; | |
8571 inev.code = 0; | |
8572 inev.timestamp = er.when * (1000 / 60); | |
8573 /* ticks to milliseconds */ | |
8574 #if USE_CARBON_EVENTS | |
8575 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | |
8576 #else | |
8577 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | |
8578 #endif | |
8579 | |
8580 XSETINT (inev.x, 0); | |
8581 XSETINT (inev.y, 0); | |
8582 | |
8583 XSETFRAME (frame, f); | |
8584 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); | |
8585 | |
8586 /* Regardless of whether Emacs was suspended or in the | |
8587 foreground, ask it to redraw its entire screen. | |
8588 Otherwise parts of the screen can be left in an | |
8589 inconsistent state. */ | |
8590 if (wp) | |
8591 #if TARGET_API_MAC_CARBON | |
8592 { | |
8593 Rect r; | |
8594 | |
8595 GetWindowPortBounds (wp, &r); | |
8596 InvalWindowRect (wp, &r); | |
8597 } | |
8598 #else /* not TARGET_API_MAC_CARBON */ | |
8599 InvalRect (&(wp->portRect)); | |
8600 #endif /* not TARGET_API_MAC_CARBON */ | |
8601 } | |
8602 default: | |
8603 break; | |
8604 } | |
8605 #if USE_CARBON_EVENTS | |
8606 ReleaseEvent (eventRef); | |
8607 } | |
8608 #endif | |
8609 | 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. */ |
8613 if (pending_autoraise_frame) | 8662 if (pending_autoraise_frame) |
8617 } | 8666 } |
8618 | 8667 |
8619 #if !TARGET_API_MAC_CARBON | 8668 #if !TARGET_API_MAC_CARBON |
8620 check_alarm (); /* simulate the handling of a SIGALRM */ | 8669 check_alarm (); /* simulate the handling of a SIGALRM */ |
8621 #endif | 8670 #endif |
8622 | |
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 | 8671 |
8675 UNBLOCK_INPUT; | 8672 UNBLOCK_INPUT; |
8676 return count; | 8673 return count; |
8677 } | 8674 } |
8678 | 8675 |
8698 | 8695 |
8699 /* Initialize the struct pointed to by MW to represent a new COLS x | 8696 /* Initialize the struct pointed to by MW to represent a new COLS x |
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 |
8707 static int making_terminal_window = 0; | 8704 static int making_terminal_window = 0; |
8708 #else | 8705 #else |
8717 (WindowPtr) -1))) | 8714 (WindowPtr) -1))) |
8718 abort (); | 8715 abort (); |
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 { |
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); | |
8757 | |
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 | |
8746 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; | 8764 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; |
8747 | |
8748 NewMacWindow(f); | |
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; |
8752 f->output_data.mac->mouse_pixel = 0xff00ff; | 8768 f->output_data.mac->mouse_pixel = 0xff00ff; |
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; |
8761 f->border_width = 0; | 8775 f->border_width = 0; |
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 |
8799 x_make_gc (f); | 8787 x_make_gc (f); |
8800 | 8788 |
8808 Fcons (Fcons (Qforeground_color, | 8796 Fcons (Fcons (Qforeground_color, |
8809 build_string ("black")), Qnil)); | 8797 build_string ("black")), Qnil)); |
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 |
8816 /*********************************************************************** | 8806 /*********************************************************************** |
8817 Initialization | 8807 Initialization |
8862 | 8852 |
8863 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; | 8853 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; |
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 * |
8870 mac_term_init (display_name, xrm_option, resource_name) | 8862 mac_term_init (display_name, xrm_option, resource_name) |
8871 Lisp_Object display_name; | 8863 Lisp_Object display_name; |
9018 NULL); | 9010 NULL); |
9019 UNBLOCK_INPUT; | 9011 UNBLOCK_INPUT; |
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; |
9028 e.code = quit_char; | 9019 e.code = 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); |
9036 kbd_buffer_store_event (&e); | 9027 kbd_buffer_store_event (&e); |
9037 } | 9028 } |