unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#998: after split-window-horizontally scroll works only on first window
@ 2008-09-18 13:44 Davide Viti
       [not found] ` <48D29A54.2050605@gmx.at>
  0 siblings, 1 reply; 13+ messages in thread
From: Davide Viti @ 2008-09-18 13:44 UTC (permalink / raw)
  To: bug-gnu-emacs

As said in the subject, no matter which of the two windows is active,
when using the mouse wheel to scroll up / down, it always happens on the left
window.

Apologies if this is a known bug.

thanx in advance,
Davide

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
If you would like to further debug the crash, please read the file
d:/emacs-22.2/etc/DEBUG for instructions.


In GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600)
 of 2008-03-26 on RELEASE
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ITA
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
  display-time-mode: t
  show-paren-mode: t
  encoded-kbd-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t









^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
       [not found] ` <48D29A54.2050605@gmx.at>
@ 2008-09-19  6:50   ` Davide Viti
  2008-09-19  7:01     ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Davide Viti @ 2008-09-19  6:50 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998

On Thu, Sep 18, 2008 at 08:13:40PM +0200, martin rudalics wrote:
> > As said in the subject, no matter which of the two windows is active,
> > when using the mouse wheel to scroll up / down, it always happens on the 
> left
> > window.
> 
> Could you please type C-h k, scroll the mouse wheel, and so tell me what
> command it is bound to?

<vertical-scroll-bar> <mouse-1> (translated from <mouse-1>) at that spot runs the command scroll-bar-toolkit-scroll
  which is an interactive compiled Lisp function in `scroll-bar.el'.
It is bound to <vertical-scroll-bar> <mouse-1>.
(scroll-bar-toolkit-scroll event)

Not documented.

thanx for your help,
Davide






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19  6:50   ` Davide Viti
@ 2008-09-19  7:01     ` martin rudalics
  2008-09-19  7:35       ` Davide Viti
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2008-09-19  7:01 UTC (permalink / raw)
  To: Davide Viti; +Cc: 998

 > <vertical-scroll-bar> <mouse-1> (translated from <mouse-1>) at that spot runs the command scroll-bar-toolkit-scroll
 >   which is an interactive compiled Lisp function in `scroll-bar.el'.

OK.  Could you now please append the following modified version of
`scroll-bar-toolkit-scroll' to your .emacs, restart Emacs, split the
window horizontally, move the mouse into each of these windows, scroll
the mouse and tell me whether the windows mentioned in the messages you
should see (here I get for example .... #<window 3 on .emacs>) have the
same or different values.

Thanks, martin.

;; code starts here
(defun scroll-bar-toolkit-scroll (event)
   (interactive "e")
   (let* ((end-position (event-end event))
	 (window (nth 0 end-position))
	 (part (nth 4 end-position))
	 before-scroll)
     (message ".... %s" window)
     (cond ((eq part 'end-scroll))
	  (t
	   (with-current-buffer (window-buffer window)
	     (setq before-scroll point-before-scroll))
	   (save-selected-window
	     (select-window window)
	     (setq before-scroll (or before-scroll (point)))
	     (cond ((eq part 'above-handle)
		    (scroll-up '-))
		   ((eq part 'below-handle)
		    (scroll-up nil))
		   ((eq part 'ratio)
		    (let* ((portion-whole (nth 2 end-position))
			   (lines (scroll-bar-scale portion-whole
						    (1- (window-height)))))
		      (scroll-up (cond ((not (zerop lines)) lines)
				       ((< (car portion-whole) 0) -1)
				       (t 1)))))
		   ((eq part 'up)
		    (scroll-up -1))
		   ((eq part 'down)
		    (scroll-up 1))
		   ((eq part 'top)
		    (set-window-start window (point-min)))
		   ((eq part 'bottom)
		    (goto-char (point-max))
		    (recenter))
		   ((eq part 'handle)
		    (scroll-bar-drag-1 event))))
	   (sit-for 0)
	   (with-current-buffer (window-buffer window)
	     (setq point-before-scroll before-scroll))))))
;; code ends here






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19  7:01     ` martin rudalics
@ 2008-09-19  7:35       ` Davide Viti
  2008-09-19  8:42         ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Davide Viti @ 2008-09-19  7:35 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998

On Fri, Sep 19, 2008 at 09:01:21AM +0200, martin rudalics wrote:
> > <vertical-scroll-bar> <mouse-1> (translated from <mouse-1>) at that spot 
> runs the command scroll-bar-toolkit-scroll
> >   which is an interactive compiled Lisp function in `scroll-bar.el'.
> 
> OK.  Could you now please append the following modified version of
> `scroll-bar-toolkit-scroll' to your .emacs, restart Emacs, split the
> window horizontally, move the mouse into each of these windows, scroll
> the mouse and tell me whether the windows mentioned in the messages you
> should see (here I get for example .... #<window 3 on .emacs>) have the
> same or different values.

still not working and I get the very same message as yours (.... #<window 3 on .emacs>)
when scrolling the wheel on any of the two windows

regards,
Davide

PS: last night I gave it a go on my Ubuntu machine and it worked; C-h-k gave me this:

<mouse-5> (translated from <down-mouse-5> <mouse-5>) at that spot runs the command mwheel-scroll
  which is an interactive compiled Lisp function in `mwheel.el'.
