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

Unified Diff: mojo/examples/window_manager/window_manager.cc

Issue 354933002: Connect X11 ConfigureNotify events to Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Complete Created 6 years, 6 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
Index: mojo/examples/window_manager/window_manager.cc
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc
index 2d3c694af4722373fccaab8793ebc25f8b1fccad..1f748df54080380053d545c2af49e3e5c0a214c9 100644
--- a/mojo/examples/window_manager/window_manager.cc
+++ b/mojo/examples/window_manager/window_manager.cc
@@ -13,6 +13,7 @@
#include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
#include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
#include "mojo/services/public/cpp/view_manager/node.h"
+#include "mojo/services/public/cpp/view_manager/node_observer.h"
#include "mojo/services/public/cpp/view_manager/view.h"
#include "mojo/services/public/cpp/view_manager/view_event_dispatcher.h"
#include "mojo/services/public/cpp/view_manager/view_manager.h"
@@ -156,6 +157,38 @@ class KeyboardManager : public KeyboardClient {
DISALLOW_COPY_AND_ASSIGN(KeyboardManager);
};
+class RootLayoutManager : public NodeObserver {
+ public:
+ explicit RootLayoutManager(ViewManager* view_manager,
+ Node* root,
+ Id content_node_id)
+ : root_(root),
+ view_manager_(view_manager),
+ content_node_id_(content_node_id) {}
+ virtual ~RootLayoutManager() {}
+
+ private:
+ // Overridden from NodeObserver
+ virtual void OnNodeBoundsChange(Node* node,
+ const gfx::Rect& /*old_bounds*/,
+ const gfx::Rect& new_bounds,
+ DispositionChangePhase phase) OVERRIDE {
+ if (phase != NodeObserver::DISPOSITION_CHANGED)
+ return;
+ DCHECK_EQ(node, root_);
+ Node* content_node = view_manager_->GetNodeById(content_node_id_);
+ content_node->SetBounds(new_bounds);
+ // TODO(hansmuller): this is just a hack to force a redraw
+ content_node->active_view()->SetColor(SK_ColorBLUE);
+ }
+
+ Node* root_;
+ ViewManager* view_manager_;
+ Id content_node_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
+};
+
class WindowManager : public ApplicationDelegate,
public DebugPanel::Delegate,
public ViewObserver,
@@ -250,9 +283,11 @@ class WindowManager : public ApplicationDelegate,
view_manager_->SetEventDispatcher(this);
Node* node = Node::Create(view_manager);
- view_manager->GetRoots().front()->AddChild(node);
- node->SetBounds(gfx::Rect(800, 600));
+ root->AddChild(node);
+ node->SetBounds(gfx::Rect(root->bounds().size()));
content_node_id_ = node->id();
+ root->AddObserver(new RootLayoutManager(view_manager, root,
+ content_node_id_));
View* view = View::Create(view_manager);
node->SetActiveView(view);
« no previous file with comments | « no previous file | mojo/services/gles2/command_buffer_impl.h » ('j') | mojo/services/native_viewport/native_viewport_x11.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698