window_tree_client.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file.
41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef UI_AURA_CLIENT_WINDOW_TREE_CLIENT_H_
61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define UI_AURA_CLIENT_WINDOW_TREE_CLIENT_H_
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/aura/aura_export.h"
91e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
101e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace gfx {
111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class Rect;
121e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace aura {
151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class Window;
161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace client {
171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Implementations of this object are used to help locate a default parent for
191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// NULL-parented Windows.
201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AURA_EXPORT WindowTreeClient {
211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public:
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual ~WindowTreeClient() {}
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Called by the Window when it looks for a default parent. Returns the
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // window that |window| should be added to instead. |context| provides a
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Window (generally a RootWindow) that can be used to determine which
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // desktop type the default parent should be chosen from.  NOTE: this may
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // have side effects. It should only be used when |window| is going to be
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // immediately added.
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  //
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // TODO(erg): Remove |context|, and maybe after oshima's patch lands,
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // |bounds|.
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual Window* GetDefaultParent(
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      Window* context,
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      Window* window,
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      const gfx::Rect& bounds) = 0;
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)};
381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Set/Get a window tree client for the RootWindow containing |window|. |window|
401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// must not be NULL.
411e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)AURA_EXPORT void SetWindowTreeClient(Window* window,
421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                     WindowTreeClient* window_tree_client);
431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)WindowTreeClient* GetWindowTreeClient(Window* window);
441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Adds |window| to an appropriate parent by consulting an implementation of
461e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// WindowTreeClient attached at the root Window containing |context|. The final
471e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// location may be a window hierarchy other than the one supplied via
481e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// |context|, which must not be NULL. |screen_bounds| may be empty.
491e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)AURA_EXPORT void ParentWindowWithContext(Window* window,
501e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                         Window* context,
511e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                                         const gfx::Rect& screen_bounds);
521e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace client
541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}  // namespace aura
551e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
561e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif  // UI_AURA_CLIENT_WINDOW_TREE_CLIENT_H_
57