OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <dwmapi.h> | 7 #include <dwmapi.h> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 const int kCustomObjectID = 1; | 125 const int kCustomObjectID = 1; |
126 | 126 |
127 } // namespace | 127 } // namespace |
128 | 128 |
129 // static | 129 // static |
130 bool WidgetWin::screen_reader_active_ = false; | 130 bool WidgetWin::screen_reader_active_ = false; |
131 | 131 |
132 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
133 // WidgetWin, public: | 133 // WidgetWin, public: |
134 | 134 |
135 WidgetWin::WidgetWin() | 135 WidgetWin::WidgetWin(internal::NativeWidgetDelegate* delegate) |
136 : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), | 136 : delegate_(delegate), |
137 close_widget_factory_(this), | 137 close_widget_factory_(this), |
138 active_mouse_tracking_flags_(0), | 138 active_mouse_tracking_flags_(0), |
139 use_layered_buffer_(false), | 139 use_layered_buffer_(false), |
140 layered_alpha_(255), | 140 layered_alpha_(255), |
141 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), | 141 ALLOW_THIS_IN_INITIALIZER_LIST(paint_layered_window_factory_(this)), |
142 delete_on_destroy_(true), | 142 delete_on_destroy_(true), |
143 can_update_layered_window_(true), | 143 can_update_layered_window_(true), |
144 is_window_(false), | 144 is_window_(false), |
145 restore_focus_when_enabled_(false), | 145 restore_focus_when_enabled_(false), |
146 accessibility_view_events_index_(-1), | 146 accessibility_view_events_index_(-1), |
147 accessibility_view_events_(kMaxAccessibilityViewEvents), | 147 accessibility_view_events_(kMaxAccessibilityViewEvents), |
148 previous_cursor_(NULL), | 148 previous_cursor_(NULL), |
149 is_input_method_win_(false) { | 149 is_input_method_win_(false) { |
150 set_native_widget(this); | |
151 } | 150 } |
152 | 151 |
153 WidgetWin::~WidgetWin() { | 152 WidgetWin::~WidgetWin() { |
154 // We need to delete the input method before calling DestroyRootView(), | 153 // We need to delete the input method before calling DestroyRootView(), |
155 // because it'll set focus_manager_ to NULL. | 154 // because it'll set focus_manager_ to NULL. |
156 input_method_.reset(); | 155 input_method_.reset(); |
157 DestroyRootView(); | 156 if (delete_on_destroy_) |
| 157 delete delegate_; |
158 } | 158 } |
159 | 159 |
160 // static | 160 // static |
161 bool WidgetWin::IsAeroGlassEnabled() { | 161 bool WidgetWin::IsAeroGlassEnabled() { |
162 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 162 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
163 return false; | 163 return false; |
164 // If composition is not enabled, we behave like on XP. | 164 // If composition is not enabled, we behave like on XP. |
165 BOOL enabled = FALSE; | 165 BOOL enabled = FALSE; |
166 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; | 166 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; |
167 } | 167 } |
(...skipping 17 matching lines...) Expand all Loading... |
185 void WidgetWin::ClearAccessibilityViewEvent(View* view) { | 185 void WidgetWin::ClearAccessibilityViewEvent(View* view) { |
186 for (std::vector<View*>::iterator it = accessibility_view_events_.begin(); | 186 for (std::vector<View*>::iterator it = accessibility_view_events_.begin(); |
187 it != accessibility_view_events_.end(); | 187 it != accessibility_view_events_.end(); |
188 ++it) { | 188 ++it) { |
189 if (*it == view) | 189 if (*it == view) |
190 *it = NULL; | 190 *it = NULL; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 //////////////////////////////////////////////////////////////////////////////// | 194 //////////////////////////////////////////////////////////////////////////////// |
195 // WidgetWin, Widget implementation: | 195 // WidgetWin, NativeWidget implementation: |
| 196 |
| 197 void WidgetWin::InitNativeWidget(const Widget::InitParams& params) { |
| 198 SetInitParams(params); |
| 199 |
| 200 // Create the window. |
| 201 gfx::NativeView parent = params.parent_widget ? |
| 202 params.parent_widget->GetNativeView() : params.parent; |
| 203 WindowImpl::Init(parent, params.bounds); |
| 204 } |
| 205 |
| 206 Widget* WidgetWin::GetWidget() { |
| 207 return delegate_->AsWidget(); |
| 208 } |
| 209 |
| 210 const Widget* WidgetWin::GetWidget() const { |
| 211 return delegate_->AsWidget(); |
| 212 } |
196 | 213 |
197 gfx::NativeView WidgetWin::GetNativeView() const { | 214 gfx::NativeView WidgetWin::GetNativeView() const { |
198 return WindowImpl::hwnd(); | 215 return WindowImpl::hwnd(); |
199 } | 216 } |
200 | 217 |
201 gfx::NativeWindow WidgetWin::GetNativeWindow() const { | 218 gfx::NativeWindow WidgetWin::GetNativeWindow() const { |
202 return WindowImpl::hwnd(); | 219 return WindowImpl::hwnd(); |
203 } | 220 } |
204 | 221 |
205 bool WidgetWin::GetAccelerator(int cmd_id, ui::Accelerator* accelerator) { | 222 Window* WidgetWin::GetContainingWindow() { |
206 return false; | |
207 } | |
208 | |
209 Window* WidgetWin::GetWindow() { | |
210 return GetWindowImpl(hwnd()); | 223 return GetWindowImpl(hwnd()); |
211 } | 224 } |
212 | 225 |
213 const Window* WidgetWin::GetWindow() const { | 226 const Window* WidgetWin::GetContainingWindow() const { |
214 return GetWindowImpl(hwnd()); | 227 return GetWindowImpl(hwnd()); |
215 } | 228 } |
216 | 229 |
217 void WidgetWin::ViewHierarchyChanged(bool is_add, View* parent, | 230 void WidgetWin::ViewRemoved(View* view) { |
218 View* child) { | |
219 Widget::ViewHierarchyChanged(is_add, parent, child); | |
220 if (drop_target_.get()) | 231 if (drop_target_.get()) |
221 drop_target_->ResetTargetViewIfEquals(child); | 232 drop_target_->ResetTargetViewIfEquals(view); |
222 | 233 |
223 if (!is_add) | 234 ClearAccessibilityViewEvent(view); |
224 ClearAccessibilityViewEvent(child); | |
225 } | |
226 | |
227 //////////////////////////////////////////////////////////////////////////////// | |
228 // WidgetWin, NativeWidget implementation: | |
229 | |
230 void WidgetWin::InitNativeWidget(const Widget::InitParams& params) { | |
231 SetInitParams(params); | |
232 | |
233 // Create the window. | |
234 gfx::NativeView parent = params.parent_widget ? | |
235 params.parent_widget->GetNativeView() : params.parent; | |
236 WindowImpl::Init(parent, params.bounds); | |
237 } | |
238 | |
239 Widget* WidgetWin::GetWidget() { | |
240 return this; | |
241 } | 235 } |
242 | 236 |
243 void WidgetWin::SetNativeWindowProperty(const char* name, void* value) { | 237 void WidgetWin::SetNativeWindowProperty(const char* name, void* value) { |
244 // Remove the existing property (if any). | 238 // Remove the existing property (if any). |
245 for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { | 239 for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { |
246 if ((*i)->Key() == name) { | 240 if ((*i)->Key() == name) { |
247 props_.erase(i); | 241 props_.erase(i); |
248 break; | 242 break; |
249 } | 243 } |
250 } | 244 } |
251 | 245 |
252 if (value) | 246 if (value) |
253 props_.push_back(new ViewProp(hwnd(), name, value)); | 247 props_.push_back(new ViewProp(hwnd(), name, value)); |
254 } | 248 } |
255 | 249 |
256 void* WidgetWin::GetNativeWindowProperty(const char* name) { | 250 void* WidgetWin::GetNativeWindowProperty(const char* name) { |
257 return ViewProp::GetValue(hwnd(), name); | 251 return ViewProp::GetValue(hwnd(), name); |
258 } | 252 } |
259 | 253 |
260 TooltipManager* WidgetWin::GetTooltipManager() const { | 254 TooltipManager* WidgetWin::GetTooltipManager() const { |
261 return tooltip_manager_.get(); | 255 return tooltip_manager_.get(); |
262 } | 256 } |
263 | 257 |
264 bool WidgetWin::IsScreenReaderActive() const { | 258 bool WidgetWin::IsScreenReaderActive() const { |
265 return screen_reader_active_; | 259 return screen_reader_active_; |
266 } | 260 } |
267 | 261 |
| 262 void WidgetWin::SendNativeAccessibilityEvent( |
| 263 View* view, |
| 264 ui::AccessibilityTypes::Event event_type) { |
| 265 // Now call the Windows-specific method to notify MSAA clients of this |
| 266 // event. The widget gives us a temporary unique child ID to associate |
| 267 // with this view so that clients can call get_accChild in |
| 268 // NativeViewAccessibilityWin to retrieve the IAccessible associated |
| 269 // with this view. |
| 270 int child_id = AddAccessibilityViewEvent(view); |
| 271 ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), |
| 272 GetNativeView(), OBJID_CLIENT, child_id); |
| 273 } |
| 274 |
268 void WidgetWin::SetMouseCapture() { | 275 void WidgetWin::SetMouseCapture() { |
269 DCHECK(!HasMouseCapture()); | 276 DCHECK(!HasMouseCapture()); |
270 SetCapture(hwnd()); | 277 SetCapture(hwnd()); |
271 } | 278 } |
272 | 279 |
273 void WidgetWin::ReleaseMouseCapture() { | 280 void WidgetWin::ReleaseMouseCapture() { |
274 ReleaseCapture(); | 281 ReleaseCapture(); |
275 } | 282 } |
276 | 283 |
277 bool WidgetWin::HasMouseCapture() const { | 284 bool WidgetWin::HasMouseCapture() const { |
278 return GetCapture() == hwnd(); | 285 return GetCapture() == hwnd(); |
279 } | 286 } |
280 | 287 |
| 288 bool WidgetWin::IsMouseButtonDown() const { |
| 289 return (GetKeyState(VK_LBUTTON) & 0x80) || |
| 290 (GetKeyState(VK_RBUTTON) & 0x80) || |
| 291 (GetKeyState(VK_MBUTTON) & 0x80) || |
| 292 (GetKeyState(VK_XBUTTON1) & 0x80) || |
| 293 (GetKeyState(VK_XBUTTON2) & 0x80); |
| 294 } |
| 295 |
281 InputMethod* WidgetWin::GetInputMethodNative() { | 296 InputMethod* WidgetWin::GetInputMethodNative() { |
282 return input_method_.get(); | 297 return input_method_.get(); |
283 } | 298 } |
284 | 299 |
285 void WidgetWin::ReplaceInputMethod(InputMethod* input_method) { | 300 void WidgetWin::ReplaceInputMethod(InputMethod* input_method) { |
286 input_method_.reset(input_method); | 301 input_method_.reset(input_method); |
287 if (input_method) { | 302 if (input_method) { |
288 input_method->set_delegate(this); | 303 input_method->set_delegate(this); |
289 input_method->Init(GetWidget()); | 304 input_method->Init(GetWidget()); |
290 } | 305 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 455 |
441 void WidgetWin::SetCursor(gfx::NativeCursor cursor) { | 456 void WidgetWin::SetCursor(gfx::NativeCursor cursor) { |
442 if(cursor) { | 457 if(cursor) { |
443 previous_cursor_ = ::SetCursor(cursor); | 458 previous_cursor_ = ::SetCursor(cursor); |
444 } else if (previous_cursor_) { | 459 } else if (previous_cursor_) { |
445 ::SetCursor(previous_cursor_); | 460 ::SetCursor(previous_cursor_); |
446 previous_cursor_ = NULL; | 461 previous_cursor_ = NULL; |
447 } | 462 } |
448 } | 463 } |
449 | 464 |
450 void WidgetWin::NotifyAccessibilityEvent( | |
451 View* view, | |
452 ui::AccessibilityTypes::Event event_type, | |
453 bool send_native_event) { | |
454 // Send the notification to the delegate. | |
455 if (ViewsDelegate::views_delegate) | |
456 ViewsDelegate::views_delegate->NotifyAccessibilityEvent(view, event_type); | |
457 | |
458 // Now call the Windows-specific method to notify MSAA clients of this | |
459 // event. The widget gives us a temporary unique child ID to associate | |
460 // with this view so that clients can call get_accChild in | |
461 // NativeViewAccessibilityWin to retrieve the IAccessible associated | |
462 // with this view. | |
463 if (send_native_event) { | |
464 int child_id = AddAccessibilityViewEvent(view); | |
465 ::NotifyWinEvent(NativeViewAccessibilityWin::MSAAEvent(event_type), | |
466 GetNativeView(), OBJID_CLIENT, child_id); | |
467 } | |
468 } | |
469 | |
470 //////////////////////////////////////////////////////////////////////////////// | 465 //////////////////////////////////////////////////////////////////////////////// |
471 // WidgetWin, MessageLoop::Observer implementation: | 466 // WidgetWin, MessageLoop::Observer implementation: |
472 | 467 |
473 void WidgetWin::WillProcessMessage(const MSG& msg) { | 468 void WidgetWin::WillProcessMessage(const MSG& msg) { |
474 } | 469 } |
475 | 470 |
476 void WidgetWin::DidProcessMessage(const MSG& msg) { | 471 void WidgetWin::DidProcessMessage(const MSG& msg) { |
477 RedrawInvalidRect(); | 472 RedrawInvalidRect(); |
478 } | 473 } |
479 | 474 |
(...skipping 20 matching lines...) Expand all Loading... |
500 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) | 495 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) |
501 result = DefWindowProc(window, message, w_param, l_param); | 496 result = DefWindowProc(window, message, w_param, l_param); |
502 if (message == WM_NCDESTROY) { | 497 if (message == WM_NCDESTROY) { |
503 MessageLoopForUI::current()->RemoveObserver(this); | 498 MessageLoopForUI::current()->RemoveObserver(this); |
504 OnFinalMessage(window); | 499 OnFinalMessage(window); |
505 } | 500 } |
506 if (message == WM_ACTIVATE) | 501 if (message == WM_ACTIVATE) |
507 PostProcessActivateMessage(this, LOWORD(w_param)); | 502 PostProcessActivateMessage(this, LOWORD(w_param)); |
508 if (message == WM_ENABLE && restore_focus_when_enabled_) { | 503 if (message == WM_ENABLE && restore_focus_when_enabled_) { |
509 restore_focus_when_enabled_ = false; | 504 restore_focus_when_enabled_ = false; |
510 GetFocusManager()->RestoreFocusedView(); | 505 GetWidget()->GetFocusManager()->RestoreFocusedView(); |
511 } | 506 } |
512 return result; | 507 return result; |
513 } | 508 } |
514 | 509 |
515 //////////////////////////////////////////////////////////////////////////////// | 510 //////////////////////////////////////////////////////////////////////////////// |
516 // WidgetWin, protected: | 511 // WidgetWin, protected: |
517 | 512 |
518 // Message handlers ------------------------------------------------------------ | 513 // Message handlers ------------------------------------------------------------ |
519 | 514 |
520 void WidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { | 515 void WidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) { |
(...skipping 30 matching lines...) Expand all Loading... |
551 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); | 546 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); |
552 | 547 |
553 use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED); | 548 use_layered_buffer_ = !!(window_ex_style() & WS_EX_LAYERED); |
554 | 549 |
555 // Attempt to detect screen readers by sending an event with our custom id. | 550 // Attempt to detect screen readers by sending an event with our custom id. |
556 if (!IsAccessibleWidget()) | 551 if (!IsAccessibleWidget()) |
557 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kCustomObjectID, CHILDID_SELF); | 552 NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd(), kCustomObjectID, CHILDID_SELF); |
558 | 553 |
559 props_.push_back(SetWindowSupportsRerouteMouseWheel(hwnd())); | 554 props_.push_back(SetWindowSupportsRerouteMouseWheel(hwnd())); |
560 | 555 |
561 drop_target_ = new DropTargetWin(GetRootView()); | 556 drop_target_ = new DropTargetWin(GetWidget()->GetRootView()); |
562 | 557 |
563 // We need to add ourselves as a message loop observer so that we can repaint | 558 // We need to add ourselves as a message loop observer so that we can repaint |
564 // aggressively if the contents of our window become invalid. Unfortunately | 559 // aggressively if the contents of our window become invalid. Unfortunately |
565 // WM_PAINT messages are starved and we get flickery redrawing when resizing | 560 // WM_PAINT messages are starved and we get flickery redrawing when resizing |
566 // if we do not do this. | 561 // if we do not do this. |
567 MessageLoopForUI::current()->AddObserver(this); | 562 MessageLoopForUI::current()->AddObserver(this); |
568 | 563 |
569 // Windows special DWM window frame requires a special tooltip manager so | 564 // Windows special DWM window frame requires a special tooltip manager so |
570 // that window controls in Chrome windows don't flicker when you move your | 565 // that window controls in Chrome windows don't flicker when you move your |
571 // mouse over them. See comment in aero_tooltip_manager.h. | 566 // mouse over them. See comment in aero_tooltip_manager.h. |
572 if (GetThemeProvider()->ShouldUseNativeFrame()) { | 567 if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame()) { |
573 tooltip_manager_.reset(new AeroTooltipManager(this)); | 568 tooltip_manager_.reset(new AeroTooltipManager(GetWidget())); |
574 } else { | 569 } else { |
575 tooltip_manager_.reset(new TooltipManagerWin(this)); | 570 tooltip_manager_.reset(new TooltipManagerWin(GetWidget())); |
576 } | 571 } |
577 | 572 |
578 // This message initializes the window so that focus border are shown for | 573 // This message initializes the window so that focus border are shown for |
579 // windows. | 574 // windows. |
580 SendMessage( | 575 SendMessage( |
581 hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); | 576 hwnd(), WM_CHANGEUISTATE, MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); |
582 | 577 |
583 // Bug 964884: detach the IME attached to this window. | 578 // Bug 964884: detach the IME attached to this window. |
584 // We should attach IMEs only when we need to input CJK strings. | 579 // We should attach IMEs only when we need to input CJK strings. |
585 ImmAssociateContextEx(hwnd(), NULL, 0); | 580 ImmAssociateContextEx(hwnd(), NULL, 0); |
(...skipping 19 matching lines...) Expand all Loading... |
605 void WidgetWin::OnDestroy() { | 600 void WidgetWin::OnDestroy() { |
606 if (drop_target_.get()) { | 601 if (drop_target_.get()) { |
607 RevokeDragDrop(hwnd()); | 602 RevokeDragDrop(hwnd()); |
608 drop_target_ = NULL; | 603 drop_target_ = NULL; |
609 } | 604 } |
610 | 605 |
611 props_.reset(); | 606 props_.reset(); |
612 } | 607 } |
613 | 608 |
614 void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { | 609 void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) { |
615 if (widget_delegate()) | 610 if (GetWidget()->widget_delegate()) |
616 widget_delegate()->OnDisplayChanged(); | 611 GetWidget()->widget_delegate()->OnDisplayChanged(); |
617 } | 612 } |
618 | 613 |
619 LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg, | 614 LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg, |
620 WPARAM w_param, | 615 WPARAM w_param, |
621 LPARAM l_param) { | 616 LPARAM l_param) { |
622 SetMsgHandled(FALSE); | 617 SetMsgHandled(FALSE); |
623 return 0; | 618 return 0; |
624 } | 619 } |
625 | 620 |
626 void WidgetWin::OnEndSession(BOOL ending, UINT logoff) { | 621 void WidgetWin::OnEndSession(BOOL ending, UINT logoff) { |
(...skipping 17 matching lines...) Expand all Loading... |
644 SetMsgHandled(FALSE); | 639 SetMsgHandled(FALSE); |
645 } | 640 } |
646 | 641 |
647 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { | 642 LRESULT WidgetWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { |
648 LRESULT reference_result = static_cast<LRESULT>(0L); | 643 LRESULT reference_result = static_cast<LRESULT>(0L); |
649 | 644 |
650 // Accessibility readers will send an OBJID_CLIENT message | 645 // Accessibility readers will send an OBJID_CLIENT message |
651 if (OBJID_CLIENT == l_param) { | 646 if (OBJID_CLIENT == l_param) { |
652 // Retrieve MSAA dispatch object for the root view. | 647 // Retrieve MSAA dispatch object for the root view. |
653 base::win::ScopedComPtr<IAccessible> root( | 648 base::win::ScopedComPtr<IAccessible> root( |
654 NativeViewAccessibilityWin::GetAccessibleForView(GetRootView())); | 649 NativeViewAccessibilityWin::GetAccessibleForView( |
| 650 GetWidget()->GetRootView())); |
655 | 651 |
656 // Create a reference that MSAA will marshall to the client. | 652 // Create a reference that MSAA will marshall to the client. |
657 reference_result = LresultFromObject(IID_IAccessible, w_param, | 653 reference_result = LresultFromObject(IID_IAccessible, w_param, |
658 static_cast<IAccessible*>(root.Detach())); | 654 static_cast<IAccessible*>(root.Detach())); |
659 } | 655 } |
660 | 656 |
661 if (kCustomObjectID == l_param) { | 657 if (kCustomObjectID == l_param) { |
662 // An MSAA client requestes our custom id. Assume that we have detected an | 658 // An MSAA client requestes our custom id. Assume that we have detected an |
663 // active windows screen reader. | 659 // active windows screen reader. |
664 OnScreenReaderDetected(); | 660 OnScreenReaderDetected(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 // Reroute the mouse wheel to the window under the pointer if applicable. | 778 // Reroute the mouse wheel to the window under the pointer if applicable. |
783 return (views::RerouteMouseWheel(hwnd(), w_param, l_param) || | 779 return (views::RerouteMouseWheel(hwnd(), w_param, l_param) || |
784 delegate_->OnMouseEvent(MouseWheelEvent(msg))) ? 0 : 1; | 780 delegate_->OnMouseEvent(MouseWheelEvent(msg))) ? 0 : 1; |
785 } | 781 } |
786 | 782 |
787 SetMsgHandled(delegate_->OnMouseEvent(event)); | 783 SetMsgHandled(delegate_->OnMouseEvent(event)); |
788 return 0; | 784 return 0; |
789 } | 785 } |
790 | 786 |
791 void WidgetWin::OnMove(const CPoint& point) { | 787 void WidgetWin::OnMove(const CPoint& point) { |
792 if (widget_delegate()) | 788 // TODO(beng): move to Widget. |
793 widget_delegate()->OnWidgetMove(); | 789 if (GetWidget()->widget_delegate()) |
| 790 GetWidget()->widget_delegate()->OnWidgetMove(); |
794 SetMsgHandled(FALSE); | 791 SetMsgHandled(FALSE); |
795 } | 792 } |
796 | 793 |
797 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { | 794 void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) { |
798 if (widget_delegate()) | 795 // TODO(beng): move to Widget. |
799 widget_delegate()->OnWidgetMove(); | 796 if (GetWidget()->widget_delegate()) |
| 797 GetWidget()->widget_delegate()->OnWidgetMove(); |
800 } | 798 } |
801 | 799 |
802 LRESULT WidgetWin::OnNCActivate(BOOL active) { | 800 LRESULT WidgetWin::OnNCActivate(BOOL active) { |
803 SetMsgHandled(FALSE); | 801 SetMsgHandled(FALSE); |
804 return 0; | 802 return 0; |
805 } | 803 } |
806 | 804 |
807 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { | 805 LRESULT WidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) { |
808 SetMsgHandled(FALSE); | 806 SetMsgHandled(FALSE); |
809 return 0; | 807 return 0; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 SetMsgHandled(FALSE); | 884 SetMsgHandled(FALSE); |
887 return 0; | 885 return 0; |
888 } | 886 } |
889 | 887 |
890 LRESULT WidgetWin::OnSetText(const wchar_t* text) { | 888 LRESULT WidgetWin::OnSetText(const wchar_t* text) { |
891 SetMsgHandled(FALSE); | 889 SetMsgHandled(FALSE); |
892 return 0; | 890 return 0; |
893 } | 891 } |
894 | 892 |
895 void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { | 893 void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { |
896 if (flags == SPI_SETWORKAREA && widget_delegate()) | 894 // TODO(beng): move to Widget. |
897 widget_delegate()->OnWorkAreaChanged(); | 895 if (flags == SPI_SETWORKAREA && GetWidget()->widget_delegate()) |
| 896 GetWidget()->widget_delegate()->OnWorkAreaChanged(); |
898 SetMsgHandled(FALSE); | 897 SetMsgHandled(FALSE); |
899 } | 898 } |
900 | 899 |
901 void WidgetWin::OnSize(UINT param, const CSize& size) { | 900 void WidgetWin::OnSize(UINT param, const CSize& size) { |
902 SetMsgHandled(FALSE); | 901 SetMsgHandled(FALSE); |
903 } | 902 } |
904 | 903 |
905 void WidgetWin::OnSysCommand(UINT notification_code, CPoint click) { | 904 void WidgetWin::OnSysCommand(UINT notification_code, CPoint click) { |
906 } | 905 } |
907 | 906 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 953 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
955 TrackMouseEvents(mouse_tracking_flags); | 954 TrackMouseEvents(mouse_tracking_flags); |
956 } | 955 } |
957 } | 956 } |
958 | 957 |
959 void WidgetWin::OnScreenReaderDetected() { | 958 void WidgetWin::OnScreenReaderDetected() { |
960 screen_reader_active_ = true; | 959 screen_reader_active_ = true; |
961 } | 960 } |
962 | 961 |
963 void WidgetWin::SetInitialFocus() { | 962 void WidgetWin::SetInitialFocus() { |
964 View* v = widget_delegate() ? | 963 // TODO(beng): move to Widget. |
965 widget_delegate()->GetInitiallyFocusedView() : NULL; | 964 View* v = GetWidget()->widget_delegate() ? |
| 965 GetWidget()->widget_delegate()->GetInitiallyFocusedView() : NULL; |
966 if (v) | 966 if (v) |
967 v->RequestFocus(); | 967 v->RequestFocus(); |
968 } | 968 } |
969 | 969 |
970 //////////////////////////////////////////////////////////////////////////////// | 970 //////////////////////////////////////////////////////////////////////////////// |
971 // WidgetWin, private: | 971 // WidgetWin, private: |
972 | 972 |
973 // static | 973 // static |
974 Window* WidgetWin::GetWindowImpl(HWND hwnd) { | 974 Window* WidgetWin::GetWindowImpl(HWND hwnd) { |
975 // NOTE: we can't use GetAncestor here as constrained windows are a Window, | 975 // NOTE: we can't use GetAncestor here as constrained windows are a Window, |
976 // but not a top level window. | 976 // but not a top level window. |
977 HWND parent = hwnd; | 977 HWND parent = hwnd; |
978 while (parent) { | 978 while (parent) { |
979 WidgetWin* widget = | 979 WidgetWin* widget = |
980 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); | 980 reinterpret_cast<WidgetWin*>(ui::GetWindowUserData(parent)); |
981 if (widget && widget->is_window_) | 981 if (widget && widget->is_window_) |
982 return static_cast<WindowWin*>(widget); | 982 return static_cast<WindowWin*>(widget)->GetWindow(); |
983 parent = ::GetParent(parent); | 983 parent = ::GetParent(parent); |
984 } | 984 } |
985 return NULL; | 985 return NULL; |
986 } | 986 } |
987 | 987 |
988 // static | 988 // static |
989 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, | 989 void WidgetWin::PostProcessActivateMessage(WidgetWin* widget, |
990 int activation_state) { | 990 int activation_state) { |
991 if (!widget->delegate_->HasFocusManager()) { | 991 if (!widget->delegate_->HasFocusManager()) { |
992 NOTREACHED(); | 992 NOTREACHED(); |
(...skipping 16 matching lines...) Expand all Loading... |
1009 // again. | 1009 // again. |
1010 if (!IsWindowEnabled(widget->GetNativeView())) { | 1010 if (!IsWindowEnabled(widget->GetNativeView())) { |
1011 DCHECK(!widget->restore_focus_when_enabled_); | 1011 DCHECK(!widget->restore_focus_when_enabled_); |
1012 widget->restore_focus_when_enabled_ = true; | 1012 widget->restore_focus_when_enabled_ = true; |
1013 return; | 1013 return; |
1014 } | 1014 } |
1015 focus_manager->RestoreFocusedView(); | 1015 focus_manager->RestoreFocusedView(); |
1016 } | 1016 } |
1017 } | 1017 } |
1018 | 1018 |
1019 void WidgetWin::SetInitParams(const InitParams& params) { | 1019 void WidgetWin::SetInitParams(const Widget::InitParams& params) { |
1020 // Set non-style attributes. | 1020 // Set non-style attributes. |
1021 delete_on_destroy_ = params.delete_on_destroy; | 1021 delete_on_destroy_ = params.delete_on_destroy; |
1022 | 1022 |
1023 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | 1023 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
1024 DWORD ex_style = 0; | 1024 DWORD ex_style = 0; |
1025 DWORD class_style = CS_DBLCLKS; | 1025 DWORD class_style = CS_DBLCLKS; |
1026 | 1026 |
1027 // Set type-independent style attributes. | 1027 // Set type-independent style attributes. |
1028 if (params.child) | 1028 if (params.child) |
1029 style |= WS_CHILD | WS_VISIBLE; | 1029 style |= WS_CHILD | WS_VISIBLE; |
1030 if (!params.accept_events) | 1030 if (!params.accept_events) |
1031 ex_style |= WS_EX_TRANSPARENT; | 1031 ex_style |= WS_EX_TRANSPARENT; |
1032 if (!params.can_activate) | 1032 if (!params.can_activate) |
1033 ex_style |= WS_EX_NOACTIVATE; | 1033 ex_style |= WS_EX_NOACTIVATE; |
1034 if (params.keep_on_top) | 1034 if (params.keep_on_top) |
1035 ex_style |= WS_EX_TOPMOST; | 1035 ex_style |= WS_EX_TOPMOST; |
1036 if (params.mirror_origin_in_rtl) | 1036 if (params.mirror_origin_in_rtl) |
1037 ex_style |= l10n_util::GetExtendedTooltipStyles(); | 1037 ex_style |= l10n_util::GetExtendedTooltipStyles(); |
1038 if (params.transparent) | 1038 if (params.transparent) |
1039 ex_style |= WS_EX_LAYERED; | 1039 ex_style |= WS_EX_LAYERED; |
1040 if (params.has_dropshadow) { | 1040 if (params.has_dropshadow) { |
1041 class_style |= (base::win::GetVersion() < base::win::VERSION_XP) ? | 1041 class_style |= (base::win::GetVersion() < base::win::VERSION_XP) ? |
1042 0 : CS_DROPSHADOW; | 1042 0 : CS_DROPSHADOW; |
1043 } | 1043 } |
1044 | 1044 |
1045 // Set type-dependent style attributes. | 1045 // Set type-dependent style attributes. |
1046 switch (params.type) { | 1046 switch (params.type) { |
1047 case InitParams::TYPE_WINDOW: | 1047 case Widget::InitParams::TYPE_WINDOW: |
1048 case InitParams::TYPE_CONTROL: | 1048 case Widget::InitParams::TYPE_CONTROL: |
1049 break; | 1049 break; |
1050 case InitParams::TYPE_POPUP: | 1050 case Widget::InitParams::TYPE_POPUP: |
1051 style |= WS_POPUP; | 1051 style |= WS_POPUP; |
1052 ex_style |= WS_EX_TOOLWINDOW; | 1052 ex_style |= WS_EX_TOOLWINDOW; |
1053 break; | 1053 break; |
1054 case InitParams::TYPE_MENU: | 1054 case Widget::InitParams::TYPE_MENU: |
1055 style |= WS_POPUP; | 1055 style |= WS_POPUP; |
1056 is_mouse_button_pressed_ = | |
1057 ((GetKeyState(VK_LBUTTON) & 0x80) || | |
1058 (GetKeyState(VK_RBUTTON) & 0x80) || | |
1059 (GetKeyState(VK_MBUTTON) & 0x80) || | |
1060 (GetKeyState(VK_XBUTTON1) & 0x80) || | |
1061 (GetKeyState(VK_XBUTTON2) & 0x80)); | |
1062 break; | 1056 break; |
1063 default: | 1057 default: |
1064 NOTREACHED(); | 1058 NOTREACHED(); |
1065 } | 1059 } |
1066 | 1060 |
1067 set_initial_class_style(class_style); | 1061 set_initial_class_style(class_style); |
1068 set_window_style(window_style() | style); | 1062 set_window_style(window_style() | style); |
1069 set_window_ex_style(window_ex_style() | ex_style); | 1063 set_window_ex_style(window_ex_style() | ex_style); |
1070 } | 1064 } |
1071 | 1065 |
(...skipping 10 matching lines...) Expand all Loading... |
1082 void WidgetWin::RedrawLayeredWindowContents() { | 1076 void WidgetWin::RedrawLayeredWindowContents() { |
1083 if (layered_window_invalid_rect_.IsEmpty()) | 1077 if (layered_window_invalid_rect_.IsEmpty()) |
1084 return; | 1078 return; |
1085 | 1079 |
1086 // We need to clip to the dirty rect ourselves. | 1080 // We need to clip to the dirty rect ourselves. |
1087 layered_window_contents_->save(SkCanvas::kClip_SaveFlag); | 1081 layered_window_contents_->save(SkCanvas::kClip_SaveFlag); |
1088 layered_window_contents_->ClipRectInt(layered_window_invalid_rect_.x(), | 1082 layered_window_contents_->ClipRectInt(layered_window_invalid_rect_.x(), |
1089 layered_window_invalid_rect_.y(), | 1083 layered_window_invalid_rect_.y(), |
1090 layered_window_invalid_rect_.width(), | 1084 layered_window_invalid_rect_.width(), |
1091 layered_window_invalid_rect_.height()); | 1085 layered_window_invalid_rect_.height()); |
1092 GetRootView()->Paint(layered_window_contents_.get()); | 1086 GetWidget()->GetRootView()->Paint(layered_window_contents_.get()); |
1093 layered_window_contents_->restore(); | 1087 layered_window_contents_->restore(); |
1094 | 1088 |
1095 RECT wr; | 1089 RECT wr; |
1096 GetWindowRect(&wr); | 1090 GetWindowRect(&wr); |
1097 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; | 1091 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; |
1098 POINT position = {wr.left, wr.top}; | 1092 POINT position = {wr.left, wr.top}; |
1099 HDC dib_dc = layered_window_contents_->beginPlatformPaint(); | 1093 HDC dib_dc = layered_window_contents_->beginPlatformPaint(); |
1100 POINT zero = {0, 0}; | 1094 POINT zero = {0, 0}; |
1101 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; | 1095 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; |
1102 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, | 1096 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, |
1103 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); | 1097 RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); |
1104 layered_window_invalid_rect_.SetRect(0, 0, 0, 0); | 1098 layered_window_invalid_rect_.SetRect(0, 0, 0, 0); |
1105 layered_window_contents_->endPlatformPaint(); | 1099 layered_window_contents_->endPlatformPaint(); |
1106 } | 1100 } |
1107 | 1101 |
1108 void WidgetWin::ClientAreaSizeChanged() { | 1102 void WidgetWin::ClientAreaSizeChanged() { |
1109 RECT r; | 1103 RECT r; |
1110 if (GetThemeProvider()->ShouldUseNativeFrame() || IsZoomed()) | 1104 if (GetWidget()->GetThemeProvider()->ShouldUseNativeFrame() || IsZoomed()) |
1111 GetClientRect(&r); | 1105 GetClientRect(&r); |
1112 else | 1106 else |
1113 GetWindowRect(&r); | 1107 GetWindowRect(&r); |
1114 gfx::Size s(std::max(0, static_cast<int>(r.right - r.left)), | 1108 gfx::Size s(std::max(0, static_cast<int>(r.right - r.left)), |
1115 std::max(0, static_cast<int>(r.bottom - r.top))); | 1109 std::max(0, static_cast<int>(r.bottom - r.top))); |
1116 delegate_->OnSizeChanged(s); | 1110 delegate_->OnSizeChanged(s); |
1117 if (use_layered_buffer_) { | 1111 if (use_layered_buffer_) { |
1118 layered_window_contents_.reset( | 1112 layered_window_contents_.reset( |
1119 new gfx::CanvasSkia(s.width(), s.height(), false)); | 1113 new gfx::CanvasSkia(s.width(), s.height(), false)); |
1120 } | 1114 } |
1121 } | 1115 } |
1122 | 1116 |
1123 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { | 1117 gfx::AcceleratedWidget WidgetWin::GetAcceleratedWidget() { |
1124 // TODO(sky): | 1118 // TODO(sky): |
1125 return gfx::kNullAcceleratedWidget; | 1119 return gfx::kNullAcceleratedWidget; |
1126 } | 1120 } |
1127 | 1121 |
1128 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { | 1122 void WidgetWin::DispatchKeyEventPostIME(const KeyEvent& key) { |
1129 SetMsgHandled(delegate_->OnKeyEvent(key)); | 1123 SetMsgHandled(delegate_->OnKeyEvent(key)); |
1130 } | 1124 } |
1131 | 1125 |
1132 //////////////////////////////////////////////////////////////////////////////// | 1126 //////////////////////////////////////////////////////////////////////////////// |
1133 // Widget, public: | 1127 // Widget, public: |
1134 | 1128 |
1135 // static | 1129 // static |
1136 Widget* Widget::CreateWidget() { | |
1137 return new WidgetWin; | |
1138 } | |
1139 | |
1140 // static | |
1141 void Widget::NotifyLocaleChanged() { | 1130 void Widget::NotifyLocaleChanged() { |
1142 NOTIMPLEMENTED(); | 1131 NOTIMPLEMENTED(); |
1143 } | 1132 } |
1144 | 1133 |
| 1134 namespace { |
| 1135 BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) { |
| 1136 NativeWidget* native_widget = |
| 1137 NativeWidget::GetNativeWidgetForNativeView(hwnd); |
| 1138 if (native_widget) { |
| 1139 Widget* widget = native_widget->GetWidget(); |
| 1140 if (widget->is_secondary_widget()) |
| 1141 widget->Close(); |
| 1142 } |
| 1143 return TRUE; |
| 1144 } |
| 1145 } // namespace |
| 1146 |
| 1147 // static |
| 1148 void Widget::CloseAllSecondaryWidgets() { |
| 1149 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); |
| 1150 } |
| 1151 |
1145 bool Widget::ConvertRect(const Widget* source, | 1152 bool Widget::ConvertRect(const Widget* source, |
1146 const Widget* target, | 1153 const Widget* target, |
1147 gfx::Rect* rect) { | 1154 gfx::Rect* rect) { |
1148 DCHECK(source); | 1155 DCHECK(source); |
1149 DCHECK(target); | 1156 DCHECK(target); |
1150 DCHECK(rect); | 1157 DCHECK(rect); |
1151 | 1158 |
1152 HWND source_hwnd = source->GetNativeView(); | 1159 HWND source_hwnd = source->GetNativeView(); |
1153 HWND target_hwnd = target->GetNativeView(); | 1160 HWND target_hwnd = target->GetNativeView(); |
1154 if (source_hwnd == target_hwnd) | 1161 if (source_hwnd == target_hwnd) |
1155 return true; | 1162 return true; |
1156 | 1163 |
1157 RECT win_rect = rect->ToRECT(); | 1164 RECT win_rect = rect->ToRECT(); |
1158 if (::MapWindowPoints(source_hwnd, target_hwnd, | 1165 if (::MapWindowPoints(source_hwnd, target_hwnd, |
1159 reinterpret_cast<LPPOINT>(&win_rect), | 1166 reinterpret_cast<LPPOINT>(&win_rect), |
1160 sizeof(RECT)/sizeof(POINT))) { | 1167 sizeof(RECT)/sizeof(POINT))) { |
1161 *rect = win_rect; | 1168 *rect = win_rect; |
1162 return true; | 1169 return true; |
1163 } | 1170 } |
1164 return false; | 1171 return false; |
1165 } | 1172 } |
1166 | 1173 |
1167 //////////////////////////////////////////////////////////////////////////////// | 1174 //////////////////////////////////////////////////////////////////////////////// |
1168 // NativeWidget, public: | 1175 // NativeWidget, public: |
1169 | 1176 |
| 1177 // static |
| 1178 NativeWidget* NativeWidget::CreateNativeWidget( |
| 1179 internal::NativeWidgetDelegate* delegate) { |
| 1180 return new WidgetWin(delegate); |
| 1181 } |
| 1182 |
| 1183 // static |
1170 NativeWidget* NativeWidget::GetNativeWidgetForNativeView( | 1184 NativeWidget* NativeWidget::GetNativeWidgetForNativeView( |
1171 gfx::NativeView native_view) { | 1185 gfx::NativeView native_view) { |
1172 return reinterpret_cast<WidgetWin*>( | 1186 return reinterpret_cast<WidgetWin*>( |
1173 ViewProp::GetValue(native_view, kNativeWidgetKey)); | 1187 ViewProp::GetValue(native_view, kNativeWidgetKey)); |
1174 } | 1188 } |
1175 | 1189 |
| 1190 // static |
1176 NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow( | 1191 NativeWidget* NativeWidget::GetNativeWidgetForNativeWindow( |
1177 gfx::NativeWindow native_window) { | 1192 gfx::NativeWindow native_window) { |
1178 return GetNativeWidgetForNativeView(native_window); | 1193 return GetNativeWidgetForNativeView(native_window); |
1179 } | 1194 } |
1180 | 1195 |
| 1196 // static |
1181 NativeWidget* NativeWidget::GetTopLevelNativeWidget( | 1197 NativeWidget* NativeWidget::GetTopLevelNativeWidget( |
1182 gfx::NativeView native_view) { | 1198 gfx::NativeView native_view) { |
1183 if (!native_view) | 1199 if (!native_view) |
1184 return NULL; | 1200 return NULL; |
1185 | 1201 |
1186 // First, check if the top-level window is a Widget. | 1202 // First, check if the top-level window is a Widget. |
1187 HWND root = ::GetAncestor(native_view, GA_ROOT); | 1203 HWND root = ::GetAncestor(native_view, GA_ROOT); |
1188 if (!root) | 1204 if (!root) |
1189 return NULL; | 1205 return NULL; |
1190 | 1206 |
1191 NativeWidget* widget = GetNativeWidgetForNativeView(root); | 1207 NativeWidget* widget = GetNativeWidgetForNativeView(root); |
1192 if (widget) | 1208 if (widget) |
1193 return widget; | 1209 return widget; |
1194 | 1210 |
1195 // Second, try to locate the last Widget window in the parent hierarchy. | 1211 // Second, try to locate the last Widget window in the parent hierarchy. |
1196 HWND parent_hwnd = native_view; | 1212 HWND parent_hwnd = native_view; |
1197 NativeWidget* parent_widget; | 1213 NativeWidget* parent_widget; |
1198 do { | 1214 do { |
1199 parent_widget = GetNativeWidgetForNativeView(parent_hwnd); | 1215 parent_widget = GetNativeWidgetForNativeView(parent_hwnd); |
1200 if (parent_widget) { | 1216 if (parent_widget) { |
1201 widget = parent_widget; | 1217 widget = parent_widget; |
1202 parent_hwnd = ::GetAncestor(parent_hwnd, GA_PARENT); | 1218 parent_hwnd = ::GetAncestor(parent_hwnd, GA_PARENT); |
1203 } | 1219 } |
1204 } while (parent_hwnd != NULL && parent_widget != NULL); | 1220 } while (parent_hwnd != NULL && parent_widget != NULL); |
1205 | 1221 |
1206 return widget; | 1222 return widget; |
1207 } | 1223 } |
1208 | 1224 |
| 1225 // static |
1209 void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view, | 1226 void NativeWidget::GetAllNativeWidgets(gfx::NativeView native_view, |
1210 NativeWidgets* children) { | 1227 NativeWidgets* children) { |
1211 if (!native_view) | 1228 if (!native_view) |
1212 return; | 1229 return; |
1213 | 1230 |
1214 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); | 1231 NativeWidget* native_widget = GetNativeWidgetForNativeView(native_view); |
1215 if (native_widget) | 1232 if (native_widget) |
1216 children->insert(native_widget); | 1233 children->insert(native_widget); |
1217 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, | 1234 EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets, |
1218 reinterpret_cast<LPARAM>(children)); | 1235 reinterpret_cast<LPARAM>(children)); |
1219 } | 1236 } |
1220 | 1237 |
| 1238 // static |
1221 void NativeWidget::ReparentNativeView(gfx::NativeView native_view, | 1239 void NativeWidget::ReparentNativeView(gfx::NativeView native_view, |
1222 gfx::NativeView new_parent) { | 1240 gfx::NativeView new_parent) { |
1223 if (!native_view) | 1241 if (!native_view) |
1224 return; | 1242 return; |
1225 | 1243 |
1226 HWND previous_parent = ::GetParent(native_view); | 1244 HWND previous_parent = ::GetParent(native_view); |
1227 if (previous_parent == new_parent) | 1245 if (previous_parent == new_parent) |
1228 return; | 1246 return; |
1229 | 1247 |
1230 NativeWidgets widgets; | 1248 NativeWidgets widgets; |
(...skipping 13 matching lines...) Expand all Loading... |
1244 | 1262 |
1245 // And now, notify them that they have a brand new parent. | 1263 // And now, notify them that they have a brand new parent. |
1246 for (NativeWidgets::iterator it = widgets.begin(); | 1264 for (NativeWidgets::iterator it = widgets.begin(); |
1247 it != widgets.end(); ++it) { | 1265 it != widgets.end(); ++it) { |
1248 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, | 1266 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, |
1249 new_parent); | 1267 new_parent); |
1250 } | 1268 } |
1251 } | 1269 } |
1252 | 1270 |
1253 } // namespace views | 1271 } // namespace views |
OLD | NEW |