patches/SUNWtgnome-xagent-01-trusted-extensions.diff
author dcarbery
Thu, 07 Jun 2007 11:51:37 +0000
changeset 10014 79c94784d3dd
parent 9738 591746900d38
child 10015 dd22f78a2084
permissions -rw-r--r--
2007-06-07 Damien Carbery <[email protected]> * patches/gnome-session-06-trusted-extensions.diff: Rework. * patches/SUNWtgnome-xagent-01-trusted-extensions.diff: Rework.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
     1
diff -urN -x'*~' gnome-session-2.18.0/gnome-session/Makefile.am ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/Makefile.am
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
     2
--- gnome-session-2.18.0/gnome-session/Makefile.am	2007-04-12 17:59:16.954363000 +0000
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
     3
+++ ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/Makefile.am	2007-04-12 18:04:53.249935000 +0000
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     4
@@ -4,6 +4,7 @@
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     5
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     6
 INCLUDES =						\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     7
 	$(GNOME_SESSION_CFLAGS)				\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     8
+	$(LIBWNCK_CFLAGS)                               \
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
     9
 	$(STANDARD_PROPERTIES_CFLAGS)			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    10
 	$(WARN_CFLAGS)					\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    11
 	$(DISABLE_DEPRECATED_CFLAGS)			\
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    12
@@ -33,6 +34,14 @@
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    13
 gnome_session_properties_LDADD = $(GNOME_SESSION_LIBS)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    14
 splash_test_LDADD = $(X_LIBS) $(GNOME_SESSION_LIBS)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    15
 logout_test_LDADD = $(X_LIBS) $(GNOME_SESSION_LIBS)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    16
+if XTSOL_DEFINED
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    17
+tsoljds_xagent_LDADD = $(XTSOL_LIBS) $(GNOME_SESSION_LIBS)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    18
+endif
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    19
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    20
+if XTSOL_DEFINED
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    21
+TSOLJDS_bin = \
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    22
+	tsoljds-xagent
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    23
+endif
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    24
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    25
 if SESSION
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    26
 noinst_PROGRAMS = \
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    27
@@ -43,7 +52,8 @@
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    28
 	gnome-session		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    29
 	gnome-session-save	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    30
 	gnome-session-remove    \
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    31
-	gnome-session-properties
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    32
+	gnome-session-properties\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    33
+	$(TSOLJDS_bin)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    34
 endif
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    35
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    36
 splash_test_SOURCES =	\
10014
79c94784d3dd 2007-06-07 Damien Carbery <[email protected]>
dcarbery
parents: 9738
diff changeset
    37
@@ -131,6 +131,41 @@
79c94784d3dd 2007-06-07 Damien Carbery <[email protected]>
dcarbery
parents: 9738
diff changeset
    38
 	util.c			\
79c94784d3dd 2007-06-07 Damien Carbery <[email protected]>
dcarbery
parents: 9738
diff changeset
    39
 	util.h
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    40
 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    41
+if XTSOL_DEFINED
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    42
+tsoljds_xagent_SOURCES =	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    43
+	tsoljds-xagent.c	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    44
+	save.c			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    45
+	save.h			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    46
+	manager.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    47
+	manager.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    48
+	remote.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    49
+	remote.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    50
+	ice.c			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    51
+	ice.h			\
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    52
+	gsm-keyring.c		\
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    53
+	gsm-keyring.h		\
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    54
+	splash-widget.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    55
+	splash-widget.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    56
+	logout.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    57
+	logout.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    58
+	prop.c			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    59
+	command.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    60
+	command.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    61
+	gsm-protocol.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    62
+	gsm-protocol.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    63
+	gsm-typebuiltins.c	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    64
+	gsm-typebuiltins.h	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    65
+	headers.h		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    66
+	util.c			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    67
+	util.h			\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    68
+	gsm-multiscreen.c	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    69
+	gsm-multiscreen.h	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    70
+	gdm-logout-action.c	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    71
+	gdm-logout-action.h	\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    72
+	tsoljds-misc.c		\
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    73
+	tsoljds-misc.h
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    74
+endif
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    75
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    76
 gnome_session_save_SOURCES =	\
