Commit 858c8cd1 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Use WideFrameView if the maximized/fullscreen task didn't cover work area

This depends on crrev.com/990203.

UI spec: page 10 in
https://docs.google.com/presentation/d/1Kp8trbUeYH8W04pX14WHi99u7_QdSIx7QpuaH3idCeg/edit?usp=sharing

Screenshot:
https://drive.google.com/file/d/19AvhiZCyinocnfpoaa5HxEo3m1kSJ6d2/view?usp=sharing

This also change UpdateAutoHideFrame to check if it's maximized/fullscren or pinned
so that autohide happens when the state switched to maximized.

I also fixed TestClientControlledStateDelegate::HandleBoundsRequest. It should commit only if
it has something to commit.

BUG=b/33693796
TEST=manual. covered by unittest.

Change-Id: I0ac1b9a57112c0e7d86745f990fa16ab1c7d7945
Reviewed-on: https://chromium-review.googlesource.com/1009205Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550499}
parent 84cb067c
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "ash/frame/caption_buttons/caption_button_model.h" #include "ash/frame/caption_buttons/caption_button_model.h"
#include "ash/frame/custom_frame_view_ash.h" #include "ash/frame/custom_frame_view_ash.h"
#include "ash/frame/wide_frame_view.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller.h" #include "ash/public/cpp/immersive/immersive_fullscreen_controller.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
...@@ -265,6 +266,9 @@ ClientControlledShellSurface::ClientControlledShellSurface(Surface* surface, ...@@ -265,6 +266,9 @@ ClientControlledShellSurface::ClientControlledShellSurface(Surface* surface,
} }
ClientControlledShellSurface::~ClientControlledShellSurface() { ClientControlledShellSurface::~ClientControlledShellSurface() {
if (wide_frame_)
wide_frame_->Close();
WMHelper::GetInstance()->RemoveDisplayConfigurationObserver(this); WMHelper::GetInstance()->RemoveDisplayConfigurationObserver(this);
display::Screen::GetScreen()->RemoveObserver(this); display::Screen::GetScreen()->RemoveObserver(this);
} }
...@@ -429,7 +433,8 @@ void ClientControlledShellSurface::SetCanMaximize(bool can_maximize) { ...@@ -429,7 +433,8 @@ void ClientControlledShellSurface::SetCanMaximize(bool can_maximize) {
void ClientControlledShellSurface::UpdateAutoHideFrame() { void ClientControlledShellSurface::UpdateAutoHideFrame() {
if (immersive_fullscreen_controller_) { if (immersive_fullscreen_controller_) {
bool enabled = frame_type_ == SurfaceFrameType::AUTOHIDE; bool enabled = (frame_type_ == SurfaceFrameType::AUTOHIDE &&
GetWindowState()->IsMaximizedOrFullscreenOrPinned());
immersive_fullscreen_controller_->SetEnabled( immersive_fullscreen_controller_->SetEnabled(
ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enabled); ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enabled);
} }
...@@ -445,10 +450,8 @@ void ClientControlledShellSurface::SetFrameButtons( ...@@ -445,10 +450,8 @@ void ClientControlledShellSurface::SetFrameButtons(
frame_visible_button_mask_ = visible_button_mask; frame_visible_button_mask_ = visible_button_mask;
frame_enabled_button_mask_ = enabled_button_mask; frame_enabled_button_mask_ = enabled_button_mask;
if (widget_) { if (widget_)
GetFrameView()->SetCaptionButtonModel(std::make_unique<CaptionButtonModel>( UpdateCaptionButtonModel();
visible_button_mask, enabled_button_mask));
}
} }
void ClientControlledShellSurface::SetExtraTitle( void ClientControlledShellSurface::SetExtraTitle(
...@@ -533,7 +536,7 @@ void ClientControlledShellSurface::OnSurfaceCommit() { ...@@ -533,7 +536,7 @@ void ClientControlledShellSurface::OnSurfaceCommit() {
} }
ShellSurfaceBase::OnSurfaceCommit(); ShellSurfaceBase::OnSurfaceCommit();
UpdateFrame();
UpdateBackdrop(); UpdateBackdrop();
if (!geometry_changed_callback_.is_null()) if (!geometry_changed_callback_.is_null())
...@@ -578,6 +581,16 @@ void ClientControlledShellSurface::OnSetFrame(SurfaceFrameType type) { ...@@ -578,6 +581,16 @@ void ClientControlledShellSurface::OnSetFrame(SurfaceFrameType type) {
UpdateAutoHideFrame(); UpdateAutoHideFrame();
} }
void ClientControlledShellSurface::OnSetFrameColors(SkColor active_color,
SkColor inactive_color) {
ShellSurfaceBase::OnSetFrameColors(active_color, inactive_color);
if (wide_frame_) {
aura::Window* window = wide_frame_->GetWidget()->GetNativeWindow();
window->SetProperty(ash::kFrameActiveColorKey, active_color);
window->SetProperty(ash::kFrameInactiveColorKey, inactive_color);
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// aura::WindowObserver overrides: // aura::WindowObserver overrides:
void ClientControlledShellSurface::OnWindowBoundsChanged( void ClientControlledShellSurface::OnWindowBoundsChanged(
...@@ -882,6 +895,51 @@ gfx::Point ClientControlledShellSurface::GetSurfaceOrigin() const { ...@@ -882,6 +895,51 @@ gfx::Point ClientControlledShellSurface::GetSurfaceOrigin() const {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// ClientControlledShellSurface, private: // ClientControlledShellSurface, private:
void ClientControlledShellSurface::UpdateFrame() {
if (!widget_ || !GetFrameView()->visible())
return;
gfx::Rect work_area =
display::Screen::GetScreen()
->GetDisplayNearestWindow(widget_->GetNativeWindow())
.work_area();
ash::wm::WindowState* window_state = GetWindowState();
if (window_state->IsMaximizedOrFullscreenOrPinned() &&
work_area.width() != geometry().width()) {
if (!wide_frame_) {
wide_frame_ = ash::WideFrameView::Create(widget_);
immersive_fullscreen_controller_->SetEnabled(
ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, false);
wide_frame_->Init(immersive_fullscreen_controller_.get());
wide_frame_->Show();
UpdateCaptionButtonModel();
}
} else {
if (wide_frame_) {
wide_frame_->Close();
wide_frame_ = nullptr;
immersive_fullscreen_controller_->SetEnabled(
ash::ImmersiveFullscreenController::WINDOW_TYPE_OTHER, false);
GetFrameView()->InitImmersiveFullscreenControllerForView(
immersive_fullscreen_controller_.get());
UpdateCaptionButtonModel();
}
}
// The autohide should be applied when the window state is in
// maximzied, fullscreen or pinned. Update the auto hide state
// inside commit.
UpdateAutoHideFrame();
}
void ClientControlledShellSurface::UpdateCaptionButtonModel() {
auto model = std::make_unique<CaptionButtonModel>(frame_visible_button_mask_,
frame_enabled_button_mask_);
if (wide_frame_)
wide_frame_->SetCaptionButtonModel(std::move(model));
else
GetFrameView()->SetCaptionButtonModel(std::move(model));
}
void ClientControlledShellSurface::UpdateBackdrop() { void ClientControlledShellSurface::UpdateBackdrop() {
aura::Window* window = widget_->GetNativeWindow(); aura::Window* window = widget_->GetNativeWindow();
const display::Display display = const display::Display display =
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
namespace ash { namespace ash {
class CustomFrameViewAsh; class CustomFrameViewAsh;
class ImmersiveFullscreenController; class ImmersiveFullscreenController;
class WideFrameView;
namespace mojom { namespace mojom {
enum class WindowPinType; enum class WindowPinType;
...@@ -174,6 +175,7 @@ class ClientControlledShellSurface ...@@ -174,6 +175,7 @@ class ClientControlledShellSurface
void OnSurfaceCommit() override; void OnSurfaceCommit() override;
bool IsInputEnabled(Surface* surface) const override; bool IsInputEnabled(Surface* surface) const override;
void OnSetFrame(SurfaceFrameType type) override; void OnSetFrame(SurfaceFrameType type) override;
void OnSetFrameColors(SkColor active_color, SkColor inactive_color) override;
// Overridden from views::WidgetDelegate: // Overridden from views::WidgetDelegate:
bool CanMaximize() const override; bool CanMaximize() const override;
...@@ -214,6 +216,8 @@ class ClientControlledShellSurface ...@@ -214,6 +216,8 @@ class ClientControlledShellSurface
static void SetClientControlledStateDelegateFactoryForTest( static void SetClientControlledStateDelegateFactoryForTest(
const DelegateFactoryCallback& callback); const DelegateFactoryCallback& callback);
ash::WideFrameView* wide_frame_for_test() { return wide_frame_; }
private: private:
class ScopedSetBoundsLocally; class ScopedSetBoundsLocally;
class ScopedLockedToRoot; class ScopedLockedToRoot;
...@@ -231,6 +235,13 @@ class ClientControlledShellSurface ...@@ -231,6 +235,13 @@ class ClientControlledShellSurface
gfx::Rect GetWidgetBounds() const override; gfx::Rect GetWidgetBounds() const override;
gfx::Point GetSurfaceOrigin() const override; gfx::Point GetSurfaceOrigin() const override;
// Update frame status. This may create (or destroy) a wide frame
// that spans the full work area width if the surface didn't cover
// the work area.
void UpdateFrame();
void UpdateCaptionButtonModel();
void UpdateBackdrop(); void UpdateBackdrop();
void AttemptToStartDrag(int component, const gfx::Point& location); void AttemptToStartDrag(int component, const gfx::Point& location);
...@@ -278,6 +289,8 @@ class ClientControlledShellSurface ...@@ -278,6 +289,8 @@ class ClientControlledShellSurface
std::unique_ptr<ash::ImmersiveFullscreenController> std::unique_ptr<ash::ImmersiveFullscreenController>
immersive_fullscreen_controller_; immersive_fullscreen_controller_;
ash::WideFrameView* wide_frame_ = nullptr;
std::unique_ptr<ui::CompositorLock> orientation_compositor_lock_; std::unique_ptr<ui::CompositorLock> orientation_compositor_lock_;
DISALLOW_COPY_AND_ASSIGN(ClientControlledShellSurface); DISALLOW_COPY_AND_ASSIGN(ClientControlledShellSurface);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h" #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/custom_frame_view_ash.h" #include "ash/frame/custom_frame_view_ash.h"
#include "ash/frame/header_view.h" #include "ash/frame/header_view.h"
#include "ash/frame/wide_frame_view.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "ash/public/interfaces/window_pin_type.mojom.h" #include "ash/public/interfaces/window_pin_type.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -1066,4 +1067,35 @@ TEST_F(ClientControlledShellSurfaceTest, SetExtraTitle) { ...@@ -1066,4 +1067,35 @@ TEST_F(ClientControlledShellSurfaceTest, SetExtraTitle) {
shell_surface->GetWindowTitle()); shell_surface->GetWindowTitle());
} }
TEST_F(ClientControlledShellSurfaceTest, WideFrame) {
std::unique_ptr<Surface> surface(new Surface);
auto shell_surface =
exo_test_helper()->CreateClientControlledShellSurface(surface.get());
std::unique_ptr<Buffer> desktop_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(gfx::Size(64, 64))));
surface->Attach(desktop_buffer.get());
shell_surface->SetGeometry(gfx::Rect(0, 0, 64, 64));
shell_surface->SetMaximized();
surface->SetFrame(SurfaceFrameType::NORMAL);
surface->Commit();
auto* wide_frame = shell_surface->wide_frame_for_test();
ASSERT_TRUE(wide_frame);
EXPECT_FALSE(wide_frame->header_view()->in_immersive_mode());
// Set AutoHide mode.
surface->SetFrame(SurfaceFrameType::AUTOHIDE);
EXPECT_TRUE(wide_frame->header_view()->in_immersive_mode());
// Exit AutoHide mode.
surface->SetFrame(SurfaceFrameType::NORMAL);
EXPECT_FALSE(wide_frame->header_view()->in_immersive_mode());
// Unmaximize it and the frame should be normal.
shell_surface->SetRestored();
surface->Commit();
EXPECT_FALSE(shell_surface->wide_frame_for_test());
}
} // namespace exo } // namespace exo
...@@ -752,7 +752,6 @@ void ShellSurfaceBase::OnSetFrame(SurfaceFrameType frame_type) { ...@@ -752,7 +752,6 @@ void ShellSurfaceBase::OnSetFrame(SurfaceFrameType frame_type) {
shadow_bounds_ = gfx::Rect(); shadow_bounds_ = gfx::Rect();
break; break;
} }
frame_type_ = frame_type;
if (!widget_) if (!widget_)
return; return;
CustomFrameView* frame_view = CustomFrameView* frame_view =
......
...@@ -68,8 +68,8 @@ void TestClientControlledStateDelegate::HandleBoundsRequest( ...@@ -68,8 +68,8 @@ void TestClientControlledStateDelegate::HandleBoundsRequest(
shell_surface->SetSnappedToLeft(); shell_surface->SetSnappedToLeft();
else else
shell_surface->SetSnappedToRight(); shell_surface->SetSnappedToRight();
shell_surface->OnSurfaceCommit();
} }
shell_surface->OnSurfaceCommit();
} }
// static // static
......
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