ben | 294d04b | 2015-10-15 01:23:33 | [diff] [blame] | 1 | // Copyright 2015 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 | |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 5 | #include "ash/window_manager.h" |
ben | 294d04b | 2015-10-15 01:23:33 | [diff] [blame] | 6 | |
avi | 703dbbf | 2015-12-22 01:46:28 | [diff] [blame] | 7 | #include <stdint.h> |
mostynb | 1aaf506 | 2016-04-04 17:56:27 | [diff] [blame] | 8 | |
xiyuan | 317fdbe | 2017-05-31 15:02:02 | [diff] [blame] | 9 | #include <limits> |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 10 | #include <memory> |
dcheng | e4860045 | 2015-12-28 02:24:50 | [diff] [blame] | 11 | #include <utility> |
avi | 703dbbf | 2015-12-22 01:46:28 | [diff] [blame] | 12 | |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 13 | #include "ash/accelerators/accelerator_handler.h" |
| 14 | #include "ash/accelerators/accelerator_ids.h" |
Michael Wasserman | 625b738 | 2017-12-13 16:34:32 | [diff] [blame] | 15 | #include "ash/display/window_tree_host_manager.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 16 | #include "ash/drag_drop/drag_image_view.h" |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 17 | #include "ash/event_matcher_util.h" |
Michael Wasserman | 625b738 | 2017-12-13 16:34:32 | [diff] [blame] | 18 | #include "ash/host/ash_window_tree_host.h" |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 19 | #include "ash/public/cpp/config.h" |
erg | 19e1e200 | 2017-02-24 23:24:12 | [diff] [blame] | 20 | #include "ash/public/cpp/shelf_types.h" |
penghuang | e52cb19 | 2017-04-05 00:54:40 | [diff] [blame] | 21 | #include "ash/public/cpp/window_pin_type.h" |
msw | 8329bfa3 | 2017-02-02 19:34:53 | [diff] [blame] | 22 | #include "ash/public/cpp/window_properties.h" |
Elliot Glaysher | 47f02ca | 2017-09-23 02:08:04 | [diff] [blame] | 23 | #include "ash/public/cpp/window_state_type.h" |
Elliot Glaysher | 247b763 | 2017-10-25 03:02:09 | [diff] [blame] | 24 | #include "ash/public/interfaces/window_actions.mojom.h" |
penghuang | e52cb19 | 2017-04-05 00:54:40 | [diff] [blame] | 25 | #include "ash/public/interfaces/window_pin_type.mojom.h" |
Elliot Glaysher | c1bfc6f9 | 2017-11-01 20:44:48 | [diff] [blame] | 26 | #include "ash/public/interfaces/window_properties.mojom.h" |
Elliot Glaysher | 47f02ca | 2017-09-23 02:08:04 | [diff] [blame] | 27 | #include "ash/public/interfaces/window_state_type.mojom.h" |
sky | b664383 | 2017-01-11 22:08:45 | [diff] [blame] | 28 | #include "ash/root_window_controller.h" |
sky | 8a8ffd2 | 2017-01-19 15:55:29 | [diff] [blame] | 29 | #include "ash/root_window_settings.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 30 | #include "ash/session/session_controller.h" |
sky | 00f98a37 | 2017-01-11 06:03:49 | [diff] [blame] | 31 | #include "ash/shell.h" |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 32 | #include "ash/shell_delegate_mus.h" |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 33 | #include "ash/shell_init_params.h" |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 34 | #include "ash/shell_port_mash.h" |
| 35 | #include "ash/shell_port_mus.h" |
Peng Huang | 87a65cd | 2017-10-06 15:21:47 | [diff] [blame] | 36 | #include "ash/wayland/wayland_server_controller.h" |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 37 | #include "ash/wm/ash_focus_rules.h" |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 38 | #include "ash/wm/move_event_handler.h" |
| 39 | #include "ash/wm/non_client_frame_controller.h" |
| 40 | #include "ash/wm/property_util.h" |
Elliot Glaysher | 247b763 | 2017-10-25 03:02:09 | [diff] [blame] | 41 | #include "ash/wm/tablet_mode/tablet_mode_controller.h" |
Scott Violet | 4c79b0d | 2017-11-17 21:47:13 | [diff] [blame] | 42 | #include "ash/wm/top_level_window_factory.h" |
Elliot Glaysher | b372ee5 | 2017-11-09 19:34:13 | [diff] [blame] | 43 | #include "ash/wm/window_properties.h" |
James Cook | b0bf8e8 | 2017-04-09 17:01:44 | [diff] [blame] | 44 | #include "ash/wm/window_state.h" |
kylechar | a06c6ea4 | 2016-10-21 17:35:04 | [diff] [blame] | 45 | #include "services/service_manager/public/cpp/connector.h" |
thanhph | 62cbfb83 | 2016-12-03 01:08:03 | [diff] [blame] | 46 | #include "services/ui/common/accelerator_util.h" |
ben | 6b0453d1 | 2016-07-02 04:27:19 | [diff] [blame] | 47 | #include "services/ui/common/types.h" |
sky | 83b1bb1 | 2017-04-24 20:29:28 | [diff] [blame] | 48 | #include "services/ui/public/cpp/input_devices/input_device_client.h" |
ben | 6b0453d1 | 2016-07-02 04:27:19 | [diff] [blame] | 49 | #include "services/ui/public/cpp/property_type_converters.h" |
ben | 06065b6 | 2016-11-16 06:29:50 | [diff] [blame] | 50 | #include "services/ui/public/interfaces/constants.mojom.h" |
ben | 6b0453d1 | 2016-07-02 04:27:19 | [diff] [blame] | 51 | #include "services/ui/public/interfaces/window_manager.mojom.h" |
moshayedi | 92b3b48 | 2017-03-21 20:27:46 | [diff] [blame] | 52 | #include "ui/aura/client/aura_constants.h" |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 53 | #include "ui/aura/client/window_parenting_client.h" |
| 54 | #include "ui/aura/env.h" |
riajiang | f6a5c39 | 2017-02-02 17:37:48 | [diff] [blame] | 55 | #include "ui/aura/mus/capture_synchronizer.h" |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 56 | #include "ui/aura/mus/property_converter.h" |
| 57 | #include "ui/aura/mus/window_tree_client.h" |
| 58 | #include "ui/aura/mus/window_tree_host_mus.h" |
| 59 | #include "ui/aura/window.h" |
kylixrd | 61e45cf | 2017-01-30 19:52:53 | [diff] [blame] | 60 | #include "ui/base/class_property.h" |
erg | 6ed29f6 | 2016-07-08 20:10:40 | [diff] [blame] | 61 | #include "ui/base/hit_test.h" |
sky | 3e56abe | 2016-09-29 19:38:21 | [diff] [blame] | 62 | #include "ui/display/display_observer.h" |
moshayedi | b1637da1 | 2016-06-13 15:32:48 | [diff] [blame] | 63 | #include "ui/events/mojo/event.mojom.h" |
sky | a4477cb3 | 2017-01-04 05:04:35 | [diff] [blame] | 64 | #include "ui/views/mus/pointer_watcher_event_router.h" |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 65 | #include "ui/wm/core/capture_controller.h" |
sky | 5c71eb34 | 2017-02-15 19:39:25 | [diff] [blame] | 66 | #include "ui/wm/core/shadow_types.h" |
Scott Violet | 0f803d05 | 2017-08-04 18:24:42 | [diff] [blame] | 67 | #include "ui/wm/core/window_animations.h" |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 68 | #include "ui/wm/core/wm_state.h" |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 69 | #include "ui/wm/public/activation_client.h" |
sky | d4ca12f | 2015-10-28 18:22:26 | [diff] [blame] | 70 | |
msw | 5e048a7 | 2016-09-07 18:55:30 | [diff] [blame] | 71 | namespace ash { |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 72 | |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 73 | struct WindowManager::DragState { |
| 74 | // An image representation of the contents of the current drag and drop |
| 75 | // clipboard. |
| 76 | std::unique_ptr<ash::DragImageView> view; |
| 77 | |
| 78 | // The cursor offset of the dragged item. |
| 79 | gfx::Vector2d image_offset; |
| 80 | }; |
| 81 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 82 | // TODO: need to register OSExchangeDataProviderMus. http://crbug.com/665077. |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 83 | WindowManager::WindowManager(service_manager::Connector* connector, |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 84 | Config config, |
| 85 | bool show_primary_host_on_connect) |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 86 | : connector_(connector), |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 87 | config_(config), |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 88 | show_primary_host_on_connect_(show_primary_host_on_connect), |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 89 | wm_state_(std::make_unique<::wm::WMState>()), |
| 90 | property_converter_(std::make_unique<aura::PropertyConverter>()) { |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 91 | property_converter_->RegisterPrimitiveProperty( |
Elliot Glaysher | b372ee5 | 2017-11-09 19:34:13 | [diff] [blame] | 92 | kCanConsumeSystemKeysKey, ash::mojom::kCanConsumeSystemKeys_Property, |
| 93 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 94 | property_converter_->RegisterPrimitiveProperty( |
James Cook | 2eed987 | 2017-11-14 21:08:54 | [diff] [blame] | 95 | aura::client::kDrawAttentionKey, |
| 96 | ui::mojom::WindowManager::kDrawAttention_Property, |
| 97 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 98 | property_converter_->RegisterPrimitiveProperty( |
erg | 19e1e200 | 2017-02-24 23:24:12 | [diff] [blame] | 99 | kPanelAttachedKey, ui::mojom::WindowManager::kPanelAttached_Property, |
| 100 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 101 | property_converter_->RegisterPrimitiveProperty( |
sky | 50261ac | 2016-12-07 17:14:52 | [diff] [blame] | 102 | kRenderTitleAreaProperty, |
erg | 19e1e200 | 2017-02-24 23:24:12 | [diff] [blame] | 103 | ui::mojom::WindowManager::kRenderParentTitleArea_Property, |
| 104 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 105 | property_converter_->RegisterPrimitiveProperty( |
erg | 19e1e200 | 2017-02-24 23:24:12 | [diff] [blame] | 106 | kShelfItemTypeKey, ui::mojom::WindowManager::kShelfItemType_Property, |
| 107 | base::Bind(&IsValidShelfItemType)); |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 108 | property_converter_->RegisterPrimitiveProperty( |
sky | 5c71eb34 | 2017-02-15 19:39:25 | [diff] [blame] | 109 | ::wm::kShadowElevationKey, |
erg | 19e1e200 | 2017-02-24 23:24:12 | [diff] [blame] | 110 | ui::mojom::WindowManager::kShadowElevation_Property, |
Trent Apted | 280f4ff | 2018-02-07 07:11:53 | [diff] [blame] | 111 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 112 | property_converter_->RegisterPrimitiveProperty( |
Elliot Glaysher | 47f02ca | 2017-09-23 02:08:04 | [diff] [blame] | 113 | kWindowStateTypeKey, mojom::kWindowStateType_Property, |
| 114 | base::Bind(&ash::IsValidWindowStateType)); |
| 115 | property_converter_->RegisterPrimitiveProperty( |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 116 | kWindowPinTypeKey, ash::mojom::kWindowPinType_Property, |
| 117 | base::Bind(&ash::IsValidWindowPinType)); |
Elliot Glaysher | c1bfc6f9 | 2017-11-01 20:44:48 | [diff] [blame] | 118 | property_converter_->RegisterPrimitiveProperty( |
| 119 | kWindowPositionManagedTypeKey, |
| 120 | ash::mojom::kWindowPositionManaged_Property, |
| 121 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
msw | e6975c7 | 2017-05-16 23:07:05 | [diff] [blame] | 122 | property_converter_->RegisterStringProperty( |
| 123 | kShelfIDKey, ui::mojom::WindowManager::kShelfID_Property); |
Maksim Sisov | a00b71f | 2018-02-22 10:43:24 | [diff] [blame] | 124 | property_converter_->RegisterPrimitiveProperty( |
| 125 | kRestoreBoundsOverrideKey, ash::mojom::kRestoreBoundsOverride_Property, |
| 126 | aura::PropertyConverter::CreateAcceptAnyValueCallback()); |
| 127 | property_converter_->RegisterPrimitiveProperty( |
| 128 | kRestoreWindowStateTypeOverrideKey, |
| 129 | ash::mojom::kRestoreWindowStateTypeOverride_Property, |
| 130 | base::BindRepeating(&ash::IsValidWindowStateType)); |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 131 | } |
sadrul | 0a064b9 | 2016-04-22 17:36:50 | [diff] [blame] | 132 | |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 133 | WindowManager::~WindowManager() { |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 134 | Shutdown(); |
sky | 00f98a37 | 2017-01-11 06:03:49 | [diff] [blame] | 135 | ash::Shell::set_window_tree_client(nullptr); |
sky | a8b222f | 2017-01-12 15:47:13 | [diff] [blame] | 136 | ash::Shell::set_window_manager_client(nullptr); |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 137 | } |
sky | 8208371 | 2016-06-06 18:17:32 | [diff] [blame] | 138 | |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 139 | void WindowManager::Init( |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 140 | std::unique_ptr<aura::WindowTreeClient> window_tree_client, |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 141 | std::unique_ptr<ShellDelegate> shell_delegate) { |
sky | 83b1bb1 | 2017-04-24 20:29:28 | [diff] [blame] | 142 | // Only create InputDeviceClient in MASH mode. For MUS mode WindowManager is |
| 143 | // created by chrome, which creates InputDeviceClient. |
Scott Violet | 361833fb | 2017-06-21 22:25:20 | [diff] [blame] | 144 | if (config_ == Config::MASH) { |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 145 | input_device_client_ = std::make_unique<ui::InputDeviceClient>(); |
Elliot Glaysher | 8e6b846 | 2017-07-27 17:37:12 | [diff] [blame] | 146 | |
| 147 | // |connector_| can be nullptr in tests. |
| 148 | if (connector_) { |
| 149 | ui::mojom::InputDeviceServerPtr server; |
| 150 | connector_->BindInterface(ui::mojom::kServiceName, &server); |
| 151 | input_device_client_->Connect(std::move(server)); |
| 152 | } |
Scott Violet | 361833fb | 2017-06-21 22:25:20 | [diff] [blame] | 153 | } else { |
| 154 | // In Config::MUS ash handles all drag and drop. |
| 155 | window_tree_client->DisableDragDropClient(); |
| 156 | } |
sky | 83b1bb1 | 2017-04-24 20:29:28 | [diff] [blame] | 157 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 158 | DCHECK(window_manager_client_); |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 159 | DCHECK(!window_tree_client_); |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 160 | window_tree_client_ = std::move(window_tree_client); |
sky | 8208371 | 2016-06-06 18:17:32 | [diff] [blame] | 161 | |
sky | 00f98a37 | 2017-01-11 06:03:49 | [diff] [blame] | 162 | DCHECK_EQ(nullptr, ash::Shell::window_tree_client()); |
| 163 | ash::Shell::set_window_tree_client(window_tree_client_.get()); |
| 164 | |
James Cook | 3d788f5 | 2017-10-28 00:07:54 | [diff] [blame] | 165 | // TODO(jamescook): Maybe not needed in Config::MUS? |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 166 | pointer_watcher_event_router_ = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 167 | std::make_unique<views::PointerWatcherEventRouter>( |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 168 | window_tree_client_.get()); |
sky | 1cbe9486 | 2016-08-12 19:48:17 | [diff] [blame] | 169 | |
riajiang | f6a5c39 | 2017-02-02 17:37:48 | [diff] [blame] | 170 | // Notify PointerWatcherEventRouter and CaptureSynchronizer that the capture |
| 171 | // client has been set. |
| 172 | aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); |
| 173 | pointer_watcher_event_router_->AttachToCaptureClient(capture_client); |
| 174 | window_tree_client_->capture_synchronizer()->AttachToCaptureClient( |
| 175 | capture_client); |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 176 | |
| 177 | if (shell_delegate) |
| 178 | shell_delegate_ = std::move(shell_delegate); |
Elliot Glaysher | ce74024 | 2017-07-17 19:09:17 | [diff] [blame] | 179 | |
| 180 | InitCursorOnKeyList(); |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 181 | } |
| 182 | |
sky | 01c007b | 2017-04-28 15:48:46 | [diff] [blame] | 183 | void WindowManager::SetLostConnectionCallback(base::OnceClosure closure) { |
| 184 | lost_connection_callback_ = std::move(closure); |
| 185 | } |
| 186 | |
sky | 494c6cbd | 2017-03-27 20:57:48 | [diff] [blame] | 187 | bool WindowManager::WaitForInitialDisplays() { |
| 188 | return window_manager_client_->WaitForInitialDisplays(); |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 189 | } |
| 190 | |
sky | 853669a | 2016-07-22 18:43:12 | [diff] [blame] | 191 | bool WindowManager::GetNextAcceleratorNamespaceId(uint16_t* id) { |
| 192 | if (accelerator_handlers_.size() == std::numeric_limits<uint16_t>::max()) |
| 193 | return false; |
| 194 | while (accelerator_handlers_.count(next_accelerator_namespace_id_) > 0) |
| 195 | ++next_accelerator_namespace_id_; |
| 196 | *id = next_accelerator_namespace_id_; |
| 197 | ++next_accelerator_namespace_id_; |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | void WindowManager::AddAcceleratorHandler(uint16_t id_namespace, |
| 202 | AcceleratorHandler* handler) { |
| 203 | DCHECK_EQ(0u, accelerator_handlers_.count(id_namespace)); |
| 204 | accelerator_handlers_[id_namespace] = handler; |
| 205 | } |
| 206 | |
| 207 | void WindowManager::RemoveAcceleratorHandler(uint16_t id_namespace) { |
| 208 | accelerator_handlers_.erase(id_namespace); |
| 209 | } |
| 210 | |
kylechar | a06c6ea4 | 2016-10-21 17:35:04 | [diff] [blame] | 211 | display::mojom::DisplayController* WindowManager::GetDisplayController() { |
| 212 | return display_controller_ ? display_controller_.get() : nullptr; |
| 213 | } |
| 214 | |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 215 | void WindowManager::CreateShell() { |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 216 | DCHECK(!created_shell_); |
| 217 | created_shell_ = true; |
| 218 | ShellInitParams init_params; |
James Cook | 3d788f5 | 2017-10-28 00:07:54 | [diff] [blame] | 219 | if (config_ == Config::MUS) { |
Scott Violet | c8a1c6c | 2017-11-29 23:17:36 | [diff] [blame] | 220 | init_params.shell_port = std::make_unique<ShellPortMus>(this); |
James Cook | 3d788f5 | 2017-10-28 00:07:54 | [diff] [blame] | 221 | } else { |
Scott Violet | c8a1c6c | 2017-11-29 23:17:36 | [diff] [blame] | 222 | init_params.shell_port = std::make_unique<ShellPortMash>( |
| 223 | this, pointer_watcher_event_router_.get()); |
James Cook | 3d788f5 | 2017-10-28 00:07:54 | [diff] [blame] | 224 | } |
Scott Violet | c8a1c6c | 2017-11-29 23:17:36 | [diff] [blame] | 225 | init_params.delegate = shell_delegate_ |
| 226 | ? std::move(shell_delegate_) |
| 227 | : std::make_unique<ShellDelegateMus>(connector_); |
| 228 | Shell::CreateInstance(std::move(init_params)); |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 229 | } |
| 230 | |
Elliot Glaysher | ce74024 | 2017-07-17 19:09:17 | [diff] [blame] | 231 | void WindowManager::InitCursorOnKeyList() { |
| 232 | DCHECK(window_manager_client_); |
| 233 | if (config_ == Config::MASH) { |
| 234 | // In Mash, we build a list of keys and send them to the window |
| 235 | // server. This controls which keys *don't* hide the cursors. |
| 236 | |
| 237 | // TODO(erg): This needs to also check the case of the accessibility |
| 238 | // keyboard being shown, since clicking a key on the keyboard shouldn't |
| 239 | // hide the cursor. |
| 240 | std::vector<ui::mojom::EventMatcherPtr> cursor_key_list; |
| 241 | cursor_key_list.push_back(BuildKeyReleaseMatcher()); |
| 242 | cursor_key_list.push_back(BuildAltMatcher()); |
| 243 | cursor_key_list.push_back(BuildControlMatcher()); |
| 244 | |
| 245 | BuildKeyMatcherRange(ui::mojom::KeyboardCode::F1, |
| 246 | ui::mojom::KeyboardCode::F24, &cursor_key_list); |
| 247 | BuildKeyMatcherRange(ui::mojom::KeyboardCode::BROWSER_BACK, |
| 248 | ui::mojom::KeyboardCode::MEDIA_LAUNCH_APP2, |
| 249 | &cursor_key_list); |
| 250 | BuildKeyMatcherList( |
| 251 | {ui::mojom::KeyboardCode::SHIFT, ui::mojom::KeyboardCode::CONTROL, |
| 252 | ui::mojom::KeyboardCode::MENU, |
| 253 | ui::mojom::KeyboardCode::LWIN, // Search key == VKEY_LWIN. |
| 254 | ui::mojom::KeyboardCode::WLAN, ui::mojom::KeyboardCode::POWER, |
| 255 | ui::mojom::KeyboardCode::BRIGHTNESS_DOWN, |
| 256 | ui::mojom::KeyboardCode::BRIGHTNESS_UP, |
| 257 | ui::mojom::KeyboardCode::KBD_BRIGHTNESS_DOWN, |
| 258 | ui::mojom::KeyboardCode::KBD_BRIGHTNESS_UP}, |
| 259 | &cursor_key_list); |
| 260 | |
| 261 | window_manager_client_->SetKeyEventsThatDontHideCursor( |
| 262 | std::move(cursor_key_list)); |
| 263 | } |
| 264 | } |
| 265 | |
sky | 2771709 | 2017-05-26 19:04:06 | [diff] [blame] | 266 | void WindowManager::InstallFrameDecorationValues() { |
| 267 | ui::mojom::FrameDecorationValuesPtr frame_decoration_values = |
| 268 | ui::mojom::FrameDecorationValues::New(); |
| 269 | const gfx::Insets client_area_insets = |
| 270 | NonClientFrameController::GetPreferredClientAreaInsets(); |
| 271 | frame_decoration_values->normal_client_area_insets = client_area_insets; |
| 272 | frame_decoration_values->maximized_client_area_insets = client_area_insets; |
| 273 | frame_decoration_values->max_title_bar_button_width = |
| 274 | NonClientFrameController::GetMaxTitleBarButtonWidth(); |
| 275 | window_manager_client_->SetFrameDecorationValues( |
| 276 | std::move(frame_decoration_values)); |
| 277 | } |
| 278 | |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 279 | void WindowManager::Shutdown() { |
| 280 | if (!window_tree_client_) |
| 281 | return; |
| 282 | |
riajiang | f6a5c39 | 2017-02-02 17:37:48 | [diff] [blame] | 283 | aura::client::CaptureClient* capture_client = wm_state_->capture_controller(); |
| 284 | pointer_watcher_event_router_->DetachFromCaptureClient(capture_client); |
| 285 | window_tree_client_->capture_synchronizer()->DetachFromCaptureClient( |
| 286 | capture_client); |
| 287 | |
sky | abcae81 | 2017-01-18 17:01:34 | [diff] [blame] | 288 | Shell::DeleteInstance(); |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 289 | |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 290 | pointer_watcher_event_router_.reset(); |
| 291 | |
| 292 | window_tree_client_.reset(); |
| 293 | window_manager_client_ = nullptr; |
| 294 | } |
| 295 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 296 | void WindowManager::OnEmbed( |
| 297 | std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) { |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 298 | // WindowManager should never see this, instead OnWmNewDisplay() is called. |
| 299 | NOTREACHED(); |
| 300 | } |
| 301 | |
sky | 247a606 | 2016-12-08 16:45:14 | [diff] [blame] | 302 | void WindowManager::OnEmbedRootDestroyed( |
| 303 | aura::WindowTreeHostMus* window_tree_host) { |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 304 | // WindowManager should never see this. |
| 305 | NOTREACHED(); |
| 306 | } |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 307 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 308 | void WindowManager::OnLostConnection(aura::WindowTreeClient* client) { |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 309 | DCHECK_EQ(client, window_tree_client_.get()); |
sky | 01c007b | 2017-04-28 15:48:46 | [diff] [blame] | 310 | if (!lost_connection_callback_.is_null()) { |
| 311 | base::ResetAndReturn(&lost_connection_callback_).Run(); |
| 312 | return; |
| 313 | } |
sky | 9636bee | 2016-09-06 18:09:32 | [diff] [blame] | 314 | Shutdown(); |
Scott Violet | 6eda33e | 2017-11-14 23:53:37 | [diff] [blame] | 315 | // TODO(sky): this case should trigger shutting down WindowManagerService too. |
sky | 1cc6966 | 2016-06-17 23:59:35 | [diff] [blame] | 316 | } |
| 317 | |
riajiang | 13661fe | 2016-08-09 17:51:57 | [diff] [blame] | 318 | void WindowManager::OnPointerEventObserved(const ui::PointerEvent& event, |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 319 | aura::Window* target) { |
Elliot Glaysher | d26fedc | 2017-12-11 19:16:37 | [diff] [blame] | 320 | pointer_watcher_event_router_->OnPointerEventObserved(event, target); |
sadrul | eaa1be2 | 2015-11-30 23:30:48 | [diff] [blame] | 321 | } |
| 322 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 323 | aura::PropertyConverter* WindowManager::GetPropertyConverter() { |
| 324 | return property_converter_.get(); |
| 325 | } |
| 326 | |
| 327 | void WindowManager::SetWindowManagerClient(aura::WindowManagerClient* client) { |
sky | f5ece4e | 2016-01-26 19:40:36 | [diff] [blame] | 328 | window_manager_client_ = client; |
sky | a8b222f | 2017-01-12 15:47:13 | [diff] [blame] | 329 | ash::Shell::set_window_manager_client(client); |
sky | bbcf04eb | 2015-10-15 23:07:56 | [diff] [blame] | 330 | } |
sky | d4ca12f | 2015-10-28 18:22:26 | [diff] [blame] | 331 | |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 332 | void WindowManager::OnWmConnected() { |
Scott Violet | eff431f9 | 2017-08-15 23:00:47 | [diff] [blame] | 333 | // InstallFrameDecorationValues() must be called before the shell is created, |
| 334 | // otherwise Mus attempts to notify clients with no frame decorations, which |
| 335 | // triggers validation errors. |
| 336 | InstallFrameDecorationValues(); |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 337 | CreateShell(); |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 338 | if (show_primary_host_on_connect_) |
| 339 | Shell::GetPrimaryRootWindow()->GetHost()->Show(); |
Peng Huang | 87a65cd | 2017-10-06 15:21:47 | [diff] [blame] | 340 | |
| 341 | // We only create controller in the ash process for mash. |
| 342 | if (Shell::GetAshConfig() == Config::MASH) |
| 343 | wayland_server_controller_ = WaylandServerController::CreateIfNecessary(); |
sky | cfaad89 | 2017-04-28 20:52:58 | [diff] [blame] | 344 | } |
sky | fef3021 | 2017-04-19 00:41:23 | [diff] [blame] | 345 | |
Sadrul Habib Chowdhury | 55cd40ff | 2017-11-28 17:18:01 | [diff] [blame] | 346 | void WindowManager::OnWmAcceleratedWidgetAvailableForDisplay( |
| 347 | int64_t display_id, |
| 348 | gfx::AcceleratedWidget widget) { |
Michael Wasserman | 625b738 | 2017-12-13 16:34:32 | [diff] [blame] | 349 | WindowTreeHostManager* manager = Shell::Get()->window_tree_host_manager(); |
| 350 | AshWindowTreeHost* host = |
| 351 | manager->GetAshWindowTreeHostForDisplayId(display_id); |
| 352 | // The display may have been destroyed before getting this async callback. |
| 353 | if (host && host->AsWindowTreeHost()) { |
| 354 | static_cast<aura::WindowTreeHostMus*>(host->AsWindowTreeHost()) |
| 355 | ->OverrideAcceleratedWidget(widget); |
Sadrul Habib Chowdhury | 55cd40ff | 2017-11-28 17:18:01 | [diff] [blame] | 356 | } |
| 357 | } |
| 358 | |
fsamuel | 69875b5 | 2017-03-27 23:15:19 | [diff] [blame] | 359 | void WindowManager::OnWmSetBounds(aura::Window* window, |
| 360 | const gfx::Rect& bounds) { |
sky | 383d818f | 2016-05-19 22:34:02 | [diff] [blame] | 361 | // TODO(sky): this indirectly sets bounds, which is against what |
| 362 | // OnWmSetBounds() recommends doing. Remove that restriction, or fix this. |
varkha | c8621dd | 2017-05-31 19:09:01 | [diff] [blame] | 363 | window->SetBounds(bounds); |
sky | 6905d4c | 2015-11-26 01:53:21 | [diff] [blame] | 364 | } |
| 365 | |
sky | 7a35dfa | 2016-02-01 21:37:28 | [diff] [blame] | 366 | bool WindowManager::OnWmSetProperty( |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 367 | aura::Window* window, |
sky | 6905d4c | 2015-11-26 01:53:21 | [diff] [blame] | 368 | const std::string& name, |
mostynb | 1aaf506 | 2016-04-04 17:56:27 | [diff] [blame] | 369 | std::unique_ptr<std::vector<uint8_t>>* new_data) { |
sky | 5c71eb34 | 2017-02-15 19:39:25 | [diff] [blame] | 370 | if (property_converter_->IsTransportNameRegistered(name)) |
| 371 | return true; |
| 372 | DVLOG(1) << "unknown property changed, ignoring " << name; |
| 373 | return false; |
sky | 6905d4c | 2015-11-26 01:53:21 | [diff] [blame] | 374 | } |
| 375 | |
moshayedi | 92b3b48 | 2017-03-21 20:27:46 | [diff] [blame] | 376 | void WindowManager::OnWmSetModalType(aura::Window* window, ui::ModalType type) { |
| 377 | ui::ModalType old_type = window->GetProperty(aura::client::kModalKey); |
| 378 | if (type == old_type) |
| 379 | return; |
| 380 | |
| 381 | window->SetProperty(aura::client::kModalKey, type); |
Scott Violet | 65326efd | 2017-07-21 00:09:56 | [diff] [blame] | 382 | // Assume the client has positioned the window in the right container and |
| 383 | // don't attempt to change the parent. This is currently true for Chrome |
| 384 | // code, but likely there should be checks. Adding checks is complicated by |
| 385 | // the fact that assumptions in GetSystemModalContainer() are not always |
| 386 | // valid for Chrome code. In particular Chrome code may create system modal |
| 387 | // dialogs without a transient parent that Chrome wants shown on the lock |
| 388 | // screen. |
moshayedi | 92b3b48 | 2017-03-21 20:27:46 | [diff] [blame] | 389 | } |
| 390 | |
moshayedi | c17142e | 2017-01-26 21:50:39 | [diff] [blame] | 391 | void WindowManager::OnWmSetCanFocus(aura::Window* window, bool can_focus) { |
| 392 | NonClientFrameController* non_client_frame_controller = |
| 393 | NonClientFrameController::Get(window); |
| 394 | if (non_client_frame_controller) |
| 395 | non_client_frame_controller->set_can_activate(can_focus); |
| 396 | } |
| 397 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 398 | aura::Window* WindowManager::OnWmCreateTopLevelWindow( |
| 399 | ui::mojom::WindowType window_type, |
sky | adfb9237 | 2016-01-07 17:34:24 | [diff] [blame] | 400 | std::map<std::string, std::vector<uint8_t>>* properties) { |
sky | b87f0a1 | 2016-12-06 20:45:49 | [diff] [blame] | 401 | if (window_type == ui::mojom::WindowType::UNKNOWN) { |
| 402 | LOG(WARNING) << "Request to create top level of unknown type, failing"; |
| 403 | return nullptr; |
| 404 | } |
| 405 | |
sky | 8a8ffd2 | 2017-01-19 15:55:29 | [diff] [blame] | 406 | return CreateAndParentTopLevelWindow(this, window_type, properties); |
sky | adfb9237 | 2016-01-07 17:34:24 | [diff] [blame] | 407 | } |
| 408 | |
ben | 3d0b318 | 2016-05-25 20:37:14 | [diff] [blame] | 409 | void WindowManager::OnWmClientJankinessChanged( |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 410 | const std::set<aura::Window*>& client_windows, |
ben | 3d0b318 | 2016-05-25 20:37:14 | [diff] [blame] | 411 | bool janky) { |
vmpstr | eb900a1 | 2016-06-29 02:22:28 | [diff] [blame] | 412 | for (auto* window : client_windows) |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 413 | window->SetProperty(kWindowIsJanky, janky); |
ben | 3d0b318 | 2016-05-25 20:37:14 | [diff] [blame] | 414 | } |
| 415 | |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 416 | void WindowManager::OnWmBuildDragImage(const gfx::Point& screen_location, |
| 417 | const SkBitmap& drag_image, |
| 418 | const gfx::Vector2d& drag_image_offset, |
| 419 | ui::mojom::PointerKind source) { |
| 420 | if (drag_image.isNull()) |
| 421 | return; |
| 422 | |
| 423 | // TODO(erg): Get the right display for this drag image. Right now, none of |
| 424 | // the drag drop code is multidisplay aware. |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 425 | aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 426 | |
| 427 | // TODO(erg): SkBitmap is the wrong data type for the drag image; we should |
| 428 | // be passing ImageSkias once http://crbug.com/655874 is implemented. |
| 429 | |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 430 | ui::DragDropTypes::DragEventSource ui_source = |
| 431 | source == ui::mojom::PointerKind::MOUSE |
| 432 | ? ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE |
| 433 | : ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 434 | std::unique_ptr<DragImageView> drag_view = |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 435 | std::make_unique<DragImageView>(root_window, ui_source); |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 436 | drag_view->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(drag_image)); |
| 437 | gfx::Size size = drag_view->GetPreferredSize(); |
| 438 | gfx::Rect drag_image_bounds(screen_location - drag_image_offset, size); |
| 439 | drag_view->SetBoundsInScreen(drag_image_bounds); |
| 440 | drag_view->SetWidgetVisible(true); |
| 441 | |
Mitsuru Oshima | 04b54d0 | 2017-10-09 14:22:45 | [diff] [blame] | 442 | drag_state_ = std::make_unique<DragState>(); |
erg | b9401c49 | 2017-03-24 17:14:12 | [diff] [blame] | 443 | drag_state_->view = std::move(drag_view); |
| 444 | drag_state_->image_offset = drag_image_offset; |
| 445 | } |
| 446 | |
| 447 | void WindowManager::OnWmMoveDragImage(const gfx::Point& screen_location) { |
| 448 | if (drag_state_) { |
| 449 | drag_state_->view->SetScreenPosition(screen_location - |
| 450 | drag_state_->image_offset); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | void WindowManager::OnWmDestroyDragImage() { |
| 455 | drag_state_.reset(); |
| 456 | } |
| 457 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 458 | void WindowManager::OnWmWillCreateDisplay(const display::Display& display) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 459 | // Ash connects such that |automatically_create_display_roots| is false, which |
| 460 | // means this should never be hit. |
| 461 | NOTREACHED(); |
sky | ffa8df2 | 2016-02-02 05:47:34 | [diff] [blame] | 462 | } |
| 463 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 464 | void WindowManager::OnWmNewDisplay( |
| 465 | std::unique_ptr<aura::WindowTreeHostMus> window_tree_host, |
| 466 | const display::Display& display) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 467 | // Ash connects such that |automatically_create_display_roots| is false, which |
| 468 | // means this should never be hit. |
| 469 | NOTREACHED(); |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 470 | } |
| 471 | |
| 472 | void WindowManager::OnWmDisplayRemoved( |
| 473 | aura::WindowTreeHostMus* window_tree_host) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 474 | // Ash connects such that |automatically_create_display_roots| is false, which |
| 475 | // means this should never be hit. |
| 476 | NOTREACHED(); |
sky | 54ff2cce | 2016-09-20 02:44:41 | [diff] [blame] | 477 | } |
| 478 | |
kylechar | a06c6ea4 | 2016-10-21 17:35:04 | [diff] [blame] | 479 | void WindowManager::OnWmDisplayModified(const display::Display& display) { |
Scott Violet | 596bb4634 | 2017-06-21 14:43:13 | [diff] [blame] | 480 | // TODO(sky): this shouldn't be called as we're passing false for |
| 481 | // |automatically_create_display_roots|, but it currently is. Update mus. |
kylechar | a06c6ea4 | 2016-10-21 17:35:04 | [diff] [blame] | 482 | } |
| 483 | |
erg | 6d0134e | 2016-07-07 00:41:13 | [diff] [blame] | 484 | void WindowManager::OnWmPerformMoveLoop( |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 485 | aura::Window* window, |
sky | e0aeea28 | 2016-07-27 22:26:09 | [diff] [blame] | 486 | ui::mojom::MoveLoopSource source, |
erg | 6d0134e | 2016-07-07 00:41:13 | [diff] [blame] | 487 | const gfx::Point& cursor_location, |
| 488 | const base::Callback<void(bool)>& on_done) { |
sky | cd9d4ae | 2017-05-25 19:38:33 | [diff] [blame] | 489 | MoveEventHandler* handler = MoveEventHandler::GetForWindow(window); |
erg | 6ed29f6 | 2016-07-08 20:10:40 | [diff] [blame] | 490 | if (!handler) { |
| 491 | on_done.Run(false); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | DCHECK(!handler->IsDragInProgress()); |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 496 | ::wm::WindowMoveSource aura_source = |
sky | e0aeea28 | 2016-07-27 22:26:09 | [diff] [blame] | 497 | source == ui::mojom::MoveLoopSource::MOUSE |
Thiago Farina | 3b086a0 | 2017-05-30 22:32:50 | [diff] [blame] | 498 | ? ::wm::WINDOW_MOVE_SOURCE_MOUSE |
| 499 | : ::wm::WINDOW_MOVE_SOURCE_TOUCH; |
erg | 6ed29f6 | 2016-07-08 20:10:40 | [diff] [blame] | 500 | handler->AttemptToStartDrag(cursor_location, HTCAPTION, aura_source, on_done); |
erg | 6d0134e | 2016-07-07 00:41:13 | [diff] [blame] | 501 | } |
| 502 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 503 | void WindowManager::OnWmCancelMoveLoop(aura::Window* window) { |
sky | cd9d4ae | 2017-05-25 19:38:33 | [diff] [blame] | 504 | MoveEventHandler* handler = MoveEventHandler::GetForWindow(window); |
erg | 6ed29f6 | 2016-07-08 20:10:40 | [diff] [blame] | 505 | if (handler) |
| 506 | handler->RevertDrag(); |
erg | 6d0134e | 2016-07-07 00:41:13 | [diff] [blame] | 507 | } |
| 508 | |
sky | c0c862a | 2017-03-22 15:14:16 | [diff] [blame] | 509 | ui::mojom::EventResult WindowManager::OnAccelerator( |
| 510 | uint32_t id, |
| 511 | const ui::Event& event, |
| 512 | std::unordered_map<std::string, std::vector<uint8_t>>* properties) { |
sky | 853669a | 2016-07-22 18:43:12 | [diff] [blame] | 513 | auto iter = accelerator_handlers_.find(GetAcceleratorNamespaceId(id)); |
| 514 | if (iter == accelerator_handlers_.end()) |
| 515 | return ui::mojom::EventResult::HANDLED; |
erg | 6ed29f6 | 2016-07-08 20:10:40 | [diff] [blame] | 516 | |
sky | c0c862a | 2017-03-22 15:14:16 | [diff] [blame] | 517 | return iter->second->OnAccelerator(id, event, properties); |
sky | 76d4666 | 2016-07-08 18:43:01 | [diff] [blame] | 518 | } |
| 519 | |
Elliot Glaysher | 08063f7 | 2017-07-29 00:24:06 | [diff] [blame] | 520 | void WindowManager::OnCursorTouchVisibleChanged(bool enabled) { |
Scott Violet | fd1f265 | 2017-10-31 19:53:38 | [diff] [blame] | 521 | // Not applicable to Config::MUS. |
| 522 | if (config_ == Config::MASH) |
| 523 | ShellPortMash::Get()->OnCursorTouchVisibleChanged(enabled); |
Elliot Glaysher | 08063f7 | 2017-07-29 00:24:06 | [diff] [blame] | 524 | } |
| 525 | |
sky | fcf18b5 | 2016-12-06 03:53:51 | [diff] [blame] | 526 | void WindowManager::OnWmSetClientArea( |
| 527 | aura::Window* window, |
| 528 | const gfx::Insets& insets, |
| 529 | const std::vector<gfx::Rect>& additional_client_areas) { |
| 530 | NonClientFrameController* non_client_frame_controller = |
| 531 | NonClientFrameController::Get(window); |
| 532 | if (!non_client_frame_controller) |
| 533 | return; |
| 534 | non_client_frame_controller->SetClientArea(insets, additional_client_areas); |
| 535 | } |
| 536 | |
erg | 02ba4e2 | 2017-01-13 21:13:48 | [diff] [blame] | 537 | bool WindowManager::IsWindowActive(aura::Window* window) { |
sky | cb4be5b | 2017-04-06 17:52:45 | [diff] [blame] | 538 | return Shell::Get()->activation_client()->GetActiveWindow() == window; |
erg | 02ba4e2 | 2017-01-13 21:13:48 | [diff] [blame] | 539 | } |
| 540 | |
| 541 | void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
sky | cb4be5b | 2017-04-06 17:52:45 | [diff] [blame] | 542 | Shell::Get()->activation_client()->DeactivateWindow(window); |
erg | 02ba4e2 | 2017-01-13 21:13:48 | [diff] [blame] | 543 | } |
| 544 | |
Elliot Glaysher | 247b763 | 2017-10-25 03:02:09 | [diff] [blame] | 545 | void WindowManager::OnWmPerformAction(aura::Window* window, |
| 546 | const std::string& action) { |
| 547 | if (action == mojom::kAddWindowToTabletMode) |
| 548 | ash::Shell::Get()->tablet_mode_controller()->AddWindow(window); |
| 549 | } |
| 550 | |
Scott Violet | 0f803d05 | 2017-08-04 18:24:42 | [diff] [blame] | 551 | void WindowManager::OnEventBlockedByModalWindow(aura::Window* window) { |
| 552 | AnimateWindow(window, ::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| 553 | } |
| 554 | |
sky | 002ba4a | 2016-06-03 00:56:11 | [diff] [blame] | 555 | } // namespace ash |