aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-04-16 16:18:06 (GMT)
committerrathnor <rathnor>2003-04-16 16:18:06 (GMT)
commite48f7836fdaca03e0626b3e7ac4d37c99dd35dc9 (patch)
treedd5421ed6b26c0d882dd34a91dfc01eb1ae3ee85 /src
parent9163668e98e1683b95fb5cc44c19b3695c7857c4 (diff)
downloadfluxbox-e48f7836fdaca03e0626b3e7ac4d37c99dd35dc9.zip
fluxbox-e48f7836fdaca03e0626b3e7ac4d37c99dd35dc9.tar.bz2
fix saving of various slit params (Simon)
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc91
-rw-r--r--src/Screen.hh20
-rw-r--r--src/Slit.cc54
-rw-r--r--src/Slit.hh6
-rw-r--r--src/fluxbox.cc7
5 files changed, 146 insertions, 32 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index c25de83..196170e 100644
--- a/src/Screen.cc
+++ b/src/Screen.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: Screen.cc,v 1.125 2003/04/16 14:43:01 rathnor Exp $ 25// $Id: Screen.cc,v 1.126 2003/04/16 16:17:56 rathnor Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -193,6 +193,29 @@ setFromString(const char *strval) {
193} 193}
194 194
195template<> 195template<>
196void Resource<Slit::Placement>::
197setFromString(const char *strval) {
198 if (strcasecmp(strval, "TopLeft")==0)
199 m_value = Slit::TOPLEFT;
200 else if (strcasecmp(strval, "CenterLeft")==0)
201 m_value = Slit::CENTERLEFT;
202 else if (strcasecmp(strval, "BottomLeft")==0)
203 m_value = Slit::BOTTOMLEFT;
204 else if (strcasecmp(strval, "TopCenter")==0)
205 m_value = Slit::TOPCENTER;
206 else if (strcasecmp(strval, "BottomCenter")==0)
207 m_value = Slit::BOTTOMCENTER;
208 else if (strcasecmp(strval, "TopRight")==0)
209 m_value = Slit::TOPRIGHT;
210 else if (strcasecmp(strval, "CenterRight")==0)
211 m_value = Slit::CENTERRIGHT;
212 else if (strcasecmp(strval, "BottomRight")==0)
213 m_value = Slit::BOTTOMRIGHT;
214 else
215 setDefaultValue();
216}
217
218template<>
196void Resource<ToolbarHandler::ToolbarMode>:: 219void Resource<ToolbarHandler::ToolbarMode>::
197setFromString(const char *strval) { 220setFromString(const char *strval) {
198 if (strcasecmp(strval, "Off") == 0) 221 if (strcasecmp(strval, "Off") == 0)
@@ -212,6 +235,16 @@ setFromString(const char *strval) {
212} 235}
213 236
214template<> 237template<>
238void Resource<Slit::Direction>::
239setFromString(const char *strval) {
240 if (strcasecmp(strval, "Vertical") == 0)
241 m_value = Slit::VERTICAL;
242 else if (strcasecmp(strval, "Horizontal") == 0)
243 m_value = Slit::HORIZONTAL;
244 else
245 setDefaultValue();
246}
247
215string Resource<Toolbar::Placement>:: 248string Resource<Toolbar::Placement>::
216getString() { 249getString() {
217 switch (m_value) { 250 switch (m_value) {
@@ -256,6 +289,39 @@ getString() {
256 return string("BottomCenter"); 289 return string("BottomCenter");
257} 290}
258 291
292
293string Resource<Slit::Placement>::
294getString() {
295 switch (m_value) {
296 case Slit::TOPLEFT:
297 return string("TopLeft");
298 break;
299 case Slit::CENTERLEFT:
300 return string("CenterLeft");
301 break;
302 case Slit::BOTTOMLEFT:
303 return string("BottomLeft");
304 break;
305 case Slit::TOPCENTER:
306 return string("TopCenter");
307 break;
308 case Slit::BOTTOMCENTER:
309 return string("BottomCenter");
310 break;
311 case Slit::TOPRIGHT:
312 return string("TopRight");
313 break;
314 case Slit::CENTERRIGHT:
315 return string("CenterRight");
316 break;
317 case Slit::BOTTOMRIGHT:
318 return string("BottomRight");
319 break;
320 }
321 //default string
322 return string("BottomRight");
323}
324
259template<> 325template<>
260string Resource<ToolbarHandler::ToolbarMode>:: 326string Resource<ToolbarHandler::ToolbarMode>::
261getString() { 327getString() {
@@ -284,6 +350,22 @@ getString() {
284 return string("Icons"); 350 return string("Icons");
285} 351}
286 352
353template<>
354string Resource<Slit::Direction>::
355getString() {
356 switch (m_value) {
357 case Slit::VERTICAL:
358 return string("Vertical");
359 break;
360 case Slit::HORIZONTAL:
361 return string("Horizontal");
362 break;
363 }
364 // default string
365 return string("Vertical");
366}
367
368
287namespace { 369namespace {
288 370
289class AddWorkspaceCmd:public FbTk::Command { 371class AddWorkspaceCmd:public FbTk::Command {
@@ -400,7 +482,12 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
400 toolbar_mode(rm, ToolbarHandler::ICONS, scrname+".toolbar.mode", altscrname+".Toolbar.Mode"), 482 toolbar_mode(rm, ToolbarHandler::ICONS, scrname+".toolbar.mode", altscrname+".Toolbar.Mode"),
401 toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), 483 toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"),
402 toolbar_placement(rm, Toolbar::BOTTOMCENTER, 484 toolbar_placement(rm, Toolbar::BOTTOMCENTER,
403 scrname+".toolbar.placement", altscrname+".Toolbar.Placement") 485 scrname+".toolbar.placement", altscrname+".Toolbar.Placement"),
486 slit_auto_hide(rm, false, scrname+".slit.autoHide", altscrname+".Slit.AutoHide"),
487 slit_placement(rm, Slit::BOTTOMRIGHT,
488 scrname+".slit.placement", altscrname+".Slit.Placement"),
489 slit_direction(rm, Slit::VERTICAL, scrname+".slit.direction", altscrname+".Slit.Direction")
490
404{ 491{
405 492
406}; 493};
diff --git a/src/Screen.hh b/src/Screen.hh
index 21d31f3..8b4d74a 100644
--- a/src/Screen.hh
+++ b/src/Screen.hh
@@ -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: Screen.hh,v 1.79 2003/04/16 14:43:02 rathnor Exp $ 25// $Id: Screen.hh,v 1.80 2003/04/16 16:17:57 rathnor Exp $
26 26
27#ifndef SCREEN_HH 27#ifndef SCREEN_HH
28#define SCREEN_HH 28#define SCREEN_HH
@@ -36,6 +36,7 @@
36#include "MultLayers.hh" 36#include "MultLayers.hh"
37#include "XLayerItem.hh" 37#include "XLayerItem.hh"
38#include "ToolbarHandler.hh" 38#include "ToolbarHandler.hh"
39#include "Slit.hh"
39 40
40#include <X11/Xlib.h> 41#include <X11/Xlib.h>
41#include <X11/Xresource.h> 42#include <X11/Xresource.h>
@@ -52,7 +53,6 @@
52#endif // HAVE_CONFIG_H 53#endif // HAVE_CONFIG_H
53 54
54class Netizen; 55class Netizen;
55class Slit;
56class Toolbar; 56class Toolbar;
57class FbWinFrameTheme; 57class FbWinFrameTheme;
58class RootTheme; 58class RootTheme;
@@ -109,15 +109,16 @@ public:
109 inline const std::string &getRootCommand() const { return *resource.rootcommand; } 109 inline const std::string &getRootCommand() const { return *resource.rootcommand; }
110 inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } 110 inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; }
111 111
112 inline bool doSlitAutoHide() const { return resource.slit_auto_hide; } 112 inline bool &doSlitAutoHide() { return *resource.slit_auto_hide; }
113 inline const bool &doSlitAutoHide() const { return *resource.slit_auto_hide; }
113#ifdef SLIT 114#ifdef SLIT
114 inline Slit *getSlit() { return m_slit.get(); } 115 inline Slit *getSlit() { return m_slit.get(); }
115 inline const Slit *getSlit() const { return m_slit.get(); } 116 inline const Slit *getSlit() const { return m_slit.get(); }
116#endif // SLIT 117#endif // SLIT
117 inline int getSlitPlacement() const { return resource.slit_placement; } 118 inline Slit::Placement getSlitPlacement() const { return *resource.slit_placement; }
118 inline int getSlitDirection() const { return resource.slit_direction; } 119 inline Slit::Direction getSlitDirection() const { return *resource.slit_direction; }
119 inline void saveSlitPlacement(int p) { resource.slit_placement = p; } 120 inline void saveSlitPlacement(Slit::Placement p) { resource.slit_placement = p; }
120 inline void saveSlitDirection(int d) { resource.slit_direction = d; } 121 inline void saveSlitDirection(Slit::Direction d) { resource.slit_direction = d; }
121 inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } 122 inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; }
122 123
123 inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } 124 inline unsigned int getSlitOnHead() const { return resource.slit_on_head; }
@@ -409,8 +410,9 @@ private:
409 Resource<ToolbarHandler::ToolbarMode> toolbar_mode; 410 Resource<ToolbarHandler::ToolbarMode> toolbar_mode;
410 Resource<int> toolbar_on_head; 411 Resource<int> toolbar_on_head;
411 Resource<Toolbar::Placement> toolbar_placement; 412 Resource<Toolbar::Placement> toolbar_placement;
412 bool slit_auto_hide; 413 Resource<bool> slit_auto_hide;
413 int slit_placement, slit_direction; 414 Resource<Slit::Placement> slit_placement;
415 Resource<Slit::Direction> slit_direction;
414 416
415 unsigned int slit_on_head; 417 unsigned int slit_on_head;
416 418
diff --git a/src/Slit.cc b/src/Slit.cc
index bb910f7..421ff79 100644
--- a/src/Slit.cc
+++ b/src/Slit.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: Slit.cc,v 1.39 2003/04/16 13:43:43 rathnor Exp $ 25// $Id: Slit.cc,v 1.40 2003/04/16 16:18:02 rathnor Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -185,9 +185,10 @@ private:
185 185
186class SlitDirMenuItem: public FbTk::MenuItem { 186class SlitDirMenuItem: public FbTk::MenuItem {
187public: 187public:
188 SlitDirMenuItem(const char *label, Slit &slit):FbTk::MenuItem(label), 188 SlitDirMenuItem(const char *label, Slit &slit, FbTk::RefCount<FbTk::Command> &cmd)
189 m_slit(slit), 189 :FbTk::MenuItem(label,cmd),
190 m_label(label ? label : "") { 190 m_slit(slit),
191 m_label(label ? label : "") {
191 setLabel(m_label.c_str()); // update label 192 setLabel(m_label.c_str()); // update label
192 } 193 }
193 void click(int button, int time) { 194 void click(int button, int time) {
@@ -197,6 +198,7 @@ public:
197 else 198 else
198 m_slit.setDirection(Slit::HORIZONTAL); 199 m_slit.setDirection(Slit::HORIZONTAL);
199 setLabel(m_label.c_str()); 200 setLabel(m_label.c_str());
201 FbTk::MenuItem::click(button, time);
200 } 202 }
201 203
202 void setLabel(const char *label) { 204 void setLabel(const char *label) {
@@ -219,13 +221,14 @@ private:
219 221
220class PlaceSlitMenuItem: public FbTk::MenuItem { 222class PlaceSlitMenuItem: public FbTk::MenuItem {
221public: 223public:
222 PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place): 224 PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place, FbTk::RefCount<FbTk::Command> &cmd):
223 FbTk::MenuItem(label), m_slit(slit), m_place(place) { 225 FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) {
224 226
225 } 227 }
226 bool isEnabled() const { return m_slit.placement() != m_place; } 228 bool isEnabled() const { return m_slit.placement() != m_place; }
227 void click(int button, int time) { 229 void click(int button, int time) {
228 m_slit.setPlacement(m_place); 230 m_slit.setPlacement(m_place);
231 FbTk::MenuItem::click(button, time);
229 } 232 }
230private: 233private:
231 Slit &m_slit; 234 Slit &m_slit;
@@ -258,9 +261,9 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
258 true)); 261 true));
259 262
260 // default placement and direction 263 // default placement and direction
261 m_direction = HORIZONTAL; 264 m_direction = screen().getSlitDirection();
262 m_placement = BOTTOMRIGHT; 265 m_placement = screen().getSlitPlacement();
263 hidden = do_auto_hide = false; 266 hidden = do_auto_hide = screen().doSlitAutoHide();
264 267
265 frame.pixmap = None; 268 frame.pixmap = None;
266 269
@@ -456,11 +459,13 @@ void Slit::addClient(Window w) {
456 459
457void Slit::setDirection(Direction dir) { 460void Slit::setDirection(Direction dir) {
458 m_direction = dir; 461 m_direction = dir;
462 screen().saveSlitDirection(dir);
459 reconfigure(); 463 reconfigure();
460} 464}
461 465
462void Slit::setPlacement(Placement place) { 466void Slit::setPlacement(Placement place) {
463 m_placement = place; 467 m_placement = place;
468 screen().saveSlitPlacement(place);
464 reconfigure(); 469 reconfigure();
465} 470}
466 471
@@ -533,6 +538,9 @@ void Slit::reconfigure() {
533 frame.width = 0; 538 frame.width = 0;
534 frame.height = 0; 539 frame.height = 0;
535 540
541 // be sure to sync slit auto hide up with the screen's menu resource
542 do_auto_hide = screen().doSlitAutoHide();
543
536 // Need to count windows because not all client list entries 544 // Need to count windows because not all client list entries
537 // actually correspond to mapped windows. 545 // actually correspond to mapped windows.
538 int num_windows = 0; 546 int num_windows = 0;
@@ -1091,6 +1099,7 @@ void Slit::saveClientList() {
1091 1099
1092void Slit::setAutoHide(bool val) { 1100void Slit::setAutoHide(bool val) {
1093 do_auto_hide = val; 1101 do_auto_hide = val;
1102 screen().saveSlitAutoHide(val);
1094} 1103}
1095 1104
1096void Slit::setupMenu() { 1105void Slit::setupMenu() {
@@ -1098,7 +1107,14 @@ void Slit::setupMenu() {
1098 using namespace FBNLS; 1107 using namespace FBNLS;
1099 using namespace FbTk; 1108 using namespace FbTk;
1100 1109
1101 RefCount<Command> menu_cmd(new SimpleCommand<Slit>(*this, &Slit::reconfigure)); 1110 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
1111 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(),
1112 &Fluxbox::save_rc));
1113 FbTk::RefCount<FbTk::Command> reconf_cmd(new FbCommands::ReconfigureFluxboxCmd());
1114 s_a_reconf_macro->add(saverc_cmd);
1115 s_a_reconf_macro->add(reconf_cmd);
1116 FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
1117
1102 // setup base menu 1118 // setup base menu
1103 slitmenu.setLabel("Slit"); 1119 slitmenu.setLabel("Slit");
1104 slitmenu.insert(i18n->getMessage( 1120 slitmenu.insert(i18n->getMessage(
@@ -1111,12 +1127,14 @@ void Slit::setupMenu() {
1111 slitmenu.insert(new BoolMenuItem(i18n->getMessage( 1127 slitmenu.insert(new BoolMenuItem(i18n->getMessage(
1112 CommonSet, CommonAutoHide, 1128 CommonSet, CommonAutoHide,
1113 "Auto hide"), 1129 "Auto hide"),
1114 do_auto_hide, 1130 screen().doSlitAutoHide(),
1115 menu_cmd)); 1131 save_and_reconfigure));
1116 1132
1117 slitmenu.insert(new SlitDirMenuItem(i18n->getMessage( 1133 slitmenu.insert(new SlitDirMenuItem(i18n->getMessage(
1118 SlitSet, SlitSlitDirection, 1134 SlitSet, SlitSlitDirection,
1119 "Slit Direction"), *this)); 1135 "Slit Direction"),
1136 *this,
1137 save_and_reconfigure));
1120 slitmenu.insert("Clients", &clientlist_menu); 1138 slitmenu.insert("Clients", &clientlist_menu);
1121 slitmenu.update(); 1139 slitmenu.update();
1122 1140
@@ -1156,9 +1174,15 @@ void Slit::setupMenu() {
1156 place_menu[i].base, 1174 place_menu[i].base,
1157 place_menu[i].default_str); 1175 place_menu[i].default_str);
1158 placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this, 1176 placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this,
1159 place_menu[i].slit_placement)); 1177 place_menu[i].slit_placement,
1178 save_and_reconfigure));
1160 } 1179 }
1161 } 1180 }
1162 // finaly update sub menu 1181 // finaly update sub menu
1163 placement_menu.update(); 1182 placement_menu.update();
1164} 1183}
1184
1185void Slit::moveToLayer(int layernum) {
1186 m_layeritem->moveToLayer(layernum);
1187 m_screen.saveSlitLayer((Fluxbox::Layer) layernum);
1188}
diff --git a/src/Slit.hh b/src/Slit.hh
index fec338d..645ba1d 100644
--- a/src/Slit.hh
+++ b/src/Slit.hh
@@ -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: Slit.hh,v 1.21 2003/04/16 13:43:44 rathnor Exp $ 25/// $Id: Slit.hh,v 1.22 2003/04/16 16:18:05 rathnor Exp $
26 26
27#ifndef SLIT_HH 27#ifndef SLIT_HH
28#define SLIT_HH 28#define SLIT_HH
@@ -33,7 +33,6 @@
33#include "XLayerItem.hh" 33#include "XLayerItem.hh"
34#include "LayerMenu.hh" 34#include "LayerMenu.hh"
35#include "fluxbox.hh" 35#include "fluxbox.hh"
36#include "Screen.hh"
37 36
38#include <X11/Xlib.h> 37#include <X11/Xlib.h>
39#include <X11/Xutil.h> 38#include <X11/Xutil.h>
@@ -43,6 +42,7 @@
43#include <memory> 42#include <memory>
44 43
45class SlitClient; 44class SlitClient;
45class BScreen;
46 46
47/// Handles dock apps 47/// Handles dock apps
48class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler { 48class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler {
@@ -103,7 +103,7 @@ public:
103 void configureRequestEvent(XConfigureRequestEvent &event); 103 void configureRequestEvent(XConfigureRequestEvent &event);
104 //@} 104 //@}
105 105
106 void moveToLayer(int layernum) { m_layeritem->moveToLayer(layernum); m_screen.saveSlitLayer((Fluxbox::Layer) layernum); } 106 void moveToLayer(int layernum);
107 FbTk::XLayerItem &getLayerItem() { return *m_layeritem; } 107 FbTk::XLayerItem &getLayerItem() { return *m_layeritem; }
108 108
109 virtual void timeout(); 109 virtual void timeout();
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index b01e420..a0a75f0 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.113 2003/04/16 14:43:06 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.114 2003/04/16 16:18:06 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -1703,6 +1703,7 @@ void Fluxbox::save_rc() {
1703 BScreen *screen = *it; 1703 BScreen *screen = *it;
1704 int screen_number = screen->getScreenNumber(); 1704 int screen_number = screen->getScreenNumber();
1705 1705
1706/*
1706#ifdef SLIT 1707#ifdef SLIT
1707 string slit_placement; 1708 string slit_placement;
1708 1709
@@ -1735,9 +1736,9 @@ void Fluxbox::save_rc() {
1735 screen->getSlitOnHead()); 1736 screen->getSlitOnHead());
1736 XrmPutLineResource(&new_blackboxrc, rc_string); 1737 XrmPutLineResource(&new_blackboxrc, rc_string);
1737 #endif // XINERAMA 1738 #endif // XINERAMA
1738 */ 1739*//*
1739#endif // SLIT 1740#endif // SLIT
1740 1741 */
1741 sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number, 1742 sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number,
1742 ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ? 1743 ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ?
1743 "LeftToRight" : "RightToLeft")); 1744 "LeftToRight" : "RightToLeft"));