| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef WINDOW_MANAGER_STACKING_MANAGER_H_ | 5 #ifndef WINDOW_MANAGER_STACKING_MANAGER_H_ | 
| 6 #define WINDOW_MANAGER_STACKING_MANAGER_H_ | 6 #define WINDOW_MANAGER_STACKING_MANAGER_H_ | 
| 7 | 7 | 
| 8 #include <map> | 8 #include <map> | 
| 9 #include <set> |  | 
| 10 #include <tr1/memory> | 9 #include <tr1/memory> | 
| 11 | 10 | 
| 12 #include <gtest/gtest_prod.h>  // for FRIEND_TEST() macro | 11 #include <gtest/gtest_prod.h>  // for FRIEND_TEST() macro | 
| 13 | 12 | 
| 14 #include "window_manager/compositor.h" | 13 #include "window_manager/compositor.h" | 
| 15 #include "window_manager/x_types.h" | 14 #include "window_manager/x_types.h" | 
| 16 | 15 | 
| 17 namespace window_manager { | 16 namespace window_manager { | 
| 18 | 17 | 
| 19 class AtomCache; | 18 class AtomCache; | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 77     LAYER_SNAPSHOT_WINDOW, | 76     LAYER_SNAPSHOT_WINDOW, | 
| 78 | 77 | 
| 79     // The background image. | 78     // The background image. | 
| 80     LAYER_BACKGROUND, | 79     LAYER_BACKGROUND, | 
| 81 | 80 | 
| 82     kNumLayers, | 81     kNumLayers, | 
| 83   }; | 82   }; | 
| 84 | 83 | 
| 85   // Is the passed-in X window one of our internal windows? | 84   // Is the passed-in X window one of our internal windows? | 
| 86   bool IsInternalWindow(XWindow xid) { | 85   bool IsInternalWindow(XWindow xid) { | 
| 87     return (xids_.find(xid) != xids_.end()); | 86     return (xid_to_layer_.find(xid) != xid_to_layer_.end()); | 
| 88   } | 87   } | 
| 89 | 88 | 
| 90   // Stack a window (both its X window and its compositor actor) at the top | 89   // Stack a window (both its X window and its compositor actor) at the top | 
| 91   // of the passed-in layer.  Its shadow will be stacked at the bottom of | 90   // of the passed-in layer.  Its shadow will be stacked at the bottom of | 
| 92   // the layer so as to not appear above the windows' siblings.  Returns | 91   // the layer so as to not appear above the windows' siblings.  Returns | 
| 93   // false if the X request fails. | 92   // false if the X request fails. | 
| 94   bool StackWindowAtTopOfLayer(Window* win, Layer layer); | 93   bool StackWindowAtTopOfLayer(Window* win, Layer layer); | 
| 95 | 94 | 
| 96   // Stack an X window at the top of the passed-in layer.  This is useful for X | 95   // Stack an X window at the top of the passed-in layer.  This is useful for X | 
| 97   // windows that don't have Window objects associated with them (e.g. input | 96   // windows that don't have Window objects associated with them (e.g. input | 
| 98   // windows).  Returns false if the X request fails. | 97   // windows).  Returns false if the X request fails. | 
| 99   bool StackXidAtTopOfLayer(XWindow xid, Layer layer); | 98   bool StackXidAtTopOfLayer(XWindow xid, Layer layer); | 
| 100 | 99 | 
| 101   // Stack a compositor actor at the top of the passed-in layer. | 100   // Stack a compositor actor at the top of the passed-in layer. | 
| 102   void StackActorAtTopOfLayer(Compositor::Actor* actor, Layer layer); | 101   void StackActorAtTopOfLayer(Compositor::Actor* actor, Layer layer); | 
| 103 | 102 | 
| 104   // Stack a window's client and composited windows directly above or below | 103   // Stack a window's client and composited windows directly above or below | 
| 105   // another window.  As in StackWindowAtTopOfLayer(), the window's shadow | 104   // another window.  As in StackWindowAtTopOfLayer(), the window's shadow | 
| 106   // will be stacked at the bottom of 'layer'.  Make sure that 'sibling' is | 105   // will be stacked at the bottom of 'layer'.  Make sure that 'sibling' is | 
| 107   // in 'layer' -- things will get confusing otherwise. | 106   // in 'layer' -- things will get confusing otherwise. | 
| 108   bool StackWindowRelativeToOtherWindow( | 107   bool StackWindowRelativeToOtherWindow( | 
| 109       Window* win, Window* sibling, bool above, Layer layer); | 108       Window* win, Window* sibling, bool above, Layer layer); | 
| 110 | 109 | 
|  | 110   // If 'xid' is being used as a layer's stacking reference point, return | 
|  | 111   // the actor corresponding to the layer.  Returns NULL otherwise. | 
|  | 112   Compositor::Actor* GetActorIfLayerXid(XWindow xid); | 
|  | 113 | 
| 111  private: | 114  private: | 
| 112   friend class BasicWindowManagerTest;  // uses Get*ForLayer() | 115   friend class BasicWindowManagerTest;  // uses Get*ForLayer() | 
| 113   FRIEND_TEST(LayoutManagerTest, InitialWindowStacking);  // uses 'layer_to_*' | 116   FRIEND_TEST(LayoutManagerTest, InitialWindowStacking);  // uses 'layer_to_*' | 
|  | 117   FRIEND_TEST(WindowManagerTest, StackOverrideRedirectWindowsAboveLayers); | 
| 114 | 118 | 
| 115   // Get a layer's name. | 119   // Get a layer's name. | 
| 116   static const char* LayerToName(Layer layer); | 120   static const char* LayerToName(Layer layer); | 
| 117 | 121 | 
| 118   // Get the actor or XID for a particular layer.  These crash if the layer | 122   // Get the actor or XID for a particular layer.  These crash if the layer | 
| 119   // is invalid. | 123   // is invalid. | 
| 120   Compositor::Actor* GetActorForLayer(Layer layer); | 124   Compositor::Actor* GetActorForLayer(Layer layer); | 
| 121   XWindow GetXidForLayer(Layer layer); | 125   XWindow GetXidForLayer(Layer layer); | 
| 122 | 126 | 
| 123   XConnection* xconn_;  // not owned | 127   XConnection* xconn_;  // not owned | 
| 124 | 128 | 
| 125   // Maps from layers to the corresponding X or Compositor reference points. | 129   // Maps from layers to the corresponding X or Compositor reference points. | 
| 126   // The reference points are stacked at the top of their corresponding | 130   // The reference points are stacked at the top of their corresponding | 
| 127   // layer (in other words, the Stack*AtTopOfLayer() methods will stack | 131   // layer (in other words, the Stack*AtTopOfLayer() methods will stack | 
| 128   // windows and actors directly beneath the corresponding reference | 132   // windows and actors directly beneath the corresponding reference | 
| 129   // points). | 133   // points). | 
| 130   std::map<Layer, XWindow> layer_to_xid_; | 134   std::map<Layer, XWindow> layer_to_xid_; | 
| 131   std::map<Layer, std::tr1::shared_ptr<Compositor::Actor> > | 135   std::map<Layer, std::tr1::shared_ptr<Compositor::Actor> > | 
| 132       layer_to_actor_; | 136       layer_to_actor_; | 
| 133 | 137 | 
| 134   // Set we can use for quick lookup of whether an X window belongs to us. | 138   // Map we can use for quick lookup of whether an X window belongs to us, | 
| 135   std::set<XWindow> xids_; | 139   // and to find the layer corresponding to an X window. | 
|  | 140   std::map<XWindow, Layer> xid_to_layer_; | 
| 136 }; | 141 }; | 
| 137 | 142 | 
| 138 }  // namespace window_manager | 143 }  // namespace window_manager | 
| 139 | 144 | 
| 140 #endif  // WINDOW_MANAGER_STACKING_MANAGER_H_ | 145 #endif  // WINDOW_MANAGER_STACKING_MANAGER_H_ | 
| OLD | NEW | 
|---|