all repos — openbox @ a52a6d96d701c993896f276e4198003317632aaf

openbox fork - make it a bit more like ryudo

tools/obsetroot.cc (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <otk/otk.hh>

int main(int, char **)
{
  otk::initialize();

  int screen = DefaultScreen(**otk::display);
  
  Pixmap old;
  Window root = otk::display->screenInfo(screen)->rootWindow();

  otk::Surface *s = new otk::Surface(screen,
				     otk::display->screenInfo(screen)->size());
  otk::RenderTexture *tx = new otk::RenderTexture(screen, false,
						  otk::RenderTexture::Flat,
						  otk::RenderTexture::Bevel1,
						  false,
						  otk::RenderTexture::Solid,
						  false, 0x202020, 0x0000ff,
						  0, 0);
  otk::display->renderControl(screen)->drawBackground(*s, *tx);

  otk::display->grab();

  otk::display->setIgnoreErrors(true);
  // get the current pixmap and free it
  if (otk::Property::get(root, otk::Property::atoms.rootpmapid,
			 otk::Property::atoms.pixmap, &old) && old) {
    XKillClient(**otk::display, old);
    XSync(**otk::display, false);
    XFreePixmap(**otk::display, old);
  }
  if (otk::Property::get(root, otk::Property::atoms.esetrootid,
			 otk::Property::atoms.pixmap, &old) && old)
    XFreePixmap(**otk::display, old);
  otk::display->setIgnoreErrors(false);

  //  XSetWindowBackground(**display, root, color.pixel());

  // don't kill us when someone wants to change the background!!
  Pixmap pixmap = XCreatePixmap(**otk::display, root, s->size().width(),
				s->size().height(),
				otk::display->screenInfo(screen)->depth());
  XCopyArea(**otk::display, s->pixmap(), pixmap,
	    DefaultGC(**otk::display, screen), 0, 0,
	    s->size().width(), s->size().height(), 0, 0);

  // set the new pixmap
  XSetWindowBackgroundPixmap(**otk::display, root, pixmap);
  XClearWindow(**otk::display, root);

  otk::Property::set(root, otk::Property::atoms.rootpmapid,
		     otk::Property::atoms.pixmap, pixmap);
  otk::Property::set(root, otk::Property::atoms.esetrootid,
		     otk::Property::atoms.pixmap, pixmap);
  
  otk::display->ungrab();

  delete tx;
  delete s;

  XSetCloseDownMode(**otk::display, RetainPermanent);
  XKillClient(**otk::display, AllTemporary);
  
  otk::destroy();
}