tizen 2.4 release
[framework/uifw/e17-mod-tizen-devicemgr.git] / src / hib_devicemgr.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <X11/Xlib.h>
4 #include "hib_set.h"
5
6 #define HIB_CHK(cond) {if (!(cond)) { SLOG(LOG_DEBUG, "DEVICEMGR", "[%s] : '%s' failed.\n", __func__, #cond); return; }}
7
8 void
9 hibernation_set (Display *dpy)
10 {
11     HIB_CHK (dpy);
12
13     Window win = DefaultRootWindow(dpy);
14         XEvent xev;
15         Atom hib_atom = None;
16
17     hib_atom = XInternAtom (dpy, STR_ATOM_HIB_SET, False);
18
19         xev.xclient.window = win;
20         xev.xclient.type = ClientMessage;
21         xev.xclient.message_type = hib_atom;
22         xev.xclient.format = 32;
23         xev.xclient.data.s[0] = HIB_CMD_SET;
24         xev.xclient.data.s[1] = 0;
25         xev.xclient.data.s[2] = 0;
26         xev.xclient.data.s[3] = 0;
27         xev.xclient.data.s[4] = 0;
28
29         XSendEvent(dpy, win, False, StructureNotifyMask, &xev);
30         XSync(dpy, False);
31 }
32
33 void
34 hibernation_unset (Display *dpy)
35 {
36     HIB_CHK (dpy);
37
38     Window win = DefaultRootWindow(dpy);
39         XEvent xev;
40         Atom hib_atom = None;
41
42     hib_atom = XInternAtom (dpy, STR_ATOM_HIB_SET, False);
43
44         xev.xclient.window = win;
45         xev.xclient.type = ClientMessage;
46         xev.xclient.message_type = hib_atom;
47         xev.xclient.format = 32;
48         xev.xclient.data.s[0] = HIB_CMD_UNSET;
49         xev.xclient.data.s[1] = 0;
50         xev.xclient.data.s[2] = 0;
51         xev.xclient.data.s[3] = 0;
52         xev.xclient.data.s[4] = 0;
53
54         XSendEvent(dpy, win, False, StructureNotifyMask, &xev);
55         XSync(dpy, False);
56 }
57