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

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

Issue 1405373005: views/mus: Move PlatformWindowMus into its own file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mus-example-focus-close
Patch Set: tot.merge Created 5 years, 1 month 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/views/mus/platform_window_mus.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/window_tree_host_mus.cc
diff --git a/ui/views/mus/window_tree_host_mus.cc b/ui/views/mus/window_tree_host_mus.cc
index 61c6f4670e47047b292f5e16424dfeb3f987f791..fa69ac3a267680642560f01453ca494c46528c01 100644
--- a/ui/views/mus/window_tree_host_mus.cc
+++ b/ui/views/mus/window_tree_host_mus.cc
@@ -4,159 +4,16 @@
#include "ui/views/mus/window_tree_host_mus.h"
-#include "components/mus/public/cpp/property_type_converters.h"
-#include "components/mus/public/cpp/window_observer.h"
-#include "components/mus/public/cpp/window_property.h"
-#include "components/mus/public/cpp/window_tree_connection.h"
-#include "components/mus/public/interfaces/window_manager.mojom.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
-#include "mojo/converters/geometry/geometry_type_converters.h"
-#include "mojo/converters/input_events/input_events_type_converters.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/events/event.h"
-#include "ui/events/event_constants.h"
-#include "ui/platform_window/platform_window.h"
-#include "ui/platform_window/platform_window_delegate.h"
#include "ui/views/mus/input_method_mus.h"
#include "ui/views/mus/native_widget_mus.h"
+#include "ui/views/mus/platform_window_mus.h"
#include "ui/views/mus/surface_context_factory.h"
-#include "ui/views/mus/window_manager_connection.h"
namespace views {
-namespace {
-
-void WindowManagerCallback(mus::mojom::WindowManagerErrorCode error_code) {}
-
-class PlatformWindowMus : public ui::PlatformWindow,
- public mus::WindowObserver {
- public:
- PlatformWindowMus(ui::PlatformWindowDelegate* delegate,
- mus::Window* mus_window)
- : delegate_(delegate),
- mus_window_(mus_window),
- show_state_(mus::mojom::SHOW_STATE_RESTORED) {
- DCHECK(delegate_);
- DCHECK(mus_window_);
- mus_window_->AddObserver(this);
-
- delegate_->OnAcceleratedWidgetAvailable(gfx::kNullAcceleratedWidget,
- mus_window_->viewport_metrics().device_pixel_ratio);
- }
-
- ~PlatformWindowMus() override {
- if (!mus_window_)
- return;
- mus_window_->RemoveObserver(this);
- mus_window_->Destroy();
- }
-
- private:
- void SetShowState(mus::mojom::ShowState show_state) {
- WindowManagerConnection::Get()->window_manager()->SetShowState(
- mus_window_->id(), show_state, base::Bind(&WindowManagerCallback));
- }
-
- // ui::PlatformWindow:
- void Show() override { mus_window_->SetVisible(true); }
- void Hide() override { mus_window_->SetVisible(false); }
- void Close() override { NOTIMPLEMENTED(); }
-
- void SetBounds(const gfx::Rect& bounds) override {
- mus_window_->SetBounds(bounds);
- }
- gfx::Rect GetBounds() override { return mus_window_->bounds(); }
- void SetTitle(const base::string16& title) override { NOTIMPLEMENTED(); }
- void SetCapture() override { NOTIMPLEMENTED(); }
- void ReleaseCapture() override { NOTIMPLEMENTED(); }
- void ToggleFullscreen() override { NOTIMPLEMENTED(); }
- void Maximize() override {
- SetShowState(mus::mojom::SHOW_STATE_MAXIMIZED);
- }
- void Minimize() override {
- SetShowState(mus::mojom::SHOW_STATE_MINIMIZED);
- }
- void Restore() override {
- SetShowState(mus::mojom::SHOW_STATE_RESTORED);
- }
- void SetCursor(ui::PlatformCursor cursor) override { NOTIMPLEMENTED(); }
- void MoveCursorTo(const gfx::Point& location) override { NOTIMPLEMENTED(); }
- void ConfineCursorToBounds(const gfx::Rect& bounds) override {
- NOTIMPLEMENTED();
- }
- ui::PlatformImeController* GetPlatformImeController() override {
- return nullptr;
- }
-
- // mus::WindowObserver:
- void OnWindowDestroyed(mus::Window* window) override {
- DCHECK_EQ(mus_window_, window);
- delegate_->OnClosed();
- mus_window_ = nullptr;
- }
-
- void OnWindowBoundsChanged(mus::Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) override {
- delegate_->OnBoundsChanged(new_bounds);
- }
-
- void OnWindowFocusChanged(mus::Window* gained_focus,
- mus::Window* lost_focus) override {
- if (gained_focus == mus_window_)
- delegate_->OnActivationChanged(true);
- else if (lost_focus == mus_window_)
- delegate_->OnActivationChanged(false);
- }
-
- void OnWindowInputEvent(mus::Window* view,
- const mus::mojom::EventPtr& event) override {
- scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event>>());
- delegate_->DispatchEvent(ui_event.get());
- }
-
- void OnWindowSharedPropertyChanged(
- mus::Window* window,
- const std::string& name,
- const std::vector<uint8_t>* old_data,
- const std::vector<uint8_t>* new_data) override {
- if (name != mus::mojom::WindowManager::kShowState_Property)
- return;
- mus::mojom::ShowState show_state = static_cast<mus::mojom::ShowState>(
- window->GetSharedProperty<int32_t>(
- mus::mojom::WindowManager::kShowState_Property));
- if (show_state == show_state_)
- return;
- show_state_ = show_state;
- ui::PlatformWindowState state = ui::PLATFORM_WINDOW_STATE_UNKNOWN;
- switch (show_state_) {
- case mus::mojom::SHOW_STATE_MINIMIZED:
- state = ui::PLATFORM_WINDOW_STATE_MINIMIZED;
- break;
- case mus::mojom::SHOW_STATE_MAXIMIZED:
- state = ui::PLATFORM_WINDOW_STATE_MAXIMIZED;
- break;
- case mus::mojom::SHOW_STATE_RESTORED:
- state = ui::PLATFORM_WINDOW_STATE_NORMAL;
- break;
- case mus::mojom::SHOW_STATE_IMMERSIVE:
- case mus::mojom::SHOW_STATE_PRESENTATION:
- // This may not be sufficient.
- state = ui::PLATFORM_WINDOW_STATE_FULLSCREEN;
- break;
- }
- delegate_->OnWindowStateChanged(state);
- }
-
- ui::PlatformWindowDelegate* delegate_;
- mus::Window* mus_window_;
- mus::mojom::ShowState show_state_;
-
- DISALLOW_COPY_AND_ASSIGN(PlatformWindowMus);
-};
-
-} // namespace
////////////////////////////////////////////////////////////////////////////////
// WindowTreeHostMus, public:
« no previous file with comments | « ui/views/mus/platform_window_mus.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698