aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2014-08-28 08:46:58 +0200
committerMartin Rudalics2014-08-28 08:46:58 +0200
commita7ef7a0e53ae1f391f4bda207bb5e9b9d833d354 (patch)
tree47c95273a03b30fdcc7f5c4e3224a6fe298668a0 /src
parentf1fdf67b4e87cf5974fa4e445b23fef1d10bb7cb (diff)
downloademacs-a7ef7a0e53ae1f391f4bda207bb5e9b9d833d354.tar.gz
emacs-a7ef7a0e53ae1f391f4bda207bb5e9b9d833d354.zip
Some fixes for scroll bar code.
* w32term.c (w32_horizontal_scroll_bar_handle_click): In `event->y' return entire range (the size of the scroll bar minus that of the thumb). * xterm.c (xm_scroll_callback, xaw_jump_callback): In `whole' return entire range (the scaled size of the scroll bar minus that of the slider). In `portion' return the scaled position of the slider. (xaw_jump_callback): Restore part of code for vertical scroll bar broken in change from 2014-07-27. (xaw_scroll_callback): Provide incremental scrolling with horizontal scroll bars. (x_scroll_bar_handle_click): Fix typo introduced in change from 2014-07-27. * scroll-bar.el (scroll-bar-horizontal-drag-1): Handle new interpretation of `portion-whole'.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog16
-rw-r--r--src/w32term.c5
-rw-r--r--src/xterm.c114
3 files changed, 99 insertions, 36 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index d08b3780242..d0eec16a60a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,19 @@
12014-08-28 Martin Rudalics <rudalics@gmx.at>
2
3 * w32term.c (w32_horizontal_scroll_bar_handle_click): In
4 `event->y' return entire range (the size of the scroll bar minus
5 that of the thumb).
6 * xterm.c (xm_scroll_callback, xaw_jump_callback): In `whole'
7 return entire range (the scaled size of the scroll bar minus
8 that of the slider). In `portion' return the scaled position of
9 the slider.
10 (xaw_jump_callback): Restore part of code for vertical scroll
11 bar broken in change from 2014-07-27.
12 (xaw_scroll_callback): Provide incremental scrolling with
13 horizontal scroll bars.
14 (x_scroll_bar_handle_click): Fix typo introduced in change from
15 2014-07-27.
16
12014-08-28 Eli Zaretskii <eliz@gnu.org> 172014-08-28 Eli Zaretskii <eliz@gnu.org>
2 18
3 * conf_post.h (_GL_EXECINFO_INLINE) [MSDOS]: Don't define. 19 * conf_post.h (_GL_EXECINFO_INLINE) [MSDOS]: Don't define.
diff --git a/src/w32term.c b/src/w32term.c
index d9e051be870..55c2d718346 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4293,7 +4293,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
4293 x = si.nTrackPos; 4293 x = si.nTrackPos;
4294 else 4294 else
4295 x = si.nPos; 4295 x = si.nPos;
4296 y = si.nMax - x - si.nPage; 4296 y = si.nMax - si.nPage;
4297 4297
4298 bar->dragging = 0; 4298 bar->dragging = 0;
4299 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam; 4299 FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
@@ -4350,12 +4350,9 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
4350 int end = bar->end; 4350 int end = bar->end;
4351 4351
4352 si.cbSize = sizeof (si); 4352 si.cbSize = sizeof (si);
4353/** si.fMask = SIF_PAGE | SIF_POS; **/
4354 si.fMask = SIF_POS; 4353 si.fMask = SIF_POS;
4355/** si.nPage = end - start + HORIZONTAL_SCROLL_BAR_MIN_HANDLE; **/
4356 si.nPos = min (last_scroll_bar_drag_pos, 4354 si.nPos = min (last_scroll_bar_drag_pos,
4357 XWINDOW (bar->window)->hscroll_whole - 1); 4355 XWINDOW (bar->window)->hscroll_whole - 1);
4358/** si.nPos = last_scroll_bar_drag_pos; **/
4359 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE); 4356 SetScrollInfo (SCROLL_BAR_W32_WINDOW (bar), SB_CTL, &si, TRUE);
4360 } 4357 }
4361 /* fall through */ 4358 /* fall through */
diff --git a/src/xterm.c b/src/xterm.c
index 7b8d32a4516..e4a725a4ab1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -4549,12 +4549,9 @@ xm_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4549 4549
4550 if (horizontal) 4550 if (horizontal)
4551 { 4551 {
4552 whole = bar->whole; 4552 portion = bar->whole * ((float)cs->value / XM_SB_MAX);
4553 portion = (((float) cs->value 4553 whole = bar->whole * ((float)(XM_SB_MAX - slider_size) / XM_SB_MAX);
4554 / (XM_SB_MAX - slider_size)) 4554 portion = min (portion, whole);
4555 * (whole
4556 - ((float) slider_size / XM_SB_MAX) * whole));
4557 portion = max (0, portion);
4558 part = scroll_bar_horizontal_handle; 4555 part = scroll_bar_horizontal_handle;
4559 } 4556 }
4560 else 4557 else
@@ -4687,24 +4684,51 @@ xaw_jump_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4687 float *top_addr = call_data; 4684 float *top_addr = call_data;
4688 float top = *top_addr; 4685 float top = *top_addr;
4689 float shown; 4686 float shown;
4690 int whole, portion, height; 4687 int whole, portion, height, width;
4691 enum scroll_bar_part part; 4688 enum scroll_bar_part part;
4692 int horizontal = bar->horizontal; 4689 int horizontal = bar->horizontal;
4693 4690
4694 /* Get the size of the thumb, a value between 0 and 1. */
4695 block_input ();
4696 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
4697 unblock_input ();
4698 4691
4699 if (horizontal) 4692 if (horizontal)
4700 { 4693 {
4701 whole = bar->whole; 4694 /* Get the size of the thumb, a value between 0 and 1. */
4702 portion = (top * (whole - (shown * whole))) / (1 - shown); 4695 block_input ();
4703 portion = max (0, portion); 4696 XtVaGetValues (widget, XtNshown, &shown, XtNwidth, &width, NULL);
4697 unblock_input ();
4698
4699 if (shown < 1)
4700 {
4701 whole = bar->whole - (shown * bar->whole);
4702 portion = min (top * bar->whole, whole);
4703 }
4704 else
4705 {
4706 whole = bar->whole;
4707 portion = 0;
4708 }
4709
4704 part = scroll_bar_horizontal_handle; 4710 part = scroll_bar_horizontal_handle;
4705 } 4711 }
4706 else 4712 else
4707 part = scroll_bar_handle; 4713 {
4714 /* Get the size of the thumb, a value between 0 and 1. */
4715 block_input ();
4716 XtVaGetValues (widget, XtNshown, &shown, XtNheight, &height, NULL);
4717 unblock_input ();
4718
4719 whole = 10000000;
4720 portion = shown < 1 ? top * whole : 0;
4721
4722 if (shown < 1 && (eabs (top + shown - 1) < 1.0f / height))
4723 /* Some derivatives of Xaw refuse to shrink the thumb when you reach
4724 the bottom, so we force the scrolling whenever we see that we're
4725 too close to the bottom (in x_set_toolkit_scroll_bar_thumb
4726 we try to ensure that we always stay two pixels away from the
4727 bottom). */
4728 part = scroll_bar_down_arrow;
4729 else
4730 part = scroll_bar_handle;
4731 }
4708 4732
4709 window_being_scrolled = bar->window; 4733 window_being_scrolled = bar->window;
4710 bar->dragging = portion; 4734 bar->dragging = portion;
@@ -4727,28 +4751,54 @@ xaw_scroll_callback (Widget widget, XtPointer client_data, XtPointer call_data)
4727 struct scroll_bar *bar = client_data; 4751 struct scroll_bar *bar = client_data;
4728 /* The position really is stored cast to a pointer. */ 4752 /* The position really is stored cast to a pointer. */
4729 int position = (intptr_t) call_data; 4753 int position = (intptr_t) call_data;
4730 Dimension height; 4754 Dimension height, width;
4731 enum scroll_bar_part part; 4755 enum scroll_bar_part part;
4732 4756
4733 /* Get the height of the scroll bar. */ 4757 if (bar->horizontal)
4734 block_input (); 4758 {
4735 XtVaGetValues (widget, XtNheight, &height, NULL); 4759 /* Get the width of the scroll bar. */
4736 unblock_input (); 4760 block_input ();
4761 XtVaGetValues (widget, XtNwidth, &width, NULL);
4762 unblock_input ();
4763
4764 if (eabs (position) >= width)
4765 part = (position < 0) ? scroll_bar_before_handle : scroll_bar_after_handle;
4737 4766
4738 if (eabs (position) >= height) 4767 /* If Xaw3d was compiled with ARROW_SCROLLBAR,
4739 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle; 4768 it maps line-movement to call_data = max(5, height/20). */
4769 else if (xaw3d_arrow_scroll && eabs (position) <= max (5, width / 20))
4770 part = (position < 0) ? scroll_bar_left_arrow : scroll_bar_right_arrow;
4771 else
4772 part = scroll_bar_move_ratio;
4740 4773
4741 /* If Xaw3d was compiled with ARROW_SCROLLBAR, 4774 window_being_scrolled = bar->window;
4742 it maps line-movement to call_data = max(5, height/20). */ 4775 bar->dragging = -1;
4743 else if (xaw3d_arrow_scroll && eabs (position) <= max (5, height / 20)) 4776 bar->last_seen_part = part;
4744 part = (position < 0) ? scroll_bar_up_arrow : scroll_bar_down_arrow; 4777 x_send_scroll_bar_event (bar->window, part, position, width, bar->horizontal);
4778 }
4745 else 4779 else
4746 part = scroll_bar_move_ratio; 4780 {
4747 4781
4748 window_being_scrolled = bar->window; 4782 /* Get the height of the scroll bar. */
4749 bar->dragging = -1; 4783 block_input ();
4750 bar->last_seen_part = part; 4784 XtVaGetValues (widget, XtNheight, &height, NULL);
4751 x_send_scroll_bar_event (bar->window, part, position, height, bar->horizontal); 4785 unblock_input ();
4786
4787 if (eabs (position) >= height)
4788 part = (position < 0) ? scroll_bar_above_handle : scroll_bar_below_handle;
4789
4790 /* If Xaw3d was compiled with ARROW_SCROLLBAR,
4791 it maps line-movement to call_data = max(5, height/20). */
4792 else if (xaw3d_arrow_scroll && eabs (position) <= max (5, height / 20))
4793 part = (position < 0) ? scroll_bar_up_arrow : scroll_bar_down_arrow;
4794 else
4795 part = scroll_bar_move_ratio;
4796
4797 window_being_scrolled = bar->window;
4798 bar->dragging = -1;
4799 bar->last_seen_part = part;
4800 x_send_scroll_bar_event (bar->window, part, position, height, bar->horizontal);
4801 }
4752} 4802}
4753 4803
4754#endif /* not USE_GTK and not USE_MOTIF */ 4804#endif /* not USE_GTK and not USE_MOTIF */
@@ -6134,7 +6184,7 @@ x_scroll_bar_handle_click (struct scroll_bar *bar,
6134 /* If the user has released the handle, set it to its final position. */ 6184 /* If the user has released the handle, set it to its final position. */
6135 if (event->type == ButtonRelease && bar->dragging != -1) 6185 if (event->type == ButtonRelease && bar->dragging != -1)
6136 { 6186 {
6137 int new_start = - bar->dragging; 6187 int new_start = y - bar->dragging;
6138 int new_end = new_start + bar->end - bar->start; 6188 int new_end = new_start + bar->end - bar->start;
6139 6189
6140 x_scroll_bar_set_handle (bar, new_start, new_end, 0); 6190 x_scroll_bar_set_handle (bar, new_start, new_end, 0);