Bug 1426384 - call gdk_window_set_decorations() on mShell GdkWindow only, r?jhorak draft
authorMartin Stransky <stransky@redhat.com>
Wed, 20 Dec 2017 16:31:13 +0100
changeset 713557 1c407328b45cf66786964f2efcf4bd25f97024bd
parent 713183 2d580aeac901ce5c61a4e5445b46906ce3cf33d8
child 713558 8d1a1f28a4aa88486b1e7ad0e31593c168d341d9
push id93673
push userstransky@redhat.com
push dateWed, 20 Dec 2017 15:37:22 +0000
reviewersjhorak
bugs1426384
milestone59.0a1
Bug 1426384 - call gdk_window_set_decorations() on mShell GdkWindow only, r?jhorak To have any effect we need to call gdk_window_set_decorations() on top-level GdkWindow only. When rendering to mContainer the mGdkWindow belongs to mContainer so we need to get the window from mShell explicitly. MozReview-Commit-ID: KLKlVJbgg3
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -5090,42 +5090,49 @@ nsWindow::SetWindowDecoration(nsBorderSt
         nsWindow *topWindow = get_window_for_gtk_widget(topWidget);
         if (!topWindow)
             return;
 
         topWindow->SetWindowDecoration(aStyle);
         return;
     }
 
+    // We can't use mGdkWindow directly here as it can be
+    // derived from mContainer which is not a top-level GdkWindow.
+    GdkWindow *window = gtk_widget_get_window(mShell);
+
     // Sawfish, metacity, and presumably other window managers get
     // confused if we change the window decorations while the window
     // is visible.
     bool wasVisible = false;
-    if (gdk_window_is_visible(mGdkWindow)) {
-        gdk_window_hide(mGdkWindow);
+    if (gdk_window_is_visible(window)) {
+        gdk_window_hide(window);
         wasVisible = true;
     }
 
     gint wmd = ConvertBorderStyles(aStyle);
     if (wmd != -1)
-      gdk_window_set_decorations(mGdkWindow, (GdkWMDecoration) wmd);
+      gdk_window_set_decorations(window, (GdkWMDecoration) wmd);
 
     if (wasVisible)
-        gdk_window_show(mGdkWindow);
+        gdk_window_show(window);
 
     // For some window managers, adding or removing window decorations
     // requires unmapping and remapping our toplevel window.  Go ahead
     // and flush the queue here so that we don't end up with a BadWindow
     // error later when this happens (when the persistence timer fires
     // and GetWindowPos is called)
 #ifdef MOZ_X11
-    XSync(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) , False);
-#else
-    gdk_flush ();
+    if (mIsX11Display) {
+        XSync(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()) , False);
+    } else
 #endif /* MOZ_X11 */
+    {
+        gdk_flush ();
+    }
 }
 
 void
 nsWindow::HideWindowChrome(bool aShouldHide)
 {
     SetWindowDecoration(aShouldHide ? eBorderStyle_none : mBorderStyle);
 }