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 <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 835 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
836 // to notify our children too, since we can have MDI child windows who need to | 836 // to notify our children too, since we can have MDI child windows who need to |
837 // update their appearance. | 837 // update their appearance. |
838 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 838 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
839 } | 839 } |
840 | 840 |
841 void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { | 841 void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { |
842 if (use_layered_buffer_) { | 842 if (use_layered_buffer_) { |
843 // We must update the back-buffer immediately, since Windows' handling of | 843 // We must update the back-buffer immediately, since Windows' handling of |
844 // invalid rects is somewhat mysterious. | 844 // invalid rects is somewhat mysterious. |
845 invalid_rect_ = invalid_rect_.Union(rect); | 845 invalid_rect_.Union(rect); |
846 | 846 |
847 // In some situations, such as drag and drop, when Windows itself runs a | 847 // In some situations, such as drag and drop, when Windows itself runs a |
848 // nested message loop our message loop appears to be starved and we don't | 848 // nested message loop our message loop appears to be starved and we don't |
849 // receive calls to DidProcessMessage(). This only seems to affect layered | 849 // receive calls to DidProcessMessage(). This only seems to affect layered |
850 // windows, so we schedule a redraw manually using a task, since those never | 850 // windows, so we schedule a redraw manually using a task, since those never |
851 // seem to be starved. Also, wtf. | 851 // seem to be starved. Also, wtf. |
852 if (!paint_layered_window_factory_.HasWeakPtrs()) { | 852 if (!paint_layered_window_factory_.HasWeakPtrs()) { |
853 MessageLoop::current()->PostTask( | 853 MessageLoop::current()->PostTask( |
854 FROM_HERE, | 854 FROM_HERE, |
855 base::Bind(&HWNDMessageHandler::RedrawLayeredWindowContents, | 855 base::Bind(&HWNDMessageHandler::RedrawLayeredWindowContents, |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 // response is to throw away the existing position/size information in | 2027 // response is to throw away the existing position/size information in |
2028 // |window_pos| and recalculate it based on the new work rect. | 2028 // |window_pos| and recalculate it based on the new work rect. |
2029 gfx::Rect new_window_rect; | 2029 gfx::Rect new_window_rect; |
2030 if (fullscreen_handler_->fullscreen()) { | 2030 if (fullscreen_handler_->fullscreen()) { |
2031 new_window_rect = monitor_rect; | 2031 new_window_rect = monitor_rect; |
2032 } else if (IsMaximized()) { | 2032 } else if (IsMaximized()) { |
2033 new_window_rect = work_area; | 2033 new_window_rect = work_area; |
2034 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 2034 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
2035 new_window_rect.Inset(-border_thickness, -border_thickness); | 2035 new_window_rect.Inset(-border_thickness, -border_thickness); |
2036 } else { | 2036 } else { |
2037 new_window_rect = gfx::Rect(window_rect).AdjustToFit(work_area); | 2037 new_window_rect = gfx::Rect(window_rect); |
| 2038 new_window_rect.AdjustToFit(work_area); |
2038 } | 2039 } |
2039 window_pos->x = new_window_rect.x(); | 2040 window_pos->x = new_window_rect.x(); |
2040 window_pos->y = new_window_rect.y(); | 2041 window_pos->y = new_window_rect.y(); |
2041 window_pos->cx = new_window_rect.width(); | 2042 window_pos->cx = new_window_rect.width(); |
2042 window_pos->cy = new_window_rect.height(); | 2043 window_pos->cy = new_window_rect.height(); |
2043 // WARNING! Don't set SWP_FRAMECHANGED here, it breaks moving the child | 2044 // WARNING! Don't set SWP_FRAMECHANGED here, it breaks moving the child |
2044 // HWNDs for some reason. | 2045 // HWNDs for some reason. |
2045 window_pos->flags &= ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW); | 2046 window_pos->flags &= ~(SWP_NOSIZE | SWP_NOMOVE | SWP_NOREDRAW); |
2046 window_pos->flags |= SWP_NOCOPYBITS; | 2047 window_pos->flags |= SWP_NOCOPYBITS; |
2047 | 2048 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2080 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2080 } | 2081 } |
2081 if (window_pos->flags & SWP_SHOWWINDOW) | 2082 if (window_pos->flags & SWP_SHOWWINDOW) |
2082 delegate_->HandleVisibilityChanged(true); | 2083 delegate_->HandleVisibilityChanged(true); |
2083 else if (window_pos->flags & SWP_HIDEWINDOW) | 2084 else if (window_pos->flags & SWP_HIDEWINDOW) |
2084 delegate_->HandleVisibilityChanged(false); | 2085 delegate_->HandleVisibilityChanged(false); |
2085 SetMsgHandled(FALSE); | 2086 SetMsgHandled(FALSE); |
2086 } | 2087 } |
2087 | 2088 |
2088 } // namespace views | 2089 } // namespace views |
OLD | NEW |