It is bound to <C-mouse-4>, <S-mouse-4>, <mouse-4>, <C-mouse-5>, <S-mouse-5>, <mouse-5>.
(mwheel-scroll event)

Scroll up or down according to the event.
This should only be bound to mouse buttons 4 and 5.







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19  7:35       ` Davide Viti
@ 2008-09-19  8:42         ` martin rudalics
  2008-09-19 11:23           ` Davide Viti
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2008-09-19  8:42 UTC (permalink / raw)
  To: Davide Viti; +Cc: 998

 > still not working and I get the very same message as yours (.... #<window 3 on .emacs>)
 > when scrolling the wheel on any of the two windows

So the fault is not with `scroll-bar-toolkit-scroll' but with the wrong
window chosen when making the input-event.  This could be related to
your mouse-driver - some of them try to "intelligently" guess the window
you want to scroll.  Finding the reason of this might be non-trivial.

 > PS: last night I gave it a go on my Ubuntu machine and it worked; C-h-k gave me this:
 >
 > <mouse-5> (translated from <down-mouse-5> <mouse-5>) at that spot runs the command mwheel-scroll
 >   which is an interactive compiled Lisp function in `mwheel.el'.
 > It is bound to <C-mouse-4>, <S-mouse-4>, <mouse-4>, <C-mouse-5>, <S-mouse-5>, <mouse-5>.
 > (mwheel-scroll event)
 >
 > Scroll up or down according to the event.
 > This should only be bound to mouse buttons 4 and 5.

I'm afraid the assignment is currently beyond the control of Emacs
whenever you have scroll bars enabled.  I suppose your Emacs on Windows
scrolls the right window (and runs `mwheel-scroll') when you disable
scroll bars, e.g., by putting (scroll-bar-mode -1) in your .emacs?

martin






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19  8:42         ` martin rudalics
@ 2008-09-19 11:23           ` Davide Viti
  2008-09-19 11:36             ` martin rudalics
  2008-09-24  9:35             ` martin rudalics
  0 siblings, 2 replies; 13+ messages in thread
From: Davide Viti @ 2008-09-19 11:23 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998

