moved initial values in function default_xxx

git-svn-id: http://tint2.googlecode.com/svn/trunk@423 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
thilor77
2010-04-18 12:07:36 +00:00
parent a94d75d393
commit c298a39d00
21 changed files with 243 additions and 225 deletions

View File

@@ -33,23 +33,23 @@
#include "clock.h" #include "clock.h"
#include "timer.h" #include "timer.h"
PangoFontDescription *bat1_font_desc=0; PangoFontDescription *bat1_font_desc;
PangoFontDescription *bat2_font_desc=0; PangoFontDescription *bat2_font_desc;
struct batstate battery_state; struct batstate battery_state;
int battery_enabled; int battery_enabled;
int percentage_hide; int percentage_hide;
static timeout* battery_timeout=0; static timeout* battery_timeout;
static char buf_bat_percentage[10]; static char buf_bat_percentage[10];
static char buf_bat_time[20]; static char buf_bat_time[20];
int8_t battery_low_status; int8_t battery_low_status;
unsigned char battery_low_cmd_send; unsigned char battery_low_cmd_send;
char *battery_low_cmd=0; char *battery_low_cmd;
char *path_energy_now=0; char *path_energy_now;
char *path_energy_full=0; char *path_energy_full;
char *path_current_now=0; char *path_current_now;
char *path_status=0; char *path_status;
void update_batterys(void* arg) void update_batterys(void* arg)
{ {
@@ -77,6 +77,32 @@ void update_batterys(void* arg)
} }
} }
void default_battery()
{
battery_enabled = 0;
percentage_hide = 101;
battery_low_cmd_send = 0;
battery_timeout = 0;
bat1_font_desc = 0;
bat2_font_desc = 0;
battery_low_cmd = 0;
path_energy_now = 0;
path_energy_full = 0;
path_current_now = 0;
path_status = 0;
}
void cleanup_battery()
{
if (bat1_font_desc) pango_font_description_free(bat1_font_desc);
if (bat2_font_desc) pango_font_description_free(bat2_font_desc);
if (path_energy_now) g_free(path_energy_now);
if (path_energy_full) g_free(path_energy_full);
if (path_current_now) g_free(path_current_now);
if (path_status) g_free(path_status);
if (battery_low_cmd) g_free(battery_low_cmd);
}
void init_battery() void init_battery()
{ {
@@ -156,43 +182,6 @@ void init_battery()
} }
void cleanup_battery()
{
battery_enabled = 0;
percentage_hide = 101;
battery_low_cmd_send = 0;
if (bat1_font_desc) {
pango_font_description_free(bat1_font_desc);
bat1_font_desc = 0;
}
if (bat2_font_desc) {
pango_font_description_free(bat2_font_desc);
bat2_font_desc = 0;
}
if (path_energy_now) {
g_free(path_energy_now);
path_energy_now = 0;
}
if (path_energy_full) {
g_free(path_energy_full);
path_energy_full = 0;
}
if (path_current_now) {
g_free(path_current_now);
path_current_now = 0;
}
if (path_status) {
g_free(path_status);
path_status = 0;
}
if (battery_low_cmd) {
g_free(battery_low_cmd);
battery_low_cmd = 0;
}
}
void init_battery_panel(void *p) void init_battery_panel(void *p)
{ {
Panel *panel = (Panel*)p; Panel *panel = (Panel*)p;

View File

@@ -57,6 +57,10 @@ extern int8_t battery_low_status;
extern char *battery_low_cmd; extern char *battery_low_cmd;
extern char *path_energy_now, *path_energy_full, *path_current_now, *path_status; extern char *path_energy_now, *path_energy_full, *path_current_now, *path_status;
// default values
void default_battery();
// freed memory
void cleanup_battery();
// initialize clock : y position, ... // initialize clock : y position, ...
void update_battery(); void update_battery();
@@ -64,9 +68,6 @@ void update_battery();
void init_battery(); void init_battery();
void init_battery_panel(void *panel); void init_battery_panel(void *panel);
// freed memory and set default values
void cleanup_battery();
void draw_battery(void *obj, cairo_t *c); void draw_battery(void *obj, cairo_t *c);
void resize_battery(void *obj); void resize_battery(void *obj);

View File

@@ -35,22 +35,53 @@
#include "timer.h" #include "timer.h"
char *time1_format=0; char *time1_format;
char *time1_timezone=0; char *time1_timezone;
char *time2_format=0; char *time2_format;
char *time2_timezone=0; char *time2_timezone;
char *time_tooltip_format=0; char *time_tooltip_format;
char *time_tooltip_timezone=0; char *time_tooltip_timezone;
char *clock_lclick_command=0; char *clock_lclick_command;
char *clock_rclick_command=0; char *clock_rclick_command;
struct timeval time_clock; struct timeval time_clock;
PangoFontDescription *time1_font_desc=0; PangoFontDescription *time1_font_desc;
PangoFontDescription *time2_font_desc=0; PangoFontDescription *time2_font_desc;
static char buf_time[40]; static char buf_time[40];
static char buf_date[40]; static char buf_date[40];
static char buf_tooltip[40]; static char buf_tooltip[40];
int clock_enabled; int clock_enabled;
static timeout* clock_timeout=0; static timeout* clock_timeout;
void default_clock()
{
clock_enabled = 0;
clock_timeout = 0;
time1_format = 0;
time1_timezone = 0;
time2_format = 0;
time2_timezone = 0;
time_tooltip_format = 0;
time_tooltip_timezone = 0;
clock_lclick_command = 0;
clock_rclick_command = 0;
time1_font_desc = 0;
time2_font_desc = 0;
}
void cleanup_clock()
{
if (time1_font_desc) pango_font_description_free(time1_font_desc);
if (time2_font_desc) pango_font_description_free(time2_font_desc);
if (time1_format) g_free(time1_format);
if (time2_format) g_free(time2_format);
if (time_tooltip_format) g_free(time_tooltip_format);
if (time1_timezone) g_free(time1_timezone);
if (time2_timezone) g_free(time2_timezone);
if (time_tooltip_timezone) g_free(time_tooltip_timezone);
if (clock_lclick_command) g_free(clock_lclick_command);
if (clock_rclick_command) g_free(clock_rclick_command);
}
void update_clocks_sec(void* arg) void update_clocks_sec(void* arg)
@@ -160,52 +191,6 @@ void init_clock_panel(void *p)
} }
void cleanup_clock()
{
clock_enabled = 0;
if (time1_font_desc) {
pango_font_description_free(time1_font_desc);
time1_font_desc = 0;
}
if (time2_font_desc) {
pango_font_description_free(time2_font_desc);
time2_font_desc = 0;
}
if (time1_format) {
g_free(time1_format);
time1_format = 0;
}
if (time2_format) {
g_free(time2_format);
time2_format = 0;
}
if (time_tooltip_format) {
g_free(time_tooltip_format);
time_tooltip_format = 0;
}
if (time1_timezone) {
g_free(time1_timezone);
time1_timezone = 0;
}
if (time2_timezone) {
g_free(time2_timezone);
time2_timezone = 0;
}
if (time_tooltip_timezone) {
g_free(time_tooltip_timezone);
time_tooltip_timezone = 0;
}
if (clock_lclick_command) {
g_free(clock_lclick_command);
clock_lclick_command = 0;
}
if (clock_rclick_command) {
g_free(clock_rclick_command);
clock_rclick_command = 0;
}
}
void draw_clock (void *obj, cairo_t *c) void draw_clock (void *obj, cairo_t *c)
{ {
Clock *clock = obj; Clock *clock = obj;

View File

@@ -37,13 +37,15 @@ extern char *clock_rclick_command;
extern int clock_enabled; extern int clock_enabled;
// default values
void default_clock();
// freed memory
void cleanup_clock();
// initialize clock : y position, precision, ... // initialize clock : y position, precision, ...
void init_clock(); void init_clock();
void init_clock_panel(void *panel); void init_clock_panel(void *panel);
// freed memory and set default values
void cleanup_clock();
void draw_clock (void *obj, cairo_t *c); void draw_clock (void *obj, cairo_t *c);
void resize_clock (void *obj); void resize_clock (void *obj);

View File

@@ -52,8 +52,8 @@
#endif #endif
// global path // global path
char *config_path = 0; char *config_path;
char *snapshot_path = 0; char *snapshot_path;
// -------------------------------------------------- // --------------------------------------------------
// backward compatibility // backward compatibility
@@ -63,6 +63,20 @@ static int old_task_icon_size;
static int old_config_file; static int old_config_file;
void default_config()
{
config_path = 0;
snapshot_path = 0;
old_config_file = 1;
}
void cleanup_config()
{
if (config_path) g_free(config_path);
if (snapshot_path) g_free(snapshot_path);
}
void init_config() void init_config()
{ {
if (backgrounds) if (backgrounds)
@@ -88,9 +102,6 @@ printf("*** init_config()\n");
pango_font_description_free(panel_config.g_task.font_desc); pango_font_description_free(panel_config.g_task.font_desc);
} }
memset(&panel_config, 0, sizeof(Panel)); memset(&panel_config, 0, sizeof(Panel));
systray.alpha = 100;
systray.sort = 3;
old_config_file = 1;
// window manager's menu default value == false // window manager's menu default value == false
wm_menu = 0; wm_menu = 0;
@@ -103,11 +114,6 @@ printf("*** init_config()\n");
} }
void cleanup_config()
{
}
void extract_values (const char *value, char **value1, char **value2, char **value3) void extract_values (const char *value, char **value1, char **value2, char **value3)
{ {
char *b=0, *c=0; char *b=0, *c=0;

View File

@@ -12,8 +12,12 @@
extern char *config_path; extern char *config_path;
extern char *snapshot_path; extern char *snapshot_path;
void init_config(); // default values
void default_config();
// freed memory
void cleanup_config(); void cleanup_config();
void init_config();
int config_read_file (const char *path); int config_read_file (const char *path);
int config_read (); int config_read ();

View File

@@ -288,6 +288,7 @@ void cleanup_panel()
{ {
if (!panel1) return; if (!panel1) return;
printf("*** cleanup_panel()\n");
task_active = 0; task_active = 0;
task_drag = 0; task_drag = 0;
@@ -568,7 +569,7 @@ void set_panel_background(Panel *p)
else if (!panel_horizontal && panel_position & RIGHT) else if (!panel_horizontal && panel_position & RIGHT)
xoff = p->area.width-p->hidden_width; xoff = p->area.width-p->hidden_width;
if (real_transparency) { if (server.real_transparency) {
clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height); clear_pixmap(p->area.pix, 0, 0, p->area.width, p->area.height);
} }
else { else {

View File

@@ -33,8 +33,6 @@
void server_catch_error (Display *d, XErrorEvent *ev){} void server_catch_error (Display *d, XErrorEvent *ev){}
int real_transparency = 0;
void server_init_atoms () void server_init_atoms ()
{ {
server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False); server.atom._XROOTPMAP_ID = XInternAtom (server.dsp, "_XROOTPMAP_ID", False);
@@ -96,10 +94,6 @@ void server_init_atoms ()
server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False); server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False);
server.atom.XdndPosition = XInternAtom(server.dsp, "XdndPosition", False); server.atom.XdndPosition = XInternAtom(server.dsp, "XdndPosition", False);
server.atom.XdndStatus = XInternAtom(server.dsp, "XdndStatus", False); server.atom.XdndStatus = XInternAtom(server.dsp, "XdndStatus", False);
server.colormap = 0;
server.monitor = 0;
server.gc = 0;
} }
@@ -391,7 +385,7 @@ void server_init_visual()
attrs.event_mask = StructureNotifyMask; attrs.event_mask = StructureNotifyMask;
XChangeWindowAttributes (server.dsp, server.composite_manager, CWEventMask, &attrs); XChangeWindowAttributes (server.dsp, server.composite_manager, CWEventMask, &attrs);
real_transparency = 1; server.real_transparency = 1;
server.depth = 32; server.depth = 32;
printf("real transparency on... depth: %d\n", server.depth); printf("real transparency on... depth: %d\n", server.depth);
server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone); server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone);
@@ -399,7 +393,7 @@ void server_init_visual()
} }
else { else {
// no composite manager or snapshot mode => fake transparency // no composite manager or snapshot mode => fake transparency
real_transparency = 0; server.real_transparency = 0;
server.depth = DefaultDepth(server.dsp, server.screen); server.depth = DefaultDepth(server.dsp, server.screen);
printf("real transparency off.... depth: %d\n", server.depth); printf("real transparency off.... depth: %d\n", server.depth);
server.colormap = DefaultColormap(server.dsp, server.screen); server.colormap = DefaultColormap(server.dsp, server.screen);

View File

@@ -13,7 +13,7 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xinerama.h>
extern int real_transparency;
typedef struct Global_atom typedef struct Global_atom
{ {
Atom _XROOTPMAP_ID; Atom _XROOTPMAP_ID;
@@ -87,6 +87,7 @@ typedef struct
Display *dsp; Display *dsp;
Window root_win; Window root_win;
Window composite_manager; Window composite_manager;
int real_transparency;
// current desktop // current desktop
int desktop; int desktop;
int screen; int screen;
@@ -110,6 +111,9 @@ typedef struct
Server_global server; Server_global server;
// freed memory
void cleanup_server();
void send_event32 (Window win, Atom at, long data1, long data2, long data3); void send_event32 (Window win, Atom at, long data1, long data2, long data3);
int get_property32 (Window win, Atom at, Atom type); int get_property32 (Window win, Atom at, Atom type);
void *server_get_property (Window win, Atom at, Atom type, int *num_results); void *server_get_property (Window win, Atom at, Atom type, int *num_results);
@@ -117,7 +121,6 @@ Atom server_get_atom (char *atom_name);
void server_catch_error (Display *d, XErrorEvent *ev); void server_catch_error (Display *d, XErrorEvent *ev);
void server_init_atoms (); void server_init_atoms ();
void server_init_visual(); void server_init_visual();
void cleanup_server();
// detect root background // detect root background
void get_root_pixmap(); void get_root_pixmap();

View File

@@ -51,9 +51,32 @@ int systray_enabled;
int systray_max_icon_size; int systray_max_icon_size;
// background pixmap if we render ourselves the icons // background pixmap if we render ourselves the icons
static Pixmap render_background = 0; static Pixmap render_background;
void default_systray()
{
printf("*** default_systray()\n");
memset(&systray, 0, sizeof(Systraybar));
render_background = 0;
systray.alpha = 100;
systray.sort = 3;
systray.area._draw_foreground = draw_systray;
systray.area._resize = resize_systray;
}
void cleanup_systray()
{
systray_enabled = 0;
systray_max_icon_size = 0;
systray.area.on_screen = 0;
free_area(&systray.area);
if (render_background) {
XFreePixmap(server.dsp, render_background);
render_background = 0;
}
}
void init_systray() void init_systray()
{ {
start_net(); start_net();
@@ -66,8 +89,6 @@ void init_systray()
systray.alpha = 100; systray.alpha = 100;
systray.brightness = systray.saturation = 0; systray.brightness = systray.saturation = 0;
} }
systray.area._draw_foreground = draw_systray;
systray.area._resize = resize_systray;
systray.area.resize = 1; systray.area.resize = 1;
systray.area.redraw = 1; systray.area.redraw = 1;
systray.area.on_screen = 1; systray.area.on_screen = 1;
@@ -92,22 +113,9 @@ void init_systray_panel(void *p)
} }
void cleanup_systray()
{
systray_enabled = 0;
systray_max_icon_size = 0;
systray.area.on_screen = 0;
free_area(&systray.area);
if (render_background) {
XFreePixmap(server.dsp, render_background);
render_background = 0;
}
}
void draw_systray(void *obj, cairo_t *c) void draw_systray(void *obj, cairo_t *c)
{ {
if (real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
if (render_background) XFreePixmap(server.dsp, render_background); if (render_background) XFreePixmap(server.dsp, render_background);
render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth); render_background = XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0); XCopyArea(server.dsp, systray.area.pix, render_background, server.gc, 0, 0, systray.area.width, systray.area.height, 0, 0);
@@ -446,7 +454,7 @@ gboolean add_icon(Window id)
// watch for the icon trying to resize itself! // watch for the icon trying to resize itself!
XSelectInput(server.dsp, traywin->tray_id, StructureNotifyMask); XSelectInput(server.dsp, traywin->tray_id, StructureNotifyMask);
if (real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles); traywin->damage = XDamageCreate(server.dsp, traywin->id, XDamageReportRawRectangles);
XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual); XCompositeRedirectWindow(server.dsp, traywin->id, CompositeRedirectManual);
} }
@@ -550,7 +558,7 @@ void systray_render_icon_now(void* t)
return; return;
} }
Picture pict_image; Picture pict_image;
if (real_transparency) if (server.real_transparency)
pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0); pict_image = XRenderCreatePicture(server.dsp, traywin->id, f, 0, 0);
else else
pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0); pict_image = XRenderCreatePicture(server.dsp, traywin->tray_id, f, 0, 0);
@@ -592,7 +600,7 @@ void systray_render_icon_now(void* t)
void systray_render_icon(TrayWindow* traywin) void systray_render_icon(TrayWindow* traywin)
{ {
if (real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) { if (server.real_transparency || systray.alpha != 100 || systray.brightness != 0 || systray.saturation != 0) {
// wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms // wine tray icons update whenever mouse is over them, so we limit the updates to 50 ms
if (traywin->render_timeout == 0) if (traywin->render_timeout == 0)
traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin); traywin->render_timeout = add_timeout(50, 0, systray_render_icon_now, traywin);

View File

@@ -52,13 +52,15 @@ extern int refresh_systray;
extern int systray_enabled; extern int systray_enabled;
extern int systray_max_icon_size; extern int systray_max_icon_size;
void init_systray(); // default values
void default_systray();
void init_systray_panel(void *p); // freed memory
// freed memory and set default values
void cleanup_systray(); void cleanup_systray();
// initialize protocol and panel position
void init_systray();
void init_systray_panel(void *p);
void draw_systray(void *obj, cairo_t *c); void draw_systray(void *obj, cairo_t *c);
void resize_systray(void *obj); void resize_systray(void *obj);

View File

@@ -35,8 +35,8 @@
#include "tooltip.h" #include "tooltip.h"
#include "timer.h" #include "timer.h"
static timeout* urgent_timeout = 0; timeout* urgent_timeout;
static GSList* urgent_list = 0; GSList* urgent_list;
const char* task_get_tooltip(void* obj) const char* task_get_tooltip(void* obj)
{ {
@@ -325,7 +325,7 @@ void draw_task_icon (Task *tsk, int text_width)
// Render // Render
imlib_context_set_image (tsk->icon[tsk->current_state]); imlib_context_set_image (tsk->icon[tsk->current_state]);
if (real_transparency) { if (server.real_transparency) {
render_image(tsk->area.pix, pos_x, panel->g_task.icon_posy, imlib_image_get_width(), imlib_image_get_height() ); render_image(tsk->area.pix, pos_x, panel->g_task.icon_posy, imlib_image_get_width(), imlib_image_get_height() );
} }
else { else {

View File

@@ -11,9 +11,12 @@
#include <pango/pangocairo.h> #include <pango/pangocairo.h>
#include <Imlib2.h> #include <Imlib2.h>
#include "common.h" #include "common.h"
#include "timer.h"
enum { TASK_NORMAL, TASK_ACTIVE, TASK_ICONIFIED, TASK_URGENT, TASK_STATE_COUNT }; enum { TASK_NORMAL, TASK_ACTIVE, TASK_ICONIFIED, TASK_URGENT, TASK_STATE_COUNT };
extern timeout* urgent_timeout;
extern GSList* urgent_list;
// -------------------------------------------------- // --------------------------------------------------
// global task parameter // global task parameter

View File

@@ -37,7 +37,7 @@
element. However for omnipresent windows (windows which are visible in every taskbar) the array element. However for omnipresent windows (windows which are visible in every taskbar) the array
contains to every Task* on each panel a pointer (i.e. GPtrArray.len == server.nb_desktop) contains to every Task* on each panel a pointer (i.e. GPtrArray.len == server.nb_desktop)
*/ */
GHashTable* win_to_task_table = 0; GHashTable* win_to_task_table;
guint win_hash(gconstpointer key) { return (guint)*((Window*)key); } guint win_hash(gconstpointer key) { return (guint)*((Window*)key); }
gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); } gboolean win_compare(gconstpointer a, gconstpointer b) { return (*((Window*)a) == *((Window*)b)); }
@@ -171,6 +171,13 @@ void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
remove_task(task_get_task(*(Window*)key)); remove_task(task_get_task(*(Window*)key));
} }
void default_taskbar()
{
win_to_task_table = 0;
urgent_timeout = 0;
urgent_list = 0;
}
void cleanup_taskbar() void cleanup_taskbar()
{ {
Panel *panel; Panel *panel;

View File

@@ -33,11 +33,14 @@ typedef struct {
int use_active; int use_active;
} Global_taskbar; } Global_taskbar;
void init_taskbar();
// freed memory and set default values // default values
void default_taskbar();
// freed memory
void cleanup_taskbar(); void cleanup_taskbar();
void init_taskbar();
Task *task_get_task (Window win); Task *task_get_task (Window win);
GPtrArray* task_get_tasks(Window win); GPtrArray* task_get_tasks(Window win);
void task_refresh_tasklist (); void task_refresh_tasklist ();

View File

@@ -42,6 +42,7 @@
#include "tooltip.h" #include "tooltip.h"
#include "timer.h" #include "timer.h"
void signal_handler(int sig) void signal_handler(int sig)
{ {
// signal handler is light as it should be // signal handler is light as it should be
@@ -53,6 +54,16 @@ void init (int argc, char *argv[])
{ {
int i; int i;
// set global data
default_timeout();
default_systray();
memset(&server, 0, sizeof(Server_global));
default_battery();
default_clock();
default_taskbar();
default_tooltip();
default_config();
// read options // read options
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -91,10 +102,6 @@ void init (int argc, char *argv[])
// sigaddset(&block_mask, SIGHUP); // sigaddset(&block_mask, SIGHUP);
// sigaddset(&block_mask, SIGUSR1); // sigaddset(&block_mask, SIGUSR1);
// sigprocmask(SIG_BLOCK, &block_mask, 0); // sigprocmask(SIG_BLOCK, &block_mask, 0);
// set global data
memset(&server, 0, sizeof(Server_global));
memset(&systray, 0, sizeof(Systraybar));
} }
void init_X11() void init_X11()
@@ -140,7 +147,8 @@ void init_X11()
void cleanup() void cleanup()
{ {
stop_all_timeouts(); printf("*** cleanup()\n");
cleanup_timeout();
cleanup_systray(); cleanup_systray();
stop_net(); stop_net();
cleanup_panel(); cleanup_panel();
@@ -149,13 +157,12 @@ void cleanup()
#ifdef ENABLE_BATTERY #ifdef ENABLE_BATTERY
cleanup_battery(); cleanup_battery();
#endif #endif
cleanup_config();
if (default_icon) { if (default_icon) {
imlib_context_set_image(default_icon); imlib_context_set_image(default_icon);
imlib_free_image(); imlib_free_image();
} }
if (config_path) g_free(config_path);
if (snapshot_path) g_free(snapshot_path);
cleanup_server(); cleanup_server();
if (server.dsp) XCloseDisplay(server.dsp); if (server.dsp) XCloseDisplay(server.dsp);

View File

@@ -34,23 +34,29 @@ void start_show_timeout();
void start_hide_timeout(); void start_hide_timeout();
void stop_tooltip_timeout(); void stop_tooltip_timeout();
// give the tooltip some reasonable default values Tooltip g_tooltip;
Tooltip g_tooltip = {
.tooltip_text = 0,
.area = 0, void default_tooltip()
.panel = 0, {
.window = 0, // give the tooltip some reasonable default values
.show_timeout_msec = 0, memset(&g_tooltip, 0, sizeof(Tooltip));
.hide_timeout_msec = 0,
.enabled = False, g_tooltip.font_color.color[0] = 1;
.mapped = False, g_tooltip.font_color.color[1] = 1;
.paddingx = 0, g_tooltip.font_color.color[2] = 1;
.paddingy = 0, g_tooltip.font_color.alpha = 1;
.font_color = { .color={1, 1, 1}, .alpha=1 }, }
.bg = 0,
.font_desc = 0, void cleanup_tooltip()
.timeout = 0 {
}; stop_tooltip_timeout();
tooltip_hide(0);
tooltip_copy_text(0);
if (g_tooltip.window) XDestroyWindow(server.dsp, g_tooltip.window);
if (g_tooltip.font_desc) pango_font_description_free(g_tooltip.font_desc);
}
void init_tooltip() void init_tooltip()
{ {
@@ -69,23 +75,6 @@ void init_tooltip()
} }
void cleanup_tooltip()
{
stop_tooltip_timeout();
tooltip_hide(0);
g_tooltip.enabled = False;
tooltip_copy_text(0);
if (g_tooltip.window) {
XDestroyWindow(server.dsp, g_tooltip.window);
g_tooltip.window = 0;
}
if (g_tooltip.font_desc) {
pango_font_description_free(g_tooltip.font_desc);
g_tooltip.font_desc = 0;
}
}
void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root) void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root)
{ {
x = x_root; x = x_root;
@@ -215,7 +204,7 @@ void tooltip_update()
c = cairo_create(cs); c = cairo_create(cs);
Color bc = g_tooltip.bg->back; Color bc = g_tooltip.bg->back;
Border b = g_tooltip.bg->border; Border b = g_tooltip.bg->border;
if (real_transparency) { if (server.real_transparency) {
clear_pixmap(g_tooltip.window, 0, 0, width, height); clear_pixmap(g_tooltip.window, 0, 0, width, height);
draw_rect(c, b.width, b.width, width-2*b.width, height-2*b.width, b.rounded-b.width/1.571); draw_rect(c, b.width, b.width, width-2*b.width, height-2*b.width, b.rounded-b.width/1.571);
cairo_set_source_rgba(c, bc.color[0], bc.color[1], bc.color[2], bc.alpha); cairo_set_source_rgba(c, bc.color[0], bc.color[1], bc.color[2], bc.alpha);
@@ -226,8 +215,10 @@ void tooltip_update()
} }
cairo_fill(c); cairo_fill(c);
cairo_set_line_width(c, b.width); cairo_set_line_width(c, b.width);
if (real_transparency) draw_rect(c, b.width/2.0, b.width/2.0, width - b.width, height - b.width, b.rounded); if (server.real_transparency)
else cairo_rectangle(c, b.width/2.0, b.width/2.0, width-b.width, height-b.width); draw_rect(c, b.width/2.0, b.width/2.0, width - b.width, height - b.width, b.rounded);
else
cairo_rectangle(c, b.width/2.0, b.width/2.0, width-b.width, height-b.width);
cairo_set_source_rgba(c, b.color[0], b.color[1], b.color[2], b.alpha); cairo_set_source_rgba(c, b.color[0], b.color[1], b.color[2], b.alpha);
cairo_stroke(c); cairo_stroke(c);

View File

@@ -42,8 +42,13 @@ typedef struct {
extern Tooltip g_tooltip; extern Tooltip g_tooltip;
void init_tooltip();
// default values
void default_tooltip();
// freed memory
void cleanup_tooltip(); void cleanup_tooltip();
void init_tooltip();
void tooltip_trigger_show(Area* area, Panel* p, int x, int y); void tooltip_trigger_show(Area* area, Panel* p, int x, int y);
void tooltip_show(void* /*arg*/); void tooltip_show(void* /*arg*/);
void tooltip_update(); void tooltip_update();

View File

@@ -101,7 +101,7 @@ void draw (Area *a)
a->pix = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth); a->pix = XCreatePixmap (server.dsp, server.root_win, a->width, a->height, server.depth);
// add layer of root pixmap (or clear pixmap if real_transparency==true) // add layer of root pixmap (or clear pixmap if real_transparency==true)
if (real_transparency) if (server.real_transparency)
clear_pixmap(a->pix, 0 ,0, a->width, a->height); clear_pixmap(a->pix, 0 ,0, a->width, a->height);
XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0); XCopyArea (server.dsp, ((Panel *)a->panel)->temp_pmap, a->pix, server.gc, a->posx, a->posy, a->width, a->height, 0, 0);

View File

@@ -22,8 +22,9 @@
#include "timer.h" #include "timer.h"
GSList* timeout_list = 0; GSList* timeout_list;
struct timeval next_timeout; struct timeval next_timeout;
GHashTable* multi_timeouts;
// functions and structs for multi timeouts // functions and structs for multi timeouts
@@ -45,6 +46,24 @@ struct _timeout {
multi_timeout* multi_timeout; multi_timeout* multi_timeout;
}; };
void default_timeout()
{
timeout_list = 0;
multi_timeouts = 0;
}
void cleanup_timeout()
{
while (timeout_list) {
timeout* t = timeout_list->data;
if (t->multi_timeout)
stop_multi_timeout(t);
free(t);
timeout_list = g_slist_remove(timeout_list, t);
}
}
void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(void*), void* arg, timeout* t); void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(void*), void* arg, timeout* t);
gint compare_timeouts(gconstpointer t1, gconstpointer t2); gint compare_timeouts(gconstpointer t1, gconstpointer t2);
gint compare_timespecs(const struct timespec* t1, const struct timespec* t2); gint compare_timespecs(const struct timespec* t1, const struct timespec* t2);
@@ -61,8 +80,6 @@ void callback_multi_timeout(void* mth);
void remove_from_multi_timeout(timeout* t); void remove_from_multi_timeout(timeout* t);
void stop_multi_timeout(timeout* t); void stop_multi_timeout(timeout* t);
GHashTable* multi_timeouts = 0;
/** Implementation notes for timeouts: The timeouts are kept in a GSList sorted by their /** Implementation notes for timeouts: The timeouts are kept in a GSList sorted by their
* expiration time. * expiration time.
* That means that update_next_timeout() only have to consider the first timeout in the list, * That means that update_next_timeout() only have to consider the first timeout in the list,
@@ -156,18 +173,6 @@ void stop_timeout(timeout* t)
} }
void stop_all_timeouts()
{
while (timeout_list) {
timeout* t = timeout_list->data;
if (t->multi_timeout)
stop_multi_timeout(t);
free(t);
timeout_list = g_slist_remove(timeout_list, t);
}
}
void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(), void* arg, timeout *t) void add_timeout_intern(int value_msec, int interval_msec, void(*_callback)(), void* arg, timeout *t)
{ {
t->interval_msec = interval_msec; t->interval_msec = interval_msec;

View File

@@ -36,6 +36,11 @@ typedef struct _timeout timeout;
* integral multiple of the other. * integral multiple of the other.
**/ **/
/** default values **/
void default_timeout();
/** freed memory : stops all timeouts **/
void cleanup_timeout();
/** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with /** installs a timeout with the first timeout of 'value_msec' and then a periodic timeout with
* 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout. * 'interval_msec'. '_callback' is the callback function when the timer reaches the timeout.
* returns a pointer to the timeout, which is needed for stopping it again * returns a pointer to the timeout, which is needed for stopping it again
@@ -48,9 +53,6 @@ void change_timeout(timeout* t, int value_msec, int interval_msec, void (*_callb
/** stops the timeout 't' **/ /** stops the timeout 't' **/
void stop_timeout(timeout* t); void stop_timeout(timeout* t);
/** stops all timeouts **/
void stop_all_timeouts();
/** update_next_timeout updates next_timeout to the value, when the next installed timeout will expire **/ /** update_next_timeout updates next_timeout to the value, when the next installed timeout will expire **/
void update_next_timeout(); void update_next_timeout();