summaryrefslogtreecommitdiff
path: root/chromium/ui/wm/public/activation_client.h
blob: a2b5ee714ec91b82ca175b1d40aad502f8ef2ec5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_WM_PUBLIC_ACTIVATION_CLIENT_H_
#define UI_WM_PUBLIC_ACTIVATION_CLIENT_H_

#include "ui/wm/public/wm_public_export.h"

namespace aura {
class Window;
}

namespace wm {
class ActivationChangeObserver;

// An interface implemented by an object that manages window activation.
class WM_PUBLIC_EXPORT ActivationClient {
 public:
  // Adds/Removes ActivationChangeObservers.
  virtual void AddObserver(ActivationChangeObserver* observer) = 0;
  virtual void RemoveObserver(ActivationChangeObserver* observer) = 0;

  // Activates |window|. If |window| is NULL, nothing happens.
  virtual void ActivateWindow(aura::Window* window) = 0;

  // Deactivates |window|. What (if anything) is activated next is up to the
  // client. If |window| is NULL, nothing happens.
  virtual void DeactivateWindow(aura::Window* window) = 0;

  // Retrieves the active window, or NULL if there is none.
  aura::Window* GetActiveWindow() {
    return const_cast<aura::Window*>(
        const_cast<const ActivationClient*>(this)->GetActiveWindow());
  }
  virtual const aura::Window* GetActiveWindow() const = 0;

  // Retrieves the activatable window for |window|, or NULL if there is none.
  // Note that this is often but not always the toplevel window (see
  // GetToplevelWindow() below), as the toplevel window may not be activatable
  // (for example it may be blocked by a modal transient, or some other
  // condition).
  virtual aura::Window* GetActivatableWindow(aura::Window* window) = 0;

  // Retrieves the toplevel window for |window|, or NULL if there is none.
  virtual aura::Window* GetToplevelWindow(aura::Window* window) = 0;

  // Returns true if |window| can be activated, false otherwise. If |window| has
  // a modal child it can not be activated.
  virtual bool CanActivateWindow(aura::Window* window) const = 0;

 protected:
  virtual ~ActivationClient() {}
};

// Sets/Gets the activation client on the root Window.
WM_PUBLIC_EXPORT void SetActivationClient(aura::Window* root_window,
                                          ActivationClient* client);
WM_PUBLIC_EXPORT ActivationClient* GetActivationClient(
    aura::Window* root_window);
WM_PUBLIC_EXPORT const ActivationClient* GetActivationClient(
    const aura::Window* root_window);

// Some types of transient window are only visible when active.
// The transient parents of these windows may have visual appearance properties
// that differ from transient parents that can be deactivated.
// The presence of this property implies these traits.
// TODO(beng): currently the UI framework (views) implements the actual
//             close-on-deactivate component of this feature but it should be
//             possible to implement in the aura client.
WM_PUBLIC_EXPORT void SetHideOnDeactivate(aura::Window* window,
                                          bool hide_on_deactivate);
WM_PUBLIC_EXPORT bool GetHideOnDeactivate(aura::Window* window);

}  // namespace wm

#endif  // UI_WM_PUBLIC_ACTIVATION_CLIENT_H_