all repos — tint2 @ a17b62f76fb3ac482ef8b19743450e97022f6a94

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

fixed segfault

git-svn-id: http://tint2.googlecode.com/svn/trunk@168 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
lorthiois@bbsoft.fr lorthiois@bbsoft.fr@121b4492-b84c-0410-8b4c-0d4edfb3f3cc
commit

a17b62f76fb3ac482ef8b19743450e97022f6a94

parent

a62548bf29ed1a56309041395925976530808690

6 files changed, 32 insertions(+), 25 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,3 +1,6 @@

+2009-09-01 +- fixed segfault + 2009-08-30 - detect pid of process owning the systray
M src/config.csrc/config.c

@@ -348,7 +348,7 @@ if(atoi(value) == 1)

panel_config->battery.area.on_screen = 1; #else if(atoi(value) == 1) - printf("tint2 is build without battery support\n"); + fprintf(stderr, "tint2 is build without battery support\n"); #endif } else if (strcmp (key, "battery_low_status") == 0) {
M src/taskbar/task.csrc/taskbar/task.c

@@ -193,15 +193,16 @@ tsk->icon_height = h;

// DATA32 is provided by imlib2 tsk->icon_data = malloc (w * h * sizeof (DATA32)); + if (tsk->icon_data) { #ifdef __x86_64__ - int length = tsk->icon_width * tsk->icon_height; - int i; - for (i = 0; i < length; ++i) - tsk->icon_data[i] = tmp_data[i]; + int length = tsk->icon_width * tsk->icon_height; + int i; + for (i = 0; i < length; ++i) + tsk->icon_data[i] = tmp_data[i]; #else - memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32)); + memcpy (tsk->icon_data, tmp_data, w * h * sizeof (DATA32)); #endif - + } XFree (data); } else {

@@ -229,20 +230,23 @@ }

tsk->icon_width = imlib_image_get_width(); tsk->icon_height = imlib_image_get_height(); tsk->icon_data = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32)); - memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); + if (tsk->icon_data) + memcpy (tsk->icon_data, data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); imlib_free_image(); } XFree(hints); } - tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32)); - memcpy (tsk->icon_data_active, tsk->icon_data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); + if (tsk->icon_data) { + tsk->icon_data_active = malloc (tsk->icon_width * tsk->icon_height * sizeof (DATA32)); + memcpy (tsk->icon_data_active, tsk->icon_data, tsk->icon_width * tsk->icon_height * sizeof (DATA32)); - if (panel->g_task.hue != 0 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) { - adjust_hsb(tsk->icon_data, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue/100, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100); - } - if (panel->g_task.hue_active != 0 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) { - adjust_hsb(tsk->icon_data_active, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue_active/100, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100); + if (panel->g_task.hue != 0 || panel->g_task.saturation != 0 || panel->g_task.brightness != 0) { + adjust_hsb(tsk->icon_data, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue/100, (float)panel->g_task.saturation/100, (float)panel->g_task.brightness/100); + } + if (panel->g_task.hue_active != 0 || panel->g_task.saturation_active != 0 || panel->g_task.brightness_active != 0) { + adjust_hsb(tsk->icon_data_active, tsk->icon_width, tsk->icon_height, (float)panel->g_task.hue_active/100, (float)panel->g_task.saturation_active/100, (float)panel->g_task.brightness_active/100); + } } }
M src/taskbar/task.hsrc/taskbar/task.h

@@ -49,8 +49,8 @@ int desktop;

// ARGB icon unsigned int *icon_data; unsigned int *icon_data_active; - int icon_width; - int icon_height; + unsigned int icon_width; + unsigned int icon_height; char *title; } Task;
M src/util/common.csrc/util/common.c

@@ -30,20 +30,19 @@ #include "common.h"

-void adjust_hsb(unsigned int *data, int w, int h, float hu, float satur, float bright) +void adjust_hsb(DATA32 *data, int w, int h, float hu, float satur, float bright) { - unsigned int *pt = data; - int x, y; + unsigned int x, y; unsigned int a, r, g, b, argb; + unsigned long id; int cmax, cmin; float h2, f, p, q, t; float hue, saturation, brightness; float redc, greenc, bluec; - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - argb = pt[y * h + x]; + for(id = y * w, x = 0; x < w; x++, id++) { + argb = data[id]; a = (argb >> 24) & 0xff; r = (argb >> 16) & 0xff; g = (argb >> 8) & 0xff;

@@ -134,7 +133,7 @@ argb = a;

argb = (argb << 8) + r; argb = (argb << 8) + g; argb = (argb << 8) + b; - pt[y * h + x] = argb; + data[id] = argb; } } }
M src/util/common.hsrc/util/common.h

@@ -9,6 +9,7 @@

#define WM_CLASS_TINT "panel" +#include <Imlib2.h> #include "area.h" /*

@@ -50,7 +51,7 @@ } config_color;

// adjust HSB on an ARGB icon -void adjust_hsb(unsigned int *data, int w, int h, float hue, float satur, float bright); +void adjust_hsb(DATA32 *data, int w, int h, float hue, float satur, float bright);