diff options
author | Danny Baumann <dannybaumann@web.de> | 2009-03-08 13:28:20 +0100 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2009-03-08 13:28:20 +0100 |
commit | 6340ef91236e75c3e7107e6dd484031dd8c455dc (patch) | |
tree | 47f0d111df2d953fb8b7842603cc56b7c762f26c /src/session.cpp | |
parent | 9f4359ca78756858dae4507072ed838cb23a3ef8 (diff) | |
download | unity-window-decorator-6340ef91236e75c3e7107e6dd484031dd8c455dc.tar.gz unity-window-decorator-6340ef91236e75c3e7107e6dd484031dd8c455dc.tar.bz2 |
SM spec says that SmUserID is a required property.
Diffstat (limited to 'src/session.cpp')
-rw-r--r-- | src/session.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/session.cpp b/src/session.cpp index 885f0a6..a7399c2 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -35,6 +35,7 @@ #include <unistd.h> #include <fcntl.h> #include <string.h> +#include <pwd.h> #include <X11/SM/SMlib.h> #include <X11/ICE/ICElib.h> @@ -141,14 +142,17 @@ setRestartStyle (SmcConn connection, } static void -setProgram (SmcConn connection, - const char *program, - pid_t pid) +setProgramInfo (SmcConn connection, + const char *program, + pid_t pid, + uid_t uid) { - SmProp progProp, pidProp; - SmPropValue progVal, pidVal; - SmProp *props[2]; - char pidBuffer[32]; + SmProp progProp, pidProp, userProp; + SmPropValue progVal, pidVal, userVal; + SmProp *props[3]; + char pidBuffer[32]; + unsigned int count = 0; + struct passwd *pw; progProp.name = const_cast<char *> (SmProgram); progProp.type = const_cast<char *> (SmARRAY8); @@ -157,6 +161,8 @@ setProgram (SmcConn connection, progVal.value = (SmPointer) program; progVal.length = strlen (program); + props[count++] = &progProp; + snprintf (pidBuffer, sizeof (pidBuffer), "%d", pid); pidProp.name = const_cast<char *> (SmProcessID); @@ -166,10 +172,22 @@ setProgram (SmcConn connection, pidVal.value = (SmPointer) pidBuffer; pidVal.length = strlen (pidBuffer); - props[0] = &progProp; - props[1] = &pidProp; + props[count++] = &pidProp; + + pw = getpwuid (uid); + if (pw) + { + userProp.name = const_cast<char *> (SmUserID); + userProp.type = const_cast<char *> (SmARRAY8); + userProp.num_vals = 1; + userProp.vals = &userVal; + userVal.value = (SmPointer) pw->pw_name; + userVal.length = strlen (pw->pw_name); + + props[count++] = &userProp; + } - SmcSetProperties (connection, 2, props); + SmcSetProperties (connection, count, props); } static void @@ -196,7 +214,7 @@ saveYourselfCallback (SmcConn connection, setCloneRestartCommands (connection); setRestartStyle (connection, SmRestartImmediately); - setProgram (connection, programName, getpid ()); + setProgramInfo (connection, programName, getpid (), getuid ()); SmcSaveYourselfDone (connection, 1); } |