]> icculus.org git repositories - mikachu/openbox.git/blob - src/Workspace.hh
re-added UnderMouse Placement
[mikachu/openbox.git] / src / Workspace.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Workspace.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef   __Workspace_hh
25 #define   __Workspace_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29 }
30
31 #include <list>
32 #include <string>
33 #include <vector>
34
35 class BScreen;
36 class Clientmenu;
37 class Workspace;
38 class BlackboxWindow;
39 class Netizen;
40
41 typedef std::list<BlackboxWindow*> BlackboxWindowList;
42 typedef std::vector<Window> StackVector;
43
44 class Workspace {
45 private:
46   BScreen *screen;
47   BlackboxWindow *lastfocus;
48   Clientmenu *clientmenu;
49
50   BlackboxWindowList stackingList, windowList;
51
52   std::string name;
53   unsigned int id;
54   int cascade_x, cascade_y;
55
56   Workspace(const Workspace&);
57   Workspace& operator=(const Workspace&);
58
59   void raiseTransients(const BlackboxWindow * const win,
60                        StackVector::iterator &stack);
61   void lowerTransients(const BlackboxWindow * const win,
62                        StackVector::iterator &stack);
63
64   void placeWindow(BlackboxWindow *win);
65   bool cascadePlacement(Rect& win, const Rect& availableArea);
66   bool smartPlacement(Rect& win, const Rect& availableArea);
67   bool underMousePlacement(Rect& win, const Rect& availableArea);
68
69 public:
70   Workspace(BScreen *scrn, unsigned int i = 0);
71
72   inline BScreen *getScreen(void) { return screen; }
73
74   inline BlackboxWindow *getLastFocusedWindow(void) { return lastfocus; }
75
76   inline Clientmenu *getMenu(void) { return clientmenu; }
77
78   inline const std::string& getName(void) const { return name; }
79
80   inline unsigned int getID(void) const { return id; }
81
82   inline void setLastFocusedWindow(BlackboxWindow *w) { lastfocus = w; }
83
84   BlackboxWindow* getWindow(unsigned int index);
85   BlackboxWindow* getNextWindowInList(BlackboxWindow *w);
86   BlackboxWindow* getPrevWindowInList(BlackboxWindow *w);
87   BlackboxWindow* getTopWindowOnStack(void) const;
88   void sendWindowList(Netizen &n);
89
90   bool isCurrent(void) const;
91   bool isLastWindow(const BlackboxWindow* w) const;
92
93   void addWindow(BlackboxWindow *w, bool place = False);
94   unsigned int removeWindow(BlackboxWindow *w);
95   unsigned int getCount(void) const;
96
97   void showAll(void);
98   void hideAll(void);
99   void removeAll(void);
100   void raiseWindow(BlackboxWindow *w);
101   void lowerWindow(BlackboxWindow *w);
102   void reconfigure(void);
103   void updateFocusModel(void);
104   void setCurrent(void);
105   void setName(const std::string& new_name);
106 };
107
108
109 #endif // __Workspace_hh
110