| OLD | NEW | 
|    1 // Copyright 2016 The Chromium Authors. All rights reserved. |    1 // Copyright 2016 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "ash/aura/wm_root_window_controller_aura.h" |    5 #include "ash/aura/wm_root_window_controller_aura.h" | 
|    6  |    6  | 
|    7 #include "ash/aura/wm_shelf_aura.h" |    7 #include "ash/aura/wm_shelf_aura.h" | 
|    8 #include "ash/aura/wm_shell_aura.h" |    8 #include "ash/aura/wm_shell_aura.h" | 
|    9 #include "ash/aura/wm_window_aura.h" |    9 #include "ash/aura/wm_window_aura.h" | 
|   10 #include "ash/common/shelf/shelf.h" |   10 #include "ash/common/shelf/shelf.h" | 
|   11 #include "ash/common/shelf/shelf_widget.h" |   11 #include "ash/common/shelf/shelf_widget.h" | 
|   12 #include "ash/common/wm_root_window_controller_observer.h" |  | 
|   13 #include "ash/display/window_tree_host_manager.h" |   12 #include "ash/display/window_tree_host_manager.h" | 
|   14 #include "ash/root_window_controller.h" |   13 #include "ash/root_window_controller.h" | 
|   15 #include "ash/shell.h" |   14 #include "ash/shell.h" | 
|   16 #include "ui/aura/window.h" |   15 #include "ui/aura/window.h" | 
|   17 #include "ui/aura/window_event_dispatcher.h" |   16 #include "ui/aura/window_event_dispatcher.h" | 
|   18 #include "ui/aura/window_property.h" |   17 #include "ui/aura/window_property.h" | 
|   19 #include "ui/aura/window_tree_host.h" |   18 #include "ui/aura/window_tree_host.h" | 
|   20 #include "ui/display/screen.h" |  | 
|   21 #include "ui/events/event_targeter.h" |   19 #include "ui/events/event_targeter.h" | 
|   22 #include "ui/events/event_utils.h" |   20 #include "ui/events/event_utils.h" | 
|   23  |   21  | 
|   24 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmRootWindowControllerAura*); |   22 DECLARE_WINDOW_PROPERTY_TYPE(ash::WmRootWindowControllerAura*); | 
|   25  |   23  | 
|   26 namespace ash { |   24 namespace ash { | 
|   27  |   25  | 
|   28 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. |   26 // TODO(sky): it likely makes more sense to hang this off RootWindowSettings. | 
|   29 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmRootWindowControllerAura, |   27 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::WmRootWindowControllerAura, | 
|   30                                  kWmRootWindowControllerKey, |   28                                  kWmRootWindowControllerKey, | 
|   31                                  nullptr); |   29                                  nullptr); | 
|   32  |   30  | 
|   33 WmRootWindowControllerAura::WmRootWindowControllerAura( |   31 WmRootWindowControllerAura::WmRootWindowControllerAura( | 
|   34     RootWindowController* root_window_controller) |   32     RootWindowController* root_window_controller) | 
|   35     : WmRootWindowController( |   33     : WmRootWindowController( | 
|   36           WmWindowAura::Get(root_window_controller->GetRootWindow())), |   34           WmWindowAura::Get(root_window_controller->GetRootWindow())), | 
|   37       root_window_controller_(root_window_controller) { |   35       root_window_controller_(root_window_controller) { | 
|   38   root_window_controller_->GetRootWindow()->SetProperty( |   36   root_window_controller_->GetRootWindow()->SetProperty( | 
|   39       kWmRootWindowControllerKey, this); |   37       kWmRootWindowControllerKey, this); | 
|   40   WmShell::Get()->AddShellObserver(this); |  | 
|   41   display::Screen::GetScreen()->AddObserver(this); |  | 
|   42 } |   38 } | 
|   43  |   39  | 
|   44 WmRootWindowControllerAura::~WmRootWindowControllerAura() { |   40 WmRootWindowControllerAura::~WmRootWindowControllerAura() {} | 
|   45   WmShell::Get()->RemoveShellObserver(this); |  | 
|   46   display::Screen::GetScreen()->RemoveObserver(this); |  | 
|   47 } |  | 
|   48  |   41  | 
|   49 // static |   42 // static | 
|   50 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( |   43 const WmRootWindowControllerAura* WmRootWindowControllerAura::Get( | 
|   51     const aura::Window* window) { |   44     const aura::Window* window) { | 
|   52   if (!window) |   45   if (!window) | 
|   53     return nullptr; |   46     return nullptr; | 
|   54  |   47  | 
|   55   RootWindowController* root_window_controller = |   48   RootWindowController* root_window_controller = | 
|   56       GetRootWindowController(window); |   49       GetRootWindowController(window); | 
|   57   if (!root_window_controller) |   50   if (!root_window_controller) | 
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  108                                        ->FindTargetForEvent(root, &test_event); |  101                                        ->FindTargetForEvent(root, &test_event); | 
|  109   return WmWindowAura::Get(static_cast<aura::Window*>(event_handler)); |  102   return WmWindowAura::Get(static_cast<aura::Window*>(event_handler)); | 
|  110 } |  103 } | 
|  111  |  104  | 
|  112 gfx::Point WmRootWindowControllerAura::GetLastMouseLocationInRoot() { |  105 gfx::Point WmRootWindowControllerAura::GetLastMouseLocationInRoot() { | 
|  113   return root_window_controller_->GetHost() |  106   return root_window_controller_->GetHost() | 
|  114       ->dispatcher() |  107       ->dispatcher() | 
|  115       ->GetLastMouseLocationInRoot(); |  108       ->GetLastMouseLocationInRoot(); | 
|  116 } |  109 } | 
|  117  |  110  | 
|  118 void WmRootWindowControllerAura::OnShelfAlignmentChanged( |  | 
|  119     WmWindow* root_window) { |  | 
|  120   if (WmWindowAura::GetAuraWindow(root_window) != |  | 
|  121       root_window_controller_->GetRootWindow()) |  | 
|  122     return; |  | 
|  123  |  | 
|  124   FOR_EACH_OBSERVER(WmRootWindowControllerObserver, *observers(), |  | 
|  125                     OnShelfAlignmentChanged()); |  | 
|  126 } |  | 
|  127  |  | 
|  128 void WmRootWindowControllerAura::OnDisplayAdded( |  | 
|  129     const display::Display& display) {} |  | 
|  130  |  | 
|  131 void WmRootWindowControllerAura::OnDisplayRemoved( |  | 
|  132     const display::Display& display) {} |  | 
|  133  |  | 
|  134 void WmRootWindowControllerAura::OnDisplayMetricsChanged( |  | 
|  135     const display::Display& display, |  | 
|  136     uint32_t metrics) { |  | 
|  137   FOR_EACH_OBSERVER(WmRootWindowControllerObserver, *observers(), |  | 
|  138                     OnWorkAreaChanged()); |  | 
|  139 } |  | 
|  140  |  | 
|  141 }  // namespace ash |  111 }  // namespace ash | 
| OLD | NEW |