OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura/root_window.h" | 5 #include "ui/aura/root_window.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
9 #include "ui/aura/focus_manager.h" | 9 #include "ui/aura/focus_manager.h" |
10 #include "ui/aura/window_delegate.h" | 10 #include "ui/aura/window_delegate.h" |
11 #include "ui/base/events.h" | 11 #include "ui/base/events.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 RootWindow::RootWindow() | 16 RootWindow::RootWindow() |
17 : Window(NULL), | 17 : Window(NULL), |
18 mouse_pressed_handler_(NULL), | 18 mouse_pressed_handler_(NULL), |
19 ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))) { | 19 ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))) { |
| 20 set_name(L"RootWindow"); |
20 } | 21 } |
21 | 22 |
22 RootWindow::~RootWindow() { | 23 RootWindow::~RootWindow() { |
23 } | 24 } |
24 | 25 |
25 bool RootWindow::HandleMouseEvent(const MouseEvent& event) { | 26 bool RootWindow::HandleMouseEvent(const MouseEvent& event) { |
26 Window* target = mouse_pressed_handler_; | 27 Window* target = mouse_pressed_handler_; |
27 if (!target) | 28 if (!target) |
28 target = GetEventHandlerForPoint(event.location()); | 29 target = GetEventHandlerForPoint(event.location()); |
29 if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_) | 30 if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_) |
30 mouse_pressed_handler_ = target; | 31 mouse_pressed_handler_ = target; |
31 if (event.type() == ui::ET_MOUSE_RELEASED) | 32 if (event.type() == ui::ET_MOUSE_RELEASED) |
32 mouse_pressed_handler_ = NULL; | 33 mouse_pressed_handler_ = NULL; |
33 if (target->delegate()) { | 34 if (target->delegate()) { |
34 MouseEvent translated_event(event, this, target); | 35 MouseEvent translated_event(event, this, target); |
35 return target->OnMouseEvent(&translated_event); | 36 return target->OnMouseEvent(&translated_event); |
36 } | 37 } |
37 return false; | 38 return false; |
38 } | 39 } |
39 | 40 |
40 bool RootWindow::HandleKeyEvent(const KeyEvent& event) { | 41 bool RootWindow::HandleKeyEvent(const KeyEvent& event) { |
41 Window* focused_window = GetFocusManager()->focused_window(); | 42 Window* focused_window = GetFocusManager()->focused_window(); |
42 if (focused_window) { | 43 if (focused_window) { |
43 KeyEvent translated_event(event); | 44 KeyEvent translated_event(event); |
44 return GetFocusManager()->focused_window()->OnKeyEvent(&translated_event); | 45 return GetFocusManager()->focused_window()->OnKeyEvent(&translated_event); |
45 } | 46 } |
46 return false; | 47 return false; |
47 } | 48 } |
48 | 49 |
49 bool RootWindow::IsTopLevelWindowContainer() const { | |
50 return true; | |
51 } | |
52 | |
53 FocusManager* RootWindow::GetFocusManager() { | 50 FocusManager* RootWindow::GetFocusManager() { |
54 return focus_manager_.get(); | 51 return focus_manager_.get(); |
55 } | 52 } |
56 | 53 |
57 } // namespace internal | 54 } // namespace internal |
58 } // namespace aura | 55 } // namespace aura |
OLD | NEW |