| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const HWND owner = ::GetWindow(window, GW_OWNER); | 224 const HWND owner = ::GetWindow(window, GW_OWNER); |
| 225 if (toplevel_hwnd == owner) { | 225 if (toplevel_hwnd == owner) { |
| 226 ::PostMessage(window, WM_CANCELMODE, 0, 0); | 226 ::PostMessage(window, WM_CANCELMODE, 0, 0); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 return TRUE; | 230 return TRUE; |
| 231 } | 231 } |
| 232 #endif | 232 #endif |
| 233 | 233 |
| 234 bool CanRendererHandleEvent(const ui::MouseEvent* event) { | 234 bool CanRendererHandleEvent(const ui::MouseEvent* event, bool mouse_locked) { |
| 235 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) | 235 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) |
| 236 return false; | 236 return false; |
| 237 | 237 |
| 238 if (mouse_locked && (event->type() == ui::ET_MOUSE_EXITED)) |
| 239 return false; |
| 240 |
| 238 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
| 239 // Renderer cannot handle WM_XBUTTON or NC events. | 242 // Renderer cannot handle WM_XBUTTON or NC events. |
| 240 switch (event->native_event().message) { | 243 switch (event->native_event().message) { |
| 241 case WM_XBUTTONDOWN: | 244 case WM_XBUTTONDOWN: |
| 242 case WM_XBUTTONUP: | 245 case WM_XBUTTONUP: |
| 243 case WM_XBUTTONDBLCLK: | 246 case WM_XBUTTONDBLCLK: |
| 244 case WM_NCMOUSELEAVE: | 247 case WM_NCMOUSELEAVE: |
| 245 case WM_NCMOUSEMOVE: | 248 case WM_NCMOUSEMOVE: |
| 246 case WM_NCLBUTTONDOWN: | 249 case WM_NCLBUTTONDOWN: |
| 247 case WM_NCLBUTTONUP: | 250 case WM_NCLBUTTONUP: |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 params.widget = this; | 1036 params.widget = this; |
| 1034 params.cutout_rects = constrained_rects_; | 1037 params.cutout_rects = constrained_rects_; |
| 1035 params.geometry = &plugin_window_moves_; | 1038 params.geometry = &plugin_window_moves_; |
| 1036 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); | 1039 LPARAM lparam = reinterpret_cast<LPARAM>(¶ms); |
| 1037 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); | 1040 EnumChildWindows(parent, SetCutoutRectsCallback, lparam); |
| 1038 } | 1041 } |
| 1039 | 1042 |
| 1040 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { | 1043 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { |
| 1041 // Clip the cursor if chrome is running on regular desktop. | 1044 // Clip the cursor if chrome is running on regular desktop. |
| 1042 if (gfx::Screen::GetScreenFor(window_) == gfx::Screen::GetNativeScreen()) { | 1045 if (gfx::Screen::GetScreenFor(window_) == gfx::Screen::GetNativeScreen()) { |
| 1043 RECT window_rect = window_->GetBoundsInScreen().ToRECT(); | 1046 RECT window_rect = |
| 1047 gfx::win::DIPToScreenRect(window_->GetBoundsInScreen()).ToRECT(); |
| 1044 ::ClipCursor(&window_rect); | 1048 ::ClipCursor(&window_rect); |
| 1045 } | 1049 } |
| 1046 } | 1050 } |
| 1047 | 1051 |
| 1048 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { | 1052 void RenderWidgetHostViewAura::OnLegacyWindowDestroyed() { |
| 1049 legacy_render_widget_host_HWND_ = NULL; | 1053 legacy_render_widget_host_HWND_ = NULL; |
| 1050 legacy_window_destroyed_ = true; | 1054 legacy_window_destroyed_ = true; |
| 1051 } | 1055 } |
| 1052 #endif | 1056 #endif |
| 1053 | 1057 |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 1929 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; |
| 1926 if (should_not_forward) { | 1930 if (should_not_forward) { |
| 1927 synthetic_move_sent_ = false; | 1931 synthetic_move_sent_ = false; |
| 1928 } else { | 1932 } else { |
| 1929 // Check if the mouse has reached the border and needs to be centered. | 1933 // Check if the mouse has reached the border and needs to be centered. |
| 1930 if (ShouldMoveToCenter()) { | 1934 if (ShouldMoveToCenter()) { |
| 1931 synthetic_move_sent_ = true; | 1935 synthetic_move_sent_ = true; |
| 1932 window_->MoveCursorTo(center); | 1936 window_->MoveCursorTo(center); |
| 1933 } | 1937 } |
| 1934 // Forward event to renderer. | 1938 // Forward event to renderer. |
| 1935 if (CanRendererHandleEvent(event) && | 1939 if (CanRendererHandleEvent(event, mouse_locked_) && |
| 1936 !(event->flags() & ui::EF_FROM_TOUCH)) { | 1940 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 1937 host_->ForwardMouseEvent(mouse_event); | 1941 host_->ForwardMouseEvent(mouse_event); |
| 1938 // Ensure that we get keyboard focus on mouse down as a plugin window | 1942 // Ensure that we get keyboard focus on mouse down as a plugin window |
| 1939 // may have grabbed keyboard focus. | 1943 // may have grabbed keyboard focus. |
| 1940 if (event->type() == ui::ET_MOUSE_PRESSED) | 1944 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1941 SetKeyboardFocus(); | 1945 SetKeyboardFocus(); |
| 1942 } | 1946 } |
| 1943 } | 1947 } |
| 1944 return; | 1948 return; |
| 1945 } | 1949 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1975 } | 1979 } |
| 1976 #endif | 1980 #endif |
| 1977 // The Disambiguation popup does not parent itself from this window, so we | 1981 // The Disambiguation popup does not parent itself from this window, so we |
| 1978 // manually dismiss it. | 1982 // manually dismiss it. |
| 1979 HideDisambiguationPopup(); | 1983 HideDisambiguationPopup(); |
| 1980 | 1984 |
| 1981 blink::WebMouseWheelEvent mouse_wheel_event = | 1985 blink::WebMouseWheelEvent mouse_wheel_event = |
| 1982 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 1986 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
| 1983 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1987 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 1984 host_->ForwardWheelEvent(mouse_wheel_event); | 1988 host_->ForwardWheelEvent(mouse_wheel_event); |
| 1985 } else if (CanRendererHandleEvent(event) && | 1989 } else if (CanRendererHandleEvent(event, mouse_locked_) && |
| 1986 !(event->flags() & ui::EF_FROM_TOUCH)) { | 1990 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 1987 // Confirm existing composition text on mouse press, to make sure | 1991 // Confirm existing composition text on mouse press, to make sure |
| 1988 // the input caret won't be moved with an ongoing composition text. | 1992 // the input caret won't be moved with an ongoing composition text. |
| 1989 if (event->type() == ui::ET_MOUSE_PRESSED) | 1993 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 1990 FinishImeCompositionSession(); | 1994 FinishImeCompositionSession(); |
| 1991 | 1995 |
| 1992 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 1996 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
| 1993 ModifyEventMovementAndCoords(&mouse_event); | 1997 ModifyEventMovementAndCoords(&mouse_event); |
| 1994 host_->ForwardMouseEvent(mouse_event); | 1998 host_->ForwardMouseEvent(mouse_event); |
| 1995 // Ensure that we get keyboard focus on mouse down as a plugin window may | 1999 // Ensure that we get keyboard focus on mouse down as a plugin window may |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2677 | 2681 |
| 2678 //////////////////////////////////////////////////////////////////////////////// | 2682 //////////////////////////////////////////////////////////////////////////////// |
| 2679 // RenderWidgetHostViewBase, public: | 2683 // RenderWidgetHostViewBase, public: |
| 2680 | 2684 |
| 2681 // static | 2685 // static |
| 2682 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2686 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2683 GetScreenInfoForWindow(results, NULL); | 2687 GetScreenInfoForWindow(results, NULL); |
| 2684 } | 2688 } |
| 2685 | 2689 |
| 2686 } // namespace content | 2690 } // namespace content |
| OLD | NEW |