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

Unified Diff: mojo/services/window_manager/window_manager_app.cc

Issue 599213002: First cut at supporting activation in the window manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / Created 6 years, 3 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 | « mojo/services/window_manager/window_manager_app.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/window_manager/window_manager_app.cc
diff --git a/mojo/services/window_manager/window_manager_app.cc b/mojo/services/window_manager/window_manager_app.cc
index b6fe7efa3cb5ba5ed04d81e6637e8b413dfef896..a22acba0b1c8880beefbf6fb2e2178088cf8f17f 100644
--- a/mojo/services/window_manager/window_manager_app.cc
+++ b/mojo/services/window_manager/window_manager_app.cc
@@ -18,7 +18,6 @@
#include "ui/base/hit_test.h"
#include "ui/wm/core/capture_controller.h"
#include "ui/wm/core/focus_controller.h"
-#include "ui/wm/core/focus_rules.h"
#include "ui/wm/public/activation_client.h"
DECLARE_WINDOW_PROPERTY_TYPE(mojo::View*);
@@ -72,42 +71,6 @@ Id GetIdForWindow(aura::Window* window) {
return window ? WindowManagerApp::GetViewForWindow(window)->id() : 0;
}
-class WMFocusRules : public wm::FocusRules {
- public:
- WMFocusRules() {}
- virtual ~WMFocusRules() {}
-
- private:
- // Overridden from wm::FocusRules:
- virtual bool IsToplevelWindow(aura::Window* window) const MOJO_OVERRIDE {
- return true;
- }
- virtual bool CanActivateWindow(aura::Window* window) const MOJO_OVERRIDE {
- return true;
- }
- virtual bool CanFocusWindow(aura::Window* window) const MOJO_OVERRIDE {
- return true;
- }
- virtual aura::Window* GetToplevelWindow(
- aura::Window* window) const MOJO_OVERRIDE {
- return window;
- }
- virtual aura::Window* GetActivatableWindow(
- aura::Window* window) const MOJO_OVERRIDE {
- return window;
- }
- virtual aura::Window* GetFocusableWindow(
- aura::Window* window) const MOJO_OVERRIDE {
- return window;
- }
- virtual aura::Window* GetNextActivatableWindow(
- aura::Window* ignore) const MOJO_OVERRIDE {
- return NULL;
- }
-
- DISALLOW_COPY_AND_ASSIGN(WMFocusRules);
-};
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -131,6 +94,11 @@ View* WindowManagerApp::GetViewForWindow(aura::Window* window) {
return window->GetProperty(kViewKey);
}
+aura::Window* WindowManagerApp::GetWindowForViewId(Id view) {
+ ViewIdToWindowMap::const_iterator it = view_id_to_window_map_.find(view);
+ return it != view_id_to_window_map_.end() ? it->second : NULL;
+}
+
void WindowManagerApp::AddConnection(WindowManagerServiceImpl* connection) {
DCHECK(connections_.find(connection) == connections_.end());
connections_.insert(connection);
@@ -163,6 +131,18 @@ bool WindowManagerApp::IsReady() const {
return view_manager_ && root_;
}
+void WindowManagerApp::InitFocus(wm::FocusRules* rules) {
+ wm::FocusController* focus_controller = new wm::FocusController(rules);
+ activation_client_ = focus_controller;
+ focus_client_.reset(focus_controller);
+ aura::client::SetFocusClient(window_tree_host_->window(), focus_controller);
+ aura::client::SetActivationClient(window_tree_host_->window(),
+ focus_controller);
+
+ focus_client_->AddObserver(this);
+ activation_client_->AddObserver(this);
+}
+
////////////////////////////////////////////////////////////////////////////////
// WindowManagerApp, ApplicationDelegate implementation:
@@ -199,14 +179,6 @@ void WindowManagerApp::OnEmbed(ViewManager* view_manager,
capture_client_.reset(
new wm::ScopedCaptureClient(window_tree_host_->window()));
- wm::FocusController* focus_controller =
- new wm::FocusController(new WMFocusRules);
- activation_client_ = focus_controller;
- focus_client_.reset(focus_controller);
- aura::client::SetFocusClient(window_tree_host_->window(), focus_controller);
-
- focus_client_->AddObserver(this);
- activation_client_->AddObserver(this);
if (wrapped_view_manager_delegate_) {
wrapped_view_manager_delegate_->OnEmbed(
@@ -327,16 +299,15 @@ void WindowManagerApp::OnWindowActivated(aura::Window* gained_active,
(*it)->NotifyWindowActivated(GetIdForWindow(gained_active),
GetIdForWindow(lost_active));
}
+ if (gained_active) {
+ View* view = GetViewForWindow(gained_active);
+ view->MoveToFront();
+ }
}
////////////////////////////////////////////////////////////////////////////////
// WindowManagerApp, private:
-aura::Window* WindowManagerApp::GetWindowForViewId(Id view) const {
- ViewIdToWindowMap::const_iterator it = view_id_to_window_map_.find(view);
- return it != view_id_to_window_map_.end() ? it->second : NULL;
-}
-
void WindowManagerApp::RegisterSubtree(View* view, aura::Window* parent) {
view->AddObserver(this);
DCHECK(view_id_to_window_map_.find(view->id()) ==
« no previous file with comments | « mojo/services/window_manager/window_manager_app.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698