comparison src/frame.c @ 284:558f606b08ae r21-0b40

Import from CVS: tag r21-0b40
author cvs
date Mon, 13 Aug 2007 10:34:13 +0200
parents c42ec1d1cded
children 57709be46d1b
comparison
equal deleted inserted replaced
283:fa3d41851a08 284:558f606b08ae
613 Lisp_Object frmcons, devcons, concons; 613 Lisp_Object frmcons, devcons, concons;
614 614
615 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons) 615 FRAME_LOOP_NO_BREAK (frmcons, devcons, concons)
616 unhold_one_frame_size_changes (XFRAME (XCAR (frmcons))); 616 unhold_one_frame_size_changes (XFRAME (XCAR (frmcons)));
617 } 617 }
618
619 void
620 invalidate_vertical_divider_cache_in_frame (struct frame *f)
621 {
622 /* Invalidate cached value of needs_vertical_divider_p in
623 every and all windows */
624 map_windows (f, invalidate_vertical_divider_cache_in_window, 0);
625 }
618 626
619 /* 627 /*
620 * Frame size may change due to changes in scrollbars, toolbars, 628 * Frame size may change due to changes in scrollbars, toolbars,
621 * default font etc. These changes are applied early in redisplay 629 * default font etc. These changes are applied early in redisplay
622 * frame. 630 * frame.
699 { 707 {
700 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil; 708 return FRAMEP (object) && FRAME_LIVE_P (XFRAME (object)) ? Qt : Qnil;
701 } 709 }
702 710
703 711
712 DEFUN ("focus-frame", Ffocus_frame, 1, 1, 0, /*
713 Select FRAME and give it the window system focus.
714 This function is not affected by the value of `focus-follows-mouse'.
715 */
716 (frame))
717 {
718 CHECK_LIVE_FRAME (frame);
719
720 MAYBE_DEVMETH (XDEVICE (FRAME_DEVICE (XFRAME (frame))), focus_on_frame,
721 (XFRAME (frame)));
722 /* FRAME will be selected by the time we receive the next event.
723 However, it is better to select it explicitly now, in case the
724 Lisp code depends on frame being selected. */
725 Fselect_frame (frame);
726 return Qnil;
727 }
728
704 /* Called from Fselect_window() */ 729 /* Called from Fselect_window() */
705 void 730 void
706 select_frame_1 (Lisp_Object frame) 731 select_frame_1 (Lisp_Object frame)
707 { 732 {
708 struct frame *f = XFRAME (frame); 733 struct frame *f = XFRAME (frame);
723 Subsequent editing commands apply to its selected window. 748 Subsequent editing commands apply to its selected window.
724 The selection of FRAME lasts until the next time the user does 749 The selection of FRAME lasts until the next time the user does
725 something to select a different frame, or until the next time this 750 something to select a different frame, or until the next time this
726 function is called. 751 function is called.
727 752
728 Note that this does not actually cause the window-system focus to 753 Note that this does not actually cause the window-system focus to be
729 be set to this frame, or the select-frame-hook or deselect-frame-hook 754 set to this frame, or the `select-frame-hook' or `deselect-frame-hook'
730 to be run, until the next time that XEmacs is waiting for an event. 755 to be run, until the next time that XEmacs is waiting for an event.
731 756
732 Also note that when focus-follows-mouse is non-nil, the frame 757 Also note that when focus-follows-mouse is non-nil, the frame
733 selection is temporary and is reverted when the current command 758 selection is temporary and is reverted when the current command
734 terminates, much like the buffer selected by `set-buffer'. In order 759 terminates, much like the buffer selected by `set-buffer'. In order
735 to effect a permanent focus change in this case, bind 760 to effect a permanent focus change, use `focus-frame'.
736 focus-follows-mouse to nil, select the frame you want, and do
737 a (sit-for 0) within the scope of the binding.
738 */ 761 */
739 (frame)) 762 (frame))
740 { 763 {
741 CHECK_LIVE_FRAME (frame); 764 CHECK_LIVE_FRAME (frame);
742 765
1714 return 0; 1737 return 0;
1715 } 1738 }
1716 1739
1717 DEFUN ("mouse-pixel-position", Fmouse_pixel_position, 0, 1, 0, /* 1740 DEFUN ("mouse-pixel-position", Fmouse_pixel_position, 0, 1, 0, /*
1718 Return a list (WINDOW X . Y) giving the current mouse window and position. 1741 Return a list (WINDOW X . Y) giving the current mouse window and position.
1719 The position is given in pixel units, where (0, 0) is the 1742 The position is given in pixel units, where (0, 0) is the upper-left corner.
1720 upper-left corner. 1743
1744 When the cursor is not over a window, the return value is a list (nil nil).
1721 1745
1722 DEVICE specifies the device on which to read the mouse position, and 1746 DEVICE specifies the device on which to read the mouse position, and
1723 defaults to the selected device. If the device is a mouseless terminal 1747 defaults to the selected device. If the device is a mouseless terminal
1724 or Emacs hasn't been programmed to read its mouse position, it returns 1748 or Emacs hasn't been programmed to read its mouse position, it returns
1725 the device's selected window for WINDOW and nil for X and Y. 1749 the device's selected window for WINDOW and nil for X and Y.
1726 */ 1750 */
1727 (device)) 1751 (device))
1728 { 1752 {
1729 struct device *d = decode_device (device); 1753 struct device *d = decode_device (device);
1730 Lisp_Object frame; 1754 Lisp_Object frame;
1731 Lisp_Object window; 1755 Lisp_Object window = Qnil;
1732 Lisp_Object x = Qnil; 1756 Lisp_Object x = Qnil;
1733 Lisp_Object y = Qnil; 1757 Lisp_Object y = Qnil;
1734 int intx, inty; 1758 int intx, inty;
1735 1759
1736 if (mouse_pixel_position_1 (d, &frame, &intx, &inty)) 1760 if (mouse_pixel_position_1 (d, &frame, &intx, &inty) > 0)
1737 { 1761 {
1738 struct window *w = 1762 struct window *w =
1739 find_window_by_pixel_pos (intx, inty, XFRAME (frame)->root_window); 1763 find_window_by_pixel_pos (intx, inty, XFRAME (frame)->root_window);
1740 if (!w) 1764 if (w)
1741 window = Qnil;
1742 else
1743 { 1765 {
1744 XSETWINDOW (window, w); 1766 XSETWINDOW (window, w);
1745 1767
1746 /* Adjust the position to be relative to the window. */ 1768 /* Adjust the position to be relative to the window. */
1747 intx -= w->pixel_left; 1769 intx -= w->pixel_left;
1748 inty -= w->pixel_top; 1770 inty -= w->pixel_top;
1749 XSETINT (x, intx); 1771 XSETINT (x, intx);
1750 XSETINT (y, inty); 1772 XSETINT (y, inty);
1751 } 1773 }
1752 } 1774 }
1753 else 1775 else if (FRAMEP (frame))
1754 { 1776 window = FRAME_SELECTED_WINDOW (XFRAME (frame));
1755 if (FRAMEP (frame))
1756 window = FRAME_SELECTED_WINDOW (XFRAME (frame));
1757 else
1758 window = Qnil;
1759 }
1760 1777
1761 return Fcons (window, Fcons (x, y)); 1778 return Fcons (window, Fcons (x, y));
1762 } 1779 }
1763 1780
1764 DEFUN ("mouse-position", Fmouse_position, 0, 1, 0, /* 1781 DEFUN ("mouse-position", Fmouse_position, 0, 1, 0, /*
1765 Return a list (WINDOW X . Y) giving the current mouse window and position. 1782 Return a list (WINDOW X . Y) giving the current mouse window and position.
1766 The position is given in character cells, where (0, 0) is the 1783 The position is of a character under cursor, where (0, 0) is the upper-left
1767 upper-left corner of the window. 1784 corner of the window.
1785
1786 When the cursor is not over a character, or not over a window, the return
1787 value is a list (nil nil).
1768 1788
1769 DEVICE specifies the device on which to read the mouse position, and 1789 DEVICE specifies the device on which to read the mouse position, and
1770 defaults to the selected device. If the device is a mouseless terminal 1790 defaults to the selected device. If the device is a mouseless terminal
1771 or Emacs hasn't been programmed to read its mouse position, it returns 1791 or Emacs hasn't been programmed to read its mouse position, it returns
1772 the device's selected window for WINDOW and nil for X and Y. 1792 the device's selected window for WINDOW and nil for X and Y.
1773 */ 1793 */
1774 (device)) 1794 (device))
1775 { 1795 {
1776 Lisp_Object val = Fmouse_pixel_position (device); 1796 struct device *d = decode_device (device);
1797 struct window *w;
1798 Lisp_Object frame, window = Qnil, lisp_x = Qnil, lisp_y = Qnil;
1777 int x, y, obj_x, obj_y; 1799 int x, y, obj_x, obj_y;
1778 struct window *w;
1779 struct frame *f;
1780 Bufpos bufpos, closest; 1800 Bufpos bufpos, closest;
1781 Charcount modeline_closest; 1801 Charcount modeline_closest;
1782 Lisp_Object obj1, obj2; 1802 Lisp_Object obj1, obj2;
1783 1803
1784 if (NILP (XCAR (val)) || NILP (XCAR (XCDR (val)))) 1804 if (mouse_pixel_position_1 (d, &frame, &x, &y) > 0)
1785 return val; 1805 {
1786 w = XWINDOW (XCAR (val)); 1806 int res = pixel_to_glyph_translation (XFRAME (frame), x, y, &x, &y,
1787 x = XINT (XCAR (XCDR (val))); 1807 &obj_x, &obj_y, &w, &bufpos,
1788 y = XINT (XCDR (XCDR (val))); 1808 &closest, &modeline_closest,
1789 f = XFRAME (w->frame); 1809 &obj1, &obj2);
1790 1810 if (res == OVER_TEXT)
1791 if (x >= 0 && y >= 0)
1792 {
1793 if (pixel_to_glyph_translation (f, x, y, &x, &y, &obj_x, &obj_y, &w,
1794 &bufpos, &closest, &modeline_closest,
1795 &obj1, &obj2)
1796 != OVER_NOTHING)
1797 { 1811 {
1798 XCAR (XCDR (val)) = make_int (x); 1812 lisp_x = make_int (x);
1799 XCDR (XCDR (val)) = make_int (y); 1813 lisp_y = make_int (y);
1814 XSETWINDOW (window, w);
1800 } 1815 }
1801 } 1816 }
1802 else 1817 else if (FRAMEP (frame))
1803 { 1818 window = FRAME_SELECTED_WINDOW (XFRAME (frame));
1804 XCAR (XCDR (val)) = Qnil; 1819
1805 XCDR (XCDR (val)) = Qnil; 1820 return Fcons (window, Fcons (lisp_x, lisp_y));
1806 }
1807
1808 return val;
1809 } 1821 }
1810 1822
1811 DEFUN ("mouse-position-as-motion-event", Fmouse_position_as_motion_event, 0, 1, 0, /* 1823 DEFUN ("mouse-position-as-motion-event", Fmouse_position_as_motion_event, 0, 1, 0, /*
1812 Return the current mouse position as a motion event. 1824 Return the current mouse position as a motion event.
1813 This allows you to call the standard event functions such as 1825 This allows you to call the standard event functions such as
3134 DEFSUBR (Fframep); 3146 DEFSUBR (Fframep);
3135 DEFSUBR (Fframe_live_p); 3147 DEFSUBR (Fframe_live_p);
3136 #if 0 /* FSFmacs */ 3148 #if 0 /* FSFmacs */
3137 DEFSUBR (Fignore_event); 3149 DEFSUBR (Fignore_event);
3138 #endif 3150 #endif
3151 DEFSUBR (Ffocus_frame);
3139 DEFSUBR (Fselect_frame); 3152 DEFSUBR (Fselect_frame);
3140 DEFSUBR (Fselected_frame); 3153 DEFSUBR (Fselected_frame);
3141 DEFSUBR (Factive_minibuffer_window); 3154 DEFSUBR (Factive_minibuffer_window);
3142 DEFSUBR (Flast_nonminibuf_frame); 3155 DEFSUBR (Flast_nonminibuf_frame);
3143 DEFSUBR (Fframe_root_window); 3156 DEFSUBR (Fframe_root_window);