aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authorsimonb <simonb>2006-04-21 16:07:45 (GMT)
committersimonb <simonb>2006-04-21 16:07:45 (GMT)
commit67326a080a6b8029c1d3b0cc23dfadaf888da32f (patch)
treed366009b22706bf6cf6a0e646dea03a414a62ce3 /src/FbTk
parenta8b9672792908ca6f3a05a6060ce9927adb878b1 (diff)
downloadfluxbox_paul-67326a080a6b8029c1d3b0cc23dfadaf888da32f.zip
fluxbox_paul-67326a080a6b8029c1d3b0cc23dfadaf888da32f.tar.bz2
update transparent window backgrounds on bg change
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/FbPixmap.cc8
-rw-r--r--src/FbTk/FbWindow.cc37
-rw-r--r--src/FbTk/FbWindow.hh9
3 files changed, 50 insertions, 4 deletions
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 @@
25#include "App.hh" 25#include "App.hh"
26#include "GContext.hh" 26#include "GContext.hh"
27#include "Transparent.hh" 27#include "Transparent.hh"
28#include "FbWindow.hh"
28 29
29#include <X11/Xutil.h> 30#include <X11/Xutil.h>
30#include <X11/Xatom.h> 31#include <X11/Xatom.h>
@@ -390,9 +391,14 @@ void FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) {
390void FbPixmap::setRootPixmap(int screen_num, Pixmap pm) { 391void FbPixmap::setRootPixmap(int screen_num, Pixmap pm) {
391 if (!m_root_pixmaps) { 392 if (!m_root_pixmaps) {
392 m_root_pixmaps = new Pixmap[ScreenCount(display())]; 393 m_root_pixmaps = new Pixmap[ScreenCount(display())];
394 for (int i=0; i < ScreenCount(display()); ++i)
395 m_root_pixmaps[i] = None;
393 } 396 }
394 397
395 m_root_pixmaps[screen_num] = pm; 398 if (m_root_pixmaps[screen_num] != pm) {
399 m_root_pixmaps[screen_num] = pm;
400 FbWindow::updatedAlphaBackground(screen_num);
401 }
396} 402}
397 403
398Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) { 404Pixmap 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),
118FbWindow::~FbWindow() { 118FbWindow::~FbWindow() {
119 119
120 // Need to free xrender pics before destroying window 120 // Need to free xrender pics before destroying window
121 if (m_transparent.get() != 0) 121 if (m_transparent.get() != 0) {
122 removeAlphaWin(*this);
122 m_transparent.reset(0); 123 m_transparent.reset(0);
124 }
123 125
124 if (m_window != 0) { 126 if (m_window != 0) {
125 // so we don't get any dangling eventhandler for this window 127 // so we don't get any dangling eventhandler for this window
@@ -127,6 +129,7 @@ FbWindow::~FbWindow() {
127 if (m_destroy) 129 if (m_destroy)
128 XDestroyWindow(display(), m_window); 130 XDestroyWindow(display(), m_window);
129 } 131 }
132
130} 133}
131 134
132void FbWindow::setBackgroundColor(const FbTk::Color &bg_color) { 135void 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
319void FbWindow::setAlpha(unsigned char alpha) { 322void FbWindow::setAlpha(unsigned char alpha) {
320#ifdef HAVE_XRENDER 323#ifdef HAVE_XRENDER
321 if (FbTk::Transparent::haveComposite()) { 324 if (FbTk::Transparent::haveComposite()) {
322 if (m_transparent.get() != 0) 325 if (m_transparent.get() != 0) {
326 removeAlphaWin(*this);
323 m_transparent.reset(0); 327 m_transparent.reset(0);
328 }
324 329
325 // don't setOpaque, let controlling objects do that 330 // don't setOpaque, let controlling objects do that
326 // since it's only needed on toplevel windows 331 // since it's only needed on toplevel windows
@@ -330,10 +335,13 @@ void FbWindow::setAlpha(unsigned char alpha) {
330 335
331 if (m_transparent.get() == 0 && alpha < 255) { 336 if (m_transparent.get() == 0 && alpha < 255) {
332 m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); 337 m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber()));
338 addAlphaWin(*this);
333 } else if (alpha < 255 && alpha != m_transparent->alpha()) 339 } else if (alpha < 255 && alpha != m_transparent->alpha())
334 m_transparent->setAlpha(alpha); 340 m_transparent->setAlpha(alpha);
335 else if (alpha == 255) 341 else if (alpha == 255) {
342 removeAlphaWin(*this);
336 m_transparent.reset(0); // destroy transparent object 343 m_transparent.reset(0); // destroy transparent object
344 }
337 } 345 }
338#endif // HAVE_XRENDER 346#endif // HAVE_XRENDER
339} 347}
@@ -592,6 +600,29 @@ void FbWindow::sendConfigureNotify(int x, int y,
592 600
593} 601}
594 602
603FbWindow::FbWinList FbWindow::m_alpha_wins;
604
605void FbWindow::addAlphaWin(FbWindow &win) {
606 m_alpha_wins.insert(&win);
607}
608
609void FbWindow::removeAlphaWin(FbWindow &win) {
610 FbWinList::iterator it = m_alpha_wins.find(&win);
611 if (it != m_alpha_wins.end())
612 m_alpha_wins.erase(it);
613}
614
615void FbWindow::updatedAlphaBackground(int screen) {
616 FbWinList::iterator it = m_alpha_wins.begin();
617 FbWinList::iterator it_end = m_alpha_wins.end();
618 for (; it != it_end; ++it) {
619 if ((*it)->screenNumber() == screen) {
620 (*it)->updateBackground(false);
621 (*it)->clear();
622 }
623 }
624}
625
595bool operator == (Window win, const FbWindow &fbwin) { 626bool operator == (Window win, const FbWindow &fbwin) {
596 return win == fbwin.window(); 627 return win == fbwin.window();
597} 628}
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 @@
29#include <X11/Xlib.h> 29#include <X11/Xlib.h>
30#include <memory> 30#include <memory>
31#include <string> 31#include <string>
32#include <set>
32 33
33namespace FbTk { 34namespace FbTk {
34 35
@@ -194,6 +195,8 @@ public:
194 /// forces full background change, recalcing of alpha values if necessary 195 /// forces full background change, recalcing of alpha values if necessary
195 void updateBackground(bool only_if_alpha); 196 void updateBackground(bool only_if_alpha);
196 197
198 static void updatedAlphaBackground(int screen);
199
197protected: 200protected:
198 /// creates a window with x window client (m_window = client) 201 /// creates a window with x window client (m_window = client)
199 explicit FbWindow(Window client); 202 explicit FbWindow(Window client);
@@ -226,6 +229,12 @@ private:
226 Pixmap m_lastbg_pm; 229 Pixmap m_lastbg_pm;
227 230
228 FbWindowRenderer *m_renderer; 231 FbWindowRenderer *m_renderer;
232
233 static void addAlphaWin(FbWindow &win);
234 static void removeAlphaWin(FbWindow &win);
235
236 typedef std::set<FbWindow *> FbWinList;
237 static FbWinList m_alpha_wins;
229}; 238};
230 239
231bool operator == (Window win, const FbWindow &fbwin); 240bool operator == (Window win, const FbWindow &fbwin);