1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

fix stale static process pointer in top.c and add nodename to X window

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@402 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
David Carter 2005-11-12 03:41:55 +00:00
parent 012457e9b2
commit 50866b5efe
5 changed files with 25 additions and 16 deletions

View File

@ -206,6 +206,7 @@ void update_stuff()
update_mail_count();
#if defined(__linux__)
if (NEED(INFO_I8K))
update_i8k();

View File

@ -1073,13 +1073,13 @@ static void free_text_objects()
break;
case OBJ_top:
if (info.first_process) {
free_all_processes(info.first_process);
free_all_processes();
info.first_process = NULL;
}
break;
case OBJ_top_mem:
if (info.first_process) {
free_all_processes(info.first_process);
free_all_processes();
info.first_process = NULL;
}
break;
@ -5178,13 +5178,13 @@ int main(int argc, char **argv)
wm_class_name,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
on_bottom, fixed_pos, set_transparent, background_colour);
on_bottom, fixed_pos, set_transparent, background_colour, info.uname_s.nodename);
#else
init_window
(own_window,
text_width + border_margin * 2 + 1,
text_height + border_margin * 2 + 1,
on_bottom, set_transparent, background_colour);
on_bottom, set_transparent, background_colour, info.uname_s.nodename);
#endif

View File

@ -269,9 +269,9 @@ extern struct conky_window window;
void init_X11();
#if defined OWN_WINDOW
void init_window(int use_own_window, char* wm_class_name, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour);
void init_window(int use_own_window, char* wm_class_name, int width, int height, int on_bottom, int fixed_pos, int set_trans, int back_colour, char * nodename);
#else
void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour);
void init_window(int use_own_window, int width, int height, int on_bottom, int set_trans, int back_colour, char * nodename);
#endif
void create_gc();
void set_transparent_background(Window win);

View File

@ -20,9 +20,9 @@ struct process *get_first_process()
void free_all_processes(struct process *pr)
void free_all_processes()
{
struct process *next = NULL;
struct process *next = NULL, *pr = first_process;
while (pr) {
next = pr->next;
if (pr->name) {
@ -31,6 +31,7 @@ void free_all_processes(struct process *pr)
free(pr);
pr = next;
}
first_process = NULL;
}
static struct process *find_process(pid_t pid)
@ -398,14 +399,14 @@ inline static void calc_cpu_each(unsigned long total)
/* Find the top processes */
/******************************************/
// static int tot_struct; //for debugging..uncomment this and the 2 printfs in the next two functs
//static int tot_struct; //for debugging..uncomment this and the 2 printfs in the next two functs
/*
* free a sp_process structure
*/
void free_sp(struct sorted_process * sp) {
free(sp);
//printf("free: %d structs\n",--tot_struct );
// printf("free: %d structs\n",--tot_struct );
}
/*
@ -417,7 +418,7 @@ struct sorted_process * malloc_sp(struct process * proc) {
sp->greater = NULL;
sp->less = NULL;
sp->proc = proc;
//printf("malloc: %d structs\n", ++tot_struct);
// printf("malloc: %d structs\n", ++tot_struct);
return(sp);
}

View File

@ -17,6 +17,8 @@
#include <X11/Xft/Xft.h>
#endif
#include <stdio.h>
#ifdef XDBE
int use_xdbe;
#endif
@ -25,6 +27,8 @@ int use_xdbe;
int use_xft = 0;
#endif
#define WINDOW_NAME_FMT "%s - conky"
/* some basic X11 stuff */
Display *display;
int display_width;
@ -171,9 +175,9 @@ inline void set_transparent_background(Window win)
}
#if defined OWN_WINDOW
void init_window(int own_window, char* wm_class_name, int w, int h, int l, int fixed_pos, int set_trans, int back_colour)
void init_window(int own_window, char* wm_class_name, int w, int h, int l, int fixed_pos, int set_trans, int back_colour, char * nodename)
#else
void init_window(int own_window, int w, int h, int l, int set_trans, int back_colour)
void init_window(int own_window, int w, int h, int l, int set_trans, int back_colour, char * nodename)
#endif
{
/* There seems to be some problems with setting transparent background (on
@ -181,6 +185,8 @@ void init_window(int own_window, int w, int h, int l, int set_trans, int back_co
* happens but I bet the bug is somewhere here. */
set_transparent = set_trans;
background_colour = back_colour;
char * window_name = NULL;
int num_chars = 0;
#ifdef OWN_WINDOW
if (own_window) {
@ -213,9 +219,10 @@ void init_window(int own_window, int w, int h, int l, int set_trans, int back_co
&class_hints);
/*set_transparent_background(window.window);*/
XStoreName(display, window.window, "conky");
window_name = (char *) malloc(strlen(WINDOW_NAME_FMT) + strlen(nodename)+1);
sprintf(window_name, WINDOW_NAME_FMT, nodename);
XStoreName(display, window.window, window_name);
free(window_name);
XClearWindow(display, window.window);
if (!fixed_pos)