10014
79c94784d3dd 2007-06-07 Damien Carbery <[email protected]>
dcarbery
parents: 9738
diff changeset
    77
 	gnome-session-save.c		\
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    78
 	gsm-typebuiltins.c	\
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    79
diff -urN -x'*~' gnome-session-2.18.0/gnome-session/tsoljds-xagent.c ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/tsoljds-xagent.c
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    80
--- gnome-session-2.18.0/gnome-session/tsoljds-xagent.c	1970-01-01 00:00:00.000000000 +0000
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    81
+++ ../SUNWtgnome-xagent-2.18.0.hacked/gnome-session-2.18.0/gnome-session/tsoljds-xagent.c	2007-04-12 18:03:20.518279000 +0000
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
    82
@@ -0,0 +1,507 @@
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    83
+#include <config.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    84
+#ifdef HAVE_XTSOL
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    85
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    86
+#include <glib.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    87
+#include <gtk/gtk.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    88
+#include <gdk/gdkx.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    89
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    90
+#include <sys/types.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    91
+#include <sys/stat.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    92
+#include <unistd.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    93
+#include <stdlib.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    94
+#include <pwd.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    95
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    96
+#include <X11/Xlib.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    97
+#include <X11/Xutil.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    98
+#include <X11/Xos.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
    99
+#include <X11/Xatom.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   100
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   101
+#include <stdio.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   102
+#include <fcntl.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   103
+#include <signal.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   104
+#include <zone.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   105
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   106
+#include <priv.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   107
+#include <sys/tsol/priv.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   108
+#include <tsol/label.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   109
+#include <sys/tsol/label.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   110
+#include <sys/tsol/label_macro.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   111
+#include <X11/extensions/Xtsol.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   112
+#include <prof_attr.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   113
+#include <secdb.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   114
+#include <libgnome/gnome-config.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   115
+#include <libgnome/gnome-program.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   116
+#include <libgnomeui/gnome-ui-init.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   117
+#include <libgnomeui/gnome-client.h>
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   118
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   119
+#include "ice.h"
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   120
+#include "headers.h"
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   121
+#include "save.h"
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
   122
