# HG changeset patch # User YAMAMOTO Mitsuharu # Date 1172284984 0 # Node ID d14fbfc5dd8e1474239b30593df3346575db2a5c # Parent d0a0f8a99229b6bd8b3897a6172e6ff1e28fa190 [USE_TOOLKIT_SCROLL_BARS] (x_scroll_bar_handle_drag) (x_set_toolkit_scroll_bar_thumb): Add bar->min_handle as margin to scroll bar handle size in order to avoid `scroll backward' problem. (x_scroll_bar_create, XTset_vertical_scroll_bar) [USE_TOOLKIT_SCROLL_BARS]: Initialize bar->min_handle. diff -r d0a0f8a99229 -r d14fbfc5dd8e src/macterm.c --- a/src/macterm.c Sat Feb 24 01:26:22 2007 +0000 +++ b/src/macterm.c Sat Feb 24 02:43:04 2007 +0000 @@ -4829,9 +4829,7 @@ XSETINT (bar->dragging, - (XINT (bar->dragging) + 1)); top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top); - top_range = (XINT (bar->track_height) - (r.bottom - r.top)) * - (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch)) - + .5; + top_range = XINT (bar->track_height) - XINT (bar->min_handle); if (top < 0) top = 0; @@ -4898,13 +4896,16 @@ if (XINT (bar->track_height) == 0) return; - if (whole == 0) + if (whole <= portion) value = 0, viewsize = 1, maximum = 0; else { - value = position; - viewsize = portion; - maximum = max (0, whole - portion); + float scale; + + maximum = XINT (bar->track_height) - XINT (bar->min_handle); + scale = (float) maximum / (whole - portion); + value = position * scale + 0.5f; + viewsize = (int) (portion * scale + 0.5f) + XINT (bar->min_handle); } BLOCK_INPUT; @@ -4985,6 +4986,7 @@ #ifdef USE_TOOLKIT_SCROLL_BARS bar->track_top = Qnil; bar->track_height = Qnil; + bar->min_handle = Qnil; #endif /* Add bar to its frame's list of scroll bars. */ @@ -5205,6 +5207,7 @@ #ifdef USE_TOOLKIT_SCROLL_BARS bar->track_top = Qnil; bar->track_height = Qnil; + bar->min_handle = Qnil; #endif } @@ -5218,6 +5221,7 @@ { XSETINT (bar->track_top, 0); XSETINT (bar->track_height, 0); + XSETINT (bar->min_handle, 0); } else { @@ -5227,7 +5231,7 @@ BLOCK_INPUT; SetControl32BitMinimum (ch, 0); - SetControl32BitMaximum (ch, 1); + SetControl32BitMaximum (ch, 1 << 30); SetControlViewSize (ch, 1); /* Move the scroll bar thumb to the top. */ @@ -5235,12 +5239,13 @@ get_control_part_bounds (ch, kControlIndicatorPart, &r0); /* Move the scroll bar thumb to the bottom. */ - SetControl32BitValue (ch, 1); + SetControl32BitValue (ch, 1 << 30); get_control_part_bounds (ch, kControlIndicatorPart, &r1); UnionRect (&r0, &r1, &r0); XSETINT (bar->track_top, r0.top); XSETINT (bar->track_height, r0.bottom - r0.top); + XSETINT (bar->min_handle, r1.bottom - r1.top); /* Don't show the scroll bar if its height is not enough to display the scroll bar thumb. */