From 8f88c1fecb28dc15ecfd2ee210a8e466afe5456c Mon Sep 17 00:00:00 2001 From: rathnor Date: Wed, 16 Jun 2004 15:38:19 +0000 Subject: toolbar fixes, updates and optimisations --- ChangeLog | 7 +++++++ src/ClockTool.cc | 6 ++---- src/Container.cc | 10 +++------- src/IconButton.cc | 17 ++++++++++++----- src/IconbarTool.cc | 31 +++++++++++++++---------------- src/IconbarTool.hh | 6 +++--- src/Toolbar.cc | 21 +++++++++++++-------- src/WorkspaceNameTool.cc | 3 +-- 8 files changed, 56 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index a59e9c8..34c3fd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ (Format: Year/Month/Day) Changes for 0.9.10: +*04/06/17: + * Improve rendering speed of toolbar (Simon) + - remove many redundant renders (esp. startup) + - only update clock if the text has changed + - fix transparency and border on most items + IconbarTool.hh/cc IconButton.cc Toolbar.cc Container.cc + ClockTool.cc WorkspaceNameTool.cc *04/06/14: * More menu transparency improvements (Henrik) Menu.cc diff --git a/src/ClockTool.cc b/src/ClockTool.cc index a65a4ea..fc2bfc3 100644 --- a/src/ClockTool.cc +++ b/src/ClockTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ClockTool.cc,v 1.10 2004/01/13 14:41:32 rathnor Exp $ +// $Id: ClockTool.cc,v 1.11 2004/06/16 15:38:19 rathnor Exp $ #include "ClockTool.hh" @@ -231,7 +231,7 @@ void ClockTool::updateTime() { return; #ifdef HAVE_STRFTIME - if (!strftime(time_string, 255, m_timeformat->c_str(), time_type)) + if (!strftime(time_string, 255, m_timeformat->c_str(), time_type) || m_button.text() == time_string) return; m_button.setText(time_string); #else // dont have strftime so we have to set it to hour:minut @@ -240,7 +240,6 @@ void ClockTool::updateTime() { } m_button.clear(); - m_button.updateTransparent(); } void ClockTool::renderTheme() { @@ -261,5 +260,4 @@ void ClockTool::renderTheme() { m_button.setBorderColor(m_theme.border().color()); m_button.setAlpha(m_theme.alpha()); m_button.clear(); - m_button.updateTransparent(); } diff --git a/src/Container.cc b/src/Container.cc index 5d07552..d329052 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Container.cc,v 1.14 2004/05/04 14:33:37 rathnor Exp $ +// $Id: Container.cc,v 1.15 2004/06/16 15:38:19 rathnor Exp $ #include "Container.hh" @@ -160,10 +160,7 @@ void Container::setSelected(int pos) { for (; pos != 0; --pos, ++it) continue; m_selected = *it; - if (m_selected) { - m_selected->clear(); - m_selected->updateTransparent(); - } + // caller does any graphics stuff if appropriate } } @@ -218,8 +215,7 @@ void Container::repositionItems() { -borderW, max_width_per_client + extra, height()); - (*it)->clear(); - (*it)->updateTransparent(); + // moveresize does a clear } } diff --git a/src/IconButton.cc b/src/IconButton.cc index 6f0b0b7..748d87b 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.20 2004/05/04 14:33:37 rathnor Exp $ +// $Id: IconButton.cc,v 1.21 2004/06/16 15:38:19 rathnor Exp $ #include "IconButton.hh" @@ -107,7 +107,7 @@ IconButton::IconButton(const FbTk::FbWindow &parent, const FbTk::Font &font, m_win.hintSig().attach(this); FbTk::EventManager::instance()->add(*this, m_icon_window); - + update(0); } @@ -122,21 +122,24 @@ void IconButton::exposeEvent(XExposeEvent &event) { else FbTk::TextButton::exposeEvent(event); } + void IconButton::moveResize(int x, int y, unsigned int width, unsigned int height) { FbTk::TextButton::moveResize(x, y, width, height); if (m_icon_window.width() != FbTk::Button::width() || - m_icon_window.height() != FbTk::Button::height()) + m_icon_window.height() != FbTk::Button::height()) { update(0); // update icon window + } } void IconButton::resize(unsigned int width, unsigned int height) { FbTk::TextButton::resize(width, height); if (m_icon_window.width() != FbTk::Button::width() || - m_icon_window.height() != FbTk::Button::height()) + m_icon_window.height() != FbTk::Button::height()) { update(0); // update icon window + } } void IconButton::clear() { @@ -210,7 +213,11 @@ void IconButton::update(FbTk::Subject *subj) { #endif // SHAPE - setupWindow(); + if (subj != 0) { + setupWindow(); + } else { + m_icon_window.clear(); + } } void IconButton::setupWindow() { diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index 5434696..eaaa0fe 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.38 2004/06/07 21:43:02 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.39 2004/06/16 15:38:19 rathnor Exp $ #include "IconbarTool.hh" @@ -436,7 +436,6 @@ void IconbarTool::update(FbTk::Subject *subj) { if (mode() == NONE) { if (subj != 0 && typeid(*subj) == typeid(IconbarTheme)) renderTheme(); - return; } @@ -448,7 +447,6 @@ void IconbarTool::update(FbTk::Subject *subj) { // start focus timer, so we can update without flicker m_focus_timer.start(); - //renderWindow(winsubj->win()); return; } else if (subj == &(winsubj->win().workspaceSig())) { // we can ignore this signal if we're in ALLWINDOWS mode @@ -524,7 +522,9 @@ void IconbarTool::update(FbTk::Subject *subj) { m_icon_container.update(); m_icon_container.showSubwindows(); - renderTheme(); + // another renderTheme we hopefully shouldn't need? These renders + // should be done individually above + // renderTheme(); } IconButton *IconbarTool::findButton(FluxboxWindow &win) { @@ -613,17 +613,18 @@ void IconbarTool::renderTheme() { if (tmp) m_screen.imageControl().removeImage(tmp); - m_icon_container.setBorderWidth(m_theme.border().width()); - m_icon_container.setBorderColor(m_theme.border().color()); + // set to zero so its consistent and not ugly + m_icon_container.setBorderWidth(0); m_icon_container.setAlpha(m_theme.alpha()); // update buttons icon_it = m_icon_list.begin(); - for (; icon_it != icon_it_end; ++icon_it) + for (; icon_it != icon_it_end; ++icon_it) { renderButton(*(*icon_it)); + } } -void IconbarTool::renderButton(IconButton &button) { +void IconbarTool::renderButton(IconButton &button, bool clear) { button.setPixmap(*m_rc_use_pixmap); button.setAlpha(m_theme.alpha()); @@ -635,6 +636,7 @@ void IconbarTool::renderButton(IconButton &button) { if (button.win().isFocused()) { // focused texture m_icon_container.setSelected(m_icon_container.find(&button)); + button.setGC(m_theme.focusedText().textGC()); button.setFont(m_theme.focusedText().font()); button.setJustify(m_theme.focusedText().justify()); @@ -646,9 +648,7 @@ void IconbarTool::renderButton(IconButton &button) { else if (wider_button && m_focused_err_pm != 0) button.setBackgroundPixmap(m_focused_err_pm); else - button.setBackgroundColor(m_theme.focusedTexture().color()); - - + button.setBackgroundColor(m_theme.focusedTexture().color()); } else { // unfocused if (m_icon_container.selected() == &button) @@ -666,11 +666,10 @@ void IconbarTool::renderButton(IconButton &button) { button.setBackgroundPixmap(m_unfocused_err_pm); else button.setBackgroundColor(m_theme.unfocusedTexture().color()); - } - button.clear(); - button.updateTransparent(); + if (clear) + button.clear(); // the clear also updates transparent } void IconbarTool::deleteIcons() { @@ -717,7 +716,8 @@ void IconbarTool::addWindow(FluxboxWindow &win) { return; IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win); - renderButton(*button); + + renderButton(*button, false); m_icon_container.insertItem(button); m_icon_list.push_back(button); @@ -809,6 +809,5 @@ void IconbarTool::timedRender() { renderButton(*button); if (current_button != 0) renderButton(*current_button); - } diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index bfcac34..600a862 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.13 2003/12/23 01:55:07 rathnor Exp $ +// $Id: IconbarTool.hh,v 1.14 2004/06/16 15:38:19 rathnor Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH @@ -81,8 +81,8 @@ private: /// render single button that holds win void renderWindow(FluxboxWindow &win); - /// render single button - void renderButton(IconButton &button); + /// render single button, and probably apply changes (clear) + void renderButton(IconButton &button, bool clear = true); /// render all buttons void renderTheme(); /// destroy all icons diff --git a/src/Toolbar.cc b/src/Toolbar.cc index b49dcc9..c6ab79c 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.143 2004/06/10 17:07:58 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.144 2004/06/16 15:38:19 rathnor Exp $ #include "Toolbar.hh" @@ -267,7 +267,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): // setup to listen to child events FbTk::EventManager::instance()->addParent(*this, window()); // get everything together - reconfigure(); + //reconfigure(); + // this gets done by the screen later as it loads } @@ -423,7 +424,7 @@ void Toolbar::reconfigure() { m_shape.reset(new Shape(frame.window, 0)); } - // recallibrate size + // recalibrate size setPlacement(placement()); if (isHidden()) { @@ -552,9 +553,13 @@ void Toolbar::exposeEvent(XExposeEvent &ee) { void Toolbar::handleEvent(XEvent &event) { + /* Commented out by Simon 16jun04, since it causes LOTS of rearrangeItems + particularly on startup. Can't figure out why this is needed. if (event.type == ConfigureNotify && - event.xconfigure.window != window().window()) - rearrangeItems(); + event.xconfigure.window != window().window()) { + rearrangeItems(); + } + */ } void Toolbar::update(FbTk::Subject *subj) { @@ -911,7 +916,7 @@ void Toolbar::rearrangeItems() { } // now move and resize the items // borderWidth added back on straight away - int next_x = -2*m_item_list.front()->borderWidth(); // list isn't empty + int next_x = -m_item_list.front()->borderWidth(); // list isn't empty last_bw = 0; for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { if (!(*item_it)->active()) { @@ -934,9 +939,9 @@ void Toolbar::rearrangeItems() { --rounding_error; } - (*item_it)->moveResize(next_x, -borderW, extra + relative_width, height()); + (*item_it)->moveResize(next_x - borderW, -borderW, extra + relative_width, height()); } else { // fixed size - (*item_it)->moveResize(next_x, -borderW, + (*item_it)->moveResize(next_x - borderW, -borderW, (*item_it)->width(), height()); } next_x += (*item_it)->width(); diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index f2291e3..8509300 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc @@ -20,7 +20,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTool.cc,v 1.7 2004/01/13 14:41:32 rathnor Exp $ +// $Id: WorkspaceNameTool.cc,v 1.8 2004/06/16 15:38:19 rathnor Exp $ #include "WorkspaceNameTool.hh" @@ -125,5 +125,4 @@ void WorkspaceNameTool::renderTheme() { m_button.setBorderColor(m_theme.border().color()); m_button.setAlpha(m_theme.alpha()); m_button.clear(); - m_button.updateTransparent(); } -- cgit v0.11.2