summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 16:38:13 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-28 16:38:13 +0000
commitf1d0e4590908f89d8d1f64553fa3438fc40f7dc8 (patch)
treee9c40d4164844818704ee6d722e0f3d72fdb97e8 /views
parentcc233bd48028bb82d3b4da55864434fb771de05c (diff)
downloadchromium_src-f1d0e4590908f89d8d1f64553fa3438fc40f7dc8.zip
chromium_src-f1d0e4590908f89d8d1f64553fa3438fc40f7dc8.tar.gz
chromium_src-f1d0e4590908f89d8d1f64553fa3438fc40f7dc8.tar.bz2
Fix grab/ungrab in views-desktop world.
In views-desktop, if you click on a window once, all the subsequent click events go to that window until it is closed. This is a fix for that. I have updated the relevant test to catch such errors. BUG=none TEST=WidgetTest.GrabUngrab Review URL: http://codereview.chromium.org/7519006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/native_widget_gtk.cc4
-rw-r--r--views/widget/native_widget_gtk.h3
-rw-r--r--views/widget/widget_unittest.cc17
3 files changed, 23 insertions, 1 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 133be66..572c53a 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -938,6 +938,7 @@ void NativeWidgetGtk::SetMouseCapture() {
}
void NativeWidgetGtk::ReleaseMouseCapture() {
+ bool delegate_lost_capture = HasMouseCapture();
if (GTK_WIDGET_HAS_GRAB(window_contents_))
gtk_grab_remove(window_contents_);
if (grab_notify_signal_id_) {
@@ -951,8 +952,9 @@ void NativeWidgetGtk::ReleaseMouseCapture() {
TouchFactory::GetInstance()->UngrabTouchDevices(
GDK_WINDOW_XDISPLAY(window_contents()->window));
#endif
- delegate_->OnMouseCaptureLost();
}
+ if (delegate_lost_capture)
+ delegate_->OnMouseCaptureLost();
}
bool NativeWidgetGtk::HasMouseCapture() const {
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index a6df8a9..a747db3 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -290,6 +290,9 @@ class VIEWS_API NativeWidgetGtk : public internal::NativeWidgetPrivate,
// application.
virtual void HandleGtkGrabBroke();
+ const internal::NativeWidgetDelegate* delegate() const { return delegate_; }
+ internal::NativeWidgetDelegate* delegate() { return delegate_; }
+
private:
class DropObserver;
friend class DropObserver;
diff --git a/views/widget/widget_unittest.cc b/views/widget/widget_unittest.cc
index 4396e4d..04e7662 100644
--- a/views/widget/widget_unittest.cc
+++ b/views/widget/widget_unittest.cc
@@ -32,6 +32,8 @@ class NativeWidgetGtkCapture : public NativeWidgetGtk {
mouse_capture_ = true;
}
virtual void ReleaseMouseCapture() OVERRIDE {
+ if (mouse_capture_)
+ delegate()->OnMouseCaptureLost();
mouse_capture_ = false;
}
virtual bool HasMouseCapture() const OVERRIDE {
@@ -251,6 +253,21 @@ TEST_F(WidgetTest, GrabUngrab) {
EXPECT_FALSE(WidgetHasMouseCapture(child1));
EXPECT_FALSE(WidgetHasMouseCapture(child2));
+ RunPendingMessages();
+
+ // Click on child2
+ MouseEvent pressed2(ui::ET_MOUSE_PRESSED, 315, 45, ui::EF_LEFT_BUTTON_DOWN);
+ EXPECT_TRUE(toplevel->OnMouseEvent(pressed2));
+ EXPECT_TRUE(WidgetHasMouseCapture(toplevel));
+ EXPECT_TRUE(WidgetHasMouseCapture(child2));
+ EXPECT_FALSE(WidgetHasMouseCapture(child1));
+
+ MouseEvent released2(ui::ET_MOUSE_RELEASED, 315, 45, ui::EF_LEFT_BUTTON_DOWN);
+ toplevel->OnMouseEvent(released2);
+ EXPECT_FALSE(WidgetHasMouseCapture(toplevel));
+ EXPECT_FALSE(WidgetHasMouseCapture(child1));
+ EXPECT_FALSE(WidgetHasMouseCapture(child2));
+
toplevel->CloseNow();
}