Index: chrome/browser/ui/views/panels/panel_stack_view.cc |
diff --git a/chrome/browser/ui/views/panels/panel_stack_view.cc b/chrome/browser/ui/views/panels/panel_stack_view.cc |
index 96c19750835938facf0140d7a1241593a823291d..d7d4b9ed7e986fed32385d597d3222ac70cc6aa8 100644 |
--- a/chrome/browser/ui/views/panels/panel_stack_view.cc |
+++ b/chrome/browser/ui/views/panels/panel_stack_view.cc |
@@ -19,7 +19,6 @@ |
#if defined(OS_WIN) |
#include "base/win/windows_version.h" |
#include "chrome/browser/shell_integration.h" |
-#include "chrome/browser/ui/views/panels/taskbar_window_thumbnailer_win.h" |
#include "ui/base/win/shell.h" |
#include "ui/views/win/hwnd_util.h" |
#endif |
@@ -46,6 +45,7 @@ PanelStackView::PanelStackView(NativePanelStackWindowDelegate* delegate) |
window_(NULL), |
is_closing_(false), |
is_drawing_attention_(false), |
+ is_minimizing_(false), |
animate_bounds_updates_(false), |
bounds_updates_started_(false) { |
DCHECK(delegate); |
@@ -74,6 +74,10 @@ void PanelStackView::AddPanel(Panel* panel) { |
window_->UpdateWindowTitle(); |
window_->UpdateWindowIcon(); |
+ |
+#if defined(OS_WIN) |
+ StartOrStopCustomThumbnailForMinimizePanel(); |
+#endif |
} |
void PanelStackView::RemovePanel(Panel* panel) { |
@@ -81,6 +85,10 @@ void PanelStackView::RemovePanel(Panel* panel) { |
MakeStackWindowOwnPanelWindow(panel, NULL); |
UpdateStackWindowBounds(); |
+ |
+#if defined(OS_WIN) |
+ StartOrStopCustomThumbnailForMinimizePanel(); |
+#endif |
} |
void PanelStackView::MergeWith(NativePanelStackWindow* another) { |
@@ -172,10 +180,15 @@ void PanelStackView::Minimize() { |
// When the owner stack window is minimized by the system, its live preview |
// is lost. We need to set it explicitly. This has to be done before the |
// minimization. |
- CaptureThumbnailForLivePreview(); |
+ CaptureThumbnailForLivePreview(true); |
#endif |
+ // On Windows, the system will activate the window before it is minimized. |
+ // Set this flag such that the thumbnailer will not be stopped in |
+ // OnWidgetActivationChanged. |
+ is_minimizing_ = true; |
window_->Minimize(); |
+ is_minimizing_ = false; |
} |
bool PanelStackView::IsMinimized() const { |
@@ -273,7 +286,7 @@ void PanelStackView::OnWidgetDestroying(views::Widget* widget) { |
void PanelStackView::OnWidgetActivationChanged(views::Widget* widget, |
bool active) { |
#if defined(OS_WIN) |
- if (active && thumbnailer_) |
+ if (active && !is_minimizing_ && thumbnailer_) |
thumbnailer_->Stop(); |
#endif |
} |
@@ -296,6 +309,20 @@ void PanelStackView::OnNativeFocusChange(gfx::NativeView focused_before, |
#endif |
} |
+#if defined(OS_WIN) |
+std::vector<HWND> PanelStackView::GetSnapshotWindowHandles() const { |
+ std::vector<HWND> native_panel_windows; |
+ for (Panels::const_iterator iter = panels_.begin(); |
+ iter != panels_.end(); ++iter) { |
+ Panel* panel = *iter; |
+ native_panel_windows.push_back( |
+ views::HWNDForWidget( |
+ static_cast<PanelView*>(panel->native_panel())->window())); |
+ } |
+ return native_panel_windows; |
+} |
+#endif |
+ |
void PanelStackView::AnimationEnded(const ui::Animation* animation) { |
bounds_updates_started_ = false; |
@@ -307,6 +334,10 @@ void PanelStackView::AnimationEnded(const ui::Animation* animation) { |
bounds_updates_.clear(); |
delegate_->PanelBoundsBatchUpdateCompleted(); |
+ |
+#if defined(OS_WIN) |
+ StartOrStopCustomThumbnailForMinimizePanel(); |
+#endif |
} |
void PanelStackView::AnimationProgressed(const ui::Animation* animation) { |
@@ -455,7 +486,30 @@ void PanelStackView::EnsureWindowCreated() { |
} |
#if defined(OS_WIN) |
-void PanelStackView::CaptureThumbnailForLivePreview() { |
+void PanelStackView::StartOrStopCustomThumbnailForMinimizePanel() { |
Dmitry Titov
2013/05/29 01:14:48
Is it possible to have a StartThumbnailer() and St
jianli
2013/05/29 18:31:52
All 3 places need the same code because otherwise
|
+ bool has_minimized_panel = false; |
+ for (Panels::const_iterator iter = panels_.begin(); |
+ iter != panels_.end(); ++iter) { |
+ if ((*iter)->IsMinimized()) { |
+ has_minimized_panel = true; |
+ break; |
+ } |
+ } |
+ |
+ // If custom thumbnail is still needed, stopping the thumbnailer and starting |
+ // it again will make the system use the fresh snapshot. |
+ if (thumbnailer_) |
+ thumbnailer_->Stop(); |
+ |
+ // Start the thumbnailer to capture the snapshot only when the system requests |
+ // it. When a panel has just been changed, its rendering might not be |
+ // completed at this point. So we want to delay the snapshot until the system |
+ // asks for it. |
+ if (has_minimized_panel) |
+ CaptureThumbnailForLivePreview(false); |
+} |
+ |
+void PanelStackView::CaptureThumbnailForLivePreview(bool should_capture_now) { |
// Live preview is only available since Windows 7. |
if (base::win::GetVersion() < base::win::VERSION_WIN7) |
return; |
@@ -464,19 +518,11 @@ void PanelStackView::CaptureThumbnailForLivePreview() { |
if (!thumbnailer_.get()) { |
DCHECK(native_window); |
- thumbnailer_.reset(new TaskbarWindowThumbnailerWin(native_window)); |
+ thumbnailer_.reset(new TaskbarWindowThumbnailerWin(native_window, this)); |
ui::HWNDSubclass::AddFilterToTarget(native_window, thumbnailer_.get()); |
} |
- std::vector<HWND> native_panel_windows; |
- for (Panels::const_iterator iter = panels_.begin(); |
- iter != panels_.end(); ++iter) { |
- Panel* panel = *iter; |
- native_panel_windows.push_back( |
- views::HWNDForWidget( |
- static_cast<PanelView*>(panel->native_panel())->window())); |
- } |
- thumbnailer_->Start(native_panel_windows); |
+ thumbnailer_->Start(should_capture_now); |
} |
void PanelStackView::DeferUpdateNativeWindowBounds(HDWP defer_window_pos_info, |