Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1246)

Unified Diff: views/widget/widget_gtk.cc

Issue 2717002: Draw composited widget's content only after something is drawn. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget_gtk.cc
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 5d946f55d83f50229307176fe6337fce8cde88e1..5f0f6f87883a0cb797b4ffdbf689dc2acbf17122 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -62,15 +62,13 @@ class CompositePainter {
}
}
- // Enable the composition.
+ // Set the composition flag.
static void SetComposited(GtkWidget* widget) {
- DCHECK(GTK_WIDGET_REALIZED(widget));
- gdk_window_set_composited(widget->window, true);
g_object_set_data(G_OBJECT(widget), kCompositeEnabledKey,
const_cast<char*>(""));
}
- // Returns true if the |widget| is composited.
+ // Returns true if the |widget| is composited and ready to be drawn.
static bool IsComposited(GtkWidget* widget) {
return g_object_get_data(G_OBJECT(widget), kCompositeEnabledKey) != NULL;
}
@@ -901,6 +899,11 @@ gboolean WidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) {
if (transparent_) {
// Clear the background before drawing any view and native components.
DrawTransparentBackground(widget, event);
+ if (type_ == TYPE_CHILD && !CompositePainter::IsComposited(widget_)) {
+ // Let the parent draw the content only after something is drawn on
+ // the widget.
+ CompositePainter::SetComposited(widget_);
+ }
}
root_view_->OnPaint(event);
return false; // False indicates other widgets should get the event as well.
@@ -1308,7 +1311,8 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) {
// The widget has to be realized to set composited flag.
// I tried "realize" signal to set this flag, but it did not work
// when the top level is popup.
- CompositePainter::SetComposited(widget_);
+ DCHECK(GTK_WIDGET_REALIZED(widget_));
+ gdk_window_set_composited(widget_->window, true);
}
} else {
widget_ = gtk_window_new(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698