all repos — tint2 @ 06518a0f4bd13b456dd51a01a18d82612cf798ab

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

*fix* 2 memleaks
*fix* no more warnings


git-svn-id: http://tint2.googlecode.com/svn/trunk@335 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
Andreas.Fink85 Andreas.Fink85@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

06518a0f4bd13b456dd51a01a18d82612cf798ab

parent

f9a7bb8b1e871b33fd39cd50e4f19103a9c7a8db

M sample/white_single_desktop.tint2rcsample/white_single_desktop.tint2rc

@@ -87,6 +87,7 @@ #time2_font = Monospace 6

clock_font_color = #151515 60 clock_padding = 4 0 clock_tooltip = %A %d %B +clock_background_id = 1 #time1_timezone = :US/Hawaii #time2_timezone = :Europe/Berlin #clock_tooltip_timezone = :/usr/share/zoneinfo/Europe/Paris
M src/battery/battery.csrc/battery/battery.c

@@ -212,36 +212,30 @@ int8_t new_percentage = 0;

fp = fopen(path_status, "r"); if(fp != NULL) { - fgets(tmp, sizeof tmp, fp); + if (fgets(tmp, sizeof tmp, fp)) { + battery_state.state = BATTERY_UNKNOWN; + if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING; + if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING; + if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL; + } fclose(fp); } - battery_state.state = BATTERY_UNKNOWN; - if(strcasecmp(tmp, "Charging\n")==0) battery_state.state = BATTERY_CHARGING; - if(strcasecmp(tmp, "Discharging\n")==0) battery_state.state = BATTERY_DISCHARGING; - if(strcasecmp(tmp, "Full\n")==0) battery_state.state = BATTERY_FULL; - if (battery_state.state == BATTERY_DISCHARGING) { - } - else { - } fp = fopen(path_energy_now, "r"); if(fp != NULL) { - fgets(tmp, sizeof tmp, fp); - energy_now = atoi(tmp); + if (fgets(tmp, sizeof tmp, fp)) energy_now = atoi(tmp); fclose(fp); } fp = fopen(path_energy_full, "r"); if(fp != NULL) { - fgets(tmp, sizeof tmp, fp); - energy_full = atoi(tmp); + if (fgets(tmp, sizeof tmp, fp)) energy_full = atoi(tmp); fclose(fp); } fp = fopen(path_current_now, "r"); if(fp != NULL) { - fgets(tmp, sizeof tmp, fp); - current_now = atoi(tmp); + if (fgets(tmp, sizeof tmp, fp)) current_now = atoi(tmp); fclose(fp); }

@@ -268,15 +262,14 @@

if(energy_full > 0) new_percentage = (energy_now*100)/energy_full; - if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) { - printf("battery low, executing: %s\n", battery_low_cmd); - if (battery_low_cmd) - system(battery_low_cmd); - battery_low_cmd_send = 1; + if(battery_low_status > new_percentage && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_send) { + if (battery_low_cmd) + if (-1 != system(battery_low_cmd)) + battery_low_cmd_send = 1; + } + if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) { + battery_low_cmd_send = 0; } - if(battery_low_status < new_percentage && battery_state.state == BATTERY_CHARGING && battery_low_cmd_send) { - battery_low_cmd_send = 0; - } battery_state.percentage = new_percentage;
M src/panel.csrc/panel.c

@@ -318,6 +318,11 @@ if (panel_config.g_task.font_desc) {

pango_font_description_free(panel_config.g_task.font_desc); panel_config.g_task.font_desc = 0; } + + if (backgrounds) { + g_array_free(backgrounds, 1); + backgrounds = 0; + } }
M src/server.csrc/server.c

@@ -85,6 +85,7 @@ server.atom._NET_SYSTEM_TRAY_MESSAGE_DATA = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);

