window_occlusion_win.cc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2018 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 "ui/aura_extra/window_occlusion_win.h"
  5. #include "ui/aura_extra/window_occlusion_impl_win.h"
  6. namespace aura_extra {
  7. namespace {
  8. // Default implementation of WindowBoundsDelegate using GetWindowRect().
  9. class WindowBoundsDelegateImpl : public WindowBoundsDelegate {
  10. public:
  11. WindowBoundsDelegateImpl();
  12. WindowBoundsDelegateImpl(const WindowBoundsDelegateImpl&) = delete;
  13. WindowBoundsDelegateImpl& operator=(const WindowBoundsDelegateImpl&) = delete;
  14. ~WindowBoundsDelegateImpl() override {}
  15. // WindowBoundsDelegate:
  16. gfx::Rect GetBoundsInPixels(aura::WindowTreeHost* window) override;
  17. };
  18. WindowBoundsDelegateImpl::WindowBoundsDelegateImpl() = default;
  19. gfx::Rect WindowBoundsDelegateImpl::GetBoundsInPixels(
  20. aura::WindowTreeHost* window) {
  21. HWND hwnd = window->GetAcceleratedWidget();
  22. RECT window_rect_in_pixels;
  23. bool success = GetWindowRect(hwnd, &window_rect_in_pixels);
  24. DCHECK(success);
  25. return gfx::Rect(window_rect_in_pixels);
  26. }
  27. } // namespace
  28. base::flat_map<aura::WindowTreeHost*, aura::Window::OcclusionState>
  29. ComputeNativeWindowOcclusionStatus(
  30. const std::vector<aura::WindowTreeHost*>& windows) {
  31. return ComputeNativeWindowOcclusionStatusImpl(
  32. windows, std::make_unique<WindowsDesktopWindowIterator>(),
  33. std::make_unique<WindowBoundsDelegateImpl>());
  34. }
  35. } // namespace aura_extra