capture_client.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef UI_AURA_CLIENT_CAPTURE_CLIENT_H_
  5. #define UI_AURA_CLIENT_CAPTURE_CLIENT_H_
  6. #include "ui/aura/aura_export.h"
  7. namespace aura {
  8. class Window;
  9. namespace client {
  10. class CaptureClientObserver;
  11. // An interface implemented by an object that manages input capture.
  12. //
  13. // The intended semantics of window-capture are that:
  14. // * At most one window on the system can register as "capturing" input.
  15. // * If a window is capturing input, then all input events will get routed to
  16. // this window.
  17. // * The window may choose to release capture while processing an event. The
  18. // resulting behavior is platform dependent (e.g. whether the event is
  19. // redispatched to the window server).
  20. class AURA_EXPORT CaptureClient {
  21. public:
  22. // Does a capture on the |window|.
  23. virtual void SetCapture(Window* window) = 0;
  24. // Releases a capture from the |window|.
  25. virtual void ReleaseCapture(Window* window) = 0;
  26. // Returns the current capture window. This may only return a Window if the
  27. // Window that has capture is a child of the Window the CaptureClient is
  28. // installed on. GetGlobalCaptureWindow() can be used to locate the Window
  29. // that has capture regardless of the Window the CaptureClient is installed
  30. // on.
  31. virtual Window* GetCaptureWindow() = 0;
  32. // See description of GetCaptureWindow() for details.
  33. virtual Window* GetGlobalCaptureWindow() = 0;
  34. virtual void AddObserver(CaptureClientObserver* observer) = 0;
  35. virtual void RemoveObserver(CaptureClientObserver* observer) = 0;
  36. protected:
  37. virtual ~CaptureClient() {}
  38. };
  39. // Sets/Gets the capture client on the root Window.
  40. AURA_EXPORT void SetCaptureClient(Window* root_window,
  41. CaptureClient* client);
  42. AURA_EXPORT CaptureClient* GetCaptureClient(Window* root_window);
  43. // A utility function to get the current capture window. Returns NULL
  44. // if the window doesn't have a root window, or there is no capture window.
  45. AURA_EXPORT Window* GetCaptureWindow(Window* window);
  46. } // namespace client
  47. } // namespace aura
  48. #endif // UI_AURA_CLIENT_CAPTURE_CLIENT_H_