focus_client.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_FOCUS_CLIENT_H_
  5. #define UI_AURA_CLIENT_FOCUS_CLIENT_H_
  6. #include "ui/aura/aura_export.h"
  7. #include "ui/aura/window.h"
  8. namespace aura {
  9. namespace client {
  10. class FocusChangeObserver;
  11. // An interface implemented by an object that manages window focus.
  12. class AURA_EXPORT FocusClient {
  13. public:
  14. virtual ~FocusClient() {}
  15. virtual void AddObserver(FocusChangeObserver* observer) = 0;
  16. virtual void RemoveObserver(FocusChangeObserver* observer) = 0;
  17. // Focuses |window|. Passing NULL clears focus.
  18. virtual void FocusWindow(Window* window) = 0;
  19. // Sets focus to |window| if it's within the active window. Not intended as a
  20. // general purpose API, use FocusWindow() instead.
  21. virtual void ResetFocusWithinActiveWindow(Window* window) = 0;
  22. // Retrieves the focused window, or NULL if there is none.
  23. virtual Window* GetFocusedWindow() = 0;
  24. };
  25. // Sets/Gets the focus client on the root Window.
  26. AURA_EXPORT void SetFocusClient(Window* root_window, FocusClient* client);
  27. AURA_EXPORT FocusClient* GetFocusClient(Window* window);
  28. AURA_EXPORT FocusClient* GetFocusClient(const Window* window);
  29. } // namespace clients
  30. } // namespace aura
  31. #endif // UI_AURA_CLIENT_FOCUS_CLIENT_H_