[haiku-bugs] Re: [Haiku] #2053: returning B_SKIP_MESSAGE in my filter let capslocks get through anyway

  • From: "leavengood" <trac@xxxxxxxxxxxx>
  • Date: Thu, 02 Aug 2012 01:55:43 -0000

#2053: returning B_SKIP_MESSAGE in my filter let capslocks get through anyway
------------------------------------+---------------------------
   Reporter:  stpere                |      Owner:  leavengood
       Type:  bug                   |     Status:  in-progress
   Priority:  normal                |  Milestone:  R1
  Component:  Servers/input_server  |    Version:  R1/pre-alpha1
 Resolution:                        |   Keywords:
 Blocked By:                        |   Blocking:
Has a Patch:  0                     |   Platform:  All
------------------------------------+---------------------------

Comment (by leavengood):

 Continuing my work on old tickets, I've looked into this more. As korli
 says, the keyboard device manages the modifiers within itself and also
 sends the B_MODIFIERS_CHANGED message which gets forwarded to filters by
 the input_server. But by the time the filters get the message, it is too
 late to stop the modifiers from being changed. Also I think in general Be
 did not design this as the sort of message that can be stopped, it is just
 informative.

 In addition, the key down message which would turn on caps lock (or other
 locks) cannot be intercepted or stopped before the modifiers are changed.
 This is because the modifier handling is done before the key down
 handling, and in addition there is not currently any way to stop the
 keyboard device from getting a key press (which is probably a good thing.)

 Given that the behavior wanted in this ticket is actually not bad
 (avoiding accidental Caps Lock by requiring left shift held), I'd be up
 for adding it as an optional feature. But since some people may not like
 that, I also think this is possible to accomplish with the current system.

 While looking around the source code to figure this out, I found the
 set_keyboard_locks function in InterfaceDefs.h. I think that instead of
 trying to stop the caps lock from being turned on, you can just
 immediately turn it off with set_keyboard_locks if shift was not pressed.
 I imagine it would happen so fast that the keyboard caps lock light might
 not even turn on. In addition you could track the modifiers in your filter
 and block B_MODIFIERS_CHANGED if nothing has changed except caps lock.

 Given that stpere is now a Haiku committer I'll leave that exercise up to
 you :)

 I'll leave this ticket open for now, but please try this and let me know
 if it works so we can close this.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/2053#comment:6>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: