Bug 1189028 - Draw a toplevel popup behind popup menus on GTK3. r=karlt
authorAndrew Comminos <acomminos@mozilla.com>
Thu, 06 Aug 2015 14:20:00 -0400
changeset 257117 12a12a5ca224cad9eefb7d4c5a3bc17c9a0283f6
parent 257116 10e77092a656b4800876c0233e2a188cf6f9eb6a
child 257118 462c4c964f040f51ce386eb18cd4b3cb2195ceb3
push id29207
push userryanvm@gmail.com
push dateTue, 11 Aug 2015 14:27:25 +0000
treeherdermozilla-central@d82b5a78686a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1189028
milestone42.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 1189028 - Draw a toplevel popup behind popup menus on GTK3. r=karlt
widget/gtk/gtk3drawing.c
--- a/widget/gtk/gtk3drawing.c
+++ b/widget/gtk/gtk3drawing.c
@@ -865,16 +865,34 @@ moz_gtk_splitter_get_metrics(gint orient
     } else {
         ensure_vpaned_widget();
         gtk_widget_style_get(gVPanedWidget, "handle_size", size, NULL);
     }
     return MOZ_GTK_SUCCESS;
 }
 
 static gint
+moz_gtk_window_paint(cairo_t *cr, GdkRectangle* rect,
+                     GtkTextDirection direction)
+{
+    GtkStyleContext* style;
+
+    ensure_window_widget();
+    gtk_widget_set_direction(gProtoWindow, direction);
+
+    style = gtk_widget_get_style_context(gProtoWindow);	
+    gtk_style_context_save(style);
+    gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
+    gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
+    gtk_style_context_restore(style);
+
+    return MOZ_GTK_SUCCESS;
+}
+
+static gint
 moz_gtk_button_paint(cairo_t *cr, GdkRectangle* rect,
                      GtkWidgetState* state,
                      GtkReliefStyle relief, GtkWidget* widget,
                      GtkTextDirection direction)
 {
     GtkStateFlags state_flags = GetStateFlagsFromGtkWidgetState(state);
     GtkStyleContext* style = gtk_widget_get_style_context(widget);    
     gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
@@ -2384,16 +2402,20 @@ static gint
 moz_gtk_menu_popup_paint(cairo_t *cr, GdkRectangle* rect,
                          GtkTextDirection direction)
 {
     GtkStyleContext* style;
 
     ensure_menu_popup_widget();
     gtk_widget_set_direction(gMenuPopupWidget, direction);
 
+    // Draw a backing toplevel. This fixes themes that don't provide a menu
+    // background, and depend on the GtkMenu's implementation window to provide it.
+    moz_gtk_window_paint(cr, rect, direction);
+
     style = gtk_widget_get_style_context(gMenuPopupWidget);
     gtk_style_context_save(style);
     gtk_style_context_add_class(style, GTK_STYLE_CLASS_MENU);
 
     gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
     gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
     gtk_style_context_restore(style);
 
@@ -2576,34 +2598,16 @@ moz_gtk_check_menu_item_paint(cairo_t *c
     } else {
       gtk_render_check(style, cr, x, y, indicator_size, indicator_size);
     }
     gtk_style_context_restore(style);
 
     return MOZ_GTK_SUCCESS;
 }
 
-static gint
-moz_gtk_window_paint(cairo_t *cr, GdkRectangle* rect,
-                     GtkTextDirection direction)
-{
-    GtkStyleContext* style;
-
-    ensure_window_widget();
-    gtk_widget_set_direction(gProtoWindow, direction);
-
-    style = gtk_widget_get_style_context(gProtoWindow);	
-    gtk_style_context_save(style);
-    gtk_style_context_add_class(style, GTK_STYLE_CLASS_BACKGROUND);
-    gtk_render_background(style, cr, rect->x, rect->y, rect->width, rect->height);
-    gtk_style_context_restore(style);
-
-    return MOZ_GTK_SUCCESS;
-}
-
 static void
 moz_gtk_add_style_border(GtkStyleContext* style,
                          gint* left, gint* top, gint* right, gint* bottom)
 {
     GtkBorder border;
 
     gtk_style_context_get_border(style, 0, &border);