update transparent window backgrounds on bg change

This commit is contained in:
simonb 2006-04-21 16:07:45 +00:00
parent a8b9672792
commit 67326a080a
4 changed files with 53 additions and 4 deletions

View file

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

View file

@ -25,6 +25,7 @@
#include "App.hh"
#include "GContext.hh"
#include "Transparent.hh"
#include "FbWindow.hh"
#include <X11/Xutil.h>
#include <X11/Xatom.h>
@ -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) {

View file

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

View file

@ -29,6 +29,7 @@
#include <X11/Xlib.h>
#include <memory>
#include <string>
#include <set>
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<FbWindow *> FbWinList;
static FbWinList m_alpha_wins;
};
bool operator == (Window win, const FbWindow &fbwin);