Recent

Author Topic: mouse extra buttons supported in Linux Lazarus 1.5 - .xbindkeysrc xte trick  (Read 9237 times)

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
goal: use extra mouse buttons  b:8 and b:9 in Lazarus 1.5 latest via FPCup

this was now fixed in LCL for gtk2 targets. extra buttons are handled OK in any gtk2 target in Linux-64bit, IMHO, i.e. in any app compiled with Lazarus for a gtk2 64bit target.


reedit:
it works in today's revision.
drewski made a cool patch  ;)

 
see http://wiki.lazarus.freepascal.org/IDE_Window:_EditorMouseOptionsAdvanced#Current_Limitations

 Current Limitations
    Extra Mouse Buttons (Button 4 and 5) work in Windows only   // updated by now.
    OS dependent: some clicks dont get through to Lazarus


but you'll still find a trick in this post:
in KDE, you can indeed use the extra mouse buttons directly,
or even trick some KDE apps into believing they received keypresses of your choosing by mapping those extra buttons.

mind you:  HOMEdir/.xbindkeysrc is a simple config textfile. After reedit: killall xbindkeys followed by xbindkeys will put it in effect straight away.

############################################################
the original thread was written when xtra mouse buttn did not work - mind you


Lazarus / tools / options / mouse /  "mouse extra 1"  or 2  has no effect   : no action is ever executed when extra mouse buttons are hit


using    xte 'key F12'     keypress-faking      in  ~/.xbindkeysrc     like

#works ! mouse-extra-uparrow --> xterm = ALT-F12
"xterm"
   m:0x8 + c:96
   Alt + F12

# mouse-extra-uparrow ALT-F12
"xte 'keydown Alt_L' 'key F12' 'keyup Alt_L'"
   b:9


this works in Kubuntu Desktop. In Lazarus, only a "real key" ALT-F12 gets executed, but not the "fake mouse-driven" ALT-F12 surrogate, which works otherwise in KDE.  ;)

So I can't find a way to use the extra mouse buttons in Lazarus - unless I start debugging the IDE to fix it.

Any pointer, maybe?  :)
« Last Edit: February 14, 2015, 01:40:09 am by mai »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Then it is probably a bug in the lcl/gtk interface.

Those setting work fine on windows.

It seems your system maps them to a key? Is that normal Linux behaviour?

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
how to use mouse extra 1 in Lazarus ?
« Reply #2 on: February 09, 2015, 04:02:37 pm »
I was unsuccessful with and without the xbindkeys remapping.

By mapping an extra mouse button to a key like ALT-F12 I hoped to achieve something more, but I cannot use the "Mouse Extra 1" with or without remapping controlled by the ~/.xbindkeysrc file.

mouse 1, 2 and wheel work fine of course in Lazarus.

Lazarus handles Mousbutton 1 OK, but not the MOUSE-EXTRA-BUTTONS accessible via Lazarus-Options.
KDE desktop is fine with those little tricks of remapping mouse-button to keypress.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
I dont think the remapping to key is supported.

But if you remap, to alt-F12 (making sure your window manager does not use this) and then assign something to that key in Lazarus, what happens?

As for the none remapped,  most actions happen on mouse up, try to go to the advanced settings, find the action on the extra button, double click it and change it to mouse down. Maybe just one of the events is missing.


As for the none remapped, I would report it on the bug tracker. It is meant to work.
Include all details about your system, including gtk version.

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
if you remap, to alt-F12 (making sure your window manager does not use this) and then assign something to that key in Lazarus, what happens?

As for the none remapped,  most actions happen on mouse up, try to go to the advanced settings, find the action on the extra button, double click it and change it to mouse down. Maybe just one of the events is missing.

thanks. I followed
http://wiki.lazarus.freepascal.org/IDE_Window:_EditorMouseOptionsAdvanced#The_Priority

and set up  middle-button , Extra 1 , Extra 2 identically to MARK FULL LINE and no additional funtion. rechecked in MOUSE and ADVANCED option-screen, restarted IDE.
MIDDLE works as expected, but extra1 and 2 do nothing.

I did
killall xbindkeys
to switch off my custom 3 remappings on KDE level. Either way still EXTRA1,2 are dead.

so: MIDDLE-MOUSE works as expected in Lazarus/ Tools / options, but in Kubuntu-64 the extra mouse buttons never execute anything, even when set to "ON UP EVENT" like you suggested.

It seems, Lazarus does not handle the b:8 and b:9 extra mouse events either way nor does it handle those "simulated keypresses via xte".


bugtracker, here I come ...  :-*
« Last Edit: February 09, 2015, 05:08:30 pm by mai »

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
I reedited post #1

extra mouse buttons work in Windows only, currently.

let's hope and wait or look into it ourselves.

had been nice, had the xte trick worked. thanks for your attention.  :-*


only question left: when mapping a mouse button in Lazarus/tools/options/mouse/advanced there is a numeric setting "OPT."  which seems undocumented to me.
« Last Edit: February 09, 2015, 08:40:46 pm by mai »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
The entry on the wiki was iirc only describing the current state of implementation. If so, then its still worth a feature request on the wiki.
I see if I can find out more. If I do not add to this post in the next week then you can still add a issue on mantis.

