neovim-qt icon indicating copy to clipboard operation
neovim-qt copied to clipboard

Scroll direction is reversed on MacOS.

Open AllenDang opened this issue 4 years ago • 13 comments

In recent commit, I noticed that scroll direction with wire mouse wheel is reversed on MacOS 10.15.4 with Qt 5.14.2.

AllenDang avatar May 19 '20 09:05 AllenDang

I have the same problem

gpncarl avatar Oct 16 '20 10:10 gpncarl

Hi @GPN211314 cal you tell us which version you are using?

From a terminal you can get the nvim-qt version using the command line argument nvim-qt --version. Can you share the output?

Also does this happen with both the touch pad and mouse?

equalsraf avatar Oct 17 '20 15:10 equalsraf

Hi @GPN211314 cal you tell us which version you are using?

From a terminal you can get the nvim-qt version using the command line argument nvim-qt --version. Can you share the output?

Also does this happen with both the touch pad and mouse?

NVIM-QT v0.2.17.9999 Build type: Release Compilation: -Wall -Wextra -Wno-unused-parameter -std=c++11 -Wfatal-errors Qt Version: 5.15.0

MacOS 10.15.7

I only use the touch pad No matter I install it with brew , nix or compiling it myself, I encountered the same problem (sorry for my poor english)

gpncarl avatar Oct 17 '20 17:10 gpncarl

I noticed this as well. I have both a conventional USB mouse and an external Apple trackpad and I observe the following:

Scroll wheel down: content moves up. Scroll wheel up: content moves down.

Unlike other applications, this is regardless of the "Scroll direction" setting under System Preferences > Mouse.

Trackpad up (2-finger): content moves left. Trackpad right: content moves left. Trackpad down: content moves diagonally up and left. Trackpad left: content moves up.

Don't know what to say about that one. It's almost as if someone's using the wrong set of constants that just happen to overlap with the correct values.

NVIM-QT v0.2.16.1
Build type: Release
Compilation: -Wall -Wextra -Wno-unused-parameter -std=c++11 -Wfatal-errors
Qt Version: 5.15.1
Environment: 
  nvim: nvim
  args: --cmd let &rtp.=',/Users/psagers/ext/neovim-qt/build/bin/nvim-qt.app/Contents/MacOS/../Resources/runtime' --cmd set termguicolors
  runtime: /Users/psagers/ext/neovim-qt/build/bin/nvim-qt.app/Contents/MacOS/../Resources/runtime

NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/config -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/src -I/usr/local/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/src/nvim/auto -I/tmp/neovim-20200808-89283-1us0ytm/neovim-0.4.4/build/include
Compiled by brew@Catalina

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.4.4/share/nvim"

Run :checkhealth for more info

psagers avatar Oct 24 '20 19:10 psagers

Do you have the ability to build from source?

Could you apply the following patch, and report back with the output?

--- a/src/gui/shell.cpp Thu Oct 15 18:01:11 2020 +0200
+++ b/src/gui/shell.cpp Sun Oct 25 13:27:20 2020 -0400
@@ -1373,6 +1373,9 @@
                        .arg(Input::GetModifierPrefix(ev->modifiers()), (scroll_delta.x() > 0) ? "Left" : "Right")
                        .arg(pos.x()).arg(pos.y());
        }
+       qDebug() << "QWheelEvent";
+       qDebug() << "  " << ev;
+       qDebug() << "  " << inp;
        m_nvim->api0()->vim_input(inp.toLatin1());
 }

You will need to build Debug for these messages to appear: -DCMAKE_BUILD_TYPE=Debug.

When you scroll, you should see lots of output like the following :

QWheelEvent
   QWheelEvent(Qt::NoScrollPhase, pixelDelta=QPoint(0,0), angleDelta=QPoint(0,-8))
   "<ScrollWheelDown><29,35>"

jgehrig avatar Oct 25 '20 17:10 jgehrig

I also see some issues in master around scroll event position:

