app_list_event_targeter.cc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2021 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/app_list/app_list_event_targeter.h"
  5. #include "ash/app_list/app_list_view_delegate.h"
  6. #include "ash/assistant/ui/assistant_ui_constants.h"
  7. #include "base/check.h"
  8. #include "ui/aura/window.h"
  9. namespace ash {
  10. AppListEventTargeter::AppListEventTargeter(AppListViewDelegate* delegate)
  11. : delegate_(delegate) {
  12. DCHECK(delegate_);
  13. }
  14. AppListEventTargeter::~AppListEventTargeter() = default;
  15. bool AppListEventTargeter::SubtreeShouldBeExploredForEvent(
  16. aura::Window* window,
  17. const ui::LocatedEvent& event) {
  18. if (delegate_ && !delegate_->CanProcessEventsOnApplistViews())
  19. return false;
  20. if (window->GetProperty(assistant::ui::kOnlyAllowMouseClickEvents)) {
  21. if (event.type() != ui::ET_MOUSE_PRESSED &&
  22. event.type() != ui::ET_MOUSE_RELEASED) {
  23. return false;
  24. }
  25. }
  26. return aura::WindowTargeter::SubtreeShouldBeExploredForEvent(window, event);
  27. }
  28. } // namespace ash