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

Unified Diff: components/exo/shell_surface.cc

Issue 1645043003: exo: Improve window placement. (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
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/shell_surface.cc
diff --git a/components/exo/shell_surface.cc b/components/exo/shell_surface.cc
index efe73aa6ee60588c1562c6002cae3d85baf32b94..b4dd92861f952faeb0e37b038a9d1f86a3fc83bc 100644
--- a/components/exo/shell_surface.cc
+++ b/components/exo/shell_surface.cc
@@ -86,39 +86,12 @@ ShellSurface::~ShellSurface() {
widget_->CloseNow();
}
-void ShellSurface::Init() {
- TRACE_EVENT0("exo", "ShellSurface::Init");
-
- if (widget_) {
- DLOG(WARNING) << "Shell surface already initialized";
- return;
- }
-
- 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);
- widget_->GetNativeWindow()->SetName("ExoShellSurface");
- widget_->GetNativeWindow()->AddChild(surface_);
- SetApplicationId(widget_->GetNativeWindow(), &application_id_);
-
- // The position of a top-level shell surface is managed by Ash.
- ash::wm::GetWindowState(widget_->GetNativeWindow())
- ->set_window_position_managed(true);
-}
-
void ShellSurface::Maximize() {
TRACE_EVENT0("exo", "ShellSurface::Maximize");
- DCHECK(widget_);
+ if (!widget_)
+ CreateShellSurfaceWidget();
+
widget_->Maximize();
if (!configure_callback_.is_null())
@@ -128,7 +101,9 @@ void ShellSurface::Maximize() {
void ShellSurface::SetFullscreen(bool fullscreen) {
TRACE_EVENT1("exo", "ShellSurface::SetFullscreen", "fullscreen", fullscreen);
- DCHECK(widget_);
+ if (!widget_)
+ CreateShellSurfaceWidget();
+
widget_->SetFullscreen(fullscreen);
if (!configure_callback_.is_null())
@@ -202,7 +177,11 @@ scoped_refptr<base::trace_event::TracedValue> ShellSurface::AsTracedValue()
// SurfaceDelegate overrides:
void ShellSurface::OnSurfaceCommit() {
+ if (enabled() && !widget_)
+ CreateShellSurfaceWidget();
+
surface_->CommitSurfaceHierarchy();
+
if (widget_) {
// Update surface bounds and widget size.
gfx::Point origin;
@@ -270,4 +249,32 @@ gfx::Size ShellSurface::GetPreferredSize() const {
return surface_ ? surface_->GetPreferredSize() : gfx::Size();
}
+////////////////////////////////////////////////////////////////////////////////
+// ShellSurface, private:
+
+void ShellSurface::CreateShellSurfaceWidget() {
+ DCHECK(enabled());
+ DCHECK(!widget_);
+
+ 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);
+ widget_->GetNativeWindow()->SetName("ExoShellSurface");
+ widget_->GetNativeWindow()->AddChild(surface_);
+ SetApplicationId(widget_->GetNativeWindow(), &application_id_);
+
+ // The position of a top-level shell surface is managed by Ash.
+ ash::wm::GetWindowState(widget_->GetNativeWindow())
+ ->set_window_position_managed(true);
+}
+
} // namespace exo
« no previous file with comments | « components/exo/shell_surface.h ('k') | components/exo/shell_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698