comparison src/xterm.c @ 1993:645d96bd3daf

Use the term `scroll bar', instead of `scrollbar'. * alloc.c, frame.c, frame.h, indent.c, keyboard.c, keyboard.h, lisp.h, term.c, termhooks.h, window.c, window.h, xdisp.c, xfns.c, xterm.c, xterm.h: Terminology changed. * xterm.c (x_window_to_scrollbar, x_scrollbar_expose, x_scrollbar_handle_click, x_scrollbar_note_movement): Remember that these can be called during GC; we have to ignore mark bits. * lisp.h (GC_NILP, GC_EQ): New macros to help with that.
author Jim Blandy <jimb@redhat.com>
date Tue, 02 Mar 1993 08:21:49 +0000
parents 047e196658fa
children 02792f3b7336
comparison
equal deleted inserted replaced
1992:37c45885540a 1993:645d96bd3daf
160 160
161 /* This is the X connection that we are using. */ 161 /* This is the X connection that we are using. */
162 162
163 Display *x_current_display; 163 Display *x_current_display;
164 164
165 /* The cursor to use for vertical scrollbars on x_current_display. */ 165 /* The cursor to use for vertical scroll bars on x_current_display. */
166 static Cursor x_vertical_scrollbar_cursor; 166 static Cursor x_vertical_scroll_bar_cursor;
167 167
168 /* Frame being updated by update_frame. */ 168 /* Frame being updated by update_frame. */
169 /* This is set by XTupdate_begin and looked at by all the 169 /* This is set by XTupdate_begin and looked at by all the
170 XT functions. It is zero while not inside an update. 170 XT functions. It is zero while not inside an update.
171 In that case, the XT functions assume that `selected_frame' 171 In that case, the XT functions assume that `selected_frame'
661 661
662 BLOCK_INPUT; 662 BLOCK_INPUT;
663 663
664 XClear (FRAME_X_WINDOW (f)); 664 XClear (FRAME_X_WINDOW (f));
665 665
666 /* We have to clear the scrollbars, too. If we have changed 666 /* We have to clear the scroll bars, too. If we have changed
667 colors or something like that, then they should be notified. */ 667 colors or something like that, then they should be notified. */
668 x_scrollbar_clear (f); 668 x_scroll_bar_clear (f);
669 669
670 #ifndef HAVE_X11 670 #ifndef HAVE_X11
671 dumpborder (f, 0); 671 dumpborder (f, 0);
672 #endif /* HAVE_X11 */ 672 #endif /* HAVE_X11 */
673 673
1139 { 1139 {
1140 register int temp_width, temp_height; 1140 register int temp_width, temp_height;
1141 int intborder; 1141 int intborder;
1142 1142
1143 frame = XCONS (tail)->car; 1143 frame = XCONS (tail)->car;
1144 if (XTYPE (frame) != Lisp_Frame) 1144 if (XGCTYPE (frame) != Lisp_Frame)
1145 continue; 1145 continue;
1146 f = XFRAME (frame); 1146 f = XFRAME (frame);
1147 if (! FRAME_X_P (f)) 1147 if (! FRAME_X_P (f))
1148 continue; 1148 continue;
1149 if (!f->async_visible) 1149 if (!f->async_visible)
1154 intborder = f->display.x->internal_border_width; 1154 intborder = f->display.x->internal_border_width;
1155 1155
1156 clear_cursor (f); 1156 clear_cursor (f);
1157 XGetWindowInfo (FRAME_X_WINDOW (f), &windowinfo); 1157 XGetWindowInfo (FRAME_X_WINDOW (f), &windowinfo);
1158 temp_width = ((windowinfo.width - 2 * intborder 1158 temp_width = ((windowinfo.width - 2 * intborder
1159 - f->display.x->v_scrollbar_width) 1159 - f->display.x->v_scroll_bar_width)
1160 / FONT_WIDTH (f->display.x->font)); 1160 / FONT_WIDTH (f->display.x->font));
1161 temp_height = ((windowinfo.height- 2 * intborder 1161 temp_height = ((windowinfo.height- 2 * intborder
1162 - f->display.x->h_scrollbar_height) 1162 - f->display.x->h_scroll_bar_height)
1163 / FONT_HEIGHT (f->display.x->font)); 1163 / FONT_HEIGHT (f->display.x->font));
1164 if (temp_width != f->width || temp_height != f->height) 1164 if (temp_width != f->width || temp_height != f->height)
1165 { 1165 {
1166 change_frame_size (f, max (1, temp_height), 1166 change_frame_size (f, max (1, temp_height),
1167 max (1, temp_width), 0, 1); 1167 max (1, temp_width), 0, 1);
1168 x_resize_scrollbars (f); 1168 x_resize_scroll_bars (f);
1169 } 1169 }
1170 f->display.x->left_pos = windowinfo.x; 1170 f->display.x->left_pos = windowinfo.x;
1171 f->display.x->top_pos = windowinfo.y; 1171 f->display.x->top_pos = windowinfo.y;
1172 dumprectangle (f, 0, 0, PIXEL_WIDTH (f), PIXEL_HEIGHT (f)); 1172 dumprectangle (f, 0, 0, PIXEL_WIDTH (f), PIXEL_HEIGHT (f));
1173 #if 0 1173 #if 0
1304 struct frame *old_highlight = x_highlight_frame; 1304 struct frame *old_highlight = x_highlight_frame;
1305 1305
1306 if (x_focus_frame) 1306 if (x_focus_frame)
1307 { 1307 {
1308 x_highlight_frame = 1308 x_highlight_frame =
1309 ((XTYPE (FRAME_FOCUS_FRAME (x_focus_frame)) == Lisp_Frame) 1309 ((XGCTYPE (FRAME_FOCUS_FRAME (x_focus_frame)) == Lisp_Frame)
1310 ? XFRAME (FRAME_FOCUS_FRAME (x_focus_frame)) 1310 ? XFRAME (FRAME_FOCUS_FRAME (x_focus_frame))
1311 : x_focus_frame); 1311 : x_focus_frame);
1312 if (! FRAME_LIVE_P (x_highlight_frame)) 1312 if (! FRAME_LIVE_P (x_highlight_frame))
1313 { 1313 {
1314 FRAME_FOCUS_FRAME (x_focus_frame) = Qnil; 1314 FRAME_FOCUS_FRAME (x_focus_frame) = Qnil;
1534 1534
1535 /* Where the mouse was last time we reported a mouse event. */ 1535 /* Where the mouse was last time we reported a mouse event. */
1536 static FRAME_PTR last_mouse_frame; 1536 static FRAME_PTR last_mouse_frame;
1537 static XRectangle last_mouse_glyph; 1537 static XRectangle last_mouse_glyph;
1538 1538
1539 /* The scrollbar in which the last X motion event occurred. 1539 /* The scroll bar in which the last X motion event occurred.
1540 1540
1541 If the last X motion event occured in a scrollbar, we set this 1541 If the last X motion event occured in a scroll bar, we set this
1542 so XTmouse_position can know whether to report a scrollbar motion or 1542 so XTmouse_position can know whether to report a scroll bar motion or
1543 an ordinary motion. 1543 an ordinary motion.
1544 1544
1545 If the last X motion event didn't occur in a scrollbar, we set this 1545 If the last X motion event didn't occur in a scroll bar, we set this
1546 to Qnil, to tell XTmouse_position to return an ordinary motion event. */ 1546 to Qnil, to tell XTmouse_position to return an ordinary motion event. */
1547 static Lisp_Object last_mouse_scrollbar; 1547 static Lisp_Object last_mouse_scroll_bar;
1548 1548
1549 /* This is a hack. We would really prefer that XTmouse_position would 1549 /* This is a hack. We would really prefer that XTmouse_position would
1550 return the time associated with the position it returns, but there 1550 return the time associated with the position it returns, but there
1551 doesn't seem to be any way to wrest the timestamp from the server 1551 doesn't seem to be any way to wrest the timestamp from the server
1552 along with the position query. So, we just keep track of the time 1552 along with the position query. So, we just keep track of the time
1574 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width 1574 || event->x >= last_mouse_glyph.x + last_mouse_glyph.width
1575 || event->y < last_mouse_glyph.y 1575 || event->y < last_mouse_glyph.y
1576 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height) 1576 || event->y >= last_mouse_glyph.y + last_mouse_glyph.height)
1577 { 1577 {
1578 mouse_moved = 1; 1578 mouse_moved = 1;
1579 last_mouse_scrollbar = Qnil; 1579 last_mouse_scroll_bar = Qnil;
1580 } 1580 }
1581 else 1581 else
1582 { 1582 {
1583 /* It's on the same glyph. Call XQueryPointer so we'll get an 1583 /* It's on the same glyph. Call XQueryPointer so we'll get an
1584 event the next time the mouse moves and we can see if it's 1584 event the next time the mouse moves and we can see if it's
1590 &dummy, &dummy, &dummy, &dummy, 1590 &dummy, &dummy, &dummy, &dummy,
1591 (unsigned int *) &dummy); 1591 (unsigned int *) &dummy);
1592 } 1592 }
1593 } 1593 }
1594 1594
1595 static struct scrollbar *x_window_to_scrollbar (); 1595 static struct scroll_bar *x_window_to_scroll_bar ();
1596 static void x_scrollbar_report_motion (); 1596 static void x_scroll_bar_report_motion ();
1597 1597
1598 /* Return the current position of the mouse. 1598 /* Return the current position of the mouse.
1599 1599
1600 If the mouse movement started in a scrollbar, set *f, *bar_window, 1600 If the mouse movement started in a scroll bar, set *f, *bar_window,
1601 and *part to the frame, window, and scrollbar part that the mouse 1601 and *part to the frame, window, and scroll bar part that the mouse
1602 is over. Set *x and *y to the portion and whole of the mouse's 1602 is over. Set *x and *y to the portion and whole of the mouse's
1603 position on the scrollbar. 1603 position on the scroll bar.
1604 1604
1605 If the mouse movement started elsewhere, set *f to the frame the 1605 If the mouse movement started elsewhere, set *f to the frame the
1606 mouse is on, *bar_window to nil, and *x and *y to the character cell 1606 mouse is on, *bar_window to nil, and *x and *y to the character cell
1607 the mouse is over. 1607 the mouse is over.
1608 1608
1616 1616
1617 static void 1617 static void
1618 XTmouse_position (f, bar_window, part, x, y, time) 1618 XTmouse_position (f, bar_window, part, x, y, time)
1619 FRAME_PTR *f; 1619 FRAME_PTR *f;
1620 Lisp_Object *bar_window; 1620 Lisp_Object *bar_window;
1621 enum scrollbar_part *part; 1621 enum scroll_bar_part *part;
1622 Lisp_Object *x, *y; 1622 Lisp_Object *x, *y;
1623 unsigned long *time; 1623 unsigned long *time;
1624 { 1624 {
1625 BLOCK_INPUT; 1625 BLOCK_INPUT;
1626 1626
1627 if (! NILP (last_mouse_scrollbar)) 1627 if (! NILP (last_mouse_scroll_bar))
1628 x_scrollbar_report_motion (f, bar_window, part, x, y, time); 1628 x_scroll_bar_report_motion (f, bar_window, part, x, y, time);
1629 else 1629 else
1630 { 1630 {
1631 Window root; 1631 Window root;
1632 int root_x, root_y; 1632 int root_x, root_y;
1633 1633
1634 Window dummy_window; 1634 Window dummy_window;
1635 int dummy; 1635 int dummy;
1636 1636
1637 mouse_moved = 0; 1637 mouse_moved = 0;
1638 last_mouse_scrollbar = Qnil; 1638 last_mouse_scroll_bar = Qnil;
1639 1639
1640 /* Figure out which root window we're on. */ 1640 /* Figure out which root window we're on. */
1641 XQueryPointer (x_current_display, 1641 XQueryPointer (x_current_display,
1642 DefaultRootWindow (x_current_display), 1642 DefaultRootWindow (x_current_display),
1643 1643
1699 never use them in that case.) */ 1699 never use them in that case.) */
1700 1700
1701 /* Is win one of our frames? */ 1701 /* Is win one of our frames? */
1702 *f = x_window_to_frame (win); 1702 *f = x_window_to_frame (win);
1703 1703
1704 /* If not, is it one of our scrollbars? */ 1704 /* If not, is it one of our scroll bars? */
1705 if (! *f) 1705 if (! *f)
1706 { 1706 {
1707 struct scrollbar *bar = x_window_to_scrollbar (win); 1707 struct scroll_bar *bar = x_window_to_scroll_bar (win);
1708 1708
1709 if (bar) 1709 if (bar)
1710 { 1710 {
1711 *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 1711 *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
1712 win_x = parent_x; 1712 win_x = parent_x;
1733 1733
1734 #else /* ! defined (HAVE_X11) */ 1734 #else /* ! defined (HAVE_X11) */
1735 #define XEvent XKeyPressedEvent 1735 #define XEvent XKeyPressedEvent
1736 #endif /* ! defined (HAVE_X11) */ 1736 #endif /* ! defined (HAVE_X11) */
1737 1737
1738 /* Scrollbar support. */ 1738 /* Scroll bar support. */
1739 1739
1740 /* Given an X window ID, find the struct scrollbar which manages it. */ 1740 /* Given an X window ID, find the struct scroll_bar which manages it.
1741 static struct scrollbar * 1741 This can be called in GC, so we have to make sure to strip off mark
1742 x_window_to_scrollbar (window_id) 1742 bits. */
1743 static struct scroll_bar *
1744 x_window_to_scroll_bar (window_id)
1743 Window window_id; 1745 Window window_id;
1744 { 1746 {
1745 Lisp_Object tail, frame; 1747 Lisp_Object tail, frame;
1746 1748
1747 for (tail = Vframe_list; CONSP (tail); tail = XCONS (tail)->cdr) 1749 for (tail = Vframe_list;
1750 XGCTYPE (tail) == Lisp_Cons;
1751 tail = XCONS (tail)->cdr)
1748 { 1752 {
1749 Lisp_Object frame = XCONS (tail)->car; 1753 Lisp_Object frame = XCONS (tail)->car;
1750 Lisp_Object bar, condemned; 1754 Lisp_Object bar, condemned;
1751 1755
1752 /* All elements of Vframe_list should be frames. */ 1756 /* All elements of Vframe_list should be frames. */
1753 if (XTYPE (frame) != Lisp_Frame) 1757 if (XGCTYPE (frame) != Lisp_Frame)
1754 abort (); 1758 abort ();
1755 1759
1756 /* Scan this frame's scrollbar list for a scrollbar with the 1760 /* Scan this frame's scroll bar list for a scroll bar with the
1757 right window ID. */ 1761 right window ID. */
1758 condemned = FRAME_CONDEMNED_SCROLLBARS (XFRAME (frame)); 1762 condemned = FRAME_CONDEMNED_SCROLL_BARS (XFRAME (frame));
1759 for (bar = FRAME_SCROLLBARS (XFRAME (frame)); 1763 for (bar = FRAME_SCROLL_BARS (XFRAME (frame));
1760 /* This trick allows us to search both the ordinary and 1764 /* This trick allows us to search both the ordinary and
1761 condemned scrollbar lists with one loop. */ 1765 condemned scroll bar lists with one loop. */
1762 ! NILP (bar) || (bar = condemned, condemned = Qnil, ! NILP (bar)); 1766 ! GC_NILP (bar) || (bar = condemned,
1763 bar = XSCROLLBAR(bar)->next) 1767 condemned = Qnil,
1764 if (SCROLLBAR_X_WINDOW (XSCROLLBAR (bar)) == window_id) 1768 ! GC_NILP (bar));
1765 return XSCROLLBAR (bar); 1769 bar = XSCROLL_BAR(bar)->next)
1770 if (SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)) == window_id)
1771 return XSCROLL_BAR (bar);
1766 } 1772 }
1767 1773
1768 return 0; 1774 return 0;
1769 } 1775 }
1770 1776
1771 /* Open a new X window to serve as a scrollbar, and return the 1777 /* Open a new X window to serve as a scroll bar, and return the
1772 scrollbar vector for it. */ 1778 scroll bar vector for it. */
1773 static struct scrollbar * 1779 static struct scroll_bar *
1774 x_scrollbar_create (window, top, left, width, height) 1780 x_scroll_bar_create (window, top, left, width, height)
1775 struct window *window; 1781 struct window *window;
1776 int top, left, width, height; 1782 int top, left, width, height;
1777 { 1783 {
1778 FRAME_PTR frame = XFRAME (WINDOW_FRAME (window)); 1784 FRAME_PTR frame = XFRAME (WINDOW_FRAME (window));
1779 struct scrollbar *bar = 1785 struct scroll_bar *bar =
1780 XSCROLLBAR (Fmake_vector (make_number (SCROLLBAR_VEC_SIZE), Qnil)); 1786 XSCROLL_BAR (Fmake_vector (make_number (SCROLL_BAR_VEC_SIZE), Qnil));
1781 1787
1782 BLOCK_INPUT; 1788 BLOCK_INPUT;
1783 1789
1784 { 1790 {
1785 XSetWindowAttributes a; 1791 XSetWindowAttributes a;
1787 1793
1788 a.background_pixel = frame->display.x->background_pixel; 1794 a.background_pixel = frame->display.x->background_pixel;
1789 a.event_mask = (ButtonPressMask | ButtonReleaseMask 1795 a.event_mask = (ButtonPressMask | ButtonReleaseMask
1790 | ButtonMotionMask | PointerMotionHintMask 1796 | ButtonMotionMask | PointerMotionHintMask
1791 | ExposureMask); 1797 | ExposureMask);
1792 a.cursor = x_vertical_scrollbar_cursor; 1798 a.cursor = x_vertical_scroll_bar_cursor;
1793 1799
1794 mask = (CWBackPixel | CWEventMask | CWCursor); 1800 mask = (CWBackPixel | CWEventMask | CWCursor);
1795 1801
1796 SET_SCROLLBAR_X_WINDOW 1802 SET_SCROLL_BAR_X_WINDOW
1797 (bar, 1803 (bar,
1798 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame), 1804 XCreateWindow (x_current_display, FRAME_X_WINDOW (frame),
1799 1805
1800 /* Position and size of scrollbar. */ 1806 /* Position and size of scroll bar. */
1801 left, top, width, height, 1807 left, top, width, height,
1802 1808
1803 /* Border width, depth, class, and visual. */ 1809 /* Border width, depth, class, and visual. */
1804 0, CopyFromParent, CopyFromParent, CopyFromParent, 1810 0, CopyFromParent, CopyFromParent, CopyFromParent,
1805 1811
1815 XSET (bar->start, Lisp_Int, 0); 1821 XSET (bar->start, Lisp_Int, 0);
1816 XSET (bar->end, Lisp_Int, 0); 1822 XSET (bar->end, Lisp_Int, 0);
1817 bar->dragging = Qnil; 1823 bar->dragging = Qnil;
1818 1824
1819 /* Add bar to its frame's list of scroll bars. */ 1825 /* Add bar to its frame's list of scroll bars. */
1820 bar->next = FRAME_SCROLLBARS (frame); 1826 bar->next = FRAME_SCROLL_BARS (frame);
1821 bar->prev = Qnil; 1827 bar->prev = Qnil;
1822 XSET (FRAME_SCROLLBARS (frame), Lisp_Vector, bar); 1828 XSET (FRAME_SCROLL_BARS (frame), Lisp_Vector, bar);
1823 if (! NILP (bar->next)) 1829 if (! NILP (bar->next))
1824 XSET (XSCROLLBAR (bar->next)->prev, Lisp_Vector, bar); 1830 XSET (XSCROLL_BAR (bar->next)->prev, Lisp_Vector, bar);
1825 1831
1826 XMapWindow (x_current_display, SCROLLBAR_X_WINDOW (bar)); 1832 XMapWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar));
1827 1833
1828 UNBLOCK_INPUT; 1834 UNBLOCK_INPUT;
1829 1835
1830 return bar; 1836 return bar;
1831 } 1837 }
1835 redrawing it, unless REBUILD is non-zero; in that case, always 1841 redrawing it, unless REBUILD is non-zero; in that case, always
1836 redraw it. (REBUILD is handy for drawing the handle after expose 1842 redraw it. (REBUILD is handy for drawing the handle after expose
1837 events.) 1843 events.)
1838 1844
1839 Normally, we want to constrain the start and end of the handle to 1845 Normally, we want to constrain the start and end of the handle to
1840 fit inside its rectangle, but if the user is dragging the scrollbar 1846 fit inside its rectangle, but if the user is dragging the scroll bar
1841 handle, we want to let them drag it down all the way, so that the 1847 handle, we want to let them drag it down all the way, so that the
1842 bar's top is as far down as it goes; otherwise, there's no way to 1848 bar's top is as far down as it goes; otherwise, there's no way to
1843 move to the very end of the buffer. */ 1849 move to the very end of the buffer. */
1844 static void 1850 static void
1845 x_scrollbar_set_handle (bar, start, end, rebuild) 1851 x_scroll_bar_set_handle (bar, start, end, rebuild)
1846 struct scrollbar *bar; 1852 struct scroll_bar *bar;
1847 int start, end; 1853 int start, end;
1848 int rebuild; 1854 int rebuild;
1849 { 1855 {
1850 int dragging = ! NILP (bar->dragging); 1856 int dragging = ! NILP (bar->dragging);
1851 Window w = SCROLLBAR_X_WINDOW (bar); 1857 Window w = SCROLL_BAR_X_WINDOW (bar);
1852 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc; 1858 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc;
1853 1859
1854 /* If the display is already accurate, do nothing. */ 1860 /* If the display is already accurate, do nothing. */
1855 if (! rebuild 1861 if (! rebuild
1856 && start == XINT (bar->start) 1862 && start == XINT (bar->start)
1858 return; 1864 return;
1859 1865
1860 BLOCK_INPUT; 1866 BLOCK_INPUT;
1861 1867
1862 { 1868 {
1863 int inside_width = VERTICAL_SCROLLBAR_INSIDE_WIDTH (XINT (bar->width)); 1869 int inside_width = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (XINT (bar->width));
1864 int inside_height = VERTICAL_SCROLLBAR_INSIDE_HEIGHT (XINT (bar->height)); 1870 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (XINT (bar->height));
1865 int top_range = VERTICAL_SCROLLBAR_TOP_RANGE (XINT (bar->height)); 1871 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (XINT (bar->height));
1866 1872
1867 /* Make sure the values are reasonable, and try to preserve 1873 /* Make sure the values are reasonable, and try to preserve
1868 the distance between start and end. */ 1874 the distance between start and end. */
1869 { 1875 {
1870 int length = end - start; 1876 int length = end - start;
1879 end = start; 1885 end = start;
1880 else if (end > top_range && ! dragging) 1886 else if (end > top_range && ! dragging)
1881 end = top_range; 1887 end = top_range;
1882 } 1888 }
1883 1889
1884 /* Store the adjusted setting in the scrollbar. */ 1890 /* Store the adjusted setting in the scroll bar. */
1885 XSET (bar->start, Lisp_Int, start); 1891 XSET (bar->start, Lisp_Int, start);
1886 XSET (bar->end, Lisp_Int, end); 1892 XSET (bar->end, Lisp_Int, end);
1887 1893
1888 /* Clip the end position, just for display. */ 1894 /* Clip the end position, just for display. */
1889 if (end > top_range) 1895 if (end > top_range)
1890 end = top_range; 1896 end = top_range;
1891 1897
1892 /* Draw bottom positions VERTICAL_SCROLLBAR_MIN_HANDLE pixels 1898 /* Draw bottom positions VERTICAL_SCROLL_BAR_MIN_HANDLE pixels
1893 below top positions, to make sure the handle is always at least 1899 below top positions, to make sure the handle is always at least
1894 that many pixels tall. */ 1900 that many pixels tall. */
1895 end += VERTICAL_SCROLLBAR_MIN_HANDLE; 1901 end += VERTICAL_SCROLL_BAR_MIN_HANDLE;
1896 1902
1897 /* Draw the empty space above the handle. Note that we can't clear 1903 /* Draw the empty space above the handle. Note that we can't clear
1898 zero-height areas; that means "clear to end of window." */ 1904 zero-height areas; that means "clear to end of window." */
1899 if (0 < start) 1905 if (0 < start)
1900 XClearArea (x_current_display, w, 1906 XClearArea (x_current_display, w,
1901 1907
1902 /* x, y, width, height, and exposures. */ 1908 /* x, y, width, height, and exposures. */
1903 VERTICAL_SCROLLBAR_LEFT_BORDER, 1909 VERTICAL_SCROLL_BAR_LEFT_BORDER,
1904 VERTICAL_SCROLLBAR_TOP_BORDER, 1910 VERTICAL_SCROLL_BAR_TOP_BORDER,
1905 inside_width, start, 1911 inside_width, start,
1906 False); 1912 False);
1907 1913
1908 /* Draw the handle itself. */ 1914 /* Draw the handle itself. */
1909 XFillRectangle (x_current_display, w, gc, 1915 XFillRectangle (x_current_display, w, gc,
1910 1916
1911 /* x, y, width, height */ 1917 /* x, y, width, height */
1912 VERTICAL_SCROLLBAR_LEFT_BORDER, 1918 VERTICAL_SCROLL_BAR_LEFT_BORDER,
1913 VERTICAL_SCROLLBAR_TOP_BORDER + start, 1919 VERTICAL_SCROLL_BAR_TOP_BORDER + start,
1914 inside_width, end - start); 1920 inside_width, end - start);
1915 1921
1916 1922
1917 /* Draw the empty space below the handle. Note that we can't 1923 /* Draw the empty space below the handle. Note that we can't
1918 clear zero-height areas; that means "clear to end of window." */ 1924 clear zero-height areas; that means "clear to end of window." */
1919 if (end < inside_height) 1925 if (end < inside_height)
1920 XClearArea (x_current_display, w, 1926 XClearArea (x_current_display, w,
1921 1927
1922 /* x, y, width, height, and exposures. */ 1928 /* x, y, width, height, and exposures. */
1923 VERTICAL_SCROLLBAR_LEFT_BORDER, 1929 VERTICAL_SCROLL_BAR_LEFT_BORDER,
1924 VERTICAL_SCROLLBAR_TOP_BORDER + end, 1930 VERTICAL_SCROLL_BAR_TOP_BORDER + end,
1925 inside_width, inside_height - end, 1931 inside_width, inside_height - end,
1926 False); 1932 False);
1927 1933
1928 } 1934 }
1929 1935
1930 UNBLOCK_INPUT; 1936 UNBLOCK_INPUT;
1931 } 1937 }
1932 1938
1933 /* Move a scrollbar around on the screen, to accomodate changing 1939 /* Move a scroll bar around on the screen, to accomodate changing
1934 window configurations. */ 1940 window configurations. */
1935 static void 1941 static void
1936 x_scrollbar_move (bar, top, left, width, height) 1942 x_scroll_bar_move (bar, top, left, width, height)
1937 struct scrollbar *bar; 1943 struct scroll_bar *bar;
1938 int top, left, width, height; 1944 int top, left, width, height;
1939 { 1945 {
1940 BLOCK_INPUT; 1946 BLOCK_INPUT;
1941 1947
1942 { 1948 {
1952 if (top != XINT (bar->top)) mask |= CWY; 1958 if (top != XINT (bar->top)) mask |= CWY;
1953 if (width != XINT (bar->width)) mask |= CWWidth; 1959 if (width != XINT (bar->width)) mask |= CWWidth;
1954 if (height != XINT (bar->height)) mask |= CWHeight; 1960 if (height != XINT (bar->height)) mask |= CWHeight;
1955 1961
1956 if (mask) 1962 if (mask)
1957 XConfigureWindow (x_current_display, SCROLLBAR_X_WINDOW (bar), 1963 XConfigureWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar),
1958 mask, &wc); 1964 mask, &wc);
1959 } 1965 }
1960 1966
1961 XSET (bar->left, Lisp_Int, left); 1967 XSET (bar->left, Lisp_Int, left);
1962 XSET (bar->top, Lisp_Int, top); 1968 XSET (bar->top, Lisp_Int, top);
1964 XSET (bar->height, Lisp_Int, height); 1970 XSET (bar->height, Lisp_Int, height);
1965 1971
1966 UNBLOCK_INPUT; 1972 UNBLOCK_INPUT;
1967 } 1973 }
1968 1974
1969 /* Destroy the X window for BAR, and set its Emacs window's scrollbar 1975 /* Destroy the X window for BAR, and set its Emacs window's scroll bar
1970 to nil. */ 1976 to nil. */
1971 static void 1977 static void
1972 x_scrollbar_remove (bar) 1978 x_scroll_bar_remove (bar)
1973 struct scrollbar *bar; 1979 struct scroll_bar *bar;
1974 { 1980 {
1975 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 1981 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
1976 1982
1977 BLOCK_INPUT; 1983 BLOCK_INPUT;
1978 1984
1979 /* Destroy the window. */ 1985 /* Destroy the window. */
1980 XDestroyWindow (x_current_display, SCROLLBAR_X_WINDOW (bar)); 1986 XDestroyWindow (x_current_display, SCROLL_BAR_X_WINDOW (bar));
1981 1987
1982 /* Disassociate this scrollbar from its window. */ 1988 /* Disassociate this scroll bar from its window. */
1983 XWINDOW (bar->window)->vertical_scrollbar = Qnil; 1989 XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
1984 1990
1985 UNBLOCK_INPUT; 1991 UNBLOCK_INPUT;
1986 } 1992 }
1987 1993
1988 /* Set the handle of the vertical scroll bar for WINDOW to indicate 1994 /* Set the handle of the vertical scroll bar for WINDOW to indicate
1989 that we are displaying PORTION characters out of a total of WHOLE 1995 that we are displaying PORTION characters out of a total of WHOLE
1990 characters, starting at POSITION. If WINDOW has no scrollbar, 1996 characters, starting at POSITION. If WINDOW has no scroll bar,
1991 create one. */ 1997 create one. */
1992 static void 1998 static void
1993 XTset_vertical_scrollbar (window, portion, whole, position) 1999 XTset_vertical_scroll_bar (window, portion, whole, position)
1994 struct window *window; 2000 struct window *window;
1995 int portion, whole, position; 2001 int portion, whole, position;
1996 { 2002 {
1997 FRAME_PTR f = XFRAME (WINDOW_FRAME (window)); 2003 FRAME_PTR f = XFRAME (WINDOW_FRAME (window));
1998 int top = XINT (window->top); 2004 int top = XINT (window->top);
1999 int left = WINDOW_VERTICAL_SCROLLBAR_COLUMN (window); 2005 int left = WINDOW_VERTICAL_SCROLL_BAR_COLUMN (window);
2000 int height = WINDOW_VERTICAL_SCROLLBAR_HEIGHT (window); 2006 int height = WINDOW_VERTICAL_SCROLL_BAR_HEIGHT (window);
2001 2007
2002 /* Where should this scrollbar be, pixelwise? */ 2008 /* Where should this scroll bar be, pixelwise? */
2003 int pixel_top = CHAR_TO_PIXEL_ROW (f, top); 2009 int pixel_top = CHAR_TO_PIXEL_ROW (f, top);
2004 int pixel_left = CHAR_TO_PIXEL_COL (f, left); 2010 int pixel_left = CHAR_TO_PIXEL_COL (f, left);
2005 int pixel_width = VERTICAL_SCROLLBAR_PIXEL_WIDTH (f); 2011 int pixel_width = VERTICAL_SCROLL_BAR_PIXEL_WIDTH (f);
2006 int pixel_height = VERTICAL_SCROLLBAR_PIXEL_HEIGHT (f, height); 2012 int pixel_height = VERTICAL_SCROLL_BAR_PIXEL_HEIGHT (f, height);
2007 2013
2008 struct scrollbar *bar; 2014 struct scroll_bar *bar;
2009 2015
2010 /* Does the scrollbar exist yet? */ 2016 /* Does the scroll bar exist yet? */
2011 if (NILP (window->vertical_scrollbar)) 2017 if (NILP (window->vertical_scroll_bar))
2012 bar = x_scrollbar_create (window, 2018 bar = x_scroll_bar_create (window,
2013 pixel_top, pixel_left, 2019 pixel_top, pixel_left,
2014 pixel_width, pixel_height); 2020 pixel_width, pixel_height);
2015 else 2021 else
2016 { 2022 {
2017 /* It may just need to be moved and resized. */ 2023 /* It may just need to be moved and resized. */
2018 bar = XSCROLLBAR (window->vertical_scrollbar); 2024 bar = XSCROLL_BAR (window->vertical_scroll_bar);
2019 x_scrollbar_move (bar, pixel_top, pixel_left, pixel_width, pixel_height); 2025 x_scroll_bar_move (bar, pixel_top, pixel_left, pixel_width, pixel_height);
2020 } 2026 }
2021 2027
2022 /* Set the scrollbar's current state, unless we're currently being 2028 /* Set the scroll bar's current state, unless we're currently being
2023 dragged. */ 2029 dragged. */
2024 if (NILP (bar->dragging)) 2030 if (NILP (bar->dragging))
2025 { 2031 {
2026 int top_range = 2032 int top_range =
2027 VERTICAL_SCROLLBAR_TOP_RANGE (pixel_height); 2033 VERTICAL_SCROLL_BAR_TOP_RANGE (pixel_height);
2028 2034
2029 if (whole == 0) 2035 if (whole == 0)
2030 x_scrollbar_set_handle (bar, 0, top_range, 0); 2036 x_scroll_bar_set_handle (bar, 0, top_range, 0);
2031 else 2037 else
2032 { 2038 {
2033 int start = (position * top_range) / whole; 2039 int start = (position * top_range) / whole;
2034 int end = ((position + portion) * top_range) / whole; 2040 int end = ((position + portion) * top_range) / whole;
2035 2041
2036 x_scrollbar_set_handle (bar, start, end, 0); 2042 x_scroll_bar_set_handle (bar, start, end, 0);
2037 } 2043 }
2038 } 2044 }
2039 2045
2040 XSET (window->vertical_scrollbar, Lisp_Vector, bar); 2046 XSET (window->vertical_scroll_bar, Lisp_Vector, bar);
2041 } 2047 }
2042 2048
2043 2049
2044 /* The following three hooks are used when we're doing a thorough 2050 /* The following three hooks are used when we're doing a thorough
2045 redisplay of the frame. We don't explicitly know which scrollbars 2051 redisplay of the frame. We don't explicitly know which scroll bars
2046 are going to be deleted, because keeping track of when windows go 2052 are going to be deleted, because keeping track of when windows go
2047 away is a real pain - "Can you say set-window-configuration, boys 2053 away is a real pain - "Can you say set-window-configuration, boys
2048 and girls?" Instead, we just assert at the beginning of redisplay 2054 and girls?" Instead, we just assert at the beginning of redisplay
2049 that *all* scrollbars are to be removed, and then save a scrollbar 2055 that *all* scroll bars are to be removed, and then save a scroll bar
2050 from the fiery pit when we actually redisplay its window. */ 2056 from the fiery pit when we actually redisplay its window. */
2051 2057
2052 /* Arrange for all scrollbars on FRAME to be removed at the next call 2058 /* Arrange for all scroll bars on FRAME to be removed at the next call
2053 to `*judge_scrollbars_hook'. A scrollbar may be spared if 2059 to `*judge_scroll_bars_hook'. A scroll bar may be spared if
2054 `*redeem_scrollbar_hook' is applied to its window before the judgement. */ 2060 `*redeem_scroll_bar_hook' is applied to its window before the judgement. */
2055 static void 2061 static void
2056 XTcondemn_scrollbars (frame) 2062 XTcondemn_scroll_bars (frame)
2057 FRAME_PTR frame; 2063 FRAME_PTR frame;
2058 { 2064 {
2059 /* The condemned list should be empty at this point; if it's not, 2065 /* The condemned list should be empty at this point; if it's not,
2060 then the rest of Emacs isn't using the condemn/redeem/judge 2066 then the rest of Emacs isn't using the condemn/redeem/judge
2061 protocol correctly. */ 2067 protocol correctly. */
2062 if (! NILP (FRAME_CONDEMNED_SCROLLBARS (frame))) 2068 if (! NILP (FRAME_CONDEMNED_SCROLL_BARS (frame)))
2063 abort (); 2069 abort ();
2064 2070
2065 /* Move them all to the "condemned" list. */ 2071 /* Move them all to the "condemned" list. */
2066 FRAME_CONDEMNED_SCROLLBARS (frame) = FRAME_SCROLLBARS (frame); 2072 FRAME_CONDEMNED_SCROLL_BARS (frame) = FRAME_SCROLL_BARS (frame);
2067 FRAME_SCROLLBARS (frame) = Qnil; 2073 FRAME_SCROLL_BARS (frame) = Qnil;
2068 } 2074 }
2069 2075
2070 /* Unmark WINDOW's scrollbar for deletion in this judgement cycle. 2076 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle.
2071 Note that WINDOW isn't necessarily condemned at all. */ 2077 Note that WINDOW isn't necessarily condemned at all. */
2072 static void 2078 static void
2073 XTredeem_scrollbar (window) 2079 XTredeem_scroll_bar (window)
2074 struct window *window; 2080 struct window *window;
2075 { 2081 {
2076 struct scrollbar *bar; 2082 struct scroll_bar *bar;
2077 2083
2078 /* We can't redeem this window's scrollbar if it doesn't have one. */ 2084 /* We can't redeem this window's scroll bar if it doesn't have one. */
2079 if (NILP (window->vertical_scrollbar)) 2085 if (NILP (window->vertical_scroll_bar))
2080 abort (); 2086 abort ();
2081 2087
2082 bar = XSCROLLBAR (window->vertical_scrollbar); 2088 bar = XSCROLL_BAR (window->vertical_scroll_bar);
2083 2089
2084 /* Unlink it from the condemned list. */ 2090 /* Unlink it from the condemned list. */
2085 { 2091 {
2086 FRAME_PTR f = XFRAME (WINDOW_FRAME (window)); 2092 FRAME_PTR f = XFRAME (WINDOW_FRAME (window));
2087 2093
2088 if (NILP (bar->prev)) 2094 if (NILP (bar->prev))
2089 { 2095 {
2090 /* If the prev pointer is nil, it must be the first in one of 2096 /* If the prev pointer is nil, it must be the first in one of
2091 the lists. */ 2097 the lists. */
2092 if (EQ (FRAME_SCROLLBARS (f), window->vertical_scrollbar)) 2098 if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar))
2093 /* It's not condemned. Everything's fine. */ 2099 /* It's not condemned. Everything's fine. */
2094 return; 2100 return;
2095 else if (EQ (FRAME_CONDEMNED_SCROLLBARS (f), 2101 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f),
2096 window->vertical_scrollbar)) 2102 window->vertical_scroll_bar))
2097 FRAME_CONDEMNED_SCROLLBARS (f) = bar->next; 2103 FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next;
2098 else 2104 else
2099 /* If its prev pointer is nil, it must be at the front of 2105 /* If its prev pointer is nil, it must be at the front of
2100 one or the other! */ 2106 one or the other! */
2101 abort (); 2107 abort ();
2102 } 2108 }
2103 else 2109 else
2104 XSCROLLBAR (bar->prev)->next = bar->next; 2110 XSCROLL_BAR (bar->prev)->next = bar->next;
2105 2111
2106 if (! NILP (bar->next)) 2112 if (! NILP (bar->next))
2107 XSCROLLBAR (bar->next)->prev = bar->prev; 2113 XSCROLL_BAR (bar->next)->prev = bar->prev;
2108 2114
2109 bar->next = FRAME_SCROLLBARS (f); 2115 bar->next = FRAME_SCROLL_BARS (f);
2110 bar->prev = Qnil; 2116 bar->prev = Qnil;
2111 XSET (FRAME_SCROLLBARS (f), Lisp_Vector, bar); 2117 XSET (FRAME_SCROLL_BARS (f), Lisp_Vector, bar);
2112 if (! NILP (bar->next)) 2118 if (! NILP (bar->next))
2113 XSET (XSCROLLBAR (bar->next)->prev, Lisp_Vector, bar); 2119 XSET (XSCROLL_BAR (bar->next)->prev, Lisp_Vector, bar);
2114 } 2120 }
2115 } 2121 }
2116 2122
2117 /* Remove all scrollbars on FRAME that haven't been saved since the 2123 /* Remove all scroll bars on FRAME that haven't been saved since the
2118 last call to `*condemn_scrollbars_hook'. */ 2124 last call to `*condemn_scroll_bars_hook'. */
2119 static void 2125 static void
2120 XTjudge_scrollbars (f) 2126 XTjudge_scroll_bars (f)
2121 FRAME_PTR f; 2127 FRAME_PTR f;
2122 { 2128 {
2123 Lisp_Object bar, next; 2129 Lisp_Object bar, next;
2124 2130
2125 bar = FRAME_CONDEMNED_SCROLLBARS (f); 2131 bar = FRAME_CONDEMNED_SCROLL_BARS (f);
2126 2132
2127 /* Clear out the condemned list now so we won't try to process any 2133 /* Clear out the condemned list now so we won't try to process any
2128 more events on the hapless scrollbars. */ 2134 more events on the hapless scroll bars. */
2129 FRAME_CONDEMNED_SCROLLBARS (f) = Qnil; 2135 FRAME_CONDEMNED_SCROLL_BARS (f) = Qnil;
2130 2136
2131 for (; ! NILP (bar); bar = next) 2137 for (; ! NILP (bar); bar = next)
2132 { 2138 {
2133 struct scrollbar *b = XSCROLLBAR (bar); 2139 struct scroll_bar *b = XSCROLL_BAR (bar);
2134 2140
2135 x_scrollbar_remove (b); 2141 x_scroll_bar_remove (b);
2136 2142
2137 next = b->next; 2143 next = b->next;
2138 b->next = b->prev = Qnil; 2144 b->next = b->prev = Qnil;
2139 } 2145 }
2140 2146
2141 /* Now there should be no references to the condemned scrollbars, 2147 /* Now there should be no references to the condemned scroll bars,
2142 and they should get garbage-collected. */ 2148 and they should get garbage-collected. */
2143 } 2149 }
2144 2150
2145 2151
2146 /* Handle an Expose or GraphicsExpose event on a scrollbar. */ 2152 /* Handle an Expose or GraphicsExpose event on a scroll bar.
2153
2154 This may be called from a signal handler, so we have to ignore GC
2155 mark bits. */
2147 static void 2156 static void
2148 x_scrollbar_expose (bar, event) 2157 x_scroll_bar_expose (bar, event)
2149 struct scrollbar *bar; 2158 struct scroll_bar *bar;
2150 XEvent *event; 2159 XEvent *event;
2151 { 2160 {
2152 Window w = SCROLLBAR_X_WINDOW (bar); 2161 Window w = SCROLL_BAR_X_WINDOW (bar);
2153 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc; 2162 GC gc = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)))->display.x->normal_gc;
2154 2163
2155 BLOCK_INPUT; 2164 BLOCK_INPUT;
2156 2165
2157 x_scrollbar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1); 2166 x_scroll_bar_set_handle (bar, XINT (bar->start), XINT (bar->end), 1);
2158 2167
2159 /* Draw a one-pixel border just inside the edges of the scrollbar. */ 2168 /* Draw a one-pixel border just inside the edges of the scroll bar. */
2160 XDrawRectangle (x_current_display, w, gc, 2169 XDrawRectangle (x_current_display, w, gc,
2161 2170
2162 /* x, y, width, height */ 2171 /* x, y, width, height */
2163 0, 0, XINT (bar->width) - 1, XINT (bar->height) - 1); 2172 0, 0, XINT (bar->width) - 1, XINT (bar->height) - 1);
2164 2173
2169 XINT (bar->width) - 2, 1, 1, XINT (bar->height) - 2); 2178 XINT (bar->width) - 2, 1, 1, XINT (bar->height) - 2);
2170 2179
2171 UNBLOCK_INPUT; 2180 UNBLOCK_INPUT;
2172 } 2181 }
2173 2182
2174 /* Handle a mouse click on the scrollbar BAR. If *EMACS_EVENT's kind 2183 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind
2175 is set to something other than no_event, it is enqueued. */ 2184 is set to something other than no_event, it is enqueued.
2185
2186 This may be called from a signal handler, so we have to ignore GC
2187 mark bits. */
2176 static void 2188 static void
2177 x_scrollbar_handle_click (bar, event, emacs_event) 2189 x_scroll_bar_handle_click (bar, event, emacs_event)
2178 struct scrollbar *bar; 2190 struct scroll_bar *bar;
2179 XEvent *event; 2191 XEvent *event;
2180 struct input_event *emacs_event; 2192 struct input_event *emacs_event;
2181 { 2193 {
2182 if (XTYPE (bar->window) != Lisp_Window) 2194 if (XGCTYPE (bar->window) != Lisp_Window)
2183 abort (); 2195 abort ();
2184 2196
2185 emacs_event->kind = scrollbar_click; 2197 emacs_event->kind = scroll_bar_click;
2186 XSET (emacs_event->code, Lisp_Int, event->xbutton.button - Button1); 2198 XSET (emacs_event->code, Lisp_Int, event->xbutton.button - Button1);
2187 emacs_event->modifiers = 2199 emacs_event->modifiers =
2188 (x_convert_modifiers (event->xbutton.state) 2200 (x_convert_modifiers (event->xbutton.state)
2189 | (event->type == ButtonRelease 2201 | (event->type == ButtonRelease
2190 ? up_modifier 2202 ? up_modifier
2191 : down_modifier)); 2203 : down_modifier));
2192 emacs_event->frame_or_window = bar->window; 2204 emacs_event->frame_or_window = bar->window;
2193 emacs_event->timestamp = event->xbutton.time; 2205 emacs_event->timestamp = event->xbutton.time;
2194 { 2206 {
2195 int internal_height = 2207 int internal_height =
2196 VERTICAL_SCROLLBAR_INSIDE_HEIGHT (XINT (bar->height)); 2208 VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (XINT (bar->height));
2197 int top_range = 2209 int top_range =
2198 VERTICAL_SCROLLBAR_TOP_RANGE (XINT (bar->height)); 2210 VERTICAL_SCROLL_BAR_TOP_RANGE (XINT (bar->height));
2199 int y = event->xbutton.y - VERTICAL_SCROLLBAR_TOP_BORDER; 2211 int y = event->xbutton.y - VERTICAL_SCROLL_BAR_TOP_BORDER;
2200 2212
2201 if (y < 0) y = 0; 2213 if (y < 0) y = 0;
2202 if (y > top_range) y = top_range; 2214 if (y > top_range) y = top_range;
2203 2215
2204 if (y < XINT (bar->start)) 2216 if (y < XINT (bar->start))
2205 emacs_event->part = scrollbar_above_handle; 2217 emacs_event->part = scroll_bar_above_handle;
2206 else if (y < XINT (bar->end) + VERTICAL_SCROLLBAR_MIN_HANDLE) 2218 else if (y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
2207 emacs_event->part = scrollbar_handle; 2219 emacs_event->part = scroll_bar_handle;
2208 else 2220 else
2209 emacs_event->part = scrollbar_below_handle; 2221 emacs_event->part = scroll_bar_below_handle;
2210 2222
2211 /* If the user has just clicked on the handle, record where they're 2223 /* If the user has just clicked on the handle, record where they're
2212 holding it. */ 2224 holding it. */
2213 if (event->type == ButtonPress 2225 if (event->type == ButtonPress
2214 && emacs_event->part == scrollbar_handle) 2226 && emacs_event->part == scroll_bar_handle)
2215 XSET (bar->dragging, Lisp_Int, y - XINT (bar->start)); 2227 XSET (bar->dragging, Lisp_Int, y - XINT (bar->start));
2216 2228
2217 /* If the user has released the handle, set it to its final position. */ 2229 /* If the user has released the handle, set it to its final position. */
2218 if (event->type == ButtonRelease 2230 if (event->type == ButtonRelease
2219 && ! NILP (bar->dragging)) 2231 && ! NILP (bar->dragging))
2220 { 2232 {
2221 int new_start = y - XINT (bar->dragging); 2233 int new_start = y - XINT (bar->dragging);
2222 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); 2234 int new_end = new_start + (XINT (bar->end) - XINT (bar->start));
2223 2235
2224 x_scrollbar_set_handle (bar, new_start, new_end, 0); 2236 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
2225 bar->dragging = Qnil; 2237 bar->dragging = Qnil;
2226 } 2238 }
2227 2239
2228 /* Clicks on the handle are always reported as occuring at the top of 2240 /* Clicks on the handle are always reported as occuring at the top of
2229 the handle. */ 2241 the handle. */
2230 if (emacs_event->part == scrollbar_handle) 2242 if (emacs_event->part == scroll_bar_handle)
2231 emacs_event->x = bar->start; 2243 emacs_event->x = bar->start;
2232 else 2244 else
2233 XSET (emacs_event->x, Lisp_Int, y); 2245 XSET (emacs_event->x, Lisp_Int, y);
2234 2246
2235 XSET (emacs_event->y, Lisp_Int, top_range); 2247 XSET (emacs_event->y, Lisp_Int, top_range);
2236 } 2248 }
2237 } 2249 }
2238 2250
2239 /* Handle some mouse motion while someone is dragging the scrollbar. */ 2251 /* Handle some mouse motion while someone is dragging the scroll bar.
2252
2253 This may be called from a signal handler, so we have to ignore GC
2254 mark bits. */
2240 static void 2255 static void
2241 x_scrollbar_note_movement (bar, event) 2256 x_scroll_bar_note_movement (bar, event)
2242 struct scrollbar *bar; 2257 struct scroll_bar *bar;
2243 XEvent *event; 2258 XEvent *event;
2244 { 2259 {
2245 last_mouse_movement_time = event->xmotion.time; 2260 last_mouse_movement_time = event->xmotion.time;
2246 2261
2247 mouse_moved = 1; 2262 mouse_moved = 1;
2248 XSET (last_mouse_scrollbar, Lisp_Vector, bar); 2263 XSET (last_mouse_scroll_bar, Lisp_Vector, bar);
2249 2264
2250 /* If we're dragging the bar, display it. */ 2265 /* If we're dragging the bar, display it. */
2251 if (! NILP (bar->dragging)) 2266 if (! GC_NILP (bar->dragging))
2252 { 2267 {
2253 /* Where should the handle be now? */ 2268 /* Where should the handle be now? */
2254 int new_start = event->xmotion.y - XINT (bar->dragging); 2269 int new_start = event->xmotion.y - XINT (bar->dragging);
2255 2270
2256 if (new_start != XINT (bar->start)) 2271 if (new_start != XINT (bar->start))
2257 { 2272 {
2258 int new_end = new_start + (XINT (bar->end) - XINT (bar->start)); 2273 int new_end = new_start + (XINT (bar->end) - XINT (bar->start));
2259 2274
2260 x_scrollbar_set_handle (bar, new_start, new_end, 0); 2275 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
2261 } 2276 }
2262 } 2277 }
2263 2278
2264 /* Call XQueryPointer so we'll get an event the next time the mouse 2279 /* Call XQueryPointer so we'll get an event the next time the mouse
2265 moves and we can see *still* on the same position. */ 2280 moves and we can see *still* on the same position. */
2272 (unsigned int *) &dummy); 2287 (unsigned int *) &dummy);
2273 } 2288 }
2274 } 2289 }
2275 2290
2276 /* Return information to the user about the current position of the mouse 2291 /* Return information to the user about the current position of the mouse
2277 on the scrollbar. */ 2292 on the scroll bar. */
2278 static void 2293 static void
2279 x_scrollbar_report_motion (f, bar_window, part, x, y, time) 2294 x_scroll_bar_report_motion (f, bar_window, part, x, y, time)
2280 FRAME_PTR *f; 2295 FRAME_PTR *f;
2281 Lisp_Object *bar_window; 2296 Lisp_Object *bar_window;
2282 enum scrollbar_part *part; 2297 enum scroll_bar_part *part;
2283 Lisp_Object *x, *y; 2298 Lisp_Object *x, *y;
2284 unsigned long *time; 2299 unsigned long *time;
2285 { 2300 {
2286 struct scrollbar *bar = XSCROLLBAR (last_mouse_scrollbar); 2301 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
2287 int win_x, win_y; 2302 int win_x, win_y;
2288 2303
2289 BLOCK_INPUT; 2304 BLOCK_INPUT;
2290 2305
2291 /* Get the mouse's position relative to the scrollbar window, and 2306 /* Get the mouse's position relative to the scroll bar window, and
2292 report that. */ 2307 report that. */
2293 { 2308 {
2294 Window dummy_window; 2309 Window dummy_window;
2295 int dummy_coord; 2310 int dummy_coord;
2296 unsigned int dummy_mask; 2311 unsigned int dummy_mask;
2297 2312
2298 if (! XQueryPointer (x_current_display, 2313 if (! XQueryPointer (x_current_display,
2299 SCROLLBAR_X_WINDOW (bar), 2314 SCROLL_BAR_X_WINDOW (bar),
2300 2315
2301 /* Root, child, root x and root y. */ 2316 /* Root, child, root x and root y. */
2302 &dummy_window, &dummy_window, 2317 &dummy_window, &dummy_window,
2303 &dummy_coord, &dummy_coord, 2318 &dummy_coord, &dummy_coord,
2304 2319
2305 /* Position relative to scrollbar. */ 2320 /* Position relative to scroll bar. */
2306 &win_x, &win_y, 2321 &win_x, &win_y,
2307 2322
2308 /* Mouse buttons and modifier keys. */ 2323 /* Mouse buttons and modifier keys. */
2309 &dummy_mask)) 2324 &dummy_mask))
2310 { 2325 {
2312 goto done; 2327 goto done;
2313 } 2328 }
2314 } 2329 }
2315 2330
2316 { 2331 {
2317 int inside_height = VERTICAL_SCROLLBAR_INSIDE_HEIGHT (XINT (bar->height)); 2332 int inside_height = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (XINT (bar->height));
2318 int top_range = VERTICAL_SCROLLBAR_TOP_RANGE (XINT (bar->height)); 2333 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (XINT (bar->height));
2319 2334
2320 win_y -= VERTICAL_SCROLLBAR_TOP_BORDER; 2335 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
2321 2336
2322 if (! NILP (bar->dragging)) 2337 if (! NILP (bar->dragging))
2323 win_y -= XINT (bar->dragging); 2338 win_y -= XINT (bar->dragging);
2324 2339
2325 if (win_y < 0) 2340 if (win_y < 0)
2329 2344
2330 *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 2345 *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
2331 *bar_window = bar->window; 2346 *bar_window = bar->window;
2332 2347
2333 if (! NILP (bar->dragging)) 2348 if (! NILP (bar->dragging))
2334 *part = scrollbar_handle; 2349 *part = scroll_bar_handle;
2335 else if (win_y < XINT (bar->start)) 2350 else if (win_y < XINT (bar->start))
2336 *part = scrollbar_above_handle; 2351 *part = scroll_bar_above_handle;
2337 else if (win_y < XINT (bar->end) + VERTICAL_SCROLLBAR_MIN_HANDLE) 2352 else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
2338 *part = scrollbar_handle; 2353 *part = scroll_bar_handle;
2339 else 2354 else
2340 *part = scrollbar_below_handle; 2355 *part = scroll_bar_below_handle;
2341 2356
2342 XSET (*x, Lisp_Int, win_y); 2357 XSET (*x, Lisp_Int, win_y);
2343 XSET (*y, Lisp_Int, top_range); 2358 XSET (*y, Lisp_Int, top_range);
2344 *time = last_mouse_movement_time; 2359 *time = last_mouse_movement_time;
2345 } 2360 }
2346 2361
2347 mouse_moved = 0; 2362 mouse_moved = 0;
2348 last_mouse_scrollbar = Qnil; 2363 last_mouse_scroll_bar = Qnil;
2349 2364
2350 done: 2365 done:
2351 UNBLOCK_INPUT; 2366 UNBLOCK_INPUT;
2352 } 2367 }
2353 2368
2354 2369
2355 /* The screen has been cleared so we may have changed foreground or 2370 /* The screen has been cleared so we may have changed foreground or
2356 background colors, and the scrollbars may need to be redrawn. 2371 background colors, and the scroll bars may need to be redrawn.
2357 Clear out the scrollbars, and ask for expose events, so we can 2372 Clear out the scroll bars, and ask for expose events, so we can
2358 redraw them. */ 2373 redraw them. */
2359 2374
2360 x_scrollbar_clear (f) 2375 x_scroll_bar_clear (f)
2361 FRAME_PTR f; 2376 FRAME_PTR f;
2362 { 2377 {
2363 Lisp_Object bar; 2378 Lisp_Object bar;
2364 2379
2365 for (bar = FRAME_SCROLLBARS (f); 2380 for (bar = FRAME_SCROLL_BARS (f);
2366 XTYPE (bar) == Lisp_Vector; 2381 XTYPE (bar) == Lisp_Vector;
2367 bar = XSCROLLBAR (bar)->next) 2382 bar = XSCROLL_BAR (bar)->next)
2368 XClearArea (x_current_display, SCROLLBAR_X_WINDOW (XSCROLLBAR (bar)), 2383 XClearArea (x_current_display, SCROLL_BAR_X_WINDOW (XSCROLL_BAR (bar)),
2369 0, 0, 0, 0, True); 2384 0, 0, 0, 0, True);
2370 } 2385 }
2371 2386
2372 2387
2373 2388
2477 if (event.xclient.data.l[0] == Xatom_wm_take_focus) 2492 if (event.xclient.data.l[0] == Xatom_wm_take_focus)
2478 { 2493 {
2479 f = x_window_to_frame (event.xclient.window); 2494 f = x_window_to_frame (event.xclient.window);
2480 if (f) 2495 if (f)
2481 x_focus_on_frame (f); 2496 x_focus_on_frame (f);
2482 /* Not certain about handling scrollbars here */ 2497 /* Not certain about handling scroll bars here */
2483 } 2498 }
2484 else if (event.xclient.data.l[0] == Xatom_wm_save_yourself) 2499 else if (event.xclient.data.l[0] == Xatom_wm_save_yourself)
2485 { 2500 {
2486 /* Save state modify the WM_COMMAND property to 2501 /* Save state modify the WM_COMMAND property to
2487 something which can reinstate us. This notifies 2502 something which can reinstate us. This notifies
2559 event.xexpose.width, event.xexpose.height); 2574 event.xexpose.width, event.xexpose.height);
2560 } 2575 }
2561 } 2576 }
2562 else 2577 else
2563 { 2578 {
2564 struct scrollbar *bar 2579 struct scroll_bar *bar
2565 = x_window_to_scrollbar (event.xexpose.window); 2580 = x_window_to_scroll_bar (event.xexpose.window);
2566 2581
2567 if (bar) 2582 if (bar)
2568 x_scrollbar_expose (bar, &event); 2583 x_scroll_bar_expose (bar, &event);
2569 } 2584 }
2570 break; 2585 break;
2571 2586
2572 case GraphicsExpose: /* This occurs when an XCopyArea's 2587 case GraphicsExpose: /* This occurs when an XCopyArea's
2573 source area was obscured or not 2588 source area was obscured or not
2905 f = x_window_to_frame (event.xmotion.window); 2920 f = x_window_to_frame (event.xmotion.window);
2906 if (f) 2921 if (f)
2907 note_mouse_movement (f, &event.xmotion); 2922 note_mouse_movement (f, &event.xmotion);
2908 else 2923 else
2909 { 2924 {
2910 struct scrollbar *bar = 2925 struct scroll_bar *bar =
2911 x_window_to_scrollbar (event.xmotion.window); 2926 x_window_to_scroll_bar (event.xmotion.window);
2912 2927
2913 if (bar) 2928 if (bar)
2914 x_scrollbar_note_movement (bar, &event); 2929 x_scroll_bar_note_movement (bar, &event);
2915 } 2930 }
2916 } 2931 }
2917 break; 2932 break;
2918 2933
2919 case ConfigureNotify: 2934 case ConfigureNotify:
2957 construct_mouse_click (&emacs_event, 2972 construct_mouse_click (&emacs_event,
2958 &event, f); 2973 &event, f);
2959 } 2974 }
2960 else 2975 else
2961 { 2976 {
2962 struct scrollbar *bar = 2977 struct scroll_bar *bar =
2963 x_window_to_scrollbar (event.xbutton.window); 2978 x_window_to_scroll_bar (event.xbutton.window);
2964 2979
2965 if (bar) 2980 if (bar)
2966 x_scrollbar_handle_click (bar, &event, &emacs_event); 2981 x_scroll_bar_handle_click (bar, &event, &emacs_event);
2967 } 2982 }
2968 2983
2969 if (numchars >= 1 && emacs_event.kind != no_event) 2984 if (numchars >= 1 && emacs_event.kind != no_event)
2970 { 2985 {
2971 bcopy (&emacs_event, bufp, sizeof (struct input_event)); 2986 bcopy (&emacs_event, bufp, sizeof (struct input_event));
3866 int mask; 3881 int mask;
3867 3882
3868 BLOCK_INPUT; 3883 BLOCK_INPUT;
3869 3884
3870 check_frame_size (f, &rows, &cols); 3885 check_frame_size (f, &rows, &cols);
3871 f->display.x->vertical_scrollbar_extra = 3886 f->display.x->vertical_scroll_bar_extra =
3872 (FRAME_HAS_VERTICAL_SCROLLBARS (f) 3887 (FRAME_HAS_VERTICAL_SCROLL_BARS (f)
3873 ? VERTICAL_SCROLLBAR_PIXEL_WIDTH (f) 3888 ? VERTICAL_SCROLL_BAR_PIXEL_WIDTH (f)
3874 : 0); 3889 : 0);
3875 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols); 3890 pixelwidth = CHAR_TO_PIXEL_WIDTH (f, cols);
3876 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows); 3891 pixelheight = CHAR_TO_PIXEL_HEIGHT (f, rows);
3877 3892
3878 #ifdef HAVE_X11 3893 #ifdef HAVE_X11
4022 #ifdef HAVE_X11 4037 #ifdef HAVE_X11
4023 if (! EQ (Vx_no_window_manager, Qt)) 4038 if (! EQ (Vx_no_window_manager, Qt))
4024 x_wm_set_window_state (f, NormalState); 4039 x_wm_set_window_state (f, NormalState);
4025 4040
4026 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 4041 XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
4027 if (FRAME_HAS_VERTICAL_SCROLLBARS (f)) 4042 if (FRAME_HAS_VERTICAL_SCROLL_BARS (f))
4028 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f)); 4043 XMapSubwindows (x_current_display, FRAME_X_WINDOW (f));
4029 #else /* ! defined (HAVE_X11) */ 4044 #else /* ! defined (HAVE_X11) */
4030 XMapWindow (XDISPLAY FRAME_X_WINDOW (f)); 4045 XMapWindow (XDISPLAY FRAME_X_WINDOW (f));
4031 if (f->display.x->icon_desc != 0) 4046 if (f->display.x->icon_desc != 0)
4032 XUnmapWindow (f->display.x->icon_desc); 4047 XUnmapWindow (f->display.x->icon_desc);
4443 } 4458 }
4444 4459
4445 /* Figure out which modifier bits mean what. */ 4460 /* Figure out which modifier bits mean what. */
4446 x_find_modifier_meanings (); 4461 x_find_modifier_meanings ();
4447 4462
4448 /* Get the scrollbar cursor. */ 4463 /* Get the scroll bar cursor. */
4449 x_vertical_scrollbar_cursor = 4464 x_vertical_scroll_bar_cursor =
4450 XCreateFontCursor (x_current_display, XC_sb_v_double_arrow); 4465 XCreateFontCursor (x_current_display, XC_sb_v_double_arrow);
4451 4466
4452 /* Watch for PropertyNotify events on the root window; we use them 4467 /* Watch for PropertyNotify events on the root window; we use them
4453 to figure out when to invalidate our cache of the cut buffers. */ 4468 to figure out when to invalidate our cache of the cut buffers. */
4454 x_watch_cut_buffer_cache (); 4469 x_watch_cut_buffer_cache ();
4504 cursor_to_hook = XTcursor_to; 4519 cursor_to_hook = XTcursor_to;
4505 reassert_line_highlight_hook = XTreassert_line_highlight; 4520 reassert_line_highlight_hook = XTreassert_line_highlight;
4506 mouse_position_hook = XTmouse_position; 4521 mouse_position_hook = XTmouse_position;
4507 frame_rehighlight_hook = XTframe_rehighlight; 4522 frame_rehighlight_hook = XTframe_rehighlight;
4508 frame_raise_lower_hook = XTframe_raise_lower; 4523 frame_raise_lower_hook = XTframe_raise_lower;
4509 set_vertical_scrollbar_hook = XTset_vertical_scrollbar; 4524 set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
4510 condemn_scrollbars_hook = XTcondemn_scrollbars; 4525 condemn_scroll_bars_hook = XTcondemn_scroll_bars;
4511 redeem_scrollbar_hook = XTredeem_scrollbar; 4526 redeem_scroll_bar_hook = XTredeem_scroll_bar;
4512 judge_scrollbars_hook = XTjudge_scrollbars; 4527 judge_scroll_bars_hook = XTjudge_scroll_bars;
4513 4528
4514 scroll_region_ok = 1; /* we'll scroll partial frames */ 4529 scroll_region_ok = 1; /* we'll scroll partial frames */
4515 char_ins_del_ok = 0; /* just as fast to write the line */ 4530 char_ins_del_ok = 0; /* just as fast to write the line */
4516 line_ins_del_ok = 1; /* we'll just blt 'em */ 4531 line_ins_del_ok = 1; /* we'll just blt 'em */
4517 fast_clear_end_of_line = 1; /* X does this well */ 4532 fast_clear_end_of_line = 1; /* X does this well */
4536 syms_of_xterm () 4551 syms_of_xterm ()
4537 { 4552 {
4538 staticpro (&invocation_name); 4553 staticpro (&invocation_name);
4539 invocation_name = Qnil; 4554 invocation_name = Qnil;
4540 4555
4541 staticpro (&last_mouse_scrollbar); 4556 staticpro (&last_mouse_scroll_bar);
4542 } 4557 }
4543 #endif /* ! defined (HAVE_X11) */ 4558 #endif /* ! defined (HAVE_X11) */
4544 #endif /* ! defined (HAVE_X_WINDOWS) */ 4559 #endif /* ! defined (HAVE_X_WINDOWS) */