"opt"
You are right it is missing docs.
It applies to some settings only

Wheel scroll
- speed lines => amount of lines
- other speed => percent

there may be other, I need to dig through the sources for that.

In synedit.pp
 TCustomSynEdit.DoHandleMouseAction
Other units may also have methods named similar.

search for "Option2"  (in the method in SynEdit: "AnAction.Option2")

In SynEdit.pp it applies only to mouse wheel scroll. But I did not search the gutter mouse handler.



mai

  • Full Member
  • ***
  • Posts: 133
  • truther
improved sample .xbindkeysrc text file
« Reply #7 on: February 09, 2015, 09:33:05 pm »

Code: [Select]
##############################
# X bind keys configuration  #      ~/.xbindkeysrc                           
##############################
#
# Version: 0.1.3bis
#
# A list of keys is in /usr/include/X11/keysym.h  e.g.  define XK_XKB_KEYS  and in
# /usr/include/X11/keysymdef.h                    e.g.  define XK_F12       0xffc9
# The XK_  prefix used there is not needed here.   
#
# (incomplete) list of modifiers                 
#   Control, Shift,  Mod1 (Alt), Mod2 (NumLock),
#   Mod3 (CapsLock), Mod4,       Mod5 (Scroll)          // WTF is "Mod4" then ?
#


# use  xev  and   xbindkeys -k   to find keycodes.
# use  xte 'key F12'             to fake keypresses or send "fake keypresses" after press of extra-mouse-button etc.


# 4 xbindkeys commands:

# xbindkeys-config     GUI
# xbindkeys_show       GUI
# xbindkeys_autostart  CLI
# xbindkeys            CLI

# live reset :   killall xbindkeys



# to specify a key use 'xev' and set the
# keycode with c:nnn or the modifier with m:nnn where nnn is
# the keycode or the state returned by xev
#
# This file is created by xbindkey_config
# The structure is :
# # Remark
# "command"
# m:xxx + c:xxx   //   or b:9   end   
# Shift+...       //   b:9      case then optional




#keystate_numlock = enable
#keystate_scrolllock = enable
#keystate_capslock = enable



# key win difficult to use in KDE
#"xbindkeys_show"
#     m:0x10 + c:117
#    Mod2 + Menu

# default stuff
#"xbindkeys_config"
#    m:0x18 + c:9
#    Alt+Mod2 + Escape

#Ctrl-Shift-x
#"xterm"
#    m:0x15 + c:53
#    Control+Shift+Mod2 + x

# butn 8 & 9 on ms trackball
#"xterm"
#    b:9
#    button 9


# real xtra mouse button b:8 -- pascal uses b:5?   
#"xte 'mouseclick 2'"
#  b:8
# don't work


#"xterm"
#  b:9
# works


# works ! mouse-extra-uparrow --> xterm = altF12
"xterm"
    m:0x8 + c:96
    Alt + F12

# mouse-extra1?-down ALT-F11 to Lazarus?
"xte 'keydown Alt_L' 'key F11' 'keyup Alt_L'"
   b:8

# mouse-extra2?-up ALT-F12
"xte 'keydown Alt_L' 'key F12' 'keyup Alt_L'"
   b:9
« Last Edit: February 13, 2015, 01:06:26 am by mai »

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
mouse extra buttons unsupported in Linux Lazarus 1.5
« Reply #8 on: February 10, 2015, 09:30:11 am »
"opt"
You are right it is missing docs.
I added that to wiki - now it's indeed documented.

I am looking into the IDE sources now.

turns out, no GTK app recognizes extra-mousbuttn in kubuntu 64. itz not specific to  ide. trying to receive a extra-mb event now in a mini app.
« Last Edit: February 10, 2015, 05:53:05 pm by mai »

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
In synedit.pp
 TCustomSynEdit.DoHandleMouseAction

well I narrowed it to   Gtk2WSStdCtrls.pp

function Gtk2WSButtonPressedEvent(widget: PGtkWidget; {%H-}event: pgdkEventButton; {%H-}data: gPointer): GBoolean; cdecl;

where extra-mouse-buttons are still received (just breakpoint there) but get lost somewhere down the line.

event decodes correctly button 8 and 9!    8)

to debug just make a naked frame / TForm1 with on-mouse-up-event , gtk2 target, KDE 64 bit Linux - and killall >:D  xbindkeys ( esp. with b:8 or b:9 usage - which do preempt the above breakpoint  )
« Last Edit: February 13, 2015, 01:32:55 am by mai »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Please but that on the bug tracker, so our gtk maintainer can pick it up.

Thanks

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
well extra mouse buttons work straight away in fpGUI programs run on the same Linux KDE.  :)

does anyone know whether the C sources of gtk2 are fully prepared for extra1 & 2 mousebuttons? maybe it breaks on the C side of things.  :o
but if fpGUI can do it, so should Lazarus, no?
« Last Edit: February 13, 2015, 01:31:50 am by mai »

mai

  • Full Member
  • ***
  • Posts: 133
  • truther
Please but that on the bug tracker, so our gtk maintainer can pick it up.

it was solved by drewski already.wow  :)

 

TinyPortal © 2005-2018