Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 64 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 65 #include "ui/base/hit_test.h" | 65 #include "ui/base/hit_test.h" |
| 66 #include "ui/base/ime/input_method.h" | 66 #include "ui/base/ime/input_method.h" |
| 67 #include "ui/base/ui_base_types.h" | 67 #include "ui/base/ui_base_types.h" |
| 68 #include "ui/compositor/layer.h" | 68 #include "ui/compositor/layer.h" |
| 69 #include "ui/events/event.h" | 69 #include "ui/events/event.h" |
| 70 #include "ui/events/event_utils.h" | 70 #include "ui/events/event_utils.h" |
| 71 #include "ui/events/gestures/gesture_recognizer.h" | 71 #include "ui/events/gestures/gesture_recognizer.h" |
| 72 #include "ui/gfx/canvas.h" | 72 #include "ui/gfx/canvas.h" |
| 73 #include "ui/gfx/display.h" | 73 #include "ui/gfx/display.h" |
| 74 #include "ui/gfx/rect.h" | |
| 74 #include "ui/gfx/rect_conversions.h" | 75 #include "ui/gfx/rect_conversions.h" |
| 75 #include "ui/gfx/screen.h" | 76 #include "ui/gfx/screen.h" |
| 76 #include "ui/gfx/size_conversions.h" | 77 #include "ui/gfx/size_conversions.h" |
| 77 #include "ui/gfx/skia_util.h" | 78 #include "ui/gfx/skia_util.h" |
| 78 | 79 |
| 79 #if defined(OS_WIN) | 80 #if defined(OS_WIN) |
| 80 #include "base/win/windows_version.h" | 81 #include "base/win/windows_version.h" |
| 81 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 82 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 82 #include "content/browser/accessibility/browser_accessibility_win.h" | 83 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 83 #include "ui/base/win/hidden_window.h" | 84 #include "ui/base/win/hidden_window.h" |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2187 cursor_client->HideCursor(); | 2188 cursor_client->HideCursor(); |
| 2188 cursor_client->LockCursor(); | 2189 cursor_client->LockCursor(); |
| 2189 } | 2190 } |
| 2190 | 2191 |
| 2191 if (ShouldMoveToCenter()) { | 2192 if (ShouldMoveToCenter()) { |
| 2192 synthetic_move_sent_ = true; | 2193 synthetic_move_sent_ = true; |
| 2193 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); | 2194 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); |
| 2194 } | 2195 } |
| 2195 if (aura::client::GetTooltipClient(root_window)) | 2196 if (aura::client::GetTooltipClient(root_window)) |
| 2196 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); | 2197 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); |
| 2198 #if defined(OS_WIN) | |
| 2199 RECT window_rect = window_->GetBoundsInScreen().ToRECT(); | |
| 2200 ::ClipCursor(&window_rect); | |
|
scheib
2013/10/30 18:16:45
Yes, clipping to the window is necessary. It's als
ananta
2013/10/30 20:47:29
Good point. We have the ConfineCursorToWindow and
| |
| 2201 #endif | |
| 2197 return true; | 2202 return true; |
| 2198 } | 2203 } |
| 2199 | 2204 |
| 2200 void RenderWidgetHostViewAura::UnlockMouse() { | 2205 void RenderWidgetHostViewAura::UnlockMouse() { |
| 2201 aura::Window* root_window = window_->GetRootWindow(); | 2206 aura::Window* root_window = window_->GetRootWindow(); |
| 2202 if (!mouse_locked_ || !root_window) | 2207 if (!mouse_locked_ || !root_window) |
| 2203 return; | 2208 return; |
| 2204 | 2209 |
| 2205 mouse_locked_ = false; | 2210 mouse_locked_ = false; |
| 2206 | 2211 |
| 2207 #if !defined(OS_WIN) | 2212 #if !defined(OS_WIN) |
| 2208 window_->ReleaseCapture(); | 2213 window_->ReleaseCapture(); |
| 2209 #endif | 2214 #endif |
| 2210 window_->MoveCursorTo(unlocked_mouse_position_); | 2215 window_->MoveCursorTo(unlocked_mouse_position_); |
| 2211 aura::client::CursorClient* cursor_client = | 2216 aura::client::CursorClient* cursor_client = |
| 2212 aura::client::GetCursorClient(root_window); | 2217 aura::client::GetCursorClient(root_window); |
| 2213 if (cursor_client) { | 2218 if (cursor_client) { |
| 2214 cursor_client->UnlockCursor(); | 2219 cursor_client->UnlockCursor(); |
| 2215 cursor_client->ShowCursor(); | 2220 cursor_client->ShowCursor(); |
| 2216 } | 2221 } |
| 2217 | 2222 |
| 2218 if (aura::client::GetTooltipClient(root_window)) | 2223 if (aura::client::GetTooltipClient(root_window)) |
| 2219 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true); | 2224 aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true); |
| 2220 | 2225 |
| 2226 #if defined(OS_WIN) | |
| 2227 ::ClipCursor(NULL); | |
| 2228 #endif | |
| 2221 host_->LostMouseLock(); | 2229 host_->LostMouseLock(); |
| 2222 } | 2230 } |
| 2223 | 2231 |
| 2224 //////////////////////////////////////////////////////////////////////////////// | 2232 //////////////////////////////////////////////////////////////////////////////// |
| 2225 // RenderWidgetHostViewAura, ui::TextInputClient implementation: | 2233 // RenderWidgetHostViewAura, ui::TextInputClient implementation: |
| 2226 void RenderWidgetHostViewAura::SetCompositionText( | 2234 void RenderWidgetHostViewAura::SetCompositionText( |
| 2227 const ui::CompositionText& composition) { | 2235 const ui::CompositionText& composition) { |
| 2228 if (!host_) | 2236 if (!host_) |
| 2229 return; | 2237 return; |
| 2230 | 2238 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2723 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); | 2731 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); |
| 2724 | 2732 |
| 2725 if (event->type() == ui::ET_MOUSEWHEEL) { | 2733 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 2726 WebKit::WebMouseWheelEvent mouse_wheel_event = | 2734 WebKit::WebMouseWheelEvent mouse_wheel_event = |
| 2727 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 2735 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
| 2728 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 2736 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 2729 host_->ForwardWheelEvent(mouse_wheel_event); | 2737 host_->ForwardWheelEvent(mouse_wheel_event); |
| 2730 return; | 2738 return; |
| 2731 } | 2739 } |
| 2732 | 2740 |
| 2741 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | |
| 2742 | |
| 2743 // If we receive non client mouse messages while we are in the locked state | |
| 2744 // it probably means that the mouse left the borders of our window and | |
| 2745 // needs to be moved back to the center. | |
| 2746 if (event->flags() & ui::EF_IS_NON_CLIENT) { | |
|
scheib
2013/10/30 18:16:45
I can't comment here because I don't understand NO
| |
| 2747 synthetic_move_sent_ = true; | |
| 2748 window_->MoveCursorTo(center); | |
| 2749 return; | |
| 2750 } | |
| 2751 | |
| 2733 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 2752 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 2734 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | |
| 2735 | 2753 |
| 2736 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 2754 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || |
| 2737 event->type() == ui::ET_MOUSE_DRAGGED) && | 2755 event->type() == ui::ET_MOUSE_DRAGGED) && |
| 2738 mouse_event.x == center.x() && mouse_event.y == center.y(); | 2756 mouse_event.x == center.x() && mouse_event.y == center.y(); |
| 2739 | 2757 |
| 2740 ModifyEventMovementAndCoords(&mouse_event); | 2758 ModifyEventMovementAndCoords(&mouse_event); |
| 2741 | 2759 |
| 2742 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 2760 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; |
| 2743 if (should_not_forward) { | 2761 if (should_not_forward) { |
| 2744 synthetic_move_sent_ = false; | 2762 synthetic_move_sent_ = false; |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3425 RenderWidgetHost* widget) { | 3443 RenderWidgetHost* widget) { |
| 3426 return new RenderWidgetHostViewAura(widget); | 3444 return new RenderWidgetHostViewAura(widget); |
| 3427 } | 3445 } |
| 3428 | 3446 |
| 3429 // static | 3447 // static |
| 3430 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3448 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3431 GetScreenInfoForWindow(results, NULL); | 3449 GetScreenInfoForWindow(results, NULL); |
| 3432 } | 3450 } |
| 3433 | 3451 |
| 3434 } // namespace content | 3452 } // namespace content |
| OLD | NEW |