aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Remember.hh')
-rw-r--r--src/Remember.hh221
1 files changed, 221 insertions, 0 deletions
diff --git a/src/Remember.hh b/src/Remember.hh
new file mode 100644
index 0000000..a93e3f5
--- /dev/null
+++ b/src/Remember.hh
@@ -0,0 +1,221 @@
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.13 2003/12/11 15:23:14 fluxgen 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, unsigned char rfc= 0 )
63 { x = posx; y = posy; refc = rfc; 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 unsigned char refc; // referenceCorner-> 0 - upperleft
89 // 1 - upperight
90 // 2 - lowerleft
91 // 3 - lowerright
92
93 bool shadedstate_remember;
94 bool shadedstate;
95
96 bool tabstate_remember;
97 bool tabstate;
98
99 bool decostate_remember;
100 unsigned int decostate;
101
102 bool stuckstate_remember;
103 bool stuckstate;
104
105 bool jumpworkspace_remember;
106 bool jumpworkspace;
107
108 bool layer_remember;
109 int layer;
110
111 bool save_on_close_remember;
112 bool save_on_close;
113
114 bool is_grouped;
115 FluxboxWindow *group;
116
117};
118
119/**
120 * Class Remember is an atomhandler to avoid interfering with
121 * the main code as much as possible, since we hope that one day
122 * things like this (and maybe toolbar/slit) can become some sort
123 * of modular plugin. Doing this should help give an idea of what
124 * sort of interface abilities we'll need...
125 */
126class Remember : public AtomHandler {
127public:
128 /**
129 * holds which attributes to remember
130 */
131 enum Attribute {
132 REM_WORKSPACE=0,
133 REM_DIMENSIONS,
134 REM_POSITION,
135 REM_STUCKSTATE,
136 REM_DECOSTATE,
137 REM_SHADEDSTATE,
138 //REM_TABSTATE, ... external tabs disabled atm
139 REM_LAYER,
140 REM_JUMPWORKSPACE,
141 REM_SAVEONCLOSE,
142 REM_LASTATTRIB // not actually used
143 };
144
145 enum {
146 POS_UPPERLEFT= 0,
147 POS_UPPERRIGHT,
148 POS_LOWERLEFT,
149 POS_LOWERRIGHT,
150 POS_CENTER,
151 POS_WINCENTER
152 };
153
154
155
156 // a "pattern" to the relevant app
157 // each app exists ONLY for that pattern.
158 // And we need to keep a list of pairs as we want to keep the
159 // applications in the same order as they will be in the apps file
160 typedef std::list< std::pair<ClientPattern *, Application *> > Patterns;
161
162 // We keep track of which app is assigned to a winclient
163 // particularly useful to update counters etc on windowclose
164 typedef std::map<WinClient *, Application *> Clients;
165
166 // we have to remember any startups we did so that they are saved again
167 typedef std::list<std::string> Startups;
168
169 Remember();
170 ~Remember();
171
172 Application* find(WinClient &winclient);
173 Application* add(WinClient &winclient);
174
175 void load();
176 void save();
177
178 bool isRemembered(WinClient &win, Attribute attrib);
179 void rememberAttrib(WinClient &win, Attribute attrib);
180 void forgetAttrib(WinClient &win, Attribute attrib);
181
182 // Functions relating to AtomHandler
183
184 // Functions we actually use
185 void setupFrame(FluxboxWindow &win);
186 void setupClient(WinClient &winclient);
187 void updateFrameClose(FluxboxWindow &win);
188 void updateClientClose(WinClient &winclient);
189
190 // Functions we ignore (zero from AtomHandler)
191 // Leaving here in case they might be useful later
192
193 void initForScreen(BScreen &screen) {}
194
195 void updateClientList(BScreen &screen) {}
196 void updateWorkspaceNames(BScreen &screen) {}
197 void updateCurrentWorkspace(BScreen &screen) {}
198 void updateWorkspaceCount(BScreen &screen) {}
199
200 void updateWorkspace(FluxboxWindow &win) {}
201 void updateState(FluxboxWindow &win) {}
202 void updateHints(FluxboxWindow &win) {}
203 void updateLayer(FluxboxWindow &win) {}
204
205 bool checkClientMessage(const XClientMessageEvent &ce,
206 BScreen * screen, WinClient * const winclient) { return false; }
207 // ignore this
208 bool propertyNotify(WinClient &winclient, Atom the_property) { return false; }
209private:
210
211 // returns number of lines read
212 // optionally can give a line to read before the first (lookahead line)
213 int parseApp(std::ifstream &file, Application &app, std::string *first_line = 0);
214 Patterns m_pats;
215 Clients m_clients;
216
217 Startups m_startups;
218
219};
220
221#endif // REMEMBER_HH