From 67326a080a6b8029c1d3b0cc23dfadaf888da32f Mon Sep 17 00:00:00 2001 From: simonb Date: Fri, 21 Apr 2006 16:07:45 +0000 Subject: update transparent window backgrounds on bg change --- ChangeLog | 3 +++ src/FbTk/FbPixmap.cc | 8 +++++++- src/FbTk/FbWindow.cc | 37 ++++++++++++++++++++++++++++++++++--- src/FbTk/FbWindow.hh | 9 +++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index e912106..40b527c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.16: *06/04/21: + * Update all transparent things when bg changes (Simon) + (fixes sf.net #1446516 - slit transparency on start) + FbTk/... FbPixmap.cc FbWindow.hh/cc * Make border between tabs same width/color as window border (Simon) (sf.net #1473870) FbWinFrame.cc diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 675e838..30f2c05 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -25,6 +25,7 @@ #include "App.hh" #include "GContext.hh" #include "Transparent.hh" +#include "FbWindow.hh" #include #include @@ -390,9 +391,14 @@ void FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) { void FbPixmap::setRootPixmap(int screen_num, Pixmap pm) { if (!m_root_pixmaps) { m_root_pixmaps = new Pixmap[ScreenCount(display())]; + for (int i=0; i < ScreenCount(display()); ++i) + m_root_pixmaps[i] = None; } - m_root_pixmaps[screen_num] = pm; + if (m_root_pixmaps[screen_num] != pm) { + m_root_pixmaps[screen_num] = pm; + FbWindow::updatedAlphaBackground(screen_num); + } } Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index a380312..8f204b1 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -118,8 +118,10 @@ FbWindow::FbWindow(Window client):FbDrawable(), m_parent(0), FbWindow::~FbWindow() { // Need to free xrender pics before destroying window - if (m_transparent.get() != 0) + if (m_transparent.get() != 0) { + removeAlphaWin(*this); m_transparent.reset(0); + } if (m_window != 0) { // so we don't get any dangling eventhandler for this window @@ -127,6 +129,7 @@ FbWindow::~FbWindow() { if (m_destroy) XDestroyWindow(display(), m_window); } + } void FbWindow::setBackgroundColor(const FbTk::Color &bg_color) { @@ -319,8 +322,10 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u void FbWindow::setAlpha(unsigned char alpha) { #ifdef HAVE_XRENDER if (FbTk::Transparent::haveComposite()) { - if (m_transparent.get() != 0) + if (m_transparent.get() != 0) { + removeAlphaWin(*this); m_transparent.reset(0); + } // don't setOpaque, let controlling objects do that // since it's only needed on toplevel windows @@ -330,10 +335,13 @@ void FbWindow::setAlpha(unsigned char alpha) { if (m_transparent.get() == 0 && alpha < 255) { m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); + addAlphaWin(*this); } else if (alpha < 255 && alpha != m_transparent->alpha()) m_transparent->setAlpha(alpha); - else if (alpha == 255) + else if (alpha == 255) { + removeAlphaWin(*this); m_transparent.reset(0); // destroy transparent object + } } #endif // HAVE_XRENDER } @@ -592,6 +600,29 @@ void FbWindow::sendConfigureNotify(int x, int y, } +FbWindow::FbWinList FbWindow::m_alpha_wins; + +void FbWindow::addAlphaWin(FbWindow &win) { + m_alpha_wins.insert(&win); +} + +void FbWindow::removeAlphaWin(FbWindow &win) { + FbWinList::iterator it = m_alpha_wins.find(&win); + if (it != m_alpha_wins.end()) + m_alpha_wins.erase(it); +} + +void FbWindow::updatedAlphaBackground(int screen) { + FbWinList::iterator it = m_alpha_wins.begin(); + FbWinList::iterator it_end = m_alpha_wins.end(); + for (; it != it_end; ++it) { + if ((*it)->screenNumber() == screen) { + (*it)->updateBackground(false); + (*it)->clear(); + } + } +} + bool operator == (Window win, const FbWindow &fbwin) { return win == fbwin.window(); } diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index d09ed90..3a5d18d 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -29,6 +29,7 @@ #include #include #include +#include namespace FbTk { @@ -194,6 +195,8 @@ public: /// forces full background change, recalcing of alpha values if necessary void updateBackground(bool only_if_alpha); + static void updatedAlphaBackground(int screen); + protected: /// creates a window with x window client (m_window = client) explicit FbWindow(Window client); @@ -226,6 +229,12 @@ private: Pixmap m_lastbg_pm; FbWindowRenderer *m_renderer; + + static void addAlphaWin(FbWindow &win); + static void removeAlphaWin(FbWindow &win); + + typedef std::set FbWinList; + static FbWinList m_alpha_wins; }; bool operator == (Window win, const FbWindow &fbwin); -- cgit v0.11.2