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

Unified Diff: examples/window_manager/window_manager.cc

Issue 698543005: Make a pure mojo::View version of the aura::Window FocusController. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sky comments Created 6 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 | « no previous file | examples/wm_flow/wm/frame_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/window_manager/window_manager.cc
diff --git a/examples/window_manager/window_manager.cc b/examples/window_manager/window_manager.cc
index 45c99b468d8122e8b3d3c01957c90e6a6a75bf96..90c63d21fed5fd215e03b0801f4ec2eb5dd42cb0 100644
--- a/examples/window_manager/window_manager.cc
+++ b/examples/window_manager/window_manager.cc
@@ -22,14 +22,14 @@
#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/navigation/navigation.mojom.h"
+#include "mojo/services/window_manager/basic_focus_rules.h"
+#include "mojo/services/window_manager/view_target.h"
#include "mojo/services/window_manager/window_manager_app.h"
#include "mojo/services/window_manager/window_manager_delegate.h"
#include "mojo/views/views_init.h"
-#include "ui/aura/window.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/geometry/size_conversions.h"
-#include "ui/wm/core/focus_rules.h"
#if defined CreateWindow
#undef CreateWindow
@@ -46,64 +46,6 @@ const int kBorderInset = 25;
const int kControlPanelWidth = 200;
const int kTextfieldHeight = 25;
-class WMFocusRules : public wm::FocusRules {
- public:
- WMFocusRules(mojo::WindowManagerApp* window_manager_app,
- mojo::View* window_container)
- : window_container_(window_container),
- window_manager_app_(window_manager_app) {}
- virtual ~WMFocusRules() {}
-
- private:
- // Overridden from wm::FocusRules:
- virtual bool IsToplevelWindow(aura::Window* window) const override {
- return mojo::WindowManagerApp::GetViewForWindow(window)->parent() ==
- window_container_;
- }
- virtual bool CanActivateWindow(aura::Window* window) const override {
- return mojo::WindowManagerApp::GetViewForWindow(window)->parent() ==
- window_container_;
- }
- virtual bool CanFocusWindow(aura::Window* window) const override {
- return true;
- }
- virtual aura::Window* GetToplevelWindow(aura::Window* window) const override {
- mojo::View* view = mojo::WindowManagerApp::GetViewForWindow(window);
- while (view->parent() != window_container_) {
- view = view->parent();
- // Unparented hierarchy, there is no "top level" window.
- if (!view)
- return NULL;
- }
-
- return window_manager_app_->GetWindowForViewId(view->id());
- }
- virtual aura::Window* GetActivatableWindow(
- aura::Window* window) const override {
- return GetToplevelWindow(window);
- }
- virtual aura::Window* GetFocusableWindow(
- aura::Window* window) const override {
- return window;
- }
- virtual aura::Window* GetNextActivatableWindow(
- aura::Window* ignore) const override {
- aura::Window* activatable = GetActivatableWindow(ignore);
- const aura::Window::Windows& children = activatable->parent()->children();
- for (aura::Window::Windows::const_reverse_iterator it = children.rbegin();
- it != children.rend(); ++it) {
- if (*it != ignore)
- return *it;
- }
- return NULL;
- }
-
- mojo::View* window_container_;
- mojo::WindowManagerApp* window_manager_app_;
-
- DISALLOW_COPY_AND_ASSIGN(WMFocusRules);
-};
-
} // namespace
class WindowManagerConnection : public InterfaceImpl<IWindowManager> {
@@ -328,8 +270,10 @@ class WindowManager
virtual ~WindowManager() {
// host() may be destroyed by the time we get here.
// TODO: figure out a way to always cleanly remove handler.
- if (window_manager_app_->host())
- window_manager_app_->host()->window()->RemovePreTargetHandler(this);
+
+ // TODO(erg): In the aura version, we removed ourselves from the
+ // PreTargetHandler list here. We may need to do something analogous when
+ // we get event handling without aura working.
}
void CloseWindow(Id view_id) {
@@ -428,10 +372,13 @@ class WindowManager
control_panel_id));
root->AddObserver(root_layout_manager_.get());
- window_manager_app_->host()->window()->AddPreTargetHandler(this);
+ // TODO(erg): In the aura version, we explicitly added ourselves as a
+ // PreTargetHandler to the window() here. We probably have to do something
+ // analogous here.
- window_manager_app_->InitFocus(new WMFocusRules(window_manager_app_.get(),
- view));
+ window_manager_app_->InitFocus(scoped_ptr<mojo::FocusRules>(
+ new mojo::BasicFocusRules(window_manager_app_.get(),
+ view)));
}
virtual void OnViewManagerDisconnected(ViewManager* view_manager) override {
DCHECK_EQ(view_manager_, view_manager);
@@ -449,8 +396,8 @@ class WindowManager
// Overridden from ui::EventHandler:
virtual void OnEvent(ui::Event* event) override {
- View* view = WindowManagerApp::GetViewForWindow(
- static_cast<aura::Window*>(event->target()));
+ View* view = WindowManagerApp::GetViewForViewTarget(
+ static_cast<ViewTarget*>(event->target()));
if (event->type() == ui::ET_MOUSE_PRESSED &&
!IsDescendantOfKeyboard(view)) {
view->SetFocus();
« no previous file with comments | « no previous file | examples/wm_flow/wm/frame_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698