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

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

Issue 10892014: 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
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | ui/views/widget/native_widget_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 423
424 void NativeWidgetWin::SetOpacity(unsigned char opacity) { 424 void NativeWidgetWin::SetOpacity(unsigned char opacity) {
425 message_handler_->SetOpacity(static_cast<BYTE>(opacity)); 425 message_handler_->SetOpacity(static_cast<BYTE>(opacity));
426 GetWidget()->GetRootView()->SchedulePaint(); 426 GetWidget()->GetRootView()->SchedulePaint();
427 } 427 }
428 428
429 void NativeWidgetWin::SetUseDragFrame(bool use_drag_frame) { 429 void NativeWidgetWin::SetUseDragFrame(bool use_drag_frame) {
430 if (use_drag_frame) { 430 if (use_drag_frame) {
431 // Make the frame slightly transparent during the drag operation. 431 // Make the frame slightly transparent during the drag operation.
432 drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE); 432 drag_frame_saved_window_style_ = GetWindowLong(GetNativeView(), GWL_STYLE);
433 drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE); 433 drag_frame_saved_window_ex_style_ =
434 SetWindowLong(GWL_EXSTYLE, 434 GetWindowLong(GetNativeView(), GWL_EXSTYLE);
435 SetWindowLong(GetNativeView(), GWL_EXSTYLE,
435 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED); 436 drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
436 // Remove the captions tyle so the window doesn't have window controls for a 437 // Remove the captions tyle so the window doesn't have window controls for a
437 // more "transparent" look. 438 // more "transparent" look.
438 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION); 439 SetWindowLong(GetNativeView(), GWL_STYLE,
439 SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF), 440 drag_frame_saved_window_style_ & ~WS_CAPTION);
441 SetLayeredWindowAttributes(GetNativeView(), RGB(0xFF, 0xFF, 0xFF),
440 kDragFrameWindowAlpha, LWA_ALPHA); 442 kDragFrameWindowAlpha, LWA_ALPHA);
441 } else { 443 } else {
442 SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_); 444 SetWindowLong(GetNativeView(), GWL_STYLE, drag_frame_saved_window_style_);
443 SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_); 445 SetWindowLong(GetNativeView(), GWL_EXSTYLE,
446 drag_frame_saved_window_ex_style_);
444 } 447 }
445 } 448 }
446 449
447 void NativeWidgetWin::FlashFrame(bool flash) { 450 void NativeWidgetWin::FlashFrame(bool flash) {
448 message_handler_->FlashFrame(flash); 451 message_handler_->FlashFrame(flash);
449 } 452 }
450 453
451 bool NativeWidgetWin::IsAccessibleWidget() const { 454 bool NativeWidgetWin::IsAccessibleWidget() const {
452 return screen_reader_active_; 455 return screen_reader_active_;
453 } 456 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 493
491 void NativeWidgetWin::EndMoveLoop() { 494 void NativeWidgetWin::EndMoveLoop() {
492 message_handler_->EndMoveLoop(); 495 message_handler_->EndMoveLoop();
493 } 496 }
494 497
495 void NativeWidgetWin::SetVisibilityChangedAnimationsEnabled(bool value) { 498 void NativeWidgetWin::SetVisibilityChangedAnimationsEnabled(bool value) {
496 message_handler_->SetVisibilityChangedAnimationsEnabled(value); 499 message_handler_->SetVisibilityChangedAnimationsEnabled(value);
497 } 500 }
498 501
499 //////////////////////////////////////////////////////////////////////////////// 502 ////////////////////////////////////////////////////////////////////////////////
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: 503 // NativeWidgetWin, WindowImpl overrides:
513 504
514 HICON NativeWidgetWin::GetDefaultWindowIcon() const { 505 HICON NativeWidgetWin::GetDefaultWindowIcon() const {
515 return message_handler_->GetDefaultWindowIcon(); 506 return message_handler_->GetDefaultWindowIcon();
516 } 507 }
517 508
518 LRESULT NativeWidgetWin::OnWndProc(UINT message, 509 LRESULT NativeWidgetWin::OnWndProc(UINT message,
519 WPARAM w_param, 510 WPARAM w_param,
520 LPARAM l_param) { 511 LPARAM l_param) {
521 return message_handler_->OnWndProc(message, w_param, l_param); 512 return message_handler_->OnWndProc(message, w_param, l_param);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 } 801 }
811 802
812 bool NativeWidgetWin::CanMaximize() const { 803 bool NativeWidgetWin::CanMaximize() const {
813 return GetWidget()->widget_delegate()->CanMaximize(); 804 return GetWidget()->widget_delegate()->CanMaximize();
814 } 805 }
815 806
816 bool NativeWidgetWin::CanActivate() const { 807 bool NativeWidgetWin::CanActivate() const {
817 return delegate_->CanActivate(); 808 return delegate_->CanActivate();
818 } 809 }
819 810
811 bool NativeWidgetWin::WidgetSizeIsClientSize() const {
812 const Widget* widget = GetWidget()->GetTopLevelWidget();
813 return IsZoomed(GetNativeView()) ||
814 (widget && widget->ShouldUseNativeFrame());
815 }
816
820 bool NativeWidgetWin::CanSaveFocus() const { 817 bool NativeWidgetWin::CanSaveFocus() const {
821 return GetWidget()->is_top_level(); 818 return GetWidget()->is_top_level();
822 } 819 }
823 820
824 void NativeWidgetWin::SaveFocusOnDeactivate() { 821 void NativeWidgetWin::SaveFocusOnDeactivate() {
825 GetWidget()->GetFocusManager()->StoreFocusedView(); 822 GetWidget()->GetFocusManager()->StoreFocusedView();
826 } 823 }
827 824
828 void NativeWidgetWin::RestoreFocusOnActivate() { 825 void NativeWidgetWin::RestoreFocusOnActivate() {
829 // Mysteriously, this only appears to be needed support restoration of focus 826 // Mysteriously, this only appears to be needed support restoration of focus
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // TODO(beng): much of this could/should maybe move to HWNDMessageHandler. 932 // TODO(beng): much of this could/should maybe move to HWNDMessageHandler.
936 933
937 SetNativeWindowProperty(kNativeWidgetKey, this); 934 SetNativeWindowProperty(kNativeWidgetKey, this);
938 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd())); 935 CHECK_EQ(this, GetNativeWidgetForNativeView(hwnd()));
939 936
940 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(hwnd())); 937 props_.push_back(ui::SetWindowSupportsRerouteMouseWheel(hwnd()));
941 938
942 drop_target_ = new DropTargetWin( 939 drop_target_ = new DropTargetWin(
943 static_cast<internal::RootView*>(GetWidget()->GetRootView())); 940 static_cast<internal::RootView*>(GetWidget()->GetRootView()));
944 941
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 942 // 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 943 // that window controls in Chrome windows don't flicker when you move your
953 // mouse over them. See comment in aero_tooltip_manager.h. 944 // mouse over them. See comment in aero_tooltip_manager.h.
954 Widget* widget = GetWidget()->GetTopLevelWidget(); 945 Widget* widget = GetWidget()->GetTopLevelWidget();
955 if (widget && widget->ShouldUseNativeFrame()) { 946 if (widget && widget->ShouldUseNativeFrame()) {
956 tooltip_manager_.reset(new AeroTooltipManager(GetWidget())); 947 tooltip_manager_.reset(new AeroTooltipManager(GetWidget()));
957 } else { 948 } else {
958 tooltip_manager_.reset(new TooltipManagerWin(GetWidget())); 949 tooltip_manager_.reset(new TooltipManagerWin(GetWidget()));
959 } 950 }
960 if (!tooltip_manager_->Init()) { 951 if (!tooltip_manager_->Init()) {
961 // There was a problem creating the TooltipManager. Common error is 127. 952 // There was a problem creating the TooltipManager. Common error is 127.
962 // See 82193 for details. 953 // See 82193 for details.
963 LOG_GETLASTERROR(WARNING) << "tooltip creation failed, disabling tooltips"; 954 LOG_GETLASTERROR(WARNING) << "tooltip creation failed, disabling tooltips";
964 tooltip_manager_.reset(); 955 tooltip_manager_.reset();
965 } 956 }
966 957
967 delegate_->OnNativeWidgetCreated(); 958 delegate_->OnNativeWidgetCreated();
968 } 959 }
969 960
970 void NativeWidgetWin::HandleDestroying() { 961 void NativeWidgetWin::HandleDestroying() {
971 delegate_->OnNativeWidgetDestroying(); 962 delegate_->OnNativeWidgetDestroying();
972 if (drop_target_.get()) { 963 if (drop_target_.get()) {
973 RevokeDragDrop(hwnd()); 964 RevokeDragDrop(hwnd());
974 drop_target_ = NULL; 965 drop_target_ = NULL;
975 } 966 }
976 } 967 }
977 968
978 void NativeWidgetWin::HandleDestroyed() { 969 void NativeWidgetWin::HandleDestroyed() {
979 MessageLoopForUI::current()->RemoveObserver(this);
980 OnFinalMessage(hwnd()); 970 OnFinalMessage(hwnd());
981 } 971 }
982 972
983 bool NativeWidgetWin::HandleInitialFocus() { 973 bool NativeWidgetWin::HandleInitialFocus() {
984 return GetWidget()->SetInitialFocus(); 974 return GetWidget()->SetInitialFocus();
985 } 975 }
986 976
987 void NativeWidgetWin::HandleDisplayChange() { 977 void NativeWidgetWin::HandleDisplayChange() {
988 GetWidget()->widget_delegate()->OnDisplayChanged(); 978 GetWidget()->widget_delegate()->OnDisplayChanged();
989 } 979 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 return false; 1055 return false;
1066 } 1056 }
1067 1057
1068 void NativeWidgetWin::HandleTooltipMouseMove(UINT message, 1058 void NativeWidgetWin::HandleTooltipMouseMove(UINT message,
1069 WPARAM w_param, 1059 WPARAM w_param,
1070 LPARAM l_param) { 1060 LPARAM l_param) {
1071 if (tooltip_manager_.get()) 1061 if (tooltip_manager_.get())
1072 tooltip_manager_->OnMouse(message, w_param, l_param); 1062 tooltip_manager_->OnMouse(message, w_param, l_param);
1073 } 1063 }
1074 1064
1065 bool NativeWidgetWin::PreHandleMSG(UINT message,
1066 WPARAM w_param,
1067 LPARAM l_param,
1068 LRESULT* result) {
1069 return false;
1070 }
1071
1072 void NativeWidgetWin::PostHandleMSG(UINT message,
1073 WPARAM w_param,
1074 LPARAM l_param) {
1075 }
1076
1075 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() { 1077 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() {
1076 return this; 1078 return this;
1077 } 1079 }
1078 1080
1079 //////////////////////////////////////////////////////////////////////////////// 1081 ////////////////////////////////////////////////////////////////////////////////
1080 // NativeWidgetWin, private: 1082 // NativeWidgetWin, private:
1081 1083
1082 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { 1084 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
1083 // Set non-style attributes. 1085 // Set non-style attributes.
1084 ownership_ = params.ownership; 1086 ownership_ = params.ownership;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 } 1163 }
1162 1164
1163 set_initial_class_style(class_style); 1165 set_initial_class_style(class_style);
1164 set_window_style(window_style() | style); 1166 set_window_style(window_style() | style);
1165 set_window_ex_style(window_ex_style() | ex_style); 1167 set_window_ex_style(window_ex_style() | ex_style);
1166 1168
1167 has_non_client_view_ = Widget::RequiresNonClientView(params.type); 1169 has_non_client_view_ = Widget::RequiresNonClientView(params.type);
1168 message_handler_->set_remove_standard_frame(params.remove_standard_frame); 1170 message_handler_->set_remove_standard_frame(params.remove_standard_frame);
1169 } 1171 }
1170 1172
1171 bool NativeWidgetWin::WidgetSizeIsClientSize() const {
1172 const Widget* widget = GetWidget()->GetTopLevelWidget();
1173 return IsZoomed() || (widget && widget->ShouldUseNativeFrame());
1174 }
1175
1176 //////////////////////////////////////////////////////////////////////////////// 1173 ////////////////////////////////////////////////////////////////////////////////
1177 // Widget, public: 1174 // Widget, public:
1178 1175
1179 // static 1176 // static
1180 void Widget::NotifyLocaleChanged() { 1177 void Widget::NotifyLocaleChanged() {
1181 NOTIMPLEMENTED(); 1178 NOTIMPLEMENTED();
1182 } 1179 }
1183 1180
1184 namespace { 1181 namespace {
1185 BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) { 1182 BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 // static 1333 // static
1337 bool NativeWidgetPrivate::IsTouchDown() { 1334 bool NativeWidgetPrivate::IsTouchDown() {
1338 // This currently isn't necessary because we're not generating touch events on 1335 // This currently isn't necessary because we're not generating touch events on
1339 // windows. When we do, this will need to be updated. 1336 // windows. When we do, this will need to be updated.
1340 return false; 1337 return false;
1341 } 1338 }
1342 1339
1343 } // namespace internal 1340 } // namespace internal
1344 1341
1345 } // namespace views 1342 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | ui/views/widget/native_widget_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698