Commit 08751aef authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Virtual Desks: Ignored windows in mini_views shouldn't cause mini_views refreshes

This is a follow-up to CL https://crrev.com/c/1709966.

Use the new widget's init properties to mark windows ignored in
mini_views before they're added to the containers. This enables
Desks to detect that it shouldn't bother updating the mini_views
with these windows, which won't mirror there in the first place.

BUG=979434, 866622
TEST=Added a new test.

Change-Id: I8e104572a5573b6dd99110440523be1ee65806d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731671
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683258}
parent 49ea40cd
...@@ -1292,6 +1292,39 @@ TEST_F(DesksTest, NextActivatable) { ...@@ -1292,6 +1292,39 @@ TEST_F(DesksTest, NextActivatable) {
EXPECT_EQ(nullptr, window_util::GetActiveWindow()); EXPECT_EQ(nullptr, window_util::GetActiveWindow());
} }
TEST_F(DesksTest, NoMiniViewsUpdateOnOverviewEnter) {
auto* controller = DesksController::Get();
NewDesk();
ASSERT_EQ(2u, controller->desks().size());
auto* desk_1 = controller->desks()[0].get();
auto* desk_2 = controller->desks()[1].get();
auto win0 = CreateTestWindow(gfx::Rect(0, 0, 250, 100));
auto win1 = CreateTestWindow(gfx::Rect(50, 50, 200, 200));
wm::ActivateWindow(win1.get());
EXPECT_EQ(win1.get(), window_util::GetActiveWindow());
TestDeskObserver desk_1_observer;
TestDeskObserver desk_2_observer;
desk_1->AddObserver(&desk_1_observer);
desk_2->AddObserver(&desk_2_observer);
EXPECT_EQ(0, desk_1_observer.notify_counts());
EXPECT_EQ(0, desk_2_observer.notify_counts());
// The widgets created by overview mode, whose windows are added to the active
// desk's container, should never result in mini_views updates since they're
// not mirrored there at all.
auto* overview_controller = Shell::Get()->overview_controller();
overview_controller->StartOverview();
EXPECT_TRUE(overview_controller->InOverviewSession());
EXPECT_EQ(0, desk_1_observer.notify_counts());
EXPECT_EQ(0, desk_2_observer.notify_counts());
desk_1->RemoveObserver(&desk_1_observer);
desk_2->RemoveObserver(&desk_2_observer);
}
class TabletModeDesksTest : public DesksTest { class TabletModeDesksTest : public DesksTest {
public: public:
TabletModeDesksTest() = default; TabletModeDesksTest() = default;
......
...@@ -169,6 +169,7 @@ std::unique_ptr<views::Widget> CreateDropTargetWidget( ...@@ -169,6 +169,7 @@ std::unique_ptr<views::Widget> CreateDropTargetWidget(
params.accept_events = false; params.accept_events = false;
params.parent = parent; params.parent = parent;
params.bounds = bounds; params.bounds = bounds;
params.init_properties_container.SetProperty(kHideInDeskMiniViewKey, true);
auto widget = std::make_unique<views::Widget>(); auto widget = std::make_unique<views::Widget>();
widget->set_focus_on_creation(false); widget->set_focus_on_creation(false);
widget->Init(std::move(params)); widget->Init(std::move(params));
...@@ -177,7 +178,6 @@ std::unique_ptr<views::Widget> CreateDropTargetWidget( ...@@ -177,7 +178,6 @@ std::unique_ptr<views::Widget> CreateDropTargetWidget(
widget->SetContentsView(new DropTargetView( widget->SetContentsView(new DropTargetView(
dragged_window->GetProperty(ash::kTabDraggingSourceWindowKey))); dragged_window->GetProperty(ash::kTabDraggingSourceWindowKey)));
aura::Window* drop_target_window = widget->GetNativeWindow(); aura::Window* drop_target_window = widget->GetNativeWindow();
drop_target_window->SetProperty(kHideInDeskMiniViewKey, true);
drop_target_window->parent()->StackChildAtBottom(drop_target_window); drop_target_window->parent()->StackChildAtBottom(drop_target_window);
widget->Show(); widget->Show();
......
...@@ -93,11 +93,11 @@ class OverviewHighlightController::HighlightWidget : public views::Widget { ...@@ -93,11 +93,11 @@ class OverviewHighlightController::HighlightWidget : public views::Widget {
params.accept_events = false; params.accept_events = false;
params.parent = params.parent =
root_window->GetChildById(kShellWindowId_WallpaperContainer); root_window->GetChildById(kShellWindowId_WallpaperContainer);
params.init_properties_container.SetProperty(kHideInDeskMiniViewKey, true);
set_focus_on_creation(false); set_focus_on_creation(false);
Init(std::move(params)); Init(std::move(params));
aura::Window* widget_window = GetNativeWindow(); aura::Window* widget_window = GetNativeWindow();
widget_window->SetProperty(kHideInDeskMiniViewKey, true);
// Disable the "bounce in" animation when showing the window. // Disable the "bounce in" animation when showing the window.
::wm::SetWindowVisibilityAnimationTransition(widget_window, ::wm::SetWindowVisibilityAnimationTransition(widget_window,
::wm::ANIMATE_NONE); ::wm::ANIMATE_NONE);
......
...@@ -521,10 +521,9 @@ void OverviewItem::UpdateCannotSnapWarningVisibility() { ...@@ -521,10 +521,9 @@ void OverviewItem::UpdateCannotSnapWarningVisibility() {
params.message_id = IDS_ASH_SPLIT_VIEW_CANNOT_SNAP; params.message_id = IDS_ASH_SPLIT_VIEW_CANNOT_SNAP;
params.parent = params.parent =
root_window()->GetChildById(kShellWindowId_AlwaysOnTopContainer); root_window()->GetChildById(kShellWindowId_AlwaysOnTopContainer);
params.hide_in_mini_view = true;
cannot_snap_widget_ = std::make_unique<RoundedLabelWidget>(); cannot_snap_widget_ = std::make_unique<RoundedLabelWidget>();
cannot_snap_widget_->Init(std::move(params)); cannot_snap_widget_->Init(std::move(params));
auto* widget_window = cannot_snap_widget_->GetNativeWindow();
widget_window->SetProperty(kHideInDeskMiniViewKey, true);
} }
DoSplitviewOpacityAnimation(cannot_snap_widget_->GetNativeWindow()->layer(), DoSplitviewOpacityAnimation(cannot_snap_widget_->GetNativeWindow()->layer(),
...@@ -973,13 +972,13 @@ void OverviewItem::CreateWindowLabel() { ...@@ -973,13 +972,13 @@ void OverviewItem::CreateWindowLabel() {
views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT;
params.accept_events = true; params.accept_events = true;
params.parent = transform_window_.window()->parent(); params.parent = transform_window_.window()->parent();
params.init_properties_container.SetProperty(kHideInDeskMiniViewKey, true);
item_widget_ = std::make_unique<views::Widget>(); item_widget_ = std::make_unique<views::Widget>();
item_widget_->set_focus_on_creation(false); item_widget_->set_focus_on_creation(false);
item_widget_->Init(std::move(params)); item_widget_->Init(std::move(params));
aura::Window* widget_window = item_widget_->GetNativeWindow(); aura::Window* widget_window = item_widget_->GetNativeWindow();
widget_window->parent()->StackChildBelow(widget_window, GetWindow()); widget_window->parent()->StackChildBelow(widget_window, GetWindow());
widget_window->SetProperty(kHideInDeskMiniViewKey, true);
shadow_ = std::make_unique<ui::Shadow>(); shadow_ = std::make_unique<ui::Shadow>();
shadow_->Init(kShadowElevation); shadow_->Init(kShadowElevation);
......
...@@ -1025,11 +1025,11 @@ void OverviewSession::UpdateNoWindowsWidget() { ...@@ -1025,11 +1025,11 @@ void OverviewSession::UpdateNoWindowsWidget() {
params.message_id = IDS_ASH_OVERVIEW_NO_RECENT_ITEMS; params.message_id = IDS_ASH_OVERVIEW_NO_RECENT_ITEMS;
params.parent = Shell::GetPrimaryRootWindow()->GetChildById( params.parent = Shell::GetPrimaryRootWindow()->GetChildById(
desks_util::GetActiveDeskContainerId()); desks_util::GetActiveDeskContainerId());
params.hide_in_mini_view = true;
no_windows_widget_ = std::make_unique<RoundedLabelWidget>(); no_windows_widget_ = std::make_unique<RoundedLabelWidget>();
no_windows_widget_->Init(std::move(params)); no_windows_widget_->Init(std::move(params));
aura::Window* widget_window = no_windows_widget_->GetNativeWindow(); aura::Window* widget_window = no_windows_widget_->GetNativeWindow();
widget_window->SetProperty(kHideInDeskMiniViewKey, true);
widget_window->parent()->StackChildAtBottom(widget_window); widget_window->parent()->StackChildAtBottom(widget_window);
ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_NO_RECENTS_FADE, ScopedOverviewAnimationSettings settings(OVERVIEW_ANIMATION_NO_RECENTS_FADE,
widget_window); widget_window);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/overview/scoped_overview_animation_settings.h" #include "ash/wm/overview/scoped_overview_animation_settings.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -71,11 +72,13 @@ class RoundedLabelView : public views::View { ...@@ -71,11 +72,13 @@ class RoundedLabelView : public views::View {
RoundedLabelWidget::InitParams::InitParams() = default; RoundedLabelWidget::InitParams::InitParams() = default;
RoundedLabelWidget::InitParams::InitParams(InitParams&& other) = default;
RoundedLabelWidget::RoundedLabelWidget() = default; RoundedLabelWidget::RoundedLabelWidget() = default;
RoundedLabelWidget::~RoundedLabelWidget() = default; RoundedLabelWidget::~RoundedLabelWidget() = default;
void RoundedLabelWidget::Init(const InitParams& params) { void RoundedLabelWidget::Init(InitParams params) {
views::Widget::InitParams widget_params; views::Widget::InitParams widget_params;
widget_params.name = params.name; widget_params.name = params.name;
widget_params.type = views::Widget::InitParams::TYPE_POPUP; widget_params.type = views::Widget::InitParams::TYPE_POPUP;
...@@ -86,6 +89,10 @@ void RoundedLabelWidget::Init(const InitParams& params) { ...@@ -86,6 +89,10 @@ void RoundedLabelWidget::Init(const InitParams& params) {
widget_params.accept_events = false; widget_params.accept_events = false;
widget_params.parent = params.parent; widget_params.parent = params.parent;
set_focus_on_creation(false); set_focus_on_creation(false);
if (params.hide_in_mini_view) {
widget_params.init_properties_container.SetProperty(kHideInDeskMiniViewKey,
true);
}
views::Widget::Init(std::move(widget_params)); views::Widget::Init(std::move(widget_params));
SetContentsView(new RoundedLabelView( SetContentsView(new RoundedLabelView(
......
...@@ -21,6 +21,8 @@ class RoundedLabelWidget : public views::Widget { ...@@ -21,6 +21,8 @@ class RoundedLabelWidget : public views::Widget {
// Params to modify the look of the label. // Params to modify the look of the label.
struct InitParams { struct InitParams {
InitParams(); InitParams();
InitParams(InitParams&& other);
std::string name; std::string name;
int horizontal_padding; int horizontal_padding;
int vertical_padding; int vertical_padding;
...@@ -30,12 +32,13 @@ class RoundedLabelWidget : public views::Widget { ...@@ -30,12 +32,13 @@ class RoundedLabelWidget : public views::Widget {
int preferred_height; int preferred_height;
int message_id; int message_id;
aura::Window* parent; aura::Window* parent;
bool hide_in_mini_view;
}; };
RoundedLabelWidget(); RoundedLabelWidget();
~RoundedLabelWidget() override; ~RoundedLabelWidget() override;
void Init(const InitParams& params); void Init(InitParams params);
// Gets the preferred size of the widget centered in |bounds|. // Gets the preferred size of the widget centered in |bounds|.
gfx::Rect GetBoundsCenteredIn(const gfx::Rect& bounds); gfx::Rect GetBoundsCenteredIn(const gfx::Rect& bounds);
......
...@@ -443,11 +443,10 @@ void SplitViewDivider::CreateDividerWidget(aura::Window* root_window) { ...@@ -443,11 +443,10 @@ void SplitViewDivider::CreateDividerWidget(aura::Window* root_window) {
params.activatable = views::Widget::InitParams::ACTIVATABLE_NO; params.activatable = views::Widget::InitParams::ACTIVATABLE_NO;
params.parent = params.parent =
Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer);
params.init_properties_container.SetProperty(kHideInDeskMiniViewKey, true);
DividerView* divider_view = new DividerView(this); DividerView* divider_view = new DividerView(this);
divider_widget_->set_focus_on_creation(false); divider_widget_->set_focus_on_creation(false);
divider_widget_->Init(std::move(params)); divider_widget_->Init(std::move(params));
aura::Window* widget_window = divider_widget_->GetNativeWindow();
widget_window->SetProperty(kHideInDeskMiniViewKey, true);
divider_widget_->SetVisibilityAnimationTransition( divider_widget_->SetVisibilityAnimationTransition(
views::Widget::ANIMATE_NONE); views::Widget::ANIMATE_NONE);
divider_widget_->SetContentsView(divider_view); divider_widget_->SetContentsView(divider_view);
......
...@@ -690,15 +690,16 @@ void StatusBubbleViews::InitPopup() { ...@@ -690,15 +690,16 @@ void StatusBubbleViews::InitPopup() {
params.parent = frame->GetNativeView(); params.parent = frame->GetNativeView();
params.context = frame->GetNativeWindow(); params.context = frame->GetNativeWindow();
params.name = "StatusBubble"; params.name = "StatusBubble";
#if defined(OS_CHROMEOS)
params.init_properties_container.SetProperty(ash::kHideInOverviewKey, true);
params.init_properties_container.SetProperty(ash::kHideInDeskMiniViewKey,
true);
#endif // defined(OS_CHROMEOS)
popup_->Init(std::move(params)); popup_->Init(std::move(params));
// We do our own animation and don't want any from the system. // We do our own animation and don't want any from the system.
popup_->SetVisibilityChangedAnimationsEnabled(false); popup_->SetVisibilityChangedAnimationsEnabled(false);
popup_->SetOpacity(0.f); popup_->SetOpacity(0.f);
popup_->SetContentsView(view_); popup_->SetContentsView(view_);
#if defined(OS_CHROMEOS)
popup_->GetNativeWindow()->SetProperty(ash::kHideInOverviewKey, true);
popup_->GetNativeWindow()->SetProperty(ash::kHideInDeskMiniViewKey, true);
#endif
RepositionPopup(); RepositionPopup();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment