Commit e7880ac7 authored by sky's avatar sky Committed by Commit bot

Adds additional_client_area to client area

This is needed for chrome.

BUG=663525
TEST=none
R=erg@chromium.org

Review-Url: https://codereview.chromium.org/2581503002
Cr-Commit-Position: refs/heads/master@{#438742}
parent db78e67f
...@@ -652,7 +652,8 @@ TEST_F(WindowServerTest, ClientAreaChanged) { ...@@ -652,7 +652,8 @@ TEST_F(WindowServerTest, ClientAreaChanged) {
// Verify change from embedded makes it to parent. // Verify change from embedded makes it to parent.
const gfx::Insets insets(1, 2, 3, 4); const gfx::Insets insets(1, 2, 3, 4);
embed_result->window_tree_host->SetClientArea(insets); embed_result->window_tree_host->SetClientArea(insets,
std::vector<gfx::Rect>());
std::unique_ptr<ClientAreaChange> client_area_change = std::unique_ptr<ClientAreaChange> client_area_change =
WaitForClientAreaToChange(); WaitForClientAreaToChange();
ASSERT_TRUE(client_area_change); ASSERT_TRUE(client_area_change);
......
...@@ -108,9 +108,11 @@ void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) { ...@@ -108,9 +108,11 @@ void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) {
SetBoundsInPixels(bounds); SetBoundsInPixels(bounds);
} }
void WindowTreeHostMus::SetClientArea(const gfx::Insets& insets) { void WindowTreeHostMus::SetClientArea(
const gfx::Insets& insets,
const std::vector<gfx::Rect>& additional_client_area) {
delegate_->OnWindowTreeHostClientAreaWillChange(this, insets, delegate_->OnWindowTreeHostClientAreaWillChange(this, insets,
std::vector<gfx::Rect>()); additional_client_area);
} }
void WindowTreeHostMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) { void WindowTreeHostMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) {
......
...@@ -61,7 +61,8 @@ class AURA_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform { ...@@ -61,7 +61,8 @@ class AURA_EXPORT WindowTreeHostMus : public aura::WindowTreeHostPlatform {
InputMethodMus* input_method() { return input_method_.get(); } InputMethodMus* input_method() { return input_method_.get(); }
// Sets the client area on the underlying mus window. // Sets the client area on the underlying mus window.
void SetClientArea(const gfx::Insets& insets); void SetClientArea(const gfx::Insets& insets,
const std::vector<gfx::Rect>& additional_client_area);
// Sets the hit test mask on the underlying mus window. Pass base::nullopt to // Sets the hit test mask on the underlying mus window. Pass base::nullopt to
// clear. // clear.
......
...@@ -16,7 +16,7 @@ TEST_F(WindowTreeHostMusTest, UpdateClientArea) { ...@@ -16,7 +16,7 @@ TEST_F(WindowTreeHostMusTest, UpdateClientArea) {
base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl()); base::MakeUnique<WindowTreeHostMus>(window_tree_client_impl());
gfx::Insets new_insets(10, 11, 12, 13); gfx::Insets new_insets(10, 11, 12, 13);
window_tree_host_mus->SetClientArea(new_insets); window_tree_host_mus->SetClientArea(new_insets, std::vector<gfx::Rect>());
EXPECT_EQ(new_insets, window_tree()->last_client_area()); EXPECT_EQ(new_insets, window_tree()->last_client_area());
} }
......
...@@ -31,11 +31,6 @@ namespace views { ...@@ -31,11 +31,6 @@ namespace views {
namespace { namespace {
bool ShouldSetClientArea(views::Widget::InitParams::Type type) {
using WIP = views::Widget::InitParams;
return type == WIP::TYPE_WINDOW || type == WIP::TYPE_PANEL;
}
// As the window manager renderers the non-client decorations this class does // As the window manager renderers the non-client decorations this class does
// very little but honor the client area insets from the window manager. // very little but honor the client area insets from the window manager.
class ClientSideNonClientFrameView : public NonClientFrameView { class ClientSideNonClientFrameView : public NonClientFrameView {
...@@ -201,7 +196,7 @@ bool DesktopWindowTreeHostMus::IsDocked() const { ...@@ -201,7 +196,7 @@ bool DesktopWindowTreeHostMus::IsDocked() const {
} }
void DesktopWindowTreeHostMus::SendClientAreaToServer() { void DesktopWindowTreeHostMus::SendClientAreaToServer() {
if (!ShouldSetClientArea(desktop_native_widget_aura_->widget_type())) if (!ShouldSendClientAreaToServer())
return; return;
NonClientView* non_client_view = NonClientView* non_client_view =
...@@ -210,10 +205,12 @@ void DesktopWindowTreeHostMus::SendClientAreaToServer() { ...@@ -210,10 +205,12 @@ void DesktopWindowTreeHostMus::SendClientAreaToServer() {
return; return;
const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); const gfx::Rect client_area_rect(non_client_view->client_view()->bounds());
SetClientArea(gfx::Insets( SetClientArea(
client_area_rect.y(), client_area_rect.x(), gfx::Insets(
non_client_view->bounds().height() - client_area_rect.bottom(), client_area_rect.y(), client_area_rect.x(),
non_client_view->bounds().width() - client_area_rect.right())); non_client_view->bounds().height() - client_area_rect.bottom(),
non_client_view->bounds().width() - client_area_rect.right()),
std::vector<gfx::Rect>());
} }
void DesktopWindowTreeHostMus::SendHitTestMaskToServer() { void DesktopWindowTreeHostMus::SendHitTestMaskToServer() {
...@@ -241,6 +238,15 @@ void DesktopWindowTreeHostMus::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) { ...@@ -241,6 +238,15 @@ void DesktopWindowTreeHostMus::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) {
SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip)); SetBoundsInPixels(gfx::ConvertRectToPixel(GetScaleFactor(), bounds_in_dip));
} }
bool DesktopWindowTreeHostMus::ShouldSendClientAreaToServer() const {
if (!auto_update_client_area_)
return false;
using WIP = views::Widget::InitParams;
const WIP::Type type = desktop_native_widget_aura_->widget_type();
return type == WIP::TYPE_WINDOW || type == WIP::TYPE_PANEL;
}
void DesktopWindowTreeHostMus::Init(aura::Window* content_window, void DesktopWindowTreeHostMus::Init(aura::Window* content_window,
const Widget::InitParams& params) { const Widget::InitParams& params) {
// Needed so we don't render over the non-client area the window manager // Needed so we don't render over the non-client area the window manager
...@@ -554,7 +560,7 @@ void DesktopWindowTreeHostMus::SetVisibilityChangedAnimationsEnabled( ...@@ -554,7 +560,7 @@ void DesktopWindowTreeHostMus::SetVisibilityChangedAnimationsEnabled(
} }
NonClientFrameView* DesktopWindowTreeHostMus::CreateNonClientFrameView() { NonClientFrameView* DesktopWindowTreeHostMus::CreateNonClientFrameView() {
if (!ShouldSetClientArea(desktop_native_widget_aura_->widget_type())) if (!ShouldSendClientAreaToServer())
return nullptr; return nullptr;
return new ClientSideNonClientFrameView(native_widget_delegate_->AsWidget()); return new ClientSideNonClientFrameView(native_widget_delegate_->AsWidget());
......
...@@ -37,6 +37,11 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus ...@@ -37,6 +37,11 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus
// Called when the window was deleted on the server. // Called when the window was deleted on the server.
void ServerDestroyedWindow() { CloseNow(); } void ServerDestroyedWindow() { CloseNow(); }
// Controls whether the client area is automatically updated as necessary.
void set_auto_update_client_area(bool value) {
auto_update_client_area_ = value;
}
private: private:
bool IsDocked() const; bool IsDocked() const;
...@@ -48,6 +53,9 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus ...@@ -48,6 +53,9 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus
void SetBoundsInDIP(const gfx::Rect& bounds_in_dip); void SetBoundsInDIP(const gfx::Rect& bounds_in_dip);
// Returns true if the client area should be set on this.
bool ShouldSendClientAreaToServer() const;
// DesktopWindowTreeHost: // DesktopWindowTreeHost:
void Init(aura::Window* content_window, void Init(aura::Window* content_window,
const Widget::InitParams& params) override; const Widget::InitParams& params) override;
...@@ -142,6 +150,8 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus ...@@ -142,6 +150,8 @@ class VIEWS_MUS_EXPORT DesktopWindowTreeHostMus
std::unique_ptr<wm::CursorManager> cursor_manager_; std::unique_ptr<wm::CursorManager> cursor_manager_;
bool auto_update_client_area_ = true;
// Used so that Close() isn't immediate. // Used so that Close() isn't immediate.
base::WeakPtrFactory<DesktopWindowTreeHostMus> close_widget_factory_; base::WeakPtrFactory<DesktopWindowTreeHostMus> close_widget_factory_;
......
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