+#include "gsm-keyring.h"
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   123
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   124
+gint purge_delay = 30000;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   125
+gint warn_delay = 30000;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   126
+gint suicide_delay = 10000;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   127
+gboolean failsafe = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   128
+gboolean autosave = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   129
+gboolean save_selected = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   130
+gboolean logout_prompt = TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   131
+gboolean session_save = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   132
+gchar *session_name = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   133
+gboolean managesession = TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   134
+gboolean trusted_session = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   135
+gboolean default_session = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   136
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   137
+typedef struct tcb_component {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   138
+  char *name;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   139
+} tcb_component;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   140
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   141
+const  tcb_component tcb[]  = {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   142
+	{"metacity" },
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   143
+	{"gnome-volcheck" }, /* This is not a tcb component, but it is not zone aware so remove */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   144
+       	{"gnome-panel"},
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   145
+       	{"gnome-smproxy"},
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   146
+       	{"gnome-wm"},
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   147
+       	{"tsoljdsselmgr"},
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   148
+       	{"tsoljds-tstripe"}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   149
+};
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   150
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   151
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   152
+#define _XA_MOTIF_WINDOW       "_MOTIF_DRAG_WINDOW"
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   153
+#define _XA_MOTIF_PROXY_WINDOW  "_MOTIF_DRAG_PROXY_WINDOW"
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   154
+#define TSOLJDS_MIGRATION_SCRIPT "/usr/dt/config/tsoljds-migration"
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   155
+ 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   156
+static void trim_tcb (Session* session);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   157
+static Window GetPropertyWindow(Display *dpy, Window in_win, Atom atom);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   158
+static Window CreateMotifDragWindow(Display *dpy);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   159
+static void WriteMotifDragWindow(Display *dpy, Window *motifWindow);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   160
+static void SetUpPolyprop (Display *x_dpy);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   161
+static gboolean setPrivForTsol (void);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   162
+int    TsolErrorHandler(Display *dpy, XErrorEvent *error);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   163
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   164
+struct passwd *pwent = NULL;   /* Password entry for this user */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   165
+int    pipe_fd;        /* Pipe read from dtwm */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   166
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   167
+void trim_tcb (Session* session)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   168
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   169
+  GSList* list;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   170
+  int i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   171
+  gboolean found = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   172
+  list = session->client_list;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   173
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   174
+  for (; list; list = list->next)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   175
+  {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   176
+    Client* client = (Client*)list->data;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   177
+    GSList* prop_list = client->properties;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   178
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   179
+      found = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   180
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   181
+      for (; prop_list; prop_list = prop_list->next) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   182
+        SmProp* prop = (SmProp*)prop_list->data;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   183
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   184
+	  /* Go through the TCB list, if it is found, remove it */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   185
+          for (i = 0; i < G_N_ELEMENTS(tcb); i++) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   186
+            if (strcmp (prop->vals->value, tcb[i].name)==0) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   187
+	      REMOVE ( client->properties, prop);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   188
+	      found = TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   189
+              break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   190
+            }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   191
+          }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   192
+	  /* Since the prop for the client has been removed, go on to next */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   193
+	  if (found) break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   194
+      }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   195
+  }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   196
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   197
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   198
+char *get_desktop_window_atom_name (void)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   199
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   200
+  static  char *atom_name = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   201
+  uid_t uid;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   202
+  zoneid_t zid;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   203
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   204
+  if (!atom_name) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   205
+    uid = geteuid ();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   206
+    zid = getzoneid ();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   207
+    atom_name = g_strdup_printf ("NAUTILUS_DESKTOP_WINDOW_%d_%d",
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   208
+			    	 uid, zid);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   209
+  }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   210
+  return atom_name;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   211
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   212
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   213
+int
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   214
+get_screen_number (char *exec_cmd)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   215
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   216
+  gchar **token;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   217
+  int scrnum;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   218
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   219
+  token = g_strsplit (exec_cmd, ":", 2);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   220
+  if (token[0]) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   221
+    scrnum = atoi (token[0]);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   222
+    return scrnum;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   223
+  }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   224
+  else return 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   225
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   226
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   227
+gchar *
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   228
+get_real_command (char *exec_cmd)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   229
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   230
+  gchar **token;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   231
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   232
+  token = g_strsplit (exec_cmd, ":", 2);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   233
+  if (token[1])
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   234
+        return (token[1]);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   235
+  else return exec_cmd;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   236
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   237
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   238
+static char * cond( GIOCondition condition)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   239
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   240
+  char value[50];
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   241
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   242
+    switch (condition) 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   243
+    {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   244
+      case 1: strcpy (value, "GLIB_SYSDEF_POLLIN");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   245
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   246
+      case 2: strcpy (value, "GLIB_SYSDEF_POLLPRI");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   247
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   248
+      case 4: strcpy (value, "GLIB_SYSDEF_POLLOUT");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   249
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   250
+      case 8: strcpy (value, "GLIB_SYSDEF_POLLERR");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   251
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   252
+      case 16: strcpy (value, "GLIB_SYSDEF_POLLHUP");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   253
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   254
+      case 32: strcpy (value, "GLIB_SYSDEF_POLLNVAL");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   255
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   256
+      default: strcpy (value, "Unknown condition");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   257
+		break;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   258
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   259
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   260
+    return(value);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   261
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   262
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   263
+static void
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   264
+so_long_pipe (gpointer data)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   265
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   266
+	/*
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   267
+	 * The pipe is bust which probably means the stripe
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   268
+	 * has died. So there's nothing to do but die.
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   269
+	 */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   270
+	exit (2);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   271
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   272
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   273
+static gboolean handle_pipe_input (GIOChannel *source,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   274
+        			   GIOCondition condition,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   275
+        			   gpointer data)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   276
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   277
+#define BUFSIZE 1024
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   278
+  gsize byteread, pos;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   279
+  gchar *str;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   280
+  GError *error = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   281
+  GIOStatus status=0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   282
+  int screen_num;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   283
+  gchar *real_cmd;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   284
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   285
+    if (condition & G_IO_ERR)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   286
+		return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   287
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   288
+    if (condition & G_IO_HUP)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   289
+	/* Seems like another good cue to get out of here */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   290
+		return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   291
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   292
+    if (condition & G_IO_IN) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   293
+      status = g_io_channel_read_line (source, &str, &byteread, &pos, &error);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   294
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   295
+    switch (status)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   296
+      {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   297
+        case G_IO_STATUS_NORMAL: str[pos] = '\0';
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   298
+			screen_num = get_screen_number (str);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   299
+			real_cmd = get_real_command (str);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   300
+			if ((strncmp (real_cmd, "save_yourself", 13) == 0) && (managesession == TRUE))
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   301
+			{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   302
+			  write_session (); 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   303
+			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   304
+			else {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   305
+			  GdkDisplay *gdk_dpy; 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   306
+  			  gdk_dpy = gdk_display_get_default ();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   307
+			  gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy, screen_num), real_cmd, &error);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   308
+			}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   309
+      			return TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   310
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   311
+    	case G_IO_STATUS_AGAIN: fprintf (stderr, "G_IO_STATUS_AGAIN\n");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   312
+      			return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   313
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   314
+    	case G_IO_STATUS_EOF: 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   315
+      			fprintf (stderr, "G_IO_STATUS_EOF\n");
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   316
+      			sleep(1);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   317
+      			return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   318
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   319
+    	case G_IO_STATUS_ERROR:
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   320
+      			fprintf (stderr, "G_IO_STATUS_ERROR: %s\n", error->message);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   321
+      			return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   322
+	
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   323
+    	default: g_assert_not_reached ();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   324
+      			return FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   325
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   326
+  }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   327
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   328
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   329
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   330
+int main (int argc, char *argv[])
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   331
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   332
+  GtkWidget *window, **windows;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   333
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   334
+  GdkDisplay *gdk_dpy;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   335
+  Display *x_dpy;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   336
+  Window win;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   337
+  gchar *displayname = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   338
+  gint screen_count;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   339
+  GdkScreen **screen_list;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   340
+  gint i;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   341
+  long myid;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   342
+  GIOChannel *channel;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   343
+  guint result;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   344
+  Session *session;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   345
+  static gboolean first_startup= TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   346
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   347
+    /* redirect stdout and stderr to /dev/null */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   348
+    int fd = open ("/dev/null", O_RDWR);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   349
+    dup2 (fd, 1);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   350
+    dup2 (fd, 2);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   351
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   352
+    /* See if session management is needed */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   353
+    if ((argc > 1) && !(strcmp (argv[1], "--nosession")))
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   354
+      managesession = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   355
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   356
+    if ((argc > 1) && !(strcmp (argv[1], "--defaultsession")))
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   357
+      default_session = TRUE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   358
+
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
   359
