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 RootWindow; 16 class Window; 17 18 namespace client { 19 class FocusChangeObserver; 20 21 // An interface implemented by an object that manages window focus. 22 class AURA_EXPORT FocusClient { 23 public: 24 virtual ~FocusClient() {} 25 26 // TODO(beng): these methods will be OBSOLETE by FocusChangeEvent. 27 virtual void AddObserver(FocusChangeObserver* observer) = 0; 28 virtual void RemoveObserver(FocusChangeObserver* observer) = 0; 29 30 // Focuses |window|. Passing NULL clears focus. 31 virtual void FocusWindow(Window* window) = 0; 32 33 // Sets focus to |window| if it's within the active window. Not intended as a 34 // general purpose API, use FocusWindow() instead. 35 virtual void ResetFocusWithinActiveWindow(Window* window) = 0; 36 37 // Retrieves the focused window, or NULL if there is none. 38 virtual Window* GetFocusedWindow() = 0; 39 40 // TODO(beng): temporary compat until FocusController is on. 41 // Called when |window|'s disposition in |root_window| changes such that 42 // focus must be shifted away from it. |destroyed| is true if the disposition 43 // change is that |window| is being destroyed. 44 virtual void OnWindowHiddenInRootWindow(aura::Window* window, 45 aura::RootWindow* root_window, 46 bool destroyed) = 0; 47 }; 48 49 // Sets/Gets the focus client on the RootWindow. 50 AURA_EXPORT void SetFocusClient(RootWindow* root_window, FocusClient* client); 51 AURA_EXPORT FocusClient* GetFocusClient(Window* window); 52 AURA_EXPORT FocusClient* GetFocusClient(const Window* window); 53 54 } // namespace clients 55 } // namespace aura 56 57 #endif // UI_AURA_CLIENT_FOCUS_CLIENT_H_ 58