blob: b3daff1e2b9fbbdc4084db365379f86cda2f7c69 (
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
|
// 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 internal {
namespace {
bool TransientChildIsWindowModal(aura::Window* window) {
return window->GetIntProperty(aura::client::kModalKey) ==
ui::MODAL_TYPE_WINDOW;
}
}
////////////////////////////////////////////////////////////////////////////////
// WindowModalityController, public:
WindowModalityController::WindowModalityController() {
}
WindowModalityController::~WindowModalityController() {
}
aura::Window* WindowModalityController::GetWindowModalTransient(
aura::Window* window) {
if (!window)
return NULL;
aura::Window::Windows::const_iterator it;
for (it = window->transient_children().begin();
it != window->transient_children().end();
++it) {
if (TransientChildIsWindowModal(*it)) {
if (!(*it)->transient_children().empty())
return GetWindowModalTransient(*it);
return *it;
}
}
return NULL;
}
////////////////////////////////////////////////////////////////////////////////
// WindowModalityController, aura::EventFilter implementation:
bool WindowModalityController::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
return !!GetWindowModalTransient(target);
}
bool WindowModalityController::PreHandleMouseEvent(aura::Window* target,
aura::MouseEvent* event) {
aura::Window* modal_transient_child = GetWindowModalTransient(target);
if (modal_transient_child && event->type() == ui::ET_MOUSE_PRESSED)
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
|