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