Home | History | Annotate | Download | only in client
      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_ACTIVATION_CLIENT_H_
      6 #define UI_AURA_CLIENT_ACTIVATION_CLIENT_H_
      7 
      8 #include "ui/aura/aura_export.h"
      9 #include "ui/aura/window.h"
     10 
     11 namespace ui {
     12 class Event;
     13 }
     14 
     15 namespace aura {
     16 class RootWindow;
     17 
     18 namespace client {
     19 class ActivationChangeObserver;
     20 
     21 // An interface implemented by an object that manages window activation.
     22 class AURA_EXPORT ActivationClient {
     23  public:
     24   // Adds/Removes ActivationChangeObservers.
     25   virtual void AddObserver(ActivationChangeObserver* observer) = 0;
     26   virtual void RemoveObserver(ActivationChangeObserver* observer) = 0;
     27 
     28   // Activates |window|. If |window| is NULL, nothing happens.
     29   virtual void ActivateWindow(Window* window) = 0;
     30 
     31   // Deactivates |window|. What (if anything) is activated next is up to the
     32   // client. If |window| is NULL, nothing happens.
     33   virtual void DeactivateWindow(Window* window) = 0;
     34 
     35   // Retrieves the active window, or NULL if there is none.
     36   virtual Window* GetActiveWindow() = 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 Window* GetActivatableWindow(Window* window) = 0;
     44 
     45   // Retrieves the toplevel window for |window|, or NULL if there is none.
     46   virtual Window* GetToplevelWindow(Window* window) = 0;
     47 
     48   // Invoked prior to |window| getting focus as a result of the |event|. |event|
     49   // may be NULL. Returning false blocks |window| from getting focus.
     50   virtual bool OnWillFocusWindow(Window* window, const ui::Event* event) = 0;
     51 
     52   // Returns true if |window| can be activated, false otherwise. If |window| has
     53   // a modal child it can not be activated.
     54   virtual bool CanActivateWindow(Window* window) const = 0;
     55 
     56  protected:
     57   virtual ~ActivationClient() {}
     58 };
     59 
     60 // Sets/Gets the activation client on the RootWindow.
     61 AURA_EXPORT void SetActivationClient(RootWindow* root_window,
     62                                      ActivationClient* client);
     63 AURA_EXPORT ActivationClient* GetActivationClient(RootWindow* 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 AURA_EXPORT void SetHideOnDeactivate(Window* window, bool hide_on_deactivate);
     73 AURA_EXPORT bool GetHideOnDeactivate(Window* window);
     74 
     75 }  // namespace clients
     76 }  // namespace aura
     77 
     78 #endif  // UI_AURA_CLIENT_ACTIVATION_CLIENT_H_
     79