unixwork / xnedit

A fast and classic X11 text editor, based on NEdit, with full unicode support and antialiased text rendering.
Other
83 stars 11 forks source link

Horizontal scroll wheel? Btn6Down Btn7Down? #105

Closed cblc closed 1 year ago

cblc commented 1 year ago

I tried to modify text.c adding a couple translations for Btn6Down/Up and Btn7Down/Up with the hope of getting horizontal scrolling with the Trackpad, but it doesn't compile because they are undefined. I searched about horizontal scrolling with NEdit, and saw several people saying that it doesn't work. This question has an interesting comment pointing to this xdvi doc that says that they had to implement their own translations manager in xdvi for getting the horizontal scroll working.

But maybe you, knowing the NEdit internals much more than me, can have any idea of any possible workaround for getting it working?

cblc commented 1 year ago

My bad: it does compile, it was a wrong semicolon. But it does nothing.

unixwork commented 1 year ago

I think Xt doesn't support specific translations for Btn 6/7 (https://gitlab.freedesktop.org/xorg/lib/libxt/-/blob/master/src/TMparse.c#L250).

Maybe using BtnDown and checking the button number in XButtonEvent works. I can't test it, I don't have btn 6/7.

cblc commented 1 year ago

In the OpenGL views that I create in Motif (with the GLw widget) in my apps, I'm able to detect both vertical and horizontal panning in the input callback, when event->type is equal to ButtonPress and when event->xbutton.button is equal to Button4, Button5, Button5+1, and Button5+2 (I don't use Button6/7, just add 1 and 2 to Button5, I don't remember if it's because it's not defined, or because in some X11 versions it's not available).

Is there any input callback for the TextArea, in which I could try this? Or would it interfere with the translations? (I never used translations -or I don't remember- so that's why I ask)

unixwork commented 1 year ago

For testing, you can add something like "<BtnDown>,<BtnUp>: test()\n" at the beginning of the translation table.

unixwork commented 1 year ago

Another way is using XtAddEventHandler. I tested it with a lapdop touchpad and I can detect button 6/7 events. Looks like a very useful feature, I will add this to XNEdit.

cblc commented 1 year ago

That will be great, thank you!

unixwork commented 1 year ago

Horizontal scrolling is now implemented. Can you test if it works correctly on your system?

cblc commented 1 year ago

Thank you very much!! I'll build it now and I'll report back!!

cblc commented 1 year ago

I con confirm it works great with the Magic Trackpad on MacOS. What a great addition!! Thanks a lot for implementing it!!!