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