Subject: Re: bug#57995: <wheel-right> with pixel-scroll-precision-mode

From: Tak Kunihiro <[email-masked]>
Date: Mon, 07 Nov 2022 18:34:41 +0900

I set a break point to line 7363 and run Emacs.  Event <wheel-left>
stops at line 7373.  I'm not familiar with neither lldb and gdb.  Please
tell me the next step specifically.

TIA

$ ./configure CFLAGS="-g -O0"
$ make
$ make install
$ lldb nextstep/Emacs.app/Contents/MacOS/Emacs
(lldb) br set --file src/nsterm.m --line 7363
(lldb) run -Q
M-: (setq mouse-wheel-tilt-scroll t)
M-: (pixel-scroll-precision-mode 1)
<wheel-right>
(lldb)
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x000000010031f749 Emacs`-[EmacsView mouseDown:](self=0x0000000103023790, _cmd="mouseDown:", theEvent=0x0000600003706b80) at nsterm.m:7373:5
   7350 #if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
   7351        {
   7352          CGFloat delta = [theEvent deltaY];
   7353          /* Mac notebooks send wheel events with delta equal to 0
   7354	     when trackpad scrolling.  */
   7355          if (delta == 0)
   7356            {
   7357              delta = [theEvent deltaX];
   7358              if (delta == 0)
   7359                {
   7360                  NSTRACE_MSG ("deltaIsZero");
   7361                  return;
   7362                }
   7363              emacs_event->kind = HORIZ_WHEEL_EVENT;
   7364            }
   7365          else
   7366            emacs_event->kind = WHEEL_EVENT;
   7367
   7368          emacs_event->code = 0;
   7369          emacs_event->modifiers = EV_MODIFIERS (theEvent) |
   7370             ((delta > 0) ? up_modifier : down_modifier);
   7371         }
   7372 #endif
-> 7373     }
   7374   else
   7375     {
   7376       Lisp_Object tab_bar_arg = Qnil;
Target 0: (Emacs) stopped.

> I do not know how to call debugger.
> It will take a while to respond!
>
>>>>> With pixel-scroll-precision-mode, <wheel-right> and <wheel-left> does
>>>>> not work. Is this expected behavior?
>>>>> 
>>>>> 1. emacs -Q
>>>>> 2. (setq mouse-wheel-tilt-scroll t)
>>>>> 3. <wheel-right> or <wheel-left> scrolls buffer.
>>>>> 4. (pixel-scroll-precision-mode 1)
>>>>> 5. Then <wheel-right> or <wheel-left> does not scroll buffer.
>>>> 
>>>> Thanks for reporting this bug.  Could you please include the output from
>>>> `report-emacs-bug', as this is likely a system-specific issue?
>>>
>>> No buffer scroll with <wheel-right> and <wheel-left> by mouse with Mac.
>>> I confirm that I can scroll buffer with swipe-right and swipe-left by
>>> touchpad with MacBook.
>> 
>> Right, thanks.  Could you please run Emacs underneath a debugger (GDB or
>> LLDB), and see whether or not this code around line 7342 of nsterm.m is
>> ever hit:
>> 
>>           CGFloat delta = [theEvent deltaY];
>>           /* Mac notebooks send wheel events with delta equal to 0
>> 	     when trackpad scrolling.  */
>>           if (delta == 0)
>>             {
>>               delta = [theEvent deltaX];
>>               if (delta == 0)
>>                 {
>>                   NSTRACE_MSG ("deltaIsZero");
>>                   return;
>>                 }
>>               emacs_event->kind = HORIZ_WHEEL_EVENT; <================
>>             }
>>           else
>>             emacs_event->kind = WHEEL_EVENT;
>> 
>>           emacs_event->code = 0;
>>           emacs_event->modifiers = EV_MODIFIERS (theEvent) |
>>             ((delta > 0) ? up_modifier : down_modifier);
>> 
>> when you try to scroll left or right with your mouse while
>> pixel-scroll-precision-mode is enabled?