system_modal_container_event_filter.cc 970 B

1234567891011121314151617181920212223242526272829
  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/system_modal_container_event_filter.h"
  5. #include "ash/shell.h"
  6. #include "ash/wm/system_modal_container_event_filter_delegate.h"
  7. #include "ui/aura/window.h"
  8. #include "ui/events/event.h"
  9. namespace ash {
  10. SystemModalContainerEventFilter::SystemModalContainerEventFilter(
  11. SystemModalContainerEventFilterDelegate* delegate)
  12. : delegate_(delegate) {}
  13. SystemModalContainerEventFilter::~SystemModalContainerEventFilter() = default;
  14. void SystemModalContainerEventFilter::OnEvent(ui::Event* event) {
  15. // Only filter modal events if a modal window is open.
  16. if (!Shell::IsSystemModalWindowOpen())
  17. return;
  18. aura::Window* target = static_cast<aura::Window*>(event->target());
  19. if (!delegate_->CanWindowReceiveEvents(target))
  20. event->StopPropagation();
  21. }
  22. } // namespace ash