blob: 91ffe9b75118c1ebff715c896a3971bf0ee700a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/window_modality_controller.h"
#include "ash/wm/window_util.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/event.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
namespace ash {
namespace wm {
namespace {
bool TransientChildIsWindowModal(aura::Window* window) {
return window->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_WINDOW;
}
aura::Window* GetWindowModalTransientChild(aura::Window* window) {
aura::Window::Windows::const_iterator it;
for (it = window->transient_children().begin();
it != window->transient_children().end();
++it) {
if (TransientChildIsWindowModal(*it) && (*it)->IsVisible()) {
if (!(*it)->transient_children().empty())
return GetWindowModalTransientChild(*it);
return *it;
}
}
return NULL;
}
} // namespace
aura::Window* GetWindowModalTransient(aura::Window* window) {
if (!window)
return NULL;
// We always want to check the for the transient child of the activatable
// window.
window = wm::GetActivatableWindow(window);
if (!window)
return NULL;
return GetWindowModalTransientChild(window);
}
} // namespace wm
namespace internal {
////////////////////////////////////////////////////////////////////////////////
// WindowModalityController, public:
WindowModalityController::WindowModalityController() {
}
WindowModalityController::~WindowModalityController() {
}
////////////////////////////////////////////////////////////////////////////////
// WindowModalityController, aura::EventFilter implementation:
bool WindowModalityController::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
return !!wm::GetWindowModalTransient(target);
}
bool WindowModalityController::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
aura::Window* modal_transient_child = wm::GetWindowModalTransient(target);
if (modal_transient_child && event->type() == ui::ET_MOUSE_PRESSED)
wm::ActivateWindow(modal_transient_child);
return !!modal_transient_child;
}
ui::TouchStatus WindowModalityController::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
// TODO: make touch work with modals.
return ui::TOUCH_STATUS_UNKNOWN;
}
ui::GestureStatus WindowModalityController::PreHandleGestureEvent(
aura::Window* target,
aura::GestureEvent* event) {
// TODO: make gestures work with modals.
return ui::GESTURE_STATUS_UNKNOWN;
}
} // namespace internal
} // namespace ash
|