DescriptionSupport SDL_ActiveEvent
SDL tracks three kinds of application state: SDL_APPACTIVE, SDL_APPINPUTFOCUS,
and SDL_APPMOUSEFOCUS. The first corresponds to whether the window is
minimized, the second to keyboard focus, and the third to whether the mouse is
over the window. For NaCl, I believe the best analogues are
PP_INPUTEVENT_TYPE_MOUSEENTER and PP_INPUTEVENT_TYPE_MOUSELEAVE for
SDL_APPMOUSEFOCUS, keyboard focus for SDL_APPINPUTFOCUS, and page visibility
for SDL_APPACTIVE.
SDL_APPMOUSEFOCUS can be supported easily with SDL_NACL_PushEvent. For the
other two, I believe we need new entry points, and possible even JS postMessage
involvement. Page visibility is exposed in pepper 18 via
pp::Instance::DidChangeView(View) and pp::View::IsPageVisible(), but that's not
on stable yet. Focus should be pp::Instance::DidChangeFocus(bool), but that
appears to be updated only when WebKit-internal focus changes. It doesn't notice
when you switch tabs or windows, unlike DOM focus and blur events. Unclear if
this is intentional or an oversight in the implementation.
The main thing this buys is that SDL calls SDL_ResetKeyboard() when input focus
is lost. This means it, e.g., generates a fake key-up event for Ctrl when
switching tabs with Ctrl-Tab, otherwise the module keeps thinking Ctrl is held
down. Some ports may also useful things with the others, such as pausing when
SDL_APPACTIVE is lost.
Implementation-wise, this is a little invasive as it rewrites the internal
event queue to use SDL_Event as the intermediate structure as that seemed
cleanest.
Landed as https://chromiumcodereview.appspot.com/9963099/
Patch Set 1 #Patch Set 2 : #Messages
Total messages: 5 (0 generated)
|