summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/fluxbox.cc228
2 files changed, 6 insertions, 223 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8f8b950..476f6ae 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,6 +114,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \
114 FocusModelMenuItem.hh \ 114 FocusModelMenuItem.hh \
115 ToggleMenu.hh \ 115 ToggleMenu.hh \
116 HeadArea.hh HeadArea.cc \ 116 HeadArea.hh HeadArea.cc \
117 Resources.cc \
117 ${newwmspec_SOURCE} ${gnome_SOURCE} \ 118 ${newwmspec_SOURCE} ${gnome_SOURCE} \
118 ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} 119 ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE}
119 120
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index b973227..c7828ac 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.255 2004/09/11 20:29:29 fluxgen Exp $ 25// $Id: fluxbox.cc,v 1.256 2004/09/12 14:01:29 fluxgen Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -150,224 +150,6 @@ class Toolbar { };
150using namespace std; 150using namespace std;
151using namespace FbTk; 151using namespace FbTk;
152 152
153//-----------------------------------------------------------------
154//---- accessors for int, bool, and some enums with Resource ------
155//-----------------------------------------------------------------
156
157template<>
158void FbTk::Resource<int>::
159setFromString(const char* strval) {
160 int val;
161 if (sscanf(strval, "%d", &val)==1)
162 *this = val;
163}
164
165template<>
166void FbTk::Resource<std::string>::
167setFromString(const char *strval) {
168 *this = strval;
169}
170
171template<>
172void FbTk::Resource<bool>::
173setFromString(char const *strval) {
174 *this = (bool)!strcasecmp(strval, "true");
175}
176
177template<>
178void FbTk::Resource<Fluxbox::TitlebarList>::
179setFromString(char const *strval) {
180 vector<std::string> val;
181 StringUtil::stringtok(val, strval);
182 int size=val.size();
183 //clear old values
184 m_value.clear();
185
186 for (int i=0; i<size; i++) {
187 if (strcasecmp(val[i].c_str(), "Maximize")==0)
188 m_value.push_back(Fluxbox::MAXIMIZE);
189 else if (strcasecmp(val[i].c_str(), "Minimize")==0)
190 m_value.push_back(Fluxbox::MINIMIZE);
191 else if (strcasecmp(val[i].c_str(), "Shade")==0)
192 m_value.push_back(Fluxbox::SHADE);
193 else if (strcasecmp(val[i].c_str(), "Stick")==0)
194 m_value.push_back(Fluxbox::STICK);
195 else if (strcasecmp(val[i].c_str(), "Menu")==0)
196 m_value.push_back(Fluxbox::MENU);
197 else if (strcasecmp(val[i].c_str(), "Close")==0)
198 m_value.push_back(Fluxbox::CLOSE);
199 }
200}
201
202template<>
203void FbTk::Resource<Fluxbox::TabsAttachArea>::
204setFromString(char const *strval) {
205 if (strcasecmp(strval, "Titlebar")==0)
206 m_value= Fluxbox::ATTACH_AREA_TITLEBAR;
207 else
208 m_value= Fluxbox::ATTACH_AREA_WINDOW;
209}
210
211template<>
212void FbTk::Resource<unsigned int>::
213setFromString(const char *strval) {
214 if (sscanf(strval, "%ul", &m_value) != 1)
215 setDefaultValue();
216}
217
218template<>
219void FbTk::Resource<long long>::
220setFromString(const char *strval) {
221 if (sscanf(strval, "%ul", &m_value) != 1)
222 setDefaultValue();
223}
224
225
226//-----------------------------------------------------------------
227//---- manipulators for int, bool, and some enums with Resource ---
228//-----------------------------------------------------------------
229template<>
230std::string FbTk::Resource<bool>::
231getString() {
232 return std::string(**this == true ? "true" : "false");
233}
234
235template<>
236std::string FbTk::Resource<int>::
237getString() {
238 char strval[256];
239 sprintf(strval, "%d", **this);
240 return std::string(strval);
241}
242
243template<>
244std::string FbTk::Resource<std::string>::
245getString() { return **this; }
246
247
248template<>
249std::string FbTk::Resource<Fluxbox::TitlebarList>::
250getString() {
251 string retval;
252 int size=m_value.size();
253 for (int i=0; i<size; i++) {
254 switch (m_value[i]) {
255 case Fluxbox::SHADE:
256 retval.append("Shade");
257 break;
258 case Fluxbox::MINIMIZE:
259 retval.append("Minimize");
260 break;
261 case Fluxbox::MAXIMIZE:
262 retval.append("Maximize");
263 break;
264 case Fluxbox::CLOSE:
265 retval.append("Close");
266 break;
267 case Fluxbox::STICK:
268 retval.append("Stick");
269 break;
270 case Fluxbox::MENU:
271 retval.append("Menu");
272 break;
273 default:
274 break;
275 }
276 retval.append(" ");
277 }
278
279 return retval;
280}
281
282template<>
283std::string FbTk::Resource<Fluxbox::TabsAttachArea>::
284getString() {
285 if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR)
286 return "Titlebar";
287 else
288 return "Window";
289}
290
291template<>
292string FbTk::Resource<unsigned int>::
293getString() {
294 char tmpstr[128];
295 sprintf(tmpstr, "%ul", m_value);
296 return string(tmpstr);
297}
298
299template<>
300string FbTk::Resource<long long>::
301getString() {
302 char tmpstr[128];
303 sprintf(tmpstr, "%ul", m_value);
304 return string(tmpstr);
305}
306
307template<>
308void FbTk::Resource<Fluxbox::Layer>::
309setFromString(const char *strval) {
310 int tempnum = 0;
311 if (sscanf(strval, "%d", &tempnum) == 1)
312 m_value = tempnum;
313 else if (strcasecmp(strval, "Menu") == 0)
314 m_value = Fluxbox::instance()->getMenuLayer();
315 else if (strcasecmp(strval, "AboveDock") == 0)
316 m_value = Fluxbox::instance()->getAboveDockLayer();
317 else if (strcasecmp(strval, "Dock") == 0)
318 m_value = Fluxbox::instance()->getDockLayer();
319 else if (strcasecmp(strval, "Top") == 0)
320 m_value = Fluxbox::instance()->getTopLayer();
321 else if (strcasecmp(strval, "Normal") == 0)
322 m_value = Fluxbox::instance()->getNormalLayer();
323 else if (strcasecmp(strval, "Bottom") == 0)
324 m_value = Fluxbox::instance()->getBottomLayer();
325 else if (strcasecmp(strval, "Desktop") == 0)
326 m_value = Fluxbox::instance()->getDesktopLayer();
327 else
328 setDefaultValue();
329}
330
331
332template<>
333string FbTk::Resource<Fluxbox::Layer>::
334getString() {
335
336 if (m_value.getNum() == Fluxbox::instance()->getMenuLayer())
337 return string("Menu");
338 else if (m_value.getNum() == Fluxbox::instance()->getAboveDockLayer())
339 return string("AboveDock");
340 else if (m_value.getNum() == Fluxbox::instance()->getDockLayer())
341 return string("Dock");
342 else if (m_value.getNum() == Fluxbox::instance()->getTopLayer())
343 return string("Top");
344 else if (m_value.getNum() == Fluxbox::instance()->getNormalLayer())
345 return string("Normal");
346 else if (m_value.getNum() == Fluxbox::instance()->getBottomLayer())
347 return string("Bottom");
348 else if (m_value.getNum() == Fluxbox::instance()->getDesktopLayer())
349 return string("Desktop");
350 else {
351 char tmpstr[128];
352 sprintf(tmpstr, "%d", m_value.getNum());
353 return string(tmpstr);
354 }
355}
356template<>
357void FbTk::Resource<long>::
358setFromString(const char *strval) {
359 if (sscanf(strval, "%ld", &m_value) != 1)
360 setDefaultValue();
361}
362
363template<>
364string FbTk::Resource<long>::
365getString() {
366 char tmpstr[128];
367 sprintf(tmpstr, "%ld", m_value);
368 return string(tmpstr);
369}
370
371static Window last_bad_window = None; 153static Window last_bad_window = None;
372namespace { 154namespace {
373void copyFile(const std::string &from, const std::string &to) { 155void copyFile(const std::string &from, const std::string &to) {
@@ -1097,11 +879,11 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) {
1097 if (be.button == 1) { 879 if (be.button == 1) {
1098 if (! screen->isRootColormapInstalled()) 880 if (! screen->isRootColormapInstalled())
1099 screen->imageControl().installRootColormap(); 881 screen->imageControl().installRootColormap();
1100 882 // hide menus
1101 if (screen->getWorkspacemenu().isVisible())
1102 screen->getWorkspacemenu().hide();
1103 if (screen->getRootmenu().isVisible()) 883 if (screen->getRootmenu().isVisible())
1104 screen->getRootmenu().hide(); 884 screen->getRootmenu().hide();
885 if (screen->getWorkspacemenu().isVisible())
886 screen->getWorkspacemenu().hide();
1105 887
1106 } else if (be.button == 2) { 888 } else if (be.button == 2) {
1107 FbCommands::ShowWorkspaceMenuCmd cmd; 889 FbCommands::ShowWorkspaceMenuCmd cmd;
@@ -1248,7 +1030,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) {
1248 switch (ke.type) { 1030 switch (ke.type) {
1249 case KeyPress: 1031 case KeyPress:
1250 m_key->doAction(ke); 1032 m_key->doAction(ke);
1251 break; 1033 break;
1252 case KeyRelease: { 1034 case KeyRelease: {
1253 // we ignore most key releases unless we need to use 1035 // we ignore most key releases unless we need to use
1254 // a release to stop something (e.g. window cycling). 1036 // a release to stop something (e.g. window cycling).