From 371440a7328b012973e43cb8e542e1c3bcfef6e2 Mon Sep 17 00:00:00 2001 From: Neil Deakin Date: Tue, 8 Nov 2011 14:58:37 -0500 Subject: [PATCH] Bug 700277, nsWindow::BringToFront doesn't handle first opened window properly, r=blassey --- widget/src/android/nsWindow.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index 3797ac47c01..6cee48844fd 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -53,6 +53,7 @@ using mozilla::unused; #include "nsIdleService.h" #include "nsWindow.h" #include "nsIObserverService.h" +#include "nsFocusManager.h" #include "nsRenderingContext.h" #include "nsIDOMSimpleGestureEvent.h" @@ -555,7 +556,14 @@ nsWindow::SetFocus(bool aRaise) void nsWindow::BringToFront() { - if (FindTopLevel() == TopWindow()) + // If the window to be raised is the same as the currently raised one, + // do nothing. We need to check the focus manager as well, as the first + // window that is created will be first in the window list but won't yet + // be focused. + nsCOMPtr fm = do_GetService(FOCUSMANAGER_CONTRACTID); + nsCOMPtr existingTopWindow; + fm->GetActiveWindow(getter_AddRefs(existingTopWindow)); + if (existingTopWindow && FindTopLevel() == TopWindow()) return; if (!IsTopLevel()) {