Compare commits

...

4 Commits

Author SHA1 Message Date
o9000
d10a505aa9 Release 0.14.5 2017-05-21 13:33:11 +02:00
o9000
77f744eba4 Update changelog 2017-05-21 13:32:49 +02:00
o9000
f8dde00a33 Do not pollute command line of executed processes 2017-05-20 14:48:25 +02:00
o9000
380f260027 Fix some memory leaks (issue #641) 2017-04-30 20:49:08 +02:00
10 changed files with 105 additions and 94 deletions

View File

@@ -1,3 +1,7 @@
2017-05-21 0.14.5
- Fixes:
- Fixed a couple of memory leaks
2017-04-29 0.14.4 2017-04-29 0.14.4
- Fixes: - Fixes:
- Fix regression in executor (issue #639) - Fix regression in executor (issue #639)

View File

@@ -1,5 +1,5 @@
# Latest stable release: 0.14.4 # Latest stable release: 0.14.5
Changes: https://gitlab.com/o9000/tint2/blob/0.14.4/ChangeLog Changes: https://gitlab.com/o9000/tint2/blob/0.14.5/ChangeLog
Documentation: [doc/tint2.md](doc/tint2.md) Documentation: [doc/tint2.md](doc/tint2.md)
@@ -8,7 +8,7 @@ Compile it with (after you install the [dependencies](https://gitlab.com/o9000/t
``` ```
git clone https://gitlab.com/o9000/tint2.git git clone https://gitlab.com/o9000/tint2.git
cd tint2 cd tint2
git checkout 0.14.4 git checkout 0.14.5
mkdir build mkdir build
cd build cd build
cmake .. cmake ..

View File

@@ -199,9 +199,9 @@ pre {
</style> </style>
</head> </head>
<body> <body>
<h1 id="latest-stable-release-0-14-4"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.14.4</span><a name="latest-stable-release-0-14-4" href="#latest-stable-release-0-14-4" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.14.4/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.14.4/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git <h1 id="latest-stable-release-0-14-5"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.14.5</span><a name="latest-stable-release-0-14-5" href="#latest-stable-release-0-14-5" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.14.5/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.14.5/ChangeLog</a></p><p>Documentation: <a href="manual.html">manual.html</a></p><p>Compile it with (after you install the <a href="https://gitlab.com/o9000/tint2/wikis/Install#dependencies">dependencies</a>):</p><pre class="highlight plaintext"><code>git clone https://gitlab.com/o9000/tint2.git
cd tint2 cd tint2
git checkout 0.14.4 git checkout 0.14.5
mkdir build mkdir build
cd build cd build
cmake .. cmake ..

View File

@@ -1,4 +1,4 @@
.TH TINT2 1 "2017\-04\-29" 0.14.4 .TH TINT2 1 "2017\-05\-21" 0.14.5
.SH NAME .SH NAME
.PP .PP
tint2 \- lightweight panel/taskbar tint2 \- lightweight panel/taskbar

View File

@@ -1,4 +1,4 @@
# TINT2 1 "2017-04-29" 0.14.4 # TINT2 1 "2017-05-21" 0.14.5
## NAME ## NAME
tint2 - lightweight panel/taskbar tint2 - lightweight panel/taskbar

View File

@@ -579,17 +579,15 @@ void execp_action(void *obj, int button, int x, int y, Time time)
break; break;
} }
if (command) { if (command) {
char *full_cmd = g_strdup_printf("export EXECP_X=%d;" setenvd("EXECP_X", x);
"export EXECP_Y=%d;" setenvd("EXECP_Y", y);
"export EXECP_W=%d;" setenvd("EXECP_W", execp->area.width);
"export EXECP_H=%d; %s", setenvd("EXECP_H", execp->area.height);
x, pid_t pid = tint_exec(command, NULL, NULL, time, obj, x, y);
y, unsetenv("EXECP_X");
execp->area.width, unsetenv("EXECP_Y");
execp->area.height, unsetenv("EXECP_W");
command); unsetenv("EXECP_H");
pid_t pid = tint_exec(full_cmd, NULL, NULL, time, obj, x, y);
g_free(full_cmd);
if (pid > 0) if (pid > 0)
g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1)); g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1));
} else { } else {

View File

@@ -158,6 +158,29 @@ Task *add_task(Window win)
return (Task *)g_ptr_array_index(task_buttons, 0); return (Task *)g_ptr_array_index(task_buttons, 0);
} }
void task_remove_icon(Task *task)
{
if (!task)
return;
for (int k = 0; k < TASK_STATE_COUNT; ++k) {
if (task->icon[k]) {
imlib_context_set_image(task->icon[k]);
imlib_free_image();
task->icon[k] = 0;
}
if (task->icon_hover[k]) {
imlib_context_set_image(task->icon_hover[k]);
imlib_free_image();
task->icon_hover[k] = 0;
}
if (task->icon_press[k]) {
imlib_context_set_image(task->icon_press[k]);
imlib_free_image();
task->icon_press[k] = 0;
}
}
}
void remove_task(Task *task) void remove_task(Task *task)
{ {
if (!task) if (!task)
@@ -178,23 +201,7 @@ void remove_task(Task *task)
// printf("remove_task %s %d\n", task->title, task->desktop); // printf("remove_task %s %d\n", task->title, task->desktop);
if (task->title) if (task->title)
free(task->title); free(task->title);
for (int k = 0; k < TASK_STATE_COUNT; ++k) { task_remove_icon(task);
if (task->icon[k]) {
imlib_context_set_image(task->icon[k]);
imlib_free_image();
task->icon[k] = 0;
}
if (task->icon_hover[k]) {
imlib_context_set_image(task->icon_hover[k]);
imlib_free_image();
task->icon_hover[k] = 0;
}
if (task->icon_press[k]) {
imlib_context_set_image(task->icon_press[k]);
imlib_free_image();
task->icon_press[k] = 0;
}
}
GPtrArray *task_buttons = g_hash_table_lookup(win_to_task, &win); GPtrArray *task_buttons = g_hash_table_lookup(win_to_task, &win);
for (int i = 0; i < task_buttons->len; ++i) { for (int i = 0; i < task_buttons->len; ++i) {
@@ -265,35 +272,31 @@ void task_update_icon(Task *task)
if (!panel->g_task.has_icon) if (!panel->g_task.has_icon)
return; return;
for (int k = 0; k < TASK_STATE_COUNT; ++k) { task_remove_icon(task);
if (task->icon[k]) {
imlib_context_set_image(task->icon[k]);
imlib_free_image();
task->icon[k] = 0;
}
}
Imlib_Image img = NULL; Imlib_Image img = NULL;
if (!img) { if (!img) {
int len; int len;
gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &len); gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &len);
if (data && len > 0) { if (data) {
// get ARGB icon if (len > 0) {
int w, h; // get ARGB icon
gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1); int w, h;
if (tmp_data) { gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1);
DATA32 icon_data[w * h]; if (tmp_data) {
for (int j = 0; j < w * h; ++j) DATA32 icon_data[w * h];
icon_data[j] = tmp_data[j]; for (int j = 0; j < w * h; ++j)
img = imlib_create_image_using_copied_data(w, h, icon_data); icon_data[j] = tmp_data[j];
if (0 && img) img = imlib_create_image_using_copied_data(w, h, icon_data);
fprintf(stderr, if (0 && img)
"%s: Got %dx%d icon via _NET_WM_ICON for %s\n", fprintf(stderr,
__FUNCTION__, "%s: Got %dx%d icon via _NET_WM_ICON for %s\n",
w, __FUNCTION__,
h, w,
task->title ? task->title : "task"); h,
task->title ? task->title : "task");
}
} }
XFree(data); XFree(data);
} }

View File

@@ -652,6 +652,7 @@ void cleanup()
cleanup_server(); cleanup_server();
cleanup_timeout(); cleanup_timeout();
if (server.display) if (server.display)
XCloseDisplay(server.display); XCloseDisplay(server.display);
server.display = NULL; server.display = NULL;

View File

@@ -103,6 +103,13 @@ gboolean parse_line(const char *line, char **key, char **value)
extern char *config_path; extern char *config_path;
int setenvd(const char *name, const int value)
{
char buf[256];
sprintf(buf, "%d", value);
return setenv(name, buf, 1);
}
#ifndef TINT2CONF #ifndef TINT2CONF
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y) pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y)
{ {
@@ -172,43 +179,23 @@ pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time
panel_y2 = panel->posy + panel->area.height; panel_y2 = panel->posy + panel->area.height;
} }
command = g_strdup_printf("export TINT2_CONFIG=%s;" setenv("TINT2_CONFIG", config_path, 1);
"export TINT2_BUTTON_X=%d;" setenvd("TINT2_BUTTON_X", x);
"export TINT2_BUTTON_Y=%d;" setenvd("TINT2_BUTTON_Y", y);
"export TINT2_BUTTON_W=%d;" setenvd("TINT2_BUTTON_W", area->width);
"export TINT2_BUTTON_H=%d;" setenvd("TINT2_BUTTON_H", area->height);
"export TINT2_BUTTON_ALIGNED_X=%d;" setenvd("TINT2_BUTTON_ALIGNED_X", aligned_x);
"export TINT2_BUTTON_ALIGNED_Y=%d;" setenvd("TINT2_BUTTON_ALIGNED_Y", aligned_y);
"export TINT2_BUTTON_ALIGNED_X1=%d;" setenvd("TINT2_BUTTON_ALIGNED_X1", aligned_x1);
"export TINT2_BUTTON_ALIGNED_Y1=%d;" setenvd("TINT2_BUTTON_ALIGNED_Y1", aligned_y1);
"export TINT2_BUTTON_ALIGNED_X2=%d;" setenvd("TINT2_BUTTON_ALIGNED_X2", aligned_x2);
"export TINT2_BUTTON_ALIGNED_Y2=%d;" setenvd("TINT2_BUTTON_ALIGNED_Y2", aligned_y2);
"export TINT2_BUTTON_PANEL_X1=%d;" setenvd("TINT2_BUTTON_PANEL_X1", panel_x1);
"export TINT2_BUTTON_PANEL_Y1=%d;" setenvd("TINT2_BUTTON_PANEL_Y1", panel_y1);
"export TINT2_BUTTON_PANEL_X2=%d;" setenvd("TINT2_BUTTON_PANEL_X2", panel_x2);
"export TINT2_BUTTON_PANEL_Y2=%d;" setenvd("TINT2_BUTTON_PANEL_Y2", panel_y2);
"%s",
config_path,
x,
y,
area->width,
area->height,
aligned_x,
aligned_y,
aligned_x1,
aligned_y1,
aligned_x2,
aligned_y2,
panel_x1,
panel_y1,
panel_x2,
panel_y2,
command);
} else { } else {
command = g_strdup_printf("export TINT2_CONFIG=%s;" setenv("TINT2_CONFIG", config_path, 1);
"%s",
config_path,
command);
} }
if (!command) if (!command)
@@ -259,6 +246,23 @@ pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time
} }
#endif // HAVE_SN #endif // HAVE_SN
} }
unsetenv("TINT2_CONFIG");
unsetenv("TINT2_BUTTON_X");
unsetenv("TINT2_BUTTON_Y");
unsetenv("TINT2_BUTTON_W");
unsetenv("TINT2_BUTTON_H");
unsetenv("TINT2_BUTTON_ALIGNED_X");
unsetenv("TINT2_BUTTON_ALIGNED_Y");
unsetenv("TINT2_BUTTON_ALIGNED_X1");
unsetenv("TINT2_BUTTON_ALIGNED_Y1");
unsetenv("TINT2_BUTTON_ALIGNED_X2");
unsetenv("TINT2_BUTTON_ALIGNED_Y2");
unsetenv("TINT2_BUTTON_PANEL_X1");
unsetenv("TINT2_BUTTON_PANEL_Y1");
unsetenv("TINT2_BUTTON_PANEL_X2");
unsetenv("TINT2_BUTTON_PANEL_Y2");
return pid; return pid;
} }

View File

@@ -56,6 +56,7 @@ void extract_values_4(const char *value, char **value1, char **value2, char **va
// Executes a command in a shell. // Executes a command in a shell.
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y); pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y);
void tint_exec_no_sn(const char *command); void tint_exec_no_sn(const char *command);
int setenvd(const char *name, const int value);
// Returns a copy of s in which "~" is expanded to the path to the user's home directory. // Returns a copy of s in which "~" is expanded to the path to the user's home directory.
// The caller takes ownership of the string. // The caller takes ownership of the string.