diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-11-19 12:24:55 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-11-19 12:24:55 -0600 |
commit | b03b9b071f41eb2a0a2ec9c5a865d8e0178895fb (patch) | |
tree | 747792ba6cc28788c69079b426a659a9cb2399c6 /tdecore/tdeapplication.cpp | |
parent | 6d15450dffbf0065b47ccb4b3a09f86829760e00 (diff) | |
download | tdelibs-b03b9b071f41eb2a0a2ec9c5a865d8e0178895fb.tar.gz tdelibs-b03b9b071f41eb2a0a2ec9c5a865d8e0178895fb.zip |
Write composition manager available file to tmp
This relates to Bug 887
Diffstat (limited to 'tdecore/tdeapplication.cpp')
-rw-r--r-- | tdecore/tdeapplication.cpp | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/tdecore/tdeapplication.cpp b/tdecore/tdeapplication.cpp index c92479490..13fd76a2e 100644 --- a/tdecore/tdeapplication.cpp +++ b/tdecore/tdeapplication.cpp @@ -1919,21 +1919,19 @@ public: #if defined(Q_WS_X11) && defined(COMPOSITE) bool TDEApplication::isCompositionManagerAvailable() { bool have_manager = false; - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); + + char *filename; + const char *pidfile = "compton-tde.available"; + char uidstr[sizeof(uid_t)*8+1]; + sprintf(uidstr, "%d", getuid()); + int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3; + filename = (char*)malloc(n*sizeof(char)); + memset(filename,0,n); + strcat(filename, P_tmpdir); + strcat(filename, "/."); + strcat(filename, uidstr); + strcat(filename, "-"); + strcat(filename, pidfile); // Now that we did all that by way of introduction...read the file! FILE *pFile; @@ -1991,21 +1989,18 @@ bool TDEApplication::detectCompositionManagerAvailable(bool force_available, boo } } - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); + char *filename; + const char *pidfile = "compton-tde.available"; + char uidstr[sizeof(uid_t)*8+1]; + sprintf(uidstr, "%d", getuid()); + int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3; + filename = (char*)malloc(n*sizeof(char)); + memset(filename,0,n); + strcat(filename, P_tmpdir); + strcat(filename, "/."); + strcat(filename, uidstr); + strcat(filename, "-"); + strcat(filename, pidfile); /* now that we did all that by way of introduction...create or remove the file! */ if (compositing_manager_available) { @@ -2117,21 +2112,18 @@ bool TDEApplication::isCompositionManagerAvailable() { } bool TDEApplication::detectCompositionManagerAvailable(bool force_available, bool available) { - const char *home; - struct passwd *p; - p = getpwuid(getuid()); - if (p) - home = p->pw_dir; - else - home = getenv("HOME"); - - char *filename; - const char *configfile = "/.kompmgr.available"; - int n = strlen(home)+strlen(configfile)+1; - filename = (char*)malloc(n*sizeof(char)); - memset(filename,0,n); - strcat(filename, home); - strcat(filename, configfile); + char *filename; + const char *pidfile = "compton-tde.available"; + char uidstr[sizeof(uid_t)*8+1]; + sprintf(uidstr, "%d", getuid()); + int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3; + filename = (char*)malloc(n*sizeof(char)); + memset(filename,0,n); + strcat(filename, P_tmpdir); + strcat(filename, "/."); + strcat(filename, uidstr); + strcat(filename, "-"); + strcat(filename, pidfile); /* now that we did all that by way of introduction...create or remove the file! */ if (force_available) { |