aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-03-13 17:07:45 +0000
committerStefan Monnier2002-03-13 17:07:45 +0000
commit6f2a7a68b9582c09aecf175cfd20c98ee7242d7e (patch)
tree24195280962df1a03dca3efcea86308304932851
parent894dc7e75d5298dbad72ca8307a93bbc6f89b16b (diff)
downloademacs-6f2a7a68b9582c09aecf175cfd20c98ee7242d7e.tar.gz
emacs-6f2a7a68b9582c09aecf175cfd20c98ee7242d7e.zip
(x_set_toolkit_scroll_bar_thumb) <USE_MOTIF>: Use a fixed-size
thumb (based on an ad-hoc estimate of 30 chars per line) to avoid annoying flicker. (xm_scroll_callback): Get rid of the now unnecessary kludge. (XTread_socket): Mark it static.
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xterm.c112
2 files changed, 56 insertions, 62 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 54e46245d30..99dda435bc1 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
12002-03-13 Stefan Monnier <monnier@cs.yale.edu> 12002-03-13 Stefan Monnier <monnier@cs.yale.edu>
2 2
3 * xterm.c (x_set_toolkit_scroll_bar_thumb) <USE_MOTIF>:
4 Use a fixed-size thumb (based on an ad-hoc estimate of 30 chars per
5 line) to avoid annoying flicker.
6 (xm_scroll_callback): Get rid of the now unnecessary kludge.
7 (XTread_socket): Mark it static.
8
3 * xdisp.c (display_mode_element): Fix int/Lisp_Object mixup. 9 * xdisp.c (display_mode_element): Fix int/Lisp_Object mixup.
4 10
52002-03-13 Kim F. Storm <storm@cua.dk> 112002-03-13 Kim F. Storm <storm@cua.dk>
diff --git a/src/xterm.c b/src/xterm.c
index a0f942e44fc..37e41d0f34a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -8553,31 +8553,10 @@ xm_scroll_callback (widget, client_data, call_data)
8553 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL); 8553 XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL);
8554 UNBLOCK_INPUT; 8554 UNBLOCK_INPUT;
8555 8555
8556 /* At the max position of the scroll bar, do a line-wise 8556 whole = XM_SB_RANGE - slider_size;
8557 movement. Without doing anything, we would be called with 8557 portion = min (cs->value - XM_SB_MIN, whole);
8558 the same cs->value again and again. If we want to make 8558 part = scroll_bar_handle;
8559 sure that we can reach the end of the buffer, we have to do 8559 bar->dragging = make_number (cs->value);
8560 something.
8561
8562 Implementation note: setting bar->dragging always to
8563 cs->value gives a smoother movement at the max position.
8564 Setting it to nil when doing line-wise movement gives
8565 a better slider behavior. */
8566
8567 if (cs->value + slider_size == XM_SB_MAX
8568 || (dragging_down_p
8569 && last_scroll_bar_part == scroll_bar_down_arrow))
8570 {
8571 part = scroll_bar_down_arrow;
8572 bar->dragging = Qnil;
8573 }
8574 else
8575 {
8576 whole = XM_SB_RANGE;
8577 portion = min (cs->value - XM_SB_MIN, XM_SB_MAX - slider_size);
8578 part = scroll_bar_handle;
8579 bar->dragging = make_number (cs->value);
8580 }
8581 } 8560 }
8582 break; 8561 break;
8583 8562
@@ -8880,7 +8859,27 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
8880 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar); 8859 Widget widget = SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar);
8881 float top, shown; 8860 float top, shown;
8882 8861
8883 if (whole == 0) 8862 BLOCK_INPUT;
8863
8864#ifdef USE_MOTIF
8865
8866 /* We use an estimate of 30 chars per line rather than the real
8867 `portion' value. This has the disadvantage that the thumb size
8868 is not very representative, but it makes our life a lot easier.
8869 Otherwise, we have to constantly adjust the thumb size, which
8870 we can't always do quickly enough: while dragging, the size of
8871 the thumb might prevent the user from dragging the thumb all the
8872 way to the end. but Motif and some versions of Xaw3d don't allow
8873 updating the thumb size while dragging. Also, even if we can update
8874 its size, the update will often happen too late.
8875 If you don't believe it, check out revision 1.650 of xterm.c to see
8876 what hoops we were going through and the still poor behavior we got. */
8877 portion = XFASTINT (XWINDOW (bar->window)->height) * 30;
8878 /* When the thumb is at the bottom, position == whole.
8879 So we need to increase `whole' to make space for the thumb. */
8880 whole += portion;
8881
8882 if (whole <= 0)
8884 top = 0, shown = 1; 8883 top = 0, shown = 1;
8885 else 8884 else
8886 { 8885 {
@@ -8888,45 +8887,34 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
8888 shown = (float) portion / whole; 8887 shown = (float) portion / whole;
8889 } 8888 }
8890 8889
8891 BLOCK_INPUT; 8890 if (NILP (bar->dragging))
8892 8891 {
8893#ifdef USE_MOTIF 8892 int size, value;
8894 {
8895 int size, value;
8896
8897 /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX
8898 is the scroll bar's maximum and MIN is the scroll bar's minimum
8899 value. */
8900 size = shown * XM_SB_RANGE;
8901 size = min (size, XM_SB_RANGE);
8902 size = max (size, 1);
8903 8893
8904 /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ 8894 /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX
8905 value = top * XM_SB_RANGE; 8895 is the scroll bar's maximum and MIN is the scroll bar's minimum
8906 value = min (value, XM_SB_MAX - size); 8896 value. */
8907 value = max (value, XM_SB_MIN); 8897 size = shown * XM_SB_RANGE;
8898 size = min (size, XM_SB_RANGE);
8899 size = max (size, 1);
8908 8900
8909 if (NILP (bar->dragging)) 8901 /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */
8902 value = top * XM_SB_RANGE;
8903 value = min (value, XM_SB_MAX - size);
8904 value = max (value, XM_SB_MIN);
8905
8910 XmScrollBarSetValues (widget, value, size, 0, 0, False); 8906 XmScrollBarSetValues (widget, value, size, 0, 0, False);
8911 else if (last_scroll_bar_part == scroll_bar_down_arrow) 8907 }
8912 /* This has the negative side effect that the slider value is
8913 not what it would be if we scrolled here using line-wise or
8914 page-wise movement. */
8915 XmScrollBarSetValues (widget, value, XM_SB_RANGE - value, 0, 0, False);
8916 else
8917 {
8918 /* If currently dragging, only update the slider size.
8919 This reduces flicker effects. */
8920 int old_value, old_size, increment, page_increment;
8921
8922 XmScrollBarGetValues (widget, &old_value, &old_size,
8923 &increment, &page_increment);
8924 XmScrollBarSetValues (widget, old_value,
8925 min (size, XM_SB_RANGE - old_value),
8926 0, 0, False);
8927 }
8928 }
8929#else /* !USE_MOTIF i.e. use Xaw */ 8908#else /* !USE_MOTIF i.e. use Xaw */
8909
8910 if (whole == 0)
8911 top = 0, shown = 1;
8912 else
8913 {
8914 top = (float) position / whole;
8915 shown = (float) portion / whole;
8916 }
8917
8930 { 8918 {
8931 float old_top, old_shown; 8919 float old_top, old_shown;
8932 Dimension height; 8920 Dimension height;
@@ -9953,7 +9941,7 @@ static struct x_display_info *next_noop_dpyinfo;
9953 9941
9954 EXPECTED is nonzero if the caller knows input is available. */ 9942 EXPECTED is nonzero if the caller knows input is available. */
9955 9943
9956int 9944static int
9957XTread_socket (sd, bufp, numchars, expected) 9945XTread_socket (sd, bufp, numchars, expected)
9958 register int sd; 9946 register int sd;
9959 /* register */ struct input_event *bufp; 9947 /* register */ struct input_event *bufp;