From f5d7833b32f77e936ce9f6e930f0b930519a28a2 Mon Sep 17 00:00:00 2001 From: akir Date: Fri, 22 Oct 2004 00:35:29 +0000 Subject: added iconbar.wheelMode and iconbar.deiconifyMode --- src/IconButton.cc | 74 +++++++++++++++++++++++++++++++++++++------- src/IconButton.hh | 7 +++-- src/IconbarTool.cc | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/IconbarTool.hh | 23 +++++++++++++- 4 files changed, 177 insertions(+), 18 deletions(-) diff --git a/src/IconButton.cc b/src/IconButton.cc index 0c383d1..a4293c6 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -20,10 +20,10 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.cc,v 1.22 2004/07/15 14:20:19 fluxgen Exp $ +// $Id: IconButton.cc,v 1.23 2004/10/22 00:35:28 akir Exp $ #include "IconButton.hh" - +#include "IconbarTool.hh" #include "fluxbox.hh" #include "Screen.hh" @@ -49,6 +49,8 @@ #include #endif // SHAPE +typedef FbTk::RefCount RefCmd; + namespace { class ShowMenu: public FbTk::Command { @@ -69,47 +71,95 @@ private: class FocusCommand: public FbTk::Command { public: - explicit FocusCommand(FluxboxWindow &win):m_win(win) { } + explicit FocusCommand(const IconbarTool& tool, FluxboxWindow &win) : + m_win(win), m_tool(tool) { } void execute() { if(m_win.isIconic() || !m_win.isFocused()) { - m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); + switch(m_tool.deiconifyMode()) { + case IconbarTool::CURRENT: + m_win.screen().sendToWorkspace(m_win.screen().currentWorkspaceID(), &m_win); + break; + case IconbarTool::FOLLOW: + m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); + break; + case IconbarTool::SEMIFOLLOW: + if (m_win.isIconic()) + m_win.screen().sendToWorkspace(m_win.screen().currentWorkspaceID(), &m_win); + else + m_win.screen().changeWorkspaceID(m_win.workspaceNumber()); + break; + }; + m_win.raiseAndFocus(); } else m_win.iconify(); } + private: FluxboxWindow &m_win; + const IconbarTool& m_tool; }; +// simple forwarding of wheeling, but only +// if desktopwheeling is enabled +class WheelWorkspaceCmd : public FbTk::Command { +public: + explicit WheelWorkspaceCmd(const IconbarTool& tool, FluxboxWindow &win, const char* cmd) : + m_win(win), m_tool(tool), m_cmd(CommandParser::instance().parseLine(cmd)){ } + void execute() { + + switch(m_tool.wheelMode()) { + case IconbarTool::ON: + m_cmd->execute(); + break; + case IconbarTool::SCREEN: + if(m_win.screen().isDesktopWheeling()) + m_cmd->execute(); + break; + case IconbarTool::OFF: + default: + break; + }; + } + +private: + FluxboxWindow &m_win; + RefCmd m_cmd; + const IconbarTool& m_tool; +}; } // end anonymous namespace -IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, - FluxboxWindow &win): +IconButton::IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent, + const FbTk::Font &font, FluxboxWindow &win): FbTk::TextButton(parent, font, win.winClient().title()), m_win(win), m_icon_window(*this, 1, 1, 1, 1, ExposureMask | ButtonPressMask | ButtonReleaseMask), m_use_pixmap(true) { - typedef FbTk::RefCount RefCmd; - RefCmd hidemenus(new FbTk::SimpleCommand(win.screen(), &BScreen::hideMenus)); - RefCmd next_workspace(CommandParser::instance().parseLine("nextworkspace")); - RefCmd prev_workspace(CommandParser::instance().parseLine("prevworkspace")); + + RefCmd next_workspace(new ::WheelWorkspaceCmd(tool, m_win, "nextworkspace")); + RefCmd prev_workspace(new ::WheelWorkspaceCmd(tool, m_win, "prevworkspace")); + //!! TODO: There're some issues with MacroCommand when // this object dies when the last macrocommand is executed (focused cmd) // In iconbar mode Icons + // + // RefCmd hidemenus(new FbTk::SimpleCommand(win.screen(), &BScreen::hideMenus)); // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); // focus_macro->add(hidemenus); // focus_macro->add(focus); - FbTk::RefCount focus_cmd(new ::FocusCommand(m_win)); - FbTk::RefCount menu_cmd(new ::ShowMenu(m_win)); + + RefCmd focus_cmd(new ::FocusCommand(tool, m_win)); + RefCmd menu_cmd(new ::ShowMenu(m_win)); setOnClick(focus_cmd, 1); setOnClick(menu_cmd, 3); setOnClick(next_workspace, 4); setOnClick(prev_workspace, 5); + m_win.hintSig().attach(this); FbTk::EventManager::instance()->add(*this, m_icon_window); diff --git a/src/IconButton.hh b/src/IconButton.hh index 69fbf46..80310b4 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.hh,v 1.4 2003/11/27 14:27:48 fluxgen Exp $ +// $Id: IconButton.hh,v 1.5 2004/10/22 00:35:28 akir Exp $ #ifndef ICONBUTTON_HH #define ICONBUTTON_HH @@ -30,11 +30,12 @@ #include "FbTk/TextButton.hh" class FluxboxWindow; +class IconbarTool; class IconButton: public FbTk::TextButton, public FbTk::Observer { public: - IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, - FluxboxWindow &window); + IconButton(const IconbarTool& tool, const FbTk::FbWindow &parent, + const FbTk::Font &font, FluxboxWindow &window); virtual ~IconButton(); void exposeEvent(XExposeEvent &event); diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 066b87d..e6cc22b 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.cc,v 1.48 2004/10/10 16:11:25 akir Exp $ +// $Id: IconbarTool.cc,v 1.49 2004/10/22 00:35:28 akir Exp $ #include "IconbarTool.hh" @@ -66,6 +66,68 @@ void FbTk::Resource::setFromString(const char *strval) { } template<> +void FbTk::Resource::setDefaultValue() { + m_value = IconbarTool::CURRENT; +} + +template<> +void FbTk::Resource::setFromString(const char* strval) { + if (strncasecmp(strval, "Current", strlen("Current")) == 0) + m_value = IconbarTool::CURRENT; + else if (strncasecmp(strval, "Follow", strlen("Follow")) == 0) + m_value = IconbarTool::FOLLOW; + else if (strncasecmp(strval, "SemiFollow", strlen("SemiFollow")) == 0) + m_value = IconbarTool::SEMIFOLLOW; + else + setDefaultValue(); +} + +template<> +std::string FbTk::Resource::getString() { + switch (m_value) { + case IconbarTool::SEMIFOLLOW: + return std::string("SemiFollow"); + break; + case IconbarTool::FOLLOW: + return std::string("Follow"); + break; + }; + return std::string("Current"); +} + +template<> +void FbTk::Resource::setDefaultValue() { + m_value = IconbarTool::SCREEN; +} + + +template<> +void FbTk::Resource::setFromString(const char* strval) { + if (strncasecmp(strval, "off", strlen("off")) == 0) + m_value = IconbarTool::OFF; + else if (strncasecmp(strval, "on", strlen("on")) == 0) + m_value = IconbarTool::ON; + else if (strncasecmp(strval, "screen", strlen("screen")) == 0) + m_value = IconbarTool::SCREEN; + else + setDefaultValue(); +} + + +template<> +std::string FbTk::Resource::getString() { + switch(m_value) { + case IconbarTool::ON: + return std::string("On"); + break; + case IconbarTool::SCREEN: + return std::string("Screen"); + break; + }; + return std::string("Off"); +} + +template<> void FbTk::Resource::setDefaultValue() { m_value = Container::RELATIVE; } @@ -275,6 +337,12 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr m_empty_pm(0), m_rc_mode(screen.resourceManager(), WORKSPACE, screen.name() + ".iconbar.mode", screen.altName() + ".Iconbar.Mode"), + m_deiconify_mode(screen.resourceManager(), CURRENT, + screen.name() + ".iconbar.deiconifyMode", + screen.name() + ".iconbar.DeiconifyMode"), + m_wheel_mode(screen.resourceManager(), OFF, + screen.name() + ".iconbar.wheelMode", + screen.name() + ".iconbar.WheelMode"), m_rc_alignment(screen.resourceManager(), Container::LEFT, screen.name() + ".iconbar.alignment", screen.altName() + ".Iconbar.Alignment"), m_rc_client_width(screen.resourceManager(), 70, @@ -404,6 +472,20 @@ void IconbarTool::setMode(Mode mode) { renderTheme(); } +void IconbarTool::setDeiconifyMode(DeiconifyMode mode) { + if (mode == *m_deiconify_mode) + return; + + *m_deiconify_mode = mode; +} + +void IconbarTool::setWheelMode(WheelMode mode) { + if (mode == *m_wheel_mode) + return; + *m_wheel_mode = mode; +} + + unsigned int IconbarTool::width() const { return m_icon_container.width(); } @@ -735,7 +817,12 @@ void IconbarTool::addWindow(FluxboxWindow &win) { #ifdef DEBUG cerr<<"IconbarTool::addWindow(0x"<<&win<<" title = "<setTextPadding(*m_rc_client_padding); renderButton(*button, false); // update the attributes, but don't clear it diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index af1ba37..278bf21 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.hh,v 1.17 2004/10/10 16:11:25 akir Exp $ +// $Id: IconbarTool.hh,v 1.18 2004/10/22 00:35:29 akir Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH @@ -54,6 +54,20 @@ public: ALLWINDOWS ///< all windows and all icons from all workspaces }; + /// deiconfiy mode for iconbuttons + enum DeiconifyMode { + CURRENT, ///< raise the window on the current workspace + FOLLOW, ///< raise the window on the workspace it was iconified from + SEMIFOLLOW, ///< like current for iconified windows, and like follow for others + }; + + /// wheeling on iconbutton + enum WheelMode { + OFF, ///< no wheeling, default mode + ON, ///< enabled wheeling + SCREEN ///< in perfect harmony with desktopwheeling-value + }; + IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen, FbTk::Menu &menu); ~IconbarTool(); @@ -68,12 +82,17 @@ public: void hide(); void setAlignment(Container::Alignment a); void setMode(Mode mode); + void setDeiconifyMode(DeiconifyMode mode); + void setWheelMode(WheelMode mode); unsigned int width() const; unsigned int height() const; unsigned int borderWidth() const; Mode mode() const { return *m_rc_mode; } + DeiconifyMode deiconifyMode() const { return *m_deiconify_mode; } + WheelMode wheelMode() const { return *m_wheel_mode; } + Container::Alignment alignment() const { return m_icon_container.alignment(); } private: /// @return button associated with window @@ -117,6 +136,8 @@ private: IconList m_icon_list; FbTk::Resource m_rc_mode; + FbTk::Resource m_deiconify_mode; + FbTk::Resource m_wheel_mode; FbTk::Resource m_rc_alignment; ///< alignment of buttons FbTk::Resource m_rc_client_width; ///< size of client button in LEFT/RIGHT mode FbTk::Resource m_rc_client_padding; ///< padding of the text -- cgit v0.11.2