summaryrefslogtreecommitdiffstats
path: root/mojo/examples/window_manager
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 17:20:56 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 17:20:56 +0000
commit6c9ceab29f79bc3ad6702408b4125ef2c6e9d375 (patch)
tree728b2e07254dc453b1da2601a3e6261e39022560 /mojo/examples/window_manager
parent94710706b818acd113d6f56c0cdaa787f13b74eb (diff)
downloadchromium_src-6c9ceab29f79bc3ad6702408b4125ef2c6e9d375.zip
chromium_src-6c9ceab29f79bc3ad6702408b4125ef2c6e9d375.tar.gz
chromium_src-6c9ceab29f79bc3ad6702408b4125ef2c6e9d375.tar.bz2
Run input events through a window-manager supplied ViewEventDispatcher so it can implement focus-on-click.
R=sky@chromium.org http://crbug.com/387212 Review URL: https://codereview.chromium.org/348373002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279429 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/examples/window_manager')
-rw-r--r--mojo/examples/window_manager/window_manager.cc18
1 files changed, 16 insertions, 2 deletions
diff --git a/mojo/examples/window_manager/window_manager.cc b/mojo/examples/window_manager/window_manager.cc
index 788d305..55df3c1 100644
--- a/mojo/examples/window_manager/window_manager.cc
+++ b/mojo/examples/window_manager/window_manager.cc
@@ -9,9 +9,11 @@
#include "mojo/public/cpp/application/application.h"
#include "mojo/services/public/cpp/view_manager/node.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"
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h"
#include "mojo/services/public/cpp/view_manager/view_observer.h"
+#include "mojo/services/public/interfaces/input_events/input_events.mojom.h"
#include "mojo/services/public/interfaces/launcher/launcher.mojom.h"
#include "mojo/services/public/interfaces/navigation/navigation.mojom.h"
#include "ui/events/event_constants.h"
@@ -24,6 +26,7 @@ using mojo::view_manager::Id;
using mojo::view_manager::Node;
using mojo::view_manager::NodeObserver;
using mojo::view_manager::View;
+using mojo::view_manager::ViewEventDispatcher;
using mojo::view_manager::ViewManager;
using mojo::view_manager::ViewManagerDelegate;
using mojo::view_manager::ViewObserver;
@@ -75,7 +78,8 @@ class NavigatorHost : public InterfaceImpl<navigation::NavigatorHost> {
class WindowManager : public Application,
public ViewObserver,
- public ViewManagerDelegate {
+ public ViewManagerDelegate,
+ public ViewEventDispatcher {
public:
WindowManager() : launcher_ui_(NULL), view_manager_(NULL) {}
virtual ~WindowManager() {}
@@ -137,6 +141,7 @@ class WindowManager : public Application,
virtual void OnRootAdded(ViewManager* view_manager, Node* root) OVERRIDE {
DCHECK(!view_manager_);
view_manager_ = view_manager;
+ view_manager_->SetEventDispatcher(this);
Node* node = Node::Create(view_manager);
view_manager->GetRoots().front()->AddChild(node);
@@ -151,7 +156,15 @@ class WindowManager : public Application,
CreateLauncherUI();
}
- virtual void OnLaunch(
+ // Overridden from ViewEventDispatcher:
+ virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE {
+ // TODO(beng): More sophisticated focus handling than this is required!
+ if (event->action == ui::ET_MOUSE_PRESSED)
+ target->node()->SetFocus();
+ view_manager_->DispatchEvent(target, event.Pass());
+ }
+
+ void OnLaunch(
uint32 source_node_id,
navigation::Target target,
const mojo::String& handler_url,
@@ -198,6 +211,7 @@ class WindowManager : public Application,
node->AddChild(embedded);
embedded->SetBounds(bounds);
Embed(embedded, url, nav_details.Pass(), response.Pass());
+ embedded->SetFocus();
return embedded;
}