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

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

Issue 11316287: Move WindowModalityController to CoreWm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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
« no previous file with comments | « ui/views/corewm/window_modality_controller.h ('k') | ui/views/test/capture_tracking_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/wm/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/events/event.h" 15 #include "ui/base/events/event.h"
16 #include "ui/base/ui_base_types.h" 16 #include "ui/base/ui_base_types.h"
17 #include "ui/views/corewm/window_animations.h" 17 #include "ui/views/corewm/window_animations.h"
18 #include "ui/views/corewm/window_util.h" 18 #include "ui/views/corewm/window_util.h"
19 19
20 namespace ash { 20 namespace views {
21 namespace corewm {
21 22
22 // Transient child's modal parent. 23 // Transient child's modal parent.
23 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey; 24 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey;
24 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL); 25 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL);
25 26
26 namespace { 27 namespace {
27 28
28 bool HasAncestor(aura::Window* window, aura::Window* ancestor) { 29 bool HasAncestor(aura::Window* window, aura::Window* ancestor) {
29 if (!window) 30 if (!window)
30 return false; 31 return false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 void SetModalParent(aura::Window* child, aura::Window* parent) { 74 void SetModalParent(aura::Window* child, aura::Window* parent) {
74 child->SetProperty(kModalParentKey, parent); 75 child->SetProperty(kModalParentKey, parent);
75 } 76 }
76 77
77 aura::Window* GetModalTransient(aura::Window* window) { 78 aura::Window* GetModalTransient(aura::Window* window) {
78 if (!window) 79 if (!window)
79 return NULL; 80 return NULL;
80 81
81 // We always want to check the for the transient child of the activatable 82 // We always want to check the for the transient child of the activatable
82 // window. 83 // window.
83 aura::Window* activatable = views::corewm::GetActivatableWindow(window); 84 aura::Window* activatable = GetActivatableWindow(window);
84 if (!activatable) 85 if (!activatable)
85 return NULL; 86 return NULL;
86 87
87 return GetModalTransientChild(activatable, window); 88 return GetModalTransientChild(activatable, window);
88 } 89 }
89 90
90 namespace internal {
91
92 //////////////////////////////////////////////////////////////////////////////// 91 ////////////////////////////////////////////////////////////////////////////////
93 // WindowModalityController, public: 92 // WindowModalityController, public:
94 93
95 WindowModalityController::WindowModalityController() { 94 WindowModalityController::WindowModalityController() {
96 aura::Env::GetInstance()->AddObserver(this); 95 aura::Env::GetInstance()->AddObserver(this);
97 } 96 }
98 97
99 WindowModalityController::~WindowModalityController() { 98 WindowModalityController::~WindowModalityController() {
100 aura::Env::GetInstance()->RemoveObserver(this); 99 aura::Env::GetInstance()->RemoveObserver(this);
101 for (size_t i = 0; i < windows_.size(); ++i) 100 for (size_t i = 0; i < windows_.size(); ++i)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void WindowModalityController::OnWindowDestroyed(aura::Window* window) { 142 void WindowModalityController::OnWindowDestroyed(aura::Window* window) {
144 windows_.erase(std::find(windows_.begin(), windows_.end(), window)); 143 windows_.erase(std::find(windows_.begin(), windows_.end(), window));
145 window->RemoveObserver(this); 144 window->RemoveObserver(this);
146 } 145 }
147 146
148 bool WindowModalityController::ProcessLocatedEvent(aura::Window* target, 147 bool WindowModalityController::ProcessLocatedEvent(aura::Window* target,
149 ui::LocatedEvent* event) { 148 ui::LocatedEvent* event) {
150 aura::Window* modal_transient_child = GetModalTransient(target); 149 aura::Window* modal_transient_child = GetModalTransient(target);
151 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED || 150 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED ||
152 event->type() == ui::ET_TOUCH_PRESSED)) { 151 event->type() == ui::ET_TOUCH_PRESSED)) {
153 views::corewm::AnimateWindow(modal_transient_child, 152 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE);
154 views::corewm::WINDOW_ANIMATION_TYPE_BOUNCE);
155 } 153 }
156 return !!modal_transient_child; 154 return !!modal_transient_child;
157 } 155 }
158 156
159 } // namespace internal 157 } // namespace corewm
160 } // namespace ash 158 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/window_modality_controller.h ('k') | ui/views/test/capture_tracking_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698