Skip to content

Commit

Permalink
chromeos: converts WindowState to aura::Window
Browse files Browse the repository at this point in the history
BUG=722553
TEST=covered by tests
R=msw@chromium.org

Review-Url: https://codereview.chromium.org/2901663003
Cr-Commit-Position: refs/heads/master@{#473992}
  • Loading branch information
sky authored and Commit bot committed May 23, 2017
1 parent 02950ed commit fd5eef9
Show file tree
Hide file tree
Showing 30 changed files with 415 additions and 454 deletions.
18 changes: 13 additions & 5 deletions ash/frame/custom_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
// TODO(pkotwicz): This is a hack. Remove ASAP. http://crbug.com/319048
window_state_ = window_state;
window_state_->AddObserver(this);
window_state_->window()->aura_window()->AddObserver(this);
window_state_->window()->AddObserver(this);

if (!enable_immersive)
return;
Expand All @@ -68,18 +68,20 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
~CustomFrameViewAshWindowStateDelegate() override {
if (window_state_) {
window_state_->RemoveObserver(this);
window_state_->window()->aura_window()->RemoveObserver(this);
window_state_->window()->RemoveObserver(this);
}
}

private:
// Overridden from wm::WindowStateDelegate:
bool ToggleFullscreen(wm::WindowState* window_state) override {
bool enter_fullscreen = !window_state->IsFullscreen();
if (enter_fullscreen)
window_state_->window()->SetShowState(ui::SHOW_STATE_FULLSCREEN);
else
if (enter_fullscreen) {
window_state_->window()->SetProperty(aura::client::kShowStateKey,
ui::SHOW_STATE_FULLSCREEN);
} else {
window_state->Restore();
}
if (immersive_fullscreen_controller_) {
immersive_fullscreen_controller_->SetEnabled(
ImmersiveFullscreenController::WINDOW_TYPE_OTHER, enter_fullscreen);
Expand Down Expand Up @@ -112,6 +114,9 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,

} // namespace

// static
bool CustomFrameViewAsh::use_empty_minimum_size_for_test_ = false;

///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::OverlayView

Expand Down Expand Up @@ -319,6 +324,9 @@ const char* CustomFrameViewAsh::GetClassName() const {
}

gfx::Size CustomFrameViewAsh::GetMinimumSize() const {
if (use_empty_minimum_size_for_test_)
return gfx::Size();

gfx::Size min_client_view_size(frame_->client_view()->GetMinimumSize());
return gfx::Size(
std::max(header_view_->GetMinimumWidth(), min_client_view_size.width()),
Expand Down
3 changes: 3 additions & 0 deletions ash/frame/custom_frame_view_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView {
private:
class OverlayView;
friend class TestWidgetConstraintsDelegate;
friend class CustomFrameViewAshSizeLock;

// views::NonClientFrameView:
bool DoesIntersectRect(const views::View* target,
Expand All @@ -117,6 +118,8 @@ class ASH_EXPORT CustomFrameViewAsh : public views::NonClientFrameView {

ImmersiveFullscreenControllerDelegate* immersive_delegate_;

static bool use_empty_minimum_size_for_test_;

DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAsh);
};

Expand Down
10 changes: 7 additions & 3 deletions ash/mus/non_client_frame_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ash/shared/immersive_fullscreen_controller_delegate.h"
#include "ash/wm/panels/panel_frame_view.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ash/wm_window.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
Expand Down Expand Up @@ -387,15 +388,18 @@ base::string16 NonClientFrameController::GetWindowTitle() const {
}

bool NonClientFrameController::CanResize() const {
return window_ && WmWindow::Get(window_)->CanResize();
return window_ && (window_->GetProperty(aura::client::kResizeBehaviorKey) &
ui::mojom::kResizeBehaviorCanResize) != 0;
}

bool NonClientFrameController::CanMaximize() const {
return window_ && WmWindow::Get(window_)->CanMaximize();
return window_ && (window_->GetProperty(aura::client::kResizeBehaviorKey) &
ui::mojom::kResizeBehaviorCanMaximize) != 0;
}

bool NonClientFrameController::CanMinimize() const {
return window_ && WmWindow::Get(window_)->CanMinimize();
return window_ && (window_->GetProperty(aura::client::kResizeBehaviorKey) &
ui::mojom::kResizeBehaviorCanMinimize) != 0;
}

bool NonClientFrameController::ShouldShowWindowTitle() const {
Expand Down
2 changes: 1 addition & 1 deletion ash/root_window_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void ReparentWindow(aura::Window* window, aura::Window* new_parent) {

gfx::Rect local_bounds;
if (update_bounds) {
local_bounds = state->window()->GetBounds();
local_bounds = state->window()->bounds();
MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
local_bounds.AdjustToFit(work_area_in_new_parent);
}
Expand Down
2 changes: 0 additions & 2 deletions ash/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ static_library("test_support_common") {
"user_metrics_recorder_test_api.h",
"wallpaper_controller_test_api.cc",
"wallpaper_controller_test_api.h",
"wm_window_test_api.cc",
"wm_window_test_api.h",
"workspace_controller_test_api.cc",
"workspace_controller_test_api.h",
"workspace_event_handler_test_helper.cc",
Expand Down
30 changes: 0 additions & 30 deletions ash/test/wm_window_test_api.cc

This file was deleted.

41 changes: 0 additions & 41 deletions ash/test/wm_window_test_api.h

This file was deleted.

Loading

0 comments on commit fd5eef9

Please sign in to comment.