all repos — tint2 @ b4f15db397ec5c81213755c98e146220dc816be2

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Use font shadows for all elements except tooltips

git-svn-id: http://tint2.googlecode.com/svn/trunk@766 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
o9000 o9000
commit

b4f15db397ec5c81213755c98e146220dc816be2

parent

6ba25fa94516c748632fbcbaa925c4559231dd7f

M sample/tint2rcsample/tint2rc

@@ -36,13 +36,14 @@ # Panel

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 @@

# 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
M src/battery/battery.csrc/battery/battery.c

@@ -499,8 +499,7 @@

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 @@ 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); - 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);
M src/clock/clock.csrc/clock/clock.c

@@ -206,8 +206,7 @@

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 @@ 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); - 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);
M src/config.csrc/config.c

@@ -287,7 +287,7 @@ else panel_horizontal = 1;

} } 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;
M src/panel.hsrc/panel.h

@@ -89,6 +89,7 @@ int marginx, marginy;

int pourcentx, pourcenty; // location of the panel (monitor number) int monitor; + int font_shadow; // -------------------------------------------------- // task and taskbar parameter per panel
M src/taskbar/task.csrc/taskbar/task.c

@@ -26,7 +26,6 @@ #include <stdlib.h>

#include <string.h> #include <glib.h> #include <unistd.h> -#include <math.h> #include "window.h" #include "task.h"

@@ -392,23 +391,7 @@ config_text = &panel->g_task.font[tsk->current_state];

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); }
M src/taskbar/task.hsrc/taskbar/task.h

@@ -40,7 +40,6 @@ int config_background_mask;

// 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;
M src/taskbar/taskbarname.csrc/taskbar/taskbarname.c

@@ -132,8 +132,7 @@

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);
M src/util/common.csrc/util/common.c

@@ -25,6 +25,7 @@ #include <X11/extensions/Xrender.h>

#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <math.h> #include <unistd.h> #include <glib.h> #include "common.h"

@@ -381,3 +382,24 @@ XFreePixmap(server.dsp, pmap_tmp);

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); +}
M src/util/common.hsrc/util/common.h

@@ -10,6 +10,7 @@

#define WM_CLASS_TINT "panel" #include <Imlib2.h> +#include <pango/pangocairo.h> #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