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

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: fixed double-notification for node bounds changes Created 6 years, 5 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 | « no previous file | mojo/services/gles2/command_buffer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5f1e8439f1b007a4a2d1278690f27063303581ef 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,36 @@ 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 OnNodeBoundsChanged(Node* node,
+ const gfx::Rect& /*old_bounds*/,
+ const gfx::Rect& new_bounds) OVERRIDE {
+ DCHECK_EQ(node, root_);
+ Node* content_node = view_manager_->GetNodeById(content_node_id_);
+ content_node->SetBounds(new_bounds);
+ // Force the view's bitmap to be recreated
+ content_node->active_view()->SetColor(SK_ColorBLUE);
+ // TODO(hansmuller): Do Layout
+ }
+
+ Node* root_;
+ ViewManager* view_manager_;
+ Id content_node_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(RootLayoutManager);
+};
+
class WindowManager : public ApplicationDelegate,
public DebugPanel::Delegate,
public ViewObserver,
@@ -250,10 +281,14 @@ 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_layout_manager_.reset(
+ new RootLayoutManager(view_manager, root, content_node_id_));
+ root->AddObserver(root_layout_manager_.get());
+
View* view = View::Create(view_manager);
node->SetActiveView(view);
view->SetColor(SK_ColorBLUE);
@@ -395,6 +430,7 @@ class WindowManager : public ApplicationDelegate,
Node* launcher_ui_;
std::vector<Node*> windows_;
ViewManager* view_manager_;
+ scoped_ptr<RootLayoutManager> root_layout_manager_;
// Id of the node most content is added to. The keyboard is NOT added here.
Id content_node_id_;
« no previous file with comments | « no previous file | mojo/services/gles2/command_buffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698