Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(854)

Unified Diff: components/exo/shell_surface.cc

Issue 1580033004: exo: Improve Maximize and Fullscreen support for ShellSurfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/exo/shell_surface.cc
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index 8fc61ee07f7bc4d38a6cd3b4a77672b95a31dc06..efe73aa6ee60588c1562c6002cae3d85baf32b94 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -54,21 +54,6 @@ class ShellSurfaceWidget : public views::Widget {
explicit ShellSurfaceWidget(ShellSurface* shell_surface)
: shell_surface_(shell_surface) {}
- static views::Widget::InitParams CreateInitParams(
- views::WidgetDelegate* delegate) {
- views::Widget::InitParams params;
- params.type = views::Widget::InitParams::TYPE_WINDOW;
- params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params.delegate = delegate;
- params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
- params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
- params.show_state = ui::SHOW_STATE_NORMAL;
- params.parent =
- ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
- ash::kShellWindowId_DefaultContainer);
- return params;
- }
-
// Overridden from views::Widget
void Close() override { shell_surface_->Close(); }
@@ -101,16 +86,23 @@ ShellSurface::~ShellSurface() {
widget_->CloseNow();
}
-void ShellSurface::SetToplevel() {
- TRACE_EVENT0("exo", "ShellSurface::SetToplevel");
+void ShellSurface::Init() {
+ TRACE_EVENT0("exo", "ShellSurface::Init");
if (widget_) {
- DLOG(WARNING) << "Shell surface already mapped";
+ DLOG(WARNING) << "Shell surface already initialized";
return;
}
- views::Widget::InitParams params = ShellSurfaceWidget::CreateInitParams(this);
- params.bounds = gfx::Rect(gfx::Size(1, 1));
+ views::Widget::InitParams params;
+ params.type = views::Widget::InitParams::TYPE_WINDOW;
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.delegate = this;
+ params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.show_state = ui::SHOW_STATE_NORMAL;
+ params.parent = ash::Shell::GetContainer(
+ ash::Shell::GetPrimaryRootWindow(), ash::kShellWindowId_DefaultContainer);
widget_.reset(new ShellSurfaceWidget(this));
widget_->Init(params);
widget_->GetNativeWindow()->set_owned_by_parent(false);
@@ -118,45 +110,29 @@ void ShellSurface::SetToplevel() {
widget_->GetNativeWindow()->AddChild(surface_);
SetApplicationId(widget_->GetNativeWindow(), &application_id_);
- // The position of a standard top level shell surface is managed by Ash.
+ // The position of a top-level shell surface is managed by Ash.
ash::wm::GetWindowState(widget_->GetNativeWindow())
->set_window_position_managed(true);
}
-void ShellSurface::SetMaximized() {
- TRACE_EVENT0("exo", "ShellSurface::SetMaximized");
+void ShellSurface::Maximize() {
+ TRACE_EVENT0("exo", "ShellSurface::Maximize");
- if (widget_) {
- DLOG(WARNING) << "Shell surface already mapped";
- return;
- }
+ DCHECK(widget_);
+ widget_->Maximize();
- views::Widget::InitParams params = ShellSurfaceWidget::CreateInitParams(this);
- params.show_state = ui::SHOW_STATE_MAXIMIZED;
- widget_.reset(new ShellSurfaceWidget(this));
- widget_->Init(params);
- widget_->GetNativeWindow()->set_owned_by_parent(false);
- widget_->GetNativeWindow()->SetName("ExoShellSurface");
- widget_->GetNativeWindow()->AddChild(surface_);
- SetApplicationId(widget_->GetNativeWindow(), &application_id_);
+ if (!configure_callback_.is_null())
+ configure_callback_.Run(widget_->GetWindowBoundsInScreen().size());
}
-void ShellSurface::SetFullscreen() {
- TRACE_EVENT0("exo", "ShellSurface::SetFullscreen");
+void ShellSurface::SetFullscreen(bool fullscreen) {
+ TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen);
- if (widget_) {
- DLOG(WARNING) << "Shell surface already mapped";
- return;
- }
+ DCHECK(widget_);
+ widget_->SetFullscreen(fullscreen);
- views::Widget::InitParams params = ShellSurfaceWidget::CreateInitParams(this);
- params.show_state = ui::SHOW_STATE_FULLSCREEN;
- widget_.reset(new ShellSurfaceWidget(this));
- widget_->Init(params);
- widget_->GetNativeWindow()->set_owned_by_parent(false);
- widget_->GetNativeWindow()->SetName("ExoShellSurface");
- widget_->GetNativeWindow()->AddChild(surface_);
- SetApplicationId(widget_->GetNativeWindow(), &application_id_);
+ if (!configure_callback_.is_null())
+ configure_callback_.Run(widget_->GetWindowBoundsInScreen().size());
}
void ShellSurface::SetTitle(const base::string16& title) {

Powered by Google App Engine
This is Rietveld 408576698