Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8046600a55 | ||
|
|
17a655b52a | ||
|
|
75b8587216 | ||
|
|
7c87ab88bc | ||
|
|
b87470a284 | ||
|
|
948bf10bad | ||
|
|
59c3761455 | ||
|
|
b50f5ecf3e | ||
|
|
be9c492406 | ||
|
|
85e1a356fe | ||
|
|
5da4c1653a | ||
|
|
64edd55add | ||
|
|
bd28ee77d9 | ||
|
|
d10a505aa9 | ||
|
|
77f744eba4 | ||
|
|
f8dde00a33 | ||
|
|
380f260027 |
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2017-06-11 0.14.6
|
||||||
|
- Fixes:
|
||||||
|
- Take into account border width when computing text height
|
||||||
|
- Taskbar: Fix task icon size limits
|
||||||
|
- Executor: Do not output last line if it is not terminated by newline
|
||||||
|
- Enhancements:
|
||||||
|
- Re-execute tint2 on SIGUSR2.
|
||||||
|
This is useful for preserving config options and environment when updating tint2.
|
||||||
|
|
||||||
|
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)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Latest stable release: 0.14.4
|
# Latest stable release: 0.14.6
|
||||||
Changes: https://gitlab.com/o9000/tint2/blob/0.14.4/ChangeLog
|
Changes: https://gitlab.com/o9000/tint2/blob/0.14.6/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.6
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
@@ -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-6"><span class="md2man-title">Latest</span> <span class="md2man-section">stable</span> <span class="md2man-date">release:</span> <span class="md2man-source">0.14.6</span><a name="latest-stable-release-0-14-6" href="#latest-stable-release-0-14-6" class="md2man-permalink" title="permalink"></a></h1><p>Changes: <a href="https://gitlab.com/o9000/tint2/blob/0.14.6/ChangeLog">https://gitlab.com/o9000/tint2/blob/0.14.6/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.6
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake ..
|
cmake ..
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH TINT2 1 "2017\-04\-29" 0.14.4
|
.TH TINT2 1 "2017\-06\-11" 0.14.6
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.PP
|
.PP
|
||||||
tint2 \- lightweight panel/taskbar
|
tint2 \- lightweight panel/taskbar
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# TINT2 1 "2017-04-29" 0.14.4
|
# TINT2 1 "2017-06-11" 0.14.6
|
||||||
|
|
||||||
## NAME
|
## NAME
|
||||||
tint2 - lightweight panel/taskbar
|
tint2 - lightweight panel/taskbar
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ echo "echo \"#define VERSION_STRING \\\"$VERSION\\\"\" > version.h" > $DIR/get_v
|
|||||||
# Copy the debian files into the source directory
|
# Copy the debian files into the source directory
|
||||||
cp -r debian $DIR/debian
|
cp -r debian $DIR/debian
|
||||||
|
|
||||||
for DISTRO in precise trusty xenial yakkety zesty
|
for DISTRO in precise trusty xenial yakkety zesty artful
|
||||||
do
|
do
|
||||||
# Cleanup from previous builds
|
# Cleanup from previous builds
|
||||||
rm -rf tint2_$VERSION-*
|
rm -rf tint2_$VERSION-*
|
||||||
|
|||||||
@@ -278,156 +278,55 @@ int update_battery()
|
|||||||
battery_state.percentage = 100;
|
battery_state.percentage = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
|
||||||
|
if (battery_state.state == BATTERY_FULL) {
|
||||||
|
strcpy(buf_bat_time, "Full");
|
||||||
|
} else {
|
||||||
|
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int battery_compute_desired_size(void *obj)
|
int battery_compute_desired_size(void *obj)
|
||||||
{
|
{
|
||||||
Battery *battery = (Battery *)obj;
|
Battery *battery = (Battery *)obj;
|
||||||
Panel *panel = (Panel *)battery->area.panel;
|
return text_area_compute_desired_size(&battery->area,
|
||||||
int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink;
|
|
||||||
int bat_time_height, bat_time_width, bat_time_height_ink;
|
|
||||||
|
|
||||||
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
|
|
||||||
if (battery_state.state == BATTERY_FULL) {
|
|
||||||
strcpy(buf_bat_time, "Full");
|
|
||||||
} else {
|
|
||||||
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
|
|
||||||
}
|
|
||||||
get_text_size2(bat1_font_desc,
|
|
||||||
&bat_percentage_height_ink,
|
|
||||||
&bat_percentage_height,
|
|
||||||
&bat_percentage_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_bat_percentage,
|
buf_bat_percentage,
|
||||||
strlen(buf_bat_percentage),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
get_text_size2(bat2_font_desc,
|
|
||||||
&bat_time_height_ink,
|
|
||||||
&bat_time_height,
|
|
||||||
&bat_time_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_bat_time,
|
buf_bat_time,
|
||||||
strlen(buf_bat_time),
|
bat1_font_desc,
|
||||||
PANGO_WRAP_WORD_CHAR,
|
bat2_font_desc);
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
if (panel_horizontal) {
|
|
||||||
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
|
||||||
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
|
|
||||||
return new_size;
|
|
||||||
} else {
|
|
||||||
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
|
|
||||||
top_bottom_border_width(&battery->area);
|
|
||||||
return new_size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean resize_battery(void *obj)
|
gboolean resize_battery(void *obj)
|
||||||
{
|
{
|
||||||
Battery *battery = (Battery *)obj;
|
Battery *battery = (Battery *)obj;
|
||||||
Panel *panel = (Panel *)battery->area.panel;
|
return resize_text_area(&battery->area,
|
||||||
int bat_percentage_height, bat_percentage_width, bat_percentage_height_ink;
|
|
||||||
int bat_time_height, bat_time_width, bat_time_height_ink;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
snprintf(buf_bat_percentage, sizeof(buf_bat_percentage), "%d%%", battery_state.percentage);
|
|
||||||
if (battery_state.state == BATTERY_FULL) {
|
|
||||||
strcpy(buf_bat_time, "Full");
|
|
||||||
} else {
|
|
||||||
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
|
|
||||||
}
|
|
||||||
get_text_size2(bat1_font_desc,
|
|
||||||
&bat_percentage_height_ink,
|
|
||||||
&bat_percentage_height,
|
|
||||||
&bat_percentage_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_bat_percentage,
|
buf_bat_percentage,
|
||||||
strlen(buf_bat_percentage),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
get_text_size2(bat2_font_desc,
|
|
||||||
&bat_time_height_ink,
|
|
||||||
&bat_time_height,
|
|
||||||
&bat_time_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_bat_time,
|
buf_bat_time,
|
||||||
strlen(buf_bat_time),
|
bat1_font_desc,
|
||||||
PANGO_WRAP_WORD_CHAR,
|
bat2_font_desc,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
&battery->bat1_posy,
|
||||||
FALSE);
|
&battery->bat2_posy);
|
||||||
|
|
||||||
if (panel_horizontal) {
|
|
||||||
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
|
|
||||||
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
|
|
||||||
if (new_size > battery->area.width || new_size < battery->area.width - 2) {
|
|
||||||
// we try to limit the number of resize
|
|
||||||
battery->area.width = new_size;
|
|
||||||
battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height) / 2;
|
|
||||||
battery->bat2_posy = battery->bat1_posy + bat_percentage_height;
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
|
|
||||||
top_bottom_border_width(&battery->area);
|
|
||||||
if (new_size > battery->area.height || new_size < battery->area.height - 2) {
|
|
||||||
battery->area.height = new_size;
|
|
||||||
battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2;
|
|
||||||
battery->bat2_posy = battery->bat1_posy + bat_percentage_height + 2;
|
|
||||||
ret = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
schedule_redraw(&battery->area);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_battery(void *obj, cairo_t *c)
|
void draw_battery(void *obj, cairo_t *c)
|
||||||
{
|
{
|
||||||
Battery *battery = obj;
|
Battery *battery = (Battery *)obj;
|
||||||
|
draw_text_area(&battery->area,
|
||||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
c,
|
||||||
pango_layout_set_font_description(layout, bat1_font_desc);
|
buf_bat_percentage,
|
||||||
pango_layout_set_width(layout, battery->area.width * PANGO_SCALE);
|
buf_bat_time,
|
||||||
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
bat1_font_desc,
|
||||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
bat2_font_desc,
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
battery->bat1_posy,
|
||||||
pango_layout_set_text(layout, buf_bat_percentage, strlen(buf_bat_percentage));
|
battery->bat2_posy,
|
||||||
|
&battery->font_color);
|
||||||
cairo_set_source_rgba(c,
|
|
||||||
battery->font_color.rgb[0],
|
|
||||||
battery->font_color.rgb[1],
|
|
||||||
battery->font_color.rgb[2],
|
|
||||||
battery->font_color.alpha);
|
|
||||||
|
|
||||||
pango_cairo_update_layout(c, layout);
|
|
||||||
draw_text(layout, c, 0, battery->bat1_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow);
|
|
||||||
|
|
||||||
pango_layout_set_font_description(layout, bat2_font_desc);
|
|
||||||
pango_layout_set_indent(layout, 0);
|
|
||||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
|
||||||
pango_layout_set_text(layout, buf_bat_time, strlen(buf_bat_time));
|
|
||||||
pango_layout_set_width(layout, battery->area.width * PANGO_SCALE);
|
|
||||||
|
|
||||||
pango_cairo_update_layout(c, layout);
|
|
||||||
draw_text(layout, c, 0, battery->bat2_posy, &battery->font_color, ((Panel *)battery->area.panel)->font_shadow);
|
|
||||||
pango_cairo_show_layout(c, layout);
|
|
||||||
|
|
||||||
g_object_unref(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void battery_dump_geometry(void *obj, int indent)
|
void battery_dump_geometry(void *obj, int indent)
|
||||||
{
|
{
|
||||||
Battery *battery = obj;
|
Battery *battery = (Battery *)obj;
|
||||||
fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", battery->bat1_posy, buf_bat_percentage);
|
fprintf(stderr, "%*sText 1: y = %d, text = %s\n", indent, "", battery->bat1_posy, buf_bat_percentage);
|
||||||
fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", battery->bat2_posy, buf_bat_time);
|
fprintf(stderr, "%*sText 2: y = %d, text = %s\n", indent, "", battery->bat2_posy, buf_bat_time);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ gboolean resize_button(void *obj)
|
|||||||
{
|
{
|
||||||
Button *button = (Button *)obj;
|
Button *button = (Button *)obj;
|
||||||
Panel *panel = (Panel *)button->area.panel;
|
Panel *panel = (Panel *)button->area.panel;
|
||||||
|
Area *area = &button->area;
|
||||||
int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy);
|
int horiz_padding = (panel_horizontal ? button->area.paddingxlr : button->area.paddingy);
|
||||||
int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr);
|
int vert_padding = (panel_horizontal ? button->area.paddingy : button->area.paddingxlr);
|
||||||
int interior_padding = button->area.paddingx;
|
int interior_padding = button->area.paddingx;
|
||||||
@@ -360,34 +361,29 @@ gboolean resize_button(void *obj)
|
|||||||
if (button->frontend->icon_load_size != button->frontend->iconw)
|
if (button->frontend->icon_load_size != button->frontend->iconw)
|
||||||
button_reload_icon(button);
|
button_reload_icon(button);
|
||||||
|
|
||||||
|
int available_w, available_h;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
available_w = panel->area.width;
|
||||||
|
available_h = area->height - 2 * area->paddingy - left_right_border_width(area);
|
||||||
|
} else {
|
||||||
|
available_w =
|
||||||
|
area->width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - left_right_border_width(area);
|
||||||
|
available_h = panel->area.height;
|
||||||
|
}
|
||||||
|
|
||||||
int txt_height_ink, txt_height, txt_width;
|
int txt_height_ink, txt_height, txt_width;
|
||||||
if (button->backend->text) {
|
if (button->backend->text) {
|
||||||
if (panel_horizontal) {
|
|
||||||
get_text_size2(button->backend->font_desc,
|
get_text_size2(button->backend->font_desc,
|
||||||
&txt_height_ink,
|
&txt_height_ink,
|
||||||
&txt_height,
|
&txt_height,
|
||||||
&txt_width,
|
&txt_width,
|
||||||
panel->area.height,
|
available_h,
|
||||||
panel->area.width,
|
available_w,
|
||||||
button->backend->text,
|
button->backend->text,
|
||||||
strlen(button->backend->text),
|
strlen(button->backend->text),
|
||||||
PANGO_WRAP_WORD_CHAR,
|
PANGO_WRAP_WORD_CHAR,
|
||||||
PANGO_ELLIPSIZE_NONE,
|
PANGO_ELLIPSIZE_NONE,
|
||||||
FALSE);
|
FALSE);
|
||||||
} else {
|
|
||||||
get_text_size2(button->backend->font_desc,
|
|
||||||
&txt_height_ink,
|
|
||||||
&txt_height,
|
|
||||||
&txt_width,
|
|
||||||
panel->area.height,
|
|
||||||
button->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
|
|
||||||
left_right_border_width(&button->area),
|
|
||||||
button->backend->text,
|
|
||||||
strlen(button->backend->text),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
txt_height_ink = txt_height = txt_width = 0;
|
txt_height_ink = txt_height = txt_width = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ void default_clock()
|
|||||||
time1_font_desc = NULL;
|
time1_font_desc = NULL;
|
||||||
time2_has_font = FALSE;
|
time2_has_font = FALSE;
|
||||||
time2_font_desc = NULL;
|
time2_font_desc = NULL;
|
||||||
|
buf_time[0] = 0;
|
||||||
|
buf_date[0] = 0;
|
||||||
|
buf_tooltip[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_clock()
|
void cleanup_clock()
|
||||||
@@ -111,31 +114,6 @@ void cleanup_clock()
|
|||||||
clock_timeout = NULL;
|
clock_timeout = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_clocks_sec(void *arg)
|
|
||||||
{
|
|
||||||
gettimeofday(&time_clock, 0);
|
|
||||||
if (time1_format) {
|
|
||||||
for (int i = 0; i < num_panels; i++)
|
|
||||||
panels[i].clock.area.resize_needed = 1;
|
|
||||||
}
|
|
||||||
schedule_panel_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_clocks_min(void *arg)
|
|
||||||
{
|
|
||||||
// remember old_sec because after suspend/hibernate the clock should be updated directly, and not
|
|
||||||
// on next minute change
|
|
||||||
time_t old_sec = time_clock.tv_sec;
|
|
||||||
gettimeofday(&time_clock, 0);
|
|
||||||
if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60) {
|
|
||||||
if (time1_format) {
|
|
||||||
for (int i = 0; i < num_panels; i++)
|
|
||||||
panels[i].clock.area.resize_needed = 1;
|
|
||||||
}
|
|
||||||
schedule_panel_redraw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct tm *clock_gettime_for_tz(const char *timezone)
|
struct tm *clock_gettime_for_tz(const char *timezone)
|
||||||
{
|
{
|
||||||
if (timezone) {
|
if (timezone) {
|
||||||
@@ -152,6 +130,35 @@ struct tm *clock_gettime_for_tz(const char *timezone)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void update_clocks()
|
||||||
|
{
|
||||||
|
if (time1_format)
|
||||||
|
strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
|
||||||
|
if (time2_format)
|
||||||
|
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
||||||
|
if (time1_format || time2_format) {
|
||||||
|
for (int i = 0; i < num_panels; i++)
|
||||||
|
panels[i].clock.area.resize_needed = 1;
|
||||||
|
}
|
||||||
|
schedule_panel_redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_clocks_sec(void *arg)
|
||||||
|
{
|
||||||
|
gettimeofday(&time_clock, 0);
|
||||||
|
update_clocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_clocks_min(void *arg)
|
||||||
|
{
|
||||||
|
// remember old_sec because after suspend/hibernate the clock should be updated directly, and not
|
||||||
|
// on next minute change
|
||||||
|
gettimeofday(&time_clock, 0);
|
||||||
|
time_t old_sec = time_clock.tv_sec;
|
||||||
|
if (time_clock.tv_sec % 60 == 0 || time_clock.tv_sec - old_sec > 60)
|
||||||
|
update_clocks();
|
||||||
|
}
|
||||||
|
|
||||||
gboolean time_format_needs_sec_ticks(char *time_format)
|
gboolean time_format_needs_sec_ticks(char *time_format)
|
||||||
{
|
{
|
||||||
if (!time_format)
|
if (!time_format)
|
||||||
@@ -205,6 +212,7 @@ void init_clock_panel(void *p)
|
|||||||
clock->area._get_tooltip_text = clock_get_tooltip;
|
clock->area._get_tooltip_text = clock_get_tooltip;
|
||||||
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
||||||
}
|
}
|
||||||
|
update_clocks_sec(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clock_init_fonts()
|
void clock_init_fonts()
|
||||||
@@ -243,7 +251,7 @@ void clock_default_font_changed()
|
|||||||
schedule_panel_redraw();
|
schedule_panel_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void clock_compute_text_geometry(Panel *panel,
|
void clock_compute_text_geometry(Clock *clock,
|
||||||
int *time_height_ink,
|
int *time_height_ink,
|
||||||
int *time_height,
|
int *time_height,
|
||||||
int *time_width,
|
int *time_width,
|
||||||
@@ -251,131 +259,53 @@ void clock_compute_text_geometry(Panel *panel,
|
|||||||
int *date_height,
|
int *date_height,
|
||||||
int *date_width)
|
int *date_width)
|
||||||
{
|
{
|
||||||
*date_height = *date_width = 0;
|
area_compute_text_geometry(&clock->area,
|
||||||
strftime(buf_time, sizeof(buf_time), time1_format, clock_gettime_for_tz(time1_timezone));
|
buf_time,
|
||||||
get_text_size2(time1_font_desc,
|
time2_format ? buf_date : NULL,
|
||||||
|
time1_font_desc,
|
||||||
|
time2_font_desc,
|
||||||
time_height_ink,
|
time_height_ink,
|
||||||
time_height,
|
time_height,
|
||||||
time_width,
|
time_width,
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_time,
|
|
||||||
strlen(buf_time),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
if (time2_format) {
|
|
||||||
strftime(buf_date, sizeof(buf_date), time2_format, clock_gettime_for_tz(time2_timezone));
|
|
||||||
get_text_size2(time2_font_desc,
|
|
||||||
date_height_ink,
|
date_height_ink,
|
||||||
date_height,
|
date_height,
|
||||||
date_width,
|
date_width);
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
buf_date,
|
|
||||||
strlen(buf_date),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int clock_compute_desired_size(void *obj)
|
int clock_compute_desired_size(void *obj)
|
||||||
{
|
{
|
||||||
Clock *clock = (Clock *)obj;
|
Clock *clock = (Clock *)obj;
|
||||||
Panel *panel = (Panel *)clock->area.panel;
|
return text_area_compute_desired_size(&clock->area,
|
||||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
buf_time,
|
||||||
clock_compute_text_geometry(panel,
|
time2_format ? buf_date : NULL,
|
||||||
&time_height_ink,
|
time1_font_desc,
|
||||||
&time_height,
|
time2_font_desc);
|
||||||
&time_width,
|
|
||||||
&date_height_ink,
|
|
||||||
&date_height,
|
|
||||||
&date_width);
|
|
||||||
|
|
||||||
if (panel_horizontal) {
|
|
||||||
int new_size = (time_width > date_width) ? time_width : date_width;
|
|
||||||
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
|
|
||||||
return new_size;
|
|
||||||
} else {
|
|
||||||
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
|
|
||||||
return new_size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean resize_clock(void *obj)
|
gboolean resize_clock(void *obj)
|
||||||
{
|
{
|
||||||
Clock *clock = (Clock *)obj;
|
Clock *clock = (Clock *)obj;
|
||||||
Panel *panel = (Panel *)clock->area.panel;
|
return resize_text_area(&clock->area,
|
||||||
gboolean result = FALSE;
|
buf_time,
|
||||||
|
time2_format ? buf_date : NULL,
|
||||||
schedule_redraw(&clock->area);
|
time1_font_desc,
|
||||||
|
time2_font_desc,
|
||||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
&clock->time1_posy,
|
||||||
clock_compute_text_geometry(panel,
|
&clock->time2_posy);
|
||||||
&time_height_ink,
|
|
||||||
&time_height,
|
|
||||||
&time_width,
|
|
||||||
&date_height_ink,
|
|
||||||
&date_height,
|
|
||||||
&date_width);
|
|
||||||
|
|
||||||
int new_size = clock_compute_desired_size(clock);
|
|
||||||
if (panel_horizontal) {
|
|
||||||
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
|
|
||||||
// we try to limit the number of resizes
|
|
||||||
clock->area.width = new_size + 1;
|
|
||||||
clock->time1_posy = (clock->area.height - time_height) / 2;
|
|
||||||
if (time2_format) {
|
|
||||||
clock->time1_posy -= (date_height) / 2;
|
|
||||||
clock->time2_posy = clock->time1_posy + time_height;
|
|
||||||
}
|
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (new_size != clock->area.height) {
|
|
||||||
// we try to limit the number of resizes
|
|
||||||
clock->area.height = new_size;
|
|
||||||
clock->time1_posy = (clock->area.height - time_height) / 2;
|
|
||||||
if (time2_format) {
|
|
||||||
clock->time1_posy -= (date_height) / 2;
|
|
||||||
clock->time2_posy = clock->time1_posy + time_height;
|
|
||||||
}
|
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_clock(void *obj, cairo_t *c)
|
void draw_clock(void *obj, cairo_t *c)
|
||||||
{
|
{
|
||||||
Clock *clock = obj;
|
Clock *clock = (Clock *)obj;
|
||||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
draw_text_area(&clock->area,
|
||||||
|
c,
|
||||||
pango_layout_set_font_description(layout, time1_font_desc);
|
buf_time,
|
||||||
pango_layout_set_width(layout, clock->area.width * PANGO_SCALE);
|
time2_format ? buf_date : NULL,
|
||||||
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
time1_font_desc,
|
||||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
time2_font_desc,
|
||||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
clock->time1_posy,
|
||||||
pango_layout_set_text(layout, buf_time, strlen(buf_time));
|
clock->time2_posy,
|
||||||
|
&clock->font);
|
||||||
cairo_set_source_rgba(c, clock->font.rgb[0], clock->font.rgb[1], clock->font.rgb[2], clock->font.alpha);
|
|
||||||
|
|
||||||
pango_cairo_update_layout(c, layout);
|
|
||||||
draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow);
|
|
||||||
|
|
||||||
if (time2_format) {
|
|
||||||
pango_layout_set_font_description(layout, time2_font_desc);
|
|
||||||
pango_layout_set_indent(layout, 0);
|
|
||||||
pango_layout_set_text(layout, buf_date, strlen(buf_date));
|
|
||||||
pango_layout_set_width(layout, clock->area.width * PANGO_SCALE);
|
|
||||||
|
|
||||||
pango_cairo_update_layout(c, layout);
|
|
||||||
draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel *)clock->area.panel)->font_shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(layout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clock_dump_geometry(void *obj, int indent)
|
void clock_dump_geometry(void *obj, int indent)
|
||||||
|
|||||||
@@ -652,8 +652,8 @@ void add_entry(char *key, char *value)
|
|||||||
Execp *execp = get_or_create_last_execp();
|
Execp *execp = get_or_create_last_execp();
|
||||||
execp->backend->interval = 0;
|
execp->backend->interval = 0;
|
||||||
int v = atoi(value);
|
int v = atoi(value);
|
||||||
if (v < 1) {
|
if (v < 0) {
|
||||||
fprintf(stderr, "execp_interval must be an integer >= 1\n");
|
fprintf(stderr, "execp_interval must be an integer >= 0\n");
|
||||||
} else {
|
} else {
|
||||||
execp->backend->interval = v;
|
execp->backend->interval = v;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,156 +290,138 @@ gboolean reload_icon(Execp *execp)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int execp_compute_desired_size(void *obj)
|
void execp_compute_icon_text_geometry(Execp *execp,
|
||||||
|
int *horiz_padding,
|
||||||
|
int *vert_padding,
|
||||||
|
int *interior_padding,
|
||||||
|
int *icon_w,
|
||||||
|
int *icon_h,
|
||||||
|
gboolean *text_next_line,
|
||||||
|
int *txt_height_ink,
|
||||||
|
int *txt_height,
|
||||||
|
int *txt_width,
|
||||||
|
int *new_size,
|
||||||
|
gboolean *resized)
|
||||||
{
|
{
|
||||||
Execp *execp = (Execp *)obj;
|
|
||||||
Panel *panel = (Panel *)execp->area.panel;
|
Panel *panel = (Panel *)execp->area.panel;
|
||||||
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
|
Area *area = &execp->area;
|
||||||
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
|
*horiz_padding = (panel_horizontal ? area->paddingxlr : area->paddingy);
|
||||||
int interior_padding = execp->area.paddingx;
|
*vert_padding = (panel_horizontal ? area->paddingy : area->paddingxlr);
|
||||||
|
*interior_padding = area->paddingx;
|
||||||
|
|
||||||
int icon_w, icon_h;
|
|
||||||
if (reload_icon(execp)) {
|
if (reload_icon(execp)) {
|
||||||
if (execp->backend->icon) {
|
if (execp->backend->icon) {
|
||||||
imlib_context_set_image(execp->backend->icon);
|
imlib_context_set_image(execp->backend->icon);
|
||||||
icon_w = imlib_image_get_width();
|
*icon_w = imlib_image_get_width();
|
||||||
icon_h = imlib_image_get_height();
|
*icon_h = imlib_image_get_height();
|
||||||
} else {
|
} else {
|
||||||
icon_w = icon_h = 0;
|
*icon_w = *icon_h = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
icon_w = icon_h = 0;
|
*icon_w = *icon_h = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;
|
*text_next_line = !panel_horizontal && *icon_w > area->width / 2;
|
||||||
|
|
||||||
|
int available_w, available_h;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
available_w = panel->area.width;
|
||||||
|
available_h = area->height - 2 * area->paddingy - left_right_border_width(area);
|
||||||
|
} else {
|
||||||
|
available_w = !text_next_line
|
||||||
|
? area->width - *icon_w - (*icon_w ? *interior_padding : 0) - 2 * *horiz_padding -
|
||||||
|
left_right_border_width(area)
|
||||||
|
: area->width - 2 * *horiz_padding - left_right_border_width(area);
|
||||||
|
available_h = panel->area.height;
|
||||||
|
}
|
||||||
|
get_text_size2(execp->backend->font_desc,
|
||||||
|
txt_height_ink,
|
||||||
|
txt_height,
|
||||||
|
txt_width,
|
||||||
|
available_h,
|
||||||
|
available_w,
|
||||||
|
execp->backend->text,
|
||||||
|
strlen(execp->backend->text),
|
||||||
|
PANGO_WRAP_WORD_CHAR,
|
||||||
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
execp->backend->has_markup);
|
||||||
|
|
||||||
|
*resized = FALSE;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
*new_size = *txt_width;
|
||||||
|
if (*icon_w)
|
||||||
|
*new_size += *interior_padding + *icon_w;
|
||||||
|
*new_size += 2 * *horiz_padding + left_right_border_width(area);
|
||||||
|
if (*new_size > area->width || *new_size < (area->width - 6)) {
|
||||||
|
// we try to limit the number of resize
|
||||||
|
*new_size += 1;
|
||||||
|
*resized = TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!*text_next_line) {
|
||||||
|
*new_size = *txt_height + 2 * *vert_padding + top_bottom_border_width(area);
|
||||||
|
*new_size = MAX(*new_size, *icon_h + 2 * *vert_padding + top_bottom_border_width(area));
|
||||||
|
} else {
|
||||||
|
*new_size = *icon_h + *interior_padding + *txt_height + 2 * *vert_padding + top_bottom_border_width(area);
|
||||||
|
}
|
||||||
|
if (*new_size != area->height) {
|
||||||
|
*resized = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int execp_compute_desired_size(void *obj)
|
||||||
|
{
|
||||||
|
Execp *execp = (Execp *)obj;
|
||||||
|
int horiz_padding, vert_padding, interior_padding;
|
||||||
|
int icon_w, icon_h;
|
||||||
|
gboolean text_next_line;
|
||||||
int txt_height_ink, txt_height, txt_width;
|
int txt_height_ink, txt_height, txt_width;
|
||||||
if (panel_horizontal) {
|
|
||||||
get_text_size2(execp->backend->font_desc,
|
|
||||||
&txt_height_ink,
|
|
||||||
&txt_height,
|
|
||||||
&txt_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
execp->backend->text,
|
|
||||||
strlen(execp->backend->text),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
execp->backend->has_markup);
|
|
||||||
} else {
|
|
||||||
get_text_size2(execp->backend->font_desc,
|
|
||||||
&txt_height_ink,
|
|
||||||
&txt_height,
|
|
||||||
&txt_width,
|
|
||||||
panel->area.height,
|
|
||||||
!text_next_line
|
|
||||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
|
|
||||||
left_right_border_width(&execp->area)
|
|
||||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
|
||||||
execp->backend->text,
|
|
||||||
strlen(execp->backend->text),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
execp->backend->has_markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (panel_horizontal) {
|
|
||||||
int new_size = txt_width;
|
|
||||||
if (icon_w)
|
|
||||||
new_size += interior_padding + icon_w;
|
|
||||||
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
|
|
||||||
return new_size;
|
|
||||||
} else {
|
|
||||||
int new_size;
|
int new_size;
|
||||||
if (!text_next_line) {
|
gboolean resized;
|
||||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
execp_compute_icon_text_geometry(execp,
|
||||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
|
&horiz_padding,
|
||||||
} else {
|
&vert_padding,
|
||||||
new_size =
|
&interior_padding,
|
||||||
icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
&icon_w,
|
||||||
}
|
&icon_h,
|
||||||
|
&text_next_line,
|
||||||
|
&txt_height_ink,
|
||||||
|
&txt_height,
|
||||||
|
&txt_width,
|
||||||
|
&new_size,
|
||||||
|
&resized);
|
||||||
|
|
||||||
return new_size;
|
return new_size;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gboolean resize_execp(void *obj)
|
gboolean resize_execp(void *obj)
|
||||||
{
|
{
|
||||||
Execp *execp = (Execp *)obj;
|
Execp *execp = (Execp *)obj;
|
||||||
Panel *panel = (Panel *)execp->area.panel;
|
int horiz_padding, vert_padding, interior_padding;
|
||||||
int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy);
|
|
||||||
int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr);
|
|
||||||
int interior_padding = execp->area.paddingx;
|
|
||||||
|
|
||||||
int icon_w, icon_h;
|
int icon_w, icon_h;
|
||||||
if (reload_icon(execp)) {
|
gboolean text_next_line;
|
||||||
if (execp->backend->icon) {
|
|
||||||
imlib_context_set_image(execp->backend->icon);
|
|
||||||
icon_w = imlib_image_get_width();
|
|
||||||
icon_h = imlib_image_get_height();
|
|
||||||
} else {
|
|
||||||
icon_w = icon_h = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
icon_w = icon_h = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2;
|
|
||||||
|
|
||||||
int txt_height_ink, txt_height, txt_width;
|
int txt_height_ink, txt_height, txt_width;
|
||||||
if (panel_horizontal) {
|
|
||||||
get_text_size2(execp->backend->font_desc,
|
|
||||||
&txt_height_ink,
|
|
||||||
&txt_height,
|
|
||||||
&txt_width,
|
|
||||||
panel->area.height,
|
|
||||||
panel->area.width,
|
|
||||||
execp->backend->text,
|
|
||||||
strlen(execp->backend->text),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
execp->backend->has_markup);
|
|
||||||
} else {
|
|
||||||
get_text_size2(execp->backend->font_desc,
|
|
||||||
&txt_height_ink,
|
|
||||||
&txt_height,
|
|
||||||
&txt_width,
|
|
||||||
panel->area.height,
|
|
||||||
!text_next_line
|
|
||||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
|
|
||||||
left_right_border_width(&execp->area)
|
|
||||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
|
||||||
execp->backend->text,
|
|
||||||
strlen(execp->backend->text),
|
|
||||||
PANGO_WRAP_WORD_CHAR,
|
|
||||||
PANGO_ELLIPSIZE_NONE,
|
|
||||||
execp->backend->has_markup);
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean result = FALSE;
|
|
||||||
if (panel_horizontal) {
|
|
||||||
int new_size = txt_width;
|
|
||||||
if (icon_w)
|
|
||||||
new_size += interior_padding + icon_w;
|
|
||||||
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
|
|
||||||
if (new_size > execp->area.width || new_size < (execp->area.width - 6)) {
|
|
||||||
// we try to limit the number of resize
|
|
||||||
execp->area.width = new_size + 1;
|
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
int new_size;
|
int new_size;
|
||||||
if (!text_next_line) {
|
gboolean resized;
|
||||||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
execp_compute_icon_text_geometry(execp,
|
||||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
|
&horiz_padding,
|
||||||
} else {
|
&vert_padding,
|
||||||
new_size =
|
&interior_padding,
|
||||||
icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
&icon_w,
|
||||||
}
|
&icon_h,
|
||||||
if (new_size != execp->area.height) {
|
&text_next_line,
|
||||||
|
&txt_height_ink,
|
||||||
|
&txt_height,
|
||||||
|
&txt_width,
|
||||||
|
&new_size,
|
||||||
|
&resized);
|
||||||
|
|
||||||
|
if (panel_horizontal)
|
||||||
|
execp->area.width = new_size;
|
||||||
|
else
|
||||||
execp->area.height = new_size;
|
execp->area.height = new_size;
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
execp->frontend->textw = txt_width;
|
execp->frontend->textw = txt_width;
|
||||||
execp->frontend->texth = txt_height;
|
execp->frontend->texth = txt_height;
|
||||||
if (execp->backend->centered) {
|
if (execp->backend->centered) {
|
||||||
@@ -479,13 +461,12 @@ gboolean resize_execp(void *obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
schedule_redraw(&execp->area);
|
schedule_redraw(&execp->area);
|
||||||
|
return resized;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_execp(void *obj, cairo_t *c)
|
void draw_execp(void *obj, cairo_t *c)
|
||||||
{
|
{
|
||||||
Execp *execp = obj;
|
Execp *execp = (Execp *)obj;
|
||||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||||
|
|
||||||
if (execp->backend->has_icon && execp->backend->icon) {
|
if (execp->backend->has_icon && execp->backend->icon) {
|
||||||
@@ -518,7 +499,7 @@ void draw_execp(void *obj, cairo_t *c)
|
|||||||
|
|
||||||
void execp_dump_geometry(void *obj, int indent)
|
void execp_dump_geometry(void *obj, int indent)
|
||||||
{
|
{
|
||||||
Execp *execp = obj;
|
Execp *execp = (Execp *)obj;
|
||||||
|
|
||||||
if (execp->backend->has_icon && execp->backend->icon) {
|
if (execp->backend->has_icon && execp->backend->icon) {
|
||||||
Imlib_Image tmp = imlib_context_get_image();
|
Imlib_Image tmp = imlib_context_get_image();
|
||||||
@@ -559,7 +540,7 @@ void execp_force_update(Execp *execp)
|
|||||||
|
|
||||||
void execp_action(void *obj, int button, int x, int y, Time time)
|
void execp_action(void *obj, int button, int x, int y, Time time)
|
||||||
{
|
{
|
||||||
Execp *execp = obj;
|
Execp *execp = (Execp *)obj;
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -579,17 +560,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 {
|
||||||
@@ -605,7 +584,7 @@ void execp_cmd_completed(Execp *execp, pid_t pid)
|
|||||||
|
|
||||||
void execp_timer_callback(void *arg)
|
void execp_timer_callback(void *arg)
|
||||||
{
|
{
|
||||||
Execp *execp = arg;
|
Execp *execp = (Execp *)arg;
|
||||||
|
|
||||||
if (!execp->backend->command)
|
if (!execp->backend->command)
|
||||||
return;
|
return;
|
||||||
@@ -729,7 +708,6 @@ gboolean read_execp(void *obj)
|
|||||||
} else if (execp->backend->continuous > 0) {
|
} else if (execp->backend->continuous > 0) {
|
||||||
// Count lines in buffer
|
// Count lines in buffer
|
||||||
int num_lines = 0;
|
int num_lines = 0;
|
||||||
char *last = execp->backend->buf_output;
|
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
for (char *c = execp->backend->buf_output; *c; c++) {
|
for (char *c = execp->backend->buf_output; *c; c++) {
|
||||||
if (*c == '\n') {
|
if (*c == '\n') {
|
||||||
@@ -737,10 +715,7 @@ gboolean read_execp(void *obj)
|
|||||||
if (num_lines == execp->backend->continuous)
|
if (num_lines == execp->backend->continuous)
|
||||||
end = c;
|
end = c;
|
||||||
}
|
}
|
||||||
last = c;
|
|
||||||
}
|
}
|
||||||
if (*last && *last != '\n')
|
|
||||||
num_lines++;
|
|
||||||
if (num_lines >= execp->backend->continuous) {
|
if (num_lines >= execp->backend->continuous) {
|
||||||
if (end)
|
if (end)
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
@@ -808,7 +783,7 @@ const char *time_to_string(int seconds, char *buffer)
|
|||||||
|
|
||||||
char *execp_get_tooltip(void *obj)
|
char *execp_get_tooltip(void *obj)
|
||||||
{
|
{
|
||||||
Execp *execp = obj;
|
Execp *execp = (Execp *)obj;
|
||||||
|
|
||||||
if (execp->backend->tooltip) {
|
if (execp->backend->tooltip) {
|
||||||
if (strlen(execp->backend->tooltip) > 0)
|
if (strlen(execp->backend->tooltip) > 0)
|
||||||
|
|||||||
@@ -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,20 +272,15 @@ 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) {
|
||||||
|
if (len > 0) {
|
||||||
// get ARGB icon
|
// get ARGB icon
|
||||||
int w, h;
|
int w, h;
|
||||||
gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1);
|
gulong *tmp_data = get_best_icon(data, get_icon_count(data, len), len, &w, &h, panel->g_task.icon_size1);
|
||||||
@@ -295,6 +297,7 @@ void task_update_icon(Task *task)
|
|||||||
h,
|
h,
|
||||||
task->title ? task->title : "task");
|
task->title ? task->title : "task");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
XFree(data);
|
XFree(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,9 +238,9 @@ void init_taskbar_panel(void *p)
|
|||||||
if ((panel->g_task.config_background_mask & (1 << TASK_URGENT)) == 0)
|
if ((panel->g_task.config_background_mask & (1 << TASK_URGENT)) == 0)
|
||||||
panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
|
panel->g_task.background[TASK_URGENT] = panel->g_task.background[TASK_ACTIVE];
|
||||||
|
|
||||||
if (!panel->g_task.maximum_width)
|
if (!panel->g_task.maximum_width || !panel_horizontal)
|
||||||
panel->g_task.maximum_width = server.monitors[panel->monitor].width;
|
panel->g_task.maximum_width = server.monitors[panel->monitor].width;
|
||||||
if (!panel->g_task.maximum_height)
|
if (!panel->g_task.maximum_height || panel_horizontal)
|
||||||
panel->g_task.maximum_height = server.monitors[panel->monitor].height;
|
panel->g_task.maximum_height = server.monitors[panel->monitor].height;
|
||||||
|
|
||||||
if (panel_horizontal) {
|
if (panel_horizontal) {
|
||||||
@@ -288,7 +288,8 @@ void init_taskbar_panel(void *p)
|
|||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr;
|
panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr;
|
||||||
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
|
panel->g_task.text_height =
|
||||||
|
panel->g_task.area.height - (2 * panel->g_task.area.paddingy) - top_bottom_border_width(&panel->g_task.area);
|
||||||
if (panel->g_task.has_icon) {
|
if (panel->g_task.has_icon) {
|
||||||
panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
|
panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
|
||||||
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
|
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
|
||||||
|
|||||||
@@ -463,6 +463,7 @@ void init(int argc, char *argv[])
|
|||||||
|
|
||||||
struct sigaction sa = {.sa_handler = signal_handler, .sa_flags = SA_RESTART};
|
struct sigaction sa = {.sa_handler = signal_handler, .sa_flags = SA_RESTART};
|
||||||
sigaction(SIGUSR1, &sa, 0);
|
sigaction(SIGUSR1, &sa, 0);
|
||||||
|
sigaction(SIGUSR2, &sa, 0);
|
||||||
sigaction(SIGINT, &sa, 0);
|
sigaction(SIGINT, &sa, 0);
|
||||||
sigaction(SIGTERM, &sa, 0);
|
sigaction(SIGTERM, &sa, 0);
|
||||||
sigaction(SIGHUP, &sa, 0);
|
sigaction(SIGHUP, &sa, 0);
|
||||||
@@ -652,6 +653,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;
|
||||||
@@ -2176,6 +2178,12 @@ start:
|
|||||||
// restart tint2
|
// restart tint2
|
||||||
// SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
|
// SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
|
||||||
goto start;
|
goto start;
|
||||||
|
} else if (signal_pending == SIGUSR2) {
|
||||||
|
fprintf(stderr, YELLOW "%s %d: reexecuting tint2..." RESET "\n", __FILE__, __LINE__);
|
||||||
|
if (execvp(argv[0], argv) == -1) {
|
||||||
|
fprintf(stderr, RED "%s %d: failed!" RESET "\n", __FILE__, __LINE__);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// SIGINT, SIGTERM, SIGHUP
|
// SIGINT, SIGTERM, SIGHUP
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
174
src/util/area.c
174
src/util/area.c
@@ -883,6 +883,180 @@ void area_dump_geometry(Area *area, int indent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void area_compute_text_geometry(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int *line1_height_ink,
|
||||||
|
int *line1_height,
|
||||||
|
int *line1_width,
|
||||||
|
int *line2_height_ink,
|
||||||
|
int *line2_height,
|
||||||
|
int *line2_width)
|
||||||
|
{
|
||||||
|
Panel *panel = (Panel *)area->panel;
|
||||||
|
int available_w, available_h;
|
||||||
|
if (panel_horizontal) {
|
||||||
|
available_w = panel->area.width;
|
||||||
|
available_h = area->height - 2 * area->paddingy - left_right_border_width(area);
|
||||||
|
} else {
|
||||||
|
available_w = area->width - 2 * area->paddingxlr - left_right_border_width(area);
|
||||||
|
available_h = panel->area.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line1 && line1[0])
|
||||||
|
get_text_size2(line1_font_desc,
|
||||||
|
line1_height_ink,
|
||||||
|
line1_height,
|
||||||
|
line1_width,
|
||||||
|
available_h,
|
||||||
|
available_w,
|
||||||
|
line1,
|
||||||
|
strlen(line1),
|
||||||
|
PANGO_WRAP_WORD_CHAR,
|
||||||
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
|
else
|
||||||
|
*line1_width = *line1_height_ink = *line1_height = 0;
|
||||||
|
|
||||||
|
if (line2 && line2[0])
|
||||||
|
get_text_size2(line2_font_desc,
|
||||||
|
line2_height_ink,
|
||||||
|
line2_height,
|
||||||
|
line2_width,
|
||||||
|
available_h,
|
||||||
|
available_w,
|
||||||
|
line2,
|
||||||
|
strlen(line2),
|
||||||
|
PANGO_WRAP_WORD_CHAR,
|
||||||
|
PANGO_ELLIPSIZE_NONE,
|
||||||
|
FALSE);
|
||||||
|
else
|
||||||
|
*line2_width = *line2_height_ink = *line2_height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int text_area_compute_desired_size(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc)
|
||||||
|
{
|
||||||
|
int line1_height_ink, line1_height, line1_width, line2_height_ink, line2_height, line2_width;
|
||||||
|
area_compute_text_geometry(area,
|
||||||
|
line1,
|
||||||
|
line2,
|
||||||
|
line1_font_desc,
|
||||||
|
line2_font_desc,
|
||||||
|
&line1_height_ink,
|
||||||
|
&line1_height,
|
||||||
|
&line1_width,
|
||||||
|
&line2_height_ink,
|
||||||
|
&line2_height,
|
||||||
|
&line2_width);
|
||||||
|
|
||||||
|
if (panel_horizontal) {
|
||||||
|
int new_size = MAX(line1_width, line2_width) + 2 * area->paddingxlr + left_right_border_width(area);
|
||||||
|
return new_size;
|
||||||
|
} else {
|
||||||
|
int new_size = line1_height + line2_height + 2 * area->paddingxlr + top_bottom_border_width(area);
|
||||||
|
return new_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean resize_text_area(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int *line1_posy,
|
||||||
|
int *line2_posy)
|
||||||
|
{
|
||||||
|
gboolean result = FALSE;
|
||||||
|
|
||||||
|
schedule_redraw(area);
|
||||||
|
|
||||||
|
int line1_height_ink, line1_height, line1_width;
|
||||||
|
int line2_height_ink, line2_height, line2_width;
|
||||||
|
area_compute_text_geometry(area,
|
||||||
|
line1,
|
||||||
|
line2,
|
||||||
|
line1_font_desc,
|
||||||
|
line2_font_desc,
|
||||||
|
&line1_height_ink,
|
||||||
|
&line1_height,
|
||||||
|
&line1_width,
|
||||||
|
&line2_height_ink,
|
||||||
|
&line2_height,
|
||||||
|
&line2_width);
|
||||||
|
|
||||||
|
int new_size = text_area_compute_desired_size(area,
|
||||||
|
line1,
|
||||||
|
line2,
|
||||||
|
line1_font_desc,
|
||||||
|
line2_font_desc);
|
||||||
|
if (panel_horizontal) {
|
||||||
|
if (new_size > area->width || new_size < (area->width - 6)) {
|
||||||
|
// we try to limit the number of resizes
|
||||||
|
area->width = new_size + 1;
|
||||||
|
*line1_posy = (area->height - line1_height) / 2;
|
||||||
|
if (line2) {
|
||||||
|
*line1_posy -= (line2_height) / 2;
|
||||||
|
*line2_posy = *line1_posy + line1_height;
|
||||||
|
}
|
||||||
|
result = TRUE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (new_size != area->height) {
|
||||||
|
// we try to limit the number of resizes
|
||||||
|
area->height = new_size;
|
||||||
|
*line1_posy = (area->height - line1_height) / 2;
|
||||||
|
if (line2) {
|
||||||
|
*line1_posy -= (line2_height) / 2;
|
||||||
|
*line2_posy = *line1_posy + line1_height;
|
||||||
|
}
|
||||||
|
result = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void draw_text_area(Area *area,
|
||||||
|
cairo_t *c,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int line1_posy,
|
||||||
|
int line2_posy,
|
||||||
|
Color *color)
|
||||||
|
{
|
||||||
|
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||||
|
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
|
||||||
|
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||||
|
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
||||||
|
pango_layout_set_width(layout, area->width * PANGO_SCALE);
|
||||||
|
cairo_set_source_rgba(c, color->rgb[0], color->rgb[1], color->rgb[2], color->alpha);
|
||||||
|
|
||||||
|
if (line1 && line1[0]) {
|
||||||
|
pango_layout_set_font_description(layout, line1_font_desc);
|
||||||
|
pango_layout_set_text(layout, line1, strlen(line1));
|
||||||
|
pango_cairo_update_layout(c, layout);
|
||||||
|
draw_text(layout, c, 0, line1_posy, color, ((Panel *)area->panel)->font_shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line2 && line2[0]) {
|
||||||
|
pango_layout_set_font_description(layout, line2_font_desc);
|
||||||
|
pango_layout_set_indent(layout, 0);
|
||||||
|
pango_layout_set_text(layout, line2, strlen(line2));
|
||||||
|
pango_cairo_update_layout(c, layout);
|
||||||
|
draw_text(layout, c, 0, line2_posy, color, ((Panel *)area->panel)->font_shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(layout);
|
||||||
|
}
|
||||||
|
|
||||||
Area *compute_element_area(Area *area, Element element)
|
Area *compute_element_area(Area *area, Element element)
|
||||||
{
|
{
|
||||||
if (element == ELEMENT_SELF)
|
if (element == ELEMENT_SELF)
|
||||||
|
|||||||
@@ -263,6 +263,39 @@ int relayout_with_constraint(Area *a, int maximum_size);
|
|||||||
int compute_desired_size(Area *a);
|
int compute_desired_size(Area *a);
|
||||||
int container_compute_desired_size(Area *a);
|
int container_compute_desired_size(Area *a);
|
||||||
|
|
||||||
|
void area_compute_text_geometry(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int *line1_height_ink,
|
||||||
|
int *line1_height,
|
||||||
|
int *line1_width,
|
||||||
|
int *line2_height_ink,
|
||||||
|
int *line2_height,
|
||||||
|
int *line2_width);
|
||||||
|
int text_area_compute_desired_size(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc);
|
||||||
|
gboolean resize_text_area(Area *area,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int *line1_posy,
|
||||||
|
int *line2_posy);
|
||||||
|
void draw_text_area(Area *area,
|
||||||
|
cairo_t *c,
|
||||||
|
const char *line1,
|
||||||
|
const char *line2,
|
||||||
|
PangoFontDescription *line1_font_desc,
|
||||||
|
PangoFontDescription *line2_font_desc,
|
||||||
|
int line1_posy,
|
||||||
|
int line2_posy,
|
||||||
|
Color *color);
|
||||||
|
|
||||||
int left_border_width(Area *a);
|
int left_border_width(Area *a);
|
||||||
int right_border_width(Area *a);
|
int right_border_width(Area *a);
|
||||||
int left_right_border_width(Area *a);
|
int left_right_border_width(Area *a);
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,35 +736,38 @@ void clear_pixmap(Pixmap p, int x, int y, int w, int h)
|
|||||||
XRenderFreePicture(server.display, pict);
|
XRenderFreePicture(server.display, pict);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_text_size2(PangoFontDescription *font,
|
void get_text_size2(const PangoFontDescription *font,
|
||||||
int *height_ink,
|
int *height_ink,
|
||||||
int *height,
|
int *height,
|
||||||
int *width,
|
int *width,
|
||||||
int panel_height,
|
int available_height,
|
||||||
int panel_width,
|
int available_width,
|
||||||
char *text,
|
const char *text,
|
||||||
int len,
|
int text_len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis,
|
PangoEllipsizeMode ellipsis,
|
||||||
gboolean markup)
|
gboolean markup)
|
||||||
{
|
{
|
||||||
PangoRectangle rect_ink, rect;
|
PangoRectangle rect_ink, rect;
|
||||||
|
|
||||||
Pixmap pmap = XCreatePixmap(server.display, server.root_win, panel_height, panel_width, server.depth);
|
available_width = MAX(0, available_width);
|
||||||
|
available_height = MAX(0, available_height);
|
||||||
|
Pixmap pmap = XCreatePixmap(server.display, server.root_win, available_height, available_width, server.depth);
|
||||||
|
|
||||||
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, pmap, server.visual, panel_height, panel_width);
|
cairo_surface_t *cs = cairo_xlib_surface_create(server.display, pmap, server.visual, available_height, available_width);
|
||||||
cairo_t *c = cairo_create(cs);
|
cairo_t *c = cairo_create(cs);
|
||||||
|
|
||||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||||
pango_layout_set_width(layout, panel_width * PANGO_SCALE);
|
pango_layout_set_width(layout, available_width * PANGO_SCALE);
|
||||||
pango_layout_set_height(layout, panel_height * PANGO_SCALE);
|
pango_layout_set_height(layout, available_height * PANGO_SCALE);
|
||||||
pango_layout_set_wrap(layout, wrap);
|
pango_layout_set_wrap(layout, wrap);
|
||||||
pango_layout_set_ellipsize(layout, ellipsis);
|
pango_layout_set_ellipsize(layout, ellipsis);
|
||||||
pango_layout_set_font_description(layout, font);
|
pango_layout_set_font_description(layout, font);
|
||||||
|
text_len = MAX(0, text_len);
|
||||||
if (!markup)
|
if (!markup)
|
||||||
pango_layout_set_text(layout, text, len);
|
pango_layout_set_text(layout, text, text_len);
|
||||||
else
|
else
|
||||||
pango_layout_set_markup(layout, text, len);
|
pango_layout_set_markup(layout, text, text_len);
|
||||||
|
|
||||||
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
|
pango_layout_get_pixel_extents(layout, &rect_ink, &rect);
|
||||||
*height_ink = rect_ink.height;
|
*height_ink = rect_ink.height;
|
||||||
|
|||||||
@@ -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.
|
||||||
@@ -94,14 +95,14 @@ void create_heuristic_mask(DATA32 *data, int w, int h);
|
|||||||
// Renders the current Imlib image to a drawable. Wrapper around imlib_render_image_on_drawable.
|
// Renders the current Imlib image to a drawable. Wrapper around imlib_render_image_on_drawable.
|
||||||
void render_image(Drawable d, int x, int y);
|
void render_image(Drawable d, int x, int y);
|
||||||
|
|
||||||
void get_text_size2(PangoFontDescription *font,
|
void get_text_size2(const PangoFontDescription *font,
|
||||||
int *height_ink,
|
int *height_ink,
|
||||||
int *height,
|
int *height,
|
||||||
int *width,
|
int *width,
|
||||||
int panel_height,
|
int available_height,
|
||||||
int panel_with,
|
int available_with,
|
||||||
char *text,
|
const char *text,
|
||||||
int len,
|
int text_len,
|
||||||
PangoWrapMode wrap,
|
PangoWrapMode wrap,
|
||||||
PangoEllipsizeMode ellipsis,
|
PangoEllipsizeMode ellipsis,
|
||||||
gboolean markup);
|
gboolean markup);
|
||||||
|
|||||||
Reference in New Issue
Block a user