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

Side by Side Diff: views/widget/widget_win.cc

Issue 164543: Reverting 23406. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "views/widget/widget_win.h" 5 #include "views/widget/widget_win.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/path.h" 8 #include "app/gfx/path.h"
9 #include "app/l10n_util_win.h" 9 #include "app/l10n_util_win.h"
10 #include "app/win_util.h" 10 #include "app/win_util.h"
11 #include "base/gfx/native_theme.h" 11 #include "base/gfx/native_theme.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/win_util.h" 13 #include "base/win_util.h"
14 #include "views/accessibility/view_accessibility.h" 14 #include "views/accessibility/view_accessibility.h"
15 #include "views/controls/native_control_win.h" 15 #include "views/controls/native_control_win.h"
16 #include "views/focus/focus_util_win.h" 16 #include "views/focus/focus_util_win.h"
17 #include "views/views_delegate.h" 17 #include "views/views_delegate.h"
18 #include "views/widget/aero_tooltip_manager.h" 18 #include "views/widget/aero_tooltip_manager.h"
19 #include "views/widget/default_theme_provider.h" 19 #include "views/widget/default_theme_provider.h"
20 #include "views/widget/drop_target_win.h" 20 #include "views/widget/drop_target_win.h"
21 #include "views/widget/root_view.h" 21 #include "views/widget/root_view.h"
22 #include "views/window/window_win.h" 22 #include "views/window/window_win.h"
23 23
24 namespace views { 24 namespace views {
25 25
26 // Property used to link the HWND to its RootView. 26 // Property used to link the HWND to its RootView.
27 static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__"; 27 static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__";
28 28
29 bool SetRootViewForHWND(HWND hwnd, RootView* root_view) { 29 bool SetRootViewForHWND(HWND hwnd, RootView* root_view) {
30 return SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false; 30 return ::SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false;
31 } 31 }
32 32
33 RootView* GetRootViewForHWND(HWND hwnd) { 33 RootView* GetRootViewForHWND(HWND hwnd) {
34 return reinterpret_cast<RootView*>(::GetProp(hwnd, kRootViewWindowProperty)); 34 return reinterpret_cast<RootView*>(::GetProp(hwnd, kRootViewWindowProperty));
35 } 35 }
36 36
37 NativeControlWin* GetNativeControlWinForHWND(HWND hwnd) { 37 NativeControlWin* GetNativeControlWinForHWND(HWND hwnd) {
38 return reinterpret_cast<NativeControlWin*>( 38 return reinterpret_cast<NativeControlWin*>(
39 GetProp(hwnd, NativeControlWin::kNativeControlWinKey)); 39 ::GetProp(hwnd, NativeControlWin::kNativeControlWinKey));
40 } 40 }
41 41
42 /////////////////////////////////////////////////////////////////////////////// 42 ///////////////////////////////////////////////////////////////////////////////
43 // WidgetWin, public 43 // WidgetWin, public
44 44
45 WidgetWin::WidgetWin() 45 WidgetWin::WidgetWin()
46 : close_widget_factory_(this), 46 : close_widget_factory_(this),
47 active_mouse_tracking_flags_(0), 47 active_mouse_tracking_flags_(0),
48 has_capture_(false), 48 has_capture_(false),
49 use_layered_buffer_(true), 49 use_layered_buffer_(true),
(...skipping 20 matching lines...) Expand all
70 // Create the window. 70 // Create the window.
71 WindowImpl::Init(parent, bounds); 71 WindowImpl::Init(parent, bounds);
72 72
73 // See if the style has been overridden. 73 // See if the style has been overridden.
74 opaque_ = !(window_ex_style() & WS_EX_TRANSPARENT); 74 opaque_ = !(window_ex_style() & WS_EX_TRANSPARENT);
75 use_layered_buffer_ = (use_layered_buffer_ && 75 use_layered_buffer_ = (use_layered_buffer_ &&
76 !!(window_ex_style() & WS_EX_LAYERED)); 76 !!(window_ex_style() & WS_EX_LAYERED));
77 77
78 default_theme_provider_.reset(new DefaultThemeProvider()); 78 default_theme_provider_.reset(new DefaultThemeProvider());
79 79
80 SetWindowSupportsRerouteMouseWheel(hwnd()); 80 SetWindowSupportsRerouteMouseWheel(GetNativeView());
81 81
82 drop_target_ = new DropTargetWin(root_view_.get()); 82 drop_target_ = new DropTargetWin(root_view_.get());
83 83
84 if ((window_style() & WS_CHILD) == 0) { 84 if ((window_style() & WS_CHILD) == 0) {
85 // Top-level widgets get a FocusManager. 85 // Top-level widgets get a FocusManager.
86 focus_manager_.reset(new FocusManager(this)); 86 focus_manager_.reset(new FocusManager(this));
87 } 87 }
88 88
89 // Sets the RootView as a property, so the automation can introspect windows. 89 // Sets the RootView as a property, so the automation can introspect windows.
90 SetRootViewForHWND(hwnd(), root_view_.get()); 90 SetRootViewForHWND(GetNativeView(), root_view_.get());
91 91
92 MessageLoopForUI::current()->AddObserver(this); 92 MessageLoopForUI::current()->AddObserver(this);
93 93
94 // Windows special DWM window frame requires a special tooltip manager so 94 // Windows special DWM window frame requires a special tooltip manager so
95 // that window controls in Chrome windows don't flicker when you move your 95 // that window controls in Chrome windows don't flicker when you move your
96 // mouse over them. See comment in aero_tooltip_manager.h. 96 // mouse over them. See comment in aero_tooltip_manager.h.
97 if (GetThemeProvider()->ShouldUseNativeFrame()) { 97 if (GetThemeProvider()->ShouldUseNativeFrame()) {
98 tooltip_manager_.reset(new AeroTooltipManager(this)); 98 tooltip_manager_.reset(new AeroTooltipManager(this));
99 } else { 99 } else {
100 tooltip_manager_.reset(new TooltipManagerWin(this)); 100 tooltip_manager_.reset(new TooltipManagerWin(this));
101 } 101 }
102 102
103 // This message initializes the window so that focus border are shown for 103 // This message initializes the window so that focus border are shown for
104 // windows. 104 // windows.
105 SendMessage(hwnd(), 105 ::SendMessage(GetNativeView(),
106 WM_CHANGEUISTATE, 106 WM_CHANGEUISTATE,
107 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 107 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
108 0); 108 0);
109 109
110 // Bug 964884: detach the IME attached to this window. 110 // Bug 964884: detach the IME attached to this window.
111 // We should attach IMEs only when we need to input CJK strings. 111 // We should attach IMEs only when we need to input CJK strings.
112 ImmAssociateContextEx(hwnd(), NULL, 0); 112 ::ImmAssociateContextEx(GetNativeView(), NULL, 0);
113 } 113 }
114 114
115 void WidgetWin::SetContentsView(View* view) { 115 void WidgetWin::SetContentsView(View* view) {
116 root_view_->SetContentsView(view); 116 root_view_->SetContentsView(view);
117 } 117 }
118 118
119 void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const { 119 void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
120 CRect crect; 120 CRect crect;
121 if (including_frame) { 121 if (including_frame) {
122 GetWindowRect(&crect); 122 GetWindowRect(&crect);
123 *out = gfx::Rect(crect); 123 *out = gfx::Rect(crect);
124 return; 124 return;
125 } 125 }
126 126
127 GetClientRect(&crect); 127 GetClientRect(&crect);
128 POINT p = {0, 0}; 128 POINT p = {0, 0};
129 ClientToScreen(hwnd(), &p); 129 ::ClientToScreen(GetNativeView(), &p);
130 out->SetRect(crect.left + p.x, crect.top + p.y, 130 out->SetRect(crect.left + p.x, crect.top + p.y,
131 crect.Width(), crect.Height()); 131 crect.Width(), crect.Height());
132 } 132 }
133 133
134 void WidgetWin::SetBounds(const gfx::Rect& bounds) { 134 void WidgetWin::SetBounds(const gfx::Rect& bounds) {
135 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(), 135 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
136 SWP_NOACTIVATE | SWP_NOZORDER); 136 SWP_NOACTIVATE | SWP_NOZORDER);
137 } 137 }
138 138
139 void WidgetWin::SetShape(const gfx::Path& shape) { 139 void WidgetWin::SetShape(const gfx::Path& shape) {
(...skipping 17 matching lines...) Expand all
157 &WidgetWin::CloseNow)); 157 &WidgetWin::CloseNow));
158 } 158 }
159 } 159 }
160 160
161 void WidgetWin::CloseNow() { 161 void WidgetWin::CloseNow() {
162 // We may already have been destroyed if the selection resulted in a tab 162 // We may already have been destroyed if the selection resulted in a tab
163 // switch which will have reactivated the browser window and closed us, so 163 // switch which will have reactivated the browser window and closed us, so
164 // we need to check to see if we're still a window before trying to destroy 164 // we need to check to see if we're still a window before trying to destroy
165 // ourself. 165 // ourself.
166 if (IsWindow()) 166 if (IsWindow())
167 DestroyWindow(hwnd()); 167 DestroyWindow();
168 } 168 }
169 169
170 void WidgetWin::Show() { 170 void WidgetWin::Show() {
171 if (IsWindow()) 171 if (IsWindow())
172 ShowWindow(SW_SHOWNOACTIVATE); 172 ShowWindow(SW_SHOWNOACTIVATE);
173 } 173 }
174 174
175 void WidgetWin::Hide() { 175 void WidgetWin::Hide() {
176 if (IsWindow()) { 176 if (IsWindow()) {
177 // NOTE: Be careful not to activate any windows here (for example, calling 177 // NOTE: Be careful not to activate any windows here (for example, calling
178 // ShowWindow(SW_HIDE) will automatically activate another window). This 178 // ShowWindow(SW_HIDE) will automatically activate another window). This
179 // code can be called while a window is being deactivated, and activating 179 // code can be called while a window is being deactivated, and activating
180 // another window will screw up the activation that is already in progress. 180 // another window will screw up the activation that is already in progress.
181 SetWindowPos(NULL, 0, 0, 0, 0, 181 SetWindowPos(NULL, 0, 0, 0, 0,
182 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | 182 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
183 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); 183 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
184 } 184 }
185 } 185 }
186 186
187 gfx::NativeView WidgetWin::GetNativeView() const { 187 gfx::NativeView WidgetWin::GetNativeView() const {
188 return WindowImpl::hwnd(); 188 return WindowImpl::GetNativeView();
189 } 189 }
190 190
191 static BOOL CALLBACK EnumChildProcForRedraw(HWND hwnd, LPARAM lparam) { 191 static BOOL CALLBACK EnumChildProcForRedraw(HWND hwnd, LPARAM lparam) {
192 DWORD process_id; 192 DWORD process_id;
193 GetWindowThreadProcessId(hwnd, &process_id); 193 GetWindowThreadProcessId(hwnd, &process_id);
194 gfx::Rect invalid_rect = *reinterpret_cast<gfx::Rect*>(lparam); 194 gfx::Rect invalid_rect = *reinterpret_cast<gfx::Rect*>(lparam);
195 195
196 RECT window_rect; 196 RECT window_rect;
197 GetWindowRect(hwnd, &window_rect); 197 GetWindowRect(hwnd, &window_rect);
198 invalid_rect.Offset(-window_rect.left, -window_rect.top); 198 invalid_rect.Offset(-window_rect.left, -window_rect.top);
199 199
200 int flags = RDW_INVALIDATE | RDW_NOCHILDREN | RDW_FRAME; 200 int flags = RDW_INVALIDATE | RDW_NOCHILDREN | RDW_FRAME;
201 if (process_id == GetCurrentProcessId()) 201 if (process_id == GetCurrentProcessId())
202 flags |= RDW_UPDATENOW; 202 flags |= RDW_UPDATENOW;
203 RedrawWindow(hwnd, &invalid_rect.ToRECT(), NULL, flags); 203 RedrawWindow(hwnd, &invalid_rect.ToRECT(), NULL, flags);
204 return TRUE; 204 return TRUE;
205 } 205 }
206 206
207 void WidgetWin::PaintNow(const gfx::Rect& update_rect) { 207 void WidgetWin::PaintNow(const gfx::Rect& update_rect) {
208 if (use_layered_buffer_) { 208 if (use_layered_buffer_) {
209 PaintLayeredWindow(); 209 PaintLayeredWindow();
210 } else if (root_view_->NeedsPainting(false) && IsWindow()) { 210 } else if (root_view_->NeedsPainting(false) && IsWindow()) {
211 if (!opaque_ && GetParent()) { 211 if (!opaque_ && GetParent()) {
212 // We're transparent. Need to force painting to occur from our parent. 212 // We're transparent. Need to force painting to occur from our parent.
213 CRect parent_update_rect = update_rect.ToRECT(); 213 CRect parent_update_rect = update_rect.ToRECT();
214 POINT location_in_parent = { 0, 0 }; 214 POINT location_in_parent = { 0, 0 };
215 ClientToScreen(hwnd(), &location_in_parent); 215 ClientToScreen(GetNativeView(), &location_in_parent);
216 ScreenToClient(GetParent(), &location_in_parent); 216 ::ScreenToClient(GetParent(), &location_in_parent);
217 parent_update_rect.OffsetRect(location_in_parent); 217 parent_update_rect.OffsetRect(location_in_parent);
218 RedrawWindow(GetParent(), parent_update_rect, NULL, 218 ::RedrawWindow(GetParent(), parent_update_rect, NULL,
219 RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); 219 RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
220 } else { 220 } else {
221 // Paint child windows that are in a different process asynchronously. 221 // Paint child windows that are in a different process asynchronously.
222 // This prevents a hang in other processes from blocking this process. 222 // This prevents a hang in other processes from blocking this process.
223 223
224 // Calculate the invalid rect in screen coordinates before the first 224 // Calculate the invalid rect in screen coordinates before the first
225 // RedrawWindow call to the parent HWND, since that will empty update_rect 225 // RedrawWindow call to the parent HWND, since that will empty update_rect
226 // (which comes from a member variable) in the OnPaint call. 226 // (which comes from a member variable) in the OnPaint call.
227 CRect screen_rect_temp; 227 CRect screen_rect_temp;
228 GetWindowRect(&screen_rect_temp); 228 GetWindowRect(&screen_rect_temp);
229 gfx::Rect screen_rect(screen_rect_temp); 229 gfx::Rect screen_rect(screen_rect_temp);
230 gfx::Rect invalid_screen_rect = update_rect; 230 gfx::Rect invalid_screen_rect = update_rect;
231 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); 231 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
232 232
233 RedrawWindow(hwnd(), &update_rect.ToRECT(), NULL, 233 ::RedrawWindow(GetNativeView(), &update_rect.ToRECT(), NULL,
234 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); 234 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
235 235
236 LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect); 236 LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect);
237 EnumChildWindows(hwnd(), EnumChildProcForRedraw, lparam); 237 EnumChildWindows(GetNativeView(), EnumChildProcForRedraw, lparam);
238 } 238 }
239 // As we were created with a style of WS_CLIPCHILDREN redraw requests may 239 // As we were created with a style of WS_CLIPCHILDREN redraw requests may
240 // result in an empty paint rect in WM_PAINT (this'll happen if a 240 // result in an empty paint rect in WM_PAINT (this'll happen if a
241 // child HWND completely contains the update _rect). In such a scenario 241 // child HWND completely contains the update _rect). In such a scenario
242 // RootView would never get a ProcessPaint and always think it needs to 242 // RootView would never get a ProcessPaint and always think it needs to
243 // be painted (leading to a steady stream of RedrawWindow requests on every 243 // be painted (leading to a steady stream of RedrawWindow requests on every
244 // event). For this reason we tell RootView it doesn't need to paint 244 // event). For this reason we tell RootView it doesn't need to paint
245 // here. 245 // here.
246 root_view_->ClearPaintRect(); 246 root_view_->ClearPaintRect();
247 } 247 }
248 } 248 }
249 249
250 void WidgetWin::SetOpacity(unsigned char opacity) { 250 void WidgetWin::SetOpacity(unsigned char opacity) {
251 layered_alpha_ = static_cast<BYTE>(opacity); 251 layered_alpha_ = static_cast<BYTE>(opacity);
252 } 252 }
253 253
254 RootView* WidgetWin::GetRootView() { 254 RootView* WidgetWin::GetRootView() {
255 if (!root_view_.get()) { 255 if (!root_view_.get()) {
256 // First time the root view is being asked for, create it now. 256 // First time the root view is being asked for, create it now.
257 root_view_.reset(CreateRootView()); 257 root_view_.reset(CreateRootView());
258 } 258 }
259 return root_view_.get(); 259 return root_view_.get();
260 } 260 }
261 261
262 Widget* WidgetWin::GetRootWidget() const { 262 Widget* WidgetWin::GetRootWidget() const {
263 return reinterpret_cast<WidgetWin*>( 263 return reinterpret_cast<WidgetWin*>(
264 win_util::GetWindowUserData(GetAncestor(hwnd(), GA_ROOT))); 264 win_util::GetWindowUserData(GetAncestor(GetNativeView(), GA_ROOT)));
265 } 265 }
266 266
267 bool WidgetWin::IsVisible() const { 267 bool WidgetWin::IsVisible() const {
268 return !!::IsWindowVisible(hwnd()); 268 return !!::IsWindowVisible(GetNativeView());
269 } 269 }
270 270
271 bool WidgetWin::IsActive() const { 271 bool WidgetWin::IsActive() const {
272 return win_util::IsWindowActive(hwnd()); 272 return win_util::IsWindowActive(GetNativeView());
273 } 273 }
274 274
275 void WidgetWin::GenerateMousePressedForView(View* view, 275 void WidgetWin::GenerateMousePressedForView(View* view,
276 const gfx::Point& point) { 276 const gfx::Point& point) {
277 gfx::Point point_in_widget(point); 277 gfx::Point point_in_widget(point);
278 View::ConvertPointToWidget(view, &point_in_widget); 278 View::ConvertPointToWidget(view, &point_in_widget);
279 root_view_->SetMouseHandler(view); 279 root_view_->SetMouseHandler(view);
280 ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false); 280 ProcessMousePressed(point_in_widget.ToPOINT(), MK_LBUTTON, false, false);
281 } 281 }
282 282
(...skipping 11 matching lines...) Expand all
294 return provider; 294 return provider;
295 295
296 provider = widget->GetDefaultThemeProvider(); 296 provider = widget->GetDefaultThemeProvider();
297 if (provider) 297 if (provider)
298 return provider; 298 return provider;
299 } 299 }
300 return default_theme_provider_.get(); 300 return default_theme_provider_.get();
301 } 301 }
302 302
303 Window* WidgetWin::GetWindow() { 303 Window* WidgetWin::GetWindow() {
304 return GetWindowImpl(hwnd()); 304 return GetWindowImpl(GetNativeView());
305 } 305 }
306 306
307 const Window* WidgetWin::GetWindow() const { 307 const Window* WidgetWin::GetWindow() const {
308 return GetWindowImpl(hwnd()); 308 return GetWindowImpl(GetNativeView());
309 } 309 }
310 310
311 FocusManager* WidgetWin::GetFocusManager() { 311 FocusManager* WidgetWin::GetFocusManager() {
312 if (focus_manager_.get()) 312 if (focus_manager_.get())
313 return focus_manager_.get(); 313 return focus_manager_.get();
314 314
315 WidgetWin* widget = static_cast<WidgetWin*>(GetRootWidget()); 315 WidgetWin* widget = static_cast<WidgetWin*>(GetRootWidget());
316 if (widget && widget != this) { 316 if (widget && widget != this) {
317 // WidgetWin subclasses may override GetFocusManager(), for example for 317 // WidgetWin subclasses may override GetFocusManager(), for example for
318 // dealing with cases where the widget has been unparented. 318 // dealing with cases where the widget has been unparented.
319 return widget->GetFocusManager(); 319 return widget->GetFocusManager();
320 } 320 }
321 return NULL; 321 return NULL;
322 } 322 }
323 323
324 void WidgetWin::ViewHierarchyChanged(bool is_add, View *parent, 324 void WidgetWin::ViewHierarchyChanged(bool is_add, View *parent,
325 View *child) { 325 View *child) {
326 if (drop_target_.get()) 326 if (drop_target_.get())
327 drop_target_->ResetTargetViewIfEquals(child); 327 drop_target_->ResetTargetViewIfEquals(child);
328 } 328 }
329 329
330 void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) { 330 void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
331 if (use_layered_buffer_ == use_layered_buffer) 331 if (use_layered_buffer_ == use_layered_buffer)
332 return; 332 return;
333 333
334 use_layered_buffer_ = use_layered_buffer; 334 use_layered_buffer_ = use_layered_buffer;
335 if (!hwnd()) 335 if (!GetNativeView())
336 return; 336 return;
337 337
338 if (use_layered_buffer_) { 338 if (use_layered_buffer_) {
339 // Force creation of the buffer at the right size. 339 // Force creation of the buffer at the right size.
340 RECT wr; 340 RECT wr;
341 GetWindowRect(&wr); 341 GetWindowRect(&wr);
342 ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top)); 342 ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top));
343 } else { 343 } else {
344 contents_.reset(NULL); 344 contents_.reset(NULL);
345 } 345 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 has_capture_ = false; 433 has_capture_ = false;
434 } 434 }
435 } 435 }
436 436
437 void WidgetWin::OnClose() { 437 void WidgetWin::OnClose() {
438 Close(); 438 Close();
439 } 439 }
440 440
441 void WidgetWin::OnDestroy() { 441 void WidgetWin::OnDestroy() {
442 if (drop_target_.get()) { 442 if (drop_target_.get()) {
443 RevokeDragDrop(hwnd()); 443 RevokeDragDrop(GetNativeView());
444 drop_target_ = NULL; 444 drop_target_ = NULL;
445 } 445 }
446 446
447 RemoveProp(hwnd(), kRootViewWindowProperty); 447 RemoveProp(GetNativeView(), kRootViewWindowProperty);
448 } 448 }
449 449
450 LRESULT WidgetWin::OnEraseBkgnd(HDC dc) { 450 LRESULT WidgetWin::OnEraseBkgnd(HDC dc) {
451 // This is needed for magical win32 flicker ju-ju 451 // This is needed for magical win32 flicker ju-ju
452 return 1; 452 return 1;
453 } 453 }
454 454
455 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { 455 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) {
456 LRESULT reference_result = static_cast<LRESULT>(0L); 456 LRESULT reference_result = static_cast<LRESULT>(0L);
457 457
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) { 541 LRESULT WidgetWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) {
542 tooltip_manager_->OnMouseLeave(); 542 tooltip_manager_->OnMouseLeave();
543 ProcessMouseExited(); 543 ProcessMouseExited();
544 return 0; 544 return 0;
545 } 545 }
546 546
547 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) { 547 LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) {
548 // Reroute the mouse-wheel to the window under the mouse pointer if 548 // Reroute the mouse-wheel to the window under the mouse pointer if
549 // applicable. 549 // applicable.
550 if (message == WM_MOUSEWHEEL && 550 if (message == WM_MOUSEWHEEL &&
551 views::RerouteMouseWheel(hwnd(), w_param, l_param)) { 551 views::RerouteMouseWheel(GetNativeView(), w_param, l_param)) {
552 return 0; 552 return 0;
553 } 553 }
554 554
555 int flags = GET_KEYSTATE_WPARAM(w_param); 555 int flags = GET_KEYSTATE_WPARAM(w_param);
556 short distance = GET_WHEEL_DELTA_WPARAM(w_param); 556 short distance = GET_WHEEL_DELTA_WPARAM(w_param);
557 int x = GET_X_LPARAM(l_param); 557 int x = GET_X_LPARAM(l_param);
558 int y = GET_Y_LPARAM(l_param); 558 int y = GET_Y_LPARAM(l_param);
559 MouseWheelEvent e(distance, x, y, Event::ConvertWindowsFlags(flags)); 559 MouseWheelEvent e(distance, x, y, Event::ConvertWindowsFlags(flags));
560 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; 560 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1;
561 } 561 }
(...skipping 29 matching lines...) Expand all
591 } 591 }
592 592
593 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { 593 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) {
594 ProcessMouseExited(); 594 ProcessMouseExited();
595 return 0; 595 return 0;
596 } 596 }
597 597
598 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { 598 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) {
599 // NC points are in screen coordinates. 599 // NC points are in screen coordinates.
600 CPoint temp = point; 600 CPoint temp = point;
601 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); 601 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
602 ProcessMouseMoved(temp, 0, true); 602 ProcessMouseMoved(temp, 0, true);
603 603
604 // We need to process this message to stop Windows from drawing the window 604 // We need to process this message to stop Windows from drawing the window
605 // controls as the mouse moves over the title bar area when the window is 605 // controls as the mouse moves over the title bar area when the window is
606 // maximized. 606 // maximized.
607 return 0; 607 return 0;
608 } 608 }
609 609
610 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { 610 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) {
611 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); 611 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true));
(...skipping 15 matching lines...) Expand all
627 bool handled; 627 bool handled;
628 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); 628 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled);
629 SetMsgHandled(handled); 629 SetMsgHandled(handled);
630 return result; 630 return result;
631 } 631 }
632 SetMsgHandled(FALSE); 632 SetMsgHandled(FALSE);
633 return 0; 633 return 0;
634 } 634 }
635 635
636 void WidgetWin::OnPaint(HDC dc) { 636 void WidgetWin::OnPaint(HDC dc) {
637 root_view_->OnPaint(hwnd()); 637 root_view_->OnPaint(GetNativeView());
638 } 638 }
639 639
640 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { 640 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) {
641 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); 641 ProcessMousePressed(point, flags | MK_RBUTTON, false, false);
642 } 642 }
643 643
644 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { 644 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) {
645 ProcessMouseReleased(point, flags | MK_RBUTTON); 645 ProcessMouseReleased(point, flags | MK_RBUTTON);
646 } 646 }
647 647
(...skipping 26 matching lines...) Expand all
674 // We're about to cancel active mouse tracking, so empty out the stored 674 // We're about to cancel active mouse tracking, so empty out the stored
675 // state. 675 // state.
676 active_mouse_tracking_flags_ = 0; 676 active_mouse_tracking_flags_ = 0;
677 } else { 677 } else {
678 active_mouse_tracking_flags_ = mouse_tracking_flags; 678 active_mouse_tracking_flags_ = mouse_tracking_flags;
679 } 679 }
680 680
681 TRACKMOUSEEVENT tme; 681 TRACKMOUSEEVENT tme;
682 tme.cbSize = sizeof(tme); 682 tme.cbSize = sizeof(tme);
683 tme.dwFlags = mouse_tracking_flags; 683 tme.dwFlags = mouse_tracking_flags;
684 tme.hwndTrack = hwnd(); 684 tme.hwndTrack = GetNativeView();
685 tme.dwHoverTime = 0; 685 tme.dwHoverTime = 0;
686 TrackMouseEvent(&tme); 686 TrackMouseEvent(&tme);
687 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { 687 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) {
688 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); 688 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL);
689 TrackMouseEvents(mouse_tracking_flags); 689 TrackMouseEvents(mouse_tracking_flags);
690 } 690 }
691 } 691 }
692 692
693 bool WidgetWin::ProcessMousePressed(const CPoint& point, 693 bool WidgetWin::ProcessMousePressed(const CPoint& point,
694 UINT flags, 694 UINT flags,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void WidgetWin::UpdateWindowFromContents(HDC dib_dc) { 841 void WidgetWin::UpdateWindowFromContents(HDC dib_dc) {
842 DCHECK(use_layered_buffer_); 842 DCHECK(use_layered_buffer_);
843 if (can_update_layered_window_) { 843 if (can_update_layered_window_) {
844 CRect wr; 844 CRect wr;
845 GetWindowRect(&wr); 845 GetWindowRect(&wr);
846 CSize size(wr.right - wr.left, wr.bottom - wr.top); 846 CSize size(wr.right - wr.left, wr.bottom - wr.top);
847 CPoint zero_origin(0, 0); 847 CPoint zero_origin(0, 0);
848 CPoint window_position = wr.TopLeft(); 848 CPoint window_position = wr.TopLeft();
849 849
850 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; 850 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA};
851 UpdateLayeredWindow( 851 ::UpdateLayeredWindow(
852 hwnd(), NULL, &window_position, &size, dib_dc, &zero_origin, 852 GetNativeView(), NULL, &window_position, &size, dib_dc, &zero_origin,
853 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); 853 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
854 } 854 }
855 } 855 }
856 856
857 // Get the source HWND of the specified message. Depending on the message, the 857 // Get the source HWND of the specified message. Depending on the message, the
858 // source HWND is encoded in either the WPARAM or the LPARAM value. 858 // source HWND is encoded in either the WPARAM or the LPARAM value.
859 HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) { 859 HWND GetControlHWNDForMessage(UINT message, WPARAM w_param, LPARAM l_param) {
860 // Each of the following messages can be sent by a child HWND and must be 860 // Each of the following messages can be sent by a child HWND and must be
861 // forwarded to its associated NativeControlWin for handling. 861 // forwarded to its associated NativeControlWin for handling.
862 switch (message) { 862 switch (message) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 if (IsWindow(control_hwnd)) { 897 if (IsWindow(control_hwnd)) {
898 NativeControlWin* wrapper = GetNativeControlWinForHWND(control_hwnd); 898 NativeControlWin* wrapper = GetNativeControlWinForHWND(control_hwnd);
899 if (wrapper) 899 if (wrapper)
900 return wrapper->ProcessMessage(message, w_param, l_param, l_result); 900 return wrapper->ProcessMessage(message, w_param, l_param, l_result);
901 } 901 }
902 902
903 return false; 903 return false;
904 } 904 }
905 905
906 LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { 906 LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
907 HWND window = hwnd(); 907 HWND window = GetNativeView();
908 LRESULT result = 0; 908 LRESULT result = 0;
909 909
910 // First allow messages sent by child controls to be processed directly by 910 // First allow messages sent by child controls to be processed directly by
911 // their associated views. If such a view is present, it will handle the 911 // their associated views. If such a view is present, it will handle the
912 // message *instead of* this WidgetWin. 912 // message *instead of* this WidgetWin.
913 if (ProcessNativeControlMessage(message, w_param, l_param, &result)) 913 if (ProcessNativeControlMessage(message, w_param, l_param, &result))
914 return result; 914 return result;
915 915
916 // Otherwise we handle everything else. 916 // Otherwise we handle everything else.
917 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) 917 if (!ProcessWindowMessage(window, message, w_param, l_param, result))
(...skipping 29 matching lines...) Expand all
947 WidgetWin* popup = new WidgetWin; 947 WidgetWin* popup = new WidgetWin;
948 popup->set_window_style(WS_POPUP); 948 popup->set_window_style(WS_POPUP);
949 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | 949 popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW |
950 WS_EX_TRANSPARENT | 950 WS_EX_TRANSPARENT |
951 l10n_util::GetExtendedTooltipStyles()); 951 l10n_util::GetExtendedTooltipStyles());
952 popup->set_delete_on_destroy(delete_on_destroy); 952 popup->set_delete_on_destroy(delete_on_destroy);
953 return popup; 953 return popup;
954 } 954 }
955 955
956 } // namespace views 956 } // namespace views
OLDNEW
« no previous file with comments | « chrome/browser/views/tab_contents/tab_contents_view_win.cc ('k') | webkit/default_plugin/default_plugin.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698