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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 10543174: Aura: Add Window::MoveCursorTo() taking relative location to the window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 8 years, 6 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 | « no previous file | ui/aura/root_window.h » ('j') | ui/aura/root_window.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 if (!root_window) 708 if (!root_window)
709 return false; 709 return false;
710 710
711 if (mouse_locked_) 711 if (mouse_locked_)
712 return true; 712 return true;
713 713
714 mouse_locked_ = true; 714 mouse_locked_ = true;
715 window_->SetCapture(); 715 window_->SetCapture();
716 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); 716 aura::Env::GetInstance()->cursor_manager()->ShowCursor(false);
717 synthetic_move_sent_ = true; 717 synthetic_move_sent_ = true;
718 root_window->MoveCursorTo(window_->bounds().CenterPoint()); 718 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint());
719 if (aura::client::GetTooltipClient(root_window)) 719 if (aura::client::GetTooltipClient(root_window))
720 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); 720 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false);
721 return true; 721 return true;
722 } 722 }
723 723
724 void RenderWidgetHostViewAura::UnlockMouse() { 724 void RenderWidgetHostViewAura::UnlockMouse() {
725 aura::RootWindow* root_window = window_->GetRootWindow(); 725 aura::RootWindow* root_window = window_->GetRootWindow();
726 if (!mouse_locked_ || !root_window) 726 if (!mouse_locked_ || !root_window)
727 return; 727 return;
728 728
729 mouse_locked_ = false; 729 mouse_locked_ = false;
730 730
731 window_->ReleaseCapture(); 731 window_->ReleaseCapture();
732 root_window->MoveCursorTo(unlocked_global_mouse_position_); 732 window_->MoveCursorTo(unlocked_mouse_position_);
733 aura::Env::GetInstance()->cursor_manager()->ShowCursor(true); 733 aura::Env::GetInstance()->cursor_manager()->ShowCursor(true);
734 if (aura::client::GetTooltipClient(root_window)) 734 if (aura::client::GetTooltipClient(root_window))
735 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true); 735 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true);
736 736
737 host_->LostMouseLock(); 737 host_->LostMouseLock();
738 } 738 }
739 739
740 //////////////////////////////////////////////////////////////////////////////// 740 ////////////////////////////////////////////////////////////////////////////////
741 // RenderWidgetHostViewAura, ui::TextInputClient implementation: 741 // RenderWidgetHostViewAura, ui::TextInputClient implementation:
742 void RenderWidgetHostViewAura::SetCompositionText( 742 void RenderWidgetHostViewAura::SetCompositionText(
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 1000
1001 int RenderWidgetHostViewAura::GetNonClientComponent( 1001 int RenderWidgetHostViewAura::GetNonClientComponent(
1002 const gfx::Point& point) const { 1002 const gfx::Point& point) const {
1003 return HTCLIENT; 1003 return HTCLIENT;
1004 } 1004 }
1005 1005
1006 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { 1006 bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) {
1007 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); 1007 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent");
1008 if (mouse_locked_) { 1008 if (mouse_locked_) {
1009 WebKit::WebMouseEvent mouse_event = content::MakeWebMouseEvent(event); 1009 WebKit::WebMouseEvent mouse_event = content::MakeWebMouseEvent(event);
1010 gfx::Point center = window_->bounds().CenterPoint(); 1010 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint());
1011 1011
1012 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || 1012 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED ||
1013 event->type() == ui::ET_MOUSE_DRAGGED) && 1013 event->type() == ui::ET_MOUSE_DRAGGED) &&
1014 mouse_event.globalX == center.x() && mouse_event.globalY == center.y(); 1014 mouse_event.x == center.x() && mouse_event.y == center.y();
1015 1015
1016 ModifyEventMovementAndCoords(&mouse_event); 1016 ModifyEventMovementAndCoords(&mouse_event);
1017 1017
1018 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; 1018 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_;
1019 if (should_not_forward) { 1019 if (should_not_forward) {
1020 synthetic_move_sent_ = false; 1020 synthetic_move_sent_ = false;
1021 } else { 1021 } else {
1022 // Check if the mouse has reached the border and needs to be centered. 1022 // Check if the mouse has reached the border and needs to be centered.
1023 if (ShouldMoveToCenter()) { 1023 if (ShouldMoveToCenter()) {
1024 synthetic_move_sent_ = true; 1024 synthetic_move_sent_ = true;
1025 window_->GetRootWindow()->MoveCursorTo(center); 1025 window_->MoveCursorTo(center);
1026 } 1026 }
1027 1027
1028 // Forward event to renderer. 1028 // Forward event to renderer.
1029 if (CanRendererHandleEvent(event)) 1029 if (CanRendererHandleEvent(event))
1030 host_->ForwardMouseEvent(mouse_event); 1030 host_->ForwardMouseEvent(mouse_event);
1031 } 1031 }
1032 1032
1033 return false; 1033 return false;
1034 } 1034 }
1035 1035
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1374 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( 1374 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget(
1375 RenderWidgetHost* widget) { 1375 RenderWidgetHost* widget) {
1376 return new RenderWidgetHostViewAura(widget); 1376 return new RenderWidgetHostViewAura(widget);
1377 } 1377 }
1378 1378
1379 // static 1379 // static
1380 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( 1380 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo(
1381 WebKit::WebScreenInfo* results) { 1381 WebKit::WebScreenInfo* results) {
1382 GetScreenInfoForWindow(results, NULL); 1382 GetScreenInfoForWindow(results, NULL);
1383 } 1383 }
OLDNEW
« no previous file with comments | « no previous file | ui/aura/root_window.h » ('j') | ui/aura/root_window.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698