diff --git a/sample/tint2rc b/sample/tint2rc index 03b0839..bc2dcf3 100644 --- a/sample/tint2rc +++ b/sample/tint2rc @@ -36,13 +36,14 @@ border_color = #999999 100 panel_items = LTSBC panel_monitor = all panel_position = bottom center horizontal -panel_size = 95% 30 +panel_size = 85% 30 panel_margin = 0 0 panel_padding = 7 0 7 panel_dock = 0 wm_menu = 1 panel_layer = top panel_background_id = 1 +font_shadow = 0 # Panel Autohide autohide = 0 @@ -92,7 +93,6 @@ task_font_color = #FFFFFF 90 task_active_font_color = #FFFFFF 90 task_urgent_font_color = #FFFFFF 90 task_iconified_font_color = #FFFFFF 90 -font_shadow = 0 # Mouse mouse_left = toggle_iconify @@ -129,7 +129,7 @@ tooltip_font_color = #222222 100 # Battery battery_low_status = 10 battery_low_cmd = notify-send "battery low" -battery_hide = 98 +battery_hide = 101 bat1_font = sans 8 bat2_font = sans 6 battery_font_color = #FFFFFF 94 diff --git a/src/battery/battery.c b/src/battery/battery.c index caf7630..6f9bb92 100644 --- a/src/battery/battery.c +++ b/src/battery/battery.c @@ -499,8 +499,7 @@ void draw_battery (void *obj, cairo_t *c) cairo_set_source_rgba(c, battery->font.color[0], battery->font.color[1], battery->font.color[2], battery->font.alpha); pango_cairo_update_layout(c, layout); - cairo_move_to(c, 0, battery->bat1_posy); - pango_cairo_show_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); @@ -508,7 +507,7 @@ void draw_battery (void *obj, cairo_t *c) pango_layout_set_width(layout, battery->area.width * PANGO_SCALE); pango_cairo_update_layout(c, layout); - cairo_move_to(c, 0, battery->bat2_posy); + 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); diff --git a/src/clock/clock.c b/src/clock/clock.c index 1592ea2..9cbccde 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -206,8 +206,7 @@ void draw_clock (void *obj, cairo_t *c) cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha); pango_cairo_update_layout (c, layout); - cairo_move_to (c, 0, clock->time1_posy); - pango_cairo_show_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); @@ -216,8 +215,7 @@ void draw_clock (void *obj, cairo_t *c) pango_layout_set_width (layout, clock->area.width * PANGO_SCALE); pango_cairo_update_layout (c, layout); - cairo_move_to (c, 0, clock->time2_posy); - pango_cairo_show_layout (c, layout); + draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel*)clock->area.panel)->font_shadow); } g_object_unref (layout); diff --git a/src/config.c b/src/config.c index e866a3f..c861c71 100644 --- a/src/config.c +++ b/src/config.c @@ -287,7 +287,7 @@ void add_entry (char *key, char *value) } } else if (strcmp (key, "font_shadow") == 0) - panel_config.g_task.font_shadow = atoi (value); + panel_config.font_shadow = atoi (value); else if (strcmp (key, "panel_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; diff --git a/src/panel.h b/src/panel.h index 3f1c5e1..e4f783d 100644 --- a/src/panel.h +++ b/src/panel.h @@ -89,6 +89,7 @@ typedef struct { int pourcentx, pourcenty; // location of the panel (monitor number) int monitor; + int font_shadow; // -------------------------------------------------- // task and taskbar parameter per panel diff --git a/src/taskbar/task.c b/src/taskbar/task.c index 62303b2..b69fa5e 100644 --- a/src/taskbar/task.c +++ b/src/taskbar/task.c @@ -26,7 +26,6 @@ #include #include #include -#include #include "window.h" #include "task.h" @@ -392,23 +391,7 @@ void draw_task (void *obj, cairo_t *c) double text_posy = (panel->g_task.area.height - height) / 2.0; - if (panel->g_task.font_shadow) { - const int shadow_size = 3; - const double shadow_edge_alpha = 0.05; - int i, j; - for (i = -shadow_size; i <= shadow_size; i++) { - for (j = -shadow_size; j <= shadow_size; j++) { - cairo_set_source_rgba(c, 0.0, 0.0, 0.0, 1.0 - (1.0 - shadow_edge_alpha) * sqrt((i*i + j*j)/(double)(shadow_size*shadow_size))); - pango_cairo_update_layout(c, layout); - cairo_move_to(c, panel->g_task.text_posx + i, text_posy + j); - pango_cairo_show_layout(c, layout); - } - } - } - cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha); - pango_cairo_update_layout (c, layout); - cairo_move_to (c, panel->g_task.text_posx, text_posy); - pango_cairo_show_layout (c, layout); + draw_text(layout, c, panel->g_task.text_posx, text_posy, config_text, panel->font_shadow); g_object_unref (layout); } diff --git a/src/taskbar/task.h b/src/taskbar/task.h index c2938ae..31a62a4 100644 --- a/src/taskbar/task.h +++ b/src/taskbar/task.h @@ -40,7 +40,6 @@ typedef struct { // starting position for text ~ task_padding + task_border + icon_size double text_posx, text_height; - int font_shadow; PangoFontDescription *font_desc; Color font[TASK_STATE_COUNT]; int config_font_mask; diff --git a/src/taskbar/taskbarname.c b/src/taskbar/taskbarname.c index 84c9070..e112779 100644 --- a/src/taskbar/taskbarname.c +++ b/src/taskbar/taskbarname.c @@ -132,8 +132,7 @@ void draw_taskbarname (void *obj, cairo_t *c) cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha); pango_cairo_update_layout (c, layout); - cairo_move_to (c, 0, taskbar_name->posy); - pango_cairo_show_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); diff --git a/src/util/common.c b/src/util/common.c index 6e7ce19..7f4a156 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "common.h" @@ -381,3 +382,24 @@ void render_image(Drawable d, int x, int y, int w, int h) XRenderFreePicture(server.dsp, pict_image); XRenderFreePicture(server.dsp, pict_drawable); } + +void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow) +{ + if (font_shadow) { + const int shadow_size = 3; + const double shadow_edge_alpha = 0.0; + int i, j; + for (i = -shadow_size; i <= shadow_size; i++) { + for (j = -shadow_size; j <= shadow_size; j++) { + cairo_set_source_rgba(c, 0.0, 0.0, 0.0, 1.0 - (1.0 - shadow_edge_alpha) * sqrt((i*i + j*j)/(double)(shadow_size*shadow_size))); + pango_cairo_update_layout(c, layout); + cairo_move_to(c, posx + i, posy + j); + pango_cairo_show_layout(c, layout); + } + } + } + cairo_set_source_rgba (c, color->color[0], color->color[1], color->color[2], color->alpha); + pango_cairo_update_layout (c, layout); + cairo_move_to (c, posx, posy); + pango_cairo_show_layout (c, layout); +} diff --git a/src/util/common.h b/src/util/common.h index de16063..77be4f0 100644 --- a/src/util/common.h +++ b/src/util/common.h @@ -10,6 +10,7 @@ #define WM_CLASS_TINT "panel" #include +#include #include "area.h" /* @@ -64,5 +65,8 @@ void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright void createHeuristicMask(DATA32* data, int w, int h); void render_image(Drawable d, int x, int y, int w, int h); + +void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow); + #endif