From e48f7836fdaca03e0626b3e7ac4d37c99dd35dc9 Mon Sep 17 00:00:00 2001 From: rathnor Date: Wed, 16 Apr 2003 16:18:06 +0000 Subject: fix saving of various slit params (Simon) --- ChangeLog | 5 +++- src/Screen.cc | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/Screen.hh | 20 +++++++------ src/Slit.cc | 54 ++++++++++++++++++++++++---------- src/Slit.hh | 6 ++-- src/fluxbox.cc | 7 +++-- 6 files changed, 150 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33d8d3f..bea0ec4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,13 @@ (Format: Year/Month/Day) Changes for 0.9.1: *03/04/16: + * Fixed saving of some other slit params - placement, direction, + autohide (Simon) + Screen.hh/cc Slit.hh/cc fluxbox.cc * Fixed saving of toolbar and slit layer (Simon) LayerMenu.hh Screen.hh Slit.hh/cc Toolbar.hh/cc ToolbarHandler.hh Window.cc - * Fixed toolbar width percent menu item + * Fixed toolbar width percent menu item (Henrik) Toolbar.cc * Fixed current focused client button rendered (Henrik) FbWinFrame.hh/cc, Window.cc 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.125 2003/04/16 14:43:01 rathnor Exp $ +// $Id: Screen.cc,v 1.126 2003/04/16 16:17:56 rathnor Exp $ #include "Screen.hh" @@ -193,6 +193,29 @@ setFromString(const char *strval) { } template<> +void Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "TopLeft")==0) + m_value = Slit::TOPLEFT; + else if (strcasecmp(strval, "CenterLeft")==0) + m_value = Slit::CENTERLEFT; + else if (strcasecmp(strval, "BottomLeft")==0) + m_value = Slit::BOTTOMLEFT; + else if (strcasecmp(strval, "TopCenter")==0) + m_value = Slit::TOPCENTER; + else if (strcasecmp(strval, "BottomCenter")==0) + m_value = Slit::BOTTOMCENTER; + else if (strcasecmp(strval, "TopRight")==0) + m_value = Slit::TOPRIGHT; + else if (strcasecmp(strval, "CenterRight")==0) + m_value = Slit::CENTERRIGHT; + else if (strcasecmp(strval, "BottomRight")==0) + m_value = Slit::BOTTOMRIGHT; + else + setDefaultValue(); +} + +template<> void Resource:: setFromString(const char *strval) { if (strcasecmp(strval, "Off") == 0) @@ -212,6 +235,16 @@ setFromString(const char *strval) { } template<> +void Resource:: +setFromString(const char *strval) { + if (strcasecmp(strval, "Vertical") == 0) + m_value = Slit::VERTICAL; + else if (strcasecmp(strval, "Horizontal") == 0) + m_value = Slit::HORIZONTAL; + else + setDefaultValue(); +} + string Resource:: getString() { switch (m_value) { @@ -256,6 +289,39 @@ getString() { return string("BottomCenter"); } + +string Resource:: +getString() { + switch (m_value) { + case Slit::TOPLEFT: + return string("TopLeft"); + break; + case Slit::CENTERLEFT: + return string("CenterLeft"); + break; + case Slit::BOTTOMLEFT: + return string("BottomLeft"); + break; + case Slit::TOPCENTER: + return string("TopCenter"); + break; + case Slit::BOTTOMCENTER: + return string("BottomCenter"); + break; + case Slit::TOPRIGHT: + return string("TopRight"); + break; + case Slit::CENTERRIGHT: + return string("CenterRight"); + break; + case Slit::BOTTOMRIGHT: + return string("BottomRight"); + break; + } + //default string + return string("BottomRight"); +} + template<> string Resource:: getString() { @@ -284,6 +350,22 @@ getString() { return string("Icons"); } +template<> +string Resource:: +getString() { + switch (m_value) { + case Slit::VERTICAL: + return string("Vertical"); + break; + case Slit::HORIZONTAL: + return string("Horizontal"); + break; + } + // default string + return string("Vertical"); +} + + namespace { class AddWorkspaceCmd:public FbTk::Command { @@ -400,7 +482,12 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm, toolbar_mode(rm, ToolbarHandler::ICONS, scrname+".toolbar.mode", altscrname+".Toolbar.Mode"), toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), toolbar_placement(rm, Toolbar::BOTTOMCENTER, - scrname+".toolbar.placement", altscrname+".Toolbar.Placement") + scrname+".toolbar.placement", altscrname+".Toolbar.Placement"), + slit_auto_hide(rm, false, scrname+".slit.autoHide", altscrname+".Slit.AutoHide"), + slit_placement(rm, Slit::BOTTOMRIGHT, + scrname+".slit.placement", altscrname+".Slit.Placement"), + slit_direction(rm, Slit::VERTICAL, scrname+".slit.direction", altscrname+".Slit.Direction") + { }; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.79 2003/04/16 14:43:02 rathnor Exp $ +// $Id: Screen.hh,v 1.80 2003/04/16 16:17:57 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH @@ -36,6 +36,7 @@ #include "MultLayers.hh" #include "XLayerItem.hh" #include "ToolbarHandler.hh" +#include "Slit.hh" #include #include @@ -52,7 +53,6 @@ #endif // HAVE_CONFIG_H class Netizen; -class Slit; class Toolbar; class FbWinFrameTheme; class RootTheme; @@ -109,15 +109,16 @@ public: inline const std::string &getRootCommand() const { return *resource.rootcommand; } inline Fluxbox::FocusModel getFocusModel() const { return *resource.focus_model; } - inline bool doSlitAutoHide() const { return resource.slit_auto_hide; } + inline bool &doSlitAutoHide() { return *resource.slit_auto_hide; } + inline const bool &doSlitAutoHide() const { return *resource.slit_auto_hide; } #ifdef SLIT inline Slit *getSlit() { return m_slit.get(); } inline const Slit *getSlit() const { return m_slit.get(); } #endif // SLIT - inline int getSlitPlacement() const { return resource.slit_placement; } - inline int getSlitDirection() const { return resource.slit_direction; } - inline void saveSlitPlacement(int p) { resource.slit_placement = p; } - inline void saveSlitDirection(int d) { resource.slit_direction = d; } + inline Slit::Placement getSlitPlacement() const { return *resource.slit_placement; } + inline Slit::Direction getSlitDirection() const { return *resource.slit_direction; } + inline void saveSlitPlacement(Slit::Placement p) { resource.slit_placement = p; } + inline void saveSlitDirection(Slit::Direction d) { resource.slit_direction = d; } inline void saveSlitAutoHide(bool t) { resource.slit_auto_hide = t; } inline unsigned int getSlitOnHead() const { return resource.slit_on_head; } @@ -409,8 +410,9 @@ private: Resource toolbar_mode; Resource toolbar_on_head; Resource toolbar_placement; - bool slit_auto_hide; - int slit_placement, slit_direction; + Resource slit_auto_hide; + Resource slit_placement; + Resource slit_direction; unsigned int slit_on_head; 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.39 2003/04/16 13:43:43 rathnor Exp $ +// $Id: Slit.cc,v 1.40 2003/04/16 16:18:02 rathnor Exp $ #include "Slit.hh" @@ -185,9 +185,10 @@ private: class SlitDirMenuItem: public FbTk::MenuItem { public: - SlitDirMenuItem(const char *label, Slit &slit):FbTk::MenuItem(label), - m_slit(slit), - m_label(label ? label : "") { + SlitDirMenuItem(const char *label, Slit &slit, FbTk::RefCount &cmd) + :FbTk::MenuItem(label,cmd), + m_slit(slit), + m_label(label ? label : "") { setLabel(m_label.c_str()); // update label } void click(int button, int time) { @@ -197,6 +198,7 @@ public: else m_slit.setDirection(Slit::HORIZONTAL); setLabel(m_label.c_str()); + FbTk::MenuItem::click(button, time); } void setLabel(const char *label) { @@ -219,13 +221,14 @@ private: class PlaceSlitMenuItem: public FbTk::MenuItem { public: - PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place): - FbTk::MenuItem(label), m_slit(slit), m_place(place) { + PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place, FbTk::RefCount &cmd): + FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) { } bool isEnabled() const { return m_slit.placement() != m_place; } void click(int button, int time) { m_slit.setPlacement(m_place); + FbTk::MenuItem::click(button, time); } private: Slit &m_slit; @@ -258,9 +261,9 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename) true)); // default placement and direction - m_direction = HORIZONTAL; - m_placement = BOTTOMRIGHT; - hidden = do_auto_hide = false; + m_direction = screen().getSlitDirection(); + m_placement = screen().getSlitPlacement(); + hidden = do_auto_hide = screen().doSlitAutoHide(); frame.pixmap = None; @@ -456,11 +459,13 @@ void Slit::addClient(Window w) { void Slit::setDirection(Direction dir) { m_direction = dir; + screen().saveSlitDirection(dir); reconfigure(); } void Slit::setPlacement(Placement place) { m_placement = place; + screen().saveSlitPlacement(place); reconfigure(); } @@ -533,6 +538,9 @@ void Slit::reconfigure() { frame.width = 0; frame.height = 0; + // be sure to sync slit auto hide up with the screen's menu resource + do_auto_hide = screen().doSlitAutoHide(); + // Need to count windows because not all client list entries // actually correspond to mapped windows. int num_windows = 0; @@ -1091,6 +1099,7 @@ void Slit::saveClientList() { void Slit::setAutoHide(bool val) { do_auto_hide = val; + screen().saveSlitAutoHide(val); } void Slit::setupMenu() { @@ -1098,7 +1107,14 @@ void Slit::setupMenu() { using namespace FBNLS; using namespace FbTk; - RefCount menu_cmd(new SimpleCommand(*this, &Slit::reconfigure)); + FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand(); + FbTk::RefCount saverc_cmd(new FbTk::SimpleCommand(*Fluxbox::instance(), + &Fluxbox::save_rc)); + FbTk::RefCount reconf_cmd(new FbCommands::ReconfigureFluxboxCmd()); + s_a_reconf_macro->add(saverc_cmd); + s_a_reconf_macro->add(reconf_cmd); + FbTk::RefCount save_and_reconfigure(s_a_reconf_macro); + // setup base menu slitmenu.setLabel("Slit"); slitmenu.insert(i18n->getMessage( @@ -1111,12 +1127,14 @@ void Slit::setupMenu() { slitmenu.insert(new BoolMenuItem(i18n->getMessage( CommonSet, CommonAutoHide, "Auto hide"), - do_auto_hide, - menu_cmd)); + screen().doSlitAutoHide(), + save_and_reconfigure)); slitmenu.insert(new SlitDirMenuItem(i18n->getMessage( - SlitSet, SlitSlitDirection, - "Slit Direction"), *this)); + SlitSet, SlitSlitDirection, + "Slit Direction"), + *this, + save_and_reconfigure)); slitmenu.insert("Clients", &clientlist_menu); slitmenu.update(); @@ -1156,9 +1174,15 @@ void Slit::setupMenu() { place_menu[i].base, place_menu[i].default_str); placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this, - place_menu[i].slit_placement)); + place_menu[i].slit_placement, + save_and_reconfigure)); } } // finaly update sub menu placement_menu.update(); } + +void Slit::moveToLayer(int layernum) { + m_layeritem->moveToLayer(layernum); + m_screen.saveSlitLayer((Fluxbox::Layer) layernum); +} 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.21 2003/04/16 13:43:44 rathnor Exp $ +/// $Id: Slit.hh,v 1.22 2003/04/16 16:18:05 rathnor Exp $ #ifndef SLIT_HH #define SLIT_HH @@ -33,7 +33,6 @@ #include "XLayerItem.hh" #include "LayerMenu.hh" #include "fluxbox.hh" -#include "Screen.hh" #include #include @@ -43,6 +42,7 @@ #include class SlitClient; +class BScreen; /// Handles dock apps class Slit : public FbTk::TimeoutHandler, public FbTk::EventHandler { @@ -103,7 +103,7 @@ public: void configureRequestEvent(XConfigureRequestEvent &event); //@} - void moveToLayer(int layernum) { m_layeritem->moveToLayer(layernum); m_screen.saveSlitLayer((Fluxbox::Layer) layernum); } + void moveToLayer(int layernum); FbTk::XLayerItem &getLayerItem() { return *m_layeritem; } 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.113 2003/04/16 14:43:06 rathnor Exp $ +// $Id: fluxbox.cc,v 1.114 2003/04/16 16:18:06 rathnor Exp $ #include "fluxbox.hh" @@ -1703,6 +1703,7 @@ void Fluxbox::save_rc() { BScreen *screen = *it; int screen_number = screen->getScreenNumber(); +/* #ifdef SLIT string slit_placement; @@ -1735,9 +1736,9 @@ void Fluxbox::save_rc() { screen->getSlitOnHead()); XrmPutLineResource(&new_blackboxrc, rc_string); #endif // XINERAMA - */ +*//* #endif // SLIT - + */ sprintf(rc_string, "session.screen%d.rowPlacementDirection: %s", screen_number, ((screen->getRowPlacementDirection() == BScreen::LEFTRIGHT) ? "LeftToRight" : "RightToLeft")); -- cgit v0.11.2