window_finder.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
  11. #define MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_
  12. #include <memory>
  13. #include "api/scoped_refptr.h"
  14. #include "modules/desktop_capture/desktop_capture_types.h"
  15. #include "modules/desktop_capture/desktop_geometry.h"
  16. #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
  17. #include "modules/desktop_capture/mac/desktop_configuration_monitor.h"
  18. #endif
  19. namespace webrtc {
  20. #if defined(WEBRTC_USE_X11)
  21. class XAtomCache;
  22. #endif
  23. // An interface to return the id of the visible window under a certain point.
  24. class WindowFinder {
  25. public:
  26. WindowFinder() = default;
  27. virtual ~WindowFinder() = default;
  28. // Returns the id of the visible window under |point|. This function returns
  29. // kNullWindowId if no window is under |point| and the platform does not have
  30. // "root window" concept, i.e. the visible area under |point| is the desktop.
  31. // |point| is always in system coordinate, i.e. the primary monitor always
  32. // starts from (0, 0).
  33. virtual WindowId GetWindowUnderPoint(DesktopVector point) = 0;
  34. struct Options final {
  35. Options();
  36. ~Options();
  37. Options(const Options& other);
  38. Options(Options&& other);
  39. #if defined(WEBRTC_USE_X11)
  40. XAtomCache* cache = nullptr;
  41. #endif
  42. #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
  43. rtc::scoped_refptr<DesktopConfigurationMonitor> configuration_monitor;
  44. #endif
  45. };
  46. // Creates a platform-independent WindowFinder implementation. This function
  47. // returns nullptr if |options| does not contain enough information or
  48. // WindowFinder does not support current platform.
  49. static std::unique_ptr<WindowFinder> Create(const Options& options);
  50. };
  51. } // namespace webrtc
  52. #endif // MODULES_DESKTOP_CAPTURE_WINDOW_FINDER_H_