server.atom._NET_SYSTEM_TRAY_ORIENTATION = XInternAtom(server.dsp, "_NET_SYSTEM_TRAY_ORIENTATION", False); server.atom._XEMBED = XInternAtom(server.dsp, "_XEMBED", False); server.atom._XEMBED_INFO = XInternAtom(server.dsp, "_XEMBED_INFO", False); + g_free(name_trayer); // drag 'n' drop server.atom.XdndAware = XInternAtom(server.dsp, "XdndAware", False);

@@ -95,9 +96,9 @@

void cleanup_server() { - XFreeColormap(server.dsp, server.colormap); - free(server.monitor); - XFreeGC(server.dsp, server.gc); + if (server.colormap) XFreeColormap(server.dsp, server.colormap); + if (server.monitor) free(server.monitor); + if (server.gc) XFreeGC(server.dsp, server.gc); }
M src/taskbar/task.csrc/taskbar/task.c

@@ -67,8 +67,10 @@ // allocate only one title and one icon

// even with task_on_all_desktop and with task_on_all_panel new_tsk.title = 0; int k; - for (k=0; k<TASK_STATE_COUNT; ++k) + for (k=0; k<TASK_STATE_COUNT; ++k) { new_tsk.icon[k] = 0; + new_tsk.state_pix[k] = 0; + } get_title(&new_tsk); get_icon(&new_tsk);
M src/tint.csrc/tint.c

@@ -157,7 +157,7 @@ if (config_path) g_free(config_path);

if (snapshot_path) g_free(snapshot_path); cleanup_server(); - XCloseDisplay(server.dsp); + if (server.dsp) XCloseDisplay(server.dsp); }

@@ -801,9 +801,11 @@ break;

default: if (e.type == XDamageNotify+damage_event) { + // union needed to avoid strict-aliasing warnings by gcc + union { XEvent e; XDamageNotifyEvent de; } event_union = {.e=e}; TrayWindow *traywin; GSList *l; - XDamageNotifyEvent* de = (XDamageNotifyEvent*)&e; + XDamageNotifyEvent* de = &event_union.de; for (l = systray.list_icons; l ; l = l->next) { traywin = (TrayWindow*)l->data; if ( traywin->id == de->drawable && !de->more ) {
M src/util/common.csrc/util/common.c

@@ -44,7 +44,9 @@

fileDest = fopen(pathDest, "wb"); if (fileDest == NULL) return; - while ((nb = fread(line, 1, 100, fileSrc)) > 0) fwrite(line, 1, nb, fileDest); + while ((nb = fread(line, 1, 100, fileSrc)) > 0) + if ( nb != fwrite(line, 1, nb, fileDest)) + printf("Error while copying file %s to %s\n", pathSrc, pathDest); fclose (fileDest); fclose (fileSrc);
M src/util/timer.csrc/util/timer.c

@@ -300,7 +300,9 @@ g_hash_table_insert(multi_timeouts, real_timeout, mth);

t1->multi_timeout = mt1; t2->multi_timeout = mt2; - real_timeout->multi_timeout = real_timeout; + // set real_timeout->multi_timeout to something, such that we see in add_timeout_intern that + // it is already a multi_timeout (we never use it, except of checking for 0 ptr) + real_timeout->multi_timeout = (void*)real_timeout; timeout_list = g_slist_remove(timeout_list, t1); timeout_list = g_slist_remove(timeout_list, t2);

@@ -411,10 +413,11 @@ {

multi_timeout_handler* mth = g_hash_table_lookup(multi_timeouts, t); g_hash_table_remove(multi_timeouts, mth->parent_timeout); while (mth->timeout_list) { - timeout* t = mth->timeout_list->data; - mth->timeout_list = g_slist_remove(mth->timeout_list, t); - g_hash_table_remove(multi_timeouts, t); - free(t); + timeout* t1 = mth->timeout_list->data; + mth->timeout_list = g_slist_remove(mth->timeout_list, t1); + g_hash_table_remove(multi_timeouts, t1); + free(t1->multi_timeout); + free(t1); } free(mth); }