comparison src/xterm.c @ 43884:eb248012bf4a

(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.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 13 Mar 2002 17:04:49 +0000
parents 50bab629a120
children c56b978cdfa2
comparison
equal deleted inserted replaced
43883:b13e662ea2b3 43884:eb248012bf4a
8551 /* Get the slider size. */ 8551 /* Get the slider size. */
8552 BLOCK_INPUT; 8552 BLOCK_INPUT;
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
8584 case XmCR_VALUE_CHANGED: 8563 case XmCR_VALUE_CHANGED:
8585 break; 8564 break;
8878 { 8857 {
8879 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); 8858 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
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
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)
8883 top = 0, shown = 1;
8884 else
8885 {
8886 top = (float) position / whole;
8887 shown = (float) portion / whole;
8888 }
8889
8890 if (NILP (bar->dragging))
8891 {
8892 int size, value;
8893
8894 /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX
8895 is the scroll bar's maximum and MIN is the scroll bar's minimum
8896 value. */
8897 size = shown * XM_SB_RANGE;
8898 size = min (size, XM_SB_RANGE);
8899 size = max (size, 1);
8900
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
8906 XmScrollBarSetValues (widget, value, size, 0, 0, False);
8907 }
8908 #else /* !USE_MOTIF i.e. use Xaw */
8909
8883 if (whole == 0) 8910 if (whole == 0)
8884 top = 0, shown = 1; 8911 top = 0, shown = 1;
8885 else 8912 else
8886 { 8913 {
8887 top = (float) position / whole; 8914 top = (float) position / whole;
8888 shown = (float) portion / whole; 8915 shown = (float) portion / whole;
8889 } 8916 }
8890 8917
8891 BLOCK_INPUT;
8892
8893 #ifdef USE_MOTIF
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
8904 /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */
8905 value = top * XM_SB_RANGE;
8906 value = min (value, XM_SB_MAX - size);
8907 value = max (value, XM_SB_MIN);
8908
8909 if (NILP (bar->dragging))
8910 XmScrollBarSetValues (widget, value, size, 0, 0, False);
8911 else if (last_scroll_bar_part == scroll_bar_down_arrow)
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 */
8930 { 8918 {
8931 float old_top, old_shown; 8919 float old_top, old_shown;
8932 Dimension height; 8920 Dimension height;
8933 XtVaGetValues (widget, 8921 XtVaGetValues (widget,
8934 XtNtopOfThumb, &old_top, 8922 XtNtopOfThumb, &old_top,
9951 We return the number of characters stored into the buffer, 9939 We return the number of characters stored into the buffer,
9952 thus pretending to be `read'. 9940 thus pretending to be `read'.
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
9956 int 9944 static int
9957 XTread_socket (sd, bufp, numchars, expected) 9945 XTread_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;
9960 /* register */ int numchars; 9948 /* register */ int numchars;
9961 int expected; 9949 int expected;