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

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

Issue 7031053: Make Widget ownership a little clearer by expressing it in terms of an enum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 | « views/widget/native_widget_win.h ('k') | 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) 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/native_widget_win.h" 5 #include "views/widget/native_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/system_monitor/system_monitor.h" 10 #include "base/system_monitor/system_monitor.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 //////////////////////////////////////////////////////////////////////////////// 132 ////////////////////////////////////////////////////////////////////////////////
133 // NativeWidgetWin, public: 133 // NativeWidgetWin, public:
134 134
135 NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate) 135 NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate)
136 : delegate_(delegate), 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 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
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 } 150 }
151 151
152 NativeWidgetWin::~NativeWidgetWin() { 152 NativeWidgetWin::~NativeWidgetWin() {
153 // We need to delete the input method before calling DestroyRootView(), 153 // We need to delete the input method before calling DestroyRootView(),
154 // because it'll set focus_manager_ to NULL. 154 // because it'll set focus_manager_ to NULL.
155 input_method_.reset(); 155 input_method_.reset();
156 if (delete_on_destroy_) 156 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
157 delete delegate_; 157 delete delegate_;
158 } 158 }
159 159
160 // static 160 // static
161 bool NativeWidgetWin::IsAeroGlassEnabled() { 161 bool NativeWidgetWin::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;
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 SetMsgHandled(FALSE); 947 SetMsgHandled(FALSE);
948 } 948 }
949 949
950 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { 950 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
951 if (DidClientAreaSizeChange(window_pos)) 951 if (DidClientAreaSizeChange(window_pos))
952 ClientAreaSizeChanged(); 952 ClientAreaSizeChanged();
953 SetMsgHandled(FALSE); 953 SetMsgHandled(FALSE);
954 } 954 }
955 955
956 void NativeWidgetWin::OnFinalMessage(HWND window) { 956 void NativeWidgetWin::OnFinalMessage(HWND window) {
957 if (delete_on_destroy_) 957 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
958 delete this; 958 delete this;
959 } 959 }
960 960
961 //////////////////////////////////////////////////////////////////////////////// 961 ////////////////////////////////////////////////////////////////////////////////
962 // NativeWidgetWin, protected: 962 // NativeWidgetWin, protected:
963 963
964 void NativeWidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) { 964 void NativeWidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
965 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE 965 // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE
966 // when the user moves the mouse outside this HWND's bounds. 966 // when the user moves the mouse outside this HWND's bounds.
967 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { 967 if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 DCHECK(!widget->restore_focus_when_enabled_); 1041 DCHECK(!widget->restore_focus_when_enabled_);
1042 widget->restore_focus_when_enabled_ = true; 1042 widget->restore_focus_when_enabled_ = true;
1043 return; 1043 return;
1044 } 1044 }
1045 focus_manager->RestoreFocusedView(); 1045 focus_manager->RestoreFocusedView();
1046 } 1046 }
1047 } 1047 }
1048 1048
1049 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) { 1049 void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
1050 // Set non-style attributes. 1050 // Set non-style attributes.
1051 delete_on_destroy_ = params.delete_on_destroy; 1051 ownership_ = params.ownership;
1052 1052
1053 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 1053 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
1054 DWORD ex_style = 0; 1054 DWORD ex_style = 0;
1055 DWORD class_style = CS_DBLCLKS; 1055 DWORD class_style = CS_DBLCLKS;
1056 1056
1057 // Set type-independent style attributes. 1057 // Set type-independent style attributes.
1058 if (params.child) 1058 if (params.child)
1059 style |= WS_CHILD | WS_VISIBLE; 1059 style |= WS_CHILD | WS_VISIBLE;
1060 if (!params.accept_events) 1060 if (!params.accept_events)
1061 ex_style |= WS_EX_TRANSPARENT; 1061 ex_style |= WS_EX_TRANSPARENT;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1296
1297 // And now, notify them that they have a brand new parent. 1297 // And now, notify them that they have a brand new parent.
1298 for (NativeWidgets::iterator it = widgets.begin(); 1298 for (NativeWidgets::iterator it = widgets.begin();
1299 it != widgets.end(); ++it) { 1299 it != widgets.end(); ++it) {
1300 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true, 1300 (*it)->GetWidget()->NotifyNativeViewHierarchyChanged(true,
1301 new_parent); 1301 new_parent);
1302 } 1302 }
1303 } 1303 }
1304 1304
1305 } // namespace views 1305 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_win.h ('k') | views/widget/native_widget_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698