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

Unified Diff: ui/aura/mus/window_tree_host_mus.cc

Issue 2445163002: Make aura work with mus (Closed)
Patch Set: NON_EXPORTED_BASE_CLASS Created 4 years, 2 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 | « ui/aura/mus/window_tree_host_mus.h ('k') | ui/aura/test/aura_mus_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_host_mus.cc
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/aura/mus/window_tree_host_mus.cc
similarity index 46%
copy from ui/views/mus/window_tree_host_mus.cc
copy to ui/aura/mus/window_tree_host_mus.cc
index 0d08e1b3f41fc1ad4ee81980577e1e255d440d8c..0f0959e049b971b33faed5fa65d30c125492c930 100644
--- a/ui/views/mus/window_tree_host_mus.cc
+++ b/ui/aura/mus/window_tree_host_mus.cc
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/views/mus/window_tree_host_mus.h"
+#include "ui/aura/mus/window_tree_host_mus.h"
#include "base/memory/ptr_util.h"
-#include "services/ui/public/cpp/window.h"
#include "ui/aura/env.h"
+#include "ui/aura/mus/input_method_mus.h"
+#include "ui/aura/mus/window_port_mus.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/aura/window_observer.h"
#include "ui/events/event.h"
#include "ui/platform_window/stub/stub_window.h"
-#include "ui/views/mus/input_method_mus.h"
-#include "ui/views/mus/native_widget_mus.h"
-namespace views {
+namespace aura {
namespace {
static uint32_t accelerated_widget_count = 1;
@@ -23,21 +23,51 @@ bool IsUsingTestContext() {
return aura::Env::GetInstance()->context_factory()->DoesCreateTestContexts();
}
-}
+} // namespace
+
+class WindowTreeHostMus::ContentWindowObserver : public WindowObserver {
+ public:
+ ContentWindowObserver(WindowTreeHostMus* window_tree_host_mus, Window* window)
+ : window_tree_host_mus_(window_tree_host_mus), window_(window) {
+ window_->AddObserver(this);
+ }
+ ~ContentWindowObserver() override { window_->RemoveObserver(this); }
+
+ // WindowObserver:
+ void OnWindowDestroyed(Window* window) override {
+ window_tree_host_mus_->ContentWindowDestroyed();
+ }
+ void OnWindowBoundsChanged(Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
+ if (old_bounds.size() != new_bounds.size())
+ window_tree_host_mus_->ContentWindowResized();
+ }
+ void OnWindowVisibilityChanging(Window* window, bool visible) override {
+ window_tree_host_mus_->ContentWindowVisibilityChanging(visible);
+ }
+
+ private:
+ WindowTreeHostMus* window_tree_host_mus_;
+ Window* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentWindowObserver);
+};
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMus, public:
-WindowTreeHostMus::WindowTreeHostMus(NativeWidgetMus* native_widget,
- ui::Window* window)
- : native_widget_(native_widget) {
+WindowTreeHostMus::WindowTreeHostMus(std::unique_ptr<WindowPortMus> window_port,
+ Window* content_window)
+ : WindowTreeHostPlatform(std::move(window_port)),
+ content_window_(content_window) {
gfx::AcceleratedWidget accelerated_widget;
if (IsUsingTestContext()) {
accelerated_widget = gfx::kNullAcceleratedWidget;
} else {
- // We need accelerated widget numbers to be different for each
- // window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
- // has this property.
+// We need accelerated widget numbers to be different for each
+// window and fit in the smallest sizeof(AcceleratedWidget) uint32_t
+// has this property.
#if defined(OS_WIN) || defined(OS_ANDROID)
accelerated_widget =
reinterpret_cast<gfx::AcceleratedWidget>(accelerated_widget_count++);
@@ -53,10 +83,21 @@ WindowTreeHostMus::WindowTreeHostMus(NativeWidgetMus* native_widget,
this,
false)); // Do not advertise accelerated widget; already set manually.
- compositor()->SetWindow(window);
+ if (content_window_) {
+ window()->AddChild(content_window_);
+ window()->SetBounds(gfx::Rect(content_window_->bounds().size()));
+ content_window_observer_ =
+ base::MakeUnique<ContentWindowObserver>(this, content_window_);
+ } else {
+ // Initialize the stub platform window bounds to those of the ui::Window.
+ platform_window()->SetBounds(window()->bounds());
+ }
+
+ input_method_ = base::MakeUnique<InputMethodMus>(
+ this, content_window_ ? content_window_ : window());
- // Initialize the stub platform window bounds to those of the ui::Window.
- platform_window()->SetBounds(window->bounds());
+ // TODO: resolve
+ // compositor()->SetWindow(window);
compositor()->SetHostHasTransparentBackground(true);
}
@@ -66,15 +107,32 @@ WindowTreeHostMus::~WindowTreeHostMus() {
DestroyDispatcher();
}
+void WindowTreeHostMus::ContentWindowDestroyed() {
+ delete this;
+}
+
+void WindowTreeHostMus::ContentWindowResized() {
+ window()->SetBounds(gfx::Rect(content_window_->bounds().size()));
+}
+
+void WindowTreeHostMus::ContentWindowVisibilityChanging(bool visible) {
+ if (visible)
+ window()->Show();
+ else
+ window()->Hide();
+}
+
void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
- // Key events are sent to InputMethodMus directly from NativeWidgetMus.
DCHECK(!event->IsKeyEvent());
WindowTreeHostPlatform::DispatchEvent(event);
}
void WindowTreeHostMus::OnClosed() {
+ // TODO: figure out if needed.
+ /*
if (native_widget_)
native_widget_->OnPlatformWindowClosed();
+ */
}
void WindowTreeHostMus::OnActivationChanged(bool active) {
@@ -82,8 +140,11 @@ void WindowTreeHostMus::OnActivationChanged(bool active) {
GetInputMethod()->OnFocus();
else
GetInputMethod()->OnBlur();
+ // TODO: figure out if needed.
+ /*
if (native_widget_)
native_widget_->OnActivationChanged(active);
+ */
WindowTreeHostPlatform::OnActivationChanged(active);
}
@@ -96,4 +157,4 @@ gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() {
return gfx::ICCProfile();
}
-} // namespace views
+} // namespace aura
« no previous file with comments | « ui/aura/mus/window_tree_host_mus.h ('k') | ui/aura/test/aura_mus_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698