| OLD | NEW |
| 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 Loading... |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 last_monitor_(NULL) { | 315 last_monitor_(NULL) { |
| 314 SetNativeWindow(this); | 316 SetNativeWindow(this); |
| 315 is_window_ = true; | 317 is_window_ = true; |
| 316 InitClass(); | 318 InitClass(); |
| 317 // Initialize these values to 0 so that subclasses can override the default | 319 // Initialize these values to 0 so that subclasses can override the default |
| 318 // behavior before calling Init. | 320 // behavior before calling Init. |
| 319 set_window_style(0); | 321 set_window_style(0); |
| 320 set_window_ex_style(0); | 322 set_window_ex_style(0); |
| 321 } | 323 } |
| 322 | 324 |
| 323 void WindowWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) { | |
| 324 if (window_style() == 0) | |
| 325 set_window_style(CalculateWindowStyle()); | |
| 326 if (window_ex_style() == 0) | |
| 327 set_window_ex_style(CalculateWindowExStyle()); | |
| 328 | |
| 329 GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, | |
| 330 &last_work_area_); | |
| 331 | |
| 332 WidgetWin::Init(parent, bounds); | |
| 333 | |
| 334 delegate_->OnNativeWindowCreated(bounds); | |
| 335 } | |
| 336 | |
| 337 gfx::Insets WindowWin::GetClientAreaInsets() const { | 325 gfx::Insets WindowWin::GetClientAreaInsets() const { |
| 338 // Returning an empty Insets object causes the default handling in | 326 // Returning an empty Insets object causes the default handling in |
| 339 // WidgetWin::OnNCCalcSize() to be invoked. | 327 // WidgetWin::OnNCCalcSize() to be invoked. |
| 340 if (delegate_->IsUsingNativeFrame()) | 328 if (delegate_->IsUsingNativeFrame()) |
| 341 return gfx::Insets(); | 329 return gfx::Insets(); |
| 342 | 330 |
| 343 if (IsMaximized()) { | 331 if (IsMaximized()) { |
| 344 // Windows automatically adds a standard width border to all sides when a | 332 // Windows automatically adds a standard width border to all sides when a |
| 345 // window is maximized. | 333 // window is maximized. |
| 346 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 334 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 361 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0); | 349 return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0); |
| 362 } | 350 } |
| 363 | 351 |
| 364 int WindowWin::GetShowState() const { | 352 int WindowWin::GetShowState() const { |
| 365 return SW_SHOWNORMAL; | 353 return SW_SHOWNORMAL; |
| 366 } | 354 } |
| 367 | 355 |
| 368 /////////////////////////////////////////////////////////////////////////////// | 356 /////////////////////////////////////////////////////////////////////////////// |
| 369 // WindowWin, WidgetWin overrides: | 357 // WindowWin, WidgetWin overrides: |
| 370 | 358 |
| 359 void WindowWin::InitNativeWidget(const Widget::CreateParams& params) { |
| 360 if (window_style() == 0) |
| 361 set_window_style(CalculateWindowStyle()); |
| 362 if (window_ex_style() == 0) |
| 363 set_window_ex_style(CalculateWindowExStyle()); |
| 364 |
| 365 GetMonitorAndRects(params.bounds.ToRECT(), &last_monitor_, |
| 366 &last_monitor_rect_, &last_work_area_); |
| 367 |
| 368 WidgetWin::InitNativeWidget(params); |
| 369 |
| 370 delegate_->OnNativeWindowCreated(params.bounds); |
| 371 } |
| 372 |
| 371 void WindowWin::OnActivateApp(BOOL active, DWORD thread_id) { | 373 void WindowWin::OnActivateApp(BOOL active, DWORD thread_id) { |
| 372 if (!active && thread_id != GetCurrentThreadId()) { | 374 if (!active && thread_id != GetCurrentThreadId()) { |
| 373 // Another application was activated, we should reset any state that | 375 // Another application was activated, we should reset any state that |
| 374 // disables inactive rendering now. | 376 // disables inactive rendering now. |
| 375 delegate_->EnableInactiveRendering(); | 377 delegate_->EnableInactiveRendering(); |
| 376 // Update the native frame too, since it could be rendering the non-client | 378 // Update the native frame too, since it could be rendering the non-client |
| 377 // area. | 379 // area. |
| 378 CallDefaultNCActivateHandler(FALSE); | 380 CallDefaultNCActivateHandler(FALSE); |
| 379 } | 381 } |
| 380 } | 382 } |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 Window::CloseSecondaryWidget(native_widget->GetWidget()); | 1351 Window::CloseSecondaryWidget(native_widget->GetWidget()); |
| 1350 return TRUE; | 1352 return TRUE; |
| 1351 } | 1353 } |
| 1352 } // namespace | 1354 } // namespace |
| 1353 | 1355 |
| 1354 void Window::CloseAllSecondaryWindows() { | 1356 void Window::CloseAllSecondaryWindows() { |
| 1355 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); | 1357 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); |
| 1356 } | 1358 } |
| 1357 | 1359 |
| 1358 } // namespace views | 1360 } // namespace views |
| OLD | NEW |