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