summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Cameron <Brian.Cameron@sun.com>2010-04-21 17:21:20 -0500
committerBrian Cameron <Brian.Cameron@sun.com>2010-04-21 17:21:20 -0500
commitf1baea4414a7859a56a66712d357b3fd6492f8b5 (patch)
tree85d2ed4be3aed01331867af444805a2760236929
parent30907fccf4c52109e0653925cabf86c656631918 (diff)
downloadgdm-f1baea4414a7859a56a66712d357b3fd6492f8b5.tar.gz
Set WINDOWPATH for user session. Fixes bug #609272.
-rw-r--r--daemon/gdm-session-direct.c17
-rw-r--r--daemon/gdm-slave.c86
-rw-r--r--daemon/gdm-welcome-session.c2
3 files changed, 96 insertions, 9 deletions
diff --git a/daemon/gdm-session-direct.c b/daemon/gdm-session-direct.c
index 77d5801f..031ae338 100644
--- a/daemon/gdm-session-direct.c
+++ b/daemon/gdm-session-direct.c
@@ -609,12 +609,12 @@ get_system_default_layout (GdmSessionDirect *session)
static XklEngine *engine = NULL;
if (engine == NULL) {
- Display *display = XOpenDisplay (session->priv->display_name);
- if (display != NULL) {
- engine = xkl_engine_get_instance (display);
- }
- /* do NOT call XCloseDisplay (display) here;
- * xkl_engine_get_instance() is a singleton which saves the display */
+ Display *display = XOpenDisplay (session->priv->display_name);
+ if (display != NULL) {
+ engine = xkl_engine_get_instance (display);
+ }
+ /* do NOT call XCloseDisplay (display) here;
+ * xkl_engine_get_instance() is a singleton which saves the display */
}
if (engine != NULL) {
@@ -2045,6 +2045,11 @@ setup_session_environment (GdmSessionDirect *session)
session->priv->user_x11_authority_file);
}
+ gdm_session_direct_set_environment_variable (session,
+ "WINDOWPATH",
+ g_getenv ("WINDOWPATH"));
+
+
/* FIXME: We do this here and in the session worker. We should consolidate
* somehow.
*/
diff --git a/daemon/gdm-slave.c b/daemon/gdm-slave.c
index 31c172d3..73784dc4 100644
--- a/daemon/gdm-slave.c
+++ b/daemon/gdm-slave.c
@@ -43,6 +43,7 @@
#include <X11/Xlib.h> /* for Display */
#include <X11/cursorfont.h> /* for watch cursor */
+#include <X11/Xatom.h>
#include "gdm-common.h"
@@ -87,6 +88,7 @@ struct GdmSlavePrivate
char *display_x11_authority_file;
char *parent_display_name;
char *parent_display_x11_authority_file;
+ char *windowpath;
GArray *display_x11_cookie;
@@ -385,6 +387,83 @@ gdm_slave_setup_xhost_auth (XHostAddress *host_entries, XServerInterpretedAddres
host_entries[1].length = sizeof (XServerInterpretedAddress);
}
+static void
+gdm_slave_set_windowpath (GdmSlave *slave)
+{
+ /* setting WINDOWPATH for clients */
+ Atom prop;
+ Atom actualtype;
+ int actualformat;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *buf;
+ const char *windowpath;
+ char *newwindowpath;
+ unsigned long num;
+ char nums[10];
+ int numn;
+
+ prop = XInternAtom (slave->priv->server_display, "XFree86_VT", False);
+ if (prop == None) {
+ g_debug ("no XFree86_VT atom\n");
+ return;
+ }
+ if (XGetWindowProperty (slave->priv->server_display,
+ DefaultRootWindow (slave->priv->server_display), prop, 0, 1,
+ False, AnyPropertyType, &actualtype, &actualformat,
+ &nitems, &bytes_after, &buf)) {
+ g_debug ("no XFree86_VT property\n");
+ return;
+ }
+
+ if (nitems != 1) {
+ g_debug ("%lu items in XFree86_VT property!\n", nitems);
+ XFree (buf);
+ return;
+ }
+
+ switch (actualtype) {
+ case XA_CARDINAL:
+ case XA_INTEGER:
+ case XA_WINDOW:
+ switch (actualformat) {
+ case 8:
+ num = (*(uint8_t *)(void *)buf);
+ break;
+ case 16:
+ num = (*(uint16_t *)(void *)buf);
+ break;
+ case 32:
+ num = (*(uint32_t *)(void *)buf);
+ break;
+ default:
+ g_debug ("format %d in XFree86_VT property!\n", actualformat);
+ XFree (buf);
+ return;
+ }
+ break;
+ default:
+ g_debug ("type %lx in XFree86_VT property!\n", actualtype);
+ XFree (buf);
+ return;
+ }
+ XFree (buf);
+
+ windowpath = getenv ("WINDOWPATH");
+ numn = snprintf (nums, sizeof (nums), "%lu", num);
+ if (!windowpath) {
+ newwindowpath = malloc (numn + 1);
+ sprintf (newwindowpath, "%s", nums);
+ } else {
+ newwindowpath = malloc (strlen (windowpath) + 1 + numn + 1);
+ sprintf (newwindowpath, "%s:%s", windowpath, nums);
+ }
+
+ slave->priv->windowpath = newwindowpath;
+
+ g_setenv ("WINDOWPATH", newwindowpath, TRUE);
+}
+
gboolean
gdm_slave_connect_to_x11_display (GdmSlave *slave)
{
@@ -427,12 +506,14 @@ gdm_slave_connect_to_x11_display (GdmSlave *slave)
g_debug ("GdmSlave: Connected to display %s", slave->priv->display_name);
ret = TRUE;
- /* Give programs run by the slave and greeter access to the display
- * independent of current hostname
+ /* Give programs run by the slave and greeter access to the
+ * display independent of current hostname
*/
gdm_slave_setup_xhost_auth (host_entries, si_entries);
XAddHosts (slave->priv->server_display, host_entries,
G_N_ELEMENTS (host_entries));
+
+ gdm_slave_set_windowpath (slave);
} else {
g_debug ("GdmSlave: Connected to display %s", slave->priv->display_name);
ret = TRUE;
@@ -1582,6 +1663,7 @@ gdm_slave_finalize (GObject *object)
g_free (slave->priv->display_x11_authority_file);
g_free (slave->priv->parent_display_name);
g_free (slave->priv->parent_display_x11_authority_file);
+ g_free (slave->priv->windowpath);
g_array_free (slave->priv->display_x11_cookie, TRUE);
G_OBJECT_CLASS (gdm_slave_parent_class)->finalize (object);
diff --git a/daemon/gdm-welcome-session.c b/daemon/gdm-welcome-session.c
index abe0b485..0a6487a8 100644
--- a/daemon/gdm-welcome-session.c
+++ b/daemon/gdm-welcome-session.c
@@ -422,7 +422,7 @@ get_welcome_environment (GdmWelcomeSession *welcome_session)
g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH")));
-
+ g_hash_table_insert (hash, g_strdup ("WINDOWPATH"), g_strdup (g_getenv ("WINDOWPATH")));
g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true"));
g_hash_table_insert (hash, g_strdup ("GVFS_DISABLE_FUSE"), g_strdup ("1"));