summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 19:55:05 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 19:55:05 +0000
commit9d4314aa8d3542ef3213654d7062d795f95e8d83 (patch)
tree34d617b6d2d479a6ecb1568411acc5c5377cbe3e /ash
parentf12c2f9daa912122ae0b47fa3d82ec853ea49d38 (diff)
downloadchromium_src-9d4314aa8d3542ef3213654d7062d795f95e8d83.zip
chromium_src-9d4314aa8d3542ef3213654d7062d795f95e8d83.tar.gz
chromium_src-9d4314aa8d3542ef3213654d7062d795f95e8d83.tar.bz2
Makes showing the modal dialog release capture. Without this capture
would stay on a window below the modal dialog, and the mouse released wouldn't get processed by the window because the SystemModalContainerEventFilter doesn't let any events through to it. BUG=124040 TEST=covered by unit tests, see bug for details. R=ben@chromium.org Review URL: https://chromiumcodereview.appspot.com/10127005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133043 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/system_modal_container_event_filter.cc10
-rw-r--r--ash/wm/system_modal_container_layout_manager.cc5
-rw-r--r--ash/wm/system_modal_container_layout_manager_unittest.cc44
3 files changed, 55 insertions, 4 deletions
diff --git a/ash/wm/system_modal_container_event_filter.cc b/ash/wm/system_modal_container_event_filter.cc
index f3fa280..69891c2 100644
--- a/ash/wm/system_modal_container_event_filter.cc
+++ b/ash/wm/system_modal_container_event_filter.cc
@@ -18,13 +18,15 @@ SystemModalContainerEventFilter::SystemModalContainerEventFilter(
SystemModalContainerEventFilter::~SystemModalContainerEventFilter() {
}
-bool SystemModalContainerEventFilter::PreHandleKeyEvent(aura::Window* target,
- aura::KeyEvent* event) {
+bool SystemModalContainerEventFilter::PreHandleKeyEvent(
+ aura::Window* target,
+ aura::KeyEvent* event) {
return !delegate_->CanWindowReceiveEvents(target);
}
-bool SystemModalContainerEventFilter::PreHandleMouseEvent(aura::Window* target,
- aura::MouseEvent* event) {
+bool SystemModalContainerEventFilter::PreHandleMouseEvent(
+ aura::Window* target,
+ aura::MouseEvent* event) {
return !delegate_->CanWindowReceiveEvents(target);
}
diff --git a/ash/wm/system_modal_container_layout_manager.cc b/ash/wm/system_modal_container_layout_manager.cc
index 326a4cf..cdad8b8 100644
--- a/ash/wm/system_modal_container_layout_manager.cc
+++ b/ash/wm/system_modal_container_layout_manager.cc
@@ -146,6 +146,11 @@ bool SystemModalContainerLayoutManager::CanWindowReceiveEvents(
// SystemModalContainerLayoutManager, private:
void SystemModalContainerLayoutManager::AddModalWindow(aura::Window* window) {
+ if (modal_windows_.empty()) {
+ aura::RootWindow* root = container_->GetRootWindow();
+ if (root->capture_window())
+ root->capture_window()->ReleaseCapture();
+ }
modal_windows_.push_back(window);
CreateModalScreen();
}
diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc
index b64e84b..277b9fd 100644
--- a/ash/wm/system_modal_container_layout_manager_unittest.cc
+++ b/ash/wm/system_modal_container_layout_manager_unittest.cc
@@ -65,6 +65,29 @@ class TestWindow : public views::WidgetDelegateView {
DISALLOW_COPY_AND_ASSIGN(TestWindow);
};
+class CaptureTrackingView : public views::View {
+ public:
+ CaptureTrackingView() : got_press_(false), got_capture_lost_(false) {}
+
+ bool got_press() const { return got_press_; }
+ bool got_capture_lost() const { return got_capture_lost_; }
+
+ // Overridden from views::View
+ virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
+ got_press_ = true;
+ return true;
+ }
+ virtual void OnMouseCaptureLost() OVERRIDE {
+ got_capture_lost_ = true;
+ }
+
+ private:
+ bool got_press_;
+ bool got_capture_lost_;
+
+ DISALLOW_COPY_AND_ASSIGN(CaptureTrackingView);
+};
+
class EventTestWindow : public TestWindow {
public:
explicit EventTestWindow(bool modal) : TestWindow(modal),
@@ -268,5 +291,26 @@ TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) {
modal_window->Show();
}
+// Verifies we generate a capture lost when showing a modal window.
+TEST_F(SystemModalContainerLayoutManagerTest, ChangeCapture) {
+ views::Widget* widget =
+ views::Widget::CreateWindowWithParent(new TestWindow(false), NULL);
+ scoped_ptr<aura::Window> widget_window(widget->GetNativeView());
+ CaptureTrackingView* view = new CaptureTrackingView;
+ widget->GetContentsView()->AddChildView(view);
+ view->SetBoundsRect(widget->GetContentsView()->bounds());
+ widget->Show();
+
+ gfx::Point center(view->width() / 2, view->height() / 2);
+ views::View::ConvertPointToScreen(view, &center);
+ aura::test::EventGenerator generator(Shell::GetRootWindow(), center);
+ generator.PressLeftButton();
+ EXPECT_TRUE(view->got_press());
+ scoped_ptr<aura::Window> modal_window(
+ TestWindow::OpenTestWindow(widget->GetNativeView(), true));
+ modal_window->Show();
+ EXPECT_TRUE(view->got_capture_lost());
+}
+
} // namespace test
} // namespace ash