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

Unified Diff: mash/wm/wm.cc

Issue 2511233002: Add the beginning of a simple window manager that we'll support on Windows. (Closed)
Patch Set: . Created 4 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
Index: mash/wm/wm.cc
diff --git a/mash/wm/wm.cc b/mash/wm/wm.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9c4f8fe48aaf536aa97829590c55658a5c9b3538
--- /dev/null
+++ b/mash/wm/wm.cc
@@ -0,0 +1,109 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "mash/wm/wm.h"
+
+#include <utility>
+
+#include "services/service_manager/public/cpp/connector.h"
+#include "services/service_manager/public/cpp/service_context.h"
+#include "services/service_manager/public/cpp/service_runner.h"
+#include "services/ui/public/cpp/window.h"
+#include "services/ui/public/cpp/window_tree_client.h"
+
+namespace mash {
+namespace wm {
+
+////////////////////////////////////////////////////////////////////////////////
+// Service, public:
+
+WM::WM() {}
+WM::~WM() {}
+
+////////////////////////////////////////////////////////////////////////////////
+// Service, service_manager::Service implementation:
+
+void WM::OnStart() {
+ window_tree_client_.reset(new ui::WindowTreeClient(this, this));
+ window_tree_client_->ConnectAsWindowManager(context()->connector());
+}
+
+bool WM::OnConnect(const service_manager::ServiceInfo& remote_info,
+ service_manager::InterfaceRegistry* registry) {
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Service, ui::WindowTreeClientDelegate implementation:
+void WM::OnEmbed(ui::Window* root) {
+ // WindowTreeClients configured as the window manager should never get
+ // OnEmbed().
+ NOTREACHED();
+}
+void WM::OnLostConnection(ui::WindowTreeClient* client) {
+ window_tree_client_.reset();
+}
+void WM::OnEmbedRootDestroyed(ui::Window* root) {
+ // WindowTreeClients configured as the window manager should never get
+ // OnEmbedRootDestroyed().
+ NOTREACHED();
+}
+void WM::OnPointerEventObserved(const ui::PointerEvent& event,
+ ui::Window* target) {
+ // Don't care.
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Service, ui::WindowManagerDelegate implementation:
+
+void WM::SetWindowManagerClient(ui::WindowManagerClient* client) {
+ window_manager_client_ = client;
+}
+bool WM::OnWmSetBounds(ui::Window* window, gfx::Rect* bounds) {
+ return true;
+}
+bool WM::OnWmSetProperty(
+ ui::Window* window,
+ const std::string& name,
+ std::unique_ptr<std::vector<uint8_t>>* new_data) {
+ return true;
+}
+ui::Window* WM::OnWmCreateTopLevelWindow(
+ std::map<std::string, std::vector<uint8_t>>* properties) {
+ ui::Window* window = root_->window_tree()->NewWindow(properties);
+ window->SetBounds(gfx::Rect(10, 10, 500, 500));
+ root_->AddChild(window);
+ return window;
+}
+void WM::OnWmClientJankinessChanged(
+ const std::set<ui::Window*>& client_windows, bool janky) {
+ // Don't care.
+}
+void WM::OnWmNewDisplay(ui::Window* window,
+ const display::Display& display) {
+ // Only handles a single root.
+ DCHECK(!root_);
+ root_ = window;
+ DCHECK(window_manager_client_);
+ window_manager_client_->AddActivationParent(root_);
+ ui::mojom::FrameDecorationValuesPtr frame_decoration_values =
+ ui::mojom::FrameDecorationValues::New();
+ frame_decoration_values->max_title_bar_button_width = 0;
+ window_manager_client_->SetFrameDecorationValues(
+ std::move(frame_decoration_values));
+}
+void WM::OnWmDisplayRemoved(ui::Window* window) {
+ window->Destroy();
+}
+void WM::OnWmDisplayModified(const display::Display& display) {}
+void WM::OnWmPerformMoveLoop(ui::Window* window,
+ ui::mojom::MoveLoopSource source,
+ const gfx::Point& cursor_location,
+ const base::Callback<void(bool)>& on_done) {
+ // Don't care.
+}
+void WM::OnWmCancelMoveLoop(ui::Window* window) {}
+
+} // namespace wm
+} // namespace mash
« mash/wm/wm.h ('K') | « mash/wm/wm.h ('k') | services/service_manager/standalone/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698