From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "grischka" Newsgroups: gmane.emacs.devel Subject: Re: vertical scrollbar error on MS Windows Date: Wed, 21 Feb 2007 01:24:20 +0100 Message-ID: <001401c7554e$bbd42100$2446fe91@j4f3n1> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_000B_01C75557.0304A420" X-Trace: sea.gmane.org 1172031079 5410 80.91.229.12 (21 Feb 2007 04:11:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 21 Feb 2007 04:11:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 21 05:11:13 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HJioy-0004m9-9a for ged-emacs-devel@m.gmane.org; Wed, 21 Feb 2007 05:11:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HJiox-00039z-Jg for ged-emacs-devel@m.gmane.org; Tue, 20 Feb 2007 23:11:11 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HJfI7-0006ay-JV for emacs-devel@gnu.org; Tue, 20 Feb 2007 19:25:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HJfI6-0006YT-3r for emacs-devel@gnu.org; Tue, 20 Feb 2007 19:25:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HJfI5-0006YK-Tm for emacs-devel@gnu.org; Tue, 20 Feb 2007 19:25:01 -0500 Original-Received: from mail.gmx.net ([213.165.64.20]) by monty-python.gnu.org with smtp (Exim 4.52) id 1HJfI5-00034o-83 for emacs-devel@gnu.org; Tue, 20 Feb 2007 19:25:01 -0500 Original-Received: (qmail invoked by alias); 21 Feb 2007 00:24:58 -0000 X-Provags-ID: V01U2FsdGVkX1/yOi0mgQTyQvdAe/O8Rwv6TpZjjVaXFgBYoyeJ8g +P7g== X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Y-GMX-Trusted: 0 X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Tue, 20 Feb 2007 23:10:57 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:66566 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C75557.0304A420 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit 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 ------=_NextPart_000_000B_01C75557.0304A420 Content-Type: application/octet-stream; name="w32term.c.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="w32term.c.diff" --- c:/checkout/emacs-cvs/emacs/src/w32term.c Tue Feb 20 02:22:42 2007=0A= +++ w32term.c Wed Feb 21 00:10:48 2007=0A= @@ -3468,11 +3468,70 @@=0A= /* Set the thumb size and position of scroll bar BAR. We are currently displaying PORTION out of a whole WHOLE, and our position POSITION. = */ =20 +#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 =3D !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 =3D draggingp; + + // scan some text + mem =3D whole; + if (mem > 20000) + mem =3D 20000; + + for (lines =3D 0, n =3D 1; n <=3D mem; ++n) + if (FETCH_BYTE(n) =3D=3D '\n') + ++lines; + + window =3D WINDOW_TOTAL_LINES (XWINDOW (bar->window)); + range =3D VERTICAL_SCROLL_BAR_INSIDE_HEIGHT (f, XINT(bar->height)); + + if (mem =3D=3D whole) { + sb_page =3D range * window / (lines + window); + } else { + window =3D window * mem / (lines + 1); // in bytes, avg. + sb_page =3D range * window / (whole + window); + } + + // bigger is nicer for them with a cheap mouse + n =3D VERTICAL_SCROLL_BAR_INSIDE_WIDTH (f, XINT(bar->width)); + if (sb_page < n) { + sb_page =3D n; + // but not too big ... + n =3D range/4; + if (sb_page > n) + sb_page =3D n; + } + + if (0 =3D=3D whole) + sb_pos =3D 0; + else + sb_pos =3D ((double) position * (range - sb_page) + whole - 1) = / whole; + + si.cbSize =3D sizeof (si); + si.fMask =3D SIF_PAGE | SIF_POS | SIF_RANGE | SIF_DISABLENOSCROLL; + si.nMin =3D 0; + si.nMax =3D range - 1; + si.nPage =3D sb_page; + si.nPos =3D sb_pos; + + w =3D SCROLL_BAR_W32_WINDOW (bar); + SetScrollInfo (w, SB_CTL, &si, TRUE); + return; + +#else Window w =3D 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 @@=0A= SetScrollInfo (w, SB_CTL, &si, TRUE); =20 UNBLOCK_INPUT; +#endif } =20 =0C @@ -3946,9 +4006,15 @@=0A= si.cbSize =3D sizeof (si); si.fMask =3D SIF_POS; =20 +#ifdef SCROLL_FIX + si.fMask =3D SIF_POS|SIF_RANGE|SIF_PAGE; //gr +#endif GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si); y =3D si.nPos; =20 +#ifdef SCROLL_FIX + top_range =3D si.nMax + 1 - si.nPage; //gr +#endif bar->dragging =3D Qnil; =20 =20 @@ -3983,6 +4049,7 @@=0A= bar->dragging =3D Qt; emacs_event->part =3D scroll_bar_handle; =20 +#ifndef SCROLL_FIX /* "Silently" update current position. */ { SCROLLINFO si; @@ -3996,11 +4063,13 @@=0A= =20 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 @@=0A= si.nPos =3D last_scroll_bar_drag_pos; SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE); } +#endif /* fall through */ default: emacs_event->kind =3D NO_EVENT; ------=_NextPart_000_000B_01C75557.0304A420 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ------=_NextPart_000_000B_01C75557.0304A420--