GNOME Bugzilla – Bug 689809
osxvideosink: inconsistent keyboard navigation events
Last modified: 2013-01-31 11:22:53 UTC
Keyboard GstNavigation events sent from osxvideosink quite inconsistent with ones in Linux and Windows (e.g., from xvimagesink or d3dvideosink): - only alphanumeric keys are sent properly with one possible char, Space, Return, cursor keys are ignored - single press on modifier keys (e.g. Shift, Ctrl, Alt, Command) are not captured I got a patch addressing the problem, it makes the situation similar to xvimagesink and d3dvideosink examples. I hope to add it tomorrow and maybe discuss it here as it looks quite ugly due to necessity of convertion between keycodes and keynames right in the element (I didn't manage to find any reliable way to do it in Mac OS X though I'm not so experienced with this OS, its API and Objective C language.
As promised, I submit a patch addressing key input problem in osxvideosink. Again, thanks to my employer, Neoshpere LLC, for permission to make it public. Unfortunately, the patch is quite big due to gst_keycode_to_keyname() function. I think it could be more reasonable to include a cross-platform version of such a function to somewhere like GstNavigation module and only use this function from multiple sinks. The problem is that things which are quite straightforward, for example, on X server and Xlib, on Mac are so confusing due to different approach to user's input. If there were a unified function to convert keycode (which are so much platform-independent) to exact GStreamer key names (which are GStreamer-specific), then it would be better both for sink and application developers.
Created attachment 231031 [details] [review] Patch addressing key input problems in osxvideosink It's against latest upstream revision of osxvideo.
Review of attachment 231031 [details] [review]: ::: gst-plugins-good/sys/osxvideo/cocoawindow.m @@ +91,3 @@ + +static +gchar* gst_keycode_to_keyname(gint16 keycode) Could you change this to return a const gchar* (no g_strdup(), no g_free() below). Also is this going to work with combination key presses like ctrl+c? And are you sure there is no function in OSX anywhere to do this conversion?
Yes, sure, I'll change return type. No, I am completely not sure that there's no system conversion functions, there's apparently several ones, so maybe someone would propose better way to do it. The main problem is that GstNavigation expected to provide platform-independent string on keypress/keyrelease. If we get x(v)imagesink as a reference, it separately sends modifier keys (as to ctrl+c it will return ctrl-press while pressing c would be grabbed by console to exit the program), all the alpha keys are only lowercase, there're some standard names for Enter, Esc and so on. What's more, the meaning for some keys really depends on OS (like Alt and Option). So I think it would be better to have some common function somewhere in GstNavigation interface to convert scan-code to GstNavigation-related platform-independent string and then all this code will go to this function.
Yeah, x(v)imagesink should be seen as the reference implementation here for everything not in the documentation (not great but....). Considering that I think your patch is fine, except for the unnecessary g_strdup() and g_free()
Created attachment 233806 [details] [review] Refreshed patch for a problem Thanks, Sebastian. Here's an updated patch, I must be getting mad when coding the previous version, thank you so much for corrections. I've also rebased the patch on top of updated git version and make it in preferred git format-patch style.
commit 3e54bb53ef51c2d553eb5570ec207f301bbe93da Author: Alexey Chernov <achernov@neosphere.com> Date: Fri Jan 18 21:08:12 2013 +0400 osxvideosink: Make GstNavigation key input events in osxvideosink compatible with x(v)imagesink ones
Thanks, Sebastian.