magiblot / tvision

A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Other
2.04k stars 151 forks source link

Mouse wheel not working on ubuntu 18.04 #29

Closed mingodad closed 3 years ago

mingodad commented 3 years ago

Hello ! Compiling on my machine with lubuntu 18.04 the mouse click works but not the mouse wheel, see the cmake output bellow:

cmake .
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Library output: xxx/tvision/lib
-- Binary output : xxx/tvision/bin
-- Install path  : /usr/local
-- Build Examples: ON
-- Build w/GPM   : ON
-- gpm library requested
-- gpm library found
-- Configuring done
-- Generating done
-- Build files have been written to: xxx/tvision

And here is tvedit link parameters:

/usr/bin/c++     CMakeFiles/tvedit.dir/examples/tvedit/tvedit1.cpp.o CMakeFiles/tvedit.dir/examples/tvedit/tvedit2.cpp.o CMakeFiles/tvedit.dir/examples/tvedit/tvedit3.cpp.o  -o bin/tvedit  lib/libtvision.a -lncursesw /usr/lib/x86_64-linux-gnu/libgpm.so

Cheers !

magiblot commented 3 years ago

¡Hola Domingo! Gracias por comentar.

Could it be that the version of Ncurses provided by Lubuntu 18.04 is too old?

In source/platform/ncursinp.cpp you can find the following code surrounded by #if:

#if NCURSES_MOUSE_VERSION > 1
        // Mouse wheel support was added in Ncurses v6. Before that, only
        // scroll up would work. It's better not to support wheel scrolling
        // in that case.
        if (mevent.bstate & BUTTON4_PRESSED)
            mouseWheel = mwUp;
        else if (mevent.bstate & BUTTON5_PRESSED)
            mouseWheel = mwDown;
#endif

Try to remove the #if and #endif and then compile again. If you get a compilation error, that means Ncurses is indeed too old.

Unfortunately, upgrading packages in LTS distributions can become a painful process. I don't use Ubuntu regularly, so I can't provide you with specific instructions on how to upgrade Ncurses.

¡Saludos!

magiblot commented 3 years ago

@asanoic, for the mouse to work from a tty console, you have to start the GPM service. I do it like this:

systemctl start gpm.service

And to have it started automatically on every session:

systemctl enable gpm.service

mingodad commented 3 years ago

Hello magiblot ! Thank you for reply ! Indeed when switching to full tty (Ctr-Alt-F1) and enabling gpm.service the mouse wheel works, but inside an xterminal it doesn't.

magiblot commented 3 years ago

Yes, mouse support on the tty is independent from Ncurses. What I said about Ncurses only applies to terminal emulators, which is your use case.

mingodad commented 3 years ago

I'm looking at https://github.com/orbitalquark/textadept and it uses http://www.leonerd.org.uk/code/libtermkey/ and it has mouse wheel working in xterm.

magiblot commented 3 years ago

Yes. Lack of (complete) mouse wheel is a limitation of Ncurses v5 because of ABI compatibility. Applications which do not rely on Ncurses (such as the one you mention) do not suffer from this limitation.

magiblot commented 3 years ago

Hi Domingo. The only way to work around this issue without a system upgrade is to implement an interface for a library other than Ncurses, and I'm not very interested in doing this.

I don't like to tell users to change their working environment, but this is all I can do for now. According to https://bugs.launchpad.net/ubuntu/+source/htop/+bug/1730143/comments/4, the Ncurses ABI was upgraded to v6 in Ubuntu 18.10 (Cosmic Cuttlefish). Maybe you can afford to upgrade your system to that version (or preferably a newer one).

Saludos.