Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1186)

Side by Side Diff: ui/views/corewm/window_modality_controller.cc

Issue 25445002: Ensure that in Desktop AURA the WindowModalityController class is at the head of the event pre targ… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/corewm/window_modality_controller.h" 5 #include "ui/views/corewm/window_modality_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/capture_client.h" 10 #include "ui/aura/client/capture_client.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/aura/window_property.h" 14 #include "ui/aura/window_property.h"
15 #include "ui/base/ui_base_types.h" 15 #include "ui/base/ui_base_types.h"
16 #include "ui/events/event.h" 16 #include "ui/events/event.h"
17 #include "ui/events/event_target.h"
17 #include "ui/views/corewm/window_animations.h" 18 #include "ui/views/corewm/window_animations.h"
18 #include "ui/views/corewm/window_util.h" 19 #include "ui/views/corewm/window_util.h"
19 20
20 namespace views { 21 namespace views {
21 namespace corewm { 22 namespace corewm {
22 23
23 // Transient child's modal parent. 24 // Transient child's modal parent.
24 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey; 25 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey;
25 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL); 26 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL);
26 27
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 aura::Window* toplevel = GetToplevelWindow(window); 89 aura::Window* toplevel = GetToplevelWindow(window);
89 if (!toplevel) 90 if (!toplevel)
90 return NULL; 91 return NULL;
91 92
92 return GetModalTransientChild(toplevel, window); 93 return GetModalTransientChild(toplevel, window);
93 } 94 }
94 95
95 //////////////////////////////////////////////////////////////////////////////// 96 ////////////////////////////////////////////////////////////////////////////////
96 // WindowModalityController, public: 97 // WindowModalityController, public:
97 98
98 WindowModalityController::WindowModalityController() { 99 WindowModalityController::WindowModalityController(
100 ui::EventTarget* event_target)
101 : event_target_(event_target) {
99 aura::Env::GetInstance()->AddObserver(this); 102 aura::Env::GetInstance()->AddObserver(this);
103 DCHECK(event_target->IsPreTargetListEmpty());
104 event_target_->AddPreTargetHandler(this);
100 } 105 }
101 106
102 WindowModalityController::~WindowModalityController() { 107 WindowModalityController::~WindowModalityController() {
108 event_target_->RemovePreTargetHandler(this);
103 aura::Env::GetInstance()->RemoveObserver(this); 109 aura::Env::GetInstance()->RemoveObserver(this);
104 for (size_t i = 0; i < windows_.size(); ++i) 110 for (size_t i = 0; i < windows_.size(); ++i)
105 windows_[i]->RemoveObserver(this); 111 windows_[i]->RemoveObserver(this);
106 } 112 }
107 113
108 //////////////////////////////////////////////////////////////////////////////// 114 ////////////////////////////////////////////////////////////////////////////////
109 // WindowModalityController, aura::EventFilter implementation: 115 // WindowModalityController, aura::EventFilter implementation:
110 116
111 void WindowModalityController::OnKeyEvent(ui::KeyEvent* event) { 117 void WindowModalityController::OnKeyEvent(ui::KeyEvent* event) {
112 aura::Window* target = static_cast<aura::Window*>(event->target()); 118 aura::Window* target = static_cast<aura::Window*>(event->target());
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 aura::Window* modal_transient_child = GetModalTransient(target); 178 aura::Window* modal_transient_child = GetModalTransient(target);
173 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED || 179 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED ||
174 event->type() == ui::ET_TOUCH_PRESSED)) { 180 event->type() == ui::ET_TOUCH_PRESSED)) {
175 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE); 181 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE);
176 } 182 }
177 return !!modal_transient_child; 183 return !!modal_transient_child;
178 } 184 }
179 185
180 } // namespace corewm 186 } // namespace corewm
181 } // namespace views 187 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698