Bug 1567434 - [Wayland] Use dynamic popup hierarchy for tooltips/context menu only, r=jhorak
☠☠ backed out by 2d66b2b14eb8 ☠ ☠
authorMartin Stransky <stransky@redhat.com>
Mon, 05 Aug 2019 08:40:16 +0000
changeset 486156 10925a6df9b39d675c08879b68f21f04675898d2
parent 486155 1cd94e91245cbc8eb5a5b58d99b4141e78195b74
child 486157 2d2938a3bee655c0f6ff21c6c0df29d60574183b
push id36391
push usermalexandru@mozilla.com
push dateMon, 05 Aug 2019 15:55:27 +0000
treeherdermozilla-central@9c91b33629b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1567434
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1567434 - [Wayland] Use dynamic popup hierarchy for tooltips/context menu only, r=jhorak If the popup is a regular menu but GetParentMenuWidget() returns nullptr, it's connected non-menu parent (bookmark toolbar for instance). In this case use a parent given at nsWindow::Create() and don't attach it to latest active popup as it has a real parent. Depends on D39347 Differential Revision: https://phabricator.services.mozilla.com/D39348
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1203,29 +1203,42 @@ GtkWidget* nsWindow::ConfigureWaylandPop
           static_cast<nsWindow*>(gVisibleWaylandPopupWindows->data);
       parentWidget = GTK_WINDOW(window->GetGtkWidget());
     } else {
       nsMenuPopupFrame* menuPopupFrame = nullptr;
       nsIFrame* frame = GetFrame();
       if (frame) {
         menuPopupFrame = do_QueryFrame(frame);
       }
+
       // The popup is not fully created yet (we're called from
       // nsWindow::Create()) or we're toplevel popup without parent.
       // In both cases just use parent which was passed to nsWindow::Create().
       if (!menuPopupFrame) {
         LOG(("...[%p] menuPopupFrame = null, using given parent widget [%p]\n",
              (void*)this, parentWidget));
         return GTK_WIDGET(parentWidget);
       }
 
+      LOG(("...[%p] is %s\n", (void*)this,
+           menuPopupFrame->IsContextMenu() ? "context menu" : "popup"));
+
       nsWindow* parentWindow =
           static_cast<nsWindow*>(menuPopupFrame->GetParentMenuWidget());
       LOG(("...[%p] GetParentMenuWidget() = %p\n", (void*)this, parentWindow));
 
+      // If the popup is a regular menu but GetParentMenuWidget() returns
+      // nullptr which means it's connected non-menu parent
+      // (bookmark toolbar for instance).
+      // In this case use a parent given at nsWindow::Create().
+      if (!parentWindow && !menuPopupFrame->IsContextMenu()) {
+        parentWindow =
+            get_window_for_gtk_widget(GTK_WIDGET(mToplevelParentWindow));
+      }
+
       if (!parentWindow) {
         LOG(("...[%p] using active/visible popups as a parent [%p]\n",
              (void*)this, gVisibleWaylandPopupWindows->data));
 
         // We're toplevel popup menu attached to another menu. Just use our
         // latest popup as a parent.
         parentWindow =
             static_cast<nsWindow*>(gVisibleWaylandPopupWindows->data);