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

Unified Diff: mojo/services/window_manager/focus_controller.h

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: Restore things lost from a deleted use_aura block in BUILD.gn files. 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
Index: mojo/services/window_manager/focus_controller.h
diff --git a/mojo/services/window_manager/focus_controller.h b/mojo/services/window_manager/focus_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..35d172570b8e2dc4bb8f6588d0d583d22cc81785
--- /dev/null
+++ b/mojo/services/window_manager/focus_controller.h
@@ -0,0 +1,99 @@
+// Copyright 2014 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.
+
+#ifndef MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_
+#define MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_
+
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+#include "base/scoped_observer.h"
+#include "mojo/services/public/cpp/view_manager/view_observer.h"
+#include "ui/events/event_handler.h"
+
+namespace mojo {
+
+class FocusControllerObserver;
+class FocusRules;
+
+// TODO: Maybe write a better comments.
sky 2014/11/10 20:45:30 At least write a description for the class.
+
+class FocusController : public ui::EventHandler,
+ public ViewObserver {
+ public:
+ // |rules| cannot be NULL.
+ explicit FocusController(FocusRules* rules);
+ virtual ~FocusController();
+
+ void AddObserver(FocusControllerObserver* observer);
+ void RemoveObserver(FocusControllerObserver* observer);
+
+ void ActivateView(View* view);
+ void DeactivateView(View* view);
+ View* GetActiveView();
+ View* GetActivatableView(View* view);
+ View* GetToplevelView(View* view);
+ bool CanActivateView(View* view) const;
+
+ void FocusView(View* view);
+
+ void ResetFocusWithinActiveView(View* view);
+ View* GetFocusedView();
+
+ // Overridden from ui::EventHandler:
+ void OnKeyEvent(ui::KeyEvent* event) override;
+ void OnMouseEvent(ui::MouseEvent* event) override;
+ void OnScrollEvent(ui::ScrollEvent* event) override;
+ void OnTouchEvent(ui::TouchEvent* event) override;
+ void OnGestureEvent(ui::GestureEvent* event) override;
+
+ // Overridden from ViewObserver:
+ void OnTreeChanging(const TreeChangeParams& params) override;
+ void OnTreeChanged(const TreeChangeParams& params) override;
+ void OnViewVisibilityChanged(View* view) override;
+ void OnViewDestroying(View* view) override;
+
+ private:
+
sky 2014/11/10 20:45:30 nit: generally no newline here.
+ // Internal implementation that sets the focused view, fires events etc.
+ // This function must be called with a valid focusable view.
+ void SetFocusedView(View* view);
+
+ // Internal implementation that sets the active window, fires events etc.
+ // This function must be called with a valid |activatable_window|.
+ // |requested window| refers to the window that was passed in to an external
+ // request (e.g. FocusWindow or ActivateWindow). It may be NULL, e.g. if
+ // SetActiveWindow was not called by an external request. |activatable_window|
+ // refers to the actual window to be activated, which may be different.
+ void SetActiveView(View* requested_view,
+ View* activatable_view);
+
+ // Called when a window's disposition changed such that it and its hierarchy
+ // are no longer focusable/activatable. |next| is a valid window that is used
+ // as a starting point for finding a window to focus next based on rules.
+ void ViewLostFocusFromDispositionChange(View* view, View* next);
+
+ // Called when an attempt is made to focus or activate a window via an input
+ // event targeted at that window. Rules determine the best focusable window
+ // for the input window.
+ void ViewFocusedFromInputEvent(View* view);
+
+ View* active_view_;
+ View* focused_view_;
+
+ bool updating_focus_;
+ bool updating_activation_;
+
+ scoped_ptr<FocusRules> rules_;
+
+ ObserverList<FocusControllerObserver> focus_controller_observers_;
+
+ ScopedObserver<View, ViewObserver> observer_manager_;
+
+ DISALLOW_COPY_AND_ASSIGN(FocusController);
+};
+
+} // namespace mojo
+
+#endif // MOJO_SERIVCES_WINDOW_MANAGER_FOCUS_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698