Write composition manager available file to tmp

This relates to Bug 887
pull/16/head
Timothy Pearson 10 years ago
parent 6d15450dff
commit b03b9b071f

@ -1919,21 +1919,19 @@ public:
#if defined(Q_WS_X11) && defined(COMPOSITE) #if defined(Q_WS_X11) && defined(COMPOSITE)
bool TDEApplication::isCompositionManagerAvailable() { bool TDEApplication::isCompositionManagerAvailable() {
bool have_manager = false; bool have_manager = false;
const char *home;
struct passwd *p; char *filename;
p = getpwuid(getuid()); const char *pidfile = "compton-tde.available";
if (p) char uidstr[sizeof(uid_t)*8+1];
home = p->pw_dir; sprintf(uidstr, "%d", getuid());
else int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
home = getenv("HOME"); filename = (char*)malloc(n*sizeof(char));
memset(filename,0,n);
char *filename; strcat(filename, P_tmpdir);
const char *configfile = "/.kompmgr.available"; strcat(filename, "/.");
int n = strlen(home)+strlen(configfile)+1; strcat(filename, uidstr);
filename = (char*)malloc(n*sizeof(char)); strcat(filename, "-");
memset(filename,0,n); strcat(filename, pidfile);
strcat(filename, home);
strcat(filename, configfile);
// Now that we did all that by way of introduction...read the file! // Now that we did all that by way of introduction...read the file!
FILE *pFile; FILE *pFile;
@ -1991,21 +1989,18 @@ bool TDEApplication::detectCompositionManagerAvailable(bool force_available, boo
} }
} }
const char *home; char *filename;
struct passwd *p; const char *pidfile = "compton-tde.available";
p = getpwuid(getuid()); char uidstr[sizeof(uid_t)*8+1];
if (p) sprintf(uidstr, "%d", getuid());
home = p->pw_dir; int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
else filename = (char*)malloc(n*sizeof(char));
home = getenv("HOME"); memset(filename,0,n);
strcat(filename, P_tmpdir);
char *filename; strcat(filename, "/.");
const char *configfile = "/.kompmgr.available"; strcat(filename, uidstr);
int n = strlen(home)+strlen(configfile)+1; strcat(filename, "-");
filename = (char*)malloc(n*sizeof(char)); strcat(filename, pidfile);
memset(filename,0,n);
strcat(filename, home);
strcat(filename, configfile);
/* now that we did all that by way of introduction...create or remove the file! */ /* now that we did all that by way of introduction...create or remove the file! */
if (compositing_manager_available) { if (compositing_manager_available) {
@ -2117,21 +2112,18 @@ bool TDEApplication::isCompositionManagerAvailable() {
} }
bool TDEApplication::detectCompositionManagerAvailable(bool force_available, bool available) { bool TDEApplication::detectCompositionManagerAvailable(bool force_available, bool available) {
const char *home; char *filename;
struct passwd *p; const char *pidfile = "compton-tde.available";
p = getpwuid(getuid()); char uidstr[sizeof(uid_t)*8+1];
if (p) sprintf(uidstr, "%d", getuid());
home = p->pw_dir; int n = strlen(P_tmpdir)+strlen(uidstr)+strlen(pidfile)+3;
else filename = (char*)malloc(n*sizeof(char));
home = getenv("HOME"); memset(filename,0,n);
strcat(filename, P_tmpdir);
char *filename; strcat(filename, "/.");
const char *configfile = "/.kompmgr.available"; strcat(filename, uidstr);
int n = strlen(home)+strlen(configfile)+1; strcat(filename, "-");
filename = (char*)malloc(n*sizeof(char)); strcat(filename, pidfile);
memset(filename,0,n);
strcat(filename, home);
strcat(filename, configfile);
/* now that we did all that by way of introduction...create or remove the file! */ /* now that we did all that by way of introduction...create or remove the file! */
if (force_available) { if (force_available) {

Loading…
Cancel
Save