Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d10a505aa9 | ||
|
|
77f744eba4 | ||
|
|
f8dde00a33 | ||
|
|
380f260027 | ||
|
|
6df4eb4bee | ||
|
|
18fcc4952d | ||
|
|
3878bd6a49 | ||
|
|
067234e9fb | ||
|
|
e32d2342a6 | ||
|
|
82776df9d6 |
@@ -1,3 +1,12 @@
|
||||
2017-05-21 0.14.5
|
||||
- Fixes:
|
||||
- Fixed a couple of memory leaks
|
||||
|
||||
2017-04-29 0.14.4
|
||||
- Fixes:
|
||||
- Fix regression in executor (issue #639)
|
||||
- Fix crash when _NET_WM_ICON is set but empty (https://github.com/jmc-88/tint3/issues/21)
|
||||
|
||||
2017-04-23 0.14.3
|
||||
- Fixes:
|
||||
- Make versioning more robust when building as package
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Latest stable release: 0.14.3
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/0.14.3/ChangeLog
|
||||
# Latest stable release: 0.14.5
|
||||
Changes: https://gitlab.com/o9000/tint2/blob/0.14.5/ChangeLog
|
||||
|
||||
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
|
||||
cd tint2
|
||||
git checkout 0.14.3
|
||||
git checkout 0.14.5
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
||||
@@ -199,9 +199,9 @@ pre {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="latest-stable-release-0-14-3"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.14.3</span><a name="latest-stable-release-0-14-3" href="#latest-stable-release-0-14-3" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.14.3/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.14.3/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
|
||||
git checkout 0.14.3
|
||||
git checkout 0.14.5
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.TH TINT2 1 "2017\-04\-23" 0.14.3
|
||||
.TH TINT2 1 "2017\-05\-21" 0.14.5
|
||||
.SH NAME
|
||||
.PP
|
||||
tint2 \- lightweight panel/taskbar
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# TINT2 1 "2017-04-23" 0.14.3
|
||||
# TINT2 1 "2017-05-21" 0.14.5
|
||||
|
||||
## NAME
|
||||
tint2 - lightweight panel/taskbar
|
||||
|
||||
@@ -237,4 +237,4 @@ if __name__ == '__main__':
|
||||
run("tar -xzf tint2-%s.tar.gz" % readable_version)
|
||||
run("cd tint2-%s ; mkdir build ; cd build ; cmake .. ; make" % readable_version)
|
||||
assert_equal(run("./tint2-%s/build/tint2 -v" % readable_version).strip(), "tint2 version %s" % readable_version)
|
||||
os.system("git log -p -1")
|
||||
os.system("git log -p -1 --word-diff")
|
||||
|
||||
@@ -437,7 +437,7 @@ char *battery_get_tooltip(void *obj)
|
||||
return battery_os_tooltip();
|
||||
}
|
||||
|
||||
void battery_action(int button, Time time)
|
||||
void battery_action(void *obj, int button, int x, int y, Time time)
|
||||
{
|
||||
char *command = NULL;
|
||||
switch (button) {
|
||||
@@ -457,5 +457,5 @@ void battery_action(int button, Time time)
|
||||
command = battery_dwheel_command;
|
||||
break;
|
||||
}
|
||||
tint_exec(command, NULL, NULL, time);
|
||||
tint_exec(command, NULL, NULL, time, obj, x, y);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ void battery_default_font_changed();
|
||||
|
||||
gboolean resize_battery(void *obj);
|
||||
|
||||
void battery_action(int button, Time time);
|
||||
void battery_action(void *obj, int button, int x, int y, Time time);
|
||||
|
||||
/* operating system specific functions */
|
||||
gboolean battery_os_init();
|
||||
|
||||
@@ -516,7 +516,6 @@ void button_dump_geometry(void *obj, int indent)
|
||||
void button_action(void *obj, int mouse_button, int x, int y, Time time)
|
||||
{
|
||||
Button *button = (Button *)obj;
|
||||
Panel *panel = (Panel *)button->area.panel;
|
||||
char *command = NULL;
|
||||
switch (mouse_button) {
|
||||
case 1:
|
||||
@@ -535,100 +534,7 @@ void button_action(void *obj, int mouse_button, int x, int y, Time time)
|
||||
command = button->backend->dwheel_command;
|
||||
break;
|
||||
}
|
||||
if (command) {
|
||||
int aligned_x, aligned_y, aligned_x1, aligned_y1, aligned_x2, aligned_y2;
|
||||
int panel_x1, panel_x2, panel_y1, panel_y2;
|
||||
if (panel_horizontal) {
|
||||
if (area_is_first(button))
|
||||
aligned_x1 = panel->posx;
|
||||
else
|
||||
aligned_x1 = panel->posx + button->area.posx;
|
||||
|
||||
if (area_is_last(button))
|
||||
aligned_x2 = panel->posx + panel->area.width;
|
||||
else
|
||||
aligned_x2 = panel->posx + button->area.posx + button->area.width;
|
||||
|
||||
if (area_is_first(button))
|
||||
aligned_x = aligned_x1;
|
||||
else if (area_is_last(button))
|
||||
aligned_x = aligned_x2;
|
||||
else
|
||||
aligned_x = aligned_x1;
|
||||
|
||||
if (panel_position & BOTTOM)
|
||||
aligned_y = panel->posy;
|
||||
else
|
||||
aligned_y = panel->posy + panel->area.height;
|
||||
|
||||
aligned_y1 = aligned_y2 = aligned_y;
|
||||
|
||||
panel_x1 = panel->posx;
|
||||
panel_x2 = panel->posx + panel->area.width;
|
||||
panel_y1 = panel_y2 = aligned_y;
|
||||
} else {
|
||||
if (area_is_first(button))
|
||||
aligned_y1 = panel->posy;
|
||||
else
|
||||
aligned_y1 = panel->posy + button->area.posy;
|
||||
|
||||
if (area_is_last(button))
|
||||
aligned_y2 = panel->posy + panel->area.height;
|
||||
else
|
||||
aligned_y2 = panel->posy + button->area.posy + button->area.height;
|
||||
|
||||
if (area_is_first(button))
|
||||
aligned_y = aligned_y1;
|
||||
else if (area_is_last(button))
|
||||
aligned_y = aligned_y2;
|
||||
else
|
||||
aligned_y = aligned_y1;
|
||||
|
||||
if (panel_position & RIGHT)
|
||||
aligned_x = panel->posx;
|
||||
else
|
||||
aligned_x = panel->posx + panel->area.width;
|
||||
|
||||
aligned_x1 = aligned_x2 = aligned_x;
|
||||
|
||||
panel_x1 = panel_x2 = aligned_x;
|
||||
panel_y1 = panel->posy;
|
||||
panel_y2 = panel->posy + panel->area.height;
|
||||
}
|
||||
|
||||
char *full_cmd = g_strdup_printf("export TINT2_BUTTON_X=%d;"
|
||||
"export TINT2_BUTTON_Y=%d;"
|
||||
"export TINT2_BUTTON_W=%d;"
|
||||
"export TINT2_BUTTON_H=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_X=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_Y=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_X1=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_Y1=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_X2=%d;"
|
||||
"export TINT2_BUTTON_ALIGNED_Y2=%d;"
|
||||
"export TINT2_BUTTON_PANEL_X1=%d;"
|
||||
"export TINT2_BUTTON_PANEL_Y1=%d;"
|
||||
"export TINT2_BUTTON_PANEL_X2=%d;"
|
||||
"export TINT2_BUTTON_PANEL_Y2=%d;"
|
||||
"%s",
|
||||
x,
|
||||
y,
|
||||
button->area.width,
|
||||
button->area.height,
|
||||
aligned_x,
|
||||
aligned_y,
|
||||
aligned_x1,
|
||||
aligned_y1,
|
||||
aligned_x2,
|
||||
aligned_y2,
|
||||
panel_x1,
|
||||
panel_y1,
|
||||
panel_x2,
|
||||
panel_y2,
|
||||
command);
|
||||
tint_exec(full_cmd, NULL, NULL, time);
|
||||
g_free(full_cmd);
|
||||
}
|
||||
tint_exec(command, NULL, NULL, time, obj, x, y);
|
||||
}
|
||||
|
||||
char *button_get_tooltip(void *obj)
|
||||
|
||||
@@ -393,7 +393,7 @@ char *clock_get_tooltip(void *obj)
|
||||
return strdup(buf_tooltip);
|
||||
}
|
||||
|
||||
void clock_action(int button, Time time)
|
||||
void clock_action(void *obj, int button, int x, int y, Time time)
|
||||
{
|
||||
char *command = NULL;
|
||||
switch (button) {
|
||||
@@ -413,5 +413,5 @@ void clock_action(int button, Time time)
|
||||
command = clock_dwheel_command;
|
||||
break;
|
||||
}
|
||||
tint_exec(command, NULL, NULL, time);
|
||||
tint_exec(command, NULL, NULL, time, obj, x, y);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,6 @@ void draw_clock(void *obj, cairo_t *c);
|
||||
|
||||
gboolean resize_clock(void *obj);
|
||||
|
||||
void clock_action(int button, Time time);
|
||||
void clock_action(void *obj, int button, int x, int y, Time time);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -579,17 +579,17 @@ void execp_action(void *obj, int button, int x, int y, Time time)
|
||||
break;
|
||||
}
|
||||
if (command) {
|
||||
char *full_cmd = g_strdup_printf("export EXECP_X=%d;"
|
||||
"export EXECP_Y=%d;"
|
||||
"export EXECP_W=%d;"
|
||||
"export EXECP_H=%d; %s",
|
||||
x,
|
||||
y,
|
||||
execp->area.width,
|
||||
execp->area.height,
|
||||
command);
|
||||
tint_exec(full_cmd, NULL, NULL, time);
|
||||
g_free(full_cmd);
|
||||
setenvd("EXECP_X", x);
|
||||
setenvd("EXECP_Y", y);
|
||||
setenvd("EXECP_W", execp->area.width);
|
||||
setenvd("EXECP_H", execp->area.height);
|
||||
pid_t pid = tint_exec(command, NULL, NULL, time, obj, x, y);
|
||||
unsetenv("EXECP_X");
|
||||
unsetenv("EXECP_Y");
|
||||
unsetenv("EXECP_W");
|
||||
unsetenv("EXECP_H");
|
||||
if (pid > 0)
|
||||
g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1));
|
||||
} else {
|
||||
execp_force_update(execp);
|
||||
}
|
||||
|
||||
@@ -415,13 +415,13 @@ void free_icon(Imlib_Image icon)
|
||||
}
|
||||
}
|
||||
|
||||
void launcher_action(LauncherIcon *icon, XEvent *evt)
|
||||
void launcher_action(LauncherIcon *icon, XEvent *evt, int x, int y)
|
||||
{
|
||||
launcher_reload_icon((Launcher *)icon->area.parent, icon);
|
||||
launcher_reload_hidden_icons((Launcher *)icon->area.parent);
|
||||
|
||||
if (evt->type == ButtonPress || evt->type == ButtonRelease)
|
||||
tint_exec(icon->cmd, icon->cwd, icon->icon_tooltip, evt->xbutton.time);
|
||||
tint_exec(icon->cmd, icon->cwd, icon->icon_tooltip, evt->xbutton.time, &icon->area, x, y);
|
||||
}
|
||||
|
||||
// Populates the list_icons list from the list_apps list
|
||||
|
||||
@@ -67,7 +67,7 @@ void launcher_default_icon_theme_changed();
|
||||
|
||||
// Populates the list_icons list
|
||||
void launcher_load_icons(Launcher *launcher);
|
||||
void launcher_action(LauncherIcon *icon, XEvent *e);
|
||||
void launcher_action(LauncherIcon *icon, XEvent *e, int x, int y);
|
||||
|
||||
void test_launcher_read_desktop_file();
|
||||
void test_launcher_read_theme_file();
|
||||
|
||||
@@ -158,6 +158,29 @@ Task *add_task(Window win)
|
||||
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)
|
||||
{
|
||||
if (!task)
|
||||
@@ -178,23 +201,7 @@ void remove_task(Task *task)
|
||||
// printf("remove_task %s %d\n", task->title, task->desktop);
|
||||
if (task->title)
|
||||
free(task->title);
|
||||
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;
|
||||
}
|
||||
}
|
||||
task_remove_icon(task);
|
||||
|
||||
GPtrArray *task_buttons = g_hash_table_lookup(win_to_task, &win);
|
||||
for (int i = 0; i < task_buttons->len; ++i) {
|
||||
@@ -265,36 +272,32 @@ void task_update_icon(Task *task)
|
||||
if (!panel->g_task.has_icon)
|
||||
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;
|
||||
}
|
||||
}
|
||||
task_remove_icon(task);
|
||||
|
||||
Imlib_Image img = NULL;
|
||||
|
||||
if (!img) {
|
||||
int i;
|
||||
gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &i);
|
||||
int len;
|
||||
gulong *data = server_get_property(task->win, server.atom._NET_WM_ICON, XA_CARDINAL, &len);
|
||||
if (data) {
|
||||
// get ARGB icon
|
||||
int w, h;
|
||||
gulong *tmp_data;
|
||||
|
||||
tmp_data = get_best_icon(data, get_icon_count(data, i), i, &w, &h, panel->g_task.icon_size1);
|
||||
DATA32 icon_data[w * h];
|
||||
for (int j = 0; j < w * h; ++j)
|
||||
icon_data[j] = tmp_data[j];
|
||||
img = imlib_create_image_using_copied_data(w, h, icon_data);
|
||||
if (0 && img)
|
||||
fprintf(stderr,
|
||||
"%s: Got %dx%d icon via _NET_WM_ICON for %s\n",
|
||||
__FUNCTION__,
|
||||
w,
|
||||
h,
|
||||
task->title ? task->title : "task");
|
||||
if (len > 0) {
|
||||
// get ARGB icon
|
||||
int w, h;
|
||||
gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1);
|
||||
if (tmp_data) {
|
||||
DATA32 icon_data[w * h];
|
||||
for (int j = 0; j < w * h; ++j)
|
||||
icon_data[j] = tmp_data[j];
|
||||
img = imlib_create_image_using_copied_data(w, h, icon_data);
|
||||
if (0 && img)
|
||||
fprintf(stderr,
|
||||
"%s: Got %dx%d icon via _NET_WM_ICON for %s\n",
|
||||
__FUNCTION__,
|
||||
w,
|
||||
h,
|
||||
task->title ? task->title : "task");
|
||||
}
|
||||
}
|
||||
XFree(data);
|
||||
}
|
||||
}
|
||||
|
||||
15
src/tint.c
15
src/tint.c
@@ -652,6 +652,7 @@ void cleanup()
|
||||
|
||||
cleanup_server();
|
||||
cleanup_timeout();
|
||||
|
||||
if (server.display)
|
||||
XCloseDisplay(server.display);
|
||||
server.display = NULL;
|
||||
@@ -967,8 +968,9 @@ void event_button_release(XEvent *e)
|
||||
break;
|
||||
}
|
||||
|
||||
if (click_clock(panel, e->xbutton.x, e->xbutton.y)) {
|
||||
clock_action(e->xbutton.button, e->xbutton.time);
|
||||
Clock *clock = click_clock(panel, e->xbutton.x, e->xbutton.y);
|
||||
if (clock) {
|
||||
clock_action(clock, e->xbutton.button, e->xbutton.x - clock->area.posx, e->xbutton.y - clock->area.posy, e->xbutton.time);
|
||||
if (panel_layer == BOTTOM_LAYER)
|
||||
XLowerWindow(server.display, panel->main_win);
|
||||
task_drag = 0;
|
||||
@@ -976,8 +978,9 @@ void event_button_release(XEvent *e)
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BATTERY
|
||||
if (click_battery(panel, e->xbutton.x, e->xbutton.y)) {
|
||||
battery_action(e->xbutton.button, e->xbutton.time);
|
||||
Battery *battery = click_battery(panel, e->xbutton.x, e->xbutton.y);
|
||||
if (battery) {
|
||||
battery_action(battery, e->xbutton.button, e->xbutton.x - battery->area.posx, e->xbutton.y - battery->area.posy, e->xbutton.time);
|
||||
if (panel_layer == BOTTOM_LAYER)
|
||||
XLowerWindow(server.display, panel->main_win);
|
||||
task_drag = 0;
|
||||
@@ -1006,7 +1009,7 @@ void event_button_release(XEvent *e)
|
||||
if (e->xbutton.button == 1 && click_launcher(panel, e->xbutton.x, e->xbutton.y)) {
|
||||
LauncherIcon *icon = click_launcher_icon(panel, e->xbutton.x, e->xbutton.y);
|
||||
if (icon) {
|
||||
launcher_action(icon, e);
|
||||
launcher_action(icon, e, e->xbutton.x - icon->area.posx, e->xbutton.y - icon->area.posy);
|
||||
}
|
||||
task_drag = 0;
|
||||
return;
|
||||
@@ -2131,7 +2134,7 @@ start:
|
||||
strcat(cmd, "\"");
|
||||
strcat(cmd, "&)");
|
||||
fprintf(stderr, "DnD %s:%d: Running command: %s\n", __FILE__, __LINE__, cmd);
|
||||
tint_exec(cmd, NULL, NULL, e.xselection.time);
|
||||
tint_exec(cmd, NULL, NULL, e.xselection.time, NULL, 0, 0);
|
||||
free(cmd);
|
||||
|
||||
// Reply OK.
|
||||
|
||||
@@ -103,22 +103,108 @@ gboolean parse_line(const char *line, char **key, char **value)
|
||||
|
||||
extern char *config_path;
|
||||
|
||||
void tint_exec(const char *command, const char *dir, const char *tooltip, Time time)
|
||||
int setenvd(const char *name, const int value)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "%d", value);
|
||||
return setenv(name, buf, 1);
|
||||
}
|
||||
|
||||
#ifndef TINT2CONF
|
||||
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y)
|
||||
{
|
||||
if (!command || strlen(command) == 0)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
if (area) {
|
||||
Panel *panel = (Panel *)area->panel;
|
||||
|
||||
int aligned_x, aligned_y, aligned_x1, aligned_y1, aligned_x2, aligned_y2;
|
||||
int panel_x1, panel_x2, panel_y1, panel_y2;
|
||||
if (panel_horizontal) {
|
||||
if (area_is_first(area))
|
||||
aligned_x1 = panel->posx;
|
||||
else
|
||||
aligned_x1 = panel->posx + area->posx;
|
||||
|
||||
if (area_is_last(area))
|
||||
aligned_x2 = panel->posx + panel->area.width;
|
||||
else
|
||||
aligned_x2 = panel->posx + area->posx + area->width;
|
||||
|
||||
if (area_is_first(area))
|
||||
aligned_x = aligned_x1;
|
||||
else if (area_is_last(area))
|
||||
aligned_x = aligned_x2;
|
||||
else
|
||||
aligned_x = aligned_x1;
|
||||
|
||||
if (panel_position & BOTTOM)
|
||||
aligned_y = panel->posy;
|
||||
else
|
||||
aligned_y = panel->posy + panel->area.height;
|
||||
|
||||
aligned_y1 = aligned_y2 = aligned_y;
|
||||
|
||||
panel_x1 = panel->posx;
|
||||
panel_x2 = panel->posx + panel->area.width;
|
||||
panel_y1 = panel_y2 = aligned_y;
|
||||
} else {
|
||||
if (area_is_first(area))
|
||||
aligned_y1 = panel->posy;
|
||||
else
|
||||
aligned_y1 = panel->posy + area->posy;
|
||||
|
||||
if (area_is_last(area))
|
||||
aligned_y2 = panel->posy + panel->area.height;
|
||||
else
|
||||
aligned_y2 = panel->posy + area->posy + area->height;
|
||||
|
||||
if (area_is_first(area))
|
||||
aligned_y = aligned_y1;
|
||||
else if (area_is_last(area))
|
||||
aligned_y = aligned_y2;
|
||||
else
|
||||
aligned_y = aligned_y1;
|
||||
|
||||
if (panel_position & RIGHT)
|
||||
aligned_x = panel->posx;
|
||||
else
|
||||
aligned_x = panel->posx + panel->area.width;
|
||||
|
||||
aligned_x1 = aligned_x2 = aligned_x;
|
||||
|
||||
panel_x1 = panel_x2 = aligned_x;
|
||||
panel_y1 = panel->posy;
|
||||
panel_y2 = panel->posy + panel->area.height;
|
||||
}
|
||||
|
||||
setenv("TINT2_CONFIG", config_path, 1);
|
||||
setenvd("TINT2_BUTTON_X", x);
|
||||
setenvd("TINT2_BUTTON_Y", y);
|
||||
setenvd("TINT2_BUTTON_W", area->width);
|
||||
setenvd("TINT2_BUTTON_H", area->height);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_X", aligned_x);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_Y", aligned_y);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_X1", aligned_x1);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_Y1", aligned_y1);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_X2", aligned_x2);
|
||||
setenvd("TINT2_BUTTON_ALIGNED_Y2", aligned_y2);
|
||||
setenvd("TINT2_BUTTON_PANEL_X1", panel_x1);
|
||||
setenvd("TINT2_BUTTON_PANEL_Y1", panel_y1);
|
||||
setenvd("TINT2_BUTTON_PANEL_X2", panel_x2);
|
||||
setenvd("TINT2_BUTTON_PANEL_Y2", panel_y2);
|
||||
} else {
|
||||
setenv("TINT2_CONFIG", config_path, 1);
|
||||
}
|
||||
|
||||
command = g_strdup_printf("export TINT2_CONFIG=%s;"
|
||||
"%s",
|
||||
config_path,
|
||||
command);
|
||||
if (!command)
|
||||
return;
|
||||
return -1;
|
||||
|
||||
if (!tooltip)
|
||||
tooltip = command;
|
||||
|
||||
#if HAVE_SN && !defined TINT2CONF
|
||||
#if HAVE_SN
|
||||
SnLauncherContext *ctx = 0;
|
||||
if (startup_notifications && time) {
|
||||
ctx = sn_launcher_context_new(server.sn_display, server.screen);
|
||||
@@ -134,7 +220,7 @@ void tint_exec(const char *command, const char *dir, const char *tooltip, Time t
|
||||
fprintf(stderr, "Could not fork\n");
|
||||
} else if (pid == 0) {
|
||||
// Child process
|
||||
#if HAVE_SN && !defined TINT2CONF
|
||||
#if HAVE_SN
|
||||
if (startup_notifications && time) {
|
||||
sn_launcher_context_setup_child_process(ctx);
|
||||
}
|
||||
@@ -146,7 +232,7 @@ void tint_exec(const char *command, const char *dir, const char *tooltip, Time t
|
||||
chdir(dir);
|
||||
execl("/bin/sh", "/bin/sh", "-c", command, NULL);
|
||||
fprintf(stderr, "Failed to execlp %s\n", command);
|
||||
#if HAVE_SN && !defined TINT2CONF
|
||||
#if HAVE_SN
|
||||
if (startup_notifications && time) {
|
||||
sn_launcher_context_unref(ctx);
|
||||
}
|
||||
@@ -154,18 +240,37 @@ void tint_exec(const char *command, const char *dir, const char *tooltip, Time t
|
||||
_exit(1);
|
||||
} else {
|
||||
// Parent process
|
||||
#if HAVE_SN && !defined TINT2CONF
|
||||
#if HAVE_SN
|
||||
if (startup_notifications && time) {
|
||||
g_tree_insert(server.pids, GINT_TO_POINTER(pid), ctx);
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
void tint_exec_no_sn(const char *command)
|
||||
{
|
||||
tint_exec(command, NULL, NULL, 0);
|
||||
tint_exec(command, NULL, NULL, 0, NULL, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *expand_tilde(const char *s)
|
||||
{
|
||||
|
||||
@@ -54,8 +54,9 @@ void extract_values(const char *value, char **value1, char **value2, char **valu
|
||||
void extract_values_4(const char *value, char **value1, char **value2, char **value3, char **value4);
|
||||
|
||||
// Executes a command in a shell.
|
||||
void tint_exec(const char *command, const char *dir, const char *tooltip, Time time);
|
||||
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);
|
||||
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.
|
||||
// The caller takes ownership of the string.
|
||||
|
||||
@@ -277,6 +277,9 @@ int get_icon_count(gulong *data, int num)
|
||||
|
||||
gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size)
|
||||
{
|
||||
if (icon_count < 1 || num < 1)
|
||||
return NULL;
|
||||
|
||||
int width[icon_count], height[icon_count], pos, i, w, h;
|
||||
gulong *icon_data[icon_count];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user