QWheelEvent
   QWheelEvent(Qt::NoScrollPhase, pixelDelta=QPoint(0,0), angleDelta=QPoint(0,80))
   "<ScrollWheelUp><                          35.2222,%4>"

It looks like Qt has changed to floating point QWheelEvents and I overlooked this in some recent changes. We should also fix the .arg and floating point issues.

My best guess for the direction issues is bad logic for direction_x and direction_y logic on MacOS.

Then we can add test coverage so scrolling doesn't break again in the future :)

jgehrig avatar Oct 25 '20 17:10 jgehrig

I was able to get debug output, but I also updated to master and the direction is no longer chaotic. It still doesn't respect the system setting, but it's intelligible.

It also doesn't seem to scroll during the gesture. If I flick with two fingers, it will sluggishly catch up. If I drag slowly (which is more typical), it never moves.

Here's some representative output, in case it's useful. Batches of events appear after the end of a quick flick gesture. Longer, continuous gestures produce no output.

Thanks

QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(0,-39), angleDelta=QPoint(0,-78))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-1,-59), angleDelta=QPoint(-2,-118))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(0,-80), angleDelta=QPoint(0,-160))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-312), angleDelta=QPoint(0,-624))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-459), angleDelta=QPoint(0,-918))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-347), angleDelta=QPoint(0,-694))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-245), angleDelta=QPoint(0,-490))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-137), angleDelta=QPoint(0,-274))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-88), angleDelta=QPoint(0,-176))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-72), angleDelta=QPoint(0,-144))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-46), angleDelta=QPoint(0,-92))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,-31), angleDelta=QPoint(0,-62))
   "<ScrollWheelUp><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,33), angleDelta=QPoint(0,66))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,174), angleDelta=QPoint(0,348))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,126), angleDelta=QPoint(0,252))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,79), angleDelta=QPoint(0,158))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,66), angleDelta=QPoint(0,132))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(0,43), angleDelta=QPoint(0,86))
   "<ScrollWheelDown><                       86.25,%4>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(31,1), angleDelta=QPoint(62,2))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(32,1), angleDelta=QPoint(64,2))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(32,1), angleDelta=QPoint(64,2))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(45,0), angleDelta=QPoint(90,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(60,0), angleDelta=QPoint(120,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(65,0), angleDelta=QPoint(130,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(130,0), angleDelta=QPoint(260,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(60,0), angleDelta=QPoint(120,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(58,0), angleDelta=QPoint(116,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(60,0), angleDelta=QPoint(120,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(56,0), angleDelta=QPoint(112,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(53,0), angleDelta=QPoint(106,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(49,0), angleDelta=QPoint(98,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(45,0), angleDelta=QPoint(90,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(41,0), angleDelta=QPoint(82,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(38,0), angleDelta=QPoint(76,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(35,0), angleDelta=QPoint(70,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(32,0), angleDelta=QPoint(64,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(30,0), angleDelta=QPoint(60,0))
   "<ScrollWheelRight><86.25,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-38,2), angleDelta=QPoint(-76,4))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-40,1), angleDelta=QPoint(-80,2))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-48,-1), angleDelta=QPoint(-96,-2))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-71,-2), angleDelta=QPoint(-142,-4))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollUpdate, pixelDelta=QPoint(-101,0), angleDelta=QPoint(-202,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-124,0), angleDelta=QPoint(-248,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-125,0), angleDelta=QPoint(-250,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-122,0), angleDelta=QPoint(-244,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-117,0), angleDelta=QPoint(-234,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-111,0), angleDelta=QPoint(-222,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-105,0), angleDelta=QPoint(-210,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-194,0), angleDelta=QPoint(-388,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-175,0), angleDelta=QPoint(-350,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-229,0), angleDelta=QPoint(-458,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-66,0), angleDelta=QPoint(-132,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-174,0), angleDelta=QPoint(-348,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-51,0), angleDelta=QPoint(-102,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-130,0), angleDelta=QPoint(-260,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-37,0), angleDelta=QPoint(-74,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-34,0), angleDelta=QPoint(-68,0))
   "<ScrollWheelLeft><86,28.8667>"
