Annotation of /trunk/vnc/patches/vnc-xscreensaver.patch
Parent Directory | Revision Log
Revision 153 -
(hide annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 2609 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 2609 byte(s)
-import
1 | niro | 153 | --- vnc-4_1_1-unixsrc/unix/vncviewer/vncviewer.cxx.xscreensaver 2005-09-06 13:39:13.000000000 +0100 |
2 | +++ vnc-4_1_1-unixsrc/unix/vncviewer/vncviewer.cxx 2005-09-06 14:46:29.000000000 +0100 | ||
3 | @@ -22,6 +22,7 @@ | ||
4 | #include <string.h> | ||
5 | #include <stdio.h> | ||
6 | #include <ctype.h> | ||
7 | +#include <fcntl.h> | ||
8 | #include <stdlib.h> | ||
9 | #include <sys/time.h> | ||
10 | #include <sys/types.h> | ||
11 | @@ -111,6 +112,45 @@ | ||
12 | exit(1); | ||
13 | } | ||
14 | |||
15 | +static void deactivate_xscreensaver (void) | ||
16 | +{ | ||
17 | + if (!fullScreen) | ||
18 | + return; | ||
19 | + | ||
20 | + pid_t pid = fork(); | ||
21 | + | ||
22 | + if (pid < 0) { | ||
23 | + perror("fork"); | ||
24 | + return; | ||
25 | + } | ||
26 | + | ||
27 | + if (pid == 0) { | ||
28 | + // child | ||
29 | + close (STDIN_FILENO); | ||
30 | + close (STDOUT_FILENO); | ||
31 | + close (STDERR_FILENO); | ||
32 | + int null = open ("/dev/null", O_RDWR); | ||
33 | + if (null != STDIN_FILENO) | ||
34 | + dup2 (null, STDIN_FILENO); | ||
35 | + if (null != STDOUT_FILENO) | ||
36 | + dup2 (null, STDOUT_FILENO); | ||
37 | + if (null != STDERR_FILENO) | ||
38 | + dup2 (null, STDERR_FILENO); | ||
39 | + execlp ("xscreensaver-command", | ||
40 | + "xscreensaver-command", "-deactivate", NULL); | ||
41 | + } | ||
42 | + | ||
43 | + // reap previous child | ||
44 | + while (wait3(NULL, WNOHANG, 0) > 0) ; | ||
45 | +} | ||
46 | + | ||
47 | +static const unsigned int alarm_period = 59; | ||
48 | +static int alarm_caught; | ||
49 | +static void AlarmSignalHandler(int sig) | ||
50 | +{ | ||
51 | + alarm_caught = 1; | ||
52 | +} | ||
53 | + | ||
54 | // XLoginIconifier is a class which iconifies the XDM login window when it has | ||
55 | // grabbed the keyboard, thus releasing the grab, allowing the viewer to use | ||
56 | // the keyboard. It remaps the xlogin window on exit. | ||
57 | @@ -230,6 +270,7 @@ | ||
58 | signal(SIGHUP, CleanupSignalHandler); | ||
59 | signal(SIGINT, CleanupSignalHandler); | ||
60 | signal(SIGTERM, CleanupSignalHandler); | ||
61 | + signal(SIGALRM, AlarmSignalHandler); | ||
62 | |||
63 | programName = argv[0]; | ||
64 | char* vncServerName = 0; | ||
65 | @@ -312,9 +353,16 @@ | ||
66 | |||
67 | // X events are processed whenever reading from the socket would block. | ||
68 | |||
69 | + alarm (alarm_period); | ||
70 | while (true) { | ||
71 | cc.getInStream()->check(1); | ||
72 | cc.processMsg(); | ||
73 | + | ||
74 | + if (alarm_caught) { | ||
75 | + alarm_caught = 0; | ||
76 | + deactivate_xscreensaver (); | ||
77 | + alarm (alarm_period); | ||
78 | + } | ||
79 | } | ||
80 | |||
81 | } catch (rdr::EndOfStream& e) { | ||
82 | --- vnc-4_1_1-unixsrc/unix/vncviewer/CConn.cxx.xscreensaver 2005-09-06 13:49:22.000000000 +0100 | ||
83 | +++ vnc-4_1_1-unixsrc/unix/vncviewer/CConn.cxx 2005-09-06 14:50:05.000000000 +0100 | ||
84 | @@ -184,7 +184,11 @@ | ||
85 | FD_SET(ConnectionNumber(dpy), &rfds); | ||
86 | FD_SET(sock->getFd(), &rfds); | ||
87 | int n = select(FD_SETSIZE, &rfds, 0, 0, tvp); | ||
88 | - if (n < 0) throw rdr::SystemException("select",errno); | ||
89 | + if (n < 0) { | ||
90 | + if (errno == EINTR) | ||
91 | + continue; | ||
92 | + throw rdr::SystemException("select",errno); | ||
93 | + } | ||
94 | } while (!(FD_ISSET(sock->getFd(), &rfds))); | ||
95 | } | ||
96 |