aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1994-03-23 20:11:17 +0000
committerKarl Heuer1994-03-23 20:11:17 +0000
commit0aed85f4d6a8021f458c75c9af77249d73679e6e (patch)
treecefdd93c256bba08bafa10c834c35128b4a6a140 /src
parent87498171d3cd0cbdc5058c0890103964d334ebd5 (diff)
downloademacs-0aed85f4d6a8021f458c75c9af77249d73679e6e.tar.gz
emacs-0aed85f4d6a8021f458c75c9af77249d73679e6e.zip
(do_switch_frame): Common code for Fselect_frame and handle_switch_frame.
Diffstat (limited to 'src')
-rw-r--r--src/frame.c102
1 files changed, 66 insertions, 36 deletions
diff --git a/src/frame.c b/src/frame.c
index df5ff2b4d2e..cdf61c88990 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -331,30 +331,10 @@ make_terminal_frame ()
331 return f; 331 return f;
332} 332}
333 333
334DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e", 334static Lisp_Object
335 "Select the frame FRAME.\n\ 335do_switch_frame (frame, no_enter, track)
336Subsequent editing commands apply to its selected window.\n\
337The selection of FRAME lasts until the next time the user does\n\
338something to select a different frame, or until the next time this\n\
339function is called.")
340 (frame, no_enter)
341 Lisp_Object frame, no_enter;
342{
343 return Fhandle_switch_frame (frame, no_enter);
344}
345
346
347DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
348 "Handle a switch-frame event EVENT.\n\
349Switch-frame events are usually bound to this function.\n\
350A switch-frame event tells Emacs that the window manager has requested\n\
351that the user's events be directed to the frame mentioned in the event.\n\
352This function selects the selected window of the frame of EVENT.\n\
353\n\
354If EVENT is frame object, handle it as if it were a switch-frame event\n\
355to that frame.")
356 (frame, no_enter)
357 Lisp_Object frame, no_enter; 336 Lisp_Object frame, no_enter;
337 int track;
358{ 338{
359 /* If FRAME is a switch-frame event, extract the frame we should 339 /* If FRAME is a switch-frame event, extract the frame we should
360 switch to. */ 340 switch to. */
@@ -373,6 +353,9 @@ to that frame.")
373 if (selected_frame == XFRAME (frame)) 353 if (selected_frame == XFRAME (frame))
374 return frame; 354 return frame;
375 355
356 /* This is too greedy; it causes inappropriate focus redirection
357 that's hard to get rid of. */
358#if 0
376 /* If a frame's focus has been redirected toward the currently 359 /* If a frame's focus has been redirected toward the currently
377 selected frame, we should change the redirection to point to the 360 selected frame, we should change the redirection to point to the
378 newly selected frame. This means that if the focus is redirected 361 newly selected frame. This means that if the focus is redirected
@@ -380,23 +363,41 @@ to that frame.")
380 can use `other-window' to switch between all the frames using 363 can use `other-window' to switch between all the frames using
381 that minibuffer frame, and the focus redirection will follow us 364 that minibuffer frame, and the focus redirection will follow us
382 around. */ 365 around. */
383 { 366 if (track)
384 Lisp_Object tail; 367 {
368 Lisp_Object tail;
385 369
386 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) 370 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr)
387 { 371 {
388 Lisp_Object focus; 372 Lisp_Object focus;
389 373
390 if (XTYPE (XCONS (tail)->car) != Lisp_Frame) 374 if (XTYPE (XCONS (tail)->car) != Lisp_Frame)
391 abort (); 375 abort ();
392 376
393 focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car)); 377 focus = FRAME_FOCUS_FRAME (XFRAME (XCONS (tail)->car));
394 378
395 if (XTYPE (focus) == Lisp_Frame 379 if (XTYPE (focus) == Lisp_Frame
396 && XFRAME (focus) == selected_frame) 380 && XFRAME (focus) == selected_frame)
397 Fredirect_frame_focus (XCONS (tail)->car, frame); 381 Fredirect_frame_focus (XCONS (tail)->car, frame);
398 } 382 }
399 } 383 }
384#else /* ! 0 */
385 /* Instead, apply it only to the frame we're pointing to. */
386#ifdef HAVE_X_WINDOWS
387 if (track)
388 {
389 Lisp_Object focus, xfocus;
390
391 xfocus = x_get_focus_frame ();
392 if (FRAMEP (xfocus))
393 {
394 focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
395 if (FRAMEP (focus) && XFRAME (focus) == selected_frame)
396 Fredirect_frame_focus (xfocus, frame);
397 }
398 }
399#endif /* HAVE_X_WINDOWS */
400#endif /* ! 0 */
400 401
401 selected_frame = XFRAME (frame); 402 selected_frame = XFRAME (frame);
402 if (! FRAME_MINIBUF_ONLY_P (selected_frame)) 403 if (! FRAME_MINIBUF_ONLY_P (selected_frame))
@@ -416,6 +417,35 @@ to that frame.")
416 return frame; 417 return frame;
417} 418}
418 419
420DEFUN ("select-frame", Fselect_frame, Sselect_frame, 1, 2, "e",
421 "Select the frame FRAME.\n\
422Subsequent editing commands apply to its selected window.\n\
423The selection of FRAME lasts until the next time the user does\n\
424something to select a different frame, or until the next time this\n\
425function is called.")
426 (frame, no_enter)
427 Lisp_Object frame, no_enter;
428{
429 return do_switch_frame (frame, no_enter, 1);
430}
431
432
433DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 2, "e",
434 "Handle a switch-frame event EVENT.\n\
435Switch-frame events are usually bound to this function.\n\
436A switch-frame event tells Emacs that the window manager has requested\n\
437that the user's events be directed to the frame mentioned in the event.\n\
438This function selects the selected window of the frame of EVENT.\n\
439\n\
440If EVENT is frame object, handle it as if it were a switch-frame event\n\
441to that frame.")
442 (frame, no_enter)
443 Lisp_Object frame, no_enter;
444{
445 return do_switch_frame (frame, no_enter, 0);
446}
447
448
419DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, 449DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0,
420 "Return the frame that is now selected.") 450 "Return the frame that is now selected.")
421 () 451 ()