Commit dfce7c74 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Allow updating frame colors after surface is enabled.

BUG=b/33693796
TEST=covered by unittest

Change-Id: Ie48bb6e93c3e591fd749b996bd8294f87def0ec6
Reviewed-on: https://chromium-review.googlesource.com/990082Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547505}
parent 82a48793
...@@ -721,10 +721,15 @@ void ShellSurfaceBase::OnSetFrame(SurfaceFrameType type) { ...@@ -721,10 +721,15 @@ void ShellSurfaceBase::OnSetFrame(SurfaceFrameType type) {
void ShellSurfaceBase::OnSetFrameColors(SkColor active_color, void ShellSurfaceBase::OnSetFrameColors(SkColor active_color,
SkColor inactive_color) { SkColor inactive_color) {
// TODO(reveman): Allow frame colors to change after surface has been enabled.
has_frame_colors_ = true; has_frame_colors_ = true;
active_frame_color_ = active_color; active_frame_color_ = SkColorSetA(active_color, SK_AlphaOPAQUE);
inactive_frame_color_ = inactive_color; inactive_frame_color_ = SkColorSetA(inactive_color, SK_AlphaOPAQUE);
if (widget_) {
widget_->GetNativeWindow()->SetProperty(ash::kFrameActiveColorKey,
active_frame_color_);
widget_->GetNativeWindow()->SetProperty(ash::kFrameInactiveColorKey,
inactive_frame_color_);
}
} }
void ShellSurfaceBase::OnSetParent(Surface* parent, void ShellSurfaceBase::OnSetParent(Surface* parent,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/exo/shell_surface.h" #include "components/exo/shell_surface.h"
#include "ash/accessibility/accessibility_delegate.h" #include "ash/accessibility/accessibility_delegate.h"
#include "ash/frame/custom_frame_view_ash.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/shell_port.h" #include "ash/shell_port.h"
...@@ -476,5 +477,29 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) { ...@@ -476,5 +477,29 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) {
shell_surface->GetWidget()->GetWindowBoundsInScreen().width()); shell_surface->GetWidget()->GetWindowBoundsInScreen().width());
} }
TEST_F(ShellSurfaceTest, FrameColors) {
std::unique_ptr<Surface> surface(new Surface);
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
surface->Attach(buffer.get());
std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
shell_surface->OnSetFrameColors(SK_ColorRED, SK_ColorTRANSPARENT);
surface->Commit();
const ash::CustomFrameViewAsh* frame =
static_cast<const ash::CustomFrameViewAsh*>(
shell_surface->GetWidget()->non_client_view()->frame_view());
// Test if colors set before initial commit are set.
EXPECT_EQ(SK_ColorRED, frame->GetActiveFrameColorForTest());
// Frame should be fully opaque.
EXPECT_EQ(SK_ColorBLACK, frame->GetInactiveFrameColorForTest());
shell_surface->OnSetFrameColors(SK_ColorTRANSPARENT, SK_ColorBLUE);
EXPECT_EQ(SK_ColorBLACK, frame->GetActiveFrameColorForTest());
EXPECT_EQ(SK_ColorBLUE, frame->GetInactiveFrameColorForTest());
}
} // namespace } // namespace
} // namespace exo } // namespace exo
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