diff options
Diffstat (limited to 'src/frame.c')
| -rw-r--r-- | src/frame.c | 78 |
1 files changed, 59 insertions, 19 deletions
diff --git a/src/frame.c b/src/frame.c index b4fa6123645..7ac1682830a 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -156,8 +156,10 @@ make_frame (mini_p) | |||
| 156 | f->no_split = 0; | 156 | f->no_split = 0; |
| 157 | f->garbaged = 0; | 157 | f->garbaged = 0; |
| 158 | f->has_minibuffer = mini_p; | 158 | f->has_minibuffer = mini_p; |
| 159 | f->focus_frame = frame; | 159 | f->focus_frame = Qnil; |
| 160 | f->explicit_name = 0; | 160 | f->explicit_name = 0; |
| 161 | f->can_have_scrollbars = 0; | ||
| 162 | f->has_vertical_scrollbars = 0; | ||
| 161 | 163 | ||
| 162 | f->param_alist = Qnil; | 164 | f->param_alist = Qnil; |
| 163 | 165 | ||
| @@ -314,8 +316,7 @@ make_terminal_frame () | |||
| 314 | Vframe_list = Qnil; | 316 | Vframe_list = Qnil; |
| 315 | f = make_frame (1); | 317 | f = make_frame (1); |
| 316 | f->name = build_string ("terminal"); | 318 | f->name = build_string ("terminal"); |
| 317 | f->async_visible = 1; | 319 | FRAME_SET_VISIBLE (f, 1); |
| 318 | f->visible = 1; | ||
| 319 | f->display.nothing = 1; /* Nonzero means frame isn't deleted. */ | 320 | f->display.nothing = 1; /* Nonzero means frame isn't deleted. */ |
| 320 | XSET (Vterminal_frame, Lisp_Frame, f); | 321 | XSET (Vterminal_frame, Lisp_Frame, f); |
| 321 | return f; | 322 | return f; |
| @@ -329,7 +330,10 @@ focus on that frame.\n\ | |||
| 329 | This function is interactive, and may be bound to the ``switch-frame''\n\ | 330 | This function is interactive, and may be bound to the ``switch-frame''\n\ |
| 330 | event; when invoked this way, it switches to the frame named in the\n\ | 331 | event; when invoked this way, it switches to the frame named in the\n\ |
| 331 | event. When called from lisp, FRAME may be a ``switch-frame'' event;\n\ | 332 | event. When called from lisp, FRAME may be a ``switch-frame'' event;\n\ |
| 332 | if it is, select the frame named in the event.") | 333 | if it is, select the frame named in the event.\n\ |
| 334 | \n\ | ||
| 335 | Changing the selected frame can change focus redirections. See\n\ | ||
| 336 | `redirect-frame-focus' for details.") | ||
| 333 | (frame, no_enter) | 337 | (frame, no_enter) |
| 334 | Lisp_Object frame, no_enter; | 338 | Lisp_Object frame, no_enter; |
| 335 | { | 339 | { |
| @@ -345,6 +349,31 @@ if it is, select the frame named in the event.") | |||
| 345 | if (selected_frame == XFRAME (frame)) | 349 | if (selected_frame == XFRAME (frame)) |
| 346 | return frame; | 350 | return frame; |
| 347 | 351 | ||
| 352 | /* If a frame's focus has been redirected toward the currently | ||
| 353 | selected frame, we should change the redirection to point to the | ||
| 354 | newly selected frame. This means that if the focus is redirected | ||
| 355 | from a minibufferless frame to a surrogate minibuffer frame, we | ||
| 356 | can use `other-window' to switch between all the frames using | ||
| 357 | that minibuffer frame, and the focus redirection will follow us | ||
| 358 | around. */ | ||
| 359 | { | ||
| 360 | Lisp_Object tail; | ||
| 361 | |||
| 362 | for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) | ||
| 363 | { | ||
| 364 | Lisp_Object focus; | ||
| 365 | |||
| 366 | if (XTYPE (XCONS (tail)->car) != Lisp_Frame) | ||
| 367 | abort (); | ||
| 368 | |||
| 369 | focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car)); | ||
| 370 | |||
| 371 | if (XTYPE (focus) == Lisp_Frame | ||
| 372 | && XFRAME (focus) == selected_frame) | ||
| 373 | Fredirect_frame_focus (XCONS (tail)->car, frame); | ||
| 374 | } | ||
| 375 | } | ||
| 376 | |||
| 348 | selected_frame = XFRAME (frame); | 377 | selected_frame = XFRAME (frame); |
| 349 | if (! FRAME_MINIBUF_ONLY_P (selected_frame)) | 378 | if (! FRAME_MINIBUF_ONLY_P (selected_frame)) |
| 350 | last_nonminibuf_frame = selected_frame; | 379 | last_nonminibuf_frame = selected_frame; |
| @@ -535,7 +564,7 @@ prev_frame (frame, minibuf) | |||
| 535 | 564 | ||
| 536 | DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0, | 565 | DEFUN ("next-frame", Fnext_frame, Snext_frame, 0, 2, 0, |
| 537 | "Return the next frame in the frame list after FRAME.\n\ | 566 | "Return the next frame in the frame list after FRAME.\n\ |
| 538 | By default, skip minibuffer-only frames. | 567 | By default, skip minibuffer-only frames.\n\ |
| 539 | If omitted, FRAME defaults to the selected frame.\n\ | 568 | If omitted, FRAME defaults to the selected frame.\n\ |
| 540 | If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\ | 569 | If optional argument MINIFRAME is non-nil, include minibuffer-only frames.\n\ |
| 541 | If MINIFRAME is a window, include only frames using that window for their\n\ | 570 | If MINIFRAME is a window, include only frames using that window for their\n\ |
| @@ -623,7 +652,7 @@ A frame may not be deleted if its minibuffer is used by other frames.") | |||
| 623 | f->root_window = Qnil; | 652 | f->root_window = Qnil; |
| 624 | 653 | ||
| 625 | Vframe_list = Fdelq (frame, Vframe_list); | 654 | Vframe_list = Fdelq (frame, Vframe_list); |
| 626 | f->visible = 0; | 655 | FRAME_SET_VISIBLE (f, 0); |
| 627 | displ = f->display; | 656 | displ = f->display; |
| 628 | f->display.nothing = 0; | 657 | f->display.nothing = 0; |
| 629 | 658 | ||
| @@ -867,9 +896,9 @@ Return the symbol `icon' if frame is visible only as an icon.") | |||
| 867 | { | 896 | { |
| 868 | CHECK_LIVE_FRAME (frame, 0); | 897 | CHECK_LIVE_FRAME (frame, 0); |
| 869 | 898 | ||
| 870 | if (XFRAME (frame)->visible) | 899 | if (FRAME_VISIBLE_P (XFRAME (frame))) |
| 871 | return Qt; | 900 | return Qt; |
| 872 | if (XFRAME (frame)->iconified) | 901 | if (FRAME_ICONIFIED_P (XFRAME (frame))) |
| 873 | return Qicon; | 902 | return Qicon; |
| 874 | return Qnil; | 903 | return Qnil; |
| 875 | } | 904 | } |
| @@ -890,7 +919,7 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, | |||
| 890 | if (XTYPE (frame) != Lisp_Frame) | 919 | if (XTYPE (frame) != Lisp_Frame) |
| 891 | continue; | 920 | continue; |
| 892 | f = XFRAME (frame); | 921 | f = XFRAME (frame); |
| 893 | if (f->visible) | 922 | if (FRAME_VISIBLE_P (f)) |
| 894 | value = Fcons (frame, value); | 923 | value = Fcons (frame, value); |
| 895 | } | 924 | } |
| 896 | return value; | 925 | return value; |
| @@ -901,25 +930,34 @@ DEFUN ("visible-frame-list", Fvisible_frame_list, Svisible_frame_list, | |||
| 901 | DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus, | 930 | DEFUN ("redirect-frame-focus", Fredirect_frame_focus, Sredirect_frame_focus, |
| 902 | 1, 2, 0, | 931 | 1, 2, 0, |
| 903 | "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\ | 932 | "Arrange for keystrokes typed at FRAME to be sent to FOCUS-FRAME.\n\ |
| 904 | This means that, after reading a keystroke typed at FRAME,\n\ | 933 | In other words, switch-frame events caused by events in FRAME will\n\ |
| 905 | `last-event-frame' will be FOCUS-FRAME.\n\ | 934 | request a switch to FOCUS-FRAME, and `last-event-frame' will be\n\ |
| 935 | FOCUS-FRAME after reading an event typed at FRAME.\n\ | ||
| 906 | \n\ | 936 | \n\ |
| 907 | If FOCUS-FRAME is omitted or eq to FRAME, any existing redirection is\n\ | 937 | If FOCUS-FRAME is omitted or nil, any existing redirection is\n\ |
| 908 | cancelled, and the frame again receives its own keystrokes.\n\ | 938 | cancelled, and the frame again receives its own keystrokes.\n\ |
| 909 | \n\ | 939 | \n\ |
| 910 | The redirection lasts until the next call to `redirect-frame-focus'\n\ | 940 | Focus redirection is useful for temporarily redirecting keystrokes to\n\ |
| 911 | or `select-frame'.\n\ | 941 | a surrogate minibuffer frame when a frame doesn't have its own\n\ |
| 942 | minibuffer window.\n\ | ||
| 912 | \n\ | 943 | \n\ |
| 913 | This is useful for temporarily redirecting keystrokes to the minibuffer\n\ | 944 | A frame's focus redirection can be changed by select-frame. If frame\n\ |
| 914 | window when a frame doesn't have its own minibuffer.") | 945 | FOO is selected, and then a different frame BAR is selected, any\n\ |
| 946 | frames redirecting their focus to FOO are shifted to redirect their\n\ | ||
| 947 | focus to BAR. This allows focus redirection to work properly when the\n\ | ||
| 948 | user switches from one frame to another using `select-window'.\n\ | ||
| 949 | \n\ | ||
| 950 | This means that a frame whose focus is redirected to itself is treated\n\ | ||
| 951 | differently from a frame whose focus is redirected to nil; the former\n\ | ||
| 952 | is affected by select-frame, while the latter is not.\n\ | ||
| 953 | \n\ | ||
| 954 | The redirection lasts until `redirect-frame-focus' is called to change it.") | ||
| 915 | (frame, focus_frame) | 955 | (frame, focus_frame) |
| 916 | Lisp_Object frame, focus_frame; | 956 | Lisp_Object frame, focus_frame; |
| 917 | { | 957 | { |
| 918 | CHECK_LIVE_FRAME (frame, 0); | 958 | CHECK_LIVE_FRAME (frame, 0); |
| 919 | 959 | ||
| 920 | if (NILP (focus_frame)) | 960 | if (! NILP (focus_frame)) |
| 921 | focus_frame = frame; | ||
| 922 | else | ||
| 923 | CHECK_LIVE_FRAME (focus_frame, 1); | 961 | CHECK_LIVE_FRAME (focus_frame, 1); |
| 924 | 962 | ||
| 925 | XFRAME (frame)->focus_frame = focus_frame; | 963 | XFRAME (frame)->focus_frame = focus_frame; |
| @@ -933,11 +971,13 @@ window when a frame doesn't have its own minibuffer.") | |||
| 933 | 971 | ||
| 934 | DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, | 972 | DEFUN ("frame-focus", Fframe_focus, Sframe_focus, 1, 1, 0, |
| 935 | "Return the frame to which FRAME's keystrokes are currently being sent.\n\ | 973 | "Return the frame to which FRAME's keystrokes are currently being sent.\n\ |
| 974 | This returns nil if FRAME's focus is not redirected.\n\ | ||
| 936 | See `redirect-frame-focus'.") | 975 | See `redirect-frame-focus'.") |
| 937 | (frame) | 976 | (frame) |
| 938 | Lisp_Object frame; | 977 | Lisp_Object frame; |
| 939 | { | 978 | { |
| 940 | CHECK_LIVE_FRAME (frame, 0); | 979 | CHECK_LIVE_FRAME (frame, 0); |
| 980 | |||
| 941 | return FRAME_FOCUS_FRAME (XFRAME (frame)); | 981 | return FRAME_FOCUS_FRAME (XFRAME (frame)); |
| 942 | } | 982 | } |
| 943 | 983 | ||