Wednesday, December 07, 2011

Sad story of the day: Qt and XF86XK_TouchpadToggle

Today I realized Gnome has support for XF86XK_TouchpadToggle, i.e. if you press the key in your keyboard that has the touchpad with an X symbol over it, it toggles the enabled state of the touchpad.

This is very useful if you are like me and attach/detach a mouse various times during the day.

Since as far as I know this is not supported in KDE, this afternoon I decided to write a quick kded module that would listen to XF86XK_TouchpadToggle and call the corresponding XInput2 functions to toggle the state of the touchpad.

Investigating XInput2 was supposed to be the difficult part since it is out of my area of comfort, but at the end it resulted it was not that difficult and the desired effect can be achieved with no more than 10 lines of code.

After getting the correct XInput2 calls I started to build the skeleton of my kded module and when I was going to register the global KAction to listen for XF86XK_TouchpadToggle I realized Qt does not have support for this key, which means I can not use a KAction for that. Sad :-/

This has resulted in my getting diverted from my original goal and writing a patch for Qt5 to support the XF86XK_TouchpadToggle key and two other ones. Sadly this does not solve my immediate itch so I will either live with that itch or try to detect the keypress at the X level, but i'm not sure that's something I want to do :D

Update: I went the X11 way and it was not that painful. I now have some code that works, putting it in a git repo as soon as I get one :-)

10 comments:

  1. This is an old Qt bug. I created a patch to add support for that key some months ago:

    bug #182672

    The fact that Qt redefines Xorg's keycodes make this a forever open bug. There will always be new keycodes and the need to patch Qt to support them.

    ReplyDelete
  2. See why discontinuing kde-qt was a bad idea? Now we're at Nokia's mercy, and since they arbitrarily decided they won't add any features to Qt 4 anymore, we have to wait for Qt 5…

    Of course, distros can patch that stuff in (just like for kdelibs…). Upload your kded4 module and a patch against Qt 4.8 somewhere and announce it on kde-packager.

    ReplyDelete
  3. for the meantime you can use xmodmap to map the key to something that Qt knows, (e.g. F20) and use that one. Its ugly but it works

    ReplyDelete
  4. @Lamarque: My Qt patch is already approved, this Qt Project thing seems to be working :-)

    @Kevin: We are not at Nokia's mercy, Qt Project is "an open thing" so we can just contribute code as well as anyone. It is true that i don't like the contributors agreement much, but for such a small change i can live with it.

    @Anon: No need, i went the full X11 way and got it working :-)

    ReplyDelete
  5. Wy do I need a passwort for Qt Reviewboard? :(

    ReplyDelete
  6. @saLOUT: good question, i guess they don't have an anonymous mode for their review tracker, you can get an account by registering at their bug tracker (https://bugreports.qt.nokia.com) and using that information as your user/password for the review site

    ReplyDelete
  7. > We are not at Nokia's mercy, Qt Project is "an open thing" so we can just contribute code as well as anyone.

    But they don't accept features for Qt 4 anymore. (That said, kdelibs is being just as silly, as you know.)

    ReplyDelete
  8. There used to be a setting to disable the touchpad when any USB mouse is plugged in in System Settings / Input / Touchpad, but it's not there anymore. I guess it's kcm_touchpad that offers it and not syaptiks that openSUSE uses.

    ReplyDelete
  9. well i just tried pressing this key (Fn+F7 on my acer netbook) in Kubuntu 11.10, and it worked out of the box

    ReplyDelete
  10. @Nick: Maybe your laptop does it by hardware (which imho makes sense)

    ReplyDelete