]> code.delx.au - gnu-emacs/commitdiff
Preliminary attempt to fix horizontal scroll bar dragging with bidi text.
authorMartin Rudalics <rudalics@gmx.at>
Sat, 16 Aug 2014 15:47:38 +0000 (17:47 +0200)
committerMartin Rudalics <rudalics@gmx.at>
Sat, 16 Aug 2014 15:47:38 +0000 (17:47 +0200)
* w32term.c (w32_horizontal_scroll_bar_handle_click): In y part
of emacs_event return length from si.nPage to si.nMax.
* xdisp.c (set_horizontal_scroll_bar): For right-to-left text
interchange start and end of thumb.
* scroll-bar.el (scroll-bar-horizontal-drag-1): Use cdr of
portion-whole for scrolling right-to-left text.

lisp/ChangeLog
lisp/scroll-bar.el
src/ChangeLog
src/w32term.c
src/xdisp.c

index f96921d432913a73a34968f7dd3f3203e0ae008e..b474e87caa154f6b80621d784e6c0331840a0611 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-16  Martin Rudalics  <rudalics@gmx.at>
+
+       * scroll-bar.el (scroll-bar-horizontal-drag-1): Use cdr of
+       portion-whole for scrolling right-to-left text.
+
 2014-08-15  Leo Liu  <sdl.web@gmail.com>
 
        * speedbar.el (speedbar-generic-list-tag-p): Allow special
index 739670cb1c93437acaf193562f828aa3317799de..1af70b0d63105425745e1645f4906ccf80f9c245 100644 (file)
@@ -327,8 +327,11 @@ If you click outside the slider, the window scrolls to bring the slider there."
         (window (nth 0 start-position))
         (portion-whole (nth 2 start-position))
         (unit (frame-char-width (window-frame window))))
-    (set-window-hscroll
-     window (/ (1- (+ (car portion-whole) unit)) unit))))
+    (if (eq (current-bidi-paragraph-direction) 'left-to-right)
+       (set-window-hscroll
+        window (/ (1- (+ (car portion-whole) unit)) unit))
+      (set-window-hscroll
+        window (/ (1- (+ (cdr portion-whole) unit)) unit)))))
 
 (defun scroll-bar-horizontal-drag (event)
   "Scroll the window horizontally by dragging the scroll bar slider.
index 91b72e479d73acf7fb6c9e5a4d2de094113485da..8e6e75e8b5304fde0cf3821bb5394d7f91489646 100644 (file)
@@ -1,3 +1,10 @@
+2014-08-16  Martin Rudalics  <rudalics@gmx.at>
+
+       * w32term.c (w32_horizontal_scroll_bar_handle_click): In y part
+       of emacs_event return length from si.nPage to si.nMax.
+       * xdisp.c (set_horizontal_scroll_bar): For right-to-left text
+       interchange start and end of thumb.
+
 2014-08-15  Ken Brown  <kbrown@cornell.edu>
 
        * gmalloc.c (_malloc_mutex, _aligned_blocks_mutex) [CYGWIN]: Use
index dfda29fb903993fff5f4beacfa98ef0a167e8fbc..4eff5ab4cdd1ac3cdad9b863f3a505cb97664f4a 100644 (file)
@@ -4272,15 +4272,15 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
 
   {
     int left_range = HORIZONTAL_SCROLL_BAR_LEFT_RANGE (f, bar->width);
-    int x;
+    int x, y;
     int dragging = bar->dragging;
     SCROLLINFO si;
 
     si.cbSize = sizeof (si);
-    si.fMask = SIF_POS;
-
+    si.fMask = SIF_POS | SIF_PAGE | SIF_RANGE;
     GetScrollInfo ((HWND) msg->msg.lParam, SB_CTL, &si);
     x = si.nPos;
+    y = si.nMax - si.nPos - si.nPage;
 
     bar->dragging = 0;
     FRAME_DISPLAY_INFO (f)->last_mouse_scroll_bar_pos = msg->msg.wParam;
@@ -4354,7 +4354,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar *bar, W32Msg *msg,
       }
 
     XSETINT (emacs_event->x, x);
-    XSETINT (emacs_event->y, left_range);
+    XSETINT (emacs_event->y, y);
 
     return TRUE;
   }
index fe16b2c6a0723d3f2df81ded924f9eb8de6a1e07..c46b4159de0e312fc39f9a05311dd0351e459cf6 100644 (file)
@@ -15779,7 +15779,7 @@ set_vertical_scroll_bar (struct window *w)
 void
 set_horizontal_scroll_bar (struct window *w)
 {
-  int start, end, whole, box_width;
+  int start, end, whole, portion;
 
   if (!MINI_WINDOW_P (w)
       || (w == XWINDOW (minibuf_window)
@@ -15806,14 +15806,25 @@ set_horizontal_scroll_bar (struct window *w)
                          MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); */
 
       start = w->hscroll * FRAME_COLUMN_WIDTH (WINDOW_XFRAME (w));
-      box_width = window_box_width (w, TEXT_AREA);
-      end = start + box_width;
+      end = start + window_box_width (w, TEXT_AREA);
+      portion = end - start;
+      /* After enlarging a horizontally scrolled window such that it
+        gets at least as wide as the text it contains, make sure that
+        the thumb doesn't fill the entire scroll bar so we can still
+        drag it back to see the entire text.  */
+      whole = max (whole, end);
 
-      /* The following is needed to ensure that if after maximizing a
-        window we get hscroll > 0, we can still drag the thumb to the
-        left.  */
-      whole = max (whole, w->hscroll + box_width);
-      whole = max (whole, end - start);
+      if (it.bidi_p)
+       {
+         Lisp_Object pdir;
+
+         pdir = Fcurrent_bidi_paragraph_direction (Qnil);
+         if (EQ (pdir, Qright_to_left))
+           {
+             start = whole - end;
+             end = start + portion;
+           }
+       }
 
       if (old_buffer)
        set_buffer_internal (old_buffer);
@@ -15826,7 +15837,7 @@ set_horizontal_scroll_bar (struct window *w)
   /* Indicate what this scroll bar ought to be displaying now.  */
   if (FRAME_TERMINAL (XFRAME (w->frame))->set_horizontal_scroll_bar_hook)
     (*FRAME_TERMINAL (XFRAME (w->frame))->set_horizontal_scroll_bar_hook)
-      (w, end - start, whole, start);
+      (w, portion, whole, start);
 }