Chromium Code Reviews| Index: ui/views/win/hwnd_message_handler.cc |
| diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc |
| index 0973c1e5d6396b3a004f2323832479d85d2fbec9..40dd7ebe9401c59fa60af1d07b7f5ce0f5e9ad4a 100644 |
| --- a/ui/views/win/hwnd_message_handler.cc |
| +++ b/ui/views/win/hwnd_message_handler.cc |
| @@ -359,7 +359,8 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate) |
| in_size_loop_(false), |
| touch_down_contexts_(0), |
| last_mouse_hwheel_time_(0), |
| - msg_handled_(FALSE) { |
| + msg_handled_(FALSE), |
| + dwm_transition_desired_(false) { |
| } |
| HWNDMessageHandler::~HWNDMessageHandler() { |
| @@ -794,33 +795,22 @@ void HWNDMessageHandler::SetCursor(HCURSOR cursor) { |
| } |
| void HWNDMessageHandler::FrameTypeChanged() { |
| - // Called when the frame type could possibly be changing (theme change or |
| - // DWM composition change). |
| - UpdateDwmNcRenderingPolicy(); |
| - |
| - // Don't redraw the window here, because we need to hide and show the window |
| - // which will also trigger a redraw. |
| - ResetWindowRegion(true, false); |
| - |
| - // The non-client view needs to update too. |
| - delegate_->HandleFrameChanged(); |
| - |
| - if (IsVisible() && !delegate_->IsUsingCustomFrame()) { |
| - // For some reason, we need to hide the window after we change from a custom |
| - // frame to a native frame. If we don't, the client area will be filled |
| - // with black. This seems to be related to an interaction between DWM and |
| - // SetWindowRgn, but the details aren't clear. Additionally, we need to |
| - // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows |
| - // open they will re-appear with a non-deterministic Z-order. |
| - UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; |
| - SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
| - SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
| + if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
| + // Don't redraw the window here, because we invalidate the window later. |
| + ResetWindowRegion(true, false); |
| + // The non-client view needs to update too. |
| + delegate_->HandleFrameChanged(); |
| + InvalidateRect(hwnd(), NULL, FALSE); |
| + } else { |
| + dwm_transition_desired_ = true; |
|
sky
2014/08/20 15:25:56
Shouldn't this be conditional on whether you actua
ananta
2014/08/20 18:52:54
Done.
|
| + // On Windows Vista and beyond, if we are transitioning from glass to |
|
sky
2014/08/20 15:25:56
I think this comment would be better in the header
ananta
2014/08/20 18:52:54
Done.
|
| + // custom and vice versa we delay setting the DWM related properties in |
| + // full screen mode as DWM is not supported in full screen windows. We |
| + // perform the DWM related operations when the window comes out of |
| + // fullscreen mode. |
| + if (!fullscreen_handler_->fullscreen()) |
| + PerformDwmTransition(); |
| } |
| - |
| - // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| - // to notify our children too, since we can have MDI child windows who need to |
| - // update their appearance. |
| - EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
| } |
| void HWNDMessageHandler::SchedulePaintInRect(const gfx::Rect& rect) { |
| @@ -875,6 +865,14 @@ void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon, |
| } |
| } |
| +void HWNDMessageHandler::SetFullscreen(bool fullscreen) { |
| + fullscreen_handler()->SetFullscreen(fullscreen); |
| + // If we are out of fullscreen and there was a pending DWM transition for the |
| + // window, then go ahead and do it now. |
| + if (!fullscreen && dwm_transition_desired_) |
| + PerformDwmTransition(); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // HWNDMessageHandler, InputMethodDelegate implementation: |
| @@ -1153,6 +1151,9 @@ void HWNDMessageHandler::UpdateDwmNcRenderingPolicy() { |
| if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| return; |
| + if (fullscreen_handler_->fullscreen()) |
| + return; |
| + |
| DWMNCRENDERINGPOLICY policy = |
| custom_window_region_ || delegate_->IsUsingCustomFrame() ? |
| DWMNCRP_DISABLED : DWMNCRP_ENABLED; |
| @@ -2443,4 +2444,34 @@ bool HWNDMessageHandler::IsSynthesizedMouseMessage(unsigned int message, |
| return false; |
| } |
| +void HWNDMessageHandler::PerformDwmTransition() { |
| + DCHECK(!fullscreen_handler_->fullscreen()); |
| + DCHECK(dwm_transition_desired_); |
| + |
| + dwm_transition_desired_ = false; |
| + |
| + UpdateDwmNcRenderingPolicy(); |
| + // Don't redraw the window here, because we need to hide and show the window |
| + // which will also trigger a redraw. |
| + ResetWindowRegion(true, false); |
| + // The non-client view needs to update too. |
| + delegate_->HandleFrameChanged(); |
| + |
| + if (IsVisible() && !delegate_->IsUsingCustomFrame()) { |
| + // For some reason, we need to hide the window after we change from a custom |
| + // frame to a native frame. If we don't, the client area will be filled |
| + // with black. This seems to be related to an interaction between DWM and |
| + // SetWindowRgn, but the details aren't clear. Additionally, we need to |
| + // specify SWP_NOZORDER here, otherwise if you have multiple chrome windows |
| + // open they will re-appear with a non-deterministic Z-order. |
| + UINT flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER; |
| + SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
| + SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
| + } |
| + // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
| + // to notify our children too, since we can have MDI child windows who need to |
| + // update their appearance. |
| + EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
| +} |
| + |
| } // namespace views |