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::SetBounds(const gfx::Rect& bounds_in_pixels) { |
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_in_pixels.x(), bounds_in_pixels.y(), |
530 bounds.height(), SWP_NOACTIVATE | SWP_NOZORDER); | 530 bounds_in_pixels.width(), bounds_in_pixels.height(), |
| 531 SWP_NOACTIVATE | SWP_NOZORDER); |
531 } | 532 } |
532 | 533 |
533 void HWNDMessageHandler::SetSize(const gfx::Size& size) { | 534 void HWNDMessageHandler::SetSize(const gfx::Size& size) { |
534 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), | 535 SetWindowPos(hwnd(), NULL, 0, 0, size.width(), size.height(), |
535 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); | 536 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); |
536 } | 537 } |
537 | 538 |
538 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { | 539 void HWNDMessageHandler::CenterWindow(const gfx::Size& size) { |
539 HWND parent = GetParent(hwnd()); | 540 HWND parent = GetParent(hwnd()); |
540 if (!IsWindow(hwnd())) | 541 if (!IsWindow(hwnd())) |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 } | 1155 } |
1155 } | 1156 } |
1156 } | 1157 } |
1157 | 1158 |
1158 void HWNDMessageHandler::RedrawLayeredWindowContents() { | 1159 void HWNDMessageHandler::RedrawLayeredWindowContents() { |
1159 if (invalid_rect_.IsEmpty()) | 1160 if (invalid_rect_.IsEmpty()) |
1160 return; | 1161 return; |
1161 | 1162 |
1162 // We need to clip to the dirty rect ourselves. | 1163 // We need to clip to the dirty rect ourselves. |
1163 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); | 1164 layered_window_contents_->sk_canvas()->save(SkCanvas::kClip_SaveFlag); |
| 1165 double scale = ui::win::GetDeviceScaleFactor(); |
| 1166 layered_window_contents_->sk_canvas()->scale( |
| 1167 SkScalar(scale),SkScalar(scale)); |
1164 layered_window_contents_->ClipRect(invalid_rect_); | 1168 layered_window_contents_->ClipRect(invalid_rect_); |
1165 delegate_->PaintLayeredWindow(layered_window_contents_.get()); | 1169 delegate_->PaintLayeredWindow(layered_window_contents_.get()); |
| 1170 layered_window_contents_->sk_canvas()->scale( |
| 1171 SkScalar(1.0/scale),SkScalar(1.0/scale)); |
1166 layered_window_contents_->sk_canvas()->restore(); | 1172 layered_window_contents_->sk_canvas()->restore(); |
1167 | 1173 |
1168 RECT wr; | 1174 RECT wr; |
1169 GetWindowRect(hwnd(), &wr); | 1175 GetWindowRect(hwnd(), &wr); |
1170 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; | 1176 SIZE size = {wr.right - wr.left, wr.bottom - wr.top}; |
1171 POINT position = {wr.left, wr.top}; | 1177 POINT position = {wr.left, wr.top}; |
1172 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas()); | 1178 HDC dib_dc = skia::BeginPlatformPaint(layered_window_contents_->sk_canvas()); |
1173 POINT zero = {0, 0}; | 1179 POINT zero = {0, 0}; |
1174 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; | 1180 BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; |
1175 UpdateLayeredWindow(hwnd(), NULL, &position, &size, dib_dc, &zero, | 1181 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); | 2112 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2107 } | 2113 } |
2108 if (window_pos->flags & SWP_SHOWWINDOW) | 2114 if (window_pos->flags & SWP_SHOWWINDOW) |
2109 delegate_->HandleVisibilityChanged(true); | 2115 delegate_->HandleVisibilityChanged(true); |
2110 else if (window_pos->flags & SWP_HIDEWINDOW) | 2116 else if (window_pos->flags & SWP_HIDEWINDOW) |
2111 delegate_->HandleVisibilityChanged(false); | 2117 delegate_->HandleVisibilityChanged(false); |
2112 SetMsgHandled(FALSE); | 2118 SetMsgHandled(FALSE); |
2113 } | 2119 } |
2114 | 2120 |
2115 } // namespace views | 2121 } // namespace views |
OLD | NEW |