summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 22:41:54 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 22:41:54 +0000
commit4c22771c386422700af38aeff1a1ea5c036e38c8 (patch)
treecb2e5ee3aa702c72ea0f67e702c4666475dfc801 /views/widget
parent9a295b8b77f4ad665fa5a3ec9201d44850b38a88 (diff)
downloadchromium_src-4c22771c386422700af38aeff1a1ea5c036e38c8.zip
chromium_src-4c22771c386422700af38aeff1a1ea5c036e38c8.tar.gz
chromium_src-4c22771c386422700af38aeff1a1ea5c036e38c8.tar.bz2
Take 2 of getting blocked popups to work on views/gtk. My first attempt was not deleting the blocked popup container view views,
which resulted in a reliability crash. This differs from the first patch in that BlockedPopupContainerViewViews::Destroy now does a delete this. From the original patch: 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/274019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/widget_gtk.cc9
-rw-r--r--views/widget/widget_gtk.h7
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);
};