Chromium Code Reviews| 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 <wtsapi32.h> | 10 #include <wtsapi32.h> |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 // frame to a native frame. If we don't, the client area will be filled | 810 // frame to a native frame. If we don't, the client area will be filled |
| 811 // with black. This seems to be related to an interaction between DWM and | 811 // with black. This seems to be related to an interaction between DWM and |
| 812 // SetWindowRgn, but the details aren't clear. Additionally, we need to | 812 // SetWindowRgn, but the details aren't clear. Additionally, we need to |
| 813 // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows | 813 // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows |
| 814 // open they will re-appear with a non-deterministic Z-order. | 814 // open they will re-appear with a non-deterministic Z-order. |
| 815 UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; | 815 UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; |
| 816 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 816 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
| 817 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 817 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
| 818 // Invalidate the window to force a paint. There may be child windows which | 818 // Invalidate the window to force a paint. There may be child windows which |
| 819 // could resize in this context. Don't paint right away. | 819 // could resize in this context. Don't paint right away. |
| 820 ::InvalidateRect(hwnd(), NULL, FALSE); | 820 base::MessageLoop::current()->PostDelayedTask( |
| 821 FROM_HERE, | |
| 822 base::Bind(base::IgnoreResult(&::InvalidateRect), hwnd(), | |
| 823 reinterpret_cast<const RECT*>(NULL), FALSE), | |
| 824 base::TimeDelta::FromMilliseconds(500)); | |
|
ananta
2014/08/05 00:24:03
It now appears that the bug was never fixed. We ne
sky
2014/08/05 01:30:56
This is a total hack. Why do we need to delay?
Als
| |
| 821 } | 825 } |
| 822 | 826 |
| 823 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 827 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| 824 // to notify our children too, since we can have MDI child windows who need to | 828 // to notify our children too, since we can have MDI child windows who need to |
| 825 // update their appearance. | 829 // update their appearance. |
| 826 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 830 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
| 827 } | 831 } |
| 828 | 832 |
| 829 void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { | 833 void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { |
| 830 if (use_layered_buffer_) { | 834 if (use_layered_buffer_) { |
| 831 // We must update the back-buffer immediately, since Windows' handling of | 835 // We must update the back-buffer immediately, since Windows' handling of |
| 832 // invalid rects is somewhat mysterious. | 836 // invalid rects is somewhat mysterious. |
| 833 invalid_rect_.Union(rect); | 837 invalid_rect_.Union(rect); |
| 834 | 838 |
| 835 // In some situations, such as drag and drop, when Windows itself runs a | 839 // In some situations, such as drag and drop, when Windows itself runs a |
| 836 // nested message loop our message loop appears to be starved and we don't | 840 // nested message loop our message loop appears to be starved and we don't |
| 837 // receive calls to DidProcessMessage(). This only seems to affect layered | 841 // receive calls to DidProcessMessage(). This only seems to affect layered |
| 838 // windows, so we schedule a redraw manually using a task, since those never | 842 // windows, so we schedule a redraw manually using a task, since those never |
| 839 // seem to be starved. Also, wtf. | 843 // seem to be starved. Also, wtf. |
| 840 if (!waiting_for_redraw_layered_window_contents_) { | 844 if (!waiting_for_redraw_layered_window_contents_) { |
| 841 waiting_for_redraw_layered_window_contents_ = true; | 845 waiting_for_redraw_layered_window_contents_ = true; |
| 842 base::MessageLoop::current()->PostTask( | 846 base::MessageLoop::current()->PostTask( |
| 843 FROM_HERE, | 847 FROM_HERE, |
| 844 base::Bind(&HWNDMessageHandler::RedrawLayeredWindowContents, | 848 base::Bind(base::IgnoreResult(&HWNDMessageHandler::RedrawLayeredWindow Contents), |
| 845 weak_factory_.GetWeakPtr())); | 849 weak_factory_.GetWeakPtr())); |
| 846 } | 850 } |
| 847 } else { | 851 } else { |
| 848 // InvalidateRect() expects client coordinates. | 852 // InvalidateRect() expects client coordinates. |
| 849 RECT r = rect.ToRECT(); | 853 RECT r = rect.ToRECT(); |
| 850 InvalidateRect(hwnd(), &r, FALSE); | 854 InvalidateRect(hwnd(), &r, FALSE); |
| 851 } | 855 } |
| 852 } | 856 } |
| 853 | 857 |
| 854 void HWNDMessageHandler::SetOpacity(BYTE opacity) { | 858 void HWNDMessageHandler::SetOpacity(BYTE opacity) { |
| (...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2437 POINT cursor_pos = {0}; | 2441 POINT cursor_pos = {0}; |
| 2438 ::GetCursorPos(&cursor_pos); | 2442 ::GetCursorPos(&cursor_pos); |
| 2439 if (memcmp(&cursor_pos, &mouse_location, sizeof(POINT))) | 2443 if (memcmp(&cursor_pos, &mouse_location, sizeof(POINT))) |
| 2440 return false; | 2444 return false; |
| 2441 return true; | 2445 return true; |
| 2442 } | 2446 } |
| 2443 return false; | 2447 return false; |
| 2444 } | 2448 } |
| 2445 | 2449 |
| 2446 } // namespace views | 2450 } // namespace views |
| OLD | NEW |