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

Return correct minimum size set by a client.

This CL hook up minimum size to
Widget::GetMinimumSize/WindowDelegate::GetMinimumSize.

BUG=b/72402291
TEST=Covered by unit test.

Change-Id: I6977f5578c5f8fd3992917f818e38a713689d84f
Reviewed-on: https://chromium-review.googlesource.com/883402
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531780}
parent 5a990a0d
......@@ -65,6 +65,29 @@ const struct {
{ui::VKEY_W, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN},
{ui::VKEY_F4, ui::EF_ALT_DOWN}};
class ShellSurfaceWidget : public views::Widget {
public:
explicit ShellSurfaceWidget(ShellSurfaceBase* shell_surface)
: shell_surface_(shell_surface) {}
// Overridden from views::Widget:
void Close() override { shell_surface_->Close(); }
void OnKeyEvent(ui::KeyEvent* event) override {
// Handle only accelerators. Do not call Widget::OnKeyEvent that eats focus
// management keys (like the tab key) as well.
if (GetFocusManager()->ProcessAccelerator(ui::Accelerator(*event)))
event->SetHandled();
}
gfx::Size GetMinimumSize() const override {
return shell_surface_->GetMinimumSize();
}
private:
ShellSurfaceBase* const shell_surface_;
DISALLOW_COPY_AND_ASSIGN(ShellSurfaceWidget);
};
class CustomFrameView : public ash::CustomFrameViewAsh {
public:
using ShapeRects = std::vector<gfx::Rect>;
......@@ -148,6 +171,10 @@ class CustomFrameView : public ash::CustomFrameViewAsh {
if (enabled())
return ash::CustomFrameViewAsh::SizeConstraintsChanged();
}
gfx::Size GetMinimumSize() const override {
return static_cast<const ShellSurfaceWidget*>(GetWidget())
->GetMinimumSize();
}
private:
// TODO(oshima): Remove this once the transition to new drag/resize
......@@ -241,26 +268,6 @@ class CustomWindowTargeter : public aura::WindowTargeter {
DISALLOW_COPY_AND_ASSIGN(CustomWindowTargeter);
};
class ShellSurfaceWidget : public views::Widget {
public:
explicit ShellSurfaceWidget(ShellSurfaceBase* shell_surface)
: shell_surface_(shell_surface) {}
// Overridden from views::Widget
void Close() override { shell_surface_->Close(); }
void OnKeyEvent(ui::KeyEvent* event) override {
// Handle only accelerators. Do not call Widget::OnKeyEvent that eats focus
// management keys (like the tab key) as well.
if (GetFocusManager()->ProcessAccelerator(ui::Accelerator(*event)))
event->SetHandled();
}
private:
ShellSurfaceBase* const shell_surface_;
DISALLOW_COPY_AND_ASSIGN(ShellSurfaceWidget);
};
// A place holder to disable default implementation created by
// ash::CustomFrameViewAsh, which triggers immersive fullscreen etc, which
// we don't need.
......
......@@ -26,6 +26,7 @@
#include "components/exo/wm_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
......@@ -312,6 +313,11 @@ TEST_F(ShellSurfaceTest, SetMinimumSize) {
surface->Attach(buffer.get());
surface->Commit();
EXPECT_EQ(size, shell_surface->GetMinimumSize());
EXPECT_EQ(size, shell_surface->GetWidget()->GetMinimumSize());
EXPECT_EQ(size, shell_surface->GetWidget()
->GetNativeWindow()
->delegate()
->GetMinimumSize());
}
TEST_F(ShellSurfaceTest, SetMaximumSize) {
......
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