fix more x errors due to using an invalid background

This commit is contained in:
simonb 2006-06-24 14:05:19 +00:00
parent 1d0b23bd02
commit 0b730c76b1
7 changed files with 39 additions and 7 deletions

View file

@ -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

View file

@ -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)

View file

@ -84,6 +84,7 @@ public:
bool tryButtonReleaseEvent(XButtonEvent &event);
void parentMoved();
void invalidateBackground();
/// accessors
inline Alignment alignment() const { return m_align; }

View file

@ -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;

View file

@ -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")

View file

@ -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;
}

View file

@ -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);
}