On Fri, Sep 19, 2008 at 10:42:35AM +0200, martin rudalics wrote:
> I'm afraid the assignment is currently beyond the control of Emacs
> whenever you have scroll bars enabled.  I suppose your Emacs on Windows
> scrolls the right window (and runs `mwheel-scroll') when you disable
> scroll bars, e.g., by putting (scroll-bar-mode -1) in your .emacs?

that is correct: (scroll-bar-mode -1) fixes it

thanx,
Davide






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19 11:23           ` Davide Viti
@ 2008-09-19 11:36             ` martin rudalics
  2008-09-24  9:35             ` martin rudalics
  1 sibling, 0 replies; 13+ messages in thread
From: martin rudalics @ 2008-09-19 11:36 UTC (permalink / raw)
  To: Davide Viti; +Cc: 998

 > that is correct: (scroll-bar-mode -1) fixes it

But that's not a very good solution, I presume.  What kind of mouse do
you have?  Are you using Intelli-mouse settings, do you use something
like improved scroll-mode?

Wrt Emacs what is your value of `mouse-wheel-follow-mouse'?  Does it
help to set this to t?  What happens when you set
`mouse-autoselect-window' to t?

martin







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-19 11:23           ` Davide Viti
  2008-09-19 11:36             ` martin rudalics
@ 2008-09-24  9:35             ` martin rudalics
  2008-09-29 13:26               ` Davide Viti
  1 sibling, 1 reply; 13+ messages in thread
From: martin rudalics @ 2008-09-24  9:35 UTC (permalink / raw)
  To: Davide Viti; +Cc: 998

I've been able to reproduce the bug by clicking the small dart above the
scrollbar of a right window and subsequently scrolling the mouse-wheel.
In that case the `event' argument passed to `scroll-bar-toolkit-scroll'
invariantly names the left (sometimes the minibuffer) window.  When I
sample the mouse explicitly the bug doesn't occur.  Davide, could you
try to append the code below to your .emacs and see whether it makes the
bug go away?

Thanks, martin.


(defun scroll-bar-toolkit-scroll (event)
   (interactive "e")
   (let* ((end-position (event-end event))
	 (mouse-position (mouse-position))
	 (window
	  (condition-case nil
	      (window-at (cadr mouse-position) (cddr mouse-position)
			 (car mouse-position))
	    (error (nth 0 end-position))))
	 (part (nth 4 end-position))
	 before-scroll)
     (unless (eq part 'end-scroll)
       (with-selected-window window
	(setq before-scroll (or point-before-scroll (point)))
	(cond
	 ((eq part 'above-handle)
	  (scroll-up '-))
	 ((eq part 'below-handle)
	  (scroll-up nil))
	 ((eq part 'ratio)
	  (let* ((portion-whole (nth 2 end-position))
		 (lines (scroll-bar-scale portion-whole
					  (1- (window-height)))))
	    (scroll-up (cond ((not (zerop lines)) lines)
			     ((< (car portion-whole) 0) -1)
			     (t 1)))))
	 ((eq part 'up)
	  (scroll-up -1))
	 ((eq part 'down)
	  (scroll-up 1))
	 ((eq part 'top)
	  (set-window-start window (point-min)))
	 ((eq part 'bottom)
	  (goto-char (point-max))
	  (recenter))
	 ((eq part 'handle)
	  (scroll-bar-drag-1 event))))
       (sit-for 0)
       (with-current-buffer (window-buffer window)
	(setq point-before-scroll before-scroll)))))







^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-24  9:35             ` martin rudalics
@ 2008-09-29 13:26               ` Davide Viti
  2008-09-30  8:58                 ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Davide Viti @ 2008-09-29 13:26 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998

On Wed, Sep 24, 2008 at 11:35:21AM +0200, martin rudalics wrote:
> I've been able to reproduce the bug by clicking the small dart above the
> scrollbar of a right window and subsequently scrolling the mouse-wheel.
> In that case the `event' argument passed to `scroll-bar-toolkit-scroll'
> invariantly names the left (sometimes the minibuffer) window.  When I
> sample the mouse explicitly the bug doesn't occur.  Davide, could you
> try to append the code below to your .emacs and see whether it makes the
> bug go away?

it does fix the problem!
thanx alot,

Davide






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-29 13:26               ` Davide Viti
@ 2008-09-30  8:58                 ` martin rudalics
  2008-09-30 14:20                   ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2008-09-30  8:58 UTC (permalink / raw)
  To: 998; +Cc: Davide Viti

[-- Attachment #1: Type: text/plain, Size: 98 bytes --]

 > it does fix the problem!

OK.  So I could install the attached patch.  Any objections?

martin

[-- Attachment #2: 998.diff --]
[-- Type: text/plain, Size: 3618 bytes --]

*** scroll-bar.el.~1.59.~	2008-05-06 09:57:49.000000000 +0200
--- scroll-bar.el	2008-09-30 08:56:36.312500000 +0200
***************
*** 295,300 ****
--- 295,311 ----
  
  \f
  ;;; Tookit scroll bars.
+ (defcustom scroll-bar-resample-mouse-position nil
+     "Non-nil means re-sample mouse position when scrolling.
+ When your mouse-wheel scrolls the wrong window, setting this to
+ non-nil might help.  The mouse cursor must be within the window
+ you want to scroll in order for this to take effect.
+ 
+ This option works for toolkit scrollbars only."
+     :type 'boolean
+     :group 'frames
+     :group 'mouse
+     :version "23.1")
  
  (defun scroll-bar-toolkit-scroll (event)
    (interactive "e")
***************
*** 302,341 ****
  	 (window (nth 0 end-position))
  	 (part (nth 4 end-position))
  	 before-scroll)
!     (cond ((eq part 'end-scroll))
! 	  (t
! 	   (with-current-buffer (window-buffer window)
! 	     (setq before-scroll point-before-scroll))
! 	   (save-selected-window
! 	     (select-window window)
! 	     (setq before-scroll (or before-scroll (point)))
! 	     (cond ((eq part 'above-handle)
! 		    (scroll-up '-))
! 		   ((eq part 'below-handle)
! 		    (scroll-up nil))
! 		   ((eq part 'ratio)
! 		    (let* ((portion-whole (nth 2 end-position))
! 			   (lines (scroll-bar-scale portion-whole
! 						    (1- (window-height)))))
! 		      (scroll-up (cond ((not (zerop lines)) lines)
! 				       ((< (car portion-whole) 0) -1)
! 				       (t 1)))))
! 		   ((eq part 'up)
! 		    (scroll-up -1))
! 		   ((eq part 'down)
! 		    (scroll-up 1))
! 		   ((eq part 'top)
! 		    (set-window-start window (point-min)))
! 		   ((eq part 'bottom)
! 		    (goto-char (point-max))
! 		    (recenter))
! 		   ((eq part 'handle)
! 		    (scroll-bar-drag-1 event))))
! 	   (sit-for 0)
! 	   (with-current-buffer (window-buffer window)
! 	     (setq point-before-scroll before-scroll))))))
! 
! 
  \f
  ;;;; Bindings.
  
--- 313,361 ----
  	 (window (nth 0 end-position))
  	 (part (nth 4 end-position))
  	 before-scroll)
!     (when scroll-bar-resample-mouse-position
!       ;; With some mouse drivers the window reported in EVENT might not
!       ;; be valid, see Bug#998.  Here we re-sample the mouse position in
!       ;; the hope to get a more suitable window.
!       (condition-case nil
! 	  (let* ((mouse-position (mouse-position))
! 		 (mouse-window
! 		  (window-at (cadr mouse-position)
! 			     (cddr mouse-position)
! 			     (car mouse-position))))
! 	    (when (window-live-p mouse-window)
! 	      (setq window mouse-window)))
! 	(error nil)))
! 
!     (unless (eq part 'end-scroll)
!       (with-selected-window window
! 	(setq before-scroll (or point-before-scroll (point)))
! 	(cond
! 	 ((eq part 'above-handle)
! 	  (scroll-up '-))
! 	 ((eq part 'below-handle)
! 	  (scroll-up nil))
! 	 ((eq part 'ratio)
! 	  (let* ((portion-whole (nth 2 end-position))
! 		 (lines (scroll-bar-scale portion-whole
! 					  (1- (window-height)))))
! 	    (scroll-up (cond ((not (zerop lines)) lines)
! 			     ((< (car portion-whole) 0) -1)
! 			     (t 1)))))
! 	 ((eq part 'up)
! 	  (scroll-up -1))
! 	 ((eq part 'down)
! 	  (scroll-up 1))
! 	 ((eq part 'top)
! 	  (set-window-start window (point-min)))
! 	 ((eq part 'bottom)
! 	  (goto-char (point-max))
! 	  (recenter))
! 	 ((eq part 'handle)
! 	  (scroll-bar-drag-1 event))))
!       (sit-for 0)
!       (with-current-buffer (window-buffer window)
! 	(setq point-before-scroll before-scroll)))))
  \f
  ;;;; Bindings.
  

^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-30  8:58                 ` martin rudalics
@ 2008-09-30 14:20                   ` Stefan Monnier
  2008-09-30 14:33                     ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Stefan Monnier @ 2008-09-30 14:20 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998, Davide Viti

>> it does fix the problem!
> OK.  So I could install the attached patch.  Any objections?

Doesn't look too terrible, but I'd first want to understand why we're
only seeing this now.  Shouldn't Emacs-22 already have suffered from
that same problem?


        Stefan






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-30 14:20                   ` Stefan Monnier
@ 2008-09-30 14:33                     ` martin rudalics
  2008-09-30 16:01                       ` Stefan Monnier
  0 siblings, 1 reply; 13+ messages in thread
From: martin rudalics @ 2008-09-30 14:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 998, Davide Viti

 > Doesn't look too terrible, but I'd first want to understand why we're
 > only seeing this now.  Shouldn't Emacs-22 already have suffered from
 > that same problem?

I think so.  IIRC the stereotypical answer to this was something like
"get yourself another mouse-driver, another mouse, ...".

martin, who didn't try to reinvent the mouse-wheel.






^ permalink raw reply	[flat|nested] 13+ messages in thread

* bug#998: after split-window-horizontally scroll works only on first window
  2008-09-30 14:33                     ` martin rudalics
@ 2008-09-30 16:01                       ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 2008-09-30 16:01 UTC (permalink / raw)
  To: martin rudalics; +Cc: 998, Davide Viti

>> Doesn't look too terrible, but I'd first want to understand why we're
>> only seeing this now.  Shouldn't Emacs-22 already have suffered from
>> that same problem?

> I think so.  IIRC the stereotypical answer to this was something like
> "get yourself another mouse-driver, another mouse, ...".

Yes, that sounds like a better fix than your workaround,


        Stefan






^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-09-30 16:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-18 13:44 bug#998: after split-window-horizontally scroll works only on first window Davide Viti
     [not found] ` <48D29A54.2050605@gmx.at>
2008-09-19  6:50   ` Davide Viti
2008-09-19  7:01     ` martin rudalics
2008-09-19  7:35       ` Davide Viti
2008-09-19  8:42         ` martin rudalics
2008-09-19 11:23           ` Davide Viti
2008-09-19 11:36             ` martin rudalics
2008-09-24  9:35             ` martin rudalics
2008-09-29 13:26               ` Davide Viti
2008-09-30  8:58                 ` martin rudalics
2008-09-30 14:20                   ` Stefan Monnier
2008-09-30 14:33                     ` martin rudalics
2008-09-30 16:01                       ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).