OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/exo/wm_helper_ash.h" |
| 6 |
| 7 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 8 #include "ash/common/wm_shell.h" |
| 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/shell.h" |
| 11 #include "base/memory/singleton.h" |
| 12 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/wm/public/activation_client.h" |
| 14 |
| 15 namespace exo { |
| 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // WMHelperAsh, public: |
| 19 |
| 20 WMHelperAsh::WMHelperAsh() { |
| 21 ash::WmShell::Get()->AddShellObserver(this); |
| 22 ash::Shell::GetInstance()->activation_client()->AddObserver(this); |
| 23 aura::client::FocusClient* focus_client = |
| 24 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 25 focus_client->AddObserver(this); |
| 26 } |
| 27 |
| 28 WMHelperAsh::~WMHelperAsh() { |
| 29 if (!ash::Shell::HasInstance()) |
| 30 return; |
| 31 aura::client::FocusClient* focus_client = |
| 32 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 33 focus_client->RemoveObserver(this); |
| 34 ash::Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 35 ash::WmShell::Get()->RemoveShellObserver(this); |
| 36 } |
| 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// |
| 39 // WMHelperAsh, private: |
| 40 |
| 41 const ash::DisplayInfo WMHelperAsh::GetDisplayInfo(int64_t display_id) const { |
| 42 return ash::Shell::GetInstance()->display_manager()->GetDisplayInfo( |
| 43 display_id); |
| 44 } |
| 45 |
| 46 aura::Window* WMHelperAsh::GetContainer(int container_id) { |
| 47 return ash::Shell::GetContainer(ash::Shell::GetTargetRootWindow(), |
| 48 container_id); |
| 49 } |
| 50 |
| 51 aura::Window* WMHelperAsh::GetActiveWindow() const { |
| 52 return ash::Shell::GetInstance()->activation_client()->GetActiveWindow(); |
| 53 } |
| 54 |
| 55 aura::Window* WMHelperAsh::GetFocusedWindow() const { |
| 56 aura::client::FocusClient* focus_client = |
| 57 aura::client::GetFocusClient(ash::Shell::GetPrimaryRootWindow()); |
| 58 return focus_client->GetFocusedWindow(); |
| 59 } |
| 60 |
| 61 ui::CursorSetType WMHelperAsh::GetCursorSet() const { |
| 62 return ash::Shell::GetInstance()->cursor_manager()->GetCursorSet(); |
| 63 } |
| 64 |
| 65 void WMHelperAsh::AddPreTargetHandler(ui::EventHandler* handler) { |
| 66 ash::Shell::GetInstance()->AddPreTargetHandler(handler); |
| 67 } |
| 68 |
| 69 void WMHelperAsh::PrependPreTargetHandler(ui::EventHandler* handler) { |
| 70 ash::Shell::GetInstance()->PrependPreTargetHandler(handler); |
| 71 } |
| 72 |
| 73 void WMHelperAsh::RemovePreTargetHandler(ui::EventHandler* handler) { |
| 74 ash::Shell::GetInstance()->RemovePreTargetHandler(handler); |
| 75 } |
| 76 |
| 77 void WMHelperAsh::AddPostTargetHandler(ui::EventHandler* handler) { |
| 78 ash::Shell::GetInstance()->AddPostTargetHandler(handler); |
| 79 } |
| 80 |
| 81 void WMHelperAsh::RemovePostTargetHandler(ui::EventHandler* handler) { |
| 82 ash::Shell::GetInstance()->RemovePostTargetHandler(handler); |
| 83 } |
| 84 |
| 85 bool WMHelperAsh::IsMaximizeModeWindowManagerEnabled() const { |
| 86 return ash::WmShell::Get() |
| 87 ->maximize_mode_controller() |
| 88 ->IsMaximizeModeWindowManagerEnabled(); |
| 89 } |
| 90 |
| 91 void WMHelperAsh::OnWindowActivated( |
| 92 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 93 aura::Window* gained_active, |
| 94 aura::Window* lost_active) { |
| 95 NotifyWindowActivated(gained_active, lost_active); |
| 96 } |
| 97 |
| 98 void WMHelperAsh::OnWindowFocused(aura::Window* gained_focus, |
| 99 aura::Window* lost_focus) { |
| 100 NotifyWindowFocused(gained_focus, lost_focus); |
| 101 } |
| 102 |
| 103 void WMHelperAsh::OnCursorVisibilityChanged(bool is_visible) { |
| 104 NotifyCursorVisibilityChanged(is_visible); |
| 105 } |
| 106 |
| 107 void WMHelperAsh::OnCursorSetChanged(ui::CursorSetType cursor_set) { |
| 108 NotifyCursorSetChanged(cursor_set); |
| 109 } |
| 110 |
| 111 void WMHelperAsh::OnMaximizeModeStarted() { |
| 112 NotifyMaximizeModeStarted(); |
| 113 } |
| 114 |
| 115 void WMHelperAsh::OnMaximizeModeEnded() { |
| 116 NotifyMaximizeModeEnded(); |
| 117 } |
| 118 |
| 119 } // namespace exo |
OLD | NEW |