From 8d6fcc39959c711b3921de41fec30c8cfdd071a3 Mon Sep 17 00:00:00 2001 From: "oshima@chromium.org" Date: Wed, 9 Jun 2010 06:45:25 +0000 Subject: Draw composited widget's content only after something is drawn. This was causing ugly flicker when screen locker is shown. BUG=none TEST=none Review URL: http://codereview.chromium.org/2717002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49232 0039d316-1c4b-4281-b951-d872f2087c98 --- views/widget/widget_gtk.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 5d946f5..5f0f6f8 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("")); } - // 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( -- cgit v1.1