Use default desktop font (Gtk/FontName from XSettings) when the font is not specified in the config file
This commit is contained in:
parent
1b545f6bbe
commit
9a85f7f2c5
22 changed files with 340 additions and 78 deletions
|
@ -1,6 +1,7 @@
|
|||
2015-12-05 master
|
||||
2015-12-12 master
|
||||
- Enhancements:
|
||||
- Support for NETWM viewports (as in Compiz) (issue #94)
|
||||
- The default desktop font (Gtk/FontName from XSettings) is used when a font is not specified in the config file
|
||||
- New plugin: executor
|
||||
- New taskbar sort order: least-recently-used (lru), most-recently-used (mru)
|
||||
2015-11-12 0.12.3
|
||||
|
|
|
@ -105,7 +105,6 @@ task_urgent_icon_asb = 100 0 0
|
|||
task_iconified_icon_asb = 100 0 0
|
||||
|
||||
# Fonts
|
||||
task_font = sans 9
|
||||
task_font_color = #FFFFFF 90
|
||||
task_active_font_color = #FFFFFF 90
|
||||
task_urgent_font_color = #FFFFFF 90
|
||||
|
@ -127,9 +126,7 @@ systray_icon_asb = 100 0 0
|
|||
|
||||
# Clock
|
||||
time1_format = %H:%M
|
||||
time1_font = sans bold 8
|
||||
time2_format = %A %d %B
|
||||
time2_font = sans 8
|
||||
clock_font_color = #FFFFFF 100
|
||||
clock_padding = 1 0
|
||||
clock_background_id = 0
|
||||
|
@ -140,15 +137,12 @@ tooltip_padding = 2 2
|
|||
tooltip_show_timeout = 0.5
|
||||
tooltip_hide_timeout = 0.1
|
||||
tooltip_background_id = 5
|
||||
tooltip_font = sans 9
|
||||
tooltip_font_color = #222222 100
|
||||
|
||||
# Battery
|
||||
battery_low_status = 10
|
||||
battery_low_cmd = notify-send "battery low"
|
||||
battery_hide = 101
|
||||
bat1_font = sans 8
|
||||
bat2_font = sans 7
|
||||
battery_font_color = #FFFFFF 100
|
||||
battery_padding = 1 0
|
||||
battery_background_id = 0
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
#include "timer.h"
|
||||
#include "common.h"
|
||||
|
||||
gboolean bat1_has_font;
|
||||
PangoFontDescription *bat1_font_desc;
|
||||
gboolean bat2_has_font;
|
||||
PangoFontDescription *bat2_font_desc;
|
||||
struct BatteryState battery_state;
|
||||
gboolean battery_enabled;
|
||||
|
@ -54,6 +56,8 @@ char *battery_uwheel_command;
|
|||
char *battery_dwheel_command;
|
||||
gboolean battery_found;
|
||||
|
||||
void battery_init_fonts();
|
||||
|
||||
void update_battery_tick(void *arg)
|
||||
{
|
||||
if (!battery_enabled)
|
||||
|
@ -91,8 +95,7 @@ void update_battery_tick(void *arg)
|
|||
battery_low_cmd_sent = FALSE;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
// Show/hide if needed
|
||||
if (!battery_found) {
|
||||
if (panels[i].battery.area.on_screen) {
|
||||
|
@ -131,7 +134,9 @@ void default_battery()
|
|||
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;
|
||||
|
@ -209,10 +214,7 @@ void init_battery_panel(void *p)
|
|||
if (!battery_enabled)
|
||||
return;
|
||||
|
||||
if (!bat1_font_desc)
|
||||
bat1_font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!bat2_font_desc)
|
||||
bat2_font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
battery_init_fonts();
|
||||
|
||||
if (!battery->area.bg)
|
||||
battery->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
|
@ -231,6 +233,42 @@ void init_battery_panel(void *p)
|
|||
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;
|
||||
|
|
|
@ -47,7 +47,9 @@ typedef struct BatteryState {
|
|||
} BatteryState;
|
||||
|
||||
extern struct BatteryState battery_state;
|
||||
extern gboolean bat1_has_font;
|
||||
extern PangoFontDescription *bat1_font_desc;
|
||||
extern gboolean bat2_has_font;
|
||||
extern PangoFontDescription *bat2_font_desc;
|
||||
extern gboolean battery_enabled;
|
||||
extern gboolean battery_tooltip_enabled;
|
||||
|
@ -103,6 +105,7 @@ void init_battery_panel(void *panel);
|
|||
|
||||
void reinit_battery();
|
||||
void draw_battery(void *obj, cairo_t *c);
|
||||
void battery_default_font_changed();
|
||||
|
||||
gboolean resize_battery(void *obj);
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ char *clock_rclick_command;
|
|||
char *clock_uwheel_command;
|
||||
char *clock_dwheel_command;
|
||||
struct timeval time_clock;
|
||||
gboolean time1_has_font;
|
||||
PangoFontDescription *time1_font_desc;
|
||||
gboolean time2_has_font;
|
||||
PangoFontDescription *time2_font_desc;
|
||||
static char buf_time[256];
|
||||
static char buf_date[256];
|
||||
|
@ -51,6 +53,8 @@ static char buf_tooltip[512];
|
|||
int clock_enabled;
|
||||
static timeout *clock_timeout;
|
||||
|
||||
void clock_init_fonts();
|
||||
|
||||
void default_clock()
|
||||
{
|
||||
clock_enabled = 0;
|
||||
|
@ -66,7 +70,9 @@ void default_clock()
|
|||
clock_rclick_command = NULL;
|
||||
clock_uwheel_command = NULL;
|
||||
clock_dwheel_command = NULL;
|
||||
time1_has_font = FALSE;
|
||||
time1_font_desc = NULL;
|
||||
time2_has_font = FALSE;
|
||||
time2_font_desc = NULL;
|
||||
}
|
||||
|
||||
|
@ -175,12 +181,9 @@ void init_clock_panel(void *p)
|
|||
Panel *panel = (Panel *)p;
|
||||
Clock *clock = &panel->clock;
|
||||
|
||||
if (!time1_font_desc)
|
||||
time1_font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!time2_font_desc)
|
||||
time2_font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!clock->area.bg)
|
||||
clock->area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
clock_init_fonts();
|
||||
clock->area.parent = p;
|
||||
clock->area.panel = p;
|
||||
clock->area.has_mouse_press_effect = clock->area.has_mouse_over_effect =
|
||||
|
@ -202,6 +205,43 @@ void init_clock_panel(void *p)
|
|||
}
|
||||
}
|
||||
|
||||
void clock_init_fonts()
|
||||
{
|
||||
if (!time1_font_desc) {
|
||||
time1_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_weight(time1_font_desc, PANGO_WEIGHT_BOLD);
|
||||
pango_font_description_set_size(time1_font_desc,
|
||||
pango_font_description_get_size(time1_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
if (!time2_font_desc) {
|
||||
time2_font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(time2_font_desc,
|
||||
pango_font_description_get_size(time2_font_desc) - PANGO_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
void clock_default_font_changed()
|
||||
{
|
||||
if (!clock_enabled)
|
||||
return;
|
||||
if (time1_has_font && time2_has_font)
|
||||
return;
|
||||
if (!time1_has_font) {
|
||||
pango_font_description_free(time1_font_desc);
|
||||
time1_font_desc = NULL;
|
||||
}
|
||||
if (!time2_has_font) {
|
||||
pango_font_description_free(time2_font_desc);
|
||||
time2_font_desc = NULL;
|
||||
}
|
||||
clock_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
panels[i].clock.area.resize_needed = TRUE;
|
||||
panels[i].clock.area.redraw_needed = TRUE;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void draw_clock(void *obj, cairo_t *c)
|
||||
{
|
||||
Clock *clock = obj;
|
||||
|
@ -323,3 +363,4 @@ void clock_action(int button)
|
|||
}
|
||||
tint_exec(command);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,9 @@ extern char *time2_format;
|
|||
extern char *time2_timezone;
|
||||
extern char *time_tooltip_format;
|
||||
extern char *time_tooltip_timezone;
|
||||
extern gboolean time1_has_font;
|
||||
extern PangoFontDescription *time1_font_desc;
|
||||
extern gboolean time2_has_font;
|
||||
extern PangoFontDescription *time2_font_desc;
|
||||
extern char *clock_lclick_command;
|
||||
extern char *clock_mclick_command;
|
||||
|
@ -46,6 +48,7 @@ void cleanup_clock();
|
|||
// initialize clock : y position, precision, ...
|
||||
void init_clock();
|
||||
void init_clock_panel(void *panel);
|
||||
void clock_default_font_changed();
|
||||
|
||||
void draw_clock(void *obj, cairo_t *c);
|
||||
|
||||
|
|
|
@ -467,10 +467,12 @@ void add_entry(char *key, char *value)
|
|||
} else if (strcmp(key, "bat1_font") == 0) {
|
||||
#ifdef ENABLE_BATTERY
|
||||
bat1_font_desc = pango_font_description_from_string(value);
|
||||
bat1_has_font = TRUE;
|
||||
#endif
|
||||
} else if (strcmp(key, "bat2_font") == 0) {
|
||||
#ifdef ENABLE_BATTERY
|
||||
bat2_font_desc = pango_font_description_from_string(value);
|
||||
bat2_has_font = TRUE;
|
||||
#endif
|
||||
} else if (strcmp(key, "battery_font_color") == 0) {
|
||||
#ifdef ENABLE_BATTERY
|
||||
|
@ -545,6 +547,7 @@ void add_entry(char *key, char *value)
|
|||
Execp *execp = get_or_create_last_execp();
|
||||
pango_font_description_free(execp->backend->font_desc);
|
||||
execp->backend->font_desc = pango_font_description_from_string(value);
|
||||
execp->backend->has_font = TRUE;
|
||||
} else if (strcmp(key, "execp_font_color") == 0) {
|
||||
Execp *execp = get_or_create_last_execp();
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
|
@ -635,6 +638,7 @@ void add_entry(char *key, char *value)
|
|||
time2_format = strdup(value);
|
||||
} else if (strcmp(key, "time1_font") == 0) {
|
||||
time1_font_desc = pango_font_description_from_string(value);
|
||||
time1_has_font = TRUE;
|
||||
} else if (strcmp(key, "time1_timezone") == 0) {
|
||||
if (strlen(value) > 0)
|
||||
time1_timezone = strdup(value);
|
||||
|
@ -643,6 +647,7 @@ void add_entry(char *key, char *value)
|
|||
time2_timezone = strdup(value);
|
||||
} else if (strcmp(key, "time2_font") == 0) {
|
||||
time2_font_desc = pango_font_description_from_string(value);
|
||||
time2_has_font = TRUE;
|
||||
} else if (strcmp(key, "clock_font_color") == 0) {
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, panel_config.clock.font.rgb);
|
||||
|
@ -729,6 +734,7 @@ void add_entry(char *key, char *value)
|
|||
panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id);
|
||||
} else if (strcmp(key, "taskbar_name_font") == 0) {
|
||||
panel_config.taskbarname_font_desc = pango_font_description_from_string(value);
|
||||
panel_config.taskbarname_has_font = TRUE;
|
||||
} else if (strcmp(key, "taskbar_name_font_color") == 0) {
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
get_color(value1, taskbarname_font.rgb);
|
||||
|
@ -795,6 +801,7 @@ void add_entry(char *key, char *value)
|
|||
panel_config.g_task.area.paddingx = atoi(value3);
|
||||
} else if (strcmp(key, "task_font") == 0) {
|
||||
panel_config.g_task.font_desc = pango_font_description_from_string(value);
|
||||
panel_config.g_task.has_font = TRUE;
|
||||
} else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) {
|
||||
gchar **split = g_regex_split_simple("_", key, 0, 0);
|
||||
int status = g_strv_length(split) == 3 ? TASK_NORMAL : get_task_status(split[1]);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
void execp_timer_callback(void *arg);
|
||||
char *execp_get_tooltip(void *obj);
|
||||
void execp_init_fonts();
|
||||
|
||||
void default_execp()
|
||||
{
|
||||
|
@ -122,12 +123,11 @@ void init_execp()
|
|||
}
|
||||
}
|
||||
|
||||
execp_init_fonts();
|
||||
for (GList *l = panel_config.execp_list; l; l = l->next) {
|
||||
Execp *execp = l->data;
|
||||
|
||||
// Set missing config options
|
||||
if (!execp->backend->font_desc)
|
||||
execp->backend->font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!execp->backend->bg)
|
||||
execp->backend->bg = &g_array_index(backgrounds, Background, 0);
|
||||
execp->backend->buf_capacity = 1024;
|
||||
|
@ -174,6 +174,44 @@ void init_execp_panel(void *p)
|
|||
}
|
||||
}
|
||||
|
||||
void execp_init_fonts()
|
||||
{
|
||||
for (GList *l = panel_config.execp_list; l; l = l->next) {
|
||||
Execp *execp = l->data;
|
||||
if (!execp->backend->font_desc)
|
||||
execp->backend->font_desc = pango_font_description_from_string(get_default_font());
|
||||
}
|
||||
}
|
||||
|
||||
void execp_default_font_changed()
|
||||
{
|
||||
gboolean needs_update = FALSE;
|
||||
for (GList *l = panel_config.execp_list; l; l = l->next) {
|
||||
Execp *execp = l->data;
|
||||
|
||||
if (!execp->backend->has_font) {
|
||||
pango_font_description_free(execp->backend->font_desc);
|
||||
execp->backend->font_desc = NULL;
|
||||
needs_update = TRUE;
|
||||
}
|
||||
}
|
||||
if (!needs_update)
|
||||
return;
|
||||
|
||||
execp_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
for (GList *l = panels[i].execp_list; l; l = l->next) {
|
||||
Execp *execp = l->data;
|
||||
|
||||
if (!execp->backend->has_font) {
|
||||
execp->area.resize_needed = TRUE;
|
||||
execp->area.redraw_needed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void cleanup_execp()
|
||||
{
|
||||
// Cleanup frontends
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct ExecpBackend {
|
|||
int icon_h;
|
||||
char *tooltip;
|
||||
gboolean centered;
|
||||
gboolean has_font;
|
||||
PangoFontDescription *font_desc;
|
||||
Color font_color;
|
||||
int continuous;
|
||||
|
@ -136,4 +137,6 @@ void execp_action(void *obj, int button);
|
|||
// Returns 1 if the output has been updated and a redraw is needed.
|
||||
gboolean read_execp(void *obj);
|
||||
|
||||
void execp_default_font_changed();
|
||||
|
||||
#endif // EXECPLUGIN_H
|
||||
|
|
|
@ -51,7 +51,6 @@ int launcher_brightness;
|
|||
char *icon_theme_name_config;
|
||||
char *icon_theme_name_xsettings;
|
||||
int launcher_icon_theme_override;
|
||||
XSettingsClient *xsettings_client;
|
||||
int startup_notifications;
|
||||
Background *launcher_icon_bg;
|
||||
|
||||
|
@ -69,17 +68,12 @@ void default_launcher()
|
|||
icon_theme_name_config = NULL;
|
||||
icon_theme_name_xsettings = NULL;
|
||||
launcher_icon_theme_override = 0;
|
||||
xsettings_client = NULL;
|
||||
startup_notifications = 0;
|
||||
launcher_icon_bg = NULL;
|
||||
}
|
||||
|
||||
void init_launcher()
|
||||
{
|
||||
if (launcher_enabled) {
|
||||
// if XSETTINGS manager running, tint2 read the icon_theme_name.
|
||||
xsettings_client = xsettings_client_new(server.dsp, server.screen, xsettings_notify_cb, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void init_launcher_panel(void *p)
|
||||
|
@ -116,10 +110,6 @@ void cleanup_launcher()
|
|||
int i;
|
||||
GSList *l;
|
||||
|
||||
if (xsettings_client)
|
||||
xsettings_client_destroy(xsettings_client);
|
||||
xsettings_client = NULL;
|
||||
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
Panel *panel = &panels[i];
|
||||
Launcher *launcher = &panel->launcher;
|
||||
|
@ -488,3 +478,19 @@ void launcher_load_themes(Launcher *launcher)
|
|||
: (icon_theme_name_xsettings ? icon_theme_name_xsettings
|
||||
: icon_theme_name_config ? icon_theme_name_config : "hicolor"));
|
||||
}
|
||||
|
||||
void launcher_default_icon_theme_changed()
|
||||
{
|
||||
if (!launcher_enabled)
|
||||
return;
|
||||
if (launcher_icon_theme_override && icon_theme_name_config)
|
||||
return;
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
Launcher *launcher = &panels[i].launcher;
|
||||
cleanup_launcher_theme(launcher);
|
||||
launcher_load_themes(launcher);
|
||||
launcher_load_icons(launcher);
|
||||
launcher->area.resize_needed = 1;
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ extern int launcher_brightness;
|
|||
extern char *icon_theme_name_xsettings; // theme name
|
||||
extern char *icon_theme_name_config;
|
||||
extern int launcher_icon_theme_override;
|
||||
extern XSettingsClient *xsettings_client;
|
||||
extern int startup_notifications;
|
||||
extern Background *launcher_icon_bg;
|
||||
|
||||
|
@ -59,6 +58,7 @@ void cleanup_launcher_theme(Launcher *launcher);
|
|||
|
||||
gboolean resize_launcher(void *obj);
|
||||
void draw_launcher(void *obj, cairo_t *c);
|
||||
void launcher_default_icon_theme_changed();
|
||||
|
||||
// Populates the list_icons list
|
||||
void launcher_load_icons(Launcher *launcher);
|
||||
|
|
|
@ -46,24 +46,25 @@ struct _XSettingsClient {
|
|||
|
||||
void xsettings_notify_cb(const char *name, XSettingsAction action, XSettingsSetting *setting, void *data)
|
||||
{
|
||||
// printf("xsettings_notify_cb\n");
|
||||
if ((action == XSETTINGS_ACTION_NEW || action == XSETTINGS_ACTION_CHANGED) && name != NULL && setting != NULL) {
|
||||
if (!strcmp(name, "Net/IconThemeName") && setting->type == XSETTINGS_TYPE_STRING) {
|
||||
if (strcmp(name, "Net/IconThemeName") == 0 && setting->type == XSETTINGS_TYPE_STRING) {
|
||||
fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string);
|
||||
if (icon_theme_name_xsettings) {
|
||||
if (strcmp(icon_theme_name_xsettings, setting->data.v_string) == 0)
|
||||
return;
|
||||
free(icon_theme_name_xsettings);
|
||||
}
|
||||
icon_theme_name_xsettings = strdup(setting->data.v_string);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < num_panels; i++) {
|
||||
Launcher *launcher = &panels[i].launcher;
|
||||
cleanup_launcher_theme(launcher);
|
||||
launcher_load_themes(launcher);
|
||||
launcher_load_icons(launcher);
|
||||
launcher->area.resize_needed = 1;
|
||||
default_icon_theme_changed();
|
||||
} else if (strcmp(name, "Gtk/FontName") == 0 && setting->type == XSETTINGS_TYPE_STRING) {
|
||||
fprintf(stderr, "xsettings: %s = %s\n", name, setting->data.v_string);
|
||||
if (default_font) {
|
||||
if (strcmp(default_font, setting->data.v_string) == 0)
|
||||
return;
|
||||
free(default_font);
|
||||
}
|
||||
default_font = strdup(setting->data.v_string);
|
||||
default_font_changed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -341,7 +342,6 @@ static void read_settings(XSettingsClient *client)
|
|||
unsigned long n_items;
|
||||
unsigned long bytes_after;
|
||||
unsigned char *data;
|
||||
int result;
|
||||
|
||||
int (*old_handler)(Display *, XErrorEvent *);
|
||||
|
||||
|
@ -349,7 +349,7 @@ static void read_settings(XSettingsClient *client)
|
|||
client->settings = NULL;
|
||||
|
||||
old_handler = XSetErrorHandler(ignore_errors);
|
||||
result = XGetWindowProperty(client->display,
|
||||
int result = XGetWindowProperty(client->display,
|
||||
client->manager_window,
|
||||
server.atom._XSETTINGS_SETTINGS,
|
||||
0,
|
||||
|
@ -401,9 +401,7 @@ XSettingsClient *xsettings_client_new(Display *display,
|
|||
XSettingsWatchFunc watch,
|
||||
void *cb_data)
|
||||
{
|
||||
XSettingsClient *client;
|
||||
|
||||
client = calloc(1, sizeof *client);
|
||||
XSettingsClient *client = calloc(1, sizeof *client);
|
||||
if (!client)
|
||||
return NULL;
|
||||
|
||||
|
@ -422,15 +420,18 @@ XSettingsClient *xsettings_client_new(Display *display,
|
|||
check_manager_window(client);
|
||||
|
||||
if (client->manager_window == None) {
|
||||
printf("NO XSETTINGS manager, tint2 use config 'launcher_icon_theme'.\n");
|
||||
printf("No XSETTINGS manager, tint2 uses config option 'launcher_icon_theme'.\n");
|
||||
free(client);
|
||||
return NULL;
|
||||
} else
|
||||
} else {
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
void xsettings_client_destroy(XSettingsClient *client)
|
||||
{
|
||||
if (!client)
|
||||
return;
|
||||
if (client->watch)
|
||||
client->watch(RootWindow(client->display, client->screen), False, 0, client->cb_data);
|
||||
if (client->manager_window && client->watch)
|
||||
|
|
23
src/panel.c
23
src/panel.c
|
@ -72,6 +72,7 @@ int num_panels;
|
|||
GArray *backgrounds;
|
||||
|
||||
Imlib_Image default_icon;
|
||||
char *default_font = NULL;
|
||||
|
||||
void default_panel()
|
||||
{
|
||||
|
@ -1013,3 +1014,25 @@ void render_panel(Panel *panel)
|
|||
relayout(&panel->area);
|
||||
draw_tree(&panel->area);
|
||||
}
|
||||
|
||||
const char *get_default_font()
|
||||
{
|
||||
if (default_font)
|
||||
return default_font;
|
||||
return DEFAULT_FONT;
|
||||
}
|
||||
|
||||
void default_icon_theme_changed()
|
||||
{
|
||||
launcher_default_icon_theme_changed();
|
||||
}
|
||||
|
||||
void default_font_changed()
|
||||
{
|
||||
battery_default_font_changed();
|
||||
clock_default_font_changed();
|
||||
execp_default_font_changed();
|
||||
taskbar_default_font_changed();
|
||||
taskbarname_default_font_changed();
|
||||
tooltip_default_font_changed();
|
||||
}
|
||||
|
|
|
@ -83,8 +83,9 @@ extern char *panel_items_order;
|
|||
extern int max_tick_urgent;
|
||||
extern GArray *backgrounds;
|
||||
extern Imlib_Image default_icon;
|
||||
// TODO maybe this should be a config option
|
||||
#define DEFAULT_FONT "sans 10"
|
||||
extern char *default_font;
|
||||
extern XSettingsClient *xsettings_client;
|
||||
|
||||
typedef struct Panel {
|
||||
Area area;
|
||||
|
@ -114,6 +115,7 @@ typedef struct Panel {
|
|||
// Array of Taskbar, with num_desktops items
|
||||
Taskbar *taskbar;
|
||||
int num_desktops;
|
||||
gboolean taskbarname_has_font;
|
||||
PangoFontDescription *taskbarname_font_desc;
|
||||
|
||||
Clock clock;
|
||||
|
@ -179,4 +181,9 @@ void autohide_hide(void *p);
|
|||
void autohide_trigger_show(Panel *p);
|
||||
void autohide_trigger_hide(Panel *p);
|
||||
|
||||
const char *get_default_font();
|
||||
|
||||
void default_icon_theme_changed();
|
||||
void default_font_changed();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@ typedef struct GlobalTask {
|
|||
// starting position for text ~ task_padding + task_border + icon_size
|
||||
double text_posx, text_height;
|
||||
|
||||
gboolean has_font;
|
||||
PangoFontDescription *font_desc;
|
||||
Color font[TASK_STATE_COUNT];
|
||||
int config_font_mask;
|
||||
|
|
|
@ -48,6 +48,8 @@ gboolean hide_task_diff_monitor;
|
|||
TaskbarSortMethod taskbar_sort_method;
|
||||
Alignment taskbar_alignment;
|
||||
|
||||
void taskbar_init_fonts();
|
||||
|
||||
guint win_hash(gconstpointer key)
|
||||
{
|
||||
return *((const Window *)key);
|
||||
|
@ -139,10 +141,9 @@ void init_taskbar_panel(void *p)
|
|||
panel->g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, 0);
|
||||
panel->g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, 0);
|
||||
}
|
||||
if (!panel->g_task.font_desc)
|
||||
panel->g_task.font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!panel->g_task.area.bg)
|
||||
panel->g_task.area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
taskbar_init_fonts();
|
||||
|
||||
// taskbar name
|
||||
panel->g_taskbar.area_name.panel = panel;
|
||||
|
@ -285,6 +286,46 @@ void init_taskbar_panel(void *p)
|
|||
init_taskbarname_panel(panel);
|
||||
}
|
||||
|
||||
void taskbar_init_fonts()
|
||||
{
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
if (!panels[i].g_task.font_desc) {
|
||||
panels[i].g_task.font_desc = pango_font_description_from_string(get_default_font());
|
||||
pango_font_description_set_size(panels[i].g_task.font_desc,
|
||||
pango_font_description_get_size(panels[i].g_task.font_desc) - PANGO_SCALE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void taskbar_default_font_changed()
|
||||
{
|
||||
if (!taskbar_enabled)
|
||||
return;
|
||||
|
||||
gboolean needs_update = FALSE;
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
if (!panels[i].g_task.has_font) {
|
||||
pango_font_description_free(panels[i].g_task.font_desc);
|
||||
panels[i].g_task.font_desc = NULL;
|
||||
needs_update = TRUE;
|
||||
}
|
||||
}
|
||||
if (!needs_update)
|
||||
return;
|
||||
taskbar_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
for (int j = 0; j < panels[i].num_desktops; j++) {
|
||||
Taskbar *taskbar = &panels[i].taskbar[j];
|
||||
for (GList *c = taskbar->area.children; c; c = c->next) {
|
||||
Task *t = c->data;
|
||||
t->area.resize_needed = TRUE;
|
||||
t->area.redraw_needed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void taskbar_remove_task(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
remove_task(task_get_task(*(Window *)key));
|
||||
|
@ -317,8 +358,7 @@ void task_refresh_tasklist()
|
|||
return;
|
||||
|
||||
GList *win_list = g_hash_table_get_keys(win_to_task);
|
||||
GList *it;
|
||||
for (it = win_list; it; it = it->next) {
|
||||
for (GList *it = win_list; it; it = it->next) {
|
||||
int i;
|
||||
for (i = 0; i < num_results; i++)
|
||||
if (*((Window *)it->data) == win[i])
|
||||
|
|
|
@ -84,4 +84,6 @@ void visible_taskbar(void *p);
|
|||
void sort_taskbar_for_win(Window win);
|
||||
void sort_tasks(Taskbar *taskbar);
|
||||
|
||||
void taskbar_default_font_changed();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,14 +33,14 @@
|
|||
#include "taskbarname.h"
|
||||
|
||||
int taskbarname_enabled;
|
||||
PangoFontDescription *taskbarname_font_desc;
|
||||
Color taskbarname_font;
|
||||
Color taskbarname_active_font;
|
||||
|
||||
void taskbarname_init_fonts();
|
||||
|
||||
void default_taskbarname()
|
||||
{
|
||||
taskbarname_enabled = 0;
|
||||
taskbarname_font_desc = NULL;
|
||||
}
|
||||
|
||||
void init_taskbarname_panel(void *p)
|
||||
|
@ -52,8 +52,7 @@ void init_taskbarname_panel(void *p)
|
|||
if (!taskbarname_enabled)
|
||||
return;
|
||||
|
||||
if (!panel_config.taskbarname_font_desc)
|
||||
panel_config.taskbarname_font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
taskbarname_init_fonts();
|
||||
|
||||
GSList *l, *list = get_desktop_names();
|
||||
for (j = 0, l = list; j < panel->num_desktops; j++) {
|
||||
|
@ -83,6 +82,34 @@ void init_taskbarname_panel(void *p)
|
|||
g_slist_free(list);
|
||||
}
|
||||
|
||||
void taskbarname_init_fonts()
|
||||
{
|
||||
if (!panel_config.taskbarname_font_desc)
|
||||
panel_config.taskbarname_font_desc = pango_font_description_from_string(get_default_font());
|
||||
}
|
||||
|
||||
void taskbarname_default_font_changed()
|
||||
{
|
||||
if (!taskbar_enabled)
|
||||
return;
|
||||
if (!taskbarname_enabled)
|
||||
return;
|
||||
if (panel_config.taskbarname_has_font)
|
||||
return;
|
||||
|
||||
pango_font_description_free(panel_config.taskbarname_font_desc);
|
||||
panel_config.taskbarname_font_desc = NULL;
|
||||
taskbarname_init_fonts();
|
||||
for (int i = 0; i < num_panels; i++) {
|
||||
for (int j = 0; j < panels[i].num_desktops; j++) {
|
||||
Taskbar *taskbar = &panels[i].taskbar[j];
|
||||
taskbar->bar_name.area.resize_needed = TRUE;
|
||||
taskbar->bar_name.area.redraw_needed = TRUE;
|
||||
}
|
||||
}
|
||||
panel_refresh = TRUE;
|
||||
}
|
||||
|
||||
void cleanup_taskbarname()
|
||||
{
|
||||
int i, j, k;
|
||||
|
|
|
@ -21,4 +21,6 @@ void draw_taskbarname(void *obj, cairo_t *c);
|
|||
|
||||
gboolean resize_taskbarname(void *obj);
|
||||
|
||||
void taskbarname_default_font_changed();
|
||||
|
||||
#endif
|
||||
|
|
29
src/tint.c
29
src/tint.c
|
@ -59,6 +59,7 @@ Atom dnd_selection;
|
|||
Atom dnd_atom;
|
||||
int dnd_sent_request;
|
||||
char *dnd_launcher_exec;
|
||||
XSettingsClient *xsettings_client = NULL;
|
||||
|
||||
timeout *detect_compositor_timer = NULL;
|
||||
int detect_compositor_timer_counter = 0;
|
||||
|
@ -124,7 +125,7 @@ void init(int argc, char *argv[])
|
|||
default_execp();
|
||||
default_panel();
|
||||
|
||||
// read options
|
||||
// Read command line arguments
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
int error = 0;
|
||||
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
|
||||
|
@ -157,7 +158,7 @@ void init(int argc, char *argv[])
|
|||
exit(1);
|
||||
}
|
||||
}
|
||||
// Set signal handler
|
||||
// Set signal handlers
|
||||
signal_pending = 0;
|
||||
struct sigaction sa = {.sa_handler = signal_handler};
|
||||
struct sigaction sa_chld = {.sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT};
|
||||
|
@ -166,16 +167,6 @@ void init(int argc, char *argv[])
|
|||
sigaction(SIGTERM, &sa, 0);
|
||||
sigaction(SIGHUP, &sa, 0);
|
||||
sigaction(SIGCHLD, &sa_chld, 0);
|
||||
|
||||
// BSD does not support pselect(), therefore we have to use select and hope that we do not
|
||||
// end up in a race condition there (see 'man select()' on a linux machine for more information)
|
||||
// block all signals, such that no race conditions occur before pselect in our main loop
|
||||
// sigset_t block_mask;
|
||||
// sigaddset(&block_mask, SIGINT);
|
||||
// sigaddset(&block_mask, SIGTERM);
|
||||
// sigaddset(&block_mask, SIGHUP);
|
||||
// sigaddset(&block_mask, SIGUSR1);
|
||||
// sigprocmask(SIG_BLOCK, &block_mask, 0);
|
||||
}
|
||||
|
||||
static int sn_pipe_valid = 0;
|
||||
|
@ -267,6 +258,8 @@ void init_X11_pre_config()
|
|||
get_desktops();
|
||||
|
||||
server.disable_transparency = 0;
|
||||
|
||||
xsettings_client = xsettings_client_new(server.dsp, server.screen, xsettings_notify_cb, NULL, NULL);
|
||||
}
|
||||
|
||||
void init_X11_post_config()
|
||||
|
@ -301,12 +294,9 @@ void init_X11_post_config()
|
|||
imlib_context_set_colormap(server.colormap);
|
||||
|
||||
// load default icon
|
||||
gchar *path;
|
||||
const gchar *const *data_dirs;
|
||||
data_dirs = g_get_system_data_dirs();
|
||||
int i;
|
||||
for (i = 0; data_dirs[i] != NULL; i++) {
|
||||
path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
|
||||
const gchar *const *data_dirs = g_get_system_data_dirs();
|
||||
for (int i = 0; data_dirs[i] != NULL; i++) {
|
||||
gchar *path = g_build_filename(data_dirs[i], "tint2", "default_icon.png", NULL);
|
||||
if (g_file_test(path, G_FILE_TEST_EXISTS))
|
||||
default_icon = imlib_load_image(path);
|
||||
g_free(path);
|
||||
|
@ -333,6 +323,9 @@ void cleanup()
|
|||
}
|
||||
imlib_context_disconnect_display();
|
||||
|
||||
xsettings_client_destroy(xsettings_client);
|
||||
xsettings_client = NULL;
|
||||
|
||||
cleanup_server();
|
||||
cleanup_timeout();
|
||||
if (server.dsp)
|
||||
|
|
|
@ -35,6 +35,8 @@ void start_show_timeout();
|
|||
void start_hide_timeout();
|
||||
void stop_tooltip_timeout();
|
||||
|
||||
void tooltip_init_fonts();
|
||||
|
||||
Tooltip g_tooltip;
|
||||
|
||||
void default_tooltip()
|
||||
|
@ -63,10 +65,9 @@ void cleanup_tooltip()
|
|||
|
||||
void init_tooltip()
|
||||
{
|
||||
if (!g_tooltip.font_desc)
|
||||
g_tooltip.font_desc = pango_font_description_from_string(DEFAULT_FONT);
|
||||
if (!g_tooltip.bg)
|
||||
g_tooltip.bg = &g_array_index(backgrounds, Background, 0);
|
||||
tooltip_init_fonts();
|
||||
|
||||
XSetWindowAttributes attr;
|
||||
attr.override_redirect = True;
|
||||
|
@ -77,10 +78,39 @@ void init_tooltip()
|
|||
unsigned long mask = CWEventMask | CWColormap | CWBorderPixel | CWBackPixel | CWOverrideRedirect;
|
||||
if (g_tooltip.window)
|
||||
XDestroyWindow(server.dsp, g_tooltip.window);
|
||||
g_tooltip.window =
|
||||
XCreateWindow(server.dsp, server.root_win, 0, 0, 100, 20, 0, server.depth, InputOutput, server.visual, mask, &attr);
|
||||
g_tooltip.window = XCreateWindow(server.dsp,
|
||||
server.root_win,
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
20,
|
||||
0,
|
||||
server.depth,
|
||||
InputOutput,
|
||||
server.visual,
|
||||
mask,
|
||||
&attr);
|
||||
}
|
||||
|
||||
void tooltip_init_fonts()
|
||||
{
|
||||
if (!g_tooltip.font_desc)
|
||||
g_tooltip.font_desc = pango_font_description_from_string(get_default_font());
|
||||
}
|
||||
|
||||
void tooltip_default_font_changed()
|
||||
{
|
||||
if (g_tooltip.has_font)
|
||||
return;
|
||||
if (!g_tooltip.has_font) {
|
||||
pango_font_description_free(g_tooltip.font_desc);
|
||||
g_tooltip.font_desc = NULL;
|
||||
}
|
||||
tooltip_init_fonts();
|
||||
tooltip_update();
|
||||
}
|
||||
|
||||
|
||||
void tooltip_trigger_show(Area *area, Panel *p, XEvent *e)
|
||||
{
|
||||
// Position the tooltip in the center of the area
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct {
|
|||
Bool mapped;
|
||||
int paddingx;
|
||||
int paddingy;
|
||||
gboolean has_font;
|
||||
PangoFontDescription *font_desc;
|
||||
Color font_color;
|
||||
Background *bg;
|
||||
|
@ -53,5 +54,6 @@ void tooltip_update();
|
|||
void tooltip_trigger_hide();
|
||||
void tooltip_hide(void * /*arg*/);
|
||||
void tooltip_copy_text(Area *area);
|
||||
void tooltip_default_font_changed();
|
||||
|
||||
#endif // TOOLTIP_H
|
||||
|
|
Loading…
Reference in a new issue