Bug 618248, don't close popups when a window is lowered while dragging, prevents bookmark menu from closing, r=karl,a=blocking
authorNeil Deakin <neil@mozilla.com>
Fri, 31 Dec 2010 14:20:00 -0500
changeset 59748 378fe2ca7eb48d9b58a91efdfc5cf99a312fc12d
parent 59747 5a63268e224c24a4a730dcf4c5707a88a423733c
child 59749 39db16b78175009a9a6e425ed1686b9d072bd99b
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewerskarl, blocking
bugs618248
milestone2.0b9pre
Bug 618248, don't close popups when a window is lowered while dragging, prevents bookmark menu from closing, r=karl,a=blocking
widget/src/gtk2/nsWindow.cpp
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -2886,17 +2886,34 @@ nsWindow::OnContainerFocusInEvent(GtkWid
 }
 
 void
 nsWindow::OnContainerFocusOutEvent(GtkWidget *aWidget, GdkEventFocus *aEvent)
 {
     LOGFOCUS(("OnContainerFocusOutEvent [%p]\n", (void *)this));
 
     if (mWindowType == eWindowType_toplevel || mWindowType == eWindowType_dialog) {
-        check_for_rollup(aEvent->window, 0, 0, PR_FALSE, PR_TRUE);
+        nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
+        nsCOMPtr<nsIDragSession> dragSession;
+        dragService->GetCurrentSession(getter_AddRefs(dragSession));
+
+        // Rollup popups when a window is focused out unless a drag is occurring.
+        // This check is because drags grab the keyboard and cause a focus out on
+        // versions of GTK before 2.18.
+        PRBool shouldRollup = !dragSession;
+        if (!shouldRollup) {
+            // we also roll up when a drag is from a different application
+            nsCOMPtr<nsIDOMNode> sourceNode;
+            dragSession->GetSourceNode(getter_AddRefs(sourceNode));
+            shouldRollup = (sourceNode == nsnull);
+        }
+
+        if (shouldRollup) {
+            check_for_rollup(aEvent->window, 0, 0, PR_FALSE, PR_TRUE);
+        }
     }
 
 #ifdef MOZ_X11
     // plugin lose focus
     if (gPluginFocusWindow) {
         nsRefPtr<nsWindow> kungFuDeathGrip = gPluginFocusWindow;
         gPluginFocusWindow->LoseNonXEmbedPluginFocus();
     }