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

Side by Side Diff: views/window/window_win.cc

Issue 6881107: Rework the way Widget::Init works: (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/window/window_win.h ('k') | no next file » | 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/window/window_win.h" 5 #include "views/window/window_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 //////////////////////////////////////////////////////////////////////////////// 235 ////////////////////////////////////////////////////////////////////////////////
236 // WindowWin, public: 236 // WindowWin, public:
237 237
238 WindowWin::~WindowWin() { 238 WindowWin::~WindowWin() {
239 } 239 }
240 240
241 // static 241 // static
242 Window* Window::CreateChromeWindow(gfx::NativeWindow parent, 242 Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
243 const gfx::Rect& bounds, 243 const gfx::Rect& bounds,
244 WindowDelegate* window_delegate) { 244 WindowDelegate* window_delegate) {
245 WindowWin* window = new WindowWin(window_delegate); 245 Window* window = new WindowWin(window_delegate);
246 window->GetWindow()->non_client_view()->SetFrameView( 246 window->non_client_view()->SetFrameView(window->CreateFrameViewForWindow());
247 window->CreateFrameViewForWindow()); 247 Widget::CreateParams params(Widget::WindowCreateParams());
248 window->Init(parent, bounds); 248 params.parent = parent;
249 params.bounds = bounds;
250 window->AsWidget()->Init(params);
249 return window; 251 return window;
250 } 252 }
251 253
252 void WindowWin::Show(int show_state) { 254 void WindowWin::Show(int show_state) {
253 ShowWindow(show_state); 255 ShowWindow(show_state);
254 // When launched from certain programs like bash and Windows Live Messenger, 256 // When launched from certain programs like bash and Windows Live Messenger,
255 // show_state is set to SW_HIDE, so we need to correct that condition. We 257 // show_state is set to SW_HIDE, so we need to correct that condition. We
256 // don't just change show_state to SW_SHOWNORMAL because MSDN says we must 258 // don't just change show_state to SW_SHOWNORMAL because MSDN says we must
257 // always first call ShowWindow with the specified value from STARTUPINFO, 259 // always first call ShowWindow with the specified value from STARTUPINFO,
258 // otherwise all future ShowWindow calls will be ignored (!!#@@#!). Instead, 260 // otherwise all future ShowWindow calls will be ignored (!!#@@#!). Instead,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 is_in_size_move_(false) { 316 is_in_size_move_(false) {
315 SetNativeWindow(this); 317 SetNativeWindow(this);
316 is_window_ = true; 318 is_window_ = true;
317 InitClass(); 319 InitClass();
318 // Initialize these values to 0 so that subclasses can override the default 320 // Initialize these values to 0 so that subclasses can override the default
319 // behavior before calling Init. 321 // behavior before calling Init.
320 set_window_style(0); 322 set_window_style(0);
321 set_window_ex_style(0); 323 set_window_ex_style(0);
322 } 324 }
323 325
324 void WindowWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
325 if (window_style() == 0)
326 set_window_style(CalculateWindowStyle());
327 if (window_ex_style() == 0)
328 set_window_ex_style(CalculateWindowExStyle());
329
330 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_,
331 &last_work_area_);
332
333 WidgetWin::Init(parent, bounds);
334
335 delegate_->OnNativeWindowCreated(bounds);
336 }
337
338 gfx::Insets WindowWin::GetClientAreaInsets() const { 326 gfx::Insets WindowWin::GetClientAreaInsets() const {
339 // Returning an empty Insets object causes the default handling in 327 // Returning an empty Insets object causes the default handling in
340 // WidgetWin::OnNCCalcSize() to be invoked. 328 // WidgetWin::OnNCCalcSize() to be invoked.
341 if (delegate_->IsUsingNativeFrame()) 329 if (delegate_->IsUsingNativeFrame())
342 return gfx::Insets(); 330 return gfx::Insets();
343 331
344 if (IsMaximized()) { 332 if (IsMaximized()) {
345 // Windows automatically adds a standard width border to all sides when a 333 // Windows automatically adds a standard width border to all sides when a
346 // window is maximized. 334 // window is maximized.
347 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); 335 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
(...skipping 14 matching lines...) Expand all
362 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0); 350 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0);
363 } 351 }
364 352
365 int WindowWin::GetShowState() const { 353 int WindowWin::GetShowState() const {
366 return SW_SHOWNORMAL; 354 return SW_SHOWNORMAL;
367 } 355 }
368 356
369 /////////////////////////////////////////////////////////////////////////////// 357 ///////////////////////////////////////////////////////////////////////////////
370 // WindowWin, WidgetWin overrides: 358 // WindowWin, WidgetWin overrides:
371 359
360 void WindowWin::InitNativeWidget(const Widget::CreateParams& params) {
361 if (window_style() == 0)
362 set_window_style(CalculateWindowStyle());
363 if (window_ex_style() == 0)
364 set_window_ex_style(CalculateWindowExStyle());
365
366 GetMonitorAndRects(params.bounds.ToRECT(), &last_monitor_,
367 &last_monitor_rect_, &last_work_area_);
368
369 WidgetWin::InitNativeWidget(params);
370
371 delegate_->OnNativeWindowCreated(params.bounds);
372 }
373
372 void WindowWin::OnActivateApp(BOOL active, DWORD thread_id) { 374 void WindowWin::OnActivateApp(BOOL active, DWORD thread_id) {
373 if (!active && thread_id != GetCurrentThreadId()) { 375 if (!active && thread_id != GetCurrentThreadId()) {
374 // Another application was activated, we should reset any state that 376 // Another application was activated, we should reset any state that
375 // disables inactive rendering now. 377 // disables inactive rendering now.
376 delegate_->EnableInactiveRendering(); 378 delegate_->EnableInactiveRendering();
377 // Update the native frame too, since it could be rendering the non-client 379 // Update the native frame too, since it could be rendering the non-client
378 // area. 380 // area.
379 CallDefaultNCActivateHandler(FALSE); 381 CallDefaultNCActivateHandler(FALSE);
380 } 382 }
381 } 383 }
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 Window::CloseSecondaryWidget(native_widget->GetWidget()); 1362 Window::CloseSecondaryWidget(native_widget->GetWidget());
1361 return TRUE; 1363 return TRUE;
1362 } 1364 }
1363 } // namespace 1365 } // namespace
1364 1366
1365 void Window::CloseAllSecondaryWindows() { 1367 void Window::CloseAllSecondaryWindows() {
1366 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); 1368 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
1367 } 1369 }
1368 1370
1369 } // namespace views 1371 } // namespace views
OLDNEW
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698