Bug 628872 - BBC iplayer fullscreen function broken in FF4 beta 9, 10 and nightly builds. r=bent@mozilla.com, a=blocker

This commit is contained in:
Jim Mathies 2011-02-03 20:13:18 -08:00
parent 3cce75a6a4
commit 0c4e4eb26e
4 changed files with 54 additions and 16 deletions

View File

@ -124,6 +124,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
, mWinlessPopupSurrogateHWND(0)
, mWinlessThrottleOldWndProc(0)
, mWinlessHiddenMsgHWND(0)
, mMouseHook(NULL)
#endif // OS_WIN
, mAsyncCallMutex("PluginInstanceChild::mAsyncCallMutex")
#if defined(OS_MACOSX)
@ -1042,6 +1043,42 @@ PluginInstanceChild::RegisterWindowClass()
return RegisterClassEx(&wcex) ? true : false;
}
static inline void
HandleMouseCapture(HWND aWnd, UINT aMessage)
{
// Make sure capture is released by the child on mouse events. Fixes a
// problem with flash full screen mode mouse input. Appears to be
// caused by a bug in flash, since we are not setting the capture
// on the window. (In non-oopp land, we would set and release via
// widget for other reasons.)
switch (aMessage) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
SetCapture(aWnd);
break;
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
ReleaseCapture();
break;
}
}
LRESULT CALLBACK MouseHookProc(int code,
WPARAM wParam,
LPARAM lParam)
{
if (code == HC_ACTION) {
MOUSEHOOKSTRUCT* hookStruct =
reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam);
if (hookStruct)
HandleMouseCapture(hookStruct->hwnd, wParam);
}
return CallNextHookEx(NULL, code, wParam, lParam);
}
bool
PluginInstanceChild::CreatePluginWindow()
{
@ -1068,6 +1105,11 @@ PluginInstanceChild::CreatePluginWindow()
SetWindowLongPtrA(mPluginWindowHWND, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(DefWindowProcA));
// Mouse capture hook for flash full screen capture bug
if (GetQuirks() & PluginModuleChild::QUIRK_FLASH_HOOK_MOUSE_CAPTURE) {
mMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, NULL,
GetCurrentThreadId());
}
return true;
}
@ -1089,6 +1131,11 @@ PluginInstanceChild::DestroyPluginWindow()
DestroyWindow(mPluginWindowHWND);
mPluginWindowHWND = 0;
}
if (mMouseHook) {
UnhookWindowsHookEx(mMouseHook);
mMouseHook = NULL;
}
}
void
@ -1200,25 +1247,11 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
return 0;
}
HandleMouseCapture(hWnd, message);
LRESULT res = CallWindowProc(self->mPluginWndProc, hWnd, message, wParam,
lParam);
// Make sure capture is released by the child on mouse events. Fixes a
// problem with flash full screen mode mouse input. Appears to be
// caused by a bug in flash, since we are not setting the capture
// on the window. (In non-oopp land, we would set and release via
// widget for other reasons.)
switch (message) {
case WM_LBUTTONDOWN:
case WM_MBUTTONDOWN:
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MBUTTONUP:
case WM_RBUTTONUP:
ReleaseCapture();
break;
}
if (message == WM_CLOSE)
self->DestroyPluginWindow();

View File

@ -346,6 +346,7 @@ private:
nsIntPoint mPluginSize;
WNDPROC mWinlessThrottleOldWndProc;
HWND mWinlessHiddenMsgHWND;
HHOOK mMouseHook;
#endif
friend class ChildAsyncCall;

View File

@ -1829,6 +1829,7 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
mQuirks |= QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS;
mQuirks |= QUIRK_FLASH_HOOK_MOUSE_CAPTURE;
}
#endif
}

View File

@ -238,6 +238,9 @@ public:
// Win: Flash trashes the alpha channel in our buffers when cleartype
// is enabled. Mask this setting so they don't know it's enabled.
QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS = 1 << 6,
// Win: Addresses a flash bug with mouse capture and full screen
// windows.
QUIRK_FLASH_HOOK_MOUSE_CAPTURE = 1 << 7,
};
int GetQuirks() { return mQuirks; }