source: projects/specs/trunk/x/xorg-x11-xinit/xinit-1.0.7-poke-ck.patch @ 10989

Revision 10989, 4.2 KB checked in by iwaim, 7 years ago (diff)

xorg-x11-xinit: add flies

RevLine 
[10989]1diff -up xinit-1.0.7/xinit.c.poke-ck xinit-1.0.7/xinit.c
2--- xinit-1.0.7/xinit.c.poke-ck 2007-09-24 13:48:04.000000000 -0400
3+++ xinit-1.0.7/xinit.c 2007-09-24 13:53:55.000000000 -0400
4@@ -1,3 +1,4 @@
5+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
6 /* $Xorg: xinit.c,v 1.5 2001/02/09 02:05:49 xorgcvs Exp $ */
7 /* $XdotOrg: $ */
8 
9@@ -39,6 +40,13 @@ in this Software without prior written a
10 #include <ctype.h>
11 #include <stdint.h>
12 
13+#define USE_CONKIT
14+#ifdef USE_CONKIT
15+#include <ck-connector.h>
16+#include <X11/Xatom.h>
17+static CkConnector *ckc = NULL;
18+#endif /* USE_CONKIT */
19+
20 #ifdef X_POSIX_C_SOURCE
21 #define _POSIX_C_SOURCE X_POSIX_C_SOURCE
22 #include <signal.h>
23@@ -521,6 +529,39 @@ processTimeout(int timeout, char *string
24        return( serverpid != pidfound );
25 }
26 
27+
28+#ifdef USE_CONKIT
29+static void
30+register_new_session_with_console_kit (void)
31+{
32+       static char conkitbuf[256];
33+       DBusError   error;
34+
35+       ckc = ck_connector_new ();
36+       if (ckc == NULL) {
37+               Error ("Cannot register with ConsoleKit: OOM creating CkConnector\n");
38+               goto out;
39+       }
40+
41+       dbus_error_init (&error);
42+       if (!ck_connector_open_session (ckc, &error)) {
43+               Error ("Cannot register with ConsoleKit: %s: %s\n", error.name, error.message);
44+               goto out;
45+       }
46+
47+       /* If we managed to register with ConsoleKit, put the
48+        * environment variable XDG_SESSION_COOKIE=cookie as second
49+        * element in newenviron. See set_environment() where we
50+        * earlier have made sure there is room...
51+        */
52+       conkitbuf[sizeof (conkitbuf) - 1] = '\0';
53+       snprintf (conkitbuf, sizeof (conkitbuf) - 1, "XDG_SESSION_COOKIE=%s", ck_connector_get_cookie (ckc));
54+       newenviron[1] = conkitbuf;
55+out:
56+       ;
57+}
58+#endif /* USE_CONKIT */
59+
60 static int
61 startServer(char *server[])
62 {
63@@ -631,6 +672,12 @@ startServer(char *server[])
64                break;
65        }
66 
67+#ifdef USE_CONKIT
68+       if (serverpid != -1 ) {
69+               register_new_session_with_console_kit ();
70+       }
71+#endif /* USE_CONKIT */
72+
73        return(serverpid);
74 }
75 
76@@ -785,6 +832,13 @@ shutdown(void)
77                                clientpid);
78        }
79 
80+#ifdef USE_CONKIT
81+       if (ckc != NULL) {
82+               ck_connector_unref (ckc);
83+               ckc = NULL;
84+       }
85+#endif
86+
87        if (serverpid < 0)
88                return;
89        errno = 0;
90@@ -821,6 +875,13 @@ shutdown(void)
91  * make a new copy of environment that has room for DISPLAY
92  */
93 
94+
95+#ifdef USE_CONKIT
96+#define NUM_EXTRA_ENV_VARS 3
97+#else
98+#define NUM_EXTRA_ENV_VARS 2
99+#endif
100+
101 static void
102 set_environment(void)
103 {
104@@ -832,11 +893,11 @@ set_environment(void)
105     for (oldPtr = environ; *oldPtr; oldPtr++) ;
106 
107     nenvvars = (oldPtr - environ);
108-    newenviron = (char **) malloc ((nenvvars + 3) * sizeof(char **));
109+    newenviron = (char **) malloc ((nenvvars + NUM_EXTRA_ENV_VARS) * sizeof(char **));
110     if (!newenviron) {
111        fprintf (stderr,
112                 "%s:  unable to allocate %d pointers for environment\n",
113-                program, nenvvars + 3);
114+                program, nenvvars + NUM_EXTRA_ENV_VARS);
115        exit (1);
116     }
117 
118@@ -846,10 +907,19 @@ set_environment(void)
119     newPtr = newenviron;
120     *newPtr++ = displaybuf;
121 
122+#ifdef USE_CONKIT
123+    *newPtr++ = "XDG_SESSION_COOKIE=";
124+#endif
125+
126     /* copy pointers to other variables */
127     for (oldPtr = environ; *oldPtr; oldPtr++) {
128        if (strncmp (*oldPtr, "DISPLAY=", 8) != 0
129-        && strncmp (*oldPtr, "WINDOWPATH=", 11) != 0) {
130+        && strncmp (*oldPtr, "WINDOWPATH=", 11) != 0
131+#ifdef USE_CONKIT
132+        && strncmp (*oldPtr, "XDG_SESSION_COOKIE=", 19) != 0
133+#endif
134+        )
135+       {
136            *newPtr++ = *oldPtr;
137        }
138     }
139diff -up xinit-1.0.7/configure.ac.poke-ck xinit-1.0.7/configure.ac
140--- xinit-1.0.7/configure.ac.poke-ck    2007-09-17 06:46:38.000000000 -0400
141+++ xinit-1.0.7/configure.ac    2007-09-24 13:48:04.000000000 -0400
142@@ -92,7 +92,7 @@ AC_ARG_WITH(xinit,
143        [XINIT="$DEFAULT_XINIT"])
144 
145 # Checks for pkg-config packages
146-PKG_CHECK_MODULES(XINIT, x11)
147+PKG_CHECK_MODULES(XINIT, x11 ck-connector)
148 
149 case $host_os in
150     *bsd*)
151diff -up xinit-1.0.7/startx.cpp.poke-ck xinit-1.0.7/startx.cpp
152--- xinit-1.0.7/startx.cpp.poke-ck      2007-09-16 17:24:48.000000000 -0400
153+++ xinit-1.0.7/startx.cpp      2007-09-24 13:48:04.000000000 -0400
154@@ -223,6 +223,12 @@ EOF
155     fi
156 done
157 
158+if [ x"$display" != x ]; then
159+    export DISPLAY=$display
160+else
161+    export DISPLAY=:0
162+fi
163+
164 #if defined(__SCO__) || defined(__UNIXWARE__)
165 if [ "$REMOTE_SERVER" = "TRUE" ]; then
166         exec SHELL_CMD ${client}
Note: See TracBrowser for help on using the repository browser.