Flash: Mouse input flickers when view is offset in window
Posted: Sat May 25, 2013 4:13 pm
I'm using CEF3 in OSR mode and I'm rendering a webpage that has a Twitch Flash player on it. When I hover the mouse over the player's buttons (play, pause, mute, etc.), the buttons flicker, i.e. it's like the Flash player registers the mouse input, but then immediately considers the mouse to have been moved away.
After doing a little bit more digging, it turns out that this behavior only happens if the browser's viewport is offset from the top-left of the browser's parent window. That is, in OSR mode, you call SetAsOffScreen() with an HWND to the browser's parent window. This HWND is somewhat irrelevant in OSR mode since there isn't necessarily a one-to-one mapping between a browser and a physical window. In my case, if I happen to have a physical window, I pass its handle to CEF; if I don't have a physical window, I just create a dummy hidden window and pass its handle to CEF (I'm not exactly sure what CEF needs the HWND for in OSR mode actually?).
Now, if the browser view is positioned at 0,0 in the physical window, the input in the flash player is just fine and dandy. However, if the view is offset, the input starts to flicker. My guess is that Flash somehow uses the coordinates of the HWND that was passed in when I created the browser despite me providing the proper view coordinates and translation to screen coordinate via GetViewRect(), GetScreenPoint(), etc.
After doing a little bit more digging, it turns out that this behavior only happens if the browser's viewport is offset from the top-left of the browser's parent window. That is, in OSR mode, you call SetAsOffScreen() with an HWND to the browser's parent window. This HWND is somewhat irrelevant in OSR mode since there isn't necessarily a one-to-one mapping between a browser and a physical window. In my case, if I happen to have a physical window, I pass its handle to CEF; if I don't have a physical window, I just create a dummy hidden window and pass its handle to CEF (I'm not exactly sure what CEF needs the HWND for in OSR mode actually?).
Now, if the browser view is positioned at 0,0 in the physical window, the input in the flash player is just fine and dandy. However, if the view is offset, the input starts to flicker. My guess is that Flash somehow uses the coordinates of the HWND that was passed in when I created the browser despite me providing the proper view coordinates and translation to screen coordinate via GetViewRect(), GetScreenPoint(), etc.