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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2263 aura::Window* root_window = window_->GetRootWindow(); | 2263 aura::Window* root_window = window_->GetRootWindow(); |
| 2264 if (!root_window) | 2264 if (!root_window) |
| 2265 return false; | 2265 return false; |
| 2266 | 2266 |
| 2267 if (mouse_locked_) | 2267 if (mouse_locked_) |
| 2268 return true; | 2268 return true; |
| 2269 | 2269 |
| 2270 mouse_locked_ = true; | 2270 mouse_locked_ = true; |
| 2271 #if !defined(OS_WIN) | 2271 #if !defined(OS_WIN) |
| 2272 window_->SetCapture(); | 2272 window_->SetCapture(); |
| 2273 #else | |
| 2274 if (gfx::Screen::GetScreenFor(window_) == | |
| 2275 gfx::Screen::GetNativeScreen()) { | |
| 2276 RECT window_rect = window_->GetBoundsInScreen().ToRECT(); | |
| 2277 ::ClipCursor(&window_rect); | |
| 2278 } | |
| 2273 #endif | 2279 #endif |
| 2274 aura::client::CursorClient* cursor_client = | 2280 aura::client::CursorClient* cursor_client = |
| 2275 aura::client::GetCursorClient(root_window); | 2281 aura::client::GetCursorClient(root_window); |
| 2276 if (cursor_client) { | 2282 if (cursor_client) { |
| 2277 cursor_client->HideCursor(); | 2283 cursor_client->HideCursor(); |
| 2278 cursor_client->LockCursor(); | 2284 cursor_client->LockCursor(); |
| 2279 } | 2285 } |
| 2280 | 2286 |
| 2281 if (ShouldMoveToCenter()) { | 2287 if (ShouldMoveToCenter()) { |
| 2282 synthetic_move_sent_ = true; | 2288 synthetic_move_sent_ = true; |
| 2283 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); | 2289 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); |
| 2284 } | 2290 } |
| 2285 tooltip_disabler_.reset(new aura::client::ScopedTooltipDisabler(root_window)); | 2291 tooltip_disabler_.reset(new aura::client::ScopedTooltipDisabler(root_window)); |
| 2286 | |
| 2287 root_window->GetHost()->ConfineCursorToRootWindow(); | |
|
oshima
2014/03/26 00:56:03
This was added in https://codereview.chromium.org/
Ben Goodger (Google)
2014/03/26 05:11:08
Maybe peel this out as a separate CL?
| |
| 2288 return true; | 2292 return true; |
| 2289 } | 2293 } |
| 2290 | 2294 |
| 2291 void RenderWidgetHostViewAura::UnlockMouse() { | 2295 void RenderWidgetHostViewAura::UnlockMouse() { |
| 2292 tooltip_disabler_.reset(); | 2296 tooltip_disabler_.reset(); |
| 2293 | 2297 |
| 2294 aura::Window* root_window = window_->GetRootWindow(); | 2298 aura::Window* root_window = window_->GetRootWindow(); |
| 2295 if (!mouse_locked_ || !root_window) | 2299 if (!mouse_locked_ || !root_window) |
| 2296 return; | 2300 return; |
| 2297 | 2301 |
| 2298 mouse_locked_ = false; | 2302 mouse_locked_ = false; |
| 2299 | 2303 |
| 2300 #if !defined(OS_WIN) | 2304 #if !defined(OS_WIN) |
| 2301 window_->ReleaseCapture(); | 2305 window_->ReleaseCapture(); |
| 2306 #else | |
| 2307 ::ClipCursor(NULL); | |
| 2302 #endif | 2308 #endif |
| 2303 window_->MoveCursorTo(unlocked_mouse_position_); | 2309 window_->MoveCursorTo(unlocked_mouse_position_); |
| 2304 aura::client::CursorClient* cursor_client = | 2310 aura::client::CursorClient* cursor_client = |
| 2305 aura::client::GetCursorClient(root_window); | 2311 aura::client::GetCursorClient(root_window); |
| 2306 if (cursor_client) { | 2312 if (cursor_client) { |
| 2307 cursor_client->UnlockCursor(); | 2313 cursor_client->UnlockCursor(); |
| 2308 cursor_client->ShowCursor(); | 2314 cursor_client->ShowCursor(); |
| 2309 } | 2315 } |
| 2310 | 2316 |
| 2311 host_->LostMouseLock(); | 2317 host_->LostMouseLock(); |
| 2312 root_window->GetHost()->UnConfineCursor(); | |
| 2313 } | 2318 } |
| 2314 | 2319 |
| 2315 //////////////////////////////////////////////////////////////////////////////// | 2320 //////////////////////////////////////////////////////////////////////////////// |
| 2316 // RenderWidgetHostViewAura, ui::TextInputClient implementation: | 2321 // RenderWidgetHostViewAura, ui::TextInputClient implementation: |
| 2317 void RenderWidgetHostViewAura::SetCompositionText( | 2322 void RenderWidgetHostViewAura::SetCompositionText( |
| 2318 const ui::CompositionText& composition) { | 2323 const ui::CompositionText& composition) { |
| 2319 if (!host_) | 2324 if (!host_) |
| 2320 return; | 2325 return; |
| 2321 | 2326 |
| 2322 // ui::CompositionUnderline should be identical to | 2327 // ui::CompositionUnderline should be identical to |
| (...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3615 RenderWidgetHost* widget) { | 3620 RenderWidgetHost* widget) { |
| 3616 return new RenderWidgetHostViewAura(widget); | 3621 return new RenderWidgetHostViewAura(widget); |
| 3617 } | 3622 } |
| 3618 | 3623 |
| 3619 // static | 3624 // static |
| 3620 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3625 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3621 GetScreenInfoForWindow(results, NULL); | 3626 GetScreenInfoForWindow(results, NULL); |
| 3622 } | 3627 } |
| 3623 | 3628 |
| 3624 } // namespace content | 3629 } // namespace content |
| OLD | NEW |