From ca7b5ee4a59ea18fd832b11040f63bcc0d8404ab Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 23 Feb 2007 17:03:01 +0000 Subject: update titlebar buttons on reconfigure --- ChangeLog | 3 ++ src/WinButton.hh | 5 +++ src/Window.cc | 107 ++++++++++++++++++++++++++++++++++++++----------------- src/Window.hh | 3 ++ 4 files changed, 85 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37f91ea..4f2648b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*07/02/23: + * Update titlebar buttons on reconfigure (Mark) + Window.cc/hh *07/02/22: * Make systemtray support XEMBED protocol (Mark) Systemtray.cc/hh diff --git a/src/WinButton.hh b/src/WinButton.hh index d1e57f3..3181278 100644 --- a/src/WinButton.hh +++ b/src/WinButton.hh @@ -21,6 +21,9 @@ /// $Id$ +#ifndef WINBUTTON_HH +#define WINBUTTON_HH + #include "FbTk/Button.hh" #include "FbTk/Observer.hh" #include "FbTk/FbPixmap.hh" @@ -65,3 +68,5 @@ private: bool overrode_bg, overrode_pressed; }; + +#endif // WINBUTTON_HH diff --git a/src/Window.cc b/src/Window.cc index 9bc4c5a..ba6fe6d 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1098,6 +1098,7 @@ void FluxboxWindow::reconfigure() { frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); + updateButtons(); frame().reconfigure(); menu().reconfigure(); @@ -3911,25 +3912,16 @@ void FluxboxWindow::setupWindow() { typedef RefCount CommandRef; typedef SimpleCommand WindowCmd; - CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify)); - CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeFull)); - CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical)); - CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal)); - CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close)); CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade)); CommandRef shade_on_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOn)); CommandRef shade_off_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOff)); CommandRef next_tab_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient)); CommandRef prev_tab_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient)); - CommandRef raise_cmd(new WindowCmd(*this, &FluxboxWindow::raise)); CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower)); CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus)); CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick)); CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu)); - // clear old buttons from frame - frame().removeAllButtons(); - typedef FbTk::Resource > WinButtonsResource; string titlebar_name[2]; @@ -3983,12 +3975,85 @@ void FluxboxWindow::setupWindow() { screen().addManagedResource(titlebar_side[i]); } + updateButtons(); + + // setup titlebar + frame().setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1 + frame().setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1 + frame().setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3 + frame().setOnClickTitlebar(lower_cmd, 2); // on release with button 2 + + int reverse = 0; + if (screen().getScrollReverse()) + reverse = 1; + + if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { + frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll + frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction + } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { + frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab + frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab + } + + frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); + + // end setup frame + +} + +void FluxboxWindow::updateButtons() { + string titlebar_name[2]; + titlebar_name[0] = screen().name() + ".titlebar.left"; + titlebar_name[1] = screen().name() + ".titlebar.right"; + + typedef FbTk::Resource > WinButtonsResource; + WinButtonsResource *titlebar_side[2]; + ResourceManager &rm = screen().resourceManager(); + + bool need_update = false; + // get resource for titlebar + for (int i=0; i < 2; ++i) { + titlebar_side[i] = dynamic_cast( + rm.findResource( titlebar_name[i] ) ); + + // check if we need to update our buttons + size_t new_size = (*titlebar_side[i])->size(); + if (new_size != m_titlebar_buttons[i].size() || need_update) + need_update = true; + else { + for (int j=0; j < new_size && !need_update; j++) { + if ((*(*titlebar_side[i]))[j] != m_titlebar_buttons[i][j]) + need_update = true; + } + } + + } + + if (!need_update) + return; + // clear old buttons from frame + frame().removeAllButtons(); + using namespace FbTk; + typedef RefCount CommandRef; + typedef SimpleCommand WindowCmd; + + CommandRef iconify_cmd(new WindowCmd(*this, &FluxboxWindow::iconify)); + CommandRef maximize_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeFull)); + CommandRef maximize_vert_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeVertical)); + CommandRef maximize_horiz_cmd(new WindowCmd(*this, &FluxboxWindow::maximizeHorizontal)); + CommandRef close_cmd(new WindowCmd(*this, &FluxboxWindow::close)); + CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade)); + CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick)); + CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu)); + + WinButtonTheme &winbutton_theme = screen().winButtonTheme(); for (size_t c = 0; c < 2 ; c++) { // get titlebar configuration for current side const vector &dir = *(*titlebar_side[c]); + m_titlebar_buttons[c] = dir; for (size_t i=0; i < dir.size(); ++i) { //create new buttons @@ -4069,32 +4134,8 @@ void FluxboxWindow::setupWindow() { } // end for c frame().reconfigure(); - - // setup titlebar - frame().setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1 - frame().setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1 - frame().setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3 - frame().setOnClickTitlebar(lower_cmd, 2); // on release with button 2 - - int reverse = 0; - if (screen().getScrollReverse()) - reverse = 1; - - if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { - frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll - frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction - } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { - frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab - frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab - } - - frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); - - // end setup frame - } - /** * reconfigTheme: must be called after frame is reconfigured * Client windows need to be made the same size and location as diff --git a/src/Window.hh b/src/Window.hh index 2cec115..4e5956f 100644 --- a/src/Window.hh +++ b/src/Window.hh @@ -32,6 +32,7 @@ #include "FbTk/EventHandler.hh" #include "FbTk/XLayerItem.hh" #include "FbWinFrame.hh" +#include "WinButton.hh" #include #include @@ -443,6 +444,7 @@ private: static const int PropBlackboxAttributesElements = 8; void setupWindow(); + void updateButtons(); void init(); /// applies a shape mask to the window if it has one @@ -543,6 +545,7 @@ private: maximize, close, menu, sticky, shade, tab, enabled; } decorations; + std::vector m_titlebar_buttons[2]; bool m_toggled_decos; struct _functions { -- cgit v0.11.2