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

Side by Side Diff: ui/gfx/win/window_impl.cc

Issue 23769011: Move a bunch of windows stuff from ui/base/win to ui/gfx/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bustage. Created 7 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/gfx/win/window_impl.h ('k') | ui/native_theme/native_theme_win.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/base/win/window_impl.h" 5 #include "ui/gfx/win/window_impl.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/win/wrapped_window_proc.h" 13 #include "base/win/wrapped_window_proc.h"
14 #include "ui/base/win/hwnd_util.h" 14 #include "ui/gfx/win/hwnd_util.h"
15 15
16 namespace ui { 16 namespace gfx {
17 17
18 static const DWORD kWindowDefaultChildStyle = 18 static const DWORD kWindowDefaultChildStyle =
19 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 19 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
20 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN; 20 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
21 static const DWORD kWindowDefaultExStyle = 0; 21 static const DWORD kWindowDefaultExStyle = 0;
22 22
23 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
24 // WindowImpl class tracking. 24 // WindowImpl class tracking.
25 25
26 // Several external scripts rely explicitly on this base class name for 26 // Several external scripts rely explicitly on this base class name for
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 got_valid_hwnd_(false), 142 got_valid_hwnd_(false),
143 destroyed_(NULL) { 143 destroyed_(NULL) {
144 } 144 }
145 145
146 WindowImpl::~WindowImpl() { 146 WindowImpl::~WindowImpl() {
147 if (destroyed_) 147 if (destroyed_)
148 *destroyed_ = true; 148 *destroyed_ = true;
149 ClearUserData(); 149 ClearUserData();
150 } 150 }
151 151
152 void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) { 152 void WindowImpl::Init(HWND parent, const Rect& bounds) {
153 if (window_style_ == 0) 153 if (window_style_ == 0)
154 window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle; 154 window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle;
155 155
156 if (parent == HWND_DESKTOP) { 156 if (parent == HWND_DESKTOP) {
157 // Only non-child windows can have HWND_DESKTOP (0) as their parent. 157 // Only non-child windows can have HWND_DESKTOP (0) as their parent.
158 CHECK((window_style_ & WS_CHILD) == 0); 158 CHECK((window_style_ & WS_CHILD) == 0);
159 parent = GetWindowToParentTo(false); 159 parent = GetWindowToParentTo(false);
160 } else if (parent == ::GetDesktopWindow()) { 160 } else if (parent == ::GetDesktopWindow()) {
161 // Any type of window can have the "Desktop Window" as their parent. 161 // Any type of window can have the "Desktop Window" as their parent.
162 parent = GetWindowToParentTo(true); 162 parent = GetWindowToParentTo(true);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 base::win::WrappedWindowProc<&WindowImpl::WndProc>; 209 base::win::WrappedWindowProc<&WindowImpl::WndProc>;
210 base::debug::Alias(&procs_match); 210 base::debug::Alias(&procs_match);
211 CHECK(false); 211 CHECK(false);
212 } 212 }
213 if (!destroyed) 213 if (!destroyed)
214 destroyed_ = NULL; 214 destroyed_ = NULL;
215 215
216 CheckWindowCreated(hwnd_); 216 CheckWindowCreated(hwnd_);
217 217
218 // The window procedure should have set the data for us. 218 // The window procedure should have set the data for us.
219 CHECK_EQ(this, ui::GetWindowUserData(hwnd)); 219 CHECK_EQ(this, GetWindowUserData(hwnd));
220 } 220 }
221 221
222 HICON WindowImpl::GetDefaultWindowIcon() const { 222 HICON WindowImpl::GetDefaultWindowIcon() const {
223 return NULL; 223 return NULL;
224 } 224 }
225 225
226 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { 226 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
227 LRESULT result = 0; 227 LRESULT result = 0;
228 228
229 // Handle the message if it's in our message map; otherwise, let the system 229 // Handle the message if it's in our message map; otherwise, let the system
230 // handle it. 230 // handle it.
231 if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result)) 231 if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result))
232 result = DefWindowProc(hwnd_, message, w_param, l_param); 232 result = DefWindowProc(hwnd_, message, w_param, l_param);
233 233
234 return result; 234 return result;
235 } 235 }
236 236
237 void WindowImpl::ClearUserData() { 237 void WindowImpl::ClearUserData() {
238 if (::IsWindow(hwnd_)) 238 if (::IsWindow(hwnd_))
239 ui::SetWindowUserData(hwnd_, NULL); 239 gfx::SetWindowUserData(hwnd_, NULL);
240 } 240 }
241 241
242 // static 242 // static
243 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, 243 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd,
244 UINT message, 244 UINT message,
245 WPARAM w_param, 245 WPARAM w_param,
246 LPARAM l_param) { 246 LPARAM l_param) {
247 if (message == WM_NCCREATE) { 247 if (message == WM_NCCREATE) {
248 CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(l_param); 248 CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(l_param);
249 WindowImpl* window = reinterpret_cast<WindowImpl*>(cs->lpCreateParams); 249 WindowImpl* window = reinterpret_cast<WindowImpl*>(cs->lpCreateParams);
250 DCHECK(window); 250 DCHECK(window);
251 ui::SetWindowUserData(hwnd, window); 251 gfx::SetWindowUserData(hwnd, window);
252 window->hwnd_ = hwnd; 252 window->hwnd_ = hwnd;
253 window->got_create_ = true; 253 window->got_create_ = true;
254 if (hwnd) 254 if (hwnd)
255 window->got_valid_hwnd_ = true; 255 window->got_valid_hwnd_ = true;
256 return TRUE; 256 return TRUE;
257 } 257 }
258 258
259 WindowImpl* window = reinterpret_cast<WindowImpl*>( 259 WindowImpl* window = reinterpret_cast<WindowImpl*>(GetWindowUserData(hwnd));
260 ui::GetWindowUserData(hwnd));
261 if (!window) 260 if (!window)
262 return 0; 261 return 0;
263 262
264 return window->OnWndProc(message, w_param, l_param); 263 return window->OnWndProc(message, w_param, l_param);
265 } 264 }
266 265
267 ATOM WindowImpl::GetWindowClassAtom() { 266 ATOM WindowImpl::GetWindowClassAtom() {
268 HICON icon = GetDefaultWindowIcon(); 267 HICON icon = GetDefaultWindowIcon();
269 ClassInfo class_info(initial_class_style(), icon); 268 ClassInfo class_info(initial_class_style(), icon);
270 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); 269 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info);
271 } 270 }
272 271
273 } // namespace ui 272 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/win/window_impl.h ('k') | ui/native_theme/native_theme_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698