From 0b730c76b10babe20738067ae7aec5a102d451fe Mon Sep 17 00:00:00 2001 From: simonb Date: Sat, 24 Jun 2006 14:05:19 +0000 Subject: fix more x errors due to using an invalid background --- ChangeLog | 6 +++++- src/Container.cc | 10 ++++++++++ src/Container.hh | 1 + src/FbTk/FbWindow.cc | 5 +++++ src/FbTk/FbWindow.hh | 2 ++ src/FbTk/TextButton.cc | 7 ++++--- src/FbWinFrame.cc | 15 ++++++++++++--- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8547ce9..452c86d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,13 @@ (Format: Year/Month/Day) Changes for 1.0rc2: *06/06/24: + * Fix some more X-errors (Simon) + - window was resized, triggering background re-render, but + background is invalid sometimes (during reconfiguring) + Container.hh/cc FbWinFrame.cc FbTk/FbWindow.hh/cc FbTk/TextButton.cc * Fix bug #1362463, menu selection pixmaps disappear (Simon) - pixmap from image cache was put into FbPixmap, which freed it. - FbPixmap.hh/cc MenuTheme.hh Menu.cc + FbTk/... FbPixmap.hh/cc MenuTheme.hh Menu.cc *06/06/23: * Make startfluxbox aware of --program-prefix and --program-suffix (Mark) configure.in util/Makefile.am util/startfluxbox.in diff --git a/src/Container.cc b/src/Container.cc index 5e7cb7d..aec5aba 100644 --- a/src/Container.cc +++ b/src/Container.cc @@ -502,6 +502,14 @@ void Container::parentMoved() { (*it)->parentMoved(); } +void Container::invalidateBackground() { + FbTk::FbWindow::invalidateBackground(); + ItemList::iterator it = m_item_list.begin(); + ItemList::iterator it_end = m_item_list.end(); + for (; it != it_end; ++it) + (*it)->invalidateBackground(); +} + void Container::clear() { ItemList::iterator it = m_item_list.begin(); ItemList::iterator it_end = m_item_list.end(); @@ -514,6 +522,8 @@ void Container::setOrientation(FbTk::Orientation orient) { if (m_orientation == orient) return; + FbTk::FbWindow::invalidateBackground(); + ItemList::iterator it = m_item_list.begin(); ItemList::iterator it_end = m_item_list.end(); for (; it != it_end; ++it) diff --git a/src/Container.hh b/src/Container.hh index 65dfbb9..a13ddcd 100644 --- a/src/Container.hh +++ b/src/Container.hh @@ -84,6 +84,7 @@ public: bool tryButtonReleaseEvent(XButtonEvent &event); void parentMoved(); + void invalidateBackground(); /// accessors inline Alignment alignment() const { return m_align; } diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index b996edc..090b788 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -153,6 +153,11 @@ void FbWindow::setBackgroundPixmap(Pixmap bg_pixmap) { updateBackground(false); } +void FbWindow::invalidateBackground() { + m_lastbg_pm = None; + m_lastbg_color_set = false; +} + void FbWindow::updateBackground(bool only_if_alpha) { Pixmap newbg = m_lastbg_pm; unsigned char alpha = 255; diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index 8f7376c..1f0c4bd 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -74,6 +74,8 @@ public: virtual ~FbWindow(); virtual void setBackgroundColor(const FbTk::Color &bg_color); virtual void setBackgroundPixmap(Pixmap bg_pixmap); + // call when background is freed, and new one not ready yet + virtual void invalidateBackground(); virtual void setBorderColor(const FbTk::Color &border_color); virtual void setBorderWidth(unsigned int size); /// set window name ("title") diff --git a/src/FbTk/TextButton.cc b/src/FbTk/TextButton.cc index 0d9eef0..474c094 100644 --- a/src/FbTk/TextButton.cc +++ b/src/FbTk/TextButton.cc @@ -63,8 +63,10 @@ void TextButton::setJustify(FbTk::Justify just) { } bool TextButton::setOrientation(FbTk::Orientation orient) { - if (!m_font->validOrientation(orient)) + if (orient == m_orientation + || !m_font->validOrientation(orient)) return false; + invalidateBackground(); if ((m_orientation == FbTk::ROT0 || m_orientation == FbTk::ROT180) && (orient == FbTk::ROT90 || orient == FbTk::ROT270) || @@ -76,8 +78,7 @@ bool TextButton::setOrientation(FbTk::Orientation orient) { } else { m_orientation = orient; } - updateBackground(false); - clear(); + return true; } diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index 00583d7..9df9012 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -159,7 +159,9 @@ bool FbWinFrame::setTabMode(TabMode tabmode) { m_tab_container.setOrientation(FbTk::ROT0); if (m_tab_container.parent()->window() == m_screen.rootWindow().window()) { m_layeritem.removeWindow(m_tab_container); + m_tab_container.hide(); m_tab_container.reparent(m_titlebar, m_label.x(), m_label.y()); + m_tab_container.invalidateBackground(); m_tab_container.resize(m_label.width(), m_label.height()); m_tab_container.raise(); } @@ -424,10 +426,8 @@ void FbWinFrame::alignTabs() { } if (m_tab_container.parent()->window() != m_screen.rootWindow().window()) { - // because the label might be using the same cached pixmap as tab container! - renderTitlebar(); - applyTitlebar(); m_tab_container.reparent(m_screen.rootWindow(), tabx, taby); + m_label.clear(); m_layeritem.addWindow(m_tab_container); } else { m_tab_container.move(tabx, taby); @@ -1000,12 +1000,15 @@ void FbWinFrame::reconfigure() { // we do handle settings whether on or not so that if they get toggled // then things are ok... + m_handle.invalidateBackground(); m_handle.moveResize(-handle_bw, ypos, m_window.width(), grip_height); + m_grip_left.invalidateBackground(); m_grip_left.moveResize(-handle_bw, -handle_bw, grip_width, grip_height); + m_grip_right.invalidateBackground(); m_grip_right.moveResize(m_handle.width() - grip_width - handle_bw, -handle_bw, grip_width, grip_height); @@ -1089,6 +1092,7 @@ void FbWinFrame::reconfigureTitlebar() { // if the titlebar grows in size, make sure the whole window does too if (orig_height != title_height) m_window.resize(m_window.width(), m_window.height()-orig_height+title_height); + m_titlebar.invalidateBackground(); m_titlebar.moveResize(-m_titlebar.borderWidth(), -m_titlebar.borderWidth(), m_window.width(), title_height); @@ -1097,6 +1101,8 @@ void FbWinFrame::reconfigureTitlebar() { unsigned int button_size = buttonHeight(); m_button_size = button_size; for (size_t i=0; i < m_buttons_left.size(); i++, next_x += button_size + m_bevel) { + // probably on theme reconfigure, leave bg alone for now + m_buttons_left[i]->invalidateBackground(); m_buttons_left[i]->moveResize(next_x, m_bevel, button_size, button_size); } @@ -1114,8 +1120,10 @@ void FbWinFrame::reconfigureTitlebar() { if (space_left <= 0) space_left = 1; + m_label.invalidateBackground(); m_label.moveResize(next_x, m_bevel, space_left, button_size); + m_tab_container.invalidateBackground(); if (m_tabmode == INTERNAL) m_tab_container.moveResize(next_x, m_bevel, space_left, button_size); @@ -1134,6 +1142,7 @@ void FbWinFrame::reconfigureTitlebar() { // finaly set new buttons to the right for (size_t i=0; i < m_buttons_right.size(); ++i, next_x += button_size + m_bevel) { + m_buttons_right[i]->invalidateBackground(); m_buttons_right[i]->moveResize(next_x, m_bevel, button_size, button_size); } -- cgit v0.11.2