all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "grischka" <grishka@gmx.de>
To: <storm@cua.dk>
Cc: emacs-devel@gnu.org
Subject: Re: vertical scrollbar error on MS Windows
Date: Wed, 21 Feb 2007 01:24:20 +0100	[thread overview]
Message-ID: <001401c7554e$bbd42100$2446fe91@j4f3n1> (raw)

[-- 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

             reply	other threads:[~2007-02-21  0:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21  0:24 grischka [this message]
2007-02-21  8:07 ` vertical scrollbar error on MS Windows 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001401c7554e$bbd42100$2446fe91@j4f3n1' \
    --to=grishka@gmx.de \
    --cc=emacs-devel@gnu.org \
    --cc=storm@cua.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.