Bug 18946 - Not all key events are processed.
Summary: Not all key events are processed.
Status: ASSIGNED
Alias: None
Product: swfdec
Classification: Unclassified
Component: library (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: high major
Assignee: swfdec ml
QA Contact: swfdec ml
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-08 02:58 UTC by helmut.jahns
Modified: 2009-02-21 20:11 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Simple flash file tracing a text message when pressing 'cursor left' (2.13 KB, application/octet-stream)
2008-12-09 04:10 UTC, helmut.jahns
Details
patch to fix key event handling (1.80 KB, patch)
2009-02-20 04:40 UTC, zou
Details | Splinter Review
patch updated. (2.34 KB, patch)
2009-02-21 19:16 UTC, zou
Details | Splinter Review

Description helmut.jahns 2008-12-08 02:58:55 UTC
swfdec 0.8.2 does not respond to keyboard events. This problem occurres when using both the GTK player and a directfb player.

The gtk-player distributed with Ubuntu 8.04 which is based on a previous library shows the same problem and can be used for reproducing.

swfdec_player_do_handle_key() is invoked as a result of sending a key press message in swfdec_player_key_press() with the proper key value, therefore I assume the problem is located in further processing of the key event.

Please confirm this problem by starting the simple swf file attached to this issue. It contains an OnClipEvent(keyDown) handler and should put a trace message to the console when pressing the 'cursor left' key. Playback using Gnash works fine, as well as testing it with CS4.
Comment 1 helmut.jahns 2008-12-09 04:10:21 UTC
Created attachment 20955 [details]
Simple flash file tracing a text message when pressing 'cursor left'
Comment 2 zou 2008-12-11 07:05:43 UTC
I haven't try the test with GTK(I don't use GTK).  But by reviewing the swfdec source code, I think the key code translation part might need to be imporved. I suspect the function swfdec_gtk_keycode_from_hardware_keycode() doesn't work quite well on some systems. It's strange to me that someone want to translate the hardware code directly. Why not translate GdkEventKey->keyval or the unicode represented by the keyval instead? Isn't hardware keycode hardware dependent, thus not portable?


To helmut.jahns:

If you'd like to take a test, you may want check if function swfdec_gtk_event_to_keycode() works as expected on your platform. 
See file swfdec_gtk_widget.c, function swfdec_gtk_widget_key_press(), line170(git head), that's where swfdec get the key code. When you press the 'LEFT' key, the return value should be 37. Add some printings there, you should see if it works as expected.

--zou



Comment 3 helmut.jahns 2008-12-12 04:28:23 UTC
We are aware of possible conversion mismatches between keyboard keycode to swfdec keycode, but we think the problem is not related to it. The 'cursor left' keycode is converted to 37 which corresponds to SWFDEC_KEY_LEFT, and this keycode value is forwarded to swfdec_player_key_press().
Comment 4 helmut.jahns 2008-12-12 07:04:23 UTC
It seems there is no valid keyboard focus.

In swfdec_player_do_handle_key(), there is a keypress operation executed dependent on a pointer in priv->focus, a pointer which is said do represent the keyboard focus. Although priv->has_focus is set to 'true' in swfdec_player_init(), priv->focus always remains NULL, because neither swfdec_player_set_focus() nor swfdec_player_update_focus() is invoked.

The result is that klass->key_press() is not called. This is possibly the reason for the failure of processing key events ('possibly', because I could not check the right behavior).

Can anyone more familiar with swfdec confirm this conclusion? Does anyone know a proper fix for it?
Comment 5 Benjamin Otte 2008-12-12 07:48:18 UTC
Interesting. I just make sure that Swfdec (both 0.8.2 and 0.9.2) handle keyboard fine by playing the tennis game.

So it looks like it's an internal issue. There's roughly infinite ways to deliver key events in Flash, among them:
- Key.onKeyDown and Key.onKeyUp
- MovieClip.onKeyDown and MovieClip.onKeyUp
- onPress(key) events defined in the flash file
- built-in keyboard handlers, like the TextField object

Some of these events are triggered all the time, some are only delivered to the movieclip that has keyboard focus and then keypress delivery is probably also restricted by the security system.

It seems that you've found a case that we do wrong: Delivery of onPress() events. The other stuff should still work fine.
Comment 6 helmut.jahns 2009-02-18 07:09:52 UTC
It turned out to be that this problem is only occuring when using OnClipEvents(keyDown). If AddListener() is used, it works fine.
Comment 7 zou 2009-02-20 04:40:06 UTC
Created attachment 23130 [details] [review]
patch to fix key event handling

fixed hanlding key event onClipEvent(keyDown) and on(keyPress, keycode).

I't would be great if anyone like to have a test.

--zou
Comment 8 zou 2009-02-20 04:48:30 UTC
The above patch only applys to git-head. But the same logic should also work for 0.8.2.

--zou
Comment 9 zou 2009-02-21 19:16:56 UTC
Created attachment 23173 [details] [review]
patch updated. 

patch updated, to handle both onClipEvent(keyDown/keyUp) and on(keyPress, keyCode).  onClipEvent(keyUp) was not handled in last patch and git-head.

--zou
Comment 10 zou 2009-02-21 19:26:12 UTC
Changed the title of this bug item, since it's not only 0.8.2 specific. Again, it would be nice if any one could do some tests with some little swfs that didn't work before.

--zou
Comment 11 zou 2009-02-21 20:11:31 UTC
OK, tested myself, the patch to swfdec_player.c is NOT correct.  The SWFDEC_EVENT_KEY_DOWN/UP event shouldn't be queued unconditionally. otherwise, each event handler might be triggered twice due to later swfdec_player_broadcast(). 

The problem is that for swf actors, there are two types of keyDown/up event handlers. One is defined in PlaceObject2 tags(built-in handlers), with actions like onClipEvent(keyDown); the other is defined in normal actionscript blocks, with actions like actor.onKeyDown = function () {}; Key.addListener(actor). As far as I can, there is more work to handle this situation correctly without changing the current interfaces.

--zou


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.