Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 280:7df0dd720c89 r21-0b38
Import from CVS: tag r21-0b38
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:32:22 +0200 |
parents | 90d73dddcdc4 |
children | c42ec1d1cded |
comparison
equal
deleted
inserted
replaced
279:c20b2fb5bb0a | 280:7df0dd720c89 |
---|---|
555 | 555 |
556 /* If a longjmp() happens in the callback, we're screwed. | 556 /* If a longjmp() happens in the callback, we're screwed. |
557 Let's hope it doesn't. I think the code here is fairly | 557 Let's hope it doesn't. I think the code here is fairly |
558 clean and doesn't do this. */ | 558 clean and doesn't do this. */ |
559 emacs_is_blocking = 1; | 559 emacs_is_blocking = 1; |
560 #if 0 | 560 |
561 /* Do this if the poll-for-quit timer seems to be taking too | 561 /* Do not poll for quit while blocking, because this prevents idle |
562 much CPU time when idle ... */ | 562 XEmacs from swapping out from memory */ |
563 reset_poll_for_quit (); | 563 reset_poll_for_quit (); |
564 #endif | 564 |
565 event_stream->next_event_cb (event); | 565 event_stream->next_event_cb (event); |
566 #if 0 | 566 |
567 init_poll_for_quit (); | 567 init_poll_for_quit (); |
568 #endif | 568 |
569 emacs_is_blocking = 0; | 569 emacs_is_blocking = 0; |
570 | 570 |
571 #ifdef DEBUG_XEMACS | 571 #ifdef DEBUG_XEMACS |
572 /* timeout events have more info set later, so | 572 /* timeout events have more info set later, so |
573 print the event out in next_event_internal(). */ | 573 print the event out in next_event_internal(). */ |
1716 function. */ | 1716 function. */ |
1717 #endif | 1717 #endif |
1718 run_hook (Qdeselect_frame_hook); | 1718 run_hook (Qdeselect_frame_hook); |
1719 } | 1719 } |
1720 | 1720 |
1721 /* When select-frame is called, we want to tell the window system that | 1721 /* When select-frame is called and focus_follows_mouse is false, we want |
1722 the focus should be changed to point to the new frame. However, | 1722 to tell the window system that the focus should be changed to point to |
1723 the new frame. However, | |
1723 sometimes Lisp functions will temporarily change the selected frame | 1724 sometimes Lisp functions will temporarily change the selected frame |
1724 (e.g. to call a function that operates on the selected frame), | 1725 (e.g. to call a function that operates on the selected frame), |
1725 and it's annoying if this focus-change happens exactly when | 1726 and it's annoying if this focus-change happens exactly when |
1726 select-frame is called, because then you get some flickering of the | 1727 select-frame is called, because then you get some flickering of the |
1727 window-manager border and perhaps other undesirable results. We | 1728 window-manager border and perhaps other undesirable results. We |
1728 really only want to change the focus when we're about to retrieve | 1729 really only want to change the focus when we're about to retrieve |
1729 an event from the user. To do this, we keep track of the frame | 1730 an event from the user. To do this, we keep track of the frame |
1730 where the window-manager focus lies on, and just before waiting | 1731 where the window-manager focus lies on, and just before waiting |
1731 for user events, check the currently selected frame and change | 1732 for user events, check the currently selected frame and change |
1732 the focus as necessary. */ | 1733 the focus as necessary. |
1733 | 1734 |
1734 static void | 1735 On the other hand, if focus_follows_mouse is true, we need to switch the |
1736 selected frame back to the frame with window manager focus just before we | |
1737 execute the next command in Fcommand_loop_1, just as the selected buffer is | |
1738 reverted after a set-buffer. | |
1739 | |
1740 Both cases are handled by this function. It must be called as appropriate | |
1741 from these two places, depending on the value of focus_follows_mouse. */ | |
1742 | |
1743 void | |
1735 investigate_frame_change (void) | 1744 investigate_frame_change (void) |
1736 { | 1745 { |
1737 Lisp_Object devcons, concons; | 1746 Lisp_Object devcons, concons; |
1738 | 1747 |
1739 /* if the selected frame was changed, change the window-system | 1748 /* if the selected frame was changed, change the window-system |
1749 but that can cause us to end up in an infinite loop focusing | 1758 but that can cause us to end up in an infinite loop focusing |
1750 between two frames. It seems that since the call to `select-frame' | 1759 between two frames. It seems that since the call to `select-frame' |
1751 in emacs_handle_focus_change_final() is based on the _FOR_HOOKS | 1760 in emacs_handle_focus_change_final() is based on the _FOR_HOOKS |
1752 value, we need to do so too. */ | 1761 value, we need to do so too. */ |
1753 if (!NILP (sel_frame) && | 1762 if (!NILP (sel_frame) && |
1754 !focus_follows_mouse && | |
1755 !EQ (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d), sel_frame) && | 1763 !EQ (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d), sel_frame) && |
1756 !NILP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d)) && | 1764 !NILP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d)) && |
1757 !EQ (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d), sel_frame)) | 1765 !EQ (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d), sel_frame)) |
1758 { | 1766 { |
1759 /* prevent us from issuing the same request more than once */ | 1767 /* At this point, we know that the frame has been changed. Now, if |
1760 DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d) = sel_frame; | 1768 * focus_follows_mouse is not set, we finish off the frame change, |
1761 MAYBE_DEVMETH (d, focus_on_frame, (XFRAME (sel_frame))); | 1769 * so that user events will now come from the new frame. Otherwise, |
1770 * if focus_follows_mouse is set, no gratuitous frame changing | |
1771 * should take place. Set the focus back to the frame which was | |
1772 * originally selected for user input. | |
1773 */ | |
1774 if (!focus_follows_mouse) | |
1775 { | |
1776 /* prevent us from issuing the same request more than once */ | |
1777 DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d) = sel_frame; | |
1778 MAYBE_DEVMETH (d, focus_on_frame, (XFRAME (sel_frame))); | |
1779 } | |
1780 else | |
1781 { | |
1782 Lisp_Object old_frame = Qnil; | |
1783 | |
1784 /* #### Do we really want to check OUGHT ?? | |
1785 * It seems to make sense, though I have never seen us | |
1786 * get here and have it be non-nil. | |
1787 */ | |
1788 if (FRAMEP (DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d))) | |
1789 old_frame = DEVICE_FRAME_THAT_OUGHT_TO_HAVE_FOCUS (d); | |
1790 else if (FRAMEP (DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d))) | |
1791 old_frame = DEVICE_FRAME_WITH_FOCUS_FOR_HOOKS (d); | |
1792 | |
1793 /* #### Can old_frame ever be NIL? play it safe.. */ | |
1794 if (!NILP (old_frame)) | |
1795 { | |
1796 /* Fselect_frame is not really the right thing: it frobs the | |
1797 * buffer stack. But there's no easy way to do the right | |
1798 * thing, and this code already had this problem anyway. | |
1799 */ | |
1800 Fselect_frame (old_frame); | |
1801 } | |
1802 } | |
1762 } | 1803 } |
1763 } | 1804 } |
1764 } | 1805 } |
1765 | 1806 |
1766 static Lisp_Object | 1807 static Lisp_Object |
1930 callers (ie, Fnext_event()) do not want to QUIT. */ | 1971 callers (ie, Fnext_event()) do not want to QUIT. */ |
1931 | 1972 |
1932 assert (NILP (XEVENT_NEXT (target_event))); | 1973 assert (NILP (XEVENT_NEXT (target_event))); |
1933 | 1974 |
1934 GCPRO1 (target_event); | 1975 GCPRO1 (target_event); |
1935 investigate_frame_change (); | 1976 |
1977 /* When focus_follows_mouse is nil, if a frame change took place, we need | |
1978 * to actually switch window manager focus to the selected window now. | |
1979 */ | |
1980 if (!focus_follows_mouse) | |
1981 investigate_frame_change (); | |
1936 | 1982 |
1937 if (allow_queued && !NILP (command_event_queue)) | 1983 if (allow_queued && !NILP (command_event_queue)) |
1938 { | 1984 { |
1939 Lisp_Object event = dequeue_command_event (); | 1985 Lisp_Object event = dequeue_command_event (); |
1940 Fcopy_event (event, target_event); | 1986 Fcopy_event (event, target_event); |