From 53b73110331803cadcbb66b775cf3037f3512b8a Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 16 Jan 2004 09:32:44 +0000 Subject: on click iconify if focused else raise and focus --- src/IconButton.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/IconButton.cc b/src/IconButton.cc index cea49c3..2ee169f 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconButton.cc,v 1.15 2004/01/13 12:27:51 fluxgen Exp $ +// $Id: IconButton.cc,v 1.16 2004/01/16 09:32:44 fluxgen Exp $ #include "IconButton.hh" @@ -65,8 +65,24 @@ private: FluxboxWindow &m_win; }; +class FocusCommand: public FbTk::Command { +public: + explicit FocusCommand(FluxboxWindow &win):m_win(win) { } + void execute() { + if(m_win.isIconic() || !m_win.isFocused()) + m_win.raiseAndFocus(); + else + m_win.iconify(); + } +private: + FluxboxWindow &m_win; +}; + + } // end anonymous namespace + + IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, FluxboxWindow &win): FbTk::TextButton(parent, font, win.winClient().title()), @@ -75,7 +91,6 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, ExposureMask | ButtonPressMask | ButtonReleaseMask), m_use_pixmap(true) { - FbTk::RefCount focus(new FbTk::SimpleCommand(m_win, &FluxboxWindow::raiseAndFocus)); FbTk::RefCount hidemenus(new FbTk::SimpleCommand(win.screen(), &BScreen::hideMenus)); //!! TODO: There're some issues with MacroCommand when // this object dies when the last macrocommand is executed (focused cmd) @@ -83,7 +98,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, // FbTk::MacroCommand *focus_macro = new FbTk::MacroCommand(); // focus_macro->add(hidemenus); // focus_macro->add(focus); - FbTk::RefCount focus_cmd(focus); + FbTk::RefCount focus_cmd(new ::FocusCommand(m_win)); FbTk::RefCount menu_cmd(new ::ShowMenu(m_win)); setOnClick(focus_cmd, 1); setOnClick(menu_cmd, 3); -- cgit v0.11.2