public setRootPixmap

This commit is contained in:
fluxgen 2005-11-22 21:08:07 +00:00
parent b131f3a8af
commit be1cbd4690
2 changed files with 50 additions and 42 deletions

View file

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

View file

@ -69,6 +69,7 @@ public:
inline int depth() const { return m_depth; } inline int depth() const { return m_depth; }
static Pixmap getRootPixmap(int screen_num); static Pixmap getRootPixmap(int screen_num);
static void setRootPixmap(int screen_num, Pixmap pm);
static void rootwinPropertyNotify(int screen_num, Atom atom); static void rootwinPropertyNotify(int screen_num, Atom atom);
void create(Drawable src, void create(Drawable src,
@ -83,7 +84,7 @@ private:
/// Functions relating to the maintenance of root window pixmap caching /// Functions relating to the maintenance of root window pixmap caching
static void checkAtoms(); static void checkAtoms();
static void setRootPixmap(int screen_num, Pixmap pm);
// array of pixmaps: 1 per screen // array of pixmaps: 1 per screen
static Pixmap *m_root_pixmaps; static Pixmap *m_root_pixmaps;
static const char *root_prop_ids[]; static const char *root_prop_ids[];