]> Dogcows Code - chaz/openbox/blob - tools/obsetroot.cc
286a61e4096e3824b5a21aa5124159be3f858f20
[chaz/openbox] / tools / obsetroot.cc
1 #include <otk/otk.hh>
2
3 int main(int argc, char **argv)
4 {
5 otk::initialize();
6
7 int screen = DefaultScreen(**otk::display);
8
9 Pixmap old;
10 Window root = otk::display->screenInfo(screen)->rootWindow();
11
12 otk::Surface *s = new otk::Surface(screen,
13 otk::display->screenInfo(screen)->size());
14 otk::RenderTexture *tx = new otk::RenderTexture(screen, false,
15 otk::RenderTexture::Flat,
16 otk::RenderTexture::Bevel1,
17 false,
18 otk::RenderTexture::Solid,
19 false, 0x202020, 0x0000ff,
20 0, 0);
21 otk::display->renderControl(screen)->drawBackground(*s, *tx);
22
23 otk::display->grab();
24
25 otk::display->setIgnoreErrors(true);
26 // get the current pixmap and free it
27 if (otk::Property::get(root, otk::Property::atoms.rootpmapid,
28 otk::Property::atoms.pixmap, &old) && old) {
29 XKillClient(**otk::display, old);
30 XSync(**otk::display, false);
31 XFreePixmap(**otk::display, old);
32 }
33 if (otk::Property::get(root, otk::Property::atoms.esetrootid,
34 otk::Property::atoms.pixmap, &old) && old)
35 XFreePixmap(**otk::display, old);
36 otk::display->setIgnoreErrors(false);
37
38 // XSetWindowBackground(**display, root, color.pixel());
39
40 // don't kill us when someone wants to change the background!!
41 Pixmap pixmap = XCreatePixmap(**otk::display, root, s->size().width(),
42 s->size().height(),
43 otk::display->screenInfo(screen)->depth());
44 XCopyArea(**otk::display, s->pixmap(), pixmap,
45 DefaultGC(**otk::display, screen), 0, 0,
46 s->size().width(), s->size().height(), 0, 0);
47
48 // set the new pixmap
49 XSetWindowBackgroundPixmap(**otk::display, root, pixmap);
50 XClearWindow(**otk::display, root);
51
52 otk::Property::set(root, otk::Property::atoms.rootpmapid,
53 otk::Property::atoms.pixmap, pixmap);
54 otk::Property::set(root, otk::Property::atoms.esetrootid,
55 otk::Property::atoms.pixmap, pixmap);
56
57 otk::display->ungrab();
58
59 delete tx;
60 delete s;
61
62 XSetCloseDownMode(**otk::display, RetainPermanent);
63 XKillClient(**otk::display, AllTemporary);
64
65 otk::destroy();
66 }
This page took 0.033712 seconds and 3 git commands to generate.