Skip to content

Commit

Permalink
Don't show the shadow for maximized/fullscreen window
Browse files Browse the repository at this point in the history
BUG=407966
TEST=covered by unit test.

Review URL: https://codereview.chromium.org/778283002

Cr-Commit-Position: refs/heads/master@{#309272}
  • Loading branch information
mitoshima authored and Commit bot committed Dec 19, 2014
1 parent 0384af3 commit deecdaf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/wm/core/shadow_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#include "base/logging.h"
#include "base/memory/linked_ptr.h"
#include "base/scoped_observer.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/wm/core/shadow.h"
#include "ui/wm/core/shadow_types.h"
Expand Down Expand Up @@ -169,7 +171,7 @@ void ShadowController::Impl::OnWindowInitialized(aura::Window* window) {
void ShadowController::Impl::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
if (key == kShadowTypeKey) {
if (key == kShadowTypeKey || key == aura::client::kShowStateKey) {
HandlePossibleShadowVisibilityChange(window);
return;
}
Expand Down Expand Up @@ -207,6 +209,13 @@ void ShadowController::Impl::OnWindowActivated(aura::Window* gained_active,

bool ShadowController::Impl::ShouldShowShadowForWindow(
aura::Window* window) const {
ui::WindowShowState show_state =
window->GetProperty(aura::client::kShowStateKey);
if (show_state == ui::SHOW_STATE_FULLSCREEN ||
show_state == ui::SHOW_STATE_MAXIMIZED) {
return SHADOW_TYPE_NONE;
}

const ShadowType type = GetShadowType(window);
switch (type) {
case SHADOW_TYPE_NONE:
Expand Down
25 changes: 25 additions & 0 deletions ui/wm/core/shadow_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <vector>

#include "base/memory/scoped_ptr.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/window_tree_client.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -154,6 +155,30 @@ TEST_F(ShadowControllerTest, ShadowStyle) {
EXPECT_EQ(Shadow::STYLE_ACTIVE, shadow2->style());
}

// Tests that shadow gets updated when the window show state chagnes.
TEST_F(ShadowControllerTest, ShowState) {
ShadowController::TestApi api(shadow_controller());

scoped_ptr<aura::Window> window(new aura::Window(NULL));
window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
window->Init(aura::WINDOW_LAYER_TEXTURED);
ParentWindow(window.get());
window->Show();

Shadow* shadow = api.GetShadowForWindow(window.get());
ASSERT_TRUE(shadow != NULL);
EXPECT_EQ(Shadow::STYLE_INACTIVE, shadow->style());

window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
EXPECT_FALSE(shadow->layer()->visible());

window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
EXPECT_TRUE(shadow->layer()->visible());

window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
EXPECT_FALSE(shadow->layer()->visible());
}

// Tests that we use smaller shadows for tooltips and menus.
TEST_F(ShadowControllerTest, SmallShadowsForTooltipsAndMenus) {
ShadowController::TestApi api(shadow_controller());
Expand Down

0 comments on commit deecdaf

Please sign in to comment.