| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/root_view.h" | 5 #include "chrome/views/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base_drag_source.h" | 9 #include "base/base_drag_source.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 316 |
| 317 if (focus_on_mouse_pressed_) { | 317 if (focus_on_mouse_pressed_) { |
| 318 HWND hwnd = view_container_->GetHWND(); | 318 HWND hwnd = view_container_->GetHWND(); |
| 319 if (::GetFocus() != hwnd) { | 319 if (::GetFocus() != hwnd) { |
| 320 ::SetFocus(hwnd); | 320 ::SetFocus(hwnd); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 return hit_disabled_view; | 323 return hit_disabled_view; |
| 324 } | 324 } |
| 325 | 325 |
| 326 bool RootView::ConvertPointToMouseHandler(const CPoint &l, CPoint *p) { | 326 bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, |
| 327 gfx::Point* p) { |
| 327 // | 328 // |
| 328 // If the mouse_handler was set explicitly, we need to keep | 329 // If the mouse_handler was set explicitly, we need to keep |
| 329 // sending events even if it was reparented in a different | 330 // sending events even if it was reparented in a different |
| 330 // window. (a non explicit mouse handler is automatically | 331 // window. (a non explicit mouse handler is automatically |
| 331 // cleared when the control is removed from the hierarchy) | 332 // cleared when the control is removed from the hierarchy) |
| 332 if (explicit_mouse_handler_) { | 333 if (explicit_mouse_handler_) { |
| 333 if (mouse_pressed_handler_->GetViewContainer()) { | 334 if (mouse_pressed_handler_->GetViewContainer()) { |
| 334 *p = l; | 335 *p = l; |
| 335 ConvertPointToScreen(this, p); | 336 ConvertPointToScreen(this, p); |
| 336 ConvertPointToView(NULL, mouse_pressed_handler_, p); | 337 ConvertPointToView(NULL, mouse_pressed_handler_, p); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 347 } | 348 } |
| 348 return true; | 349 return true; |
| 349 } | 350 } |
| 350 | 351 |
| 351 bool RootView::OnMouseDragged(const MouseEvent& e) { | 352 bool RootView::OnMouseDragged(const MouseEvent& e) { |
| 352 UpdateCursor(e); | 353 UpdateCursor(e); |
| 353 | 354 |
| 354 if (mouse_pressed_handler_) { | 355 if (mouse_pressed_handler_) { |
| 355 SetMouseLocationAndFlags(e); | 356 SetMouseLocationAndFlags(e); |
| 356 | 357 |
| 357 CPoint p; | 358 gfx::Point p; |
| 358 ConvertPointToMouseHandler(WTL::CPoint(e.x(), e.y()), &p); | 359 ConvertPointToMouseHandler(e.location(), &p); |
| 359 MouseEvent mouse_event(e.GetType(), p.x, p.y, e.GetFlags()); | 360 MouseEvent mouse_event(e.GetType(), p.x(), p.y(), e.GetFlags()); |
| 360 if (!mouse_pressed_handler_->ProcessMouseDragged(mouse_event, | 361 if (!mouse_pressed_handler_->ProcessMouseDragged(mouse_event, |
| 361 &drag_info)) { | 362 &drag_info)) { |
| 362 mouse_pressed_handler_ = NULL; | 363 mouse_pressed_handler_ = NULL; |
| 363 return false; | 364 return false; |
| 364 } else { | 365 } else { |
| 365 return true; | 366 return true; |
| 366 } | 367 } |
| 367 } | 368 } |
| 368 return false; | 369 return false; |
| 369 } | 370 } |
| 370 | 371 |
| 371 void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) { | 372 void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) { |
| 372 UpdateCursor(e); | 373 UpdateCursor(e); |
| 373 | 374 |
| 374 if (mouse_pressed_handler_) { | 375 if (mouse_pressed_handler_) { |
| 375 CPoint p; | 376 gfx::Point p; |
| 376 ConvertPointToMouseHandler(WTL::CPoint(e.x(), e.y()), &p); | 377 ConvertPointToMouseHandler(e.location(), &p); |
| 377 MouseEvent mouse_released(e.GetType(), p.x, p.y, e.GetFlags()); | 378 MouseEvent mouse_released(e.GetType(), p.x(), p.y(), e.GetFlags()); |
| 378 // We allow the view to delete us from ProcessMouseReleased. As such, | 379 // We allow the view to delete us from ProcessMouseReleased. As such, |
| 379 // configure state such that we're done first, then call View. | 380 // configure state such that we're done first, then call View. |
| 380 View* mouse_pressed_handler = mouse_pressed_handler_; | 381 View* mouse_pressed_handler = mouse_pressed_handler_; |
| 381 mouse_pressed_handler_ = NULL; | 382 mouse_pressed_handler_ = NULL; |
| 382 explicit_mouse_handler_ = false; | 383 explicit_mouse_handler_ = false; |
| 383 mouse_pressed_handler->ProcessMouseReleased(mouse_released, canceled); | 384 mouse_pressed_handler->ProcessMouseReleased(mouse_released, canceled); |
| 384 // WARNING: we may have been deleted. | 385 // WARNING: we may have been deleted. |
| 385 } | 386 } |
| 386 } | 387 } |
| 387 | 388 |
| 388 void RootView::UpdateCursor(const MouseEvent& e) { | 389 void RootView::UpdateCursor(const MouseEvent& e) { |
| 389 View *v = GetViewForPoint(WTL::CPoint(e.x(), e.y())); | 390 View *v = GetViewForPoint(e.location().ToPOINT()); |
| 390 | 391 |
| 391 if (v && v != this) { | 392 if (v && v != this) { |
| 392 CPoint l(e.x(), e.y()); | 393 gfx::Point l(e.location()); |
| 393 View::ConvertPointToView(this, v, &l); | 394 View::ConvertPointToView(this, v, &l); |
| 394 HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x, l.y); | 395 HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y()); |
| 395 if (cursor) { | 396 if (cursor) { |
| 396 ::SetCursor(cursor); | 397 ::SetCursor(cursor); |
| 397 return; | 398 return; |
| 398 } | 399 } |
| 399 } | 400 } |
| 400 if (previous_cursor_) { | 401 if (previous_cursor_) { |
| 401 SetCursor(previous_cursor_); | 402 SetCursor(previous_cursor_); |
| 402 } | 403 } |
| 403 } | 404 } |
| 404 | 405 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 drag_view->OnDragDone(); | 962 drag_view->OnDragDone(); |
| 962 } | 963 } |
| 963 } | 964 } |
| 964 | 965 |
| 965 View* RootView::GetDragView() { | 966 View* RootView::GetDragView() { |
| 966 return drag_view_; | 967 return drag_view_; |
| 967 } | 968 } |
| 968 | 969 |
| 969 } | 970 } |
| 970 | 971 |
| OLD | NEW |