Bug 1210249 - don't mess with toplevel widget when client side decorations are enabled. r=karlt, a=lizzard
authorMartin Stransky <stransky@redhat.com>
Mon, 12 Oct 2015 09:56:00 +0200
changeset 296435 08420d2c251ae6d791562cc3bf914bada728312a
parent 296434 203e5d3c06ba63d4cea2b15107e508fde75b9c12
child 296436 d32d0321812f0fc485fbbc7719010b041afc0e12
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt, lizzard
bugs1210249
milestone43.0a2
Bug 1210249 - don't mess with toplevel widget when client side decorations are enabled. r=karlt, a=lizzard
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3434,16 +3434,17 @@ nsWindow::Create(nsIWidget        *aPare
 
     // figure out our parent window
     GtkWidget      *parentMozContainer = nullptr;
     GtkContainer   *parentGtkContainer = nullptr;
     GdkWindow      *parentGdkWindow = nullptr;
     GtkWindow      *topLevelParent = nullptr;
     nsWindow       *parentnsWindow = nullptr;
     GtkWidget      *eventWidget = nullptr;
+    bool            shellHasCSD = false;
 
     if (aParent) {
         parentnsWindow = static_cast<nsWindow*>(aParent);
         parentGdkWindow = parentnsWindow->mGdkWindow;
     } else if (aNativeParent && GDK_IS_WINDOW(aNativeParent)) {
         parentGdkWindow = GDK_WINDOW(aNativeParent);
         parentnsWindow = get_window_for_gdk_window(parentGdkWindow);
         if (!parentnsWindow)
@@ -3586,36 +3587,34 @@ nsWindow::Create(nsIWidget        *aPare
             gtk_window_group_add_window(group, GTK_WINDOW(mShell));
             g_object_unref(group);
         }
 
         // Create a container to hold child windows and child GtkWidgets.
         GtkWidget *container = moz_container_new();
         mContainer = MOZ_CONTAINER(container);
 
-#if (MOZ_WIDGET_GTK == 2)
-        bool containerHasWindow = false;
-#else
+#if (MOZ_WIDGET_GTK == 3)
         // "csd" style is set when widget is realized so we need to call
         // it explicitly now.
         gtk_widget_realize(mShell);
 
         // We can't draw directly to top-level window when client side
         // decorations are enabled. We use container with GdkWindow instead.
         GtkStyleContext* style = gtk_widget_get_style_context(mShell);
-        bool containerHasWindow = gtk_style_context_has_class(style, "csd");
+        shellHasCSD = gtk_style_context_has_class(style, "csd");
 #endif
-        if (!containerHasWindow) {
+        if (!shellHasCSD) {
             // Use mShell's window for drawing and events.
             gtk_widget_set_has_window(container, FALSE);
             // Prevent GtkWindow from painting a background to flicker.
             gtk_widget_set_app_paintable(mShell, TRUE);
         }
         // Set up event widget
-        eventWidget = containerHasWindow ? container : mShell;
+        eventWidget = shellHasCSD ? container : mShell;
         gtk_widget_add_events(eventWidget, kEvents);
 
         gtk_container_add(GTK_CONTAINER(mShell), container);
         gtk_widget_realize(container);
 
         // make sure this is the focus widget in the container
         gtk_widget_show(container);
         gtk_widget_grab_focus(container);
@@ -3754,17 +3753,18 @@ nsWindow::Create(nsIWidget        *aPare
                          G_CALLBACK(drag_motion_event_cb), nullptr);
         g_signal_connect(mContainer, "drag_leave",
                          G_CALLBACK(drag_leave_event_cb), nullptr);
         g_signal_connect(mContainer, "drag_drop",
                          G_CALLBACK(drag_drop_event_cb), nullptr);
         g_signal_connect(mContainer, "drag_data_received",
                          G_CALLBACK(drag_data_received_event_cb), nullptr);
 
-        GtkWidget *widgets[] = { GTK_WIDGET(mContainer), mShell };
+        GtkWidget *widgets[] = { GTK_WIDGET(mContainer),
+                                 !shellHasCSD ? mShell : nullptr };
         for (size_t i = 0; i < ArrayLength(widgets) && widgets[i]; ++i) {
             // Visibility events are sent to the owning widget of the relevant
             // window but do not propagate to parent widgets so connect on
             // mShell (if it exists) as well as mContainer.
             g_signal_connect(widgets[i], "visibility-notify-event",
                              G_CALLBACK(visibility_notify_event_cb), nullptr);
             // Similarly double buffering is controlled by the window's owning
             // widget.  Disable double buffering for painting directly to the