QWheelEvent
   QWheelEvent(Qt::ScrollMomentum, pixelDelta=QPoint(-31,0), angleDelta=QPoint(-62,0))
   "<ScrollWheelLeft><86,28.8667>"

psagers avatar Oct 25 '20 21:10 psagers

Let's try to fix this issue.

Can anyone provide me with some more debug output from build #797? (I don't have access to MacOS hardware)

  1. Build the PR above.
  2. Open neovim-qt.
  3. Perform one short scroll in a single direction.
  4. Copy the terminal output from step 3. Add a note which direction you scrolled (up, down, left, right)

A vertical event is most useful. A horizontal event would also be helpful. The buffer doesn't need to actually move/scroll, we are only trying to capture the raw mouse events. Events are sent regardless of the buffer state.

The output should look something like this:

QWheelEvent(Qt::NoScrollPhase, pixelDelta=QPoint(0,0), angleDelta=QPoint(0,-8))
  angleDelta: QPoint(0,-8)
  button: QFlags<Qt::MouseButton>(NoButton)
  globalPosition: QPointF(272,1110)
  inverted: false
  phase: Qt::NoScrollPhase
  pixelDelta: QPoint(0,0)
  position: QPointF(272,1045)
  source: Qt::MouseEventNotSynthesized
  deltasPerStep: 120
  m_scrollDeltaRemainder: QPoint(56,0)
    evString: "<ScrollWheelDown><30,47>"

My goal here is to write test coverage for this scenario. If we can add a test, we can fix the problem and guarantee it continues to work in the future.

Thanks!

jgehrig avatar Nov 30 '20 05:11 jgehrig

Hi! I don't get any test output when running the nvim-qt.app

This is what I did:

> gh pr checkout 797
> mkdir build
> cd build
> cmake -DCMAKE_BUILD_TYPE=Release ..
> make
> cd bin
> open Nvim-qt.app

Mathijs-Bakker avatar Jan 25 '21 23:01 Mathijs-Bakker

@Mathijs-Bakker

Release builds don't have qDebug() output.

You should see the output if you change Line 4: cmake -DCMAKE_BUILD_TYPE=Debug

I assume you see the reversed scrolling behavior? If so, thanks for helping with this!

jgehrig avatar Jan 26 '21 01:01 jgehrig

@jgehrig Confirmed. The debug build has the correct scrolling behavior!

Mathijs-Bakker avatar Jan 26 '21 07:01 Mathijs-Bakker

I have the same problem -- the scroll direction is inverted on MacOs.

$ nvim-qt --version
NVIM-QT v0.2.16.1
Build type: Release
Compilation: -Wall -Wextra -Wno-unused-parameter -std=c++11 -Wfatal-errors
Qt Version: 5.15.2
Environment:
  nvim: nvim
  args: --cmd let &rtp.=',/usr/local/Cellar/neovim-qt/0.2.16.1/nvim-qt.app/Contents/MacOS/../Resources/runtime' --cmd set termguicolors
  runtime: /usr/local/Cellar/neovim-qt/0.2.16.1/nvim-qt.app/Contents/MacOS/../Resources/runtime

NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20210927-21425-quzo0s/neovim-0.5.1/build/config -I/tmp/neovim-20210927-21425-quzo0s/neovim-0.5.1/src -I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20210927-21425-quzo0s/neovim-0.5.1/build/src/nvim/auto -I/tmp/neovim-20210927-21425-quzo0s/neovim-0.5.1/build/include
Compiled by brew@iMac-Pro

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.1/share/nvim"

Run :checkhealth for more info

Is there an option to invert it?

korya avatar Oct 08 '21 23:10 korya

@korya

Is there an option to invert it?

No, there is no option to invert the scrolling.

I cannot reproduce the issue... First we need to understand what is going wrong here.

Are you willing to provide debug info with the steps above? (let me know, and I will update #797)

jgehrig avatar Oct 11 '21 03:10 jgehrig