| Index: ui/views/widget/native_widget_win.cc
|
| diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
|
| index fe4c6b14e54183c5658f509c7816b1ec4a8e8f28..18c18866eff4fd1528c7f067199f4e3ebe7d49e9 100644
|
| --- a/ui/views/widget/native_widget_win.cc
|
| +++ b/ui/views/widget/native_widget_win.cc
|
| @@ -28,6 +28,7 @@
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/canvas_paint.h"
|
| #include "ui/gfx/canvas_skia_paint.h"
|
| +#include "ui/gfx/gdi_util.h"
|
| #include "ui/gfx/icon_util.h"
|
| #include "ui/base/native_theme/native_theme_win.h"
|
| #include "ui/gfx/path.h"
|
| @@ -330,6 +331,27 @@ BOOL CALLBACK FindOwnedWindowsCallback(HWND hwnd, LPARAM param) {
|
| return TRUE;
|
| }
|
|
|
| +HBITMAP GetNativeBitmapFromSkBitmap(const SkBitmap& bitmap) {
|
| + int width = bitmap.width();
|
| + int height = bitmap.height();
|
| +
|
| + BITMAPV4HEADER native_bitmap_header;
|
| + gfx::CreateBitmapV4Header(width, height, &native_bitmap_header);
|
| +
|
| + HDC dc = ::GetDC(NULL);
|
| + void* bits;
|
| + HBITMAP native_bitmap = ::CreateDIBSection(dc,
|
| + reinterpret_cast<BITMAPINFO*>(&native_bitmap_header),
|
| + DIB_RGB_COLORS,
|
| + &bits,
|
| + NULL,
|
| + 0);
|
| + DCHECK(native_bitmap);
|
| + ::ReleaseDC(NULL, dc);
|
| + bitmap.copyPixelsTo(bits, width * height * 4, width * 4);
|
| + return native_bitmap;
|
| +}
|
| +
|
| } // namespace
|
|
|
| // static
|
| @@ -1367,6 +1389,50 @@ LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg,
|
| return 0;
|
| }
|
|
|
| +LRESULT NativeWidgetWin::OnDwmSendIconicThumbnail(UINT msg,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + if (!GetWidget()->non_client_view()) {
|
| + SetMsgHandled(FALSE);
|
| + return 0;
|
| + }
|
| +
|
| + gfx::Size size(HIWORD(l_param), LOWORD(l_param));
|
| + SkBitmap preview_bitmap =
|
| + GetWidget()->widget_delegate()->GetPreviewImage(size, false);
|
| + if (preview_bitmap.empty()) {
|
| + SetMsgHandled(FALSE);
|
| + return 0;
|
| + }
|
| +
|
| + HBITMAP native_bitmap = GetNativeBitmapFromSkBitmap(preview_bitmap);
|
| + ::DwmSetIconicThumbnail(hwnd(), native_bitmap, 0);
|
| + ::DeleteObject(native_bitmap);
|
| + return 0;
|
| +}
|
| +
|
| +LRESULT NativeWidgetWin::OnDwmSendIconicLivePreviewBitmap(UINT msg,
|
| + WPARAM w_param,
|
| + LPARAM l_param) {
|
| + if (!GetWidget()->non_client_view()) {
|
| + SetMsgHandled(FALSE);
|
| + return 0;
|
| + }
|
| +
|
| + gfx::Rect bounds = GetWindowScreenBounds();
|
| + SkBitmap preview_bitmap =
|
| + GetWidget()->widget_delegate()->GetPreviewImage(bounds.size(), true);
|
| + if (preview_bitmap.empty()) {
|
| + SetMsgHandled(FALSE);
|
| + return 0;
|
| + }
|
| +
|
| + HBITMAP native_bitmap = GetNativeBitmapFromSkBitmap(preview_bitmap);
|
| + ::DwmSetIconicLivePreviewBitmap(hwnd(), native_bitmap, NULL, 0);
|
| + ::DeleteObject(native_bitmap);
|
| + return 0;
|
| +}
|
| +
|
| void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) {
|
| SetMsgHandled(FALSE);
|
| }
|
|
|