Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: ui/views/widget/native_widget_win.cc

Issue 10408047: Fix bug 105043: Panels [WIN]: For minimize panels, taskbar hover preview show the 4-pixel represent… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698