Menu

#226 Special Key Modifiers (Shift, Ctrl..) aren't passed correctly on X11

open
nobody
None
5
2015-06-11
2015-06-11
Lukas Gaal
No

After registering a callback with glutMotionFunc() I noticed that special key modifiers as Shift, Control and so on aren't generated at all on X11.

Solution: I solved this problem with adding some code into fg_xinput_x11.c file, fgHandleExtensionEvents function, line 251.
I thing that manually generated MotionNotifyEvent isn't complete and so I added "std_ev.xmotion.state |= event->mods.base" line which solved my problem;

Discussion

  • John Tsiombikas

    John Tsiombikas - 2015-06-11

    The wording on the original GLUT documentation is slightly vague, but I think the intention is for modifiers to be flagged only on Keyboard, KeyboardUp, Special, SpecialUp, and Mouse callbacks. Not motion callbacks.

    I'll fire up my silicon graphics doorstop, to see what the original behaviour was.

     
    • Diederick C. Niehorster

      This issue has come up before (I think, didn't feel like reading the
      whole thread):
      http://sourceforge.net/p/freeglut/mailman/message/20281575/

      But previous people have agreed with you John, and with good reason:

      On Wed, 2008-09-10 at 07:55 -0500, Steve Baker wrote:

      the PASSIVE motion callback.

      I don't think you can call glutGetModifiers there either. The "passive
      motion"
      callback doesn't involve a key up/down event.

      You have to remember the state of the modifiers when the mouse button
      goes down.
      In X11, if you start a "shift-drag" or "ctrl-drag" mouse operation and
      release the
      shift or ctrl key partway through the drag, the operation will continue
      as if you
      held the key down. The kind of click you have is only knowable at the
      onset or
      the end of the click/drag/release operation.

      One of those ikky little things sent to drive cross-platform programmers
      nuts!

      -- Steve.

      John, I also came across this:
      https://bugzilla.redhat.com/show_bug.cgi?id=971577
      Not sure if it is still relevant (and in the end it didn't necessarily
      seem to be a freeglut problem)

      Note, however, that on windows you can call glutGetModifiers during a
      motion or passivemotion callback and get what modifiers are down at
      the time the callback was generated (line 1146 of fg_main_mswin.c).
      That doesn't avoid the problem identified by Steve though, and perhaps
      we should pull behavior in line between windows and X11... That means:
      - in all cases update/improve the docs
      - either remove this functionality from windows, or add it to X11.
      - first would be a breaking change (docs should explain Steve's logic)
      - second would allow users to shoot themselves in the foot a bit, if
      they're not careful. Steve's logic also needs to be explained, but
      with different emphasis.
      I vote for adding to X11 (it doesn't break compatibility for programs
      that don't expect this to be possible).

      All the best,
      Dee

       

Log in to post a comment.

MongoDB Logo MongoDB