aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/FbPixmap.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/FbPixmap.cc')
-rw-r--r--src/FbTk/FbPixmap.cc59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc
index b0c9d70..d63090e 100644
--- a/src/FbTk/FbPixmap.cc
+++ b/src/FbTk/FbPixmap.cc
@@ -43,25 +43,22 @@ namespace {
43 43
44Pixmap *root_pixmaps = 0; 44Pixmap *root_pixmaps = 0;
45 45
46const char* root_prop_ids[] = { 46struct RootProps {
47 "_XROOTPMAP_ID", 47 const char* name;
48 "_XSETROOT_ID", 48 Atom atom;
49 0
50}; 49};
51 50
52// same number as in root_prop_ids 51struct RootProps root_props[] = {
53Atom root_prop_atoms[] = { 52 { "_XROOTPMAP_ID", None },
54 None, 53 { "_XSETROOT_ID", None }
55 None,
56 None
57}; 54};
58 55
59void checkAtoms() { 56void checkAtoms() {
60 57
61 Display* display = FbTk::App::instance()->display(); 58 Display* display = FbTk::App::instance()->display();
62 for (int i=0; root_prop_ids[i] != 0; ++i) { 59 for (size_t i = 0; i < sizeof(root_props)/sizeof(RootProps); ++i) {
63 if (root_prop_atoms[i] == None) { 60 if (root_props[i].atom == None) {
64 root_prop_atoms[i] = XInternAtom(display, root_prop_ids[i], False); 61 root_props[i].atom = XInternAtom(display, root_props[i].name, False);
65 } 62 }
66 } 63 }
67} 64}
@@ -372,8 +369,8 @@ bool FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) {
372 return false; 369 return false;
373 370
374 checkAtoms(); 371 checkAtoms();
375 for (int i=0; root_prop_ids[i] != 0; ++i) { 372 for (int i=0; i < sizeof(root_props)/sizeof(RootProps); ++i) {
376 if (root_prop_atoms[i] == atom) { 373 if (root_props[i].atom == atom) {
377 Pixmap root_pm = None; 374 Pixmap root_pm = None;
378 Atom real_type; 375 Atom real_type;
379 int real_format; 376 int real_format;
@@ -382,7 +379,7 @@ bool FbPixmap::rootwinPropertyNotify(int screen_num, Atom atom) {
382 379
383 if (XGetWindowProperty(display(), 380 if (XGetWindowProperty(display(),
384 RootWindow(display(), screen_num), 381 RootWindow(display(), screen_num),
385 root_prop_atoms[i], 382 root_props[i].atom,
386 0l, 1l, 383 0l, 1l,
387 False, XA_PIXMAP, 384 False, XA_PIXMAP,
388 &real_type, &real_format, 385 &real_type, &real_format,
@@ -427,6 +424,8 @@ Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) {
427 if (root_pixmaps && !force_update) 424 if (root_pixmaps && !force_update)
428 return root_pixmaps[screen_num]; 425 return root_pixmaps[screen_num];
429 426
427 checkAtoms();
428
430 // else setup pixmap cache 429 // else setup pixmap cache
431 int numscreens = ScreenCount(display()); 430 int numscreens = ScreenCount(display());
432 for (int i=0; i < numscreens; ++i) { 431 for (int i=0; i < numscreens; ++i) {
@@ -435,32 +434,31 @@ Pixmap FbPixmap::getRootPixmap(int screen_num, bool force_update) {
435 unsigned long items_read, items_left; 434 unsigned long items_read, items_left;
436 unsigned long *data; 435 unsigned long *data;
437 436
438 unsigned int prop = 0;
439
440 static bool print_error = true; // print error_message only once 437 static bool print_error = true; // print error_message only once
441 static const char* error_message = {
442 "\n\n !!! WARNING WARNING WARNING WARNING !!!!!\n"
443 " if you experience problems with transparency:\n"
444 " you are using a wallpapersetter that \n"
445 " uses _XSETROOT_ID .. which we do not support.\n"
446 " consult 'fbsetbg -i' or try any other wallpapersetter\n"
447 " that uses _XROOTPMAP_ID !\n"
448 " !!! WARNING WARNING WARNING WARNING !!!!!!\n\n"
449 };
450 438
451 Pixmap root_pm = None; 439 Pixmap root_pm = None;
452 for (prop = 0; root_prop_ids[prop]; prop++) { 440
453 checkAtoms(); 441 unsigned int prop = 0;
442 for (prop = 0; prop < sizeof(root_props)/sizeof(RootProps); ++prop) {
454 if (XGetWindowProperty(display(), 443 if (XGetWindowProperty(display(),
455 RootWindow(display(), i), 444 RootWindow(display(), i),
456 root_prop_atoms[prop], 445 root_props[prop].atom,
457 0l, 1l, 446 0l, 1l,
458 False, XA_PIXMAP, 447 False, XA_PIXMAP,
459 &real_type, &real_format, 448 &real_type, &real_format,
460 &items_read, &items_left, 449 &items_read, &items_left,
461 (unsigned char **) &data) == Success) { 450 (unsigned char **) &data) == Success) {
462 if (real_format == 32 && items_read == 1) { 451 if (real_format == 32 && items_read == 1) {
463 if (print_error && strcmp(root_prop_ids[prop], "_XSETROOT_ID") == 0) { 452 if (print_error && strcmp(root_props[prop].name, "_XSETROOT_ID") == 0) {
453 static const char* error_message = {
454 "\n\n !!! WARNING WARNING WARNING WARNING !!!!!\n"
455 " if you experience problems with transparency:\n"
456 " you are using a wallpapersetter that \n"
457 " uses _XSETROOT_ID .. which we do not support.\n"
458 " consult 'fbsetbg -i' or try any other wallpapersetter\n"
459 " that uses _XROOTPMAP_ID !\n"
460 " !!! WARNING WARNING WARNING WARNING !!!!!!\n\n"
461 };
464 cerr<<error_message; 462 cerr<<error_message;
465 print_error = false; 463 print_error = false;
466 } else 464 } else
@@ -507,3 +505,4 @@ void FbPixmap::create(Drawable src,
507} 505}
508 506
509} // end namespace FbTk 507} // end namespace FbTk
508