emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Gtk scrollbar: thumb too short


From: Stefan Monnier
Subject: Re: Gtk scrollbar: thumb too short
Date: Thu, 27 Mar 2003 18:23:21 -0500

> I've just thought of an alternative trick to what the Motif code uses:
> use the Xaw system in general, but while dragging force the thumb size
> to 0.  I don't have a patch yet, but it might be a better solution
> than what Motif uses right now.  The only disadvantage compared to
> the native scrollbar should be that the thumb size will be wrong
> while dragging (which it is already anyway).

Here's a sample patch for Motif users.
The main problem with it is that the thumb size is left as 0 when
the mouse button is released and is only reset to its true value
after a cursor movement or a click or .... anything.  But that's
the same problem as what Owen is complaingin about and I have
another patch in the works for it.


        Stefan


Index: xterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xterm.c,v
retrieving revision 1.785
diff -u -u -b -r1.785 xterm.c
--- xterm.c     23 Mar 2003 00:59:23 -0000      1.785
+++ xterm.c     27 Mar 2003 23:21:48 -0000
@@ -4105,9 +4109,7 @@
 
 /* Minimum and maximum values used for Motif scroll bars.  */
 
-#define XM_SB_MIN 1
 #define XM_SB_MAX 10000000
-#define XM_SB_RANGE (XM_SB_MAX - XM_SB_MIN)
 
 
 /* Scroll bar callback for Motif scroll bars.  WIDGET is the scroll
@@ -4157,17 +4159,14 @@
 
     case XmCR_DRAG:
       {
-       int slider_size;
-       int dragging_down_p = (INTEGERP (bar->dragging)
-                              && XINT (bar->dragging) <= cs->value);
-
-       /* Get the slider size.  */
+       /* Set the slider size to 0 to make sure we can drag to point-max.  */
        BLOCK_INPUT;
-       XtVaGetValues (widget, XmNsliderSize, &slider_size, NULL);
+       XmScrollBarSetValues (widget, cs->value, 1,
+                             0, 0, False);
        UNBLOCK_INPUT;
 
-       whole = XM_SB_RANGE - slider_size;
-       portion = min (cs->value - XM_SB_MIN, whole);
+       whole = XM_SB_MAX - 1;
+       portion = min (cs->value, whole);
        part = scroll_bar_handle;
        bar->dragging = make_number (cs->value);
       }
@@ -4382,7 +4381,7 @@
 #ifdef USE_MOTIF
   /* Set resources.  Create the widget.  */
   XtSetArg (av[ac], XtNmappedWhenManaged, False); ++ac;
-  XtSetArg (av[ac], XmNminimum, XM_SB_MIN); ++ac;
+  XtSetArg (av[ac], XmNminimum, 0); ++ac;
   XtSetArg (av[ac], XmNmaximum, XM_SB_MAX); ++ac;
   XtSetArg (av[ac], XmNorientation, XmVERTICAL); ++ac;
   XtSetArg (av[ac], XmNprocessingDirection, XmMAX_ON_BOTTOM), ++ac;
@@ -4576,22 +4575,6 @@
 
 #ifdef USE_MOTIF
 
-  /* We use an estimate of 30 chars per line rather than the real
-     `portion' value.  This has the disadvantage that the thumb size
-     is not very representative, but it makes our life a lot easier.
-     Otherwise, we have to constantly adjust the thumb size, which
-     we can't always do quickly enough: while dragging, the size of
-     the thumb might prevent the user from dragging the thumb all the
-     way to the end.  but Motif and some versions of Xaw3d don't allow
-     updating the thumb size while dragging.  Also, even if we can update
-     its size, the update will often happen too late.
-     If you don't believe it, check out revision 1.650 of xterm.c to see
-     what hoops we were going through and the still poor behavior we got.  */
-  portion = XFASTINT (XWINDOW (bar->window)->height) * 30;
-  /* When the thumb is at the bottom, position == whole.
-     So we need to increase `whole' to make space for the thumb.  */
-  whole += portion;
-
   if (whole <= 0)
     top = 0, shown = 1;
   else
@@ -4607,14 +4590,13 @@
       /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
          is the scroll bar's maximum and MIN is the scroll bar's minimum
         value.  */
-      size = shown * XM_SB_RANGE;
-      size = min (size, XM_SB_RANGE);
+      size = shown * XM_SB_MAX;
+      size = min (size, XM_SB_MAX);
       size = max (size, 1);
 
       /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
-      value = top * XM_SB_RANGE;
+      value = top * XM_SB_MAX;
       value = min (value, XM_SB_MAX - size);
-      value = max (value, XM_SB_MIN);
 
       XmScrollBarSetValues (widget, value, size, 0, 0, False);
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]