event_client_impl.cc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright (c) 2012 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. #include "ash/wm/event_client_impl.h"
  5. #include "ash/keyboard/ui/keyboard_util.h"
  6. #include "ash/public/cpp/shell_window_ids.h"
  7. #include "ash/session/session_controller_impl.h"
  8. #include "ash/shell.h"
  9. #include "ash/tray_action/tray_action.h"
  10. #include "ui/aura/window.h"
  11. namespace ash {
  12. EventClientImpl::EventClientImpl() = default;
  13. EventClientImpl::~EventClientImpl() = default;
  14. bool EventClientImpl::GetCanProcessEventsWithinSubtree(
  15. const aura::Window* window) const {
  16. if (skip_user_session_blocked_check_)
  17. return true;
  18. // TODO(oshima): Migrate this logic to Shell::CanWindowReceieveEvents and
  19. // remove this.
  20. const aura::Window* root_window = window ? window->GetRootWindow() : NULL;
  21. if (!root_window ||
  22. !Shell::Get()->session_controller()->IsUserSessionBlocked()) {
  23. return true;
  24. }
  25. const aura::Window* lock_screen_containers = Shell::GetContainer(
  26. root_window, kShellWindowId_LockScreenContainersContainer);
  27. const aura::Window* lock_wallpaper_containers = Shell::GetContainer(
  28. root_window, kShellWindowId_LockScreenWallpaperContainer);
  29. const aura::Window* lock_screen_related_containers = Shell::GetContainer(
  30. root_window, kShellWindowId_LockScreenRelatedContainersContainer);
  31. bool can_process_events =
  32. (window->Contains(lock_screen_containers) &&
  33. window->Contains(lock_wallpaper_containers) &&
  34. window->Contains(lock_screen_related_containers)) ||
  35. lock_screen_containers->Contains(window) ||
  36. lock_wallpaper_containers->Contains(window) ||
  37. lock_screen_related_containers->Contains(window);
  38. if (keyboard::IsKeyboardEnabled()) {
  39. const aura::Window* virtual_keyboard_container = Shell::GetContainer(
  40. root_window, kShellWindowId_VirtualKeyboardContainer);
  41. can_process_events |= (window->Contains(virtual_keyboard_container) ||
  42. virtual_keyboard_container->Contains(window));
  43. }
  44. return can_process_events;
  45. }
  46. ui::EventTarget* EventClientImpl::GetToplevelEventTarget() {
  47. return Shell::Get();
  48. }
  49. } // namespace ash