summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorreveman <reveman@chromium.org>2015-11-30 12:29:12 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-30 20:29:50 +0000
commit39a9727c8dda6a4dca540e4d06a8614268abfa21 (patch)
tree90b0cbdaeecda2384dcc5ee82f52f95e6fe7d01d /components
parent2e4d8173e148558f60fe90143613bfeefbcc7896 (diff)
downloadchromium_src-39a9727c8dda6a4dca540e4d06a8614268abfa21.zip
chromium_src-39a9727c8dda6a4dca540e4d06a8614268abfa21.tar.gz
chromium_src-39a9727c8dda6a4dca540e4d06a8614268abfa21.tar.bz2
exo: Add maximize support and simplify shell surfaces.
This allows a client to show a shell surface as maximized and simplifies the shell surface implemenatation by always requiring client side decorations. BUG=549781 TEST=exo_unittests --gtest_filter=ShellSurfaceTest.SetMaximized Review URL: https://codereview.chromium.org/1481773002 Cr-Commit-Position: refs/heads/master@{#362213}
Diffstat (limited to 'components')
-rw-r--r--components/exo/shell_surface.cc39
-rw-r--r--components/exo/shell_surface.h12
-rw-r--r--components/exo/shell_surface_unittest.cc28
-rw-r--r--components/exo/wayland/server.cc4
4 files changed, 45 insertions, 38 deletions
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index f1983af..29f6749 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -64,13 +64,6 @@ ShellSurface::~ShellSurface() {
widget_->CloseNow();
}
-void ShellSurface::Show() {
- TRACE_EVENT0("exo", "ShellSurface::Show");
-
- if (!widget_ && show_state_ == ui::SHOW_STATE_END)
- show_state_ = ui::SHOW_STATE_DEFAULT;
-}
-
void ShellSurface::SetToplevel() {
TRACE_EVENT0("exo", "ShellSurface::SetToplevel");
@@ -78,15 +71,26 @@ void ShellSurface::SetToplevel() {
show_state_ = ui::SHOW_STATE_NORMAL;
}
-void ShellSurface::SetFullscreen(bool fullscreen) {
- TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen);
+void ShellSurface::SetMaximized() {
+ TRACE_EVENT0("exo", "ShellSurface::SetMaximized");
+
+ if (widget_) {
+ widget_->Maximize();
+ return;
+ }
+
+ show_state_ = ui::SHOW_STATE_MAXIMIZED;
+}
+
+void ShellSurface::SetFullscreen() {
+ TRACE_EVENT0("exo", "ShellSurface::SetFullscreen");
if (widget_) {
- widget_->SetFullscreen(fullscreen);
+ widget_->SetFullscreen(true);
return;
}
- show_state_ = fullscreen ? ui::SHOW_STATE_FULLSCREEN : ui::SHOW_STATE_DEFAULT;
+ show_state_ = ui::SHOW_STATE_FULLSCREEN;
}
void ShellSurface::SetTitle(const base::string16& title) {
@@ -121,12 +125,8 @@ void ShellSurface::OnSurfaceCommit() {
params.type = views::Widget::InitParams::TYPE_WINDOW;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.delegate = this;
- params.shadow_type = show_state_ == ui::SHOW_STATE_NORMAL
- ? views::Widget::InitParams::SHADOW_TYPE_DROP
- : views::Widget::InitParams::SHADOW_TYPE_NONE;
- params.opacity = show_state_ == ui::SHOW_STATE_NORMAL
- ? views::Widget::InitParams::OPAQUE_WINDOW
- : views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
params.show_state = show_state_;
params.parent = ash::Shell::GetContainer(
ash::Shell::GetPrimaryRootWindow(), ash::kShellWindowId_DefaultContainer);
@@ -176,10 +176,7 @@ views::View* ShellSurface::GetContentsView() {
views::NonClientFrameView* ShellSurface::CreateNonClientFrameView(
views::Widget* widget) {
- // Default show state is borderless and requires a custom frame view as the
- // default one does not support this.
- return show_state_ != ui::SHOW_STATE_NORMAL ? new CustomFrameView(widget)
- : nullptr;
+ return new CustomFrameView(widget);
}
} // namespace exo
diff --git a/components/exo/shell_surface.h b/components/exo/shell_surface.h
index ef2d4ce..6d5950e 100644
--- a/components/exo/shell_surface.h
+++ b/components/exo/shell_surface.h
@@ -33,14 +33,14 @@ class ShellSurface : public SurfaceDelegate,
explicit ShellSurface(Surface* surface);
~ShellSurface() override;
- // Show surface at the time of the next commit.
- void Show();
-
- // Show surface as a toplevel window with decorations.
+ // Show surface as a toplevel window.
void SetToplevel();
- // Make the surface fullscreen.
- void SetFullscreen(bool fullscreen);
+ // Maximize or show surface as a maximized window.
+ void SetMaximized();
+
+ // Fullscreen or show surface as a fullscreen window.
+ void SetFullscreen();
// Set title for surface.
void SetTitle(const base::string16& title);
diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
index d04da9e..3a08c04 100644
--- a/components/exo/shell_surface_unittest.cc
+++ b/components/exo/shell_surface_unittest.cc
@@ -10,6 +10,7 @@
#include "components/exo/test/exo_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
+#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"
namespace exo {
@@ -17,7 +18,7 @@ namespace {
using ShellSurfaceTest = test::ExoTestBase;
-TEST_F(ShellSurfaceTest, Show) {
+TEST_F(ShellSurfaceTest, SetTopLevel) {
gfx::Size small_buffer_size(64, 64);
scoped_ptr<Buffer> small_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(small_buffer_size),
@@ -29,7 +30,7 @@ TEST_F(ShellSurfaceTest, Show) {
scoped_ptr<Surface> surface(new Surface);
scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
- shell_surface->Show();
+ shell_surface->SetToplevel();
surface->Attach(small_buffer.get());
surface->Commit();
ASSERT_TRUE(shell_surface->GetWidget());
@@ -44,24 +45,33 @@ TEST_F(ShellSurfaceTest, Show) {
shell_surface->GetWidget()->GetWindowBoundsInScreen().size().ToString());
}
-TEST_F(ShellSurfaceTest, SetToplevel) {
+TEST_F(ShellSurfaceTest, SetMaximized) {
+ gfx::Size buffer_size(256, 256);
+ scoped_ptr<Buffer> buffer(new Buffer(
+ exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
scoped_ptr<Surface> surface(new Surface);
scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
- shell_surface->SetToplevel();
+ shell_surface->SetMaximized();
+ surface->Attach(buffer.get());
+ surface->Commit();
+ EXPECT_EQ(CurrentContext()->bounds().width(),
+ shell_surface->GetWidget()->GetWindowBoundsInScreen().width());
surface->Commit();
}
TEST_F(ShellSurfaceTest, SetFullscreen) {
+ gfx::Size buffer_size(256, 256);
+ scoped_ptr<Buffer> buffer(new Buffer(
+ exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), GL_TEXTURE_2D));
scoped_ptr<Surface> surface(new Surface);
scoped_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
- shell_surface->SetFullscreen(true);
- surface->Commit();
-
- // Fullscreen mode can change after the initial Commit().
- shell_surface->SetFullscreen(false);
+ shell_surface->SetFullscreen();
+ surface->Attach(buffer.get());
surface->Commit();
+ EXPECT_EQ(CurrentContext()->bounds().ToString(),
+ shell_surface->GetWidget()->GetWindowBoundsInScreen().ToString());
}
TEST_F(ShellSurfaceTest, SetTitle) {
diff --git a/components/exo/wayland/server.cc b/components/exo/wayland/server.cc
index 7cc2250..2a6bed3 100644
--- a/components/exo/wayland/server.cc
+++ b/components/exo/wayland/server.cc
@@ -615,7 +615,7 @@ void shell_surface_set_fullscreen(wl_client* client,
uint32_t method,
uint32_t framerate,
wl_resource* output_resource) {
- GetUserDataAs<ShellSurface>(resource)->SetFullscreen(true);
+ GetUserDataAs<ShellSurface>(resource)->SetFullscreen();
}
void shell_surface_set_popup(wl_client* client,
@@ -632,7 +632,7 @@ void shell_surface_set_popup(wl_client* client,
void shell_surface_set_maximized(wl_client* client,
wl_resource* resource,
wl_resource* output_resource) {
- NOTIMPLEMENTED();
+ GetUserDataAs<ShellSurface>(resource)->SetMaximized();
}
void shell_surface_set_title(wl_client* client,