OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/browser/shell_desktop_controller_aura.h" | 5 #include "extensions/shell/browser/shell_desktop_controller_aura.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "ui/gfx/geometry/size.h" | 28 #include "ui/gfx/geometry/size.h" |
29 #include "ui/gfx/native_widget_types.h" | 29 #include "ui/gfx/native_widget_types.h" |
30 #include "ui/gfx/screen.h" | 30 #include "ui/gfx/screen.h" |
31 #include "ui/wm/core/base_focus_rules.h" | 31 #include "ui/wm/core/base_focus_rules.h" |
32 #include "ui/wm/core/compound_event_filter.h" | 32 #include "ui/wm/core/compound_event_filter.h" |
33 #include "ui/wm/core/cursor_manager.h" | 33 #include "ui/wm/core/cursor_manager.h" |
34 #include "ui/wm/core/focus_controller.h" | 34 #include "ui/wm/core/focus_controller.h" |
35 #include "ui/wm/core/input_method_event_filter.h" | 35 #include "ui/wm/core/input_method_event_filter.h" |
36 #include "ui/wm/core/native_cursor_manager.h" | 36 #include "ui/wm/core/native_cursor_manager.h" |
37 #include "ui/wm/core/native_cursor_manager_delegate.h" | 37 #include "ui/wm/core/native_cursor_manager_delegate.h" |
| 38 #include "ui/wm/core/window_activation_pre_target_handler.h" |
38 | 39 |
39 #if defined(OS_CHROMEOS) | 40 #if defined(OS_CHROMEOS) |
40 #include "chromeos/dbus/dbus_thread_manager.h" | 41 #include "chromeos/dbus/dbus_thread_manager.h" |
41 #include "ui/chromeos/user_activity_power_manager_notifier.h" | 42 #include "ui/chromeos/user_activity_power_manager_notifier.h" |
42 #include "ui/display/types/display_mode.h" | 43 #include "ui/display/types/display_mode.h" |
43 #include "ui/display/types/display_snapshot.h" | 44 #include "ui/display/types/display_snapshot.h" |
44 #endif | 45 #endif |
45 | 46 |
46 namespace extensions { | 47 namespace extensions { |
47 namespace { | 48 namespace { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 DCHECK_EQ(host_.get(), host); | 249 DCHECK_EQ(host_.get(), host); |
249 CloseAppWindows(); | 250 CloseAppWindows(); |
250 base::MessageLoop::current()->PostTask(FROM_HERE, | 251 base::MessageLoop::current()->PostTask(FROM_HERE, |
251 base::MessageLoop::QuitClosure()); | 252 base::MessageLoop::QuitClosure()); |
252 } | 253 } |
253 | 254 |
254 void ShellDesktopControllerAura::InitWindowManager() { | 255 void ShellDesktopControllerAura::InitWindowManager() { |
255 wm::FocusController* focus_controller = | 256 wm::FocusController* focus_controller = |
256 new wm::FocusController(new AppsFocusRules()); | 257 new wm::FocusController(new AppsFocusRules()); |
257 aura::client::SetFocusClient(host_->window(), focus_controller); | 258 aura::client::SetFocusClient(host_->window(), focus_controller); |
258 host_->window()->AddPreTargetHandler(focus_controller); | |
259 aura::client::SetActivationClient(host_->window(), focus_controller); | 259 aura::client::SetActivationClient(host_->window(), focus_controller); |
260 focus_client_.reset(focus_controller); | 260 focus_client_.reset(focus_controller); |
| 261 window_activation_pretarget_handler_.reset( |
| 262 new wm::WindowActivationPreTargetHandler(focus_controller)); |
| 263 host_->window()->AddPreTargetHandler( |
| 264 window_activation_pretarget_handler_.get()); |
261 | 265 |
262 input_method_filter_.reset( | 266 input_method_filter_.reset( |
263 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget())); | 267 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget())); |
264 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); | 268 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); |
265 root_window_event_filter_->AddHandler(input_method_filter_.get()); | 269 root_window_event_filter_->AddHandler(input_method_filter_.get()); |
266 | 270 |
267 capture_client_.reset( | 271 capture_client_.reset( |
268 new aura::client::DefaultCaptureClient(host_->window())); | 272 new aura::client::DefaultCaptureClient(host_->window())); |
269 | 273 |
270 // Ensure new windows fill the display. | 274 // Ensure new windows fill the display. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 host_->AddObserver(this); | 318 host_->AddObserver(this); |
315 | 319 |
316 // Ensure the X window gets mapped. | 320 // Ensure the X window gets mapped. |
317 host_->Show(); | 321 host_->Show(); |
318 } | 322 } |
319 | 323 |
320 void ShellDesktopControllerAura::DestroyRootWindow() { | 324 void ShellDesktopControllerAura::DestroyRootWindow() { |
321 host_->RemoveObserver(this); | 325 host_->RemoveObserver(this); |
322 if (input_method_filter_) | 326 if (input_method_filter_) |
323 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); | 327 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); |
324 wm::FocusController* focus_controller = | 328 if (window_activation_pretarget_handler_) { |
325 static_cast<wm::FocusController*>(focus_client_.get()); | 329 host_->window()->RemovePreTargetHandler( |
326 if (focus_controller) { | 330 window_activation_pretarget_handler_.get()); |
327 host_->window()->RemovePreTargetHandler(focus_controller); | |
328 aura::client::SetActivationClient(host_->window(), NULL); | 331 aura::client::SetActivationClient(host_->window(), NULL); |
| 332 window_activation_pretarget_handler_.reset(); |
329 } | 333 } |
330 root_window_event_filter_.reset(); | 334 root_window_event_filter_.reset(); |
331 capture_client_.reset(); | 335 capture_client_.reset(); |
332 input_method_filter_.reset(); | 336 input_method_filter_.reset(); |
333 focus_client_.reset(); | 337 focus_client_.reset(); |
334 cursor_manager_.reset(); | 338 cursor_manager_.reset(); |
335 #if defined(OS_CHROMEOS) | 339 #if defined(OS_CHROMEOS) |
336 user_activity_notifier_.reset(); | 340 user_activity_notifier_.reset(); |
337 #endif | 341 #endif |
338 user_activity_detector_.reset(); | 342 user_activity_detector_.reset(); |
339 host_.reset(); | 343 host_.reset(); |
340 screen_.reset(); | 344 screen_.reset(); |
341 } | 345 } |
342 | 346 |
343 gfx::Size ShellDesktopControllerAura::GetPrimaryDisplaySize() { | 347 gfx::Size ShellDesktopControllerAura::GetPrimaryDisplaySize() { |
344 #if defined(OS_CHROMEOS) | 348 #if defined(OS_CHROMEOS) |
345 const ui::DisplayConfigurator::DisplayStateList& displays = | 349 const ui::DisplayConfigurator::DisplayStateList& displays = |
346 display_configurator_->cached_displays(); | 350 display_configurator_->cached_displays(); |
347 if (displays.empty()) | 351 if (displays.empty()) |
348 return gfx::Size(); | 352 return gfx::Size(); |
349 const ui::DisplayMode* mode = displays[0]->current_mode(); | 353 const ui::DisplayMode* mode = displays[0]->current_mode(); |
350 return mode ? mode->size() : gfx::Size(); | 354 return mode ? mode->size() : gfx::Size(); |
351 #else | 355 #else |
352 return gfx::Size(); | 356 return gfx::Size(); |
353 #endif | 357 #endif |
354 } | 358 } |
355 | 359 |
356 } // namespace extensions | 360 } // namespace extensions |
OLD | NEW |