Code cleanup
This commit is contained in:
parent
7025cc399e
commit
3790723483
14 changed files with 709 additions and 720 deletions
|
@ -57,6 +57,146 @@ char *battery_dwheel_command;
|
|||
gboolean battery_found;
|
||||
|
||||
void battery_init_fonts();
|
||||
char *battery_get_tooltip(void *obj);
|
||||
|
||||
void default_battery()
|
||||
{
|
||||
battery_enabled = FALSE;
|
||||
battery_tooltip_enabled = TRUE;
|
||||
battery_found = FALSE;
|
||||
percentage_hide = 101;
|
||||
battery_low_cmd_sent = FALSE;
|
||||
battery_timeout = NULL;
|
||||
bat1_has_font = FALSE;
|
||||
bat1_font_desc = NULL;
|
||||
bat2_has_font = FALSE;
|
||||
bat2_font_desc = NULL;
|
||||
ac_connected_cmd = NULL;
|
||||
ac_disconnected_cmd = NULL;
|
||||
battery_low_cmd = NULL;
|
||||
battery_lclick_command = NULL;
|
||||
battery_mclick_command = NULL;
|
||||
battery_rclick_command = NULL;
|
||||
battery_uwheel_command = NULL;
|
||||
battery_dwheel_command = NULL;
|
||||
battery_state.percentage = 0;
|
||||
battery_state.time.hours = 0;
|
||||
battery_state.time.minutes = 0;
|
||||
battery_state.time.seconds = 0;
|
||||
battery_state.state = BATTERY_UNKNOWN;
|
||||
}
|
||||
|
||||
void cleanup_battery()
|
||||
{
|
||||
pango_font_description_free(bat1_font_desc);
|
||||
bat1_font_desc = NULL;
|
||||
pango_font_description_free(bat2_font_desc);
|
||||
bat2_font_desc = NULL;
|
||||
free(battery_low_cmd);
|
||||
battery_low_cmd = NULL;
|
||||
free(battery_lclick_command);
|
||||
battery_lclick_command = NULL;
|
||||
free(battery_mclick_command);
|
||||
battery_mclick_command = NULL;
|
||||
free(battery_rclick_command);
|
||||
battery_rclick_command = NULL;
|
||||
free(battery_uwheel_command);
|
||||
battery_uwheel_command = NULL;
|
||||
free(battery_dwheel_command);
|
||||
battery_dwheel_command = NULL;
|
||||
free(ac_connected_cmd);
|
||||
ac_connected_cmd = NULL;
|
||||
free(ac_disconnected_cmd);
|
||||
ac_disconnected_cmd = NULL;
|
||||
stop_timeout(battery_timeout);
|
||||
battery_timeout = NULL;
|
||||
battery_found = FALSE;
|
||||
|
||||
battery_os_free();
|
||||
}
|
||||
|
||||
void init_battery()
|
||||
{
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
|
||||
battery_found = battery_os_init();
|
||||
|
||||
if (!battery_timeout)
|
||||
battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout);
|
||||
|
||||
update_battery();
|
||||
}
|
||||
|
||||
void reinit_battery()
|
||||
{
|
||||
battery_os_free();
|
||||
battery_found = battery_os_init();
|
||||
update_battery();
|
||||
}
|
||||
|
||||
void init_battery_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
Battery *battery = &panel->battery;
|
||||
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
|
||||
battery_init_fonts();
|
||||
|
||||
if (!battery->area.bg)
|
||||
battery->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
|
||||
battery->area.parent = p;
|
||||
battery->area.panel = p;
|
||||
battery->area._draw_foreground = draw_battery;
|
||||
battery->area.size_mode = LAYOUT_FIXED;
|
||||
battery->area._resize = resize_battery;
|
||||
battery->area.on_screen = TRUE;
|
||||
battery->area.resize_needed = 1;
|
||||
battery->area.has_mouse_over_effect = battery_lclick_command || battery_mclick_command || battery_rclick_command ||
|
||||
battery_uwheel_command || battery_dwheel_command;
|
||||
battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect;
|
||||
if (battery_tooltip_enabled)
|
||||
battery->area._get_tooltip_text = battery_get_tooltip;
|
||||
}
|
||||
|
||||
void battery_init_fonts()
|
||||
{
|
||||
if (!bat1_font_desc) {
|
||||
bat1_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(bat1_font_desc,
|
||||
pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
if (!bat2_font_desc) {
|
||||
bat2_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(bat2_font_desc,
|
||||
pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void battery_default_font_changed()
|
||||
{
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
if (bat1_has_font && bat2_has_font)
|
||||
return;
|
||||
if (!bat1_has_font) {
|
||||
pango_font_description_free(bat1_font_desc);
|
||||
bat1_font_desc = NULL;
|
||||
}
|
||||
if (!bat2_has_font) {
|
||||
pango_font_description_free(bat2_font_desc);
|
||||
bat2_font_desc = NULL;
|
||||
}
|
||||
battery_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
panels[i].battery.area.resize_needed = TRUE;
|
||||
panels[i].battery.area.redraw_needed = TRUE;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void update_battery_tick(void *arg)
|
||||
{
|
||||
|
@ -126,162 +266,17 @@ void update_battery_tick(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
void default_battery()
|
||||
{
|
||||
battery_enabled = FALSE;
|
||||
battery_tooltip_enabled = TRUE;
|
||||
battery_found = FALSE;
|
||||
percentage_hide = 101;
|
||||
battery_low_cmd_sent = FALSE;
|
||||
battery_timeout = NULL;
|
||||
bat1_has_font = FALSE;
|
||||
bat1_font_desc = NULL;
|
||||
bat2_has_font = FALSE;
|
||||
bat2_font_desc = NULL;
|
||||
ac_connected_cmd = NULL;
|
||||
ac_disconnected_cmd = NULL;
|
||||
battery_low_cmd = NULL;
|
||||
battery_lclick_command = NULL;
|
||||
battery_mclick_command = NULL;
|
||||
battery_rclick_command = NULL;
|
||||
battery_uwheel_command = NULL;
|
||||
battery_dwheel_command = NULL;
|
||||
battery_state.percentage = 0;
|
||||
battery_state.time.hours = 0;
|
||||
battery_state.time.minutes = 0;
|
||||
battery_state.time.seconds = 0;
|
||||
battery_state.state = BATTERY_UNKNOWN;
|
||||
}
|
||||
|
||||
void cleanup_battery()
|
||||
{
|
||||
pango_font_description_free(bat1_font_desc);
|
||||
bat1_font_desc = NULL;
|
||||
pango_font_description_free(bat2_font_desc);
|
||||
bat2_font_desc = NULL;
|
||||
free(battery_low_cmd);
|
||||
battery_low_cmd = NULL;
|
||||
free(battery_lclick_command);
|
||||
battery_lclick_command = NULL;
|
||||
free(battery_mclick_command);
|
||||
battery_mclick_command = NULL;
|
||||
free(battery_rclick_command);
|
||||
battery_rclick_command = NULL;
|
||||
free(battery_uwheel_command);
|
||||
battery_uwheel_command = NULL;
|
||||
free(battery_dwheel_command);
|
||||
battery_dwheel_command = NULL;
|
||||
free(ac_connected_cmd);
|
||||
ac_connected_cmd = NULL;
|
||||
free(ac_disconnected_cmd);
|
||||
ac_disconnected_cmd = NULL;
|
||||
stop_timeout(battery_timeout);
|
||||
battery_timeout = NULL;
|
||||
battery_found = FALSE;
|
||||
|
||||
battery_os_free();
|
||||
}
|
||||
|
||||
void reinit_battery()
|
||||
{
|
||||
battery_os_free();
|
||||
battery_found = battery_os_init();
|
||||
update_battery();
|
||||
}
|
||||
void init_battery()
|
||||
{
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
|
||||
battery_found = battery_os_init();
|
||||
|
||||
if (!battery_timeout)
|
||||
battery_timeout = add_timeout(10, 30000, update_battery_tick, 0, &battery_timeout);
|
||||
|
||||
update_battery();
|
||||
}
|
||||
|
||||
char *battery_get_tooltip(void *obj)
|
||||
{
|
||||
return battery_os_tooltip();
|
||||
}
|
||||
|
||||
void init_battery_panel(void *p)
|
||||
{
|
||||
Panel *panel = (Panel *)p;
|
||||
Battery *battery = &panel->battery;
|
||||
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
|
||||
battery_init_fonts();
|
||||
|
||||
if (!battery->area.bg)
|
||||
battery->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
|
||||
battery->area.parent = p;
|
||||
battery->area.panel = p;
|
||||
battery->area._draw_foreground = draw_battery;
|
||||
battery->area.size_mode = LAYOUT_FIXED;
|
||||
battery->area._resize = resize_battery;
|
||||
battery->area.on_screen = TRUE;
|
||||
battery->area.resize_needed = 1;
|
||||
battery->area.has_mouse_over_effect = battery_lclick_command || battery_mclick_command || battery_rclick_command ||
|
||||
battery_uwheel_command || battery_dwheel_command;
|
||||
battery->area.has_mouse_press_effect = battery->area.has_mouse_over_effect;
|
||||
if (battery_tooltip_enabled)
|
||||
battery->area._get_tooltip_text = battery_get_tooltip;
|
||||
}
|
||||
|
||||
void battery_init_fonts()
|
||||
{
|
||||
if (!bat1_font_desc) {
|
||||
bat1_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(bat1_font_desc,
|
||||
pango_font_description_get_size(bat1_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
if (!bat2_font_desc) {
|
||||
bat2_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(bat2_font_desc,
|
||||
pango_font_description_get_size(bat2_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void battery_default_font_changed()
|
||||
{
|
||||
if (!battery_enabled)
|
||||
return;
|
||||
if (bat1_has_font && bat2_has_font)
|
||||
return;
|
||||
if (!bat1_has_font) {
|
||||
pango_font_description_free(bat1_font_desc);
|
||||
bat1_font_desc = NULL;
|
||||
}
|
||||
if (!bat2_has_font) {
|
||||
pango_font_description_free(bat2_font_desc);
|
||||
bat2_font_desc = NULL;
|
||||
}
|
||||
battery_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
panels[i].battery.area.resize_needed = TRUE;
|
||||
panels[i].battery.area.redraw_needed = TRUE;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
int update_battery()
|
||||
{
|
||||
int err;
|
||||
|
||||
/* reset */
|
||||
// Reset
|
||||
battery_state.state = BATTERY_UNKNOWN;
|
||||
battery_state.percentage = 0;
|
||||
battery_state.ac_connected = FALSE;
|
||||
battery_state_set_time(&battery_state, 0);
|
||||
|
||||
err = battery_os_update(&battery_state);
|
||||
int err = battery_os_update(&battery_state);
|
||||
|
||||
// clamp percentage to 100 in case battery is misreporting that its current charge is more than its max
|
||||
// Clamp percentage to 100 in case battery is misreporting that its current charge is more than its max
|
||||
if (battery_state.percentage > 100) {
|
||||
battery_state.percentage = 100;
|
||||
}
|
||||
|
@ -289,40 +284,6 @@ int update_battery()
|
|||
return err;
|
||||
}
|
||||
|
||||
void draw_battery(void *obj, cairo_t *c)
|
||||
{
|
||||
Battery *battery = obj;
|
||||
PangoLayout *layout;
|
||||
|
||||
layout = pango_cairo_create_layout(c);
|
||||
|
||||
// draw layout
|
||||
pango_layout_set_font_description(layout, bat1_font_desc);
|
||||
pango_layout_set_width(layout, battery->area.width * PANGO_SCALE);
|
||||
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_text(layout, buf_bat_percentage, strlen(buf_bat_percentage));
|
||||
|
||||
cairo_set_source_rgba(c, battery->font.rgb[0], battery->font.rgb[1], battery->font.rgb[2], battery->font.alpha);
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout, c, 0, battery->bat1_posy, &battery->font, ((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, ((Panel *)battery->area.panel)->font_shadow);
|
||||
pango_cairo_show_layout(c, layout);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
gboolean resize_battery(void *obj)
|
||||
{
|
||||
Battery *battery = obj;
|
||||
|
@ -385,9 +346,49 @@ gboolean resize_battery(void *obj)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void draw_battery(void *obj, cairo_t *c)
|
||||
{
|
||||
Battery *battery = obj;
|
||||
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
pango_layout_set_font_description(layout, bat1_font_desc);
|
||||
pango_layout_set_width(layout, battery->area.width * PANGO_SCALE);
|
||||
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_text(layout, buf_bat_percentage, strlen(buf_bat_percentage));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
char *battery_get_tooltip(void *obj)
|
||||
{
|
||||
return battery_os_tooltip();
|
||||
}
|
||||
|
||||
void battery_action(int button)
|
||||
{
|
||||
char *command = 0;
|
||||
char *command = NULL;
|
||||
switch (button) {
|
||||
case 1:
|
||||
command = battery_lclick_command;
|
||||
|
|
|
@ -16,12 +16,9 @@
|
|||
#include "common.h"
|
||||
#include "area.h"
|
||||
|
||||
// battery drawing parameter (per panel)
|
||||
typedef struct Battery {
|
||||
// always start with area
|
||||
Area area;
|
||||
|
||||
Color font;
|
||||
Color font_color;
|
||||
int bat1_posy;
|
||||
int bat2_posy;
|
||||
} Battery;
|
||||
|
|
|
@ -54,6 +54,7 @@ int clock_enabled;
|
|||
static timeout *clock_timeout;
|
||||
|
||||
void clock_init_fonts();
|
||||
char *clock_get_tooltip(void *obj);
|
||||
|
||||
void default_clock()
|
||||
{
|
||||
|
@ -111,9 +112,8 @@ void cleanup_clock()
|
|||
void update_clocks_sec(void *arg)
|
||||
{
|
||||
gettimeofday(&time_clock, 0);
|
||||
int i;
|
||||
if (time1_format) {
|
||||
for (i = 0; i < num_panels; i++)
|
||||
for (int i = 0; i < num_panels; i++)
|
||||
panels[i].clock.area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
|
@ -126,9 +126,8 @@ void update_clocks_min(void *arg)
|
|||
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) {
|
||||
int i;
|
||||
if (time1_format) {
|
||||
for (i = 0; i < num_panels; i++)
|
||||
for (int i = 0; i < num_panels; i++)
|
||||
panels[i].clock.area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
|
@ -146,23 +145,18 @@ struct tm *clock_gettime_for_tz(const char *timezone)
|
|||
else
|
||||
unsetenv("TZ");
|
||||
return result;
|
||||
} else
|
||||
} else {
|
||||
return localtime(&time_clock.tv_sec);
|
||||
}
|
||||
}
|
||||
|
||||
char *clock_get_tooltip(void *obj)
|
||||
{
|
||||
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
||||
return strdup(buf_tooltip);
|
||||
}
|
||||
|
||||
int time_format_needs_sec_ticks(char *time_format)
|
||||
gboolean time_format_needs_sec_ticks(char *time_format)
|
||||
{
|
||||
if (!time_format)
|
||||
return 0;
|
||||
return FALSE;
|
||||
if (strchr(time_format, 'S') || strchr(time_format, 'T') || strchr(time_format, 'r'))
|
||||
return 1;
|
||||
return 0;
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void init_clock()
|
||||
|
@ -242,44 +236,12 @@ void clock_default_font_changed()
|
|||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void draw_clock(void *obj, cairo_t *c)
|
||||
{
|
||||
Clock *clock = obj;
|
||||
PangoLayout *layout;
|
||||
|
||||
layout = pango_cairo_create_layout(c);
|
||||
|
||||
// draw layout
|
||||
pango_layout_set_font_description(layout, time1_font_desc);
|
||||
pango_layout_set_width(layout, clock->area.width * PANGO_SCALE);
|
||||
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_text(layout, buf_time, strlen(buf_time));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
gboolean resize_clock(void *obj)
|
||||
{
|
||||
Clock *clock = obj;
|
||||
Panel *panel = clock->area.panel;
|
||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width, ret = 0;
|
||||
int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width;
|
||||
gboolean result = FALSE;
|
||||
|
||||
clock->area.redraw_needed = TRUE;
|
||||
|
||||
|
@ -322,7 +284,7 @@ gboolean resize_clock(void *obj)
|
|||
clock->time1_posy -= (date_height) / 2;
|
||||
clock->time2_posy = clock->time1_posy + time_height;
|
||||
}
|
||||
ret = 1;
|
||||
result = TRUE;
|
||||
}
|
||||
} else {
|
||||
int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width));
|
||||
|
@ -334,16 +296,52 @@ gboolean resize_clock(void *obj)
|
|||
clock->time1_posy -= (date_height) / 2;
|
||||
clock->time2_posy = clock->time1_posy + time_height;
|
||||
}
|
||||
ret = 1;
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return result;
|
||||
}
|
||||
|
||||
void draw_clock(void *obj, cairo_t *c)
|
||||
{
|
||||
Clock *clock = obj;
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
|
||||
pango_layout_set_font_description(layout, time1_font_desc);
|
||||
pango_layout_set_width(layout, clock->area.width * PANGO_SCALE);
|
||||
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_text(layout, buf_time, strlen(buf_time));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
char *clock_get_tooltip(void *obj)
|
||||
{
|
||||
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
||||
return strdup(buf_tooltip);
|
||||
}
|
||||
|
||||
void clock_action(int button)
|
||||
{
|
||||
char *command = 0;
|
||||
char *command = NULL;
|
||||
switch (button) {
|
||||
case 1:
|
||||
command = clock_lclick_command;
|
||||
|
@ -363,4 +361,3 @@ void clock_action(int button)
|
|||
}
|
||||
tint_exec(command);
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,6 @@ void add_entry(char *key, char *value)
|
|||
} else if (strcmp(key, "panel_items") == 0) {
|
||||
new_config_file = 1;
|
||||
panel_items_order = strdup(value);
|
||||
int j;
|
||||
systray_enabled = 0;
|
||||
launcher_enabled = 0;
|
||||
#ifdef ENABLE_BATTERY
|
||||
|
@ -326,7 +325,7 @@ void add_entry(char *key, char *value)
|
|||
#endif
|
||||
clock_enabled = 0;
|
||||
taskbar_enabled = 0;
|
||||
for (j = 0; j < strlen(panel_items_order); j++) {
|
||||
for (int j = 0; j < strlen(panel_items_order); j++) {
|
||||
if (panel_items_order[j] == 'L')
|
||||
launcher_enabled = 1;
|
||||
if (panel_items_order[j] == 'T')
|
||||
|
@ -477,11 +476,11 @@ void add_entry(char *key, char *value)
|
|||
} else if (strcmp(key, "battery_font_color") == 0) {
|
||||
#ifdef ENABLE_BATTERY
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, panel_config.battery.font.rgb);
|
||||
get_color(value1, panel_config.battery.font_color.rgb);
|
||||
if (value2)
|
||||
panel_config.battery.font.alpha = (atoi(value2) / 100.0);
|
||||
panel_config.battery.font_color.alpha = (atoi(value2) / 100.0);
|
||||
else
|
||||
panel_config.battery.font.alpha = 0.5;
|
||||
panel_config.battery.font_color.alpha = 0.5;
|
||||
#endif
|
||||
} else if (strcmp(key, "battery_padding") == 0) {
|
||||
#ifdef ENABLE_BATTERY
|
||||
|
|
|
@ -273,39 +273,6 @@ gboolean reload_icon(Execp *execp)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void draw_execp(void *obj, cairo_t *c)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
|
||||
if (execp->backend->has_icon && execp->backend->icon) {
|
||||
imlib_context_set_image(execp->backend->icon);
|
||||
// Render icon
|
||||
render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony);
|
||||
}
|
||||
|
||||
// draw layout
|
||||
pango_layout_set_font_description(layout, execp->backend->font_desc);
|
||||
pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE);
|
||||
pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT);
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
||||
if (!execp->backend->has_markup)
|
||||
pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text));
|
||||
else
|
||||
pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text));
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout,
|
||||
c,
|
||||
execp->frontend->textx,
|
||||
execp->frontend->texty,
|
||||
&execp->backend->font_color,
|
||||
panel_config.font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
gboolean resize_execp(void *obj)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
|
@ -428,6 +395,39 @@ gboolean resize_execp(void *obj)
|
|||
return result;
|
||||
}
|
||||
|
||||
void draw_execp(void *obj, cairo_t *c)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
|
||||
if (execp->backend->has_icon && execp->backend->icon) {
|
||||
imlib_context_set_image(execp->backend->icon);
|
||||
// Render icon
|
||||
render_image(execp->area.pix, execp->frontend->iconx, execp->frontend->icony);
|
||||
}
|
||||
|
||||
// draw layout
|
||||
pango_layout_set_font_description(layout, execp->backend->font_desc);
|
||||
pango_layout_set_width(layout, execp->frontend->textw * PANGO_SCALE);
|
||||
pango_layout_set_alignment(layout, execp->backend->centered ? PANGO_ALIGN_CENTER : PANGO_ALIGN_LEFT);
|
||||
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
|
||||
if (!execp->backend->has_markup)
|
||||
pango_layout_set_text(layout, execp->backend->text, strlen(execp->backend->text));
|
||||
else
|
||||
pango_layout_set_markup(layout, execp->backend->text, strlen(execp->backend->text));
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout,
|
||||
c,
|
||||
execp->frontend->textx,
|
||||
execp->frontend->texty,
|
||||
&execp->backend->font_color,
|
||||
panel_config.font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
void execp_action(void *obj, int button)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
|
|
|
@ -48,9 +48,8 @@ void init_freespace_panel(void *p)
|
|||
int freespace_get_max_size(Panel *p)
|
||||
{
|
||||
// Get space used by every element except the freespace
|
||||
GList *walk;
|
||||
int size = 0;
|
||||
for (walk = p->area.children; walk; walk = g_list_next(walk)) {
|
||||
for (GList *walk = p->area.children; walk; walk = g_list_next(walk)) {
|
||||
Area *a = (Area *)walk->data;
|
||||
|
||||
if (a->_resize == resize_freespace || !a->on_screen)
|
||||
|
@ -75,12 +74,12 @@ gboolean resize_freespace(void *obj)
|
|||
FreeSpace *freespace = (FreeSpace *)obj;
|
||||
Panel *panel = (Panel *)freespace->area.panel;
|
||||
if (!freespace->area.on_screen)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
int old_size = panel_horizontal ? freespace->area.width : freespace->area.height;
|
||||
int size = freespace_get_max_size(panel);
|
||||
if (old_size == size)
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
if (panel_horizontal) {
|
||||
freespace->area.width = size;
|
||||
|
@ -90,5 +89,5 @@ gboolean resize_freespace(void *obj)
|
|||
|
||||
freespace->area.redraw_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -107,16 +107,13 @@ void init_launcher_panel(void *p)
|
|||
|
||||
void cleanup_launcher()
|
||||
{
|
||||
int i;
|
||||
GSList *l;
|
||||
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Panel *panel = &panels[i];
|
||||
Launcher *launcher = &panel->launcher;
|
||||
cleanup_launcher_theme(launcher);
|
||||
}
|
||||
|
||||
for (l = panel_config.launcher.list_apps; l; l = l->next) {
|
||||
for (GSList *l = panel_config.launcher.list_apps; l; l = l->next) {
|
||||
free(l->data);
|
||||
}
|
||||
g_slist_free(panel_config.launcher.list_apps);
|
||||
|
@ -128,14 +125,13 @@ void cleanup_launcher()
|
|||
free(icon_theme_name_xsettings);
|
||||
icon_theme_name_xsettings = NULL;
|
||||
|
||||
launcher_enabled = 0;
|
||||
launcher_enabled = FALSE;
|
||||
}
|
||||
|
||||
void cleanup_launcher_theme(Launcher *launcher)
|
||||
{
|
||||
free_area(&launcher->area);
|
||||
GSList *l;
|
||||
for (l = launcher->list_icons; l; l = l->next) {
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon) {
|
||||
free_icon(launcherIcon->image);
|
||||
|
@ -158,10 +154,9 @@ void cleanup_launcher_theme(Launcher *launcher)
|
|||
gboolean resize_launcher(void *obj)
|
||||
{
|
||||
Launcher *launcher = obj;
|
||||
GSList *l;
|
||||
int count, icon_size;
|
||||
int icons_per_column = 1, icons_per_row = 1, margin = 0;
|
||||
|
||||
int icon_size;
|
||||
if (panel_horizontal) {
|
||||
icon_size = launcher->area.height;
|
||||
} else {
|
||||
|
@ -172,7 +167,7 @@ gboolean resize_launcher(void *obj)
|
|||
icon_size = launcher_max_icon_size;
|
||||
|
||||
// Resize icons if necessary
|
||||
for (l = launcher->list_icons; l; l = l->next) {
|
||||
for (GSList *l = launcher->list_icons; l; l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
if (launcherIcon->icon_size != icon_size || !launcherIcon->image) {
|
||||
launcherIcon->icon_size = icon_size;
|
||||
|
@ -231,7 +226,7 @@ gboolean resize_launcher(void *obj)
|
|||
}
|
||||
}
|
||||
|
||||
count = g_slist_length(launcher->list_icons);
|
||||
int count = g_slist_length(launcher->list_icons);
|
||||
|
||||
if (panel_horizontal) {
|
||||
if (!count) {
|
||||
|
@ -259,7 +254,7 @@ gboolean resize_launcher(void *obj)
|
|||
}
|
||||
}
|
||||
|
||||
int i, posx, posy;
|
||||
int posx, posy;
|
||||
int start = launcher->area.bg->border.width + launcher->area.paddingy + margin / 2;
|
||||
if (panel_horizontal) {
|
||||
posy = start;
|
||||
|
@ -269,6 +264,8 @@ gboolean resize_launcher(void *obj)
|
|||
posy = launcher->area.bg->border.width + launcher->area.paddingxlr;
|
||||
}
|
||||
|
||||
int i;
|
||||
GSList *l;
|
||||
for (i = 1, l = launcher->list_icons; l; i++, l = l->next) {
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
|
||||
|
||||
|
@ -296,7 +293,7 @@ gboolean resize_launcher(void *obj)
|
|||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Here we override the default layout of the icons; normally Area layouts its children
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct LauncherIcon {
|
|||
int x, y;
|
||||
} LauncherIcon;
|
||||
|
||||
extern int launcher_enabled;
|
||||
extern gboolean launcher_enabled;
|
||||
extern int launcher_max_icon_size;
|
||||
extern int launcher_tooltip_enabled;
|
||||
extern int launcher_alpha;
|
||||
|
|
|
@ -137,7 +137,7 @@ void cleanup_server()
|
|||
if (server.gc)
|
||||
XFreeGC(server.dsp, server.gc);
|
||||
server.gc = NULL;
|
||||
server.disable_transparency = 0;
|
||||
server.disable_transparency = FALSE;
|
||||
}
|
||||
|
||||
void send_event32(Window win, Atom at, long data1, long data2, long data3)
|
||||
|
@ -565,14 +565,14 @@ void server_init_visual()
|
|||
attrs.event_mask = StructureNotifyMask;
|
||||
XChangeWindowAttributes(server.dsp, server.composite_manager, CWEventMask, &attrs);
|
||||
|
||||
server.real_transparency = 1;
|
||||
server.real_transparency = TRUE;
|
||||
server.depth = 32;
|
||||
printf("real transparency on... depth: %d\n", server.depth);
|
||||
server.colormap = XCreateColormap(server.dsp, server.root_win, visual, AllocNone);
|
||||
server.visual = visual;
|
||||
} else {
|
||||
// no composite manager or snapshot mode => fake transparency
|
||||
server.real_transparency = 0;
|
||||
server.real_transparency = FALSE;
|
||||
server.depth = DefaultDepth(server.dsp, server.screen);
|
||||
printf("real transparency off.... depth: %d\n", server.depth);
|
||||
server.colormap = DefaultColormap(server.dsp, server.screen);
|
||||
|
|
|
@ -110,8 +110,8 @@ typedef struct Server {
|
|||
Display *dsp;
|
||||
Window root_win;
|
||||
Window composite_manager;
|
||||
int real_transparency;
|
||||
int disable_transparency;
|
||||
gboolean real_transparency;
|
||||
gboolean disable_transparency;
|
||||
// current desktop
|
||||
int desktop;
|
||||
int screen;
|
||||
|
@ -123,7 +123,7 @@ typedef struct Server {
|
|||
// In that case there are num_desktops viewports.
|
||||
Viewport *viewports;
|
||||
Monitor *monitor;
|
||||
int got_root_win;
|
||||
gboolean got_root_win;
|
||||
Visual *visual;
|
||||
Visual *visual32;
|
||||
// root background
|
||||
|
|
|
@ -122,37 +122,11 @@ void init_systray_panel(void *p)
|
|||
refresh_systray = 1;
|
||||
}
|
||||
|
||||
void draw_systray(void *obj, cairo_t *c)
|
||||
{
|
||||
if (systray_profile)
|
||||
fprintf(stderr, BLUE "[%f] %s:%d\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
if (systray_composited) {
|
||||
if (render_background)
|
||||
XFreePixmap(server.dsp, render_background);
|
||||
render_background =
|
||||
XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
|
||||
XCopyArea(server.dsp,
|
||||
systray.area.pix,
|
||||
render_background,
|
||||
server.gc,
|
||||
0,
|
||||
0,
|
||||
systray.area.width,
|
||||
systray.area.height,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
refresh_systray = 1;
|
||||
}
|
||||
|
||||
gboolean resize_systray(void *obj)
|
||||
{
|
||||
if (systray_profile)
|
||||
fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
Systraybar *sysbar = obj;
|
||||
GSList *l;
|
||||
int count;
|
||||
|
||||
if (panel_horizontal)
|
||||
sysbar->icon_size = sysbar->area.height;
|
||||
|
@ -174,8 +148,8 @@ gboolean resize_systray(void *obj)
|
|||
1);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
int count = 0;
|
||||
for (GSList *l = systray.list_icons; l; l = l->next) {
|
||||
if (((TrayWindow *)l->data)->hide)
|
||||
continue;
|
||||
count++;
|
||||
|
@ -209,7 +183,31 @@ gboolean resize_systray(void *obj)
|
|||
start_net();
|
||||
}
|
||||
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void draw_systray(void *obj, cairo_t *c)
|
||||
{
|
||||
if (systray_profile)
|
||||
fprintf(stderr, BLUE "[%f] %s:%d\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
if (systray_composited) {
|
||||
if (render_background)
|
||||
XFreePixmap(server.dsp, render_background);
|
||||
render_background =
|
||||
XCreatePixmap(server.dsp, server.root_win, systray.area.width, systray.area.height, server.depth);
|
||||
XCopyArea(server.dsp,
|
||||
systray.area.pix,
|
||||
render_background,
|
||||
server.gc,
|
||||
0,
|
||||
0,
|
||||
systray.area.width,
|
||||
systray.area.height,
|
||||
0,
|
||||
0);
|
||||
}
|
||||
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
void on_change_systray(void *obj)
|
||||
|
@ -222,7 +220,7 @@ void on_change_systray(void *obj)
|
|||
return;
|
||||
|
||||
Panel *panel = sysbar->area.panel;
|
||||
int i, posx, posy;
|
||||
int posx, posy;
|
||||
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width +
|
||||
systray.area.paddingy + sysbar->margin / 2;
|
||||
if (panel_horizontal) {
|
||||
|
@ -235,6 +233,7 @@ void on_change_systray(void *obj)
|
|||
|
||||
TrayWindow *traywin;
|
||||
GSList *l;
|
||||
int i;
|
||||
for (i = 1, l = systray.list_icons; l; i++, l = l->next) {
|
||||
traywin = (TrayWindow *)l->data;
|
||||
if (traywin->hide)
|
||||
|
@ -293,7 +292,7 @@ void on_change_systray(void *obj)
|
|||
if (!traywin->reparented)
|
||||
reparent_icon(traywin);
|
||||
}
|
||||
refresh_systray = 1;
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
// ***********************************************
|
||||
|
@ -426,10 +425,9 @@ void net_message(XClientMessageEvent *e)
|
|||
{
|
||||
if (systray_profile)
|
||||
fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
unsigned long opcode;
|
||||
Window win;
|
||||
|
||||
opcode = e->data.l[1];
|
||||
Window win;
|
||||
unsigned long opcode = e->data.l[1];
|
||||
switch (opcode) {
|
||||
case SYSTEM_TRAY_REQUEST_DOCK:
|
||||
win = e->data.l[2];
|
||||
|
@ -550,9 +548,8 @@ gboolean add_icon(Window win)
|
|||
}
|
||||
|
||||
// Check if the application leaves behind empty icons
|
||||
GSList *l;
|
||||
int num_empty_same_pid = 0;
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
for (GSList *l = systray.list_icons; l; l = l->next) {
|
||||
TrayWindow *other = (TrayWindow *)l->data;
|
||||
if (other->win == win) {
|
||||
free(name);
|
||||
|
@ -575,7 +572,7 @@ gboolean add_icon(Window win)
|
|||
imlib_image_set_has_alpha(other->depth > 24);
|
||||
DATA32 *data = imlib_image_get_data_for_reading_only();
|
||||
int x, y;
|
||||
int empty = 1;
|
||||
gboolean empty = TRUE;
|
||||
for (x = 0; x < other->width && empty; x++) {
|
||||
for (y = 0; y < other->height && empty; y++) {
|
||||
DATA32 pixel = data[y * other->width + x];
|
||||
|
@ -589,7 +586,7 @@ gboolean add_icon(Window win)
|
|||
if (rgb != rgb_bg) {
|
||||
if (systray_profile)
|
||||
fprintf(stderr, "Pixel: %x different from bg %x at pos %d %d\n", pixel, pixel_bg, x, y);
|
||||
empty = 0;
|
||||
empty = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -617,7 +614,7 @@ gboolean add_icon(Window win)
|
|||
// Remove empty icons if the application leaves behind more than 1
|
||||
const int max_num_empty_same_pid = 0;
|
||||
if (num_empty_same_pid > max_num_empty_same_pid) {
|
||||
for (l = systray.list_icons; l; l = l->next) {
|
||||
for (GSList *l = systray.list_icons; l; l = l->next) {
|
||||
if (pid && ((TrayWindow *)l->data)->pid == pid && ((TrayWindow *)l->data)->empty) {
|
||||
num_empty_same_pid++;
|
||||
fprintf(stderr,
|
||||
|
@ -723,11 +720,11 @@ gboolean add_icon(Window win)
|
|||
// Resize and redraw the systray
|
||||
if (systray_profile)
|
||||
fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
systray.area.resize_needed = 1;
|
||||
systray.area.resize_needed = TRUE;
|
||||
systray.area.redraw_needed = TRUE;
|
||||
panel->area.resize_needed = 1;
|
||||
panel->area.resize_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
refresh_systray = 1;
|
||||
refresh_systray = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -795,7 +792,7 @@ gboolean reparent_icon(TrayWindow *traywin)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
traywin->reparented = 1;
|
||||
traywin->reparented = TRUE;
|
||||
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
|
@ -836,7 +833,8 @@ gboolean embed_icon(TrayWindow *traywin)
|
|||
int ret;
|
||||
|
||||
if (systray_profile)
|
||||
fprintf(stderr, "XGetWindowProperty(server.dsp, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, "
|
||||
fprintf(stderr,
|
||||
"XGetWindowProperty(server.dsp, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, "
|
||||
"server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n");
|
||||
ret = XGetWindowProperty(server.dsp,
|
||||
traywin->win,
|
||||
|
@ -918,7 +916,7 @@ gboolean embed_icon(TrayWindow *traywin)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
traywin->embedded = 1;
|
||||
traywin->embedded = TRUE;
|
||||
|
||||
if (systray_profile)
|
||||
fprintf(stderr,
|
||||
|
@ -985,11 +983,11 @@ void remove_icon(TrayWindow *traywin)
|
|||
// Resize and redraw the systray
|
||||
if (systray_profile)
|
||||
fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw\n" RESET, profiling_get_time(), __FUNCTION__, __LINE__);
|
||||
systray.area.resize_needed = 1;
|
||||
systray.area.resize_needed = TRUE;
|
||||
systray.area.redraw_needed = TRUE;
|
||||
panel->area.resize_needed = 1;
|
||||
panel->area.resize_needed = TRUE;
|
||||
panel_refresh = TRUE;
|
||||
refresh_systray = 1;
|
||||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
void systray_resize_icon(void *t)
|
||||
|
@ -1543,5 +1541,6 @@ void refresh_systray_icons()
|
|||
|
||||
gboolean systray_on_monitor(int i_monitor, int num_panelss)
|
||||
{
|
||||
return (i_monitor == systray_monitor) || (i_monitor == 0 && (systray_monitor >= num_panelss || systray_monitor < 0));
|
||||
return (i_monitor == systray_monitor) ||
|
||||
(i_monitor == 0 && (systray_monitor >= num_panelss || systray_monitor < 0));
|
||||
}
|
||||
|
|
|
@ -70,10 +70,10 @@ void default_taskbar()
|
|||
win_to_task = NULL;
|
||||
urgent_timeout = NULL;
|
||||
urgent_list = NULL;
|
||||
taskbar_enabled = 0;
|
||||
taskbar_distribute_size = 0;
|
||||
hide_inactive_tasks = 0;
|
||||
hide_task_diff_monitor = 0;
|
||||
taskbar_enabled = FALSE;
|
||||
taskbar_distribute_size = FALSE;
|
||||
hide_inactive_tasks = FALSE;
|
||||
hide_task_diff_monitor = FALSE;
|
||||
taskbar_sort_method = TASKBAR_NOSORT;
|
||||
taskbar_alignment = ALIGN_LEFT;
|
||||
default_taskbarname();
|
||||
|
|
|
@ -135,35 +135,6 @@ void cleanup_taskbarname()
|
|||
}
|
||||
}
|
||||
|
||||
void draw_taskbarname(void *obj, cairo_t *c)
|
||||
{
|
||||
Taskbarname *taskbar_name = obj;
|
||||
Taskbar *taskbar = taskbar_name->area.parent;
|
||||
PangoLayout *layout;
|
||||
Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font;
|
||||
|
||||
int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
|
||||
if (!panel_config.mouse_effects)
|
||||
taskbar_name->state_pix[state] = taskbar_name->area.pix;
|
||||
|
||||
// draw content
|
||||
layout = pango_cairo_create_layout(c);
|
||||
pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc);
|
||||
pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE);
|
||||
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_text(layout, taskbar_name->name, strlen(taskbar_name->name));
|
||||
|
||||
cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha);
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
// printf("draw_taskbarname %s ******************************\n", taskbar_name->name);
|
||||
}
|
||||
|
||||
gboolean resize_taskbarname(void *obj)
|
||||
{
|
||||
Taskbarname *taskbar_name = obj;
|
||||
|
@ -201,3 +172,32 @@ gboolean resize_taskbarname(void *obj)
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void draw_taskbarname(void *obj, cairo_t *c)
|
||||
{
|
||||
Taskbarname *taskbar_name = obj;
|
||||
Taskbar *taskbar = taskbar_name->area.parent;
|
||||
PangoLayout *layout;
|
||||
Color *config_text = (taskbar->desktop == server.desktop) ? &taskbarname_active_font : &taskbarname_font;
|
||||
|
||||
int state = (taskbar->desktop == server.desktop) ? TASKBAR_ACTIVE : TASKBAR_NORMAL;
|
||||
if (!panel_config.mouse_effects)
|
||||
taskbar_name->state_pix[state] = taskbar_name->area.pix;
|
||||
|
||||
// draw content
|
||||
layout = pango_cairo_create_layout(c);
|
||||
pango_layout_set_font_description(layout, panel_config.taskbarname_font_desc);
|
||||
pango_layout_set_width(layout, taskbar_name->area.width * PANGO_SCALE);
|
||||
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_text(layout, taskbar_name->name, strlen(taskbar_name->name));
|
||||
|
||||
cairo_set_source_rgba(c, config_text->rgb[0], config_text->rgb[1], config_text->rgb[2], config_text->alpha);
|
||||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel *)taskbar_name->area.panel)->font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
// printf("draw_taskbarname %s ******************************\n", taskbar_name->name);
|
||||
}
|
||||
|
|
38
src/tint.c
38
src/tint.c
|
@ -369,12 +369,13 @@ void get_snapshot(const char *path)
|
|||
imlib_free_image();
|
||||
}
|
||||
|
||||
void window_action(Task *task, int action)
|
||||
void window_action(Task *task, MouseAction action)
|
||||
{
|
||||
if (!task)
|
||||
return;
|
||||
int desk;
|
||||
switch (action) {
|
||||
case NONE:
|
||||
break;
|
||||
case CLOSE:
|
||||
close_window(task->win);
|
||||
break;
|
||||
|
@ -402,30 +403,30 @@ void window_action(Task *task, int action)
|
|||
case RESTORE:
|
||||
toggle_window_maximized(task->win);
|
||||
break;
|
||||
case DESKTOP_LEFT:
|
||||
case DESKTOP_LEFT: {
|
||||
if (task->desktop == 0)
|
||||
break;
|
||||
desk = task->desktop - 1;
|
||||
change_window_desktop(task->win, desk);
|
||||
if (desk == server.desktop)
|
||||
int desktop = task->desktop - 1;
|
||||
change_window_desktop(task->win, desktop);
|
||||
if (desktop == server.desktop)
|
||||
activate_window(task->win);
|
||||
break;
|
||||
case DESKTOP_RIGHT:
|
||||
}
|
||||
case DESKTOP_RIGHT: {
|
||||
if (task->desktop == server.num_desktops)
|
||||
break;
|
||||
desk = task->desktop + 1;
|
||||
change_window_desktop(task->win, desk);
|
||||
if (desk == server.desktop)
|
||||
int desktop = task->desktop + 1;
|
||||
change_window_desktop(task->win, desktop);
|
||||
if (desktop == server.desktop)
|
||||
activate_window(task->win);
|
||||
break;
|
||||
}
|
||||
case NEXT_TASK: {
|
||||
Task *task1;
|
||||
task1 = next_task(find_active_task(task));
|
||||
Task *task1 = next_task(find_active_task(task));
|
||||
activate_window(task1->win);
|
||||
} break;
|
||||
case PREV_TASK: {
|
||||
Task *task1;
|
||||
task1 = prev_task(find_active_task(task));
|
||||
Task *task1 = prev_task(find_active_task(task));
|
||||
activate_window(task1->win);
|
||||
}
|
||||
}
|
||||
|
@ -737,7 +738,6 @@ void event_property_notify(XEvent *e)
|
|||
{
|
||||
gboolean debug = FALSE;
|
||||
|
||||
int i;
|
||||
Window win = e->xproperty.window;
|
||||
Atom at = e->xproperty.atom;
|
||||
|
||||
|
@ -746,7 +746,7 @@ void event_property_notify(XEvent *e)
|
|||
if (win == server.root_win) {
|
||||
if (!server.got_root_win) {
|
||||
XSelectInput(server.dsp, server.root_win, PropertyChangeMask | StructureNotifyMask);
|
||||
server.got_root_win = 1;
|
||||
server.got_root_win = TRUE;
|
||||
}
|
||||
|
||||
// Change name of desktops
|
||||
|
@ -775,7 +775,7 @@ void event_property_notify(XEvent *e)
|
|||
}
|
||||
cleanup_taskbar();
|
||||
init_taskbar();
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
init_taskbar_panel(&panels[i]);
|
||||
set_panel_items_order(&panels[i]);
|
||||
visible_taskbar(&panels[i]);
|
||||
|
@ -785,7 +785,7 @@ void event_property_notify(XEvent *e)
|
|||
reset_active_task();
|
||||
panel_refresh = TRUE;
|
||||
} else if (old_desktop != server.desktop) {
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Panel *panel = &panels[i];
|
||||
set_taskbar_state(&panel->taskbar[old_desktop], TASKBAR_NORMAL);
|
||||
set_taskbar_state(&panel->taskbar[server.desktop], TASKBAR_ACTIVE);
|
||||
|
@ -863,7 +863,7 @@ void event_property_notify(XEvent *e)
|
|||
if (debug)
|
||||
fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__);
|
||||
// change Wallpaper
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
set_panel_background(&panels[i]);
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
|
|
Loading…
Reference in a new issue