all repos — fluxbox @ be1cbd46909e678bbd71f3a590e36c3077cb2960

custom fork of the fluxbox windowmanager

public setRootPixmap
fluxgen fluxgen
commit

be1cbd46909e678bbd71f3a590e36c3077cb2960

parent

b131f3a8afd3884763adcec17f8a9af3b80b8278

2 files changed, 50 insertions(+), 42 deletions(-)

jump to
M src/FbTk/FbPixmap.ccsrc/FbTk/FbPixmap.cc

@@ -357,55 +357,62 @@ m_root_pixmaps[screen_num] = pm;

} Pixmap FbPixmap::getRootPixmap(int screen_num) { - if (!FbTk::Transparent::haveRender()) - return None; + /* + if (!FbTk::Transparent::haveRender()) + return None; + */ - if (!m_root_pixmaps) { - int numscreens = ScreenCount(display()); - for (int i=0; i < numscreens; ++i) { - Atom real_type; - int real_format; - unsigned long items_read, items_left; - unsigned long *data; + // check and see if if we have the pixmaps in cache + if (m_root_pixmaps) + return m_root_pixmaps[screen_num]; + + // else setup pixmap cache + int numscreens = ScreenCount(display()); + for (int i=0; i < numscreens; ++i) { + Atom real_type; + int real_format; + unsigned long items_read, items_left; + unsigned long *data; - unsigned int prop = 0; + unsigned int prop = 0; - static bool print_error = true; // print error_message only once - static const char* error_message = { "\n\n !!! WARNING WARNING WARNING WARNING !!!!!\n" - " if you experience problems with transparency:\n" - " you are using a wallpapersetter that \n" - " uses _XSETROOT_ID .. which we do not support.\n" - " consult 'fbsetbg -i' or try any other wallpapersetter\n" - " that uses _XROOTPMAP_ID !\n" - " !!! WARNING WARNING WARNING WARNING !!!!!!\n\n" - }; + static bool print_error = true; // print error_message only once + static const char* error_message = { + "\n\n !!! WARNING WARNING WARNING WARNING !!!!!\n" + " if you experience problems with transparency:\n" + " you are using a wallpapersetter that \n" + " uses _XSETROOT_ID .. which we do not support.\n" + " consult 'fbsetbg -i' or try any other wallpapersetter\n" + " that uses _XROOTPMAP_ID !\n" + " !!! WARNING WARNING WARNING WARNING !!!!!!\n\n" + }; - Pixmap root_pm = None; - for (prop = 0; root_prop_ids[prop]; prop++) { - checkAtoms(); - if (XGetWindowProperty(display(), - RootWindow(display(), i), - root_prop_atoms[i], - 0l, 1l, - False, XA_PIXMAP, - &real_type, &real_format, - &items_read, &items_left, - (unsigned char **) &data) == Success) { - if (real_format == 32 && items_read == 1) { - if (print_error && strcmp(root_prop_ids[prop], "_XSETROOT_ID") == 0) { - cerr<<error_message; - print_error = false; - } else - root_pm = (Pixmap) (*data); - } - XFree(data); - if (root_pm != None) - break; + Pixmap root_pm = None; + for (prop = 0; root_prop_ids[prop]; prop++) { + checkAtoms(); + if (XGetWindowProperty(display(), + RootWindow(display(), i), + root_prop_atoms[i], + 0l, 1l, + False, XA_PIXMAP, + &real_type, &real_format, + &items_read, &items_left, + (unsigned char **) &data) == Success) { + if (real_format == 32 && items_read == 1) { + if (print_error && strcmp(root_prop_ids[prop], "_XSETROOT_ID") == 0) { + cerr<<error_message; + print_error = false; + } else + root_pm = (Pixmap) (*data); } + XFree(data); + if (root_pm != None) + break; } - setRootPixmap(i, root_pm); } + setRootPixmap(i, root_pm); } + return m_root_pixmaps[screen_num]; }
M src/FbTk/FbPixmap.hhsrc/FbTk/FbPixmap.hh

@@ -69,6 +69,7 @@ inline unsigned int height() const { return m_height; }

inline int depth() const { return m_depth; } static Pixmap getRootPixmap(int screen_num); + static void setRootPixmap(int screen_num, Pixmap pm); static void rootwinPropertyNotify(int screen_num, Atom atom); void create(Drawable src,

@@ -83,7 +84,7 @@ int m_depth;

/// Functions relating to the maintenance of root window pixmap caching static void checkAtoms(); - static void setRootPixmap(int screen_num, Pixmap pm); + // array of pixmaps: 1 per screen static Pixmap *m_root_pixmaps; static const char *root_prop_ids[];