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/widget/native_widget_win.h" | 5 #include "views/widget/native_widget_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/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2017 last_work_area_ = work_area; | 2017 last_work_area_ = work_area; |
2018 } | 2018 } |
2019 } | 2019 } |
2020 | 2020 |
2021 if (force_hidden_count_) { | 2021 if (force_hidden_count_) { |
2022 // Prevent the window from being made visible if we've been asked to do so. | 2022 // Prevent the window from being made visible if we've been asked to do so. |
2023 // See comment in header as to why we might want this. | 2023 // See comment in header as to why we might want this. |
2024 window_pos->flags &= ~SWP_SHOWWINDOW; | 2024 window_pos->flags &= ~SWP_SHOWWINDOW; |
2025 } | 2025 } |
2026 | 2026 |
| 2027 // When WM_WINDOWPOSCHANGING message is handled by DefWindowProc, it will |
| 2028 // enforce (cx, cy) not to be smaller than (6, 6) for any non-popup window. |
| 2029 // We work around this by changing cy back to our intended value. |
| 2030 if (!GetParent() && ~(window_pos->flags & SWP_NOSIZE) && window_pos->cy < 6) { |
| 2031 LONG old_cy = window_pos->cy; |
| 2032 DefWindowProc(GetNativeView(), WM_WINDOWPOSCHANGING, 0, |
| 2033 reinterpret_cast<LPARAM>(window_pos)); |
| 2034 window_pos->cy = old_cy; |
| 2035 SetMsgHandled(TRUE); |
| 2036 return; |
| 2037 } |
| 2038 |
2027 SetMsgHandled(FALSE); | 2039 SetMsgHandled(FALSE); |
2028 } | 2040 } |
2029 | 2041 |
2030 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { | 2042 void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) { |
2031 if (DidClientAreaSizeChange(window_pos)) | 2043 if (DidClientAreaSizeChange(window_pos)) |
2032 ClientAreaSizeChanged(); | 2044 ClientAreaSizeChanged(); |
2033 if (window_pos->flags & SWP_SHOWWINDOW) | 2045 if (window_pos->flags & SWP_SHOWWINDOW) |
2034 delegate_->OnNativeWidgetVisibilityChanged(true); | 2046 delegate_->OnNativeWidgetVisibilityChanged(true); |
2035 else if (window_pos->flags & SWP_HIDEWINDOW) | 2047 else if (window_pos->flags & SWP_HIDEWINDOW) |
2036 delegate_->OnNativeWidgetVisibilityChanged(false); | 2048 delegate_->OnNativeWidgetVisibilityChanged(false); |
(...skipping 12 matching lines...) Expand all Loading... |
2049 //////////////////////////////////////////////////////////////////////////////// | 2061 //////////////////////////////////////////////////////////////////////////////// |
2050 // NativeWidgetWin, protected: | 2062 // NativeWidgetWin, protected: |
2051 | 2063 |
2052 int NativeWidgetWin::GetShowState() const { | 2064 int NativeWidgetWin::GetShowState() const { |
2053 return SW_SHOWNORMAL; | 2065 return SW_SHOWNORMAL; |
2054 } | 2066 } |
2055 | 2067 |
2056 gfx::Insets NativeWidgetWin::GetClientAreaInsets() const { | 2068 gfx::Insets NativeWidgetWin::GetClientAreaInsets() const { |
2057 // Returning an empty Insets object causes the default handling in | 2069 // Returning an empty Insets object causes the default handling in |
2058 // NativeWidgetWin::OnNCCalcSize() to be invoked. | 2070 // NativeWidgetWin::OnNCCalcSize() to be invoked. |
2059 if (!GetWidget()->non_client_view() || GetWidget()->ShouldUseNativeFrame()) | 2071 if (GetWidget()->ShouldUseNativeFrame()) |
2060 return gfx::Insets(); | 2072 return gfx::Insets(); |
2061 | 2073 |
2062 if (IsMaximized()) { | 2074 if (IsMaximized()) { |
2063 // Windows automatically adds a standard width border to all sides when a | 2075 // Windows automatically adds a standard width border to all sides when a |
2064 // window is maximized. | 2076 // window is maximized. |
2065 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 2077 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
2066 return gfx::Insets(border_thickness, border_thickness, border_thickness, | 2078 return gfx::Insets(border_thickness, border_thickness, border_thickness, |
2067 border_thickness); | 2079 border_thickness); |
2068 } | 2080 } |
2069 // This is weird, but highly essential. If we don't offset the bottom edge | 2081 // This is weird, but highly essential. If we don't offset the bottom edge |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 return (GetKeyState(VK_LBUTTON) & 0x80) || | 2533 return (GetKeyState(VK_LBUTTON) & 0x80) || |
2522 (GetKeyState(VK_RBUTTON) & 0x80) || | 2534 (GetKeyState(VK_RBUTTON) & 0x80) || |
2523 (GetKeyState(VK_MBUTTON) & 0x80) || | 2535 (GetKeyState(VK_MBUTTON) & 0x80) || |
2524 (GetKeyState(VK_XBUTTON1) & 0x80) || | 2536 (GetKeyState(VK_XBUTTON1) & 0x80) || |
2525 (GetKeyState(VK_XBUTTON2) & 0x80); | 2537 (GetKeyState(VK_XBUTTON2) & 0x80); |
2526 } | 2538 } |
2527 | 2539 |
2528 } // namespace internal | 2540 } // namespace internal |
2529 | 2541 |
2530 } // namespace views | 2542 } // namespace views |
OLD | NEW |