Add option to debug geometry (set env var DEBUG_GEOMETRY) (issue #583)
This commit is contained in:
parent
95a9e8a82e
commit
fc56e48781
12 changed files with 297 additions and 101 deletions
|
@ -58,6 +58,7 @@ gboolean battery_found;
|
|||
|
||||
void battery_init_fonts();
|
||||
char *battery_get_tooltip(void *obj);
|
||||
void battery_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_battery()
|
||||
{
|
||||
|
@ -382,6 +383,23 @@ void draw_battery(void *obj, cairo_t *c)
|
|||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
void battery_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Battery *battery = obj;
|
||||
fprintf(stderr,
|
||||
"%*sText 1: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
battery->bat1_posy,
|
||||
buf_bat_percentage);
|
||||
fprintf(stderr,
|
||||
"%*sText 2: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
battery->bat2_posy,
|
||||
buf_bat_time);
|
||||
}
|
||||
|
||||
char *battery_get_tooltip(void *obj)
|
||||
{
|
||||
return battery_os_tooltip();
|
||||
|
|
|
@ -55,6 +55,7 @@ static timeout *clock_timeout;
|
|||
|
||||
void clock_init_fonts();
|
||||
char *clock_get_tooltip(void *obj);
|
||||
void clock_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_clock()
|
||||
{
|
||||
|
@ -188,6 +189,7 @@ void init_clock_panel(void *p)
|
|||
clock->area._draw_foreground = draw_clock;
|
||||
clock->area.size_mode = LAYOUT_FIXED;
|
||||
clock->area._resize = resize_clock;
|
||||
clock->area._dump_geometry = clock_dump_geometry;
|
||||
// check consistency
|
||||
if (!time1_format)
|
||||
return;
|
||||
|
@ -334,6 +336,26 @@ void draw_clock(void *obj, cairo_t *c)
|
|||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
void clock_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Clock *clock = (Clock *)obj;
|
||||
fprintf(stderr,
|
||||
"%*sText 1: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
clock->time1_posy,
|
||||
buf_time);
|
||||
if (time2_format) {
|
||||
fprintf(stderr,
|
||||
"%*sText 2: y = %d, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
clock->time2_posy,
|
||||
buf_date);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
char *clock_get_tooltip(void *obj)
|
||||
{
|
||||
strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
void execp_timer_callback(void *arg);
|
||||
char *execp_get_tooltip(void *obj);
|
||||
void execp_init_fonts();
|
||||
void execp_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_execp()
|
||||
{
|
||||
|
@ -157,17 +158,21 @@ void init_execp_panel(void *p)
|
|||
execp->area.paddingxlr = execp->backend->paddingxlr;
|
||||
execp->area.parent = panel;
|
||||
execp->area.panel = panel;
|
||||
snprintf(execp->area.name, sizeof(execp->area.name), "Execp %s", execp->backend->command ? execp->backend->command : "null");
|
||||
execp->area._dump_geometry = execp_dump_geometry;
|
||||
snprintf(execp->area.name,
|
||||
sizeof(execp->area.name),
|
||||
"Execp %s",
|
||||
execp->backend->command ? execp->backend->command : "null");
|
||||
execp->area._draw_foreground = draw_execp;
|
||||
execp->area.size_mode = LAYOUT_FIXED;
|
||||
execp->area._resize = resize_execp;
|
||||
execp->area._get_tooltip_text = execp_get_tooltip;
|
||||
execp->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
execp->area.has_mouse_press_effect =
|
||||
panel_config.mouse_effects &&
|
||||
(execp->area.has_mouse_over_effect = execp->backend->lclick_command || execp->backend->mclick_command ||
|
||||
execp->backend->rclick_command || execp->backend->uwheel_command ||
|
||||
execp->backend->dwheel_command);
|
||||
panel_config.mouse_effects &&
|
||||
(execp->area.has_mouse_over_effect = execp->backend->lclick_command || execp->backend->mclick_command ||
|
||||
execp->backend->rclick_command || execp->backend->uwheel_command ||
|
||||
execp->backend->dwheel_command);
|
||||
|
||||
execp->area.resize_needed = TRUE;
|
||||
execp->area.on_screen = TRUE;
|
||||
|
@ -265,7 +270,7 @@ gboolean reload_icon(Execp *execp)
|
|||
}
|
||||
if (w != imlib_image_get_width() || h != imlib_image_get_height()) {
|
||||
Imlib_Image icon_scaled =
|
||||
imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), w, h);
|
||||
imlib_create_cropped_scaled_image(0, 0, imlib_image_get_width(), imlib_image_get_height(), w, h);
|
||||
imlib_context_set_image(execp->backend->icon);
|
||||
imlib_free_image();
|
||||
execp->backend->icon = icon_scaled;
|
||||
|
@ -304,31 +309,31 @@ gboolean resize_execp(void *obj)
|
|||
int txt_height_ink, txt_height, txt_width;
|
||||
if (panel_horizontal) {
|
||||
get_text_size2(execp->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
panel->area.width,
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
} else {
|
||||
get_text_size2(execp->backend->font_desc,
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
!text_next_line
|
||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) -
|
||||
2 * horiz_padding - left_right_border_width(&execp->area)
|
||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
&txt_height_ink,
|
||||
&txt_height,
|
||||
&txt_width,
|
||||
panel->area.height,
|
||||
!text_next_line
|
||||
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding -
|
||||
left_right_border_width(&execp->area)
|
||||
: execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area),
|
||||
execp->backend->text,
|
||||
strlen(execp->backend->text),
|
||||
PANGO_WRAP_WORD_CHAR,
|
||||
PANGO_ELLIPSIZE_NONE,
|
||||
execp->backend->has_markup);
|
||||
}
|
||||
|
||||
gboolean result = FALSE;
|
||||
|
@ -348,7 +353,8 @@ gboolean resize_execp(void *obj)
|
|||
new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area));
|
||||
} else {
|
||||
new_size = icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
new_size =
|
||||
icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area);
|
||||
}
|
||||
if (new_size != execp->area.height) {
|
||||
execp->area.height = new_size;
|
||||
|
@ -420,15 +426,44 @@ void draw_execp(void *obj, cairo_t *c)
|
|||
|
||||
pango_cairo_update_layout(c, layout);
|
||||
draw_text(layout,
|
||||
c,
|
||||
execp->frontend->textx,
|
||||
execp->frontend->texty,
|
||||
&execp->backend->font_color,
|
||||
panel_config.font_shadow);
|
||||
c,
|
||||
execp->frontend->textx,
|
||||
execp->frontend->texty,
|
||||
&execp->backend->font_color,
|
||||
panel_config.font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
void execp_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
|
||||
if (execp->backend->has_icon && execp->backend->icon) {
|
||||
Imlib_Image tmp = imlib_context_get_image();
|
||||
imlib_context_set_image(execp->backend->icon);
|
||||
fprintf(stderr,
|
||||
"%*sIcon: x = %d, y = %d, w = %d\n",
|
||||
indent,
|
||||
"",
|
||||
execp->frontend->iconx,
|
||||
execp->frontend->icony,
|
||||
imlib_image_get_width(),
|
||||
imlib_image_get_height());
|
||||
if (tmp)
|
||||
imlib_context_set_image(tmp);
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%*sText: x = %d, y = %d, w = %d, h = %d, align = %s, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
execp->frontend->textx,
|
||||
execp->frontend->texty,
|
||||
execp->frontend->textw,
|
||||
execp->backend->centered ? "center" : "left",
|
||||
execp->backend->text);
|
||||
}
|
||||
|
||||
void execp_action(void *obj, int button, int x, int y)
|
||||
{
|
||||
Execp *execp = obj;
|
||||
|
@ -537,8 +572,8 @@ gboolean read_execp(void *obj)
|
|||
execp->backend->buf_output = realloc(execp->backend->buf_output, execp->backend->buf_capacity);
|
||||
}
|
||||
ssize_t count = read(execp->backend->child_pipe,
|
||||
execp->backend->buf_output + execp->backend->buf_length,
|
||||
execp->backend->buf_capacity - execp->backend->buf_length - 1);
|
||||
execp->backend->buf_output + execp->backend->buf_length,
|
||||
execp->backend->buf_capacity - execp->backend->buf_length - 1);
|
||||
if (count > 0) {
|
||||
// Successful read
|
||||
execp->backend->buf_length += count;
|
||||
|
@ -568,7 +603,7 @@ gboolean read_execp(void *obj)
|
|||
execp->backend->child_pipe = -1;
|
||||
if (execp->backend->interval)
|
||||
execp->backend->timer =
|
||||
add_timeout(execp->backend->interval * 1000, 0, execp_timer_callback, execp, &execp->backend->timer);
|
||||
add_timeout(execp->backend->interval * 1000, 0, execp_timer_callback, execp, &execp->backend->timer);
|
||||
}
|
||||
|
||||
if (!execp->backend->continuous && command_finished) {
|
||||
|
@ -594,7 +629,7 @@ gboolean read_execp(void *obj)
|
|||
execp->backend->buf_output[execp->backend->buf_length] = '\0';
|
||||
execp->backend->last_update_finish_time = time(NULL);
|
||||
execp->backend->last_update_duration =
|
||||
execp->backend->last_update_finish_time - execp->backend->last_update_start_time;
|
||||
execp->backend->last_update_finish_time - execp->backend->last_update_start_time;
|
||||
return TRUE;
|
||||
} else if (execp->backend->continuous > 0) {
|
||||
// Count lines in buffer
|
||||
|
@ -649,7 +684,7 @@ gboolean read_execp(void *obj)
|
|||
|
||||
execp->backend->last_update_finish_time = time(NULL);
|
||||
execp->backend->last_update_duration =
|
||||
execp->backend->last_update_finish_time - execp->backend->last_update_start_time;
|
||||
execp->backend->last_update_finish_time - execp->backend->last_update_start_time;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -698,16 +733,16 @@ char *execp_get_tooltip(void *obj)
|
|||
// We updated at least once
|
||||
if (execp->backend->interval > 0) {
|
||||
sprintf(execp->backend->tooltip_text,
|
||||
"Last update finished %s ago (took %s). Next update starting in %s.",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)execp->backend->last_update_duration, tmp_buf2),
|
||||
time_to_string((int)(execp->backend->interval - (now - execp->backend->last_update_finish_time)),
|
||||
tmp_buf3));
|
||||
"Last update finished %s ago (took %s). Next update starting in %s.",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)execp->backend->last_update_duration, tmp_buf2),
|
||||
time_to_string((int)(execp->backend->interval - (now - execp->backend->last_update_finish_time)),
|
||||
tmp_buf3));
|
||||
} else {
|
||||
sprintf(execp->backend->tooltip_text,
|
||||
"Last update finished %s ago (took %s).",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)execp->backend->last_update_duration, tmp_buf2));
|
||||
"Last update finished %s ago (took %s).",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)execp->backend->last_update_duration, tmp_buf2));
|
||||
}
|
||||
} else {
|
||||
// we never requested an update
|
||||
|
@ -718,14 +753,14 @@ char *execp_get_tooltip(void *obj)
|
|||
if (execp->backend->last_update_finish_time) {
|
||||
// we finished updating at least once
|
||||
sprintf(execp->backend->tooltip_text,
|
||||
"Last update finished %s ago. Update in progress (started %s ago).",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf3));
|
||||
"Last update finished %s ago. Update in progress (started %s ago).",
|
||||
time_to_string((int)(now - execp->backend->last_update_finish_time), tmp_buf1),
|
||||
time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf3));
|
||||
} else {
|
||||
// we never finished an update
|
||||
sprintf(execp->backend->tooltip_text,
|
||||
"First update in progress (started %s seconds ago).",
|
||||
time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf1));
|
||||
"First update in progress (started %s seconds ago).",
|
||||
time_to_string((int)(now - execp->backend->last_update_start_time), tmp_buf1));
|
||||
}
|
||||
}
|
||||
return strdup(execp->backend->tooltip_text);
|
||||
|
|
|
@ -56,6 +56,7 @@ Background *launcher_icon_bg;
|
|||
|
||||
Imlib_Image scale_icon(Imlib_Image original, int icon_size);
|
||||
void free_icon(Imlib_Image icon);
|
||||
void launcher_icon_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_launcher()
|
||||
{
|
||||
|
@ -346,6 +347,17 @@ void draw_launcher_icon(void *obj, cairo_t *c)
|
|||
render_image(launcherIcon->area.pix, 0, 0);
|
||||
}
|
||||
|
||||
void launcher_icon_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
LauncherIcon *launcherIcon = (LauncherIcon *)obj;
|
||||
fprintf(stderr,
|
||||
"%*sIcon: w = h = %d, name = %s\n",
|
||||
indent,
|
||||
"",
|
||||
launcherIcon->icon_size,
|
||||
launcherIcon->icon_name);
|
||||
}
|
||||
|
||||
Imlib_Image scale_icon(Imlib_Image original, int icon_size)
|
||||
{
|
||||
Imlib_Image icon_scaled;
|
||||
|
@ -468,6 +480,7 @@ void launcher_load_icons(Launcher *launcher)
|
|||
launcherIcon->area.bg = launcher_icon_bg;
|
||||
launcherIcon->area.on_screen = TRUE;
|
||||
launcherIcon->area._on_change_layout = launcher_icon_on_change_layout;
|
||||
launcherIcon->area._dump_geometry = launcher_icon_dump_geometry;
|
||||
if (launcher_tooltip_enabled) {
|
||||
launcherIcon->area._get_tooltip_text = launcher_icon_get_tooltip_text;
|
||||
} else {
|
||||
|
|
|
@ -55,6 +55,7 @@ gboolean panel_horizontal;
|
|||
gboolean panel_refresh;
|
||||
gboolean task_dragged;
|
||||
char *panel_window_name = NULL;
|
||||
gboolean debug_geometry;
|
||||
|
||||
gboolean panel_autohide;
|
||||
int panel_autohide_show_timeout;
|
||||
|
@ -942,6 +943,8 @@ void autohide_trigger_hide(Panel *p)
|
|||
void render_panel(Panel *panel)
|
||||
{
|
||||
relayout(&panel->area);
|
||||
if (debug_geometry)
|
||||
area_dump_geometry(&panel->area, 0);
|
||||
draw_tree(&panel->area);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ extern Imlib_Image default_icon;
|
|||
#define DEFAULT_FONT "sans 10"
|
||||
extern char *default_font;
|
||||
extern XSettingsClient *xsettings_client;
|
||||
extern gboolean debug_geometry;
|
||||
|
||||
typedef struct Panel {
|
||||
Area area;
|
||||
|
|
|
@ -65,6 +65,8 @@ const int slow_resize_period = 5000;
|
|||
const int min_bad_resize_events = 3;
|
||||
const int max_bad_resize_events = 10;
|
||||
|
||||
void systray_dump_geometry(void *obj, int indent);
|
||||
|
||||
void default_systray()
|
||||
{
|
||||
systray_enabled = 0;
|
||||
|
@ -114,6 +116,7 @@ void init_systray_panel(void *p)
|
|||
Panel *panel = (Panel *)p;
|
||||
systray.area.parent = panel;
|
||||
systray.area.panel = panel;
|
||||
systray.area._dump_geometry = systray_dump_geometry;
|
||||
snprintf(systray.area.name, sizeof(systray.area.name), "Systray");
|
||||
if (!systray.area.bg)
|
||||
systray.area.bg = &g_array_index(backgrounds, Background, 0);
|
||||
|
@ -208,6 +211,29 @@ void draw_systray(void *obj, cairo_t *c)
|
|||
refresh_systray = TRUE;
|
||||
}
|
||||
|
||||
void systray_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Systray *tray = (Systray *)obj;
|
||||
|
||||
fprintf(stderr,
|
||||
"%*sIcons:\n",
|
||||
indent,
|
||||
"");
|
||||
indent += 2;
|
||||
for (GSList *l = tray->list_icons; l; l = l->next) {
|
||||
TrayWindow *traywin = (TrayWindow *)l->data;
|
||||
fprintf(stderr,
|
||||
"%*sIcon: x = %d, y = %d, w = %d, h = %d, name = %s\n",
|
||||
indent,
|
||||
"",
|
||||
traywin->x,
|
||||
traywin->y,
|
||||
traywin->width,
|
||||
traywin->height,
|
||||
traywin->name);
|
||||
}
|
||||
}
|
||||
|
||||
void on_change_systray(void *obj)
|
||||
{
|
||||
if (systray_profile)
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
timeout *urgent_timeout;
|
||||
GSList *urgent_list;
|
||||
|
||||
void task_dump_geometry(void *obj, int indent);
|
||||
|
||||
char *task_get_tooltip(void *obj)
|
||||
{
|
||||
Task *t = (Task *)obj;
|
||||
|
@ -68,6 +70,7 @@ Task *add_task(Window win)
|
|||
snprintf(task_template.area.name, sizeof(task_template.area.name), "Task %d", (int)win);
|
||||
task_template.area.has_mouse_over_effect = panel_config.mouse_effects;
|
||||
task_template.area.has_mouse_press_effect = panel_config.mouse_effects;
|
||||
task_template.area._dump_geometry = task_dump_geometry;
|
||||
task_template.area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
task_template.win = win;
|
||||
task_template.desktop = get_window_desktop(win);
|
||||
|
@ -83,7 +86,11 @@ Task *add_task(Window win)
|
|||
}
|
||||
task_update_title(&task_template);
|
||||
task_update_icon(&task_template);
|
||||
snprintf(task_template.area.name, sizeof(task_template.area.name), "Task %d %s", (int)win, task_template.title ? task_template.title : "null");
|
||||
snprintf(task_template.area.name,
|
||||
sizeof(task_template.area.name),
|
||||
"Task %d %s",
|
||||
(int)win,
|
||||
task_template.title ? task_template.title : "null");
|
||||
|
||||
// fprintf(stderr, "%s %d: win = %ld, task = %s\n", __FUNCTION__, __LINE__, win, task_template.title ?
|
||||
// task_template.title : "??");
|
||||
|
@ -99,6 +106,7 @@ Task *add_task(Window win)
|
|||
memcpy(&task_instance->area, &panels[monitor].g_task.area, sizeof(Area));
|
||||
task_instance->area.has_mouse_over_effect = panel_config.mouse_effects;
|
||||
task_instance->area.has_mouse_press_effect = panel_config.mouse_effects;
|
||||
task_instance->area._dump_geometry = task_dump_geometry;
|
||||
task_instance->area._is_under_mouse = full_width_area_is_under_mouse;
|
||||
task_instance->win = task_template.win;
|
||||
task_instance->desktop = task_template.desktop;
|
||||
|
@ -303,7 +311,7 @@ void task_update_icon(Task *task)
|
|||
int w = imlib_image_get_width();
|
||||
int h = imlib_image_get_height();
|
||||
Imlib_Image orig_image =
|
||||
imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1);
|
||||
imlib_create_cropped_scaled_image(0, 0, w, h, panel->g_task.icon_size1, panel->g_task.icon_size1);
|
||||
imlib_free_image();
|
||||
|
||||
imlib_context_set_image(orig_image);
|
||||
|
@ -317,22 +325,22 @@ void task_update_icon(Task *task)
|
|||
if (panel->g_task.alpha[k] != 100 || panel->g_task.saturation[k] != 0 || panel->g_task.brightness[k] != 0) {
|
||||
data32 = imlib_image_get_data();
|
||||
adjust_asb(data32,
|
||||
task->icon_width,
|
||||
task->icon_height,
|
||||
panel->g_task.alpha[k] / 100.0,
|
||||
panel->g_task.saturation[k] / 100.0,
|
||||
panel->g_task.brightness[k] / 100.0);
|
||||
task->icon_width,
|
||||
task->icon_height,
|
||||
panel->g_task.alpha[k] / 100.0,
|
||||
panel->g_task.saturation[k] / 100.0,
|
||||
panel->g_task.brightness[k] / 100.0);
|
||||
imlib_image_put_back_data(data32);
|
||||
}
|
||||
if (panel_config.mouse_effects) {
|
||||
task->icon_hover[k] = adjust_icon(task->icon[k],
|
||||
panel_config.mouse_over_alpha,
|
||||
panel_config.mouse_over_saturation,
|
||||
panel_config.mouse_over_brightness);
|
||||
panel_config.mouse_over_alpha,
|
||||
panel_config.mouse_over_saturation,
|
||||
panel_config.mouse_over_brightness);
|
||||
task->icon_press[k] = adjust_icon(task->icon[k],
|
||||
panel_config.mouse_pressed_alpha,
|
||||
panel_config.mouse_pressed_saturation,
|
||||
panel_config.mouse_pressed_brightness);
|
||||
panel_config.mouse_pressed_alpha,
|
||||
panel_config.mouse_pressed_saturation,
|
||||
panel_config.mouse_pressed_brightness);
|
||||
}
|
||||
}
|
||||
imlib_context_set_image(orig_image);
|
||||
|
@ -361,15 +369,14 @@ void draw_task_icon(Task *task, int text_width)
|
|||
return;
|
||||
|
||||
// Find pos
|
||||
int pos_x;
|
||||
Panel *panel = (Panel *)task->area.panel;
|
||||
if (panel->g_task.centered) {
|
||||
if (panel->g_task.has_text)
|
||||
pos_x = (task->area.width - text_width - panel->g_task.icon_size1) / 2;
|
||||
task->_icon_x = (task->area.width - text_width - panel->g_task.icon_size1) / 2;
|
||||
else
|
||||
pos_x = (task->area.width - panel->g_task.icon_size1) / 2;
|
||||
task->_icon_x = (task->area.width - panel->g_task.icon_size1) / 2;
|
||||
} else {
|
||||
pos_x = left_border_width(&task->area) + task->area.paddingxlr;
|
||||
task->_icon_x = left_border_width(&task->area) + task->area.paddingxlr;
|
||||
}
|
||||
|
||||
// Render
|
||||
|
@ -388,14 +395,8 @@ void draw_task_icon(Task *task, int text_width)
|
|||
}
|
||||
|
||||
imlib_context_set_image(image);
|
||||
render_image(task->area.pix, pos_x, (task->area.height - panel->g_task.icon_size1) / 2);
|
||||
if (0) {
|
||||
fprintf(stderr, "Task icon size: %d %d pos %d %d\n", imlib_image_get_width(), imlib_image_get_height(), pos_x, panel->g_task.icon_posy);
|
||||
fprintf(stderr, "Task max size : %d %d\n", panel->g_task.maximum_width, panel->g_task.maximum_height);
|
||||
fprintf(stderr, "Task area size: %d %d\n", task->area.width, task->area.height);
|
||||
fprintf(stderr, "Task border : %d\n", left_border_width(&task->area));
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
task->_icon_y = (task->area.height - panel->g_task.icon_size1) / 2;
|
||||
render_image(task->area.pix, task->_icon_x, task->_icon_y);
|
||||
}
|
||||
|
||||
void draw_task(void *obj, cairo_t *c)
|
||||
|
@ -403,7 +404,7 @@ void draw_task(void *obj, cairo_t *c)
|
|||
Task *task = (Task *)obj;
|
||||
Panel *panel = (Panel *)task->area.panel;
|
||||
|
||||
int text_width = 0;
|
||||
task->_text_width = 0;
|
||||
if (panel->g_task.has_text) {
|
||||
PangoLayout *layout = pango_cairo_create_layout(c);
|
||||
pango_layout_set_font_description(layout, panel->g_task.font_desc);
|
||||
|
@ -419,18 +420,41 @@ void draw_task(void *obj, cairo_t *c)
|
|||
else
|
||||
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
|
||||
|
||||
int text_height;
|
||||
pango_layout_get_pixel_size(layout, &text_width, &text_height);
|
||||
double text_posy = (panel->g_task.area.height - text_height) / 2.0;
|
||||
pango_layout_get_pixel_size(layout, &task->_text_width, &task->_text_height);
|
||||
task->_text_posy = (panel->g_task.area.height - task->_text_height) / 2.0;
|
||||
|
||||
Color *config_text = &panel->g_task.font[task->current_state];
|
||||
draw_text(layout, c, panel->g_task.text_posx, text_posy, config_text, panel->font_shadow);
|
||||
draw_text(layout, c, panel->g_task.text_posx, task->_text_posy, config_text, panel->font_shadow);
|
||||
|
||||
g_object_unref(layout);
|
||||
}
|
||||
|
||||
if (panel->g_task.has_icon)
|
||||
draw_task_icon(task, text_width);
|
||||
draw_task_icon(task, task->_text_width);
|
||||
}
|
||||
|
||||
void task_dump_geometry(void *obj, int indent)
|
||||
{
|
||||
Task *task = (Task *)obj;
|
||||
Panel *panel = (Panel *)task->area.panel;
|
||||
|
||||
fprintf(stderr,
|
||||
"%*sText: x = %d, y = %d, w = %d, h = %d, align = %s, text = %s\n",
|
||||
indent,
|
||||
"",
|
||||
(int)panel->g_task.text_posx,
|
||||
(int)task->_text_posy,
|
||||
task->_text_width,
|
||||
task->_text_height,
|
||||
panel->g_task.centered ? "center" : "left",
|
||||
task->title);
|
||||
fprintf(stderr,
|
||||
"%*sIcon: x = %d, y = %d, w = h = %d\n",
|
||||
indent,
|
||||
"",
|
||||
task->_icon_x,
|
||||
task->_icon_y,
|
||||
panel->g_task.icon_size1);
|
||||
}
|
||||
|
||||
void on_change_task(void *obj)
|
||||
|
@ -440,13 +464,13 @@ void on_change_task(void *obj)
|
|||
|
||||
long value[] = {panel->posx + task->area.posx, panel->posy + task->area.posy, task->area.width, task->area.height};
|
||||
XChangeProperty(server.display,
|
||||
task->win,
|
||||
server.atom._NET_WM_ICON_GEOMETRY,
|
||||
XA_CARDINAL,
|
||||
32,
|
||||
PropModeReplace,
|
||||
(unsigned char *)value,
|
||||
4);
|
||||
task->win,
|
||||
server.atom._NET_WM_ICON_GEOMETRY,
|
||||
XA_CARDINAL,
|
||||
32,
|
||||
PropModeReplace,
|
||||
(unsigned char *)value,
|
||||
4);
|
||||
}
|
||||
|
||||
Task *find_active_task(Task *current_task)
|
||||
|
@ -579,7 +603,7 @@ void set_task_state(Task *task, TaskState state)
|
|||
}
|
||||
}
|
||||
if (get_window_monitor(task->win) != ((Panel *)task->area.panel)->monitor &&
|
||||
(hide_task_diff_monitor || num_panels > 1)) {
|
||||
(hide_task_diff_monitor || num_panels > 1)) {
|
||||
hide = TRUE;
|
||||
}
|
||||
if ((!hide) != task1->area.on_screen) {
|
||||
|
|
|
@ -67,6 +67,11 @@ typedef struct Task {
|
|||
int win_w;
|
||||
int win_h;
|
||||
struct timespec last_activation_time;
|
||||
int _text_width;
|
||||
int _text_height;
|
||||
double _text_posy;
|
||||
int _icon_x;
|
||||
int _icon_y;
|
||||
} Task;
|
||||
|
||||
extern timeout *urgent_timeout;
|
||||
|
|
|
@ -372,6 +372,8 @@ void init(int argc, char *argv[])
|
|||
sigaction(SIGABRT, &sa_crash, 0);
|
||||
sigaction(SIGSYS, &sa_crash, 0);
|
||||
#endif
|
||||
|
||||
debug_geometry = getenv("DEBUG_GEOMETRY") != NULL;
|
||||
}
|
||||
|
||||
static int sn_pipe_valid = 0;
|
||||
|
|
|
@ -177,7 +177,8 @@ void relayout_dynamic(Area *a, int level)
|
|||
children_size += (l == a->children) ? 0 : a->paddingx;
|
||||
}
|
||||
|
||||
int pos = (panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr;
|
||||
int pos =
|
||||
(panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr;
|
||||
pos += ((panel_horizontal ? a->width : a->height) - children_size) / 2;
|
||||
|
||||
for (GList *l = a->children; l; l = l->next) {
|
||||
|
@ -459,10 +460,10 @@ void draw_background(Area *a, cairo_t *c)
|
|||
a->bg->fill_color.alpha);
|
||||
// Not sure about this
|
||||
draw_rect(c,
|
||||
left_border_width(a),
|
||||
top_border_width(a),
|
||||
a->width - left_right_border_width(a),
|
||||
a->height - top_bottom_border_width(a),
|
||||
left_border_width(a),
|
||||
top_border_width(a),
|
||||
a->width - left_right_border_width(a),
|
||||
a->height - top_bottom_border_width(a),
|
||||
a->bg->border.radius - a->bg->border.width / 1.571);
|
||||
|
||||
cairo_fill(c);
|
||||
|
@ -491,10 +492,10 @@ void draw_background(Area *a, cairo_t *c)
|
|||
a->bg->border.color.rgb[2],
|
||||
a->bg->border.color.alpha);
|
||||
draw_rect_on_sides(c,
|
||||
left_border_width(a) / 2.,
|
||||
top_border_width(a) / 2.,
|
||||
a->width - left_right_border_width(a) / 2.,
|
||||
a->height - top_bottom_border_width(a) / 2.,
|
||||
left_border_width(a) / 2.,
|
||||
top_border_width(a) / 2.,
|
||||
a->width - left_right_border_width(a) / 2.,
|
||||
a->height - top_bottom_border_width(a) / 2.,
|
||||
a->bg->border.radius,
|
||||
a->bg->border.mask);
|
||||
|
||||
|
@ -772,3 +773,44 @@ int top_bottom_bg_border_width(Background *bg)
|
|||
{
|
||||
return top_bg_border_width(bg) + bottom_bg_border_width(bg);
|
||||
}
|
||||
|
||||
void area_dump_geometry(Area *area, int indent)
|
||||
{
|
||||
fprintf(stderr, "%*s%s:\n", indent, "", area->name);
|
||||
indent += 2;
|
||||
if (!area->on_screen) {
|
||||
fprintf(stderr, "%*shidden\n", indent, "");
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,
|
||||
"%*sBox: x = %d, y = %d, w = %d, h = %d\n",
|
||||
indent,
|
||||
"",
|
||||
area->posx,
|
||||
area->posy,
|
||||
area->width,
|
||||
area->height);
|
||||
fprintf(stderr,
|
||||
"%*sBorder: left = %d, right = %d, top = %d, bottom = %d\n",
|
||||
indent,
|
||||
"",
|
||||
left_border_width(area),
|
||||
right_border_width(area),
|
||||
top_border_width(area),
|
||||
bottom_border_width(area));
|
||||
fprintf(stderr,
|
||||
"%*sPadding: left = right = %d, top = bottom = %d, spacing = %d\n",
|
||||
indent,
|
||||
"",
|
||||
area->paddingxlr,
|
||||
area->paddingy,
|
||||
area->paddingx);
|
||||
if (area->_dump_geometry)
|
||||
area->_dump_geometry(area, indent);
|
||||
if (area->children) {
|
||||
fprintf(stderr, "%*sChildren:\n", indent, "");
|
||||
indent += 2;
|
||||
for (GList *l = area->children; l; l = l->next)
|
||||
area_dump_geometry((Area *)l->data, indent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,6 +230,9 @@ typedef struct Area {
|
|||
// Returns true if the Area handles a mouse event at the given x, y coordinates relative to the window.
|
||||
// Leave this to NULL to use a default implementation.
|
||||
gboolean (*_is_under_mouse)(void *obj, int x, int y);
|
||||
|
||||
// Prints the geometry of the object on stderr, with left indentation of indent spaces.
|
||||
void (*_dump_geometry)(void *obj, int indent);
|
||||
} Area;
|
||||
|
||||
// Initializes the Background member to default values.
|
||||
|
@ -306,6 +309,8 @@ gboolean area_is_under_mouse(void *obj, int x, int y);
|
|||
// they are outside the drawing area of the button.
|
||||
gboolean full_width_area_is_under_mouse(void *obj, int x, int y);
|
||||
|
||||
void area_dump_geometry(Area *area, int indent);
|
||||
|
||||
void mouse_over(Area *area, int pressed);
|
||||
void mouse_out();
|
||||
|
||||
|
|
Loading…
Reference in a new issue