| OLD | NEW |
| 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/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <oleacc.h> | 8 #include <oleacc.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <tchar.h> | 10 #include <tchar.h> |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 *show_state = ui::SHOW_STATE_NORMAL; | 516 *show_state = ui::SHOW_STATE_NORMAL; |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels, | 520 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds_in_pixels, |
| 521 bool force_size_changed) { | 521 bool force_size_changed) { |
| 522 background_fullscreen_hack_ = false; | 522 background_fullscreen_hack_ = false; |
| 523 SetBoundsInternal(bounds_in_pixels, force_size_changed); | 523 SetBoundsInternal(bounds_in_pixels, force_size_changed); |
| 524 } | 524 } |
| 525 | 525 |
| 526 void HWNDMessageHandler::SetDwmFrameExtension(DwmFrameState state) { |
| 527 if (!delegate_->HasFrame() && ui::win::IsAeroGlassEnabled() && |
| 528 (window_ex_style() & WS_EX_COMPOSITED) == 0) { |
| 529 MARGINS m = {0, 0, 0, 0}; |
| 530 if (state == DwmFrameState::ON) |
| 531 m = {0, 0, 1, 0}; |
| 532 DwmExtendFrameIntoClientArea(hwnd(), &m); |
| 533 } |
| 534 } |
| 535 |
| 526 void HWNDMessageHandler::SetSize(const gfx::Size& size) { | 536 void HWNDMessageHandler::SetSize(const gfx::Size& size) { |
| 527 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), | 537 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), |
| 528 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 538 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
| 529 } | 539 } |
| 530 | 540 |
| 531 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { | 541 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { |
| 532 HWND parent = GetParent(hwnd()); | 542 HWND parent = GetParent(hwnd()); |
| 533 if (!IsWindow(hwnd())) | 543 if (!IsWindow(hwnd())) |
| 534 parent = ::GetWindow(hwnd(), GW_OWNER); | 544 parent = ::GetWindow(hwnd(), GW_OWNER); |
| 535 gfx::CenterAndSizeWindow(parent, hwnd(), size); | 545 gfx::CenterAndSizeWindow(parent, hwnd(), size); |
| (...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 } | 2364 } |
| 2355 | 2365 |
| 2356 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) { | 2366 if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) { |
| 2357 // Prevent the window from being made visible if we've been asked to do so. | 2367 // Prevent the window from being made visible if we've been asked to do so. |
| 2358 // See comment in header as to why we might want this. | 2368 // See comment in header as to why we might want this. |
| 2359 window_pos->flags &= ~SWP_SHOWWINDOW; | 2369 window_pos->flags &= ~SWP_SHOWWINDOW; |
| 2360 } | 2370 } |
| 2361 | 2371 |
| 2362 if (window_pos->flags & SWP_SHOWWINDOW) | 2372 if (window_pos->flags & SWP_SHOWWINDOW) |
| 2363 delegate_->HandleVisibilityChanging(true); | 2373 delegate_->HandleVisibilityChanging(true); |
| 2364 else if (window_pos->flags & SWP_HIDEWINDOW) | 2374 else if (window_pos->flags & SWP_HIDEWINDOW) { |
| 2375 SetDwmFrameExtension(DwmFrameState::OFF); |
| 2365 delegate_->HandleVisibilityChanging(false); | 2376 delegate_->HandleVisibilityChanging(false); |
| 2377 } |
| 2366 | 2378 |
| 2367 SetMsgHandled(FALSE); | 2379 SetMsgHandled(FALSE); |
| 2368 } | 2380 } |
| 2369 | 2381 |
| 2370 void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) { | 2382 void HWNDMessageHandler::OnWindowPosChanged(WINDOWPOS* window_pos) { |
| 2371 if (DidClientAreaSizeChange(window_pos)) | 2383 if (DidClientAreaSizeChange(window_pos)) |
| 2372 ClientAreaSizeChanged(); | 2384 ClientAreaSizeChanged(); |
| 2373 if (!delegate_->HasFrame() && window_pos->flags & SWP_FRAMECHANGED && | 2385 if (window_pos->flags & SWP_FRAMECHANGED) |
| 2374 ui::win::IsAeroGlassEnabled() && | 2386 SetDwmFrameExtension(DwmFrameState::ON); |
| 2375 (window_ex_style() & WS_EX_COMPOSITED) == 0) { | |
| 2376 MARGINS m = {10, 10, 10, 10}; | |
| 2377 DwmExtendFrameIntoClientArea(hwnd(), &m); | |
| 2378 } | |
| 2379 if (window_pos->flags & SWP_SHOWWINDOW) { | 2387 if (window_pos->flags & SWP_SHOWWINDOW) { |
| 2380 delegate_->HandleVisibilityChanged(true); | 2388 delegate_->HandleVisibilityChanged(true); |
| 2381 if (direct_manipulation_helper_) | 2389 if (direct_manipulation_helper_) |
| 2382 direct_manipulation_helper_->Activate(hwnd()); | 2390 direct_manipulation_helper_->Activate(hwnd()); |
| 2391 SetDwmFrameExtension(DwmFrameState::ON); |
| 2383 } else if (window_pos->flags & SWP_HIDEWINDOW) { | 2392 } else if (window_pos->flags & SWP_HIDEWINDOW) { |
| 2384 delegate_->HandleVisibilityChanged(false); | 2393 delegate_->HandleVisibilityChanged(false); |
| 2385 if (direct_manipulation_helper_) | 2394 if (direct_manipulation_helper_) |
| 2386 direct_manipulation_helper_->Deactivate(hwnd()); | 2395 direct_manipulation_helper_->Deactivate(hwnd()); |
| 2387 } | 2396 } |
| 2388 if (sent_window_size_changing_) { | 2397 if (sent_window_size_changing_) { |
| 2389 sent_window_size_changing_ = false; | 2398 sent_window_size_changing_ = false; |
| 2390 delegate_->HandleWindowSizeChanged(); | 2399 delegate_->HandleWindowSizeChanged(); |
| 2391 } | 2400 } |
| 2392 SetMsgHandled(FALSE); | 2401 SetMsgHandled(FALSE); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2749 MONITORINFO monitor_info = {sizeof(monitor_info)}; | 2758 MONITORINFO monitor_info = {sizeof(monitor_info)}; |
| 2750 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), | 2759 GetMonitorInfo(MonitorFromWindow(hwnd(), MONITOR_DEFAULTTOPRIMARY), |
| 2751 &monitor_info); | 2760 &monitor_info); |
| 2752 gfx::Rect shrunk_rect(monitor_info.rcMonitor); | 2761 gfx::Rect shrunk_rect(monitor_info.rcMonitor); |
| 2753 shrunk_rect.set_height(shrunk_rect.height() - 1); | 2762 shrunk_rect.set_height(shrunk_rect.height() - 1); |
| 2754 background_fullscreen_hack_ = true; | 2763 background_fullscreen_hack_ = true; |
| 2755 SetBoundsInternal(shrunk_rect, false); | 2764 SetBoundsInternal(shrunk_rect, false); |
| 2756 } | 2765 } |
| 2757 | 2766 |
| 2758 } // namespace views | 2767 } // namespace views |
| OLD | NEW |