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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 if (show_state) { | 515 if (show_state) { |
516 if (wp.showCmd == SW_SHOWMAXIMIZED) | 516 if (wp.showCmd == SW_SHOWMAXIMIZED) |
517 *show_state = ui::SHOW_STATE_MAXIMIZED; | 517 *show_state = ui::SHOW_STATE_MAXIMIZED; |
518 else if (wp.showCmd == SW_SHOWMINIMIZED) | 518 else if (wp.showCmd == SW_SHOWMINIMIZED) |
519 *show_state = ui::SHOW_STATE_MINIMIZED; | 519 *show_state = ui::SHOW_STATE_MINIMIZED; |
520 else | 520 else |
521 *show_state = ui::SHOW_STATE_NORMAL; | 521 *show_state = ui::SHOW_STATE_NORMAL; |
522 } | 522 } |
523 } | 523 } |
524 | 524 |
525 void HWNDMessageHandler::SetBounds(const gfx::Rect& bounds) { | 525 void HWNDMessageHandler::SetBoundsInPixel(const gfx::Rect& bounds) { |
526 LONG style = GetWindowLong(hwnd(), GWL_STYLE); | 526 LONG style = GetWindowLong(hwnd(), GWL_STYLE); |
527 if (style & WS_MAXIMIZE) | 527 if (style & WS_MAXIMIZE) |
528 SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE); | 528 SetWindowLong(hwnd(), GWL_STYLE, style & ~WS_MAXIMIZE); |
529 SetWindowPos(hwnd(), NULL, bounds.x(), bounds.y(), bounds.width(), | 529 SetWindowPos(hwnd(), NULL, bounds.x(), bounds.y(), bounds.width(), |
530 bounds.height(), SWP_NOACTIVATE | SWP_NOZORDER); | 530 bounds.height(), SWP_NOACTIVATE | SWP_NOZORDER); |
531 } | 531 } |
532 | 532 |
533 void HWNDMessageHandler::SetSize(const gfx::Size& size) { | 533 void HWNDMessageHandler::SetSize(const gfx::Size& size) { |
534 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), | 534 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), |
535 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 535 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 RedrawWindow(hwnd(), &r, NULL, | 1152 RedrawWindow(hwnd(), &r, NULL, |
1153 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); | 1153 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 } | 1156 } |
1157 | 1157 |
1158 void HWNDMessageHandler::RedrawLayeredWindowContents() { | 1158 void HWNDMessageHandler::RedrawLayeredWindowContents() { |
1159 if (invalid_rect_.IsEmpty()) | 1159 if (invalid_rect_.IsEmpty()) |
1160 return; | 1160 return; |
1161 | 1161 |
1162 // We need to clip to the dirty rect ourselves. | 1162 // We need to clip to the dirty rect ourselves. |
kevers
2013/06/03 17:28:50
Tested on Aura?
| |
1163 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); | 1163 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); |
1164 double scale = ui::win::GetDeviceScaleFactor(); | |
1165 layered_window_contents_->sk_canvas()->scale( | |
1166 SkScalar(scale),SkScalar(scale)); | |
1164 layered_window_contents_->ClipRect(invalid_rect_); | 1167 layered_window_contents_->ClipRect(invalid_rect_); |
1165 delegate_->PaintLayeredWindow(layered_window_contents_.get()); | 1168 delegate_->PaintLayeredWindow(layered_window_contents_.get()); |
1169 layered_window_contents_->sk_canvas()->scale( | |
1170 SkScalar(1.0/scale),SkScalar(1.0/scale)); | |
1166 layered_window_contents_->sk_canvas()->restore(); | 1171 layered_window_contents_->sk_canvas()->restore(); |
1167 | 1172 |
1168 RECT wr; | 1173 RECT wr; |
1169 GetWindowRect(hwnd(), &wr); | 1174 GetWindowRect(hwnd(), &wr); |
1170 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; | 1175 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; |
1171 POINT position = {wr.left, wr.top}; | 1176 POINT position = {wr.left, wr.top}; |
1172 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas()); | 1177 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas()); |
1173 POINT zero = {0, 0}; | 1178 POINT zero = {0, 0}; |
1174 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; | 1179 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; |
1175 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, | 1180 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, |
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2106 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2111 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2107 } | 2112 } |
2108 if (window_pos->flags & SWP_SHOWWINDOW) | 2113 if (window_pos->flags & SWP_SHOWWINDOW) |
2109 delegate_->HandleVisibilityChanged(true); | 2114 delegate_->HandleVisibilityChanged(true); |
2110 else if (window_pos->flags & SWP_HIDEWINDOW) | 2115 else if (window_pos->flags & SWP_HIDEWINDOW) |
2111 delegate_->HandleVisibilityChanged(false); | 2116 delegate_->HandleVisibilityChanged(false); |
2112 SetMsgHandled(FALSE); | 2117 SetMsgHandled(FALSE); |
2113 } | 2118 } |
2114 | 2119 |
2115 } // namespace views | 2120 } // namespace views |
OLD | NEW |