aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c68
1 files changed, 43 insertions, 25 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 2c6559c8932..77e85ca2274 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1,6 +1,7 @@
1/* Implementation of GUI terminal on the Microsoft W32 API. 1/* Implementation of GUI terminal on the Microsoft W32 API.
2 Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2 Copyright (C) 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 3 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 2006, 2007 Free Software Foundation, Inc.
4 5
5This file is part of GNU Emacs. 6This file is part of GNU Emacs.
6 7
@@ -3473,31 +3474,51 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3473 int portion, position, whole; 3474 int portion, position, whole;
3474{ 3475{
3475 Window w = SCROLL_BAR_W32_WINDOW (bar); 3476 Window w = SCROLL_BAR_W32_WINDOW (bar);
3476 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 3477 /* We use the whole scroll-bar height in the calculations below, to
3478 avoid strange effects like scrolling backwards when just clicking
3479 on the handle (without moving it). */
3480 double range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height))
3481 + VERTICAL_SCROLL_BAR_MIN_HANDLE;
3477 int sb_page, sb_pos; 3482 int sb_page, sb_pos;
3478 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE; 3483 BOOL draggingp = !NILP (bar->dragging) ? TRUE : FALSE;
3479 SCROLLINFO si; 3484 SCROLLINFO si;
3480 3485
3481 if (whole) 3486 /* We used to change the nPage setting while dragging the handle,
3487 but that had very strange effects (such as scrolling backwards
3488 while dragging downwards).
3489
3490 Now, we don't change the nPage setting while dragging unless we
3491 get near to the end of the buffer, in which case we often have to
3492 resize the handle to "go all the way". */
3493
3494 if (draggingp)
3482 { 3495 {
3483#if 0 3496 int near_bottom_p;
3484 /* This code is not used (the settings are overwritten 3497 BLOCK_INPUT;
3485 immediately by the lines below it). 3498 si.cbSize = sizeof (si);
3486 Should it be used? KFS 2007-02-19. */ 3499 si.fMask = SIF_POS | SIF_PAGE;
3500 GetScrollInfo(w, SB_CTL, &si);
3501 near_bottom_p = si.nPos + si.nPage >= range;
3502 UNBLOCK_INPUT;
3503 if (!near_bottom_p)
3504 return;
3505 }
3487 3506
3507 if (whole)
3508 {
3488 /* Position scroll bar at rock bottom if the bottom of the 3509 /* Position scroll bar at rock bottom if the bottom of the
3489 buffer is visible. This avoids shinking the thumb away 3510 buffer is visible. This avoids shinking the thumb away
3490 to nothing if it is held at the bottom of the buffer. */ 3511 to nothing if it is held at the bottom of the buffer. */
3491 if (position + portion >= whole) 3512 if (position + portion >= whole && !draggingp)
3492 { 3513 {
3493 sb_page = range * (whole - position) / whole 3514 sb_page = range * (whole - position) / whole;
3494 + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3515 sb_pos = range;
3495 sb_pos = range; 3516 }
3496 } 3517 else
3497#endif 3518 {
3498 3519 sb_pos = position * range / whole;
3499 sb_page = portion * range / whole + VERTICAL_SCROLL_BAR_MIN_HANDLE; 3520 sb_page = (min (portion, (whole - position)) * range) / whole;
3500 sb_pos = position * range / whole; 3521 }
3501 } 3522 }
3502 else 3523 else
3503 { 3524 {
@@ -3505,19 +3526,16 @@ w32_set_scroll_bar_thumb (bar, portion, position, whole)
3505 sb_pos = 0; 3526 sb_pos = 0;
3506 } 3527 }
3507 3528
3529 sb_page = max (sb_page, VERTICAL_SCROLL_BAR_MIN_HANDLE);
3530
3508 BLOCK_INPUT; 3531 BLOCK_INPUT;
3509 3532
3510 si.cbSize = sizeof (si); 3533 si.cbSize = sizeof (si);
3511 /* Only update page size if currently dragging, to reduce 3534 si.fMask = SIF_PAGE | SIF_POS;
3512 flicker effects. */
3513 if (draggingp)
3514 si.fMask = SIF_PAGE;
3515 else
3516 si.fMask = SIF_PAGE | SIF_POS;
3517 si.nPage = sb_page; 3535 si.nPage = sb_page;
3518 si.nPos = sb_pos; 3536 si.nPos = sb_pos;
3519 3537
3520 SetScrollInfo (w, SB_CTL, &si, !draggingp); 3538 SetScrollInfo (w, SB_CTL, &si, TRUE);
3521 3539
3522 UNBLOCK_INPUT; 3540 UNBLOCK_INPUT;
3523} 3541}