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_WM_PUBLIC_ACTIVATION_CLIENT_H_
6 #define UI_WM_PUBLIC_ACTIVATION_CLIENT_H_
7 
8 #include "ui/wm/public/wm_public_export.h"
9 
10 namespace aura {
11 class Window;
12 }
13 
14 namespace wm {
15 class ActivationChangeObserver;
16 
17 // An interface implemented by an object that manages window activation.
18 class WM_PUBLIC_EXPORT ActivationClient {
19  public:
20   // Adds/Removes ActivationChangeObservers.
21   virtual void AddObserver(ActivationChangeObserver* observer) = 0;
22   virtual void RemoveObserver(ActivationChangeObserver* observer) = 0;
23 
24   // Activates |window|. If |window| is NULL, nothing happens.
25   virtual void ActivateWindow(aura::Window* window) = 0;
26 
27   // Deactivates |window|. What (if anything) is activated next is up to the
28   // client. If |window| is NULL, nothing happens.
29   virtual void DeactivateWindow(aura::Window* window) = 0;
30 
31   // Retrieves the active window, or NULL if there is none.
GetActiveWindow()32   aura::Window* GetActiveWindow() {
33     return const_cast<aura::Window*>(
34         const_cast<const ActivationClient*>(this)->GetActiveWindow());
35   }
36   virtual const aura::Window* GetActiveWindow() const = 0;
37 
38   // Retrieves the activatable window for |window|, or NULL if there is none.
39   // Note that this is often but not always the toplevel window (see
40   // GetToplevelWindow() below), as the toplevel window may not be activatable
41   // (for example it may be blocked by a modal transient, or some other
42   // condition).
43   virtual aura::Window* GetActivatableWindow(aura::Window* window) const = 0;
44 
45   // Retrieves the toplevel window for |window|, or NULL if there is none.
46   virtual const aura::Window* GetToplevelWindow(
47       const aura::Window* window) const = 0;
48 
49   // Returns true if |window| can be activated, false otherwise. If |window| has
50   // a modal child it can not be activated.
51   virtual bool CanActivateWindow(const aura::Window* window) const = 0;
52 
53  protected:
~ActivationClient()54   virtual ~ActivationClient() {}
55 };
56 
57 // Sets/Gets the activation client on the root Window.
58 WM_PUBLIC_EXPORT void SetActivationClient(aura::Window* root_window,
59                                           ActivationClient* client);
60 WM_PUBLIC_EXPORT ActivationClient* GetActivationClient(
61     aura::Window* root_window);
62 WM_PUBLIC_EXPORT const ActivationClient* GetActivationClient(
63     const aura::Window* root_window);
64 
65 // Some types of transient window are only visible when active.
66 // The transient parents of these windows may have visual appearance properties
67 // that differ from transient parents that can be deactivated.
68 // The presence of this property implies these traits.
69 // TODO(beng): currently the UI framework (views) implements the actual
70 //             close-on-deactivate component of this feature but it should be
71 //             possible to implement in the aura client.
72 WM_PUBLIC_EXPORT void SetHideOnDeactivate(aura::Window* window,
73                                           bool hide_on_deactivate);
74 WM_PUBLIC_EXPORT bool GetHideOnDeactivate(aura::Window* window);
75 
76 }  // namespace wm
77 
78 #endif  // UI_WM_PUBLIC_ACTIVATION_CLIENT_H_
79