+    gsm_keyring_daemon_start ();
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
   360
+
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   361
+    /* This is required some that the ~/.gnome2 are setup */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   362
+    if (managesession)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   363
+      gnome_program_init ("tsoljds-xagent", "0.1", LIBGNOMEUI_MODULE,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   364
+                          argc, argv,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   365
+                          NULL);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   366
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   367
+    /* Ignore all child deaths */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   368
+    signal(SIGCHLD, SIG_IGN);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   369
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   370
+	/* Get password entry to use the pw_shell entry later */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   371
+	pwent = getpwuid(getuid());
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   372
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   373
+    if ((pipe_fd = dup(fileno(stdin))) != -1) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   374
+      int dummy_fd;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   375
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   376
+        close(fileno(stdin));
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   377
+        /* Open /dev/null as stdin */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   378
+        dummy_fd = open("/dev/null", O_RDONLY);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   379
+        /* Set close_on_exec */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   380
+        fcntl(pipe_fd, F_SETFD, 1);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   381
+    } else
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   382
+   	pipe_fd = fileno(stdin);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   383
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   384
+    gtk_init (&argc, &argv); 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   385
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   386
+    /* Get GdkDisplay and number of screens */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   387
+    gdk_dpy = gdk_display_get_default ();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   388
+    x_dpy =  GDK_DISPLAY_XDISPLAY (gdk_dpy);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   389
+    screen_count =  gdk_display_get_n_screens (gdk_dpy);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   390
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   391
+    displayname = g_strdup (gdk_display_get_name (gdk_dpy));
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   392
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   393
+    if (screen_count <= 0) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   394
+      screen_count = 1; /* at least one screen */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   395
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   396
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   397
+    /* allocation memory for the number of screens */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   398
+    screen_list = g_new (GdkScreen *, screen_count);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   399
+    windows = g_new (GtkWidget *, screen_count);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   400
+    
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   401
+    for (i = 0; i < screen_count; i++) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   402
+      windows[i] = gtk_window_new (GTK_WINDOW_TOPLEVEL);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   403
+      gtk_widget_realize (windows[i]);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   404
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   405
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   406
+    /* Trap the Xserver error as this is an essential hack to make the program
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   407
+     * to start up in the local zone.
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   408
+     */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   409
+    XSetErrorHandler(TsolErrorHandler);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   410
+  
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   411
+    /* Set to Polyinstantiated properties for selection manager */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   412
+    SetUpPolyprop (x_dpy); 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   413
+  
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   414
+    if (managesession == TRUE) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   415
+    /*
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   416
+     * This script is needed to enable input method per zones and roles.
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   417
+     * start_session () is shared between gnome-session and tsoljds-xagent
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   418
+     * so putting this out of start_session () here.
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   419
+     */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   420
+      if (g_file_test (TSOLJDS_MIGRATION_SCRIPT, G_FILE_TEST_IS_EXECUTABLE)) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   421
+        system (TSOLJDS_MIGRATION_SCRIPT);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   422
+      }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   423
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   424
+      initialize_ice (); 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   425
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   426
+      if (session_name == NULL &&
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   427
+          g_getenv ("GDM_GNOME_SESSION") != NULL) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   428
+            session_name = g_strdup (g_getenv ("GDM_GNOME_SESSION"));
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   429
+      }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   430
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   431
+      /* If the session name hasn't been specified from the command line */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   432
+      if(session_name == NULL) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   433
+        /* If there is no key specified, fall back to the default session */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   434
+        session_name = gnome_config_get_string (CURRENT_SESSION_KEY "=" DEFAULT_SESSION);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   435
+        /* if key was specified but is blank, just use the default */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   436
+        if (!*session_name) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   437
+          g_free (session_name);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   438
+          session_name = g_strdup (DEFAULT_SESSION);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   439
+        }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   440
+      }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   441
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   442
+      session = read_session (session_name);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   443
+      trim_tcb (session);  
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   444
+      start_session (session); 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   445
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   446
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   447
+    if (first_startup) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   448
+      GError *err=NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   449
+	/* FIXME: need to get the screen info some how, but default to 0 for now */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   450
+	gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy, 0), g_getenv("LABEL_EXEC_COMMAND"), &err);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   451
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   452
+	if (err)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   453
+	  g_print ("error is %s\n", err->message);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   454
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   455
+ 	first_startup = FALSE;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   456
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   457
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   458
+    channel = g_io_channel_unix_new (pipe_fd);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   459
+    result = g_io_add_watch_full (channel, G_PRIORITY_HIGH, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   460
+		                  G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   461
+                                  (GIOFunc)handle_pipe_input, NULL, so_long_pipe);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   462
+    gtk_main ();
9738
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
   463
+
591746900d38 2007-04-12 Ghee Teo <[email protected]>
gheet
parents: 9397
diff changeset
   464
+    gsm_keyring_daemon_stop ();
9397
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   465
+  
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   466
+    return 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   467
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   468
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   469
+static void SetUpPolyprop (Display *x_dpy)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   470
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   471
+  /* copy motif_proxy_win from user's clearance to current label */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   472
+#define ROOT_UID        0
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   473
+  XTsolResAttributes resattr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   474
+  Atom ATOM_MOTIF_DRAG_WIN;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   475
+  Atom ATOM_MOTIF_PROXY_WIN;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   476
+  m_label_t *slabel;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   477
+  Window motif_drag_win = None;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   478
+  Window proxy_win = None;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   479
+  XWindowAttributes wattr;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   480
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   481
+    /* Set up to look up the polyprop used by the sel_mgr */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   482
+    slabel = blabel_alloc();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   483
+    bsllow(slabel);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   484
+    resattr.sl = slabel;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   485
+    resattr.uid = ROOT_UID;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   486
+    XTSOLsetPolyInstInfo(x_dpy, resattr.sl, (uid_t *)(&resattr.uid), True);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   487
+    ATOM_MOTIF_DRAG_WIN = XInternAtom(x_dpy, _XA_MOTIF_WINDOW, False);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   488
+    ATOM_MOTIF_PROXY_WIN = XInternAtom(x_dpy, _XA_MOTIF_PROXY_WINDOW, False);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   489
+    motif_drag_win = GetPropertyWindow(x_dpy, DefaultRootWindow(x_dpy),
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   490
+        			       ATOM_MOTIF_DRAG_WIN);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   491
+    if (motif_drag_win != None) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   492
+      proxy_win = GetPropertyWindow(x_dpy, motif_drag_win, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   493
+				    ATOM_MOTIF_PROXY_WIN);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   494
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   495
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   496
+    /* put back our original polyprop settings */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   497
+    getplabel(slabel);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   498
+    resattr.uid = getuid();
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   499
+    XTSOLsetPolyInstInfo(x_dpy, resattr.sl, (uid_t *)(&resattr.uid), False);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   500
+    blabel_free(slabel);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   501
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   502
+    motif_drag_win = GetPropertyWindow(x_dpy, DefaultRootWindow(x_dpy),
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   503
+                             	       ATOM_MOTIF_DRAG_WIN);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   504
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   505
+    /* Validate motif_drag_win */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   506
+    if (XGetWindowAttributes(x_dpy, motif_drag_win, &wattr) == 0) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   507
+      /* if window is invalid, create a new one */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   508
+      motif_drag_win = CreateMotifDragWindow(x_dpy);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   509
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   510
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   511
+    if (motif_drag_win != None) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   512
+      XChangeProperty(x_dpy, motif_drag_win, ATOM_MOTIF_PROXY_WIN,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   513
+                      XA_WINDOW, 32, PropModeReplace, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   514
+                      (unsigned char *) &proxy_win, 1);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   515
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   516
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   517
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   518
+Window
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   519
+GetPropertyWindow(Display *dpy, Window in_win, Atom atom)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   520
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   521
+  Atom            type;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   522
+  int             format;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   523
+  unsigned long   lengthRtn;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   524
+  unsigned long   bytesafter;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   525
+  Window         *property = NULL;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   526
+  Window          win = None;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   527
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   528
+    if ((XGetWindowProperty (dpy, in_win, atom, 0L, 1, False, AnyPropertyType,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   529
+                             &type, &format, &lengthRtn, &bytesafter,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   530
+                             (unsigned char **) &property) == Success) &&
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   531
+        (type == XA_WINDOW) && (format == 32) && (lengthRtn == 1)) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   532
+          win = *property;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   533
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   534
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   535
+    if (property) {
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   536
+        XFree ((char *)property);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   537
+    }
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   538
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   539
+    return (win);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   540
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   541
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   542
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   543
+static Window
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   544
+CreateMotifDragWindow(Display *dpy)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   545
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   546
+  XSetWindowAttributes sAttributes;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   547
+  Window               motifWindow;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   548
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   549
+    XSetCloseDownMode (dpy, RetainPermanent);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   550
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   551
+    sAttributes.override_redirect = True;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   552
+    sAttributes.event_mask = PropertyChangeMask;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   553
+    motifWindow = XCreateWindow (dpy, DefaultRootWindow (dpy), -100, -100, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   554
+				 10, 10, 0, 0, InputOnly, CopyFromParent,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   555
+                                 (CWOverrideRedirect |CWEventMask),
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   556
+                                 &sAttributes);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   557
+    XMapWindow (dpy, motifWindow);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   558
+    WriteMotifDragWindow (dpy, &motifWindow);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   559
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   560
+    return (motifWindow);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   561
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   562
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   563
+static void
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   564
+WriteMotifDragWindow(Display *dpy, Window *motifWindow)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   565
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   566
+  Atom motifWindowAtom;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   567
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   568
+    motifWindowAtom = XInternAtom (dpy, _XA_MOTIF_WINDOW, False);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   569
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   570
+    XChangeProperty (dpy, RootWindow (dpy, 0), motifWindowAtom,
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   571
+                     XA_WINDOW, 32, PropModeReplace, 
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   572
+		     (unsigned char *) motifWindow, 1);
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   573
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   574
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   575
+/*
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   576
+ * Ignore X protocol errors
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   577
+ */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   578
+int
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   579
+TsolErrorHandler(Display *dpy, XErrorEvent *error)
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   580
+{
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   581
+  char    err_msg[132];
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   582
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   583
+  /* ignore all errors */
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   584
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   585
+  XGetErrorText(dpy, error->error_code, err_msg, sizeof(err_msg));
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   586
+
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   587
+  return 0;
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   588
+}
b16e349d18c5 the easy part of the reorg (most files moved around)
laca
parents:
diff changeset
   589
+#endif