aboutsummaryrefslogtreecommitdiff
path: root/src/Workspace.hh
blob: 61abe9c08389ad70e350e19f6d258f78894cdca3 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Workspace.hh for Fluxbox
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
//
// Workspace.hh for Blackbox - an X11 Window manager
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#ifndef	 WORKSPACE_HH
#define	 WORKSPACE_HH

#include "Clientmenu.hh"
#include "Window.hh"
#include "NotCopyable.hh"

#include <X11/Xlib.h>
#include <string>
#include <vector>
#include <list>

class BScreen;

/**
	Handles a single workspace
*/
class Workspace:private NotCopyable {
public:
	typedef std::vector<FluxboxWindow *> Windows;
	typedef std::vector<Window> Stack;

	explicit Workspace(BScreen *screen, unsigned int workspaceid = 0);
	~Workspace();
	
	void setLastFocusedWindow(FluxboxWindow *w);
	/**
		Set workspace name
	*/
	void setName(const std::string &name);
	void showAll();
	void hideAll();
	void removeAll();
	void raiseWindow(FluxboxWindow *win);
	void lowerWindow(FluxboxWindow *win);
	void reconfigure();
	void update();
	void setCurrent();
	void shutdown();
	int addWindow(FluxboxWindow *win, bool place = false);
	int removeWindow(FluxboxWindow *win);
	BScreen *getScreen() { return screen; }
	FluxboxWindow *getLastFocusedWindow() { return lastfocus; }

	const BScreen *getScreen() const { return screen; }	
	const FluxboxWindow *getLastFocusedWindow() const { return lastfocus; }	
	Clientmenu *menu() { return &m_clientmenu; }
	/**
		@return client menu 
	*/
	inline const Clientmenu *menu() const { return &m_clientmenu; }
	/**
		@return name of this workspace
	*/
	inline const std::string &name() const { return m_name; }
	/**
		@return the number of this workspace, note: obsolete, should be in BScreen
	*/
	inline unsigned int workspaceID() const { return m_id; }	
	/**
		@param id the window id number
		@return window that match the id, else 0
	*/
	FluxboxWindow *getWindow(unsigned int id);
	const FluxboxWindow *getWindow(unsigned int id) const;
	const Windows &getWindowList() const { return m_windowlist; }
	Windows &getWindowList() { return m_windowlist; }

	bool isCurrent() const;
	bool isLastWindow(FluxboxWindow *window) const;
	int getCount() const;
	void checkGrouping(FluxboxWindow &win);
	static bool loadGroups(const std::string &filename);
protected:
	void placeWindow(FluxboxWindow *win);

private:

	void raiseAndFillStack(Stack::iterator &it, const FluxboxWindow &win);
	void lowerAndFillStack(Stack::iterator &it, const FluxboxWindow &win);

	BScreen *screen;
	FluxboxWindow *lastfocus;
	Clientmenu m_clientmenu;

	typedef std::list<FluxboxWindow *> WindowStack;
	typedef std::vector<std::string> Group;
	typedef std::vector<Group> GroupList;
	
	static GroupList m_groups; ///< handle auto groupings

	WindowStack stackingList;
	Windows m_windowlist;

	std::string m_name;  ///< name of this workspace
	unsigned int m_id;	///< id, obsolete, this should be in BScreen
	int cascade_x, cascade_y;
};


#endif // WORKSPACE_HH