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

Unified Diff: ui/aura/root_window.cc

Issue 7976020: Wires up mouse capture code for aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweaks 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/window.h » ('j') | ui/aura/window.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window.cc
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc
index 9c50a2cf801ca0b2bb1b779fdf28aa3e29316363..2a0d74f5b2a66d7087e0f907177e43fe869d8a21 100644
--- a/ui/aura/root_window.cc
+++ b/ui/aura/root_window.cc
@@ -15,9 +15,10 @@ namespace aura {
namespace internal {
RootWindow::RootWindow()
- : Window(NULL),
+ : Window(NULL, true),
mouse_pressed_handler_(NULL),
- ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(focus_manager_(new FocusManager(this))),
+ capture_window_(NULL) {
set_name(ASCIIToUTF16("RootWindow"));
}
@@ -25,14 +26,15 @@ RootWindow::~RootWindow() {
}
bool RootWindow::HandleMouseEvent(const MouseEvent& event) {
- Window* target = mouse_pressed_handler_;
+ Window* target =
+ mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
if (!target)
target = GetEventHandlerForPoint(event.location());
if (event.type() == ui::ET_MOUSE_PRESSED && !mouse_pressed_handler_)
mouse_pressed_handler_ = target;
if (event.type() == ui::ET_MOUSE_RELEASED)
mouse_pressed_handler_ = NULL;
- if (target->delegate()) {
+ if (target && target->delegate()) {
MouseEvent translated_event(event, this, target);
return target->OnMouseEvent(&translated_event);
}
@@ -48,6 +50,41 @@ bool RootWindow::HandleKeyEvent(const KeyEvent& event) {
return false;
}
+void RootWindow::SetCapture(Window* window) {
+ if (capture_window_ == window)
+ return;
+
+ if (capture_window_ && capture_window_->delegate())
+ capture_window_->delegate()->OnCaptureLost();
+ capture_window_ = window;
+ if (capture_window_ && capture_window_->delegate())
+ capture_window_->delegate()->OnCaptureGained();
+
+ if (capture_window_ && mouse_pressed_handler_) {
+ // Make all subsequent mouse events go to the capture window. We shouldn't
+ // need to send an event here as OnCaptureLost should take care of that.
+ mouse_pressed_handler_ = capture_window_;
+ }
+}
+
+void RootWindow::ReleaseCapture(Window* window) {
+ if (capture_window_ != window)
+ return;
+
+ if (capture_window_ && capture_window_->delegate())
+ capture_window_->delegate()->OnCaptureLost();
+ capture_window_ = NULL;
+}
+
+void RootWindow::WindowDestroying(Window* window) {
+ // When a window is being destroyed it's likely that the windows delegate
Ben Goodger (Google) 2011/09/21 04:15:21 window's WindowDelegate delegate
+ // won't want events.
+ if (mouse_pressed_handler_ == window)
+ mouse_pressed_handler_ = NULL;
+ if (capture_window_ == window)
+ capture_window_ = NULL;
+}
+
FocusManager* RootWindow::GetFocusManager() {
return focus_manager_.get();
}
« no previous file with comments | « ui/aura/root_window.h ('k') | ui/aura/window.h » ('j') | ui/aura/window.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698