aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Remember.hh')
-rw-r--r--src/Remember.hh206
1 files changed, 206 insertions, 0 deletions
diff --git a/src/Remember.hh b/src/Remember.hh
new file mode 100644
index 0000000..1671a41
--- /dev/null
+++ b/src/Remember.hh
@@ -0,0 +1,206 @@
1// Remember.hh for Fluxbox Window Manager
2// Copyright (c) 2002 Xavier Brouckaert
3// Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
4// and Simon Bowden (rathnor at users.sourceforge.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// $Id: Remember.hh,v 1.12 2003/07/28 15:06:33 rathnor Exp $
25
26/* Based on the original "Remember patch" by Xavier Brouckaert */
27
28#ifndef REMEMBER_HH
29#define REMEMBER_HH
30
31#include "AtomHandler.hh"
32
33#include <fstream>
34#include <map>
35#include <list>
36#include <string>
37#include <utility>
38
39class FluxboxWindow;
40class BScreen;
41class WinClient;
42class ClientPattern;
43
44class Application {
45public:
46 Application(bool grouped);
47 inline void forgetWorkspace() { workspace_remember = false; }
48 inline void forgetDimensions() { dimensions_remember = false; }
49 inline void forgetPosition() { position_remember = false; }
50 inline void forgetShadedstate() { shadedstate_remember = false; }
51 inline void forgetTabstate() { tabstate_remember = false; }
52 inline void forgetDecostate() { decostate_remember = false; }
53 inline void forgetStuckstate() { stuckstate_remember = false; }
54 inline void forgetJumpworkspace() { jumpworkspace_remember = false; }
55 inline void forgetLayer() { layer_remember = false; }
56 inline void forgetSaveOnClose() { save_on_close_remember = false; }
57
58 inline void rememberWorkspace(int ws)
59 { workspace = ws; workspace_remember = true; }
60 inline void rememberDimensions(int width, int height)
61 { w = width; h = height; dimensions_remember = true; }
62 inline void rememberPosition(int posx, int posy)
63 { x = posx; y = posy; position_remember = true; }
64 inline void rememberShadedstate(bool state)
65 { shadedstate = state; shadedstate_remember = true; }
66 inline void rememberTabstate(bool state)
67 { tabstate = state; tabstate_remember = true; }
68 inline void rememberDecostate(unsigned int state)
69 { decostate = state; decostate_remember = true; }
70 inline void rememberStuckstate(bool state)
71 { stuckstate = state; stuckstate_remember = true; }
72 inline void rememberJumpworkspace(bool state)
73 { jumpworkspace = state; jumpworkspace_remember = true; }
74 inline void rememberLayer(int layernum)
75 { layer = layernum; layer_remember = true; }
76 inline void rememberSaveOnClose(bool state)
77 { save_on_close = state; save_on_close_remember = true; }
78
79
80 bool workspace_remember;
81 unsigned int workspace;
82
83 bool dimensions_remember;
84 int w,h; // width, height
85
86 bool position_remember;
87 int x,y;
88
89 bool shadedstate_remember;
90 bool shadedstate;
91
92 bool tabstate_remember;
93 bool tabstate;
94
95 bool decostate_remember;
96 unsigned int decostate;
97
98 bool stuckstate_remember;
99 bool stuckstate;
100
101 bool jumpworkspace_remember;
102 bool jumpworkspace;
103
104 bool layer_remember;
105 int layer;
106
107 bool save_on_close_remember;
108 bool save_on_close;
109
110 bool is_grouped;
111 FluxboxWindow *group;
112
113};
114
115/**
116 * Class Remember is an atomhandler to avoid interfering with
117 * the main code as much as possible, since we hope that one day
118 * things like this (and maybe toolbar/slit) can become some sort
119 * of modular plugin. Doing this should help give an idea of what
120 * sort of interface abilities we'll need...
121 */
122class Remember : public AtomHandler {
123public:
124 /**
125 * holds which attributes to remember
126 */
127 enum Attribute {
128 REM_WORKSPACE=0,
129 REM_DIMENSIONS,
130 REM_POSITION,
131 REM_STUCKSTATE,
132 REM_DECOSTATE,
133 REM_SHADEDSTATE,
134 //REM_TABSTATE, ... external tabs disabled atm
135 REM_LAYER,
136 REM_JUMPWORKSPACE,
137 REM_SAVEONCLOSE,
138 REM_LASTATTRIB // not actually used
139 };
140
141 // a "pattern" to the relevant app
142 // each app exists ONLY for that pattern.
143 // And we need to keep a list of pairs as we want to keep the
144 // applications in the same order as they will be in the apps file
145 typedef std::list< std::pair<ClientPattern *, Application *> > Patterns;
146
147 // We keep track of which app is assigned to a winclient
148 // particularly useful to update counters etc on windowclose
149 typedef std::map<WinClient *, Application *> Clients;
150
151 // we have to remember any startups we did so that they are saved again
152 typedef std::list<std::string> Startups;
153
154 Remember();
155 ~Remember();
156
157 Application* find(WinClient &winclient);
158 Application* add(WinClient &winclient);
159
160 void load();
161 void save();
162
163 bool isRemembered(WinClient &win, Attribute attrib);
164 void rememberAttrib(WinClient &win, Attribute attrib);
165 void forgetAttrib(WinClient &win, Attribute attrib);
166
167 // Functions relating to AtomHandler
168
169 // Functions we actually use
170 void setupFrame(FluxboxWindow &win);
171 void setupClient(WinClient &winclient);
172 void updateFrameClose(FluxboxWindow &win);
173 void updateClientClose(WinClient &winclient);
174
175 // Functions we ignore (zero from AtomHandler)
176 // Leaving here in case they might be useful later
177
178 void initForScreen(BScreen &screen) {}
179
180 void updateClientList(BScreen &screen) {}
181 void updateWorkspaceNames(BScreen &screen) {}
182 void updateCurrentWorkspace(BScreen &screen) {}
183 void updateWorkspaceCount(BScreen &screen) {}
184
185 void updateWorkspace(FluxboxWindow &win) {}
186 void updateState(FluxboxWindow &win) {}
187 void updateHints(FluxboxWindow &win) {}
188 void updateLayer(FluxboxWindow &win) {}
189
190 bool checkClientMessage(const XClientMessageEvent &ce,
191 BScreen * screen, WinClient * const winclient) { return false; }
192 // ignore this
193 bool propertyNotify(WinClient &winclient, Atom the_property) { return false; }
194private:
195
196 // returns number of lines read
197 // optionally can give a line to read before the first (lookahead line)
198 int parseApp(std::ifstream &file, Application &app, std::string *first_line = 0);
199 Patterns m_pats;
200 Clients m_clients;
201
202 Startups m_startups;
203
204};
205
206#endif // REMEMBER_HH