From 1ec537eca52c64b4d3c68685947d1e392431aa18 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Tue, 16 Jun 2009 14:34:13 -0400 Subject: [PATCH] Bug 498075, two clicks required to switch away from focused plugin, also fixes ususual minimzing behaviour where it immediately restores again, r+sr=smaug --- dom/base/nsFocusManager.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 9cf772ff3c7c..b04d8ef7a093 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1306,17 +1306,21 @@ nsFocusManager::Blur(nsPIDOMWindow* aWindowToClear, // if an object/plug-in is being blurred, move the system focus to the // parent window, otherwise events will still get fired at the plugin. - nsIFrame* contentFrame = presShell->GetPrimaryFrameFor(content); - nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); - if (objectFrame) { - // note that the presshell's widget is being retrieved here, not the one - // for the object frame. - nsIViewManager* vm = presShell->GetViewManager(); - if (vm) { - nsCOMPtr widget; - vm->GetWidget(getter_AddRefs(widget)); - if (widget) - widget->SetFocus(PR_TRUE); + // But don't do this if we are blurring due to the window being lowered, + // otherwise, the parent window can get raised again. + if (mActiveWindow) { + nsIFrame* contentFrame = presShell->GetPrimaryFrameFor(content); + nsIObjectFrame* objectFrame = do_QueryFrame(contentFrame); + if (objectFrame) { + // note that the presshell's widget is being retrieved here, not the one + // for the object frame. + nsIViewManager* vm = presShell->GetViewManager(); + if (vm) { + nsCOMPtr widget; + vm->GetWidget(getter_AddRefs(widget)); + if (widget) + widget->SetFocus(PR_TRUE); + } } } }