Skip to content

Commit

Permalink
[ash-md] Makes sure that minimized windows can be activated in overview
Browse files Browse the repository at this point in the history
When windows are minimized before entering overview mode, they are
replaced with a widget that has mirrored layers. Opacity of the original
window needs to be then set to 1 in order to make it visible
(in WindowMirrorView::InitLayerOwner()).
Upon exiting overview the original window's opacity is restored.
This logic breaks if a window is selected - the opacity need not be
restored (to zero).
Make it so that the opacity is set to 1 upon exit if a window is
selected.

BUG=677177

Review-Url: https://codereview.chromium.org/2637403013
Cr-Commit-Position: refs/heads/master@{#445524}
  • Loading branch information
varkha authored and Commit bot committed Jan 23, 2017
1 parent 4d9f1c2 commit 8f64e92
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ash/common/wm/overview/scoped_transform_overview_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -446,15 +446,21 @@ WmWindow* ScopedTransformOverviewWindow::GetOverviewWindow() const {
return window_;
}

void ScopedTransformOverviewWindow::EnsureVisible() {
original_opacity_ = 1.f;
}

void ScopedTransformOverviewWindow::OnGestureEvent(ui::GestureEvent* event) {
if (event->type() == ui::ET_GESTURE_TAP) {
EnsureVisible();
window_->Show();
window_->Activate();
}
}

void ScopedTransformOverviewWindow::OnMouseEvent(ui::MouseEvent* event) {
if (event->type() == ui::ET_MOUSE_PRESSED && event->IsOnlyLeftMouseButton()) {
EnsureVisible();
window_->Show();
window_->Activate();
}
Expand Down
3 changes: 3 additions & 0 deletions ash/common/wm/overview/scoped_transform_overview_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ class ASH_EXPORT ScopedTransformOverviewWindow : public ui::EventHandler {
// For minmiezd window, this will be a window that hosts mirrored layers.
WmWindow* GetOverviewWindow() const;

// Ensures that a window is visible by setting its opacity to 1.
void EnsureVisible();

// Returns the window created for minimized window, or nullptr
// if it does not exit.
WmWindow* GetOverviewWindowForMinimizedState() const;
Expand Down
8 changes: 4 additions & 4 deletions ash/common/wm/overview/window_selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ void WindowSelector::OnGridEmpty(WindowGrid* grid) {
CancelSelection();
}

void WindowSelector::SelectWindow(WmWindow* window) {
void WindowSelector::SelectWindow(WindowSelectorItem* item) {
WmWindow* window = item->GetWindow();
std::vector<WmWindow*> window_list =
WmShell::Get()->mru_window_tracker()->BuildMruWindowList();
if (!window_list.empty()) {
Expand All @@ -425,7 +426,7 @@ void WindowSelector::SelectWindow(WmWindow* window) {
1 + it - window_list.begin());
}
}

item->EnsureVisible();
window->GetWindowState()->Activate();
}

Expand Down Expand Up @@ -481,8 +482,7 @@ bool WindowSelector::HandleKeyEvent(views::Textfield* sender,
(num_key_presses_ * 100) / num_items_, 1, 300,
30);
WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_ENTER_KEY);
SelectWindow(
grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow());
SelectWindow(grid_list_[selected_grid_index_]->SelectedWindow());
break;
default:
// Not a key we are interested in, allow the textfield to handle it.
Expand Down
4 changes: 2 additions & 2 deletions ash/common/wm/overview/window_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class ASH_EXPORT WindowSelector : public display::DisplayObserver,
// Called when the last window selector item from a grid is deleted.
void OnGridEmpty(WindowGrid* grid);

// Activates |window|.
void SelectWindow(WmWindow* window);
// Activates |item's| window.
void SelectWindow(WindowSelectorItem* item);

// Called when |window| is about to get closed.
void WindowClosing(WindowSelectorItem* window);
Expand Down
6 changes: 5 additions & 1 deletion ash/common/wm/overview/window_selector_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ void WindowSelectorItem::RestoreWindow() {
OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
}

void WindowSelectorItem::EnsureVisible() {
transform_window_.EnsureVisible();
}

void WindowSelectorItem::Shutdown() {
if (transform_window_.GetTopInset()) {
// Activating a window (even when it is the window that was active before
Expand Down Expand Up @@ -555,7 +559,7 @@ void WindowSelectorItem::ButtonPressed(views::Button* sender,
return;
}
CHECK(sender == caption_container_view_->listener_button());
window_selector_->SelectWindow(transform_window_.window());
window_selector_->SelectWindow(this);
}

void WindowSelectorItem::OnWindowDestroying(WmWindow* window) {
Expand Down
3 changes: 3 additions & 0 deletions ash/common/wm/overview/window_selector_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
// Restores and animates the managed window to its non overview mode state.
void RestoreWindow();

// Ensures that a possibly minimized window becomes visible after restore.
void EnsureVisible();

// Restores stacking of window captions above the windows, then fades out.
void Shutdown();

Expand Down
3 changes: 3 additions & 0 deletions ash/wm/overview/window_selector_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,14 @@ TEST_F(WindowSelectorTest, ActivateMinimized) {
wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE);
window_state->OnWMEvent(&minimize_event);
EXPECT_FALSE(window->IsVisible());
EXPECT_EQ(0.f, window->layer()->GetTargetOpacity());
EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED,
wm::GetWindowState(window.get())->GetStateType());

ToggleOverview();

EXPECT_FALSE(window->IsVisible());
EXPECT_EQ(0.f, window->layer()->GetTargetOpacity());
EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED,
wm::GetWindowState(window.get())->GetStateType());
aura::Window* window_for_minimized_window =
Expand All @@ -490,6 +492,7 @@ TEST_F(WindowSelectorTest, ActivateMinimized) {
EXPECT_FALSE(IsSelecting());

EXPECT_TRUE(window->IsVisible());
EXPECT_EQ(1.f, window->layer()->GetTargetOpacity());
EXPECT_EQ(wm::WINDOW_STATE_TYPE_NORMAL,
wm::GetWindowState(window.get())->GetStateType());
}
Expand Down

0 comments on commit 8f64e92

Please sign in to comment.