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

Side by Side Diff: ui/aura/root_window.cc

Issue 7983039: Add support for MouseEnter/MouseExit event types to be sent to aura::Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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/aura/root_window.h ('k') | ui/aura/window_unittest.cc » ('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) 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 "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/aura/event.h" 9 #include "ui/aura/event.h"
10 #include "ui/aura/focus_manager.h" 10 #include "ui/aura/focus_manager.h"
11 #include "ui/aura/window_delegate.h" 11 #include "ui/aura/window_delegate.h"
12 #include "ui/base/events.h" 12 #include "ui/base/events.h"
13 13
14 namespace aura { 14 namespace aura {
15 namespace internal { 15 namespace internal {
16 16
17 RootWindow::RootWindow() 17 RootWindow::RootWindow()
18 : Window(NULL), 18 : Window(NULL),
19 mouse_pressed_handler_(NULL), 19 mouse_pressed_handler_(NULL),
20 mouse_moved_handler_(NULL),
20 ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))), 21 ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))),
21 capture_window_(NULL) { 22 capture_window_(NULL) {
22 set_name(ASCIIToUTF16("RootWindow")); 23 set_name(ASCIIToUTF16("RootWindow"));
23 } 24 }
24 25
25 RootWindow::~RootWindow() { 26 RootWindow::~RootWindow() {
26 } 27 }
27 28
28 bool RootWindow::HandleMouseEvent(const MouseEvent& event) { 29 bool RootWindow::HandleMouseEvent(const MouseEvent& event) {
29 Window* target = 30 Window* target =
30 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; 31 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
31 if (!target) 32 if (!target)
32 target = GetEventHandlerForPoint(event.location()); 33 target = GetEventHandlerForPoint(event.location());
33 if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_) 34 switch (event.type()) {
34 mouse_pressed_handler_ = target; 35 case ui::ET_MOUSE_MOVED:
35 if (event.type() == ui::ET_MOUSE_RELEASED) 36 HandleMouseMoved(event, target);
36 mouse_pressed_handler_ = NULL; 37 break;
38 case ui::ET_MOUSE_PRESSED:
39 if (!mouse_pressed_handler_)
40 mouse_pressed_handler_ = target;
41 break;
42 case ui::ET_MOUSE_RELEASED:
43 mouse_pressed_handler_ = NULL;
44 break;
45 default:
46 break;
47 }
37 if (target && target->delegate()) { 48 if (target && target->delegate()) {
38 MouseEvent translated_event(event, this, target); 49 MouseEvent translated_event(event, this, target);
39 return target->OnMouseEvent(&translated_event); 50 return target->OnMouseEvent(&translated_event);
40 } 51 }
41 return false; 52 return false;
42 } 53 }
43 54
44 bool RootWindow::HandleKeyEvent(const KeyEvent& event) { 55 bool RootWindow::HandleKeyEvent(const KeyEvent& event) {
45 Window* focused_window = GetFocusManager()->focused_window(); 56 Window* focused_window = GetFocusManager()->focused_window();
46 if (focused_window) { 57 if (focused_window) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Update the FocusManager if the window was focused. 89 // Update the FocusManager if the window was focused.
79 internal::FocusManager* focus_manager = GetFocusManager(); 90 internal::FocusManager* focus_manager = GetFocusManager();
80 if (focus_manager && focus_manager->focused_window() == window) 91 if (focus_manager && focus_manager->focused_window() == window)
81 focus_manager->SetFocusedWindow(NULL); 92 focus_manager->SetFocusedWindow(NULL);
82 93
83 // When a window is being destroyed it's likely that the WindowDelegate won't 94 // When a window is being destroyed it's likely that the WindowDelegate won't
84 // want events, so we reset the mouse_pressed_handler_ and capture_window_ and 95 // want events, so we reset the mouse_pressed_handler_ and capture_window_ and
85 // don't sent it release/capture lost events. 96 // don't sent it release/capture lost events.
86 if (mouse_pressed_handler_ == window) 97 if (mouse_pressed_handler_ == window)
87 mouse_pressed_handler_ = NULL; 98 mouse_pressed_handler_ = NULL;
99 if (mouse_moved_handler_ == window)
100 mouse_moved_handler_ = NULL;
88 if (capture_window_ == window) 101 if (capture_window_ == window)
89 capture_window_ = NULL; 102 capture_window_ = NULL;
90 } 103 }
91 104
92 FocusManager* RootWindow::GetFocusManager() { 105 FocusManager* RootWindow::GetFocusManager() {
93 return focus_manager_.get(); 106 return focus_manager_.get();
94 } 107 }
95 108
96 internal::RootWindow* RootWindow::GetRoot() { 109 internal::RootWindow* RootWindow::GetRoot() {
97 return this; 110 return this;
98 } 111 }
99 112
113 void RootWindow::HandleMouseMoved(const MouseEvent& event, Window* target) {
114 if (target == mouse_moved_handler_)
115 return;
116
117 // Send an exited event.
118 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
119 MouseEvent translated_event(event, this, mouse_moved_handler_,
120 ui::ET_MOUSE_EXITED);
121 mouse_moved_handler_->OnMouseEvent(&translated_event);
122 }
123 mouse_moved_handler_ = target;
124 // Send an entered event.
125 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
126 MouseEvent translated_event(event, this, mouse_moved_handler_,
127 ui::ET_MOUSE_ENTERED);
128 mouse_moved_handler_->OnMouseEvent(&translated_event);
129 }
130 }
131
100 } // namespace internal 132 } // namespace internal
101 } // namespace aura 133 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698