summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/controls/native/native_view_host_gtk.cc16
-rw-r--r--views/widget/widget_gtk.cc19
-rw-r--r--views/widget/widget_gtk.h10
3 files changed, 35 insertions, 10 deletions
diff --git a/views/controls/native/native_view_host_gtk.cc b/views/controls/native/native_view_host_gtk.cc
index 533683e..36aa82b 100644
--- a/views/controls/native/native_view_host_gtk.cc
+++ b/views/controls/native/native_view_host_gtk.cc
@@ -188,13 +188,15 @@ void NativeViewHostGtk::RemovedFromWidget() {
void NativeViewHostGtk::InstallClip(int x, int y, int w, int h) {
DCHECK(w > 0 && h > 0);
installed_clip_bounds_.SetRect(x, y, w, h);
- installed_clip_ = true;
-
- // We only re-create the fixed with a window when a cliprect is installed.
- // Because the presence of a X Window will prevent transparency from working
- // properly, we only want it to be active for the duration of a clip
- // (typically during animations and scrolling.)
- CreateFixed(true);
+ if (!installed_clip_) {
+ installed_clip_ = true;
+
+ // We only re-create the fixed with a window when a cliprect is installed.
+ // Because the presence of a X Window will prevent transparency from working
+ // properly, we only want it to be active for the duration of a clip
+ // (typically during animations and scrolling.)
+ CreateFixed(true);
+ }
}
bool NativeViewHostGtk::HasInstalledClip() {
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 6e78a71..cb54356 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -153,7 +153,8 @@ WidgetGtk::WidgetGtk(Type type)
got_initial_focus_in_(false),
has_focus_(false),
delegate_(NULL),
- always_on_top_(false) {
+ always_on_top_(false),
+ is_double_buffered_(false) {
static bool installed_message_loop_observer = false;
if (!installed_message_loop_observer) {
installed_message_loop_observer = true;
@@ -210,6 +211,16 @@ bool WidgetGtk::MakeTransparent() {
return true;
}
+void WidgetGtk::EnableDoubleBuffer(bool enabled) {
+ is_double_buffered_ = enabled;
+ if (window_contents_) {
+ if (is_double_buffered_)
+ GTK_WIDGET_SET_FLAGS(window_contents_, GTK_DOUBLE_BUFFERED);
+ else
+ GTK_WIDGET_UNSET_FLAGS(window_contents_, GTK_DOUBLE_BUFFERED);
+ }
+}
+
bool WidgetGtk::MakeIgnoreEvents() {
// Transparency can only be enabled for windows/popups and only if we haven't
// realized the widget.
@@ -1186,7 +1197,8 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) {
if (type_ == TYPE_CHILD) {
window_contents_ = widget_ = gtk_views_fixed_new();
gtk_widget_set_name(widget_, "views-gtkwidget-child-fixed");
- GTK_WIDGET_UNSET_FLAGS(widget_, GTK_DOUBLE_BUFFERED);
+ if (!is_double_buffered_)
+ GTK_WIDGET_UNSET_FLAGS(widget_, GTK_DOUBLE_BUFFERED);
gtk_fixed_set_has_window(GTK_FIXED(widget_), true);
if (!parent && !null_parent_) {
GtkWidget* popup = gtk_window_new(GTK_WINDOW_POPUP);
@@ -1221,7 +1233,8 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) {
window_contents_ = gtk_views_fixed_new();
gtk_widget_set_name(window_contents_, "views-gtkwidget-window-fixed");
- GTK_WIDGET_UNSET_FLAGS(window_contents_, GTK_DOUBLE_BUFFERED);
+ if (!is_double_buffered_)
+ GTK_WIDGET_UNSET_FLAGS(window_contents_, GTK_DOUBLE_BUFFERED);
gtk_fixed_set_has_window(GTK_FIXED(window_contents_), true);
gtk_container_add(GTK_CONTAINER(widget_), window_contents_);
gtk_widget_show(window_contents_);
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h
index b86820a..5ce37e6 100644
--- a/views/widget/widget_gtk.h
+++ b/views/widget/widget_gtk.h
@@ -79,6 +79,12 @@ class WidgetGtk
bool MakeTransparent();
bool is_transparent() const { return transparent_; }
+ // Enable/Disable double buffering.This is neccessary to prevent
+ // flickering in ScrollView, which has both native and view
+ // controls.
+ void EnableDoubleBuffer(bool enabled);
+ bool is_double_buffered() const { return is_double_buffered_; }
+
// Makes the window pass all events through to any windows behind it.
// This must be invoked before Init. This does a couple of checks and returns
// true if the window can be made to ignore events. The actual work of making
@@ -431,6 +437,10 @@ class WidgetGtk
// for types other than TYPE_CHILD.
bool always_on_top_;
+ // If true, we enable the content widget's double buffering.
+ // This is false by default.
+ bool is_double_buffered_;
+
DISALLOW_COPY_AND_ASSIGN(WidgetGtk);
};