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

Side by Side Diff: ui/views/widget/native_widget_win.cc

Issue 10867096: Make HWNDMessageHandler subclass WindowImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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) 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 "ui/views/widget/native_widget_win.h" 5 #include "ui/views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (*it == view) 140 if (*it == view)
141 *it = NULL; 141 *it = NULL;
142 } 142 }
143 } 143 }
144 144
145 //////////////////////////////////////////////////////////////////////////////// 145 ////////////////////////////////////////////////////////////////////////////////
146 // NativeWidgetWin, NativeWidget implementation: 146 // NativeWidgetWin, NativeWidget implementation:
147 147
148 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) { 148 void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) {
149 SetInitParams(params); 149 SetInitParams(params);
150 150 message_handler_->Init(params.GetParent(), params.bounds);
151 message_handler_->Init(params.bounds);
152
153 // Create the window.
154 WindowImpl::Init(params.GetParent(), params.bounds);
155 } 151 }
156 152
157 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() { 153 NonClientFrameView* NativeWidgetWin::CreateNonClientFrameView() {
158 return GetWidget()->ShouldUseNativeFrame() ? 154 return GetWidget()->ShouldUseNativeFrame() ?
159 new NativeFrameView(GetWidget()) : NULL; 155 new NativeFrameView(GetWidget()) : NULL;
160 } 156 }
161 157
162 void NativeWidgetWin::UpdateFrameAfterFrameChange() { 158 void NativeWidgetWin::UpdateFrameAfterFrameChange() {
163 // We've either gained or lost a custom window region, so reset it now. 159 // We've either gained or lost a custom window region, so reset it now.
164 message_handler_->ResetWindowRegion(true); 160 message_handler_->ResetWindowRegion(true);
165 } 161 }
166 162
167 bool NativeWidgetWin::ShouldUseNativeFrame() const { 163 bool NativeWidgetWin::ShouldUseNativeFrame() const {
168 return ui::win::IsAeroGlassEnabled(); 164 return ui::win::IsAeroGlassEnabled();
169 } 165 }
170 166
171 void NativeWidgetWin::FrameTypeChanged() { 167 void NativeWidgetWin::FrameTypeChanged() {
172 message_handler_->FrameTypeChanged(); 168 message_handler_->FrameTypeChanged();
173 } 169 }
174 170
175 Widget* NativeWidgetWin::GetWidget() { 171 Widget* NativeWidgetWin::GetWidget() {
176 return delegate_->AsWidget(); 172 return delegate_->AsWidget();
177 } 173 }
178 174
179 const Widget* NativeWidgetWin::GetWidget() const { 175 const Widget* NativeWidgetWin::GetWidget() const {
180 return delegate_->AsWidget(); 176 return delegate_->AsWidget();
181 } 177 }
182 178
183 gfx::NativeView NativeWidgetWin::GetNativeView() const { 179 gfx::NativeView NativeWidgetWin::GetNativeView() const {
184 return WindowImpl::hwnd(); 180 return message_handler_->hwnd();
185 } 181 }
186 182
187 gfx::NativeWindow NativeWidgetWin::GetNativeWindow() const { 183 gfx::NativeWindow NativeWidgetWin::GetNativeWindow() const {
188 return WindowImpl::hwnd(); 184 return message_handler_->hwnd();
189 } 185 }
190 186
191 Widget* NativeWidgetWin::GetTopLevelWidget() { 187 Widget* NativeWidgetWin::GetTopLevelWidget() {
192 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView()); 188 NativeWidgetPrivate* native_widget = GetTopLevelNativeWidget(GetNativeView());
193 return native_widget ? native_widget->GetWidget() : NULL; 189 return native_widget ? native_widget->GetWidget() : NULL;
194 } 190 }
195 191
196 const ui::Compositor* NativeWidgetWin::GetCompositor() const { 192 const ui::Compositor* NativeWidgetWin::GetCompositor() const {
197 return NULL; 193 return NULL;
198 } 194 }
(...skipping 17 matching lines...) Expand all
216 void NativeWidgetWin::SetNativeWindowProperty(const char* name, void* value) { 212 void NativeWidgetWin::SetNativeWindowProperty(const char* name, void* value) {
217 // Remove the existing property (if any). 213 // Remove the existing property (if any).
218 for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { 214 for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) {
219 if ((*i)->Key() == name) { 215 if ((*i)->Key() == name) {
220 props_.erase(i); 216 props_.erase(i);
221 break; 217 break;
222 } 218 }
223 } 219 }
224 220
225 if (value) 221 if (value)
226 props_.push_back(new ViewProp(hwnd(), name, value)); 222 props_.push_back(new ViewProp(GetNativeView(), name, value));
227 } 223 }
228 224
229 void* NativeWidgetWin::GetNativeWindowProperty(const char* name) const { 225 void* NativeWidgetWin::GetNativeWindowProperty(const char* name) const {
230 return ViewProp::GetValue(hwnd(), name); 226 return ViewProp::GetValue(GetNativeView(), name);
231 } 227 }
232 228
233 TooltipManager* NativeWidgetWin::GetTooltipManager() const { 229 TooltipManager* NativeWidgetWin::GetTooltipManager() const {
234 return tooltip_manager_.get(); 230 return tooltip_manager_.get();
235 } 231 }
236 232
237 bool NativeWidgetWin::IsScreenReaderActive() const { 233 bool NativeWidgetWin::IsScreenReaderActive() const {
238 return screen_reader_active_; 234 return screen_reader_active_;
239 } 235 }
240 236
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 418 }
423 419
424 void NativeWidgetWin::SetOpacity(unsigned char opacity) { 420 void NativeWidgetWin::SetOpacity(unsigned char opacity) {
425 message_handler_->SetOpacity(static_cast<BYTE>(opacity)); 421 message_handler_->SetOpacity(static_cast<BYTE>(opacity));
426 GetWidget()->GetRootView()->SchedulePaint(); 422 GetWidget()->GetRootView()->SchedulePaint();
427 } 423 }
428 424
429 void NativeWidgetWin::SetUseDragFrame(bool use_drag_frame) { 425 void NativeWidgetWin::SetUseDragFrame(bool use_drag_frame) {
430 if (use_drag_frame) { 426 if (use_drag_frame) {
431 // Make the frame slightly transparent during the drag operation. 427 // Make the frame slightly transparent during the drag operation.
432 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE); 428 drag_frame_saved_window_style_ = GetWindowLong(GetNativeView(), GWL_STYLE);
433 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE); 429 drag_frame_saved_window_ex_style_ =
434 SetWindowLong(GWL_EXSTYLE, 430 GetWindowLong(GetNativeView(), GWL_EXSTYLE);
431 SetWindowLong(GetNativeView(), GWL_EXSTYLE,
435 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED); 432 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
436 // Remove the captions tyle so the window doesn't have window controls for a 433 // Remove the captions tyle so the window doesn't have window controls for a
437 // more "transparent" look. 434 // more "transparent" look.
438 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); 435 SetWindowLong(GetNativeView(), GWL_STYLE,
436 drag_frame_saved_window_style_ & ~WS_CAPTION);
439 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), 437 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
440 kDragFrameWindowAlpha, LWA_ALPHA); 438 kDragFrameWindowAlpha, LWA_ALPHA);
441 } else { 439 } else {
442 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); 440 SetWindowLong(GetNativeView(), GWL_STYLE, drag_frame_saved_window_style_);
443 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); 441 SetWindowLong(GetNativeView(), GWL_EXSTYLE,
442 drag_frame_saved_window_ex_style_);
444 } 443 }
445 } 444 }
446 445
447 void NativeWidgetWin::FlashFrame(bool flash) { 446 void NativeWidgetWin::FlashFrame(bool flash) {
448 message_handler_->FlashFrame(flash); 447 message_handler_->FlashFrame(flash);
449 } 448 }
450 449
451 bool NativeWidgetWin::IsAccessibleWidget() const { 450 bool NativeWidgetWin::IsAccessibleWidget() const {
452 return screen_reader_active_; 451 return screen_reader_active_;
453 } 452 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 489
491 void NativeWidgetWin::EndMoveLoop() { 490 void NativeWidgetWin::EndMoveLoop() {
492 message_handler_->EndMoveLoop(); 491 message_handler_->EndMoveLoop();
493 } 492 }
494 493
495 void NativeWidgetWin::SetVisibilityChangedAnimationsEnabled(bool value) { 494 void NativeWidgetWin::SetVisibilityChangedAnimationsEnabled(bool value) {
496 message_handler_->SetVisibilityChangedAnimationsEnabled(value); 495 message_handler_->SetVisibilityChangedAnimationsEnabled(value);
497 } 496 }
498 497
499 //////////////////////////////////////////////////////////////////////////////// 498 ////////////////////////////////////////////////////////////////////////////////
500 // NativeWidgetWin, MessageLoop::Observer implementation:
501
502 base::EventStatus NativeWidgetWin::WillProcessEvent(
503 const base::NativeEvent& event) {
504 return base::EVENT_CONTINUE;
505 }
506
507 void NativeWidgetWin::DidProcessEvent(const base::NativeEvent& event) {
508 message_handler_->RedrawInvalidRect();
509 }
510
511 ////////////////////////////////////////////////////////////////////////////////
512 // NativeWidgetWin, WindowImpl overrides:
513
514 HICON NativeWidgetWin::GetDefaultWindowIcon() const {
515 return message_handler_->GetDefaultWindowIcon();
516 }
517
518 LRESULT NativeWidgetWin::OnWndProc(UINT message,
519 WPARAM w_param,
520 LPARAM l_param) {
521 return message_handler_->OnWndProc(message, w_param, l_param);
522 }
523
524 ////////////////////////////////////////////////////////////////////////////////
525 // NativeWidgetWin, protected: 499 // NativeWidgetWin, protected:
526 500
527 // Message handlers ------------------------------------------------------------
528
529 void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) {
530 message_handler_->OnActivate(action, minimized, window);
531 }
532
533 void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) {
534 message_handler_->OnActivateApp(active, thread_id);
535 }
536
537 LRESULT NativeWidgetWin::OnAppCommand(HWND window,
538 short app_command,
539 WORD device,
540 int keystate) {
541 return message_handler_->OnAppCommand(window, app_command, device, keystate);
542 }
543
544 void NativeWidgetWin::OnCancelMode() {
545 message_handler_->OnCancelMode();
546 }
547
548 void NativeWidgetWin::OnCaptureChanged(HWND hwnd) {
549 message_handler_->OnCaptureChanged(hwnd);
550 }
551
552 void NativeWidgetWin::OnClose() {
553 message_handler_->OnClose();
554 }
555
556 void NativeWidgetWin::OnCommand(UINT notification_code,
557 int command_id,
558 HWND window) {
559 message_handler_->OnCommand(notification_code, command_id, window);
560 }
561
562 LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
563 return message_handler_->OnCreate(create_struct);
564 }
565
566 void NativeWidgetWin::OnDestroy() {
567 message_handler_->OnDestroy();
568 }
569
570 void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
571 message_handler_->OnDisplayChange(bits_per_pixel, screen_size);
572 }
573
574 LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg,
575 WPARAM w_param,
576 LPARAM l_param) {
577 return message_handler_->OnDwmCompositionChanged(msg, w_param, l_param);
578 }
579
580 void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) {
581 message_handler_->OnEndSession(ending, logoff);
582 }
583
584 void NativeWidgetWin::OnEnterSizeMove() {
585 message_handler_->OnEnterSizeMove();
586 }
587
588 LRESULT NativeWidgetWin::OnEraseBkgnd(HDC dc) {
589 return message_handler_->OnEraseBkgnd(dc);
590 }
591
592 void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) {
593 message_handler_->OnExitMenuLoop(is_track_popup_menu);
594 }
595
596 void NativeWidgetWin::OnExitSizeMove() {
597 message_handler_->OnExitSizeMove();
598 }
599
600 LRESULT NativeWidgetWin::OnGetObject(UINT message,
601 WPARAM w_param,
602 LPARAM l_param) {
603 return message_handler_->OnGetObject(message, w_param, l_param);
604 }
605
606 void NativeWidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
607 message_handler_->OnGetMinMaxInfo(minmax_info);
608 }
609
610 void NativeWidgetWin::OnHScroll(int scroll_type,
611 short position,
612 HWND scrollbar) {
613 message_handler_->OnHScroll(scroll_type, position, scrollbar);
614 }
615
616 LRESULT NativeWidgetWin::OnImeMessages(UINT message,
617 WPARAM w_param,
618 LPARAM l_param) {
619 return message_handler_->OnImeMessages(message, w_param, l_param);
620 }
621
622 void NativeWidgetWin::OnInitMenu(HMENU menu) {
623 message_handler_->OnInitMenu(menu);
624 }
625
626 void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
627 UINT position,
628 BOOL is_system_menu) {
629 message_handler_->OnInitMenuPopup();
630 }
631
632 void NativeWidgetWin::OnInputLangChange(DWORD character_set,
633 HKL input_language_id) {
634 message_handler_->OnInputLangChange(character_set, input_language_id);
635 }
636
637 LRESULT NativeWidgetWin::OnKeyEvent(UINT message,
638 WPARAM w_param,
639 LPARAM l_param) {
640 return message_handler_->OnKeyEvent(message, w_param, l_param);
641 }
642
643 void NativeWidgetWin::OnKillFocus(HWND focused_window) {
644 message_handler_->OnKillFocus(focused_window);
645 }
646
647 LRESULT NativeWidgetWin::OnMouseActivate(UINT message,
648 WPARAM w_param,
649 LPARAM l_param) {
650 return message_handler_->OnMouseActivate(message, w_param, l_param);
651 }
652
653 LRESULT NativeWidgetWin::OnMouseRange(UINT message,
654 WPARAM w_param,
655 LPARAM l_param) {
656 return message_handler_->OnMouseRange(message, w_param, l_param);
657 }
658
659 void NativeWidgetWin::OnMove(const CPoint& point) {
660 message_handler_->OnMove(point);
661 }
662
663 void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
664 message_handler_->OnMoving(param, new_bounds);
665 }
666
667 LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
668 return message_handler_->OnNCActivate(active);
669 }
670
671 LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
672 return message_handler_->OnNCCalcSize(mode, l_param);
673 }
674
675 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
676 return message_handler_->OnNCHitTest(point);
677 }
678
679 void NativeWidgetWin::OnNCPaint(HRGN rgn) {
680 message_handler_->OnNCPaint(rgn);
681 }
682
683 LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg,
684 WPARAM w_param,
685 LPARAM l_param) {
686 return message_handler_->OnNCUAHDrawCaption(msg, w_param, l_param);
687 }
688
689 LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg,
690 WPARAM w_param,
691 LPARAM l_param) {
692 return message_handler_->OnNCUAHDrawFrame(msg, w_param, l_param);
693 }
694
695 LRESULT NativeWidgetWin::OnNotify(int w_param, NMHDR* l_param) {
696 return message_handler_->OnNotify(w_param, l_param);
697 }
698
699 void NativeWidgetWin::OnPaint(HDC dc) {
700 message_handler_->OnPaint(dc);
701 }
702
703 LRESULT NativeWidgetWin::OnPowerBroadcast(DWORD power_event, DWORD data) {
704 return message_handler_->OnPowerBroadcast(power_event, data);
705 }
706
707 LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
708 WPARAM w_param,
709 LPARAM l_param) {
710 return message_handler_->OnReflectedMessage(msg, w_param, l_param);
711 }
712
713 LRESULT NativeWidgetWin::OnSetCursor(UINT message,
714 WPARAM w_param,
715 LPARAM l_param) {
716 return message_handler_->OnSetCursor(message, w_param, l_param);
717 }
718
719 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) {
720 message_handler_->OnSetFocus(old_focused_window);
721 }
722
723 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
724 return message_handler_->OnSetIcon(size_type, new_icon);
725 }
726
727 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) {
728 return message_handler_->OnSetText(text);
729 }
730
731 void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
732 message_handler_->OnSettingChange(flags, section);
733 }
734
735 void NativeWidgetWin::OnSize(UINT param, const CSize& size) {
736 message_handler_->OnSize(param, size);
737 }
738
739 void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
740 message_handler_->OnSysCommand(notification_code, click);
741 }
742
743 void NativeWidgetWin::OnThemeChanged() {
744 message_handler_->OnThemeChanged();
745 }
746
747 LRESULT NativeWidgetWin::OnTouchEvent(UINT message,
748 WPARAM w_param,
749 LPARAM l_param) {
750 return message_handler_->OnTouchEvent(message, w_param, l_param);
751 }
752
753 void NativeWidgetWin::OnVScroll(int scroll_type,
754 short position,
755 HWND scrollbar) {
756 message_handler_->OnVScroll(scroll_type, position, scrollbar);
757 }
758
759 void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
760 message_handler_->OnWindowPosChanging(window_pos);
761 }
762
763 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
764 message_handler_->OnWindowPosChanged(window_pos);
765 }
766
767 void NativeWidgetWin::OnFinalMessage(HWND window) { 501 void NativeWidgetWin::OnFinalMessage(HWND window) {
768 // We don't destroy props in WM_DESTROY as we may still get messages after 502 // We don't destroy props in WM_DESTROY as we may still get messages after
769 // WM_DESTROY that assume the properties are still valid (such as WM_CLOSE). 503 // WM_DESTROY that assume the properties are still valid (such as WM_CLOSE).
770 props_.clear(); 504 props_.clear();
771 delegate_->OnNativeWidgetDestroyed(); 505 delegate_->OnNativeWidgetDestroyed();
772 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 506 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
773 delete this; 507 delete this;
774 } 508 }
775 509
776 //////////////////////////////////////////////////////////////////////////////// 510 ////////////////////////////////////////////////////////////////////////////////
777 // NativeWidgetWin, protected: 511 // NativeWidgetWin, protected:
778 512
779 void NativeWidgetWin::OnScreenReaderDetected() { 513 void NativeWidgetWin::OnScreenReaderDetected() {
780 screen_reader_active_ = true; 514 screen_reader_active_ = true;
781 } 515 }
782 516
517 HWNDMessageHandler* NativeWidgetWin::GetMessageHandler() {
518 return message_handler_.get();
519 }
520
783 //////////////////////////////////////////////////////////////////////////////// 521 ////////////////////////////////////////////////////////////////////////////////
784 // NativeWidgetWin, HWNDMessageHandlerDelegate implementation: 522 // NativeWidgetWin, HWNDMessageHandlerDelegate implementation:
785 523
786 bool NativeWidgetWin::IsWidgetWindow() const { 524 bool NativeWidgetWin::IsWidgetWindow() const {
787 // We don't NULL check GetWidget()->non_client_view() here because this 525 // We don't NULL check GetWidget()->non_client_view() here because this
788 // function can be called before the widget is fully constructed. 526 // function can be called before the widget is fully constructed.
789 return has_non_client_view_; 527 return has_non_client_view_;
790 } 528 }
791 529
792 bool NativeWidgetWin::IsUsingCustomFrame() const { 530 bool NativeWidgetWin::IsUsingCustomFrame() const {
(...skipping 17 matching lines...) Expand all
810 } 548 }
811 549
812 bool NativeWidgetWin::CanMaximize() const { 550 bool NativeWidgetWin::CanMaximize() const {
813 return GetWidget()->widget_delegate()->CanMaximize(); 551 return GetWidget()->widget_delegate()->CanMaximize();
814 } 552 }
815 553
816 bool NativeWidgetWin::CanActivate() const { 554 bool NativeWidgetWin::CanActivate() const {
817 return delegate_->CanActivate(); 555 return delegate_->CanActivate();
818 } 556 }
819 557
558 bool NativeWidgetWin::WidgetSizeIsClientSize() const {
559 const Widget* widget = GetWidget()->GetTopLevelWidget();
560 return IsMaximized() || (widget && widget->ShouldUseNativeFrame());
561 }
562
820 bool NativeWidgetWin::CanSaveFocus() const { 563 bool NativeWidgetWin::CanSaveFocus() const {
821 return GetWidget()->is_top_level(); 564 return GetWidget()->is_top_level();
822 } 565 }
823 566
824 void NativeWidgetWin::SaveFocusOnDeactivate() { 567 void NativeWidgetWin::SaveFocusOnDeactivate() {
825 GetWidget()->GetFocusManager()->StoreFocusedView(); 568 GetWidget()->GetFocusManager()->StoreFocusedView();
826 } 569 }
827 570
828 void NativeWidgetWin::RestoreFocusOnActivate() { 571 void NativeWidgetWin::RestoreFocusOnActivate() {
829 // Mysteriously, this only appears to be needed support restoration of focus 572 // Mysteriously, this only appears to be needed support restoration of focus
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 void NativeWidgetWin::HandleAppDeactivated() { 644 void NativeWidgetWin::HandleAppDeactivated() {
902 // Another application was activated, we should reset any state that 645 // Another application was activated, we should reset any state that
903 // disables inactive rendering now. 646 // disables inactive rendering now.
904 delegate_->EnableInactiveRendering(); 647 delegate_->EnableInactiveRendering();
905 } 648 }
906 649
907 void NativeWidgetWin::HandleActivationChanged(bool active) { 650 void NativeWidgetWin::HandleActivationChanged(bool active) {
908 delegate_->OnNativeWidgetActivationChanged(active); 651 delegate_->OnNativeWidgetActivationChanged(active);
909 } 652 }
910 653
654 void NativeWidgetWin::HandleMouseActivate(int hittest_code) {
655 }
656
911 bool NativeWidgetWin::HandleAppCommand(short command) { 657 bool NativeWidgetWin::HandleAppCommand(short command) {
912 // We treat APPCOMMAND ids as an extension of our command namespace, and just 658 // We treat APPCOMMAND ids as an extension of our command namespace, and just
913 // let the delegate figure out what to do... 659 // let the delegate figure out what to do...
914 return GetWidget()->widget_delegate() && 660 return GetWidget()->widget_delegate() &&
915 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); 661 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
916 } 662 }
917 663
918 void NativeWidgetWin::HandleCaptureLost() { 664 void NativeWidgetWin::HandleCaptureLost() {
919 delegate_->OnMouseCaptureLost(); 665 delegate_->OnMouseCaptureLost();
920 } 666 }
921 667
922 void NativeWidgetWin::HandleClose() { 668 void NativeWidgetWin::HandleClose() {
923 GetWidget()->Close(); 669 GetWidget()->Close();
924 } 670 }
925 671
926 bool NativeWidgetWin::HandleCommand(int command) { 672 bool NativeWidgetWin::HandleCommand(int command) {
927 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command); 673 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
928 } 674 }
929 675
930 void NativeWidgetWin::HandleAccelerator(const ui::Accelerator& accelerator) { 676 void NativeWidgetWin::HandleAccelerator(const ui::Accelerator& accelerator) {
931 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator); 677 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator);
932 } 678 }
933 679
934 void NativeWidgetWin::HandleCreate() { 680 void NativeWidgetWin::HandleCreate() {
935 // TODO(beng): much of this could/should maybe move to HWNDMessageHandler. 681 // TODO(beng): much of this could/should maybe move to HWNDMessageHandler.
936 682
937 SetNativeWindowProperty(kNativeWidgetKey, this); 683 SetNativeWindowProperty(kNativeWidgetKey, this);
938 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); 684 CHECK_EQ(this, GetNativeWidgetForNativeView(GetNativeView()));
939 685
940 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(hwnd())); 686 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(GetNativeView()));
941 687
942 drop_target_ = new DropTargetWin( 688 drop_target_ = new DropTargetWin(
943 static_cast<internal::RootView*>(GetWidget()->GetRootView())); 689 static_cast<internal::RootView*>(GetWidget()->GetRootView()));
944 690
945 // We need to add ourselves as a message loop observer so that we can repaint
946 // aggressively if the contents of our window become invalid. Unfortunately
947 // WM_PAINT messages are starved and we get flickery redrawing when resizing
948 // if we do not do this.
949 MessageLoopForUI::current()->AddObserver(this);
950
951 // Windows special DWM window frame requires a special tooltip manager so 691 // Windows special DWM window frame requires a special tooltip manager so
952 // that window controls in Chrome windows don't flicker when you move your 692 // that window controls in Chrome windows don't flicker when you move your
953 // mouse over them. See comment in aero_tooltip_manager.h. 693 // mouse over them. See comment in aero_tooltip_manager.h.
954 Widget* widget = GetWidget()->GetTopLevelWidget(); 694 Widget* widget = GetWidget()->GetTopLevelWidget();
955 if (widget && widget->ShouldUseNativeFrame()) { 695 if (widget && widget->ShouldUseNativeFrame()) {
956 tooltip_manager_.reset(new AeroTooltipManager(GetWidget())); 696 tooltip_manager_.reset(new AeroTooltipManager(GetWidget()));
957 } else { 697 } else {
958 tooltip_manager_.reset(new TooltipManagerWin(GetWidget())); 698 tooltip_manager_.reset(new TooltipManagerWin(GetWidget()));
959 } 699 }
960 if (!tooltip_manager_->Init()) { 700 if (!tooltip_manager_->Init()) {
961 // There was a problem creating the TooltipManager. Common error is 127. 701 // There was a problem creating the TooltipManager. Common error is 127.
962 // See 82193 for details. 702 // See 82193 for details.
963 LOG_GETLASTERROR(WARNING) << "tooltip creation failed, disabling tooltips"; 703 LOG_GETLASTERROR(WARNING) << "tooltip creation failed, disabling tooltips";
964 tooltip_manager_.reset(); 704 tooltip_manager_.reset();
965 } 705 }
966 706
967 delegate_->OnNativeWidgetCreated(); 707 delegate_->OnNativeWidgetCreated();
968 } 708 }
969 709
970 void NativeWidgetWin::HandleDestroying() { 710 void NativeWidgetWin::HandleDestroying() {
971 delegate_->OnNativeWidgetDestroying(); 711 delegate_->OnNativeWidgetDestroying();
972 if (drop_target_.get()) { 712 if (drop_target_.get()) {
973 RevokeDragDrop(hwnd()); 713 RevokeDragDrop(GetNativeView());
974 drop_target_ = NULL; 714 drop_target_ = NULL;
975 } 715 }
976 } 716 }
977 717
978 void NativeWidgetWin::HandleDestroyed() { 718 void NativeWidgetWin::HandleDestroyed() {
979 MessageLoopForUI::current()->RemoveObserver(this); 719 OnFinalMessage(GetNativeView());
980 OnFinalMessage(hwnd());
981 } 720 }
982 721
983 bool NativeWidgetWin::HandleInitialFocus() { 722 bool NativeWidgetWin::HandleInitialFocus() {
984 return GetWidget()->SetInitialFocus(); 723 return GetWidget()->SetInitialFocus();
985 } 724 }
986 725
987 void NativeWidgetWin::HandleDisplayChange() { 726 void NativeWidgetWin::HandleDisplayChange() {
988 GetWidget()->widget_delegate()->OnDisplayChanged(); 727 GetWidget()->widget_delegate()->OnDisplayChanged();
989 } 728 }
990 729
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 return false; 804 return false;
1066 } 805 }
1067 806
1068 void NativeWidgetWin::HandleTooltipMouseMove(UINT message, 807 void NativeWidgetWin::HandleTooltipMouseMove(UINT message,
1069 WPARAM w_param, 808 WPARAM w_param,
1070 LPARAM l_param) { 809 LPARAM l_param) {
1071 if (tooltip_manager_.get()) 810 if (tooltip_manager_.get())
1072 tooltip_manager_->OnMouse(message, w_param, l_param); 811 tooltip_manager_->OnMouse(message, w_param, l_param);
1073 } 812 }
1074 813
1075 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() { 814 void NativeWidgetWin::HandleEndSession() {
1076 return this; 815 }
816
817 void NativeWidgetWin::HandleInitMenuPopup() {
818 }
819
820 void NativeWidgetWin::HandleFrameChanged() {
821 }
822
823 bool NativeWidgetWin::HandleMSG(UINT message,
824 WPARAM w_param,
825 LPARAM l_param,
826 LRESULT* result) {
827 return false;
1077 } 828 }
1078 829
1079 //////////////////////////////////////////////////////////////////////////////// 830 ////////////////////////////////////////////////////////////////////////////////
1080 // NativeWidgetWin, private: 831 // NativeWidgetWin, private:
1081 832
1082 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { 833 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
1083 // Set non-style attributes. 834 // Set non-style attributes.
1084 ownership_ = params.ownership; 835 ownership_ = params.ownership;
1085 836
1086 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 837 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 style |= WS_POPUP; 904 style |= WS_POPUP;
1154 ex_style |= WS_EX_TOOLWINDOW; 905 ex_style |= WS_EX_TOOLWINDOW;
1155 break; 906 break;
1156 case Widget::InitParams::TYPE_MENU: 907 case Widget::InitParams::TYPE_MENU:
1157 style |= WS_POPUP; 908 style |= WS_POPUP;
1158 break; 909 break;
1159 default: 910 default:
1160 NOTREACHED(); 911 NOTREACHED();
1161 } 912 }
1162 913
1163 set_initial_class_style(class_style); 914 message_handler_->set_initial_class_style(class_style);
1164 set_window_style(window_style() | style); 915 message_handler_->set_window_style(
1165 set_window_ex_style(window_ex_style() | ex_style); 916 message_handler_->window_style() | style);
917 message_handler_->set_window_ex_style(
918 message_handler_->window_ex_style() | ex_style);
1166 919
1167 has_non_client_view_ = Widget::RequiresNonClientView(params.type); 920 has_non_client_view_ = Widget::RequiresNonClientView(params.type);
1168 message_handler_->set_remove_standard_frame(params.remove_standard_frame); 921 message_handler_->set_remove_standard_frame(params.remove_standard_frame);
1169 } 922 }
1170 923
1171 bool NativeWidgetWin::WidgetSizeIsClientSize() const {
1172 const Widget* widget = GetWidget()->GetTopLevelWidget();
1173 return IsZoomed() || (widget && widget->ShouldUseNativeFrame());
1174 }
1175
1176 //////////////////////////////////////////////////////////////////////////////// 924 ////////////////////////////////////////////////////////////////////////////////
1177 // Widget, public: 925 // Widget, public:
1178 926
1179 // static 927 // static
1180 void Widget::NotifyLocaleChanged() { 928 void Widget::NotifyLocaleChanged() {
1181 NOTIMPLEMENTED(); 929 NOTIMPLEMENTED();
1182 } 930 }
1183 931
1184 namespace { 932 namespace {
1185 BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) { 933 BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 // static 1084 // static
1337 bool NativeWidgetPrivate::IsTouchDown() { 1085 bool NativeWidgetPrivate::IsTouchDown() {
1338 // This currently isn't necessary because we're not generating touch events on 1086 // This currently isn't necessary because we're not generating touch events on
1339 // windows. When we do, this will need to be updated. 1087 // windows. When we do, this will need to be updated.
1340 return false; 1088 return false;
1341 } 1089 }
1342 1090
1343 } // namespace internal 1091 } // namespace internal
1344 1092
1345 } // namespace views 1093 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698