diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 17:44:40 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-12 17:44:40 +0000 |
commit | 65b541890c5a048796bd2fc9ac687f0bac02bebe (patch) | |
tree | 9a02ae860b48a53abb147bc6cd2141fc4210d4e1 /views/widget | |
parent | 56ec62a9dbeda39c379b31ebb48756e2f1bcedaf (diff) | |
download | chromium_src-65b541890c5a048796bd2fc9ac687f0bac02bebe.zip chromium_src-65b541890c5a048796bd2fc9ac687f0bac02bebe.tar.gz chromium_src-65b541890c5a048796bd2fc9ac687f0bac02bebe.tar.bz2 |
Gets blocked popups to work on views/gtk. I had to fix a couple of
additional things here:
. Avoid doing anything in OnSizeAllocation if the size hasn't
changed. Because of how gtk works I was getting stuck in a loop if I
OnSizeAllocate did anything if the size hadn't changed.
. Applied similar shortcut to TabContentsViewGtk.
. Made SimpleMenuModel only ask delegate for checked state if the item
is a check.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/261051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/widget_gtk.cc | 9 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index cc0aec9..51140a6 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -628,6 +628,15 @@ void WidgetGtk::CreateGtkWidget(GtkWidget* parent, const gfx::Rect& bounds) { } void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { + // See comment next to size_ as to why we do this. Also note, it's tempting + // to put this in the static method so subclasses don't need to worry about + // it, but if a subclasses needs to set a shape then they need to always + // reset the shape in this method regardless of whether the size changed. + gfx::Size new_size(allocation->width, allocation->height); + if (new_size == size_) + return; + + size_ = new_size; root_view_->SetBounds(0, 0, allocation->width, allocation->height); root_view_->SchedulePaint(); } diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index ccd3bd5..e082eea 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -8,6 +8,7 @@ #include <gtk/gtk.h> #include "app/active_window_watcher_x.h" +#include "base/gfx/size.h" #include "base/message_loop.h" #include "views/focus/focus_manager.h" #include "views/widget/widget.h" @@ -413,6 +414,12 @@ class WidgetGtk // See make_transient_to_parent for a description. bool transient_to_parent_; + // Last size supplied to OnSizeAllocate. We cache this as any time the + // size of a GtkWidget changes size_allocate is called, even if the size + // didn't change. If we didn't cache this and ignore calls when the size + // hasn't changed, we can end up getting stuck in a never ending loop. + gfx::Size size_; + DISALLOW_COPY_AND_ASSIGN(WidgetGtk); }; |