| Index: ui/aura/mus/window_tree_host_mus.cc
|
| diff --git a/ui/aura/mus/window_tree_host_mus.cc b/ui/aura/mus/window_tree_host_mus.cc
|
| index 0f0959e049b971b33faed5fa65d30c125492c930..3be01cfb7c661ec9fd462171ef54791a14bdf2d4 100644
|
| --- a/ui/aura/mus/window_tree_host_mus.cc
|
| +++ b/ui/aura/mus/window_tree_host_mus.cc
|
| @@ -8,9 +8,12 @@
|
| #include "ui/aura/env.h"
|
| #include "ui/aura/mus/input_method_mus.h"
|
| #include "ui/aura/mus/window_port_mus.h"
|
| +#include "ui/aura/mus/window_tree_host_mus_delegate.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| #include "ui/aura/window_observer.h"
|
| +#include "ui/display/display.h"
|
| +#include "ui/display/screen.h"
|
| #include "ui/events/event.h"
|
| #include "ui/platform_window/stub/stub_window.h"
|
|
|
| @@ -37,15 +40,6 @@ class WindowTreeHostMus::ContentWindowObserver : public 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_;
|
| @@ -58,8 +52,14 @@ class WindowTreeHostMus::ContentWindowObserver : public WindowObserver {
|
| // WindowTreeHostMus, public:
|
|
|
| WindowTreeHostMus::WindowTreeHostMus(std::unique_ptr<WindowPortMus> window_port,
|
| + WindowTreeHostMusDelegate* delegate,
|
| + RootWindowType root_window_type,
|
| + int64_t display_id,
|
| Window* content_window)
|
| : WindowTreeHostPlatform(std::move(window_port)),
|
| + display_id_(display_id),
|
| + root_window_type_(root_window_type),
|
| + delegate_(delegate),
|
| content_window_(content_window) {
|
| gfx::AcceleratedWidget accelerated_widget;
|
| if (IsUsingTestContext()) {
|
| @@ -96,10 +96,13 @@ WindowTreeHostMus::WindowTreeHostMus(std::unique_ptr<WindowPortMus> window_port,
|
| input_method_ = base::MakeUnique<InputMethodMus>(
|
| this, content_window_ ? content_window_ : window());
|
|
|
| - // TODO: resolve
|
| + // TODO: hook up to compositor correctly.
|
| // compositor()->SetWindow(window);
|
|
|
| compositor()->SetHostHasTransparentBackground(true);
|
| +
|
| + // Mus windows are assumed hidden.
|
| + compositor()->SetVisible(false);
|
| }
|
|
|
| WindowTreeHostMus::~WindowTreeHostMus() {
|
| @@ -107,19 +110,67 @@ WindowTreeHostMus::~WindowTreeHostMus() {
|
| DestroyDispatcher();
|
| }
|
|
|
| +void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds) {
|
| + base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true);
|
| + SetBounds(bounds);
|
| +}
|
| +
|
| +display::Display WindowTreeHostMus::GetDisplay() const {
|
| + for (const display::Display& display :
|
| + display::Screen::GetScreen()->GetAllDisplays()) {
|
| + if (display.id() == display_id_)
|
| + return display;
|
| + }
|
| + return display::Display();
|
| +}
|
| +
|
| +Window* WindowTreeHostMus::GetWindowWithServerWindow() {
|
| + return content_window_ ? content_window_ : window();
|
| +}
|
| +
|
| void WindowTreeHostMus::ContentWindowDestroyed() {
|
| delete this;
|
| }
|
|
|
| -void WindowTreeHostMus::ContentWindowResized() {
|
| - window()->SetBounds(gfx::Rect(content_window_->bounds().size()));
|
| +void WindowTreeHostMus::ShowImpl() {
|
| + WindowTreeHostPlatform::ShowImpl();
|
| + window()->Show();
|
| + if (content_window_)
|
| + content_window_->Show();
|
| }
|
|
|
| -void WindowTreeHostMus::ContentWindowVisibilityChanging(bool visible) {
|
| - if (visible)
|
| - window()->Show();
|
| - else
|
| - window()->Hide();
|
| +void WindowTreeHostMus::HideImpl() {
|
| + WindowTreeHostPlatform::HideImpl();
|
| + window()->Hide();
|
| + if (content_window_)
|
| + content_window_->Hide();
|
| +}
|
| +
|
| +void WindowTreeHostMus::SetBounds(const gfx::Rect& bounds) {
|
| + gfx::Rect adjusted_bounds(bounds);
|
| + if (!in_set_bounds_from_server_) {
|
| + delegate_->SetRootWindowBounds(GetWindowWithServerWindow(),
|
| + &adjusted_bounds);
|
| + }
|
| + WindowTreeHostPlatform::SetBounds(adjusted_bounds);
|
| + if (content_window_)
|
| + content_window_->SetBounds(adjusted_bounds);
|
| +}
|
| +
|
| +gfx::Rect WindowTreeHostMus::GetBounds() const {
|
| + // TODO(sky): this is wrong, root windows need to be told their location
|
| + // relative to the display.
|
| + const display::Display display(GetDisplay());
|
| + const gfx::Vector2d origin(origin_offset_ +
|
| + display.bounds().OffsetFromOrigin());
|
| + return gfx::Rect(gfx::Point(origin.x(), origin.y()),
|
| + WindowTreeHostPlatform::GetBounds().size());
|
| +}
|
| +
|
| +gfx::Point WindowTreeHostMus::GetLocationOnNativeScreen() const {
|
| + // TODO(sky): this is wrong, root windows need to be told their location
|
| + // relative to the display.
|
| + return gfx::Point(origin_offset_.x(), origin_offset_.y());
|
| }
|
|
|
| void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
|
| @@ -128,11 +179,6 @@ void WindowTreeHostMus::DispatchEvent(ui::Event* event) {
|
| }
|
|
|
| void WindowTreeHostMus::OnClosed() {
|
| - // TODO: figure out if needed.
|
| - /*
|
| - if (native_widget_)
|
| - native_widget_->OnPlatformWindowClosed();
|
| - */
|
| }
|
|
|
| void WindowTreeHostMus::OnActivationChanged(bool active) {
|
| @@ -140,11 +186,6 @@ 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);
|
| }
|
|
|
|
|