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