summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpuppetmaster <puppetmaster>2005-07-28 23:13:57 +0000
committerpuppetmaster <puppetmaster>2005-07-28 23:13:57 +0000
commitbde4c25ee95fd0eaa3e641c920194ddb0cc861fc (patch)
tree6a509fdfd1504831df7af60dc2cde22eef2506d1
parent2612ccffe01e4df7c81136bb06a46a8bd562fee3 (diff)
Added ecore_x_screensaver_add ...
-rw-r--r--ecore/src/lib/ecore_x/ecore_x_screensaver.c103
1 files changed, 64 insertions, 39 deletions
diff --git a/ecore/src/lib/ecore_x/ecore_x_screensaver.c b/ecore/src/lib/ecore_x/ecore_x_screensaver.c
index 1b1d394..9a44d54 100644
--- a/ecore/src/lib/ecore_x/ecore_x_screensaver.c
+++ b/ecore/src/lib/ecore_x/ecore_x_screensaver.c
@@ -9,65 +9,90 @@
9 9
10#endif 10#endif
11 11
12XScreenSaverInfo * 12XScreenSaverInfo *
13ecore_x_screensaver_get_alloc_info(void) 13ecore_x_screensaver_get_alloc_info (void)
14{ 14{
15 XScreenSaverInfo *info; 15 XScreenSaverInfo *info;
16 Ecore_X_Window root; 16 Ecore_X_Window root;
17 17
18 info = XScreenSaverAllocInfo(); 18 info = XScreenSaverAllocInfo ();
19 19
20 if (!info) 20 if (!info)
21 return NULL; 21 return NULL;
22 22
23 root = DefaultRootWindow(_ecore_x_disp); 23 root = DefaultRootWindow (_ecore_x_disp);
24 24
25 if (!XScreenSaverQueryInfo(_ecore_x_disp, root, info)) 25 if (!XScreenSaverQueryInfo (_ecore_x_disp, root, info))
26 return info; 26 return info;
27 else 27 else
28 return NULL; 28 return NULL;
29} 29}
30 30
31void 31void
32ecore_x_screensaver_free_alloc_info(XScreenSaverQueryInfo * info) 32ecore_x_screensaver_free_alloc_info (XScreenSaverQueryInfo * info)
33{ 33{
34 XFree(info); 34 XFree (info);
35 return; 35 return;
36} 36}
37 37
38int 38int
39ecore_x_screensaver_set_attributes(XSetWindowAttributes attr) 39ecore_x_screensaver_set_attributes (XSetWindowAttributes attr)
40{ 40{
41 Ecore_X_Window root; 41 Ecore_X_Window root;
42 int screen; 42 int screen;
43 43
44 root = DefaultRootWindow(_ecore_x_disp); 44 root = DefaultRootWindow (_ecore_x_disp);
45 45
46 screen = DefaultScreen(_ecore_x_disp); 46 screen = DefaultScreen (_ecore_x_disp);
47 47
48 if (!XScreenSaverSetAttributes(_ecore_x_disp, root, 0, 0, 48 if (!XScreenSaverSetAttributes (_ecore_x_disp, root, 0, 0,
49 DisplayWidth(_ecore_x_disp, screen), 49 DisplayWidth (_ecore_x_disp, screen),
50 DisplayHeight(_ecore_x_disp, screen), 50 DisplayHeight (_ecore_x_disp, screen),
51 0, 51 0,
52 CopyFromParent, 52 CopyFromParent,
53 CopyFromParent, CopyFromParent, mask, &attr)) 53 CopyFromParent, CopyFromParent, mask,
54 return 1; 54 &attr))
55 else 55 return 1;
56 return 0; 56 else
57 return 0;
57} 58}
58 59
59int 60int
60ecore_x_screensaver_event_handler_add(void) 61ecore_x_screensaver_add (void)
61{ 62{
62 Ecore_X_Window root; 63 GC gc;
63 64 int screen;
64 root = DefaultRootWindow(_ecore_x_disp); 65 XEvent event;
65 66 Ecore_X_Window root;
66 if (!XScreenSaverSelectInput 67 XScreenSaverNotifyEvent *se;
67 (_ecore_x_disp, root, ScreenSaverNotifyMask | ScreenSaverCycleMask)) 68
68 return 1; 69 root = DefaultRootWindow (_ecore_x_disp);
69 70 screen = DefaultScreen (_ecore_x_disp);
70 if (!ecore_x_screensaver_set_attributes()) 71 gc = DefaultGC (_ecore_x_disp, screen);
71 return 1; 72
72 /* ... */ 73 if (!XScreenSaverSelectInput
74 (_ecore_x_disp, root, ScreenSaverNotifyMask | ScreenSaverCycleMask))
75 return 1;
76
77 if (!ecore_x_screensaver_set_attributes ())
78 return 1;
79
80 if (!XSetForeground (_ecore_x_disp, gc, WhitePixel (_ecore_x_disp, screen)))
81 return 1;
82
83 while (1)
84 {
85 if (!XNextEvent (_ecore_x_disp, &event))
86 return 1;
87 if (event.type == _ecore_x_event_scrnsaver_id)
88 {
89 se = (XScreenSaverNotifyEvent *) & pe;
90
91 if (se->state == ScreenSaverOn && se->kind == ScreenSaverExternal)
92 {
93 XDrawString (_ecore_x_disp, 100, 100, "Ecore ScreeSaver", 17);
94 XSync (_ecore_x_disp, False);
95 }
96 }
97 }
73} 98}