diff options
| author | YAMAMOTO Mitsuharu | 2005-04-16 03:05:15 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-04-16 03:05:15 +0000 |
| commit | 7ca7ccd51135d24b89a97f0bcc760f7b6f78063a (patch) | |
| tree | 5d02263627f86157e6123d641200ba8ff45dfb3e /src | |
| parent | 28fbbe2306c459a21ca819f646232fa40c44da53 (diff) | |
| download | emacs-7ca7ccd51135d24b89a97f0bcc760f7b6f78063a.tar.gz emacs-7ca7ccd51135d24b89a97f0bcc760f7b6f78063a.zip | |
(x_autoselect_window_p): Remove variable.
(last_window): New variable.
(XTreassert_line_highlight, x_change_line_highlight): Remove
declarations.
(mac_focus_changed, x_detect_focus_change): New functions and
declarations.
(XTextExtents16, front_emacs_window): Remove function.
(mac_focus_frame): New function.
(XTmouse_position, do_menu_choice, do_zoom_window, XTread_socket)
(mac_check_for_quit_char): Use it instead of front_emacs_window.
(x_scroll_bar_report_motion): Obtain window from control owner.
(x_make_frame_invisible): Set window manager size hint.
(do_mouse_moved): Remove function.
(XTread_socket): Move its contents here. Generate select-window
event on mouse movement if needed. Use x_detect_focus_change on
activate/deactivate events. Don't deiconify frame or invalidate
window rectangle when dnd items are dropped. Don't
activate/deactivate root control.
(frame_highlight, frame_unhighlight): Activate/deactivate root
control here.
(syms_of_macterm): Delete DEFVAR_BOOL for x_autoselect_window_p.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 363 |
1 files changed, 206 insertions, 157 deletions
diff --git a/src/macterm.c b/src/macterm.c index bb77d381792..fb1e6c14abc 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -95,6 +95,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 95 | : controlKey) | 95 | : controlKey) |
| 96 | #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) | 96 | #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) |
| 97 | 97 | ||
| 98 | #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP) | ||
| 98 | 99 | ||
| 99 | 100 | ||
| 100 | /* Non-nil means Emacs uses toolkit scroll bars. */ | 101 | /* Non-nil means Emacs uses toolkit scroll bars. */ |
| @@ -110,9 +111,8 @@ Lisp_Object Vmac_use_core_graphics; | |||
| 110 | 111 | ||
| 111 | static int any_help_event_p; | 112 | static int any_help_event_p; |
| 112 | 113 | ||
| 113 | /* Non-zero means autoselect window with the mouse cursor. */ | 114 | /* Last window where we saw the mouse. Used by mouse-autoselect-window. */ |
| 114 | 115 | static Lisp_Object last_window; | |
| 115 | int x_autoselect_window_p; | ||
| 116 | 116 | ||
| 117 | /* Non-zero means make use of UNDERLINE_POSITION font properties. */ | 117 | /* Non-zero means make use of UNDERLINE_POSITION font properties. */ |
| 118 | 118 | ||
| @@ -273,14 +273,16 @@ static void x_font_min_bounds P_ ((XFontStruct *, int *, int *)); | |||
| 273 | static int x_compute_min_glyph_bounds P_ ((struct frame *)); | 273 | static int x_compute_min_glyph_bounds P_ ((struct frame *)); |
| 274 | static void x_update_end P_ ((struct frame *)); | 274 | static void x_update_end P_ ((struct frame *)); |
| 275 | static void XTframe_up_to_date P_ ((struct frame *)); | 275 | static void XTframe_up_to_date P_ ((struct frame *)); |
| 276 | static void XTreassert_line_highlight P_ ((int, int)); | ||
| 277 | static void x_change_line_highlight P_ ((int, int, int, int)); | ||
| 278 | static void XTset_terminal_modes P_ ((void)); | 276 | static void XTset_terminal_modes P_ ((void)); |
| 279 | static void XTreset_terminal_modes P_ ((void)); | 277 | static void XTreset_terminal_modes P_ ((void)); |
| 280 | static void x_clear_frame P_ ((void)); | 278 | static void x_clear_frame P_ ((void)); |
| 281 | static void frame_highlight P_ ((struct frame *)); | 279 | static void frame_highlight P_ ((struct frame *)); |
| 282 | static void frame_unhighlight P_ ((struct frame *)); | 280 | static void frame_unhighlight P_ ((struct frame *)); |
| 283 | static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); | 281 | static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); |
| 282 | static void mac_focus_changed P_ ((int, struct mac_display_info *, | ||
| 283 | struct frame *, struct input_event *)); | ||
| 284 | static void x_detect_focus_change P_ ((struct mac_display_info *, | ||
| 285 | EventRecord *, struct input_event *)); | ||
| 284 | static void XTframe_rehighlight P_ ((struct frame *)); | 286 | static void XTframe_rehighlight P_ ((struct frame *)); |
| 285 | static void x_frame_rehighlight P_ ((struct x_display_info *)); | 287 | static void x_frame_rehighlight P_ ((struct x_display_info *)); |
| 286 | static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); | 288 | static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); |
| @@ -1198,15 +1200,6 @@ XSetFont (display, gc, font) | |||
| 1198 | } | 1200 | } |
| 1199 | 1201 | ||
| 1200 | 1202 | ||
| 1201 | static void | ||
| 1202 | XTextExtents16 (XFontStruct *font, XChar2b *text, int nchars, | ||
| 1203 | int *direction,int *font_ascent, | ||
| 1204 | int *font_descent, XCharStruct *cs) | ||
| 1205 | { | ||
| 1206 | /* MAC_TODO: Use GetTextMetrics to do this and inline it below. */ | ||
| 1207 | } | ||
| 1208 | |||
| 1209 | |||
| 1210 | /* x_sync is a no-op on Mac. */ | 1203 | /* x_sync is a no-op on Mac. */ |
| 1211 | void | 1204 | void |
| 1212 | x_sync (f) | 1205 | x_sync (f) |
| @@ -3494,6 +3487,14 @@ static void | |||
| 3494 | frame_highlight (f) | 3487 | frame_highlight (f) |
| 3495 | struct frame *f; | 3488 | struct frame *f; |
| 3496 | { | 3489 | { |
| 3490 | OSErr err; | ||
| 3491 | ControlRef root_control; | ||
| 3492 | |||
| 3493 | BLOCK_INPUT; | ||
| 3494 | err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control); | ||
| 3495 | if (err == noErr) | ||
| 3496 | ActivateControl (root_control); | ||
| 3497 | UNBLOCK_INPUT; | ||
| 3497 | x_update_cursor (f, 1); | 3498 | x_update_cursor (f, 1); |
| 3498 | } | 3499 | } |
| 3499 | 3500 | ||
| @@ -3501,6 +3502,14 @@ static void | |||
| 3501 | frame_unhighlight (f) | 3502 | frame_unhighlight (f) |
| 3502 | struct frame *f; | 3503 | struct frame *f; |
| 3503 | { | 3504 | { |
| 3505 | OSErr err; | ||
| 3506 | ControlRef root_control; | ||
| 3507 | |||
| 3508 | BLOCK_INPUT; | ||
| 3509 | err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control); | ||
| 3510 | if (err == noErr) | ||
| 3511 | DeactivateControl (root_control); | ||
| 3512 | UNBLOCK_INPUT; | ||
| 3504 | x_update_cursor (f, 1); | 3513 | x_update_cursor (f, 1); |
| 3505 | } | 3514 | } |
| 3506 | 3515 | ||
| @@ -3543,6 +3552,68 @@ x_new_focus_frame (dpyinfo, frame) | |||
| 3543 | x_frame_rehighlight (dpyinfo); | 3552 | x_frame_rehighlight (dpyinfo); |
| 3544 | } | 3553 | } |
| 3545 | 3554 | ||
| 3555 | /* Handle FocusIn and FocusOut state changes for FRAME. | ||
| 3556 | If FRAME has focus and there exists more than one frame, puts | ||
| 3557 | a FOCUS_IN_EVENT into *BUFP. */ | ||
| 3558 | |||
| 3559 | static void | ||
| 3560 | mac_focus_changed (type, dpyinfo, frame, bufp) | ||
| 3561 | int type; | ||
| 3562 | struct mac_display_info *dpyinfo; | ||
| 3563 | struct frame *frame; | ||
| 3564 | struct input_event *bufp; | ||
| 3565 | { | ||
| 3566 | if (type == activeFlag) | ||
| 3567 | { | ||
| 3568 | if (dpyinfo->x_focus_event_frame != frame) | ||
| 3569 | { | ||
| 3570 | x_new_focus_frame (dpyinfo, frame); | ||
| 3571 | dpyinfo->x_focus_event_frame = frame; | ||
| 3572 | |||
| 3573 | /* Don't stop displaying the initial startup message | ||
| 3574 | for a switch-frame event we don't need. */ | ||
| 3575 | if (GC_NILP (Vterminal_frame) | ||
| 3576 | && GC_CONSP (Vframe_list) | ||
| 3577 | && !GC_NILP (XCDR (Vframe_list))) | ||
| 3578 | { | ||
| 3579 | bufp->kind = FOCUS_IN_EVENT; | ||
| 3580 | XSETFRAME (bufp->frame_or_window, frame); | ||
| 3581 | } | ||
| 3582 | } | ||
| 3583 | } | ||
| 3584 | else | ||
| 3585 | { | ||
| 3586 | if (dpyinfo->x_focus_event_frame == frame) | ||
| 3587 | { | ||
| 3588 | dpyinfo->x_focus_event_frame = 0; | ||
| 3589 | x_new_focus_frame (dpyinfo, 0); | ||
| 3590 | } | ||
| 3591 | } | ||
| 3592 | } | ||
| 3593 | |||
| 3594 | /* The focus may have changed. Figure out if it is a real focus change, | ||
| 3595 | by checking both FocusIn/Out and Enter/LeaveNotify events. | ||
| 3596 | |||
| 3597 | Returns FOCUS_IN_EVENT event in *BUFP. */ | ||
| 3598 | |||
| 3599 | static void | ||
| 3600 | x_detect_focus_change (dpyinfo, event, bufp) | ||
| 3601 | struct mac_display_info *dpyinfo; | ||
| 3602 | EventRecord *event; | ||
| 3603 | struct input_event *bufp; | ||
| 3604 | { | ||
| 3605 | struct frame *frame; | ||
| 3606 | |||
| 3607 | frame = mac_window_to_frame ((WindowPtr) event->message); | ||
| 3608 | if (! frame) | ||
| 3609 | return; | ||
| 3610 | |||
| 3611 | /* On Mac, this is only called from focus events, so no switch needed. */ | ||
| 3612 | mac_focus_changed ((event->modifiers & activeFlag), | ||
| 3613 | dpyinfo, frame, bufp); | ||
| 3614 | } | ||
| 3615 | |||
| 3616 | |||
| 3546 | /* Handle an event saying the mouse has moved out of an Emacs frame. */ | 3617 | /* Handle an event saying the mouse has moved out of an Emacs frame. */ |
| 3547 | 3618 | ||
| 3548 | void | 3619 | void |
| @@ -3980,25 +4051,19 @@ remember_mouse_glyph (f1, gx, gy) | |||
| 3980 | } | 4051 | } |
| 3981 | 4052 | ||
| 3982 | 4053 | ||
| 3983 | static WindowPtr | 4054 | static struct frame * |
| 3984 | front_emacs_window () | 4055 | mac_focus_frame (dpyinfo) |
| 4056 | struct mac_display_info *dpyinfo; | ||
| 3985 | { | 4057 | { |
| 3986 | #if TARGET_API_MAC_CARBON | 4058 | if (dpyinfo->x_focus_frame) |
| 3987 | WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true); | 4059 | return dpyinfo->x_focus_frame; |
| 3988 | 4060 | else | |
| 3989 | while (wp && !is_emacs_window (wp)) | 4061 | /* Mac version may get events, such as a menu bar click, even when |
| 3990 | wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true); | 4062 | all the frames are invisible. In this case, we regard the |
| 3991 | #else | 4063 | event came to the selected frame. */ |
| 3992 | WindowPtr wp = FrontWindow (); | 4064 | return SELECTED_FRAME (); |
| 3993 | |||
| 3994 | while (wp && (wp == tip_window || !is_emacs_window (wp))) | ||
| 3995 | wp = GetNextWindow (wp); | ||
| 3996 | #endif | ||
| 3997 | |||
| 3998 | return wp; | ||
| 3999 | } | 4065 | } |
| 4000 | 4066 | ||
| 4001 | #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP) | ||
| 4002 | 4067 | ||
| 4003 | /* Return the current position of the mouse. | 4068 | /* Return the current position of the mouse. |
| 4004 | *fp should be a frame which indicates which display to ask about. | 4069 | *fp should be a frame which indicates which display to ask about. |
| @@ -4031,13 +4096,10 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 4031 | { | 4096 | { |
| 4032 | Point mouse_pos; | 4097 | Point mouse_pos; |
| 4033 | int ignore1, ignore2; | 4098 | int ignore1, ignore2; |
| 4034 | WindowPtr wp = front_emacs_window (); | 4099 | struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp)); |
| 4035 | struct frame *f; | 4100 | WindowPtr wp = FRAME_MAC_WINDOW (f); |
| 4036 | Lisp_Object frame, tail; | 4101 | Lisp_Object frame, tail; |
| 4037 | 4102 | ||
| 4038 | if (is_emacs_window(wp)) | ||
| 4039 | f = mac_window_to_frame (wp); | ||
| 4040 | |||
| 4041 | BLOCK_INPUT; | 4103 | BLOCK_INPUT; |
| 4042 | 4104 | ||
| 4043 | if (! NILP (last_mouse_scroll_bar) && insist == 0) | 4105 | if (! NILP (last_mouse_scroll_bar) && insist == 0) |
| @@ -4604,7 +4666,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) | |||
| 4604 | unsigned long *time; | 4666 | unsigned long *time; |
| 4605 | { | 4667 | { |
| 4606 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 4668 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); |
| 4607 | WindowPtr wp = front_emacs_window (); | 4669 | ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); |
| 4670 | #if TARGET_API_MAC_CARBON | ||
| 4671 | WindowPtr wp = GetControlOwner (ch); | ||
| 4672 | #else | ||
| 4673 | WindowPtr wp = (*ch)->contrlOwner; | ||
| 4674 | #endif | ||
| 4608 | Point mouse_pos; | 4675 | Point mouse_pos; |
| 4609 | struct frame *f = mac_window_to_frame (wp); | 4676 | struct frame *f = mac_window_to_frame (wp); |
| 4610 | int win_y, top_range; | 4677 | int win_y, top_range; |
| @@ -5050,7 +5117,7 @@ x_new_fontset (f, fontsetname) | |||
| 5050 | return Qnil; | 5117 | return Qnil; |
| 5051 | 5118 | ||
| 5052 | /* Since x_new_font doesn't update any fontset information, do it now. */ | 5119 | /* Since x_new_font doesn't update any fontset information, do it now. */ |
| 5053 | FRAME_FONTSET(f) = fontset; | 5120 | FRAME_FONTSET (f) = fontset; |
| 5054 | 5121 | ||
| 5055 | return build_string (fontsetname); | 5122 | return build_string (fontsetname); |
| 5056 | } | 5123 | } |
| @@ -5498,6 +5565,13 @@ x_make_frame_invisible (f) | |||
| 5498 | 5565 | ||
| 5499 | BLOCK_INPUT; | 5566 | BLOCK_INPUT; |
| 5500 | 5567 | ||
| 5568 | /* Before unmapping the window, update the WM_SIZE_HINTS property to claim | ||
| 5569 | that the current position of the window is user-specified, rather than | ||
| 5570 | program-specified, so that when the window is mapped again, it will be | ||
| 5571 | placed at the same location, without forcing the user to position it | ||
| 5572 | by hand again (they have already done that once for this window.) */ | ||
| 5573 | x_wm_set_size_hint (f, (long) 0, 1); | ||
| 5574 | |||
| 5501 | HideWindow (FRAME_MAC_WINDOW (f)); | 5575 | HideWindow (FRAME_MAC_WINDOW (f)); |
| 5502 | 5576 | ||
| 5503 | /* We can't distinguish this from iconification | 5577 | /* We can't distinguish this from iconification |
| @@ -7454,21 +7528,6 @@ do_app_resume () | |||
| 7454 | { | 7528 | { |
| 7455 | /* Window-activate events will do the job. */ | 7529 | /* Window-activate events will do the job. */ |
| 7456 | #if 0 | 7530 | #if 0 |
| 7457 | WindowPtr wp; | ||
| 7458 | struct frame *f; | ||
| 7459 | |||
| 7460 | wp = front_emacs_window (); | ||
| 7461 | if (wp) | ||
| 7462 | { | ||
| 7463 | f = mac_window_to_frame (wp); | ||
| 7464 | |||
| 7465 | if (f) | ||
| 7466 | { | ||
| 7467 | x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); | ||
| 7468 | activate_scroll_bars (f); | ||
| 7469 | } | ||
| 7470 | } | ||
| 7471 | |||
| 7472 | app_is_suspended = false; | 7531 | app_is_suspended = false; |
| 7473 | app_sleep_time = WNE_SLEEP_AT_RESUME; | 7532 | app_sleep_time = WNE_SLEEP_AT_RESUME; |
| 7474 | #endif | 7533 | #endif |
| @@ -7479,21 +7538,6 @@ do_app_suspend () | |||
| 7479 | { | 7538 | { |
| 7480 | /* Window-deactivate events will do the job. */ | 7539 | /* Window-deactivate events will do the job. */ |
| 7481 | #if 0 | 7540 | #if 0 |
| 7482 | WindowPtr wp; | ||
| 7483 | struct frame *f; | ||
| 7484 | |||
| 7485 | wp = front_emacs_window (); | ||
| 7486 | if (wp) | ||
| 7487 | { | ||
| 7488 | f = mac_window_to_frame (wp); | ||
| 7489 | |||
| 7490 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | ||
| 7491 | { | ||
| 7492 | x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); | ||
| 7493 | deactivate_scroll_bars (f); | ||
| 7494 | } | ||
| 7495 | } | ||
| 7496 | |||
| 7497 | app_is_suspended = true; | 7541 | app_is_suspended = true; |
| 7498 | app_sleep_time = WNE_SLEEP_AT_SUSPEND; | 7542 | app_sleep_time = WNE_SLEEP_AT_SUSPEND; |
| 7499 | #endif | 7543 | #endif |
| @@ -7501,40 +7545,6 @@ do_app_suspend () | |||
| 7501 | 7545 | ||
| 7502 | 7546 | ||
| 7503 | static void | 7547 | static void |
| 7504 | do_mouse_moved (mouse_pos, f) | ||
| 7505 | Point mouse_pos; | ||
| 7506 | FRAME_PTR *f; | ||
| 7507 | { | ||
| 7508 | WindowPtr wp = front_emacs_window (); | ||
| 7509 | struct x_display_info *dpyinfo; | ||
| 7510 | |||
| 7511 | if (wp) | ||
| 7512 | { | ||
| 7513 | *f = mac_window_to_frame (wp); | ||
| 7514 | dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); | ||
| 7515 | |||
| 7516 | if (dpyinfo->mouse_face_hidden) | ||
| 7517 | { | ||
| 7518 | dpyinfo->mouse_face_hidden = 0; | ||
| 7519 | clear_mouse_face (dpyinfo); | ||
| 7520 | } | ||
| 7521 | |||
| 7522 | SetPortWindowPort (wp); | ||
| 7523 | |||
| 7524 | GlobalToLocal (&mouse_pos); | ||
| 7525 | |||
| 7526 | if (dpyinfo->grabbed && tracked_scroll_bar) | ||
| 7527 | x_scroll_bar_note_movement (tracked_scroll_bar, | ||
| 7528 | mouse_pos.v | ||
| 7529 | - XINT (tracked_scroll_bar->top), | ||
| 7530 | TickCount() * (1000 / 60)); | ||
| 7531 | else | ||
| 7532 | note_mouse_movement (*f, &mouse_pos); | ||
| 7533 | } | ||
| 7534 | } | ||
| 7535 | |||
| 7536 | |||
| 7537 | static void | ||
| 7538 | do_apple_menu (SInt16 menu_item) | 7548 | do_apple_menu (SInt16 menu_item) |
| 7539 | { | 7549 | { |
| 7540 | #if !TARGET_API_MAC_CARBON | 7550 | #if !TARGET_API_MAC_CARBON |
| @@ -7570,7 +7580,7 @@ do_menu_choice (SInt32 menu_choice) | |||
| 7570 | 7580 | ||
| 7571 | default: | 7581 | default: |
| 7572 | { | 7582 | { |
| 7573 | struct frame *f = mac_window_to_frame (front_emacs_window ()); | 7583 | struct frame *f = mac_focus_frame (&one_mac_display_info); |
| 7574 | MenuHandle menu = GetMenuHandle (menu_id); | 7584 | MenuHandle menu = GetMenuHandle (menu_id); |
| 7575 | if (menu) | 7585 | if (menu) |
| 7576 | { | 7586 | { |
| @@ -7648,13 +7658,14 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7648 | Point top_left; | 7658 | Point top_left; |
| 7649 | int w_title_height, columns, rows, width, height; | 7659 | int w_title_height, columns, rows, width, height; |
| 7650 | struct frame *f = mac_window_to_frame (w); | 7660 | struct frame *f = mac_window_to_frame (w); |
| 7661 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); | ||
| 7651 | 7662 | ||
| 7652 | #if TARGET_API_MAC_CARBON | 7663 | #if TARGET_API_MAC_CARBON |
| 7653 | { | 7664 | { |
| 7654 | Point standard_size; | 7665 | Point standard_size; |
| 7655 | 7666 | ||
| 7656 | standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); | 7667 | standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); |
| 7657 | standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height; | 7668 | standard_size.v = dpyinfo->height; |
| 7658 | 7669 | ||
| 7659 | if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) | 7670 | if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) |
| 7660 | zoom_in_or_out = inZoomIn; | 7671 | zoom_in_or_out = inZoomIn; |
| @@ -7710,7 +7721,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7710 | = zoom_rect; | 7721 | = zoom_rect; |
| 7711 | } | 7722 | } |
| 7712 | 7723 | ||
| 7713 | ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ()); | 7724 | ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo)); |
| 7714 | 7725 | ||
| 7715 | SetPort (save_port); | 7726 | SetPort (save_port); |
| 7716 | #endif /* not TARGET_API_MAC_CARBON */ | 7727 | #endif /* not TARGET_API_MAC_CARBON */ |
| @@ -8576,10 +8587,13 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8576 | { | 8587 | { |
| 8577 | SInt32 delta; | 8588 | SInt32 delta; |
| 8578 | Point point; | 8589 | Point point; |
| 8579 | WindowPtr window_ptr = front_emacs_window (); | 8590 | struct frame *f = mac_focus_frame (dpyinfo); |
| 8591 | WindowPtr window_ptr; | ||
| 8580 | 8592 | ||
| 8581 | if (!IsValidWindowPtr (window_ptr)) | 8593 | if (!f) |
| 8582 | { | 8594 | { |
| 8595 | /* Beep if wheel move occurs when all the frames | ||
| 8596 | are invisible. */ | ||
| 8583 | SysBeep(1); | 8597 | SysBeep(1); |
| 8584 | break; | 8598 | break; |
| 8585 | } | 8599 | } |
| @@ -8595,6 +8609,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8595 | inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) | 8609 | inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) |
| 8596 | | ((delta < 0) ? down_modifier | 8610 | | ((delta < 0) ? down_modifier |
| 8597 | : up_modifier)); | 8611 | : up_modifier)); |
| 8612 | window_ptr = FRAME_MAC_WINDOW (f); | ||
| 8598 | SetPortWindowPort (window_ptr); | 8613 | SetPortWindowPort (window_ptr); |
| 8599 | GlobalToLocal (&point); | 8614 | GlobalToLocal (&point); |
| 8600 | XSETINT (inev.x, point.h); | 8615 | XSETINT (inev.x, point.h); |
| @@ -8653,14 +8668,14 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8653 | switch (part_code) | 8668 | switch (part_code) |
| 8654 | { | 8669 | { |
| 8655 | case inMenuBar: | 8670 | case inMenuBar: |
| 8656 | f = mac_window_to_frame (front_emacs_window ()); | 8671 | f = mac_focus_frame (dpyinfo); |
| 8657 | saved_menu_event_location = er.where; | 8672 | saved_menu_event_location = er.where; |
| 8658 | inev.kind = MENU_BAR_ACTIVATE_EVENT; | 8673 | inev.kind = MENU_BAR_ACTIVATE_EVENT; |
| 8659 | XSETFRAME (inev.frame_or_window, f); | 8674 | XSETFRAME (inev.frame_or_window, f); |
| 8660 | break; | 8675 | break; |
| 8661 | 8676 | ||
| 8662 | case inContent: | 8677 | case inContent: |
| 8663 | if (window_ptr != front_emacs_window ()) | 8678 | if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo))) |
| 8664 | SelectWindow (window_ptr); | 8679 | SelectWindow (window_ptr); |
| 8665 | else | 8680 | else |
| 8666 | { | 8681 | { |
| @@ -8851,7 +8866,61 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8851 | help_echo_string = help_echo_object = help_echo_window = Qnil; | 8866 | help_echo_string = help_echo_object = help_echo_window = Qnil; |
| 8852 | help_echo_pos = -1; | 8867 | help_echo_pos = -1; |
| 8853 | 8868 | ||
| 8854 | do_mouse_moved (er.where, &f); | 8869 | if (dpyinfo->grabbed && last_mouse_frame |
| 8870 | && FRAME_LIVE_P (last_mouse_frame)) | ||
| 8871 | f = last_mouse_frame; | ||
| 8872 | else | ||
| 8873 | f = dpyinfo->x_focus_frame; | ||
| 8874 | |||
| 8875 | if (dpyinfo->mouse_face_hidden) | ||
| 8876 | { | ||
| 8877 | dpyinfo->mouse_face_hidden = 0; | ||
| 8878 | clear_mouse_face (dpyinfo); | ||
| 8879 | } | ||
| 8880 | |||
| 8881 | if (f) | ||
| 8882 | { | ||
| 8883 | WindowPtr wp = FRAME_MAC_WINDOW (f); | ||
| 8884 | Point mouse_pos = er.where; | ||
| 8885 | |||
| 8886 | SetPortWindowPort (wp); | ||
| 8887 | |||
| 8888 | GlobalToLocal (&mouse_pos); | ||
| 8889 | |||
| 8890 | if (dpyinfo->grabbed && tracked_scroll_bar) | ||
| 8891 | x_scroll_bar_note_movement (tracked_scroll_bar, | ||
| 8892 | mouse_pos.v | ||
| 8893 | - XINT (tracked_scroll_bar->top), | ||
| 8894 | TickCount() * (1000 / 60)); | ||
| 8895 | else | ||
| 8896 | { | ||
| 8897 | /* Generate SELECT_WINDOW_EVENTs when needed. */ | ||
| 8898 | if (mouse_autoselect_window) | ||
| 8899 | { | ||
| 8900 | Lisp_Object window; | ||
| 8901 | |||
| 8902 | window = window_from_coordinates (f, | ||
| 8903 | mouse_pos.h, | ||
| 8904 | mouse_pos.v, | ||
| 8905 | 0, 0, 0, 0); | ||
| 8906 | |||
| 8907 | /* Window will be selected only when it is | ||
| 8908 | not selected now and last mouse movement | ||
| 8909 | event was not in it. Minibuffer window | ||
| 8910 | will be selected iff it is active. */ | ||
| 8911 | if (WINDOWP (window) | ||
| 8912 | && !EQ (window, last_window) | ||
| 8913 | && !EQ (window, selected_window)) | ||
| 8914 | { | ||
| 8915 | inev.kind = SELECT_WINDOW_EVENT; | ||
| 8916 | inev.frame_or_window = window; | ||
| 8917 | } | ||
| 8918 | |||
| 8919 | last_window=window; | ||
| 8920 | } | ||
| 8921 | note_mouse_movement (f, &mouse_pos); | ||
| 8922 | } | ||
| 8923 | } | ||
| 8855 | 8924 | ||
| 8856 | /* If the contents of the global variable | 8925 | /* If the contents of the global variable |
| 8857 | help_echo_string has changed, generate a | 8926 | help_echo_string has changed, generate a |
| @@ -8865,7 +8934,6 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8865 | case activateEvt: | 8934 | case activateEvt: |
| 8866 | { | 8935 | { |
| 8867 | WindowPtr window_ptr = (WindowPtr) er.message; | 8936 | WindowPtr window_ptr = (WindowPtr) er.message; |
| 8868 | ControlRef root_control; | ||
| 8869 | 8937 | ||
| 8870 | #if USE_CARBON_EVENTS | 8938 | #if USE_CARBON_EVENTS |
| 8871 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | 8939 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| @@ -8881,16 +8949,12 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8881 | if (!is_emacs_window (window_ptr)) | 8949 | if (!is_emacs_window (window_ptr)) |
| 8882 | break; | 8950 | break; |
| 8883 | 8951 | ||
| 8884 | f = mac_window_to_frame (window_ptr); | ||
| 8885 | GetRootControl (window_ptr, &root_control); | ||
| 8886 | |||
| 8887 | if ((er.modifiers & activeFlag) != 0) | 8952 | if ((er.modifiers & activeFlag) != 0) |
| 8888 | { | 8953 | { |
| 8889 | /* A window has been activated */ | 8954 | /* A window has been activated */ |
| 8890 | Point mouse_loc = er.where; | 8955 | Point mouse_loc = er.where; |
| 8891 | 8956 | ||
| 8892 | x_new_focus_frame (dpyinfo, f); | 8957 | x_detect_focus_change (dpyinfo, &er, &inev); |
| 8893 | ActivateControl (root_control); | ||
| 8894 | 8958 | ||
| 8895 | SetPortWindowPort (window_ptr); | 8959 | SetPortWindowPort (window_ptr); |
| 8896 | GlobalToLocal (&mouse_loc); | 8960 | GlobalToLocal (&mouse_loc); |
| @@ -8904,13 +8968,9 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8904 | /* A window has been deactivated */ | 8968 | /* A window has been deactivated */ |
| 8905 | dpyinfo->grabbed = 0; | 8969 | dpyinfo->grabbed = 0; |
| 8906 | 8970 | ||
| 8907 | if (f == dpyinfo->x_focus_frame) | 8971 | x_detect_focus_change (dpyinfo, &er, &inev); |
| 8908 | { | ||
| 8909 | x_new_focus_frame (dpyinfo, 0); | ||
| 8910 | DeactivateControl (root_control); | ||
| 8911 | } | ||
| 8912 | |||
| 8913 | 8972 | ||
| 8973 | f = mac_window_to_frame (window_ptr); | ||
| 8914 | if (f == dpyinfo->mouse_face_mouse_frame) | 8974 | if (f == dpyinfo->mouse_face_mouse_frame) |
| 8915 | { | 8975 | { |
| 8916 | /* If we move outside the frame, then we're | 8976 | /* If we move outside the frame, then we're |
| @@ -8951,13 +9011,14 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8951 | break; | 9011 | break; |
| 8952 | #endif | 9012 | #endif |
| 8953 | 9013 | ||
| 8954 | #if TARGET_API_MAC_CARBON | 9014 | if (dpyinfo->x_focus_frame == NULL) |
| 8955 | if (!IsValidWindowPtr (front_emacs_window ())) | ||
| 8956 | { | 9015 | { |
| 9016 | /* Beep if keyboard input occurs when all the frames | ||
| 9017 | are invisible. */ | ||
| 8957 | SysBeep (1); | 9018 | SysBeep (1); |
| 8958 | break; | 9019 | break; |
| 8959 | } | 9020 | } |
| 8960 | #endif | 9021 | |
| 8961 | { | 9022 | { |
| 8962 | static SInt16 last_key_script = -1; | 9023 | static SInt16 last_key_script = -1; |
| 8963 | SInt16 current_key_script = GetScriptManagerVariable (smKeyScript); | 9024 | SInt16 current_key_script = GetScriptManagerVariable (smKeyScript); |
| @@ -8965,7 +9026,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8965 | if (last_key_script != current_key_script) | 9026 | if (last_key_script != current_key_script) |
| 8966 | { | 9027 | { |
| 8967 | struct input_event event; | 9028 | struct input_event event; |
| 8968 | 9029 | ||
| 8969 | EVENT_INIT (event); | 9030 | EVENT_INIT (event); |
| 8970 | event.kind = LANGUAGE_CHANGE_EVENT; | 9031 | event.kind = LANGUAGE_CHANGE_EVENT; |
| 8971 | event.arg = Qnil; | 9032 | event.arg = Qnil; |
| @@ -9009,18 +9070,20 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9009 | unsigned long some_state = 0; | 9070 | unsigned long some_state = 0; |
| 9010 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | 9071 | inev.code = KeyTranslate (kchr_ptr, new_keycode, |
| 9011 | &some_state) & 0xff; | 9072 | &some_state) & 0xff; |
| 9012 | } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) | 9073 | } |
| 9013 | { | 9074 | else if (!NILP (Vmac_option_modifier) |
| 9014 | /* When using the option key as an emacs modifier, convert | 9075 | && (er.modifiers & optionKey)) |
| 9015 | the pressed key code back to one without the Mac option | 9076 | { |
| 9016 | modifier applied. */ | 9077 | /* When using the option key as an emacs modifier, |
| 9017 | int new_modifiers = er.modifiers & ~optionKey; | 9078 | convert the pressed key code back to one |
| 9018 | int new_keycode = keycode | new_modifiers; | 9079 | without the Mac option modifier applied. */ |
| 9019 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | 9080 | int new_modifiers = er.modifiers & ~optionKey; |
| 9020 | unsigned long some_state = 0; | 9081 | int new_keycode = keycode | new_modifiers; |
| 9021 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | 9082 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); |
| 9022 | &some_state) & 0xff; | 9083 | unsigned long some_state = 0; |
| 9023 | } | 9084 | inev.code = KeyTranslate (kchr_ptr, new_keycode, |
| 9085 | &some_state) & 0xff; | ||
| 9086 | } | ||
| 9024 | else | 9087 | else |
| 9025 | inev.code = er.message & charCodeMask; | 9088 | inev.code = er.message & charCodeMask; |
| 9026 | inev.kind = ASCII_KEYSTROKE_EVENT; | 9089 | inev.kind = ASCII_KEYSTROKE_EVENT; |
| @@ -9032,8 +9095,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9032 | #else | 9095 | #else |
| 9033 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 9096 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 9034 | #endif | 9097 | #endif |
| 9035 | XSETFRAME (inev.frame_or_window, | 9098 | XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo)); |
| 9036 | mac_window_to_frame (front_emacs_window ())); | ||
| 9037 | inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ | 9099 | inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ |
| 9038 | break; | 9100 | break; |
| 9039 | 9101 | ||
| @@ -9046,22 +9108,10 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9046 | constuct_drag_n_drop in w32term.c. */ | 9108 | constuct_drag_n_drop in w32term.c. */ |
| 9047 | if (!NILP (drag_and_drop_file_list)) | 9109 | if (!NILP (drag_and_drop_file_list)) |
| 9048 | { | 9110 | { |
| 9049 | struct frame *f = NULL; | 9111 | struct frame *f = mac_focus_frame (dpyinfo); |
| 9050 | WindowPtr wp; | 9112 | WindowPtr wp; |
| 9051 | Lisp_Object frame; | 9113 | Lisp_Object frame; |
| 9052 | 9114 | ||
| 9053 | wp = front_emacs_window (); | ||
| 9054 | |||
| 9055 | if (!wp) | ||
| 9056 | { | ||
| 9057 | struct frame *f = XFRAME (XCAR (Vframe_list)); | ||
| 9058 | CollapseWindow (FRAME_MAC_WINDOW (f), false); | ||
| 9059 | wp = front_emacs_window (); | ||
| 9060 | } | ||
| 9061 | |||
| 9062 | if (wp) | ||
| 9063 | f = mac_window_to_frame (wp); | ||
| 9064 | |||
| 9065 | inev.kind = DRAG_N_DROP_EVENT; | 9115 | inev.kind = DRAG_N_DROP_EVENT; |
| 9066 | inev.code = 0; | 9116 | inev.code = 0; |
| 9067 | inev.timestamp = er.when * (1000 / 60); | 9117 | inev.timestamp = er.when * (1000 / 60); |
| @@ -9078,10 +9128,12 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9078 | XSETFRAME (frame, f); | 9128 | XSETFRAME (frame, f); |
| 9079 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); | 9129 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); |
| 9080 | 9130 | ||
| 9131 | #if 0 | ||
| 9081 | /* Regardless of whether Emacs was suspended or in the | 9132 | /* Regardless of whether Emacs was suspended or in the |
| 9082 | foreground, ask it to redraw its entire screen. | 9133 | foreground, ask it to redraw its entire screen. |
| 9083 | Otherwise parts of the screen can be left in an | 9134 | Otherwise parts of the screen can be left in an |
| 9084 | inconsistent state. */ | 9135 | inconsistent state. */ |
| 9136 | wp = FRAME_MAC_WINDOW (f); | ||
| 9085 | if (wp) | 9137 | if (wp) |
| 9086 | #if TARGET_API_MAC_CARBON | 9138 | #if TARGET_API_MAC_CARBON |
| 9087 | { | 9139 | { |
| @@ -9093,6 +9145,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9093 | #else /* not TARGET_API_MAC_CARBON */ | 9145 | #else /* not TARGET_API_MAC_CARBON */ |
| 9094 | InvalRect (&(wp->portRect)); | 9146 | InvalRect (&(wp->portRect)); |
| 9095 | #endif /* not TARGET_API_MAC_CARBON */ | 9147 | #endif /* not TARGET_API_MAC_CARBON */ |
| 9148 | #endif | ||
| 9096 | } | 9149 | } |
| 9097 | default: | 9150 | default: |
| 9098 | break; | 9151 | break; |
| @@ -9572,7 +9625,7 @@ mac_check_for_quit_char () | |||
| 9572 | e.arg = Qnil; | 9625 | e.arg = Qnil; |
| 9573 | e.modifiers = NULL; | 9626 | e.modifiers = NULL; |
| 9574 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); | 9627 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); |
| 9575 | XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ())); | 9628 | XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info)); |
| 9576 | /* Remove event from queue to prevent looping. */ | 9629 | /* Remove event from queue to prevent looping. */ |
| 9577 | RemoveEventFromQueue (GetMainEventQueue (), event); | 9630 | RemoveEventFromQueue (GetMainEventQueue (), event); |
| 9578 | ReleaseEvent (event); | 9631 | ReleaseEvent (event); |
| @@ -9765,10 +9818,6 @@ syms_of_macterm () | |||
| 9765 | Qeuc_kr = intern ("euc-kr"); | 9818 | Qeuc_kr = intern ("euc-kr"); |
| 9766 | staticpro (&Qeuc_kr); | 9819 | staticpro (&Qeuc_kr); |
| 9767 | 9820 | ||
| 9768 | DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p, | ||
| 9769 | doc: /* *Non-nil means autoselect window with mouse pointer. */); | ||
| 9770 | x_autoselect_window_p = 0; | ||
| 9771 | |||
| 9772 | DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, | 9821 | DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, |
| 9773 | doc: /* If not nil, Emacs uses toolkit scroll bars. */); | 9822 | doc: /* If not nil, Emacs uses toolkit scroll bars. */); |
| 9774 | Vx_toolkit_scroll_bars = Qt; | 9823 | Vx_toolkit_scroll_bars = Qt; |