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

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

Issue 159713012: Don't track mouse events in HWNDMessageHandler when they are forwarded by the LegacyRenderWidgetHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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/legacy_render_widget_host_win.h" 5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "base/win/win_util.h"
10 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 11 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
11 #include "content/browser/accessibility/browser_accessibility_win.h" 12 #include "content/browser/accessibility/browser_accessibility_win.h"
12 #include "content/public/common/content_switches.h" 13 #include "content/public/common/content_switches.h"
13 #include "ui/base/touch/touch_enabled.h" 14 #include "ui/base/touch/touch_enabled.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() { 19 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
19 ::DestroyWindow(hwnd()); 20 ::DestroyWindow(hwnd());
20 } 21 }
21 22
22 // static 23 // static
23 scoped_ptr<LegacyRenderWidgetHostHWND> LegacyRenderWidgetHostHWND::Create( 24 scoped_ptr<LegacyRenderWidgetHostHWND> LegacyRenderWidgetHostHWND::Create(
24 HWND parent) { 25 HWND parent) {
26 if (CommandLine::ForCurrentProcess()->HasSwitch(
27 switches::kDisableLegacyIntermediateWindow))
28 return scoped_ptr<LegacyRenderWidgetHostHWND>();
29
25 scoped_ptr<LegacyRenderWidgetHostHWND> legacy_window_instance; 30 scoped_ptr<LegacyRenderWidgetHostHWND> legacy_window_instance;
26 legacy_window_instance.reset(new LegacyRenderWidgetHostHWND(parent)); 31 legacy_window_instance.reset(new LegacyRenderWidgetHostHWND(parent));
27 // If we failed to create the child, or if the switch to disable the legacy 32 // If we failed to create the child, or if the switch to disable the legacy
28 // window is passed in, then return NULL. 33 // window is passed in, then return NULL.
29 if (!::IsWindow(legacy_window_instance->hwnd()) || 34 if (!::IsWindow(legacy_window_instance->hwnd()))
30 CommandLine::ForCurrentProcess()->HasSwitch(
31 switches::kDisableLegacyIntermediateWindow))
32 return scoped_ptr<LegacyRenderWidgetHostHWND>(); 35 return scoped_ptr<LegacyRenderWidgetHostHWND>();
33 36
34 legacy_window_instance->Init(); 37 legacy_window_instance->Init();
35 return legacy_window_instance.Pass(); 38 return legacy_window_instance.Pass();
36 } 39 }
37 40
38 void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) { 41 void LegacyRenderWidgetHostHWND::UpdateParent(HWND parent) {
39 ::SetParent(hwnd(), parent); 42 ::SetParent(hwnd(), parent);
40 // If the new parent is the desktop Window, then we disable the child window 43 // If the new parent is the desktop Window, then we disable the child window
41 // to ensure that it does not receive any input events. It should not because 44 // to ensure that it does not receive any input events. It should not because
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 WPARAM w_param, 126 WPARAM w_param,
124 LPARAM l_param, 127 LPARAM l_param,
125 BOOL& handled) { 128 BOOL& handled) {
126 return ::SendMessage(GetParent(), message, w_param, l_param); 129 return ::SendMessage(GetParent(), message, w_param, l_param);
127 } 130 }
128 131
129 LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message, 132 LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
130 WPARAM w_param, 133 WPARAM w_param,
131 LPARAM l_param, 134 LPARAM l_param,
132 BOOL& handled) { 135 BOOL& handled) {
133 POINT mouse_coords; 136 // Mark the WM_MOUSEMOVE message with a special flag 0xbeef in the high word
sky 2014/02/12 22:51:29 nit nuke 0xbeef, since you really mean SPECIAL_MOU
ananta 2014/02/12 23:17:08 Done.
134 mouse_coords.x = GET_X_LPARAM(l_param); 137 // of the WPARAM.
135 mouse_coords.y = GET_Y_LPARAM(l_param); 138 // The parent window has code to track mouse events, i.e to detect if the
136 ::MapWindowPoints(hwnd(), GetParent(), &mouse_coords, 1); 139 // cursor left the bounds of the parent window. Technically entering a child
137 return ::SendMessage(GetParent(), message, w_param, 140 // window indicates that the cursor left the parent window.
138 MAKELPARAM(mouse_coords.x, mouse_coords.y)); 141 // To ensure that the parent does not turn on tracking for the WM_MOUSEMOVE
142 // messages sent from us, we flag this in the WPARAM.
143 if (message == WM_MOUSEMOVE)
144 w_param = MAKEWPARAM(LOWORD(w_param), SPECIAL_MOUSEMOVE_NOT_TO_BE_TRACKED);
145
146 // The offsets in mouse wheel messages are in screen coordinates. We should
147 // not be converting them to parent coordinates.
148 if (message != WM_MOUSEWHEEL && message != WM_MOUSEHWHEEL) {
149 POINT mouse_coords;
150 mouse_coords.x = GET_X_LPARAM(l_param);
151 mouse_coords.y = GET_Y_LPARAM(l_param);
152 ::MapWindowPoints(hwnd(), GetParent(), &mouse_coords, 1);
153 l_param = MAKELPARAM(mouse_coords.x, mouse_coords.y);
154 }
155 return ::SendMessage(GetParent(), message, w_param, l_param);
139 } 156 }
140 157
141 LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message, 158 LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message,
142 WPARAM w_param, 159 WPARAM w_param,
143 LPARAM l_param) { 160 LPARAM l_param) {
144 // Don't pass this to DefWindowProc. That results in the WM_MOUSEACTIVATE 161 // Don't pass this to DefWindowProc. That results in the WM_MOUSEACTIVATE
145 // message going all the way to the parent which then messes up state 162 // message going all the way to the parent which then messes up state
146 // related to focused views, etc. This is because it treats this as if 163 // related to focused views, etc. This is because it treats this as if
147 // it lost activation. 164 // it lost activation.
148 // Our dummy window should not interfere with focus and activation in 165 // Our dummy window should not interfere with focus and activation in
(...skipping 26 matching lines...) Expand all
175 return 0; 192 return 0;
176 } 193 }
177 194
178 LRESULT LegacyRenderWidgetHostHWND::OnSetCursor(UINT message, 195 LRESULT LegacyRenderWidgetHostHWND::OnSetCursor(UINT message,
179 WPARAM w_param, 196 WPARAM w_param,
180 LPARAM l_param) { 197 LPARAM l_param) {
181 return 0; 198 return 0;
182 } 199 }
183 200
184 } // namespace content 201 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698