unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: vertical scrollbar error on MS Windows
@ 2007-02-21  0:24 grischka
  2007-02-21  8:07 ` Kim F. Storm
  2007-02-21 19:01 ` Stefan Monnier
  0 siblings, 2 replies; 27+ messages in thread
From: grischka @ 2007-02-21  0:24 UTC (permalink / raw)
  To: storm; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 239 bytes --]

Hi there,

Here is another fix for the scrollbars. From the approach
it calculates the thumb length once on mouse down and 
then leaves bar parameters alone during dragging. Patch 
for w32term.c is in the attachement.

Regards
-- grischka

[-- Attachment #2: w32term.c.diff --]
[-- Type: application/octet-stream, Size: 3482 bytes --]

--- c:/checkout/emacs-cvs/emacs/src/w32term.c	Tue Feb 20 02:22:42 2007
+++ w32term.c	Wed Feb 21 00:10:48 2007
@@ -3468,11 +3468,70 @@
 /* Set the thumb size and position of scroll bar BAR.  We are currently
    displaying PORTION out of a whole WHOLE, and our position POSITION.  */
 
+#define SCROLL_FIX
+
 static void
 w32_set_scroll_bar_thumb (bar, portion, position, whole)
      struct scroll_bar *bar;
      int portion, position, whole;
 {
+#ifdef SCROLL_FIX
+    Window w;
+    BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
+    SCROLLINFO si;
+    int sb_page, sb_pos, range, window, lines, n, mem;
+
+    static int was_draggingp;
+    if (draggingp && was_draggingp)
+        return;
+    was_draggingp = draggingp;
+
+    // scan some text
+    mem = whole;
+    if (mem > 20000)
+        mem = 20000;
+
+    for (lines = 0, n = 1; n <= mem; ++n)
+        if (FETCH_BYTE(n) == '\n')
+            ++lines;
+
+    window = WINDOW_TOTAL_LINES (XWINDOW (bar->window));
+    range = VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT(bar->height));
+
+    if (mem == whole) {
+        sb_page = range * window / (lines + window);
+    } else {
+        window = window * mem / (lines + 1); // in bytes, avg.
+        sb_page = range * window / (whole + window);
+    }
+
+    // bigger is nicer for them with a cheap mouse
+    n = VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT(bar->width));
+    if (sb_page < n) {
+        sb_page = n;
+        // but not too big ...
+        n = range/4;
+        if (sb_page > n)
+            sb_page = n;
+    }
+
+    if (0 == whole)
+        sb_pos = 0;
+    else
+        sb_pos = ((double) position * (range - sb_page) + whole - 1) / whole;
+
+    si.cbSize = sizeof (si);
+    si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL;
+    si.nMin = 0;
+    si.nMax = range - 1;
+    si.nPage = sb_page;
+    si.nPos = sb_pos;
+
+    w = SCROLL_BAR_W32_WINDOW (bar);
+    SetScrollInfo (w, SB_CTL, &si, TRUE);
+    return;
+
+#else
   Window w = SCROLL_BAR_W32_WINDOW (bar);
   /* We use the whole scroll-bar height in the calculations below, to
      avoid strange effects like scrolling backwards when just clicking
@@ -3538,6 +3597,7 @@
   SetScrollInfo (w, SB_CTL, &si, TRUE);
 
   UNBLOCK_INPUT;
+#endif
 }
 
 \f
@@ -3946,9 +4006,15 @@
     si.cbSize = sizeof (si);
     si.fMask = SIF_POS;
 
+#ifdef SCROLL_FIX
+    si.fMask = SIF_POS|SIF_RANGE|SIF_PAGE; //gr
+#endif
     GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
     y = si.nPos;
 
+#ifdef SCROLL_FIX
+    top_range = si.nMax + 1 - si.nPage; //gr
+#endif
     bar->dragging = Qnil;
 
 
@@ -3983,6 +4049,7 @@
 	bar->dragging = Qt;
 	emacs_event->part = scroll_bar_handle;
 
+#ifndef SCROLL_FIX
 	/* "Silently" update current position.  */
 	{
 	  SCROLLINFO si;
@@ -3996,11 +4063,13 @@
 
 	  SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, FALSE);
 	}
+#endif
 	break;
       case SB_ENDSCROLL:
 	/* If this is the end of a drag sequence, then reset the scroll
 	   handle size to normal and do a final redraw.  Otherwise do
 	   nothing.  */
+#ifndef SCROLL_FIX
 	if (dragging)
 	  {
 	    SCROLLINFO si;
@@ -4013,6 +4082,7 @@
 	    si.nPos = last_scroll_bar_drag_pos;
 	    SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
 	  }
+#endif
 	/* fall through */
       default:
 	emacs_event->kind = NO_EVENT;

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 27+ messages in thread
* Re: vertical scrollbar error on MS Windows
@ 2007-02-28 20:01 grischka
  2007-02-28 20:54 ` Lennart Borgman (gmail)
  2007-03-01  9:11 ` David Kastrup
  0 siblings, 2 replies; 27+ messages in thread
From: grischka @ 2007-02-28 20:01 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

David Kastrup wrote:

> ... since anything but Athena behavior (and the resulting Lucid toolbars
> _have_ Athena behavior) is so much less functional as to be crippled.

> Scroll back and forth without moving the mouse in between?  Blank.
> Scroll a variable amount with one click?  Blank.
> Scroll back and forth a variable amount?  Double blank.

Yes, not bad. Aside from personal preference, I'm all pro 
to keep up variety in GUI culture.

-- grischka

^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <b5accf970702131432t76036b4erb72cbe4d86e11077@mail.gmail.com>]

end of thread, other threads:[~2007-03-01  9:11 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-21  0:24 vertical scrollbar error on MS Windows grischka
2007-02-21  8:07 ` Kim F. Storm
2007-02-21 14:02   ` grischka
2007-02-21 19:01 ` Stefan Monnier
2007-02-21 23:36   ` grischka
2007-02-26 19:39     ` Stefan Monnier
2007-02-27 19:19       ` grischka
2007-02-27 20:44         ` David Kastrup
2007-02-27 22:56         ` Stefan Monnier
2007-02-28 19:45           ` grischka
2007-02-28 21:45             ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2007-02-28 20:01 grischka
2007-02-28 20:54 ` Lennart Borgman (gmail)
2007-03-01  9:11 ` David Kastrup
     [not found] <b5accf970702131432t76036b4erb72cbe4d86e11077@mail.gmail.com>
     [not found] ` <er4kem$ce7$1@sea.gmane.org>
2007-02-19 14:58   ` Kim F. Storm
2007-02-19 16:13     ` Juanma Barranquero
2007-02-19 22:39       ` Kim F. Storm
2007-02-19 23:01         ` Juanma Barranquero
2007-02-19 23:16           ` Nick Roberts
2007-02-19 17:03     ` Lennart Borgman (gmail)
2007-02-19 22:54       ` Peter Tury
2007-02-22 15:07       ` Stephan Hennig
2007-02-22 15:56         ` Jason Rumney
2007-02-22 16:52           ` Kim F. Storm
2007-02-22 17:00           ` Stephan Hennig
2007-02-22 17:28             ` Kim F. Storm
2007-02-22 23:35         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).