Compute layouts correctly with partial borders (issue #580)

This commit is contained in:
o9000 2016-05-21 15:14:57 +02:00
parent 77d2a74865
commit ed802d7602
13 changed files with 450 additions and 365 deletions

View file

@ -158,8 +158,8 @@ void init_battery_panel(void *p)
battery->area.on_screen = TRUE;
battery->area.resize_needed = 1;
battery->area.has_mouse_over_effect =
panel_config.mouse_effects && (battery_lclick_command || battery_mclick_command || battery_rclick_command ||
battery_uwheel_command || battery_dwheel_command);
panel_config.mouse_effects && (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;
@ -227,12 +227,12 @@ void update_battery_tick(void *arg)
}
if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING &&
!battery_low_cmd_sent) {
!battery_low_cmd_sent) {
tint_exec(battery_low_cmd);
battery_low_cmd_sent = TRUE;
}
if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING &&
battery_low_cmd_sent) {
battery_low_cmd_sent) {
battery_low_cmd_sent = FALSE;
}
@ -259,7 +259,7 @@ void update_battery_tick(void *arg)
// Redraw if needed
if (panels[i].battery.area.on_screen) {
if (old_found != battery_found || old_percentage != battery_state.percentage ||
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) {
panels[i].battery.area.resize_needed = TRUE;
panel_refresh = TRUE;
}
@ -302,31 +302,31 @@ gboolean resize_battery(void *obj)
snprintf(buf_bat_time, sizeof(buf_bat_time), "%02d:%02d", battery_state.time.hours, battery_state.time.minutes);
}
get_text_size2(bat1_font_desc,
&bat_percentage_height_ink,
&bat_percentage_height,
&bat_percentage_width,
panel->area.height,
panel->area.width,
buf_bat_percentage,
strlen(buf_bat_percentage),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
&bat_percentage_height_ink,
&bat_percentage_height,
&bat_percentage_width,
panel->area.height,
panel->area.width,
buf_bat_percentage,
strlen(buf_bat_percentage),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
get_text_size2(bat2_font_desc,
&bat_time_height_ink,
&bat_time_height,
&bat_time_width,
panel->area.height,
panel->area.width,
buf_bat_time,
strlen(buf_bat_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
&bat_time_height_ink,
&bat_time_height,
&bat_time_width,
panel->area.height,
panel->area.width,
buf_bat_time,
strlen(buf_bat_time),
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_NONE,
FALSE);
if (panel_horizontal) {
int new_size = (bat_percentage_width > bat_time_width) ? bat_percentage_width : bat_time_width;
new_size += 2 * battery->area.paddingxlr + 2 * battery->area.bg->border.width;
new_size += 2 * battery->area.paddingxlr + left_right_border_width(&battery->area);
if (new_size > battery->area.width || new_size < battery->area.width - 2) {
// we try to limit the number of resize
battery->area.width = new_size;
@ -335,8 +335,8 @@ gboolean resize_battery(void *obj)
ret = 1;
}
} else {
int new_size =
bat_percentage_height + bat_time_height + (2 * (battery->area.paddingxlr + battery->area.bg->border.width));
int new_size = bat_percentage_height + bat_time_height + 2 * battery->area.paddingxlr +
top_bottom_border_width(&battery->area);
if (new_size > battery->area.height || new_size < battery->area.height - 2) {
battery->area.height = new_size;
battery->bat1_posy = (battery->area.height - bat_percentage_height - bat_time_height - 2) / 2;

View file

@ -276,7 +276,7 @@ gboolean resize_clock(void *obj)
if (panel_horizontal) {
int new_size = (time_width > date_width) ? time_width : date_width;
new_size += (2 * clock->area.paddingxlr) + (2 * clock->area.bg->border.width);
new_size += 2 * clock->area.paddingxlr + left_right_border_width(&clock->area);
if (new_size > clock->area.width || new_size < (clock->area.width - 6)) {
// we try to limit the number of resizes
clock->area.width = new_size + 1;
@ -288,7 +288,7 @@ gboolean resize_clock(void *obj)
result = TRUE;
}
} else {
int new_size = time_height + date_height + (2 * (clock->area.paddingxlr + clock->area.bg->border.width));
int new_size = time_height + date_height + 2 * clock->area.paddingxlr + top_bottom_border_width(&clock->area);
if (new_size != clock->area.height) {
// we try to limit the number of resizes
clock->area.height = new_size;

View file

@ -322,8 +322,8 @@ gboolean resize_execp(void *obj)
panel->area.height,
!text_next_line
? execp->area.width - icon_w - (icon_w ? interior_padding : 0) -
2 * (horiz_padding + execp->area.bg->border.width)
: execp->area.width - 2 * (horiz_padding + execp->area.bg->border.width),
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,
@ -336,7 +336,7 @@ gboolean resize_execp(void *obj)
int new_size = txt_width;
if (icon_w)
new_size += interior_padding + icon_w;
new_size += 2 * (horiz_padding + execp->area.bg->border.width);
new_size += 2 * horiz_padding + left_right_border_width(&execp->area);
if (new_size > execp->area.width || new_size < (execp->area.width - 6)) {
// we try to limit the number of resize
execp->area.width = new_size + 1;
@ -345,12 +345,10 @@ gboolean resize_execp(void *obj)
} else {
int new_size;
if (!text_next_line) {
new_size = txt_height + (2 * (vert_padding + execp->area.bg->border.width));
if (new_size < icon_h + (2 * (vert_padding + execp->area.bg->border.width))) {
new_size = icon_h + (2 * (vert_padding + execp->area.bg->border.width));
}
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 + execp->area.bg->border.width));
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;
@ -380,18 +378,18 @@ gboolean resize_execp(void *obj)
if (icon_w) {
if (!text_next_line) {
execp->frontend->icony = (execp->area.height - icon_h) / 2;
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
execp->frontend->texty = (execp->area.height - txt_height) / 2;
execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding;
} else {
execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2;
execp->frontend->iconx = execp->area.bg->border.width + horiz_padding;
execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding;
execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding;
execp->frontend->textx = execp->frontend->iconx;
}
} else {
execp->frontend->texty = (execp->area.height - txt_height) / 2;
execp->frontend->textx = execp->area.bg->border.width + horiz_padding;
execp->frontend->textx = left_border_width(&execp->area) + horiz_padding;
}
}

View file

@ -57,15 +57,15 @@ int freespace_get_max_size(Panel *p)
continue;
if (panel_horizontal)
size += a->width + (a->bg->border.width * 2) + p->area.paddingx;
size += a->width + p->area.paddingx;
else
size += a->height + (a->bg->border.width * 2) + p->area.paddingy;
size += a->height + p->area.paddingy;
}
if (panel_horizontal)
size = p->area.width - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
size = p->area.width - size - left_right_border_width(&p->area) - p->area.paddingxlr;
else
size = p->area.height - size - (p->area.bg->border.width * 2) - p->area.paddingxlr;
size = p->area.height - size - top_bottom_border_width(&p->area) - p->area.paddingxlr;
return size;
}

View file

@ -163,7 +163,8 @@ gboolean resize_launcher(void *obj)
} else {
icon_size = launcher->area.width;
}
icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy);
icon_size = icon_size - MAX(left_right_border_width(&launcher->area), top_bottom_border_width(&launcher->area)) -
(2 * launcher->area.paddingy);
if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
icon_size = launcher_max_icon_size;
@ -177,7 +178,7 @@ gboolean resize_launcher(void *obj)
// Get the path for an icon file with the new size
char *new_icon_path =
get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size);
get_icon_path(launcher->icon_theme_wrapper, launcherIcon->icon_name, launcherIcon->icon_size);
if (!new_icon_path) {
// Draw a blank icon
free_icon(launcherIcon->image);
@ -217,13 +218,13 @@ gboolean resize_launcher(void *obj)
if (panel_config.mouse_effects) {
launcherIcon->image_hover = adjust_icon(launcherIcon->image,
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);
launcherIcon->image_pressed = adjust_icon(launcherIcon->image,
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);
}
}
save_icon_cache(launcher->icon_theme_wrapper);
@ -234,36 +235,36 @@ gboolean resize_launcher(void *obj)
if (!count) {
launcher->area.width = 0;
} else {
int height = launcher->area.height - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
int height = launcher->area.height - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_column always higher than 0
icons_per_column = (height + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = height - (icons_per_column - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_row = count / icons_per_column + (count % icons_per_column != 0);
launcher->area.width = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
launcher->area.width = left_right_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_row) + ((icons_per_row - 1) * launcher->area.paddingx);
}
} else {
if (!count) {
launcher->area.height = 0;
} else {
int width = launcher->area.width - 2 * launcher->area.bg->border.width - 2 * launcher->area.paddingy;
int width = launcher->area.width - top_bottom_border_width(&launcher->area) - 2 * launcher->area.paddingy;
// here icons_per_row always higher than 0
icons_per_row = (width + launcher->area.paddingx) / (icon_size + launcher->area.paddingx);
margin = width - (icons_per_row - 1) * (icon_size + launcher->area.paddingx) - icon_size;
icons_per_column = count / icons_per_row + (count % icons_per_row != 0);
launcher->area.height = (2 * launcher->area.bg->border.width) + (2 * launcher->area.paddingxlr) +
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
launcher->area.height = top_bottom_border_width(&launcher->area) + 2 * launcher->area.paddingxlr +
(icon_size * icons_per_column) + ((icons_per_column - 1) * launcher->area.paddingx);
}
}
int posx, posy;
int start = launcher->area.bg->border.width + launcher->area.paddingy + margin / 2;
int start;
if (panel_horizontal) {
posy = start;
posx = launcher->area.bg->border.width + launcher->area.paddingxlr;
posy = start = top_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
posx = left_border_width(&launcher->area) + launcher->area.paddingxlr;
} else {
posx = start;
posy = launcher->area.bg->border.width + launcher->area.paddingxlr;
posx = start = left_border_width(&launcher->area) + launcher->area.paddingy + margin / 2;
posy = top_border_width(&launcher->area) + launcher->area.paddingxlr;
}
int i;
@ -351,21 +352,21 @@ Imlib_Image scale_icon(Imlib_Image original, int icon_size)
if (original) {
imlib_context_set_image(original);
icon_scaled = imlib_create_cropped_scaled_image(0,
0,
imlib_image_get_width(),
imlib_image_get_height(),
icon_size,
icon_size);
0,
imlib_image_get_width(),
imlib_image_get_height(),
icon_size,
icon_size);
imlib_context_set_image(icon_scaled);
imlib_image_set_has_alpha(1);
DATA32 *data = imlib_image_get_data();
adjust_asb(data,
icon_size,
icon_size,
launcher_alpha / 100.0,
launcher_saturation / 100.0,
launcher_brightness / 100.0);
icon_size,
icon_size,
launcher_alpha / 100.0,
launcher_saturation / 100.0,
launcher_brightness / 100.0);
imlib_image_put_back_data(data);
imlib_context_set_image(icon_scaled);
@ -453,7 +454,10 @@ void launcher_load_icons(Launcher *launcher)
if (entry.exec) {
LauncherIcon *launcherIcon = calloc(1, sizeof(LauncherIcon));
launcherIcon->area.panel = launcher->area.panel;
snprintf(launcherIcon->area.name, sizeof(launcherIcon->area.name), "LauncherIcon %s", entry.name ? entry.name : "null");
snprintf(launcherIcon->area.name,
sizeof(launcherIcon->area.name),
"LauncherIcon %s",
entry.name ? entry.name : "null");
launcherIcon->area._draw_foreground = draw_launcher_icon;
launcherIcon->area.size_mode = LAYOUT_FIXED;
launcherIcon->area._resize = NULL;

View file

@ -184,10 +184,10 @@ void init_panel()
}
fprintf(stderr,
"tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n",
server.num_monitors,
num_panels,
server.num_desktops);
"tint2 : nb monitor %d, nb monitor used %d, nb desktop %d\n",
server.num_monitors,
num_panels,
server.num_desktops);
for (int i = 0; i < num_panels; i++) {
Panel *p = &panels[i];
@ -231,28 +231,28 @@ void init_panel()
XSetWindowAttributes att = {.colormap = server.colormap, .background_pixel = 0, .border_pixel = 0};
unsigned long mask = CWEventMask | CWColormap | CWBackPixel | CWBorderPixel;
p->main_win = XCreateWindow(server.display,
server.root_win,
p->posx,
p->posy,
p->area.width,
p->area.height,
0,
server.depth,
InputOutput,
server.visual,
mask,
&att);
server.root_win,
p->posx,
p->posy,
p->area.width,
p->area.height,
0,
server.depth,
InputOutput,
server.visual,
mask,
&att);
long event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | PropertyChangeMask;
if (p->mouse_effects || p->g_task.tooltip_enabled || p->clock.area._get_tooltip_text ||
(launcher_enabled && launcher_tooltip_enabled))
(launcher_enabled && launcher_tooltip_enabled))
event_mask |= PointerMotionMask | LeaveWindowMask;
if (panel_autohide)
event_mask |= LeaveWindowMask | EnterWindowMask;
XChangeWindowAttributes(server.display,
p->main_win,
CWEventMask,
&(XSetWindowAttributes){.event_mask = event_mask});
p->main_win,
CWEventMask,
&(XSetWindowAttributes){.event_mask = event_mask});
if (!server.gc) {
XGCValues gcv;
@ -337,11 +337,11 @@ void init_panel_size_and_position(Panel *panel)
} else {
if (panel_position & RIGHT) {
panel->posx = server.monitors[panel->monitor].x + server.monitors[panel->monitor].width -
panel->area.width - panel->marginx;
panel->area.width - panel->marginx;
} else {
if (panel_horizontal)
panel->posx = server.monitors[panel->monitor].x +
((server.monitors[panel->monitor].width - panel->area.width) / 2);
((server.monitors[panel->monitor].width - panel->area.width) / 2);
else
panel->posx = server.monitors[panel->monitor].x + panel->marginx;
}
@ -351,10 +351,10 @@ void init_panel_size_and_position(Panel *panel)
} else {
if (panel_position & BOTTOM) {
panel->posy = server.monitors[panel->monitor].y + server.monitors[panel->monitor].height -
panel->area.height - panel->marginy;
panel->area.height - panel->marginy;
} else {
panel->posy =
server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2);
server.monitors[panel->monitor].y + ((server.monitors[panel->monitor].height - panel->area.height) / 2);
}
}
@ -435,7 +435,9 @@ gboolean resize_panel(void *obj)
for (int i = 0; i < panel->num_desktops; i++) {
Taskbar *taskbar = &panel->taskbar[i];
int requested_size = (2 * taskbar->area.bg->border.width) + (2 * taskbar->area.paddingxlr);
int requested_size = (panel_horizontal ? left_right_border_width(&taskbar->area)
: top_bottom_border_width(&taskbar->area)) +
2 * taskbar->area.paddingxlr;
int items = 0;
GList *l = taskbar->area.children;
if (taskbarname_enabled)
@ -519,21 +521,21 @@ void update_strut(Panel *p)
}
// Old specification : fluxbox need _NET_WM_STRUT.
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_STRUT,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&struts,
4);
p->main_win,
server.atom._NET_WM_STRUT,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&struts,
4);
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_STRUT_PARTIAL,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&struts,
12);
p->main_win,
server.atom._NET_WM_STRUT_PARTIAL,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&struts,
12);
}
void set_panel_items_order(Panel *p)
@ -579,13 +581,13 @@ void place_panel_all_desktops(Panel *p)
{
long val = ALL_DESKTOPS;
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_DESKTOP,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&val,
1);
p->main_win,
server.atom._NET_WM_DESKTOP,
XA_CARDINAL,
32,
PropModeReplace,
(unsigned char *)&val,
1);
Atom state[4];
state[0] = server.atom._NET_WM_STATE_SKIP_PAGER;
@ -594,13 +596,13 @@ void place_panel_all_desktops(Panel *p)
state[3] = panel_layer == BOTTOM_LAYER ? server.atom._NET_WM_STATE_BELOW : server.atom._NET_WM_STATE_ABOVE;
int num_atoms = panel_layer == NORMAL_LAYER ? 3 : 4;
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_STATE,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)state,
num_atoms);
p->main_win,
server.atom._NET_WM_STATE,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)state,
num_atoms);
}
void replace_panel_all_desktops(Panel *p)
@ -627,34 +629,34 @@ void set_panel_properties(Panel *p)
gchar *name = g_locale_to_utf8(panel_window_name, -1, NULL, &len, NULL);
if (name != NULL) {
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_NAME,
server.atom.UTF8_STRING,
8,
PropModeReplace,
(unsigned char *)name,
(int)len);
p->main_win,
server.atom._NET_WM_NAME,
server.atom.UTF8_STRING,
8,
PropModeReplace,
(unsigned char *)name,
(int)len);
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_ICON_NAME,
server.atom.UTF8_STRING,
8,
PropModeReplace,
(unsigned char *)name,
(int)len);
p->main_win,
server.atom._NET_WM_ICON_NAME,
server.atom.UTF8_STRING,
8,
PropModeReplace,
(unsigned char *)name,
(int)len);
g_free(name);
}
// Dock
long val = server.atom._NET_WM_WINDOW_TYPE_DOCK;
XChangeProperty(server.display,
p->main_win,
server.atom._NET_WM_WINDOW_TYPE,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)&val,
1);
p->main_win,
server.atom._NET_WM_WINDOW_TYPE,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)&val,
1);
place_panel_all_desktops(p);
@ -675,24 +677,24 @@ void set_panel_properties(Panel *p)
// Undecorated
long prop[5] = {2, 0, 0, 0, 0};
XChangeProperty(server.display,
p->main_win,
server.atom._MOTIF_WM_HINTS,
server.atom._MOTIF_WM_HINTS,
32,
PropModeReplace,
(unsigned char *)prop,
5);
p->main_win,
server.atom._MOTIF_WM_HINTS,
server.atom._MOTIF_WM_HINTS,
32,
PropModeReplace,
(unsigned char *)prop,
5);
// XdndAware - Register for Xdnd events
Atom version = 4;
XChangeProperty(server.display,
p->main_win,
server.atom.XdndAware,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)&version,
1);
p->main_win,
server.atom.XdndAware,
XA_ATOM,
32,
PropModeReplace,
(unsigned char *)&version,
1);
update_strut(p);
@ -858,21 +860,21 @@ void autohide_show(void *p)
XResizeWindow(server.display, panel->main_win, panel->area.width, panel->area.height);
else
XMoveResizeWindow(server.display,
panel->main_win,
panel->posx,
panel->posy,
panel->area.width,
panel->area.height);
panel->main_win,
panel->posx,
panel->posy,
panel->area.width,
panel->area.height);
} else {
if (panel_position & LEFT)
XResizeWindow(server.display, panel->main_win, panel->area.width, panel->area.height);
else
XMoveResizeWindow(server.display,
panel->main_win,
panel->posx,
panel->posy,
panel->area.width,
panel->area.height);
panel->main_win,
panel->posx,
panel->posy,
panel->area.width,
panel->area.height);
}
if (panel_strut_policy == STRUT_FOLLOW_SIZE)
update_strut(panel);
@ -896,21 +898,21 @@ void autohide_hide(void *p)
XResizeWindow(server.display, panel->main_win, panel->hidden_width, panel->hidden_height);
else
XMoveResizeWindow(server.display,
panel->main_win,
panel->posx,
panel->posy + diff,
panel->hidden_width,
panel->hidden_height);
panel->main_win,
panel->posx,
panel->posy + diff,
panel->hidden_width,
panel->hidden_height);
} else {
if (panel_position & LEFT)
XResizeWindow(server.display, panel->main_win, panel->hidden_width, panel->hidden_height);
else
XMoveResizeWindow(server.display,
panel->main_win,
panel->posx + diff,
panel->posy,
panel->hidden_width,
panel->hidden_height);
panel->main_win,
panel->posx + diff,
panel->posy,
panel->hidden_width,
panel->hidden_height);
}
panel_refresh = TRUE;
}

View file

@ -131,7 +131,8 @@ gboolean resize_systray(void *obj)
systray.icon_size = systray.area.height;
else
systray.icon_size = systray.area.width;
systray.icon_size -= (2 * systray.area.bg->border.width) + (2 * systray.area.paddingy);
systray.icon_size -= MAX(left_right_border_width(&systray.area), top_bottom_border_width(&systray.area)) +
2 * systray.area.paddingy;
if (systray_max_icon_size > 0)
systray.icon_size = MIN(systray.icon_size, systray_max_icon_size);
@ -155,25 +156,25 @@ gboolean resize_systray(void *obj)
fprintf(stderr, BLUE "%s:%d number of icons = %d" RESET "\n", __FUNCTION__, __LINE__, count);
if (panel_horizontal) {
int height = systray.area.height - 2 * systray.area.bg->border.width - 2 * systray.area.paddingy;
int height = systray.area.height - top_bottom_border_width(&systray.area) - 2 * systray.area.paddingy;
// here icons_per_column always higher than 0
systray.icons_per_column = (height + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
systray.margin =
height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
height - (systray.icons_per_column - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
systray.icons_per_row = count / systray.icons_per_column + (count % systray.icons_per_column != 0);
systray.area.width = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) +
(systray.icon_size * systray.icons_per_row) +
((systray.icons_per_row - 1) * systray.area.paddingx);
systray.area.width = left_right_border_width(&systray.area) + 2 * systray.area.paddingxlr +
(systray.icon_size * systray.icons_per_row) +
((systray.icons_per_row - 1) * systray.area.paddingx);
} else {
int width = systray.area.width - 2 * systray.area.bg->border.width - 2 * systray.area.paddingy;
int width = systray.area.width - left_right_border_width(&systray.area) - 2 * systray.area.paddingy;
// here icons_per_row always higher than 0
systray.icons_per_row = (width + systray.area.paddingx) / (systray.icon_size + systray.area.paddingx);
systray.margin =
width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
width - (systray.icons_per_row - 1) * (systray.icon_size + systray.area.paddingx) - systray.icon_size;
systray.icons_per_column = count / systray.icons_per_row + (count % systray.icons_per_row != 0);
systray.area.height = (2 * systray.area.bg->border.width) + (2 * systray.area.paddingxlr) +
(systray.icon_size * systray.icons_per_column) +
((systray.icons_per_column - 1) * systray.area.paddingx);
systray.area.height = top_bottom_border_width(&systray.area) + (2 * systray.area.paddingxlr) +
(systray.icon_size * systray.icons_per_column) +
((systray.icons_per_column - 1) * systray.area.paddingx);
}
if (net_sel_win == None) {
@ -191,7 +192,7 @@ void draw_systray(void *obj, cairo_t *c)
if (render_background)
XFreePixmap(server.display, render_background);
render_background =
XCreatePixmap(server.display, server.root_win, systray.area.width, systray.area.height, server.depth);
XCreatePixmap(server.display, server.root_win, systray.area.width, systray.area.height, server.depth);
XCopyArea(server.display,
systray.area.pix,
render_background,
@ -218,14 +219,15 @@ void on_change_systray(void *obj)
// Based on this we calculate the positions of the tray icons.
Panel *panel = systray.area.panel;
int posx, posy;
int start = panel->area.bg->border.width + panel->area.paddingy + systray.area.bg->border.width +
systray.area.paddingy + systray.margin / 2;
int start;
if (panel_horizontal) {
posy = start;
posx = systray.area.posx + systray.area.bg->border.width + systray.area.paddingxlr;
posy = start = top_border_width(&panel->area) + panel->area.paddingy + top_border_width(&systray.area) +
systray.area.paddingy + systray.margin / 2;
posx = systray.area.posx + left_border_width(&systray.area) + systray.area.paddingxlr;
} else {
posx = start;
posy = systray.area.posy + systray.area.bg->border.width + systray.area.paddingxlr;
posx = start = left_border_width(&panel->area) + panel->area.paddingy + left_border_width(&systray.area) +
systray.area.paddingy + systray.margin / 2;
posy = systray.area.posy + top_border_width(&systray.area) + systray.area.paddingxlr;
}
TrayWindow *traywin;
@ -275,7 +277,7 @@ void on_change_systray(void *obj)
if (width != traywin->width || height != traywin->height || xpos != traywin->x || ypos != traywin->y) {
if (systray_profile)
fprintf(stderr,
"XMoveResizeWindow(server.display, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, "
"XMoveResizeWindow(server.display, traywin->parent = %ld, traywin->x = %d, traywin->y = %d, "
"traywin->width = %d, traywin->height = %d)\n",
traywin->parent,
traywin->x,
@ -386,7 +388,7 @@ void start_net()
vid = XVisualIDFromVisual(server.visual);
XChangeProperty(server.display,
net_sel_win,
XInternAtom(server.display, "_NET_SYSTEM_TRAY_VISUAL", False),
XInternAtom(server.display, "_NET_SYSTEM_TRAY_VISUAL", False),
XA_VISUALID,
32,
PropModeReplace,
@ -535,7 +537,7 @@ gboolean add_icon(Window win)
XSelectInput(server.display, win, StructureNotifyMask | PropertyChangeMask | ResizeRedirectMask);
char *name = get_window_name(win);
char *name = get_window_name(win);
if (systray_profile)
fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name);
Panel *panel = systray.area.panel;
@ -589,7 +591,7 @@ gboolean add_icon(Window win)
XSetWindowAttributes set_attr;
Visual *visual = server.visual;
fprintf(stderr,
GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n",
GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n",
win,
name,
pid,
@ -668,10 +670,10 @@ gboolean add_icon(Window win)
// Resize and redraw the systray
if (systray_profile)
fprintf(stderr,
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
systray.area.resize_needed = TRUE;
panel->area.resize_needed = TRUE;
schedule_redraw(&systray.area);
@ -701,8 +703,8 @@ gboolean reparent_icon(TrayWindow *traywin)
if (systray_profile)
fprintf(stderr,
"XMoveResizeWindow(server.display, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = "
"%d)\n",
"XMoveResizeWindow(server.display, traywin->win = %ld, 0, 0, traywin->width = %d, traywin->height = "
"%d)\n",
traywin->win,
traywin->width,
traywin->height);
@ -783,7 +785,7 @@ gboolean embed_icon(TrayWindow *traywin)
if (systray_profile)
fprintf(stderr,
"XGetWindowProperty(server.display, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, "
"XGetWindowProperty(server.display, traywin->win, server.atom._XEMBED_INFO, 0, 2, False, "
"server.atom._XEMBED_INFO, &acttype, &actfmt, &nbitem, &bytes, &data)\n");
ret = XGetWindowProperty(server.display,
traywin->win,
@ -925,10 +927,10 @@ void remove_icon(TrayWindow *traywin)
// Resize and redraw the systray
if (systray_profile)
fprintf(stderr,
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
systray.area.resize_needed = TRUE;
panel->area.resize_needed = TRUE;
schedule_redraw(&systray.area);
@ -948,10 +950,10 @@ void systray_resize_icon(void *t)
} else {
if (systray_profile)
fprintf(stderr,
"systray_resize_icon win = %ld, w = %d, h = %d\n",
traywin->win,
traywin->width,
traywin->height);
"systray_resize_icon win = %ld, w = %d, h = %d\n",
traywin->win,
traywin->width,
traywin->height);
// This is the obvious thing to do but GTK tray icons do not respect the new size
if (0) {
XMoveResizeWindow(server.display, traywin->win, 0, 0, traywin->width, traywin->height);
@ -1048,10 +1050,10 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e)
// Resize and redraw the systray
if (systray_profile)
fprintf(stderr,
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
panel_refresh = TRUE;
refresh_systray = TRUE;
}
@ -1061,7 +1063,7 @@ void systray_property_notify(TrayWindow *traywin, XEvent *e)
Atom at = e->xproperty.atom;
if (at == server.atom.WM_NAME) {
free(traywin->name);
traywin->name = get_window_name(traywin->win);
traywin->name = get_window_name(traywin->win);
if (systray.sort == SYSTRAY_SORT_ASCENDING || systray.sort == SYSTRAY_SORT_DESCENDING) {
systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows);
// print_icons();
@ -1127,10 +1129,10 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e)
// Resize and redraw the systray
if (systray_profile)
fprintf(stderr,
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",
profiling_get_time(),
__FUNCTION__,
__LINE__);
panel_refresh = TRUE;
refresh_systray = TRUE;
}
@ -1154,15 +1156,15 @@ void systray_render_icon_from_image(TrayWindow *traywin)
return;
imlib_context_set_image(traywin->image);
XCopyArea(server.display,
render_background,
systray.area.pix,
server.gc,
traywin->x - systray.area.posx,
traywin->y - systray.area.posy,
traywin->width,
traywin->height,
traywin->x - systray.area.posx,
traywin->y - systray.area.posy);
render_background,
systray.area.pix,
server.gc,
traywin->x - systray.area.posx,
traywin->y - systray.area.posy,
traywin->width,
traywin->height,
traywin->x - systray.area.posx,
traywin->y - systray.area.posy);
render_image(systray.area.pix, traywin->x - systray.area.posx, traywin->y - systray.area.posy);
}
@ -1267,7 +1269,7 @@ void systray_render_icon_composited(void *t)
goto on_error;
}
Picture pict_drawable =
XRenderCreatePicture(server.display, tmp_pmap, XRenderFindVisualFormat(server.display, server.visual32), 0, 0);
XRenderCreatePicture(server.display, tmp_pmap, XRenderFindVisualFormat(server.display, server.visual32), 0, 0);
if (!pict_drawable) {
XRenderFreePicture(server.display, pict_image);
XFreePixmap(server.display, tmp_pmap);
@ -1324,9 +1326,9 @@ void systray_render_icon_composited(void *t)
adjust_asb(data,
traywin->width,
traywin->height,
systray.alpha / 100.0,
systray.saturation / 100.0,
systray.brightness / 100.0);
systray.alpha / 100.0,
systray.saturation / 100.0,
systray.brightness / 100.0);
imlib_image_put_back_data(data);
systray_render_icon_from_image(traywin);
@ -1449,12 +1451,12 @@ void systray_render_icon(void *t)
// Trigger window repaint
if (systray_profile)
fprintf(stderr,
"XClearArea(server.display, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n",
"XClearArea(server.display, traywin->parent = %ld, 0, 0, traywin->width, traywin->height, True)\n",
traywin->parent);
XClearArea(server.display, traywin->parent, 0, 0, 0, 0, True);
if (systray_profile)
fprintf(stderr,
"XClearArea(server.display, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n",
"XClearArea(server.display, traywin->win = %ld, 0, 0, traywin->width, traywin->height, True)\n",
traywin->win);
XClearArea(server.display, traywin->win, 0, 0, 0, 0, True);
}

View file

@ -369,7 +369,7 @@ void draw_task_icon(Task *task, int text_width)
else
pos_x = (task->area.width - panel->g_task.icon_size1) / 2;
} else {
pos_x = task->area.bg->border.width + task->area.paddingxlr;
pos_x = left_border_width(&task->area) + task->area.paddingxlr;
}
// Render
@ -393,7 +393,7 @@ void draw_task_icon(Task *task, int text_width)
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", task->area.bg->border.width);
fprintf(stderr, "Task border : %d\n", left_border_width(&task->area));
fprintf(stderr, "\n");
}
}

View file

@ -167,13 +167,15 @@ void init_taskbar_panel(void *p)
panel->g_taskbar.area.resize_needed = 1;
panel->g_taskbar.area.on_screen = TRUE;
if (panel_horizontal) {
panel->g_taskbar.area.posy = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.height = panel->area.height - (2 * panel->g_taskbar.area.posy);
panel->g_taskbar.area.posy = top_border_width(&panel->area) + panel->area.paddingy;
panel->g_taskbar.area.height =
panel->area.height - top_bottom_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->g_taskbar.area_name.posy = panel->g_taskbar.area.posy;
panel->g_taskbar.area_name.height = panel->g_taskbar.area.height;
} else {
panel->g_taskbar.area.posx = panel->area.bg->border.width + panel->area.paddingy;
panel->g_taskbar.area.width = panel->area.width - (2 * panel->g_taskbar.area.posx);
panel->g_taskbar.area.posx = left_border_width(&panel->area) + panel->area.paddingy;
panel->g_taskbar.area.width =
panel->area.width - left_right_border_width(&panel->area) - 2 * panel->area.paddingy;
panel->g_taskbar.area_name.posx = panel->g_taskbar.area.posx;
panel->g_taskbar.area_name.width = panel->g_taskbar.area.width;
}
@ -230,15 +232,19 @@ void init_taskbar_panel(void *p)
if (panel_horizontal) {
panel->g_task.area.posy = panel->g_taskbar.area.posy +
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
panel->g_taskbar.area.paddingy;
top_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->g_task.maximum_width;
panel->g_task.area.height = panel->area.height - (2 * panel->g_task.area.posy);
panel->g_task.area.height = panel->g_taskbar.area.height -
top_bottom_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
2 * panel->g_taskbar.area.paddingy;
} else {
panel->g_task.area.posx = panel->g_taskbar.area.posx +
panel->g_taskbar.background[TASKBAR_NORMAL]->border.width +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->area.width - (2 * panel->g_task.area.posx);
left_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) +
panel->g_taskbar.area.paddingy;
panel->g_task.area.width = panel->g_taskbar.area.width -
left_right_bg_border_width(panel->g_taskbar.background[TASKBAR_NORMAL]) -
2 * panel->g_taskbar.area.paddingy;
panel->g_task.area.height = panel->g_task.maximum_height;
}
@ -247,7 +253,7 @@ void init_taskbar_panel(void *p)
panel->g_task.background[j] = &g_array_index(backgrounds, Background, 0);
if (panel->g_task.background[j]->border.radius > panel->g_task.area.height / 2) {
printf("task%sbackground_id has a too large rounded value. Please fix your tint2rc\n",
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
j == 0 ? "_" : j == 1 ? "_active_" : j == 2 ? "_iconified_" : "_urgent_");
g_array_append_val(backgrounds, *panel->g_task.background[j]);
panel->g_task.background[j] = &g_array_index(backgrounds, Background, backgrounds->len - 1);
panel->g_task.background[j]->border.radius = panel->g_task.area.height / 2;
@ -257,36 +263,36 @@ void init_taskbar_panel(void *p)
// compute vertical position : text and icon
int height_ink, height, width;
get_text_size2(panel->g_task.font_desc,
&height_ink,
&height,
&width,
panel->area.height,
panel->area.width,
"TAjpg",
5,
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_END,
FALSE);
&height_ink,
&height,
&width,
panel->area.height,
panel->area.width,
"TAjpg",
5,
PANGO_WRAP_WORD_CHAR,
PANGO_ELLIPSIZE_END,
FALSE);
panel->g_task.text_posx = panel->g_task.background[0]->border.width + panel->g_task.area.paddingxlr;
panel->g_task.text_posx = left_bg_border_width(panel->g_task.background[0]) + panel->g_task.area.paddingxlr;
panel->g_task.text_height = panel->g_task.area.height - (2 * panel->g_task.area.paddingy);
if (panel->g_task.has_icon) {
panel->g_task.icon_size1 =
MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
(2 * panel->g_task.area.paddingy) - 2 * panel->g_task.area.bg->border.width;
panel->g_task.icon_size1 = MIN(MIN(panel->g_task.maximum_width, panel->g_task.maximum_height),
MIN(panel->g_task.area.width, panel->g_task.area.height)) -
2 * panel->g_task.area.paddingy - MAX(left_right_border_width(&panel->g_task.area),
top_bottom_border_width(&panel->g_task.area));
panel->g_task.text_posx += panel->g_task.icon_size1 + panel->g_task.area.paddingx;
panel->g_task.icon_posy = (panel->g_task.area.height - panel->g_task.icon_size1) / 2;
if (0)
printf("task: icon_size = %d, textx = %f, texth = %f, icony = %d, w = %d, h = %d, maxw = %d, maxh = %d\n",
panel->g_task.icon_size1,
panel->g_task.text_posx,
panel->g_task.text_height,
panel->g_task.icon_posy,
panel->g_task.area.width,
panel->g_task.area.height,
panel->g_task.maximum_width,
panel->g_task.maximum_height);
panel->g_task.icon_size1,
panel->g_task.text_posx,
panel->g_task.text_height,
panel->g_task.icon_posy,
panel->g_task.area.width,
panel->g_task.area.height,
panel->g_task.maximum_width,
panel->g_task.maximum_height);
}
Taskbar *taskbar;
@ -413,13 +419,13 @@ gboolean resize_taskbar(void *obj)
break;
}
}
taskbar->text_width =
text_width - panel->g_task.text_posx - panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
taskbar->text_width = text_width - panel->g_task.text_posx - right_border_width(&panel->g_task.area) -
panel->g_task.area.paddingxlr;
} else {
relayout_with_constraint(&taskbar->area, panel->g_task.maximum_height);
taskbar->text_width = taskbar->area.width - (2 * panel->g_taskbar.area.paddingy) - panel->g_task.text_posx -
panel->g_task.area.bg->border.width - panel->g_task.area.paddingxlr;
right_border_width(&panel->g_task.area) - panel->g_task.area.paddingxlr;
}
return FALSE;
}
@ -442,7 +448,7 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
schedule_redraw(&taskbar->bar_name.area);
}
if (taskbar_mode == MULTI_DESKTOP &&
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
panels[0].g_taskbar.background[TASKBAR_NORMAL] != panels[0].g_taskbar.background[TASKBAR_ACTIVE]) {
GList *l = taskbar->area.children;
if (taskbarname_enabled)
l = l->next;
@ -486,7 +492,7 @@ gint compare_tasks_trivial(Task *a, Task *b, Taskbar *taskbar)
gboolean contained_within(Task *a, Task *b)
{
if ((a->win_x <= b->win_x) && (a->win_y <= b->win_y) && (a->win_x + a->win_w >= b->win_x + b->win_w) &&
(a->win_y + a->win_h >= b->win_y + b->win_h)) {
(a->win_y + a->win_h >= b->win_y + b->win_h)) {
return TRUE;
}
return FALSE;

View file

@ -147,14 +147,14 @@ gboolean resize_taskbarname(void *obj)
FALSE);
if (panel_horizontal) {
int new_size = name_width + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
int new_size = name_width + 2 * taskbar_name->area.paddingxlr + left_right_border_width(&taskbar_name->area);
if (new_size != taskbar_name->area.width) {
taskbar_name->area.width = new_size;
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;
result = TRUE;
}
} else {
int new_size = name_height + (2 * (taskbar_name->area.paddingxlr + taskbar_name->area.bg->border.width));
int new_size = name_height + 2 * taskbar_name->area.paddingxlr + top_bottom_border_width(&taskbar_name->area);
if (new_size != taskbar_name->area.height) {
taskbar_name->area.height = new_size;
taskbar_name->posy = (taskbar_name->area.height - name_height) / 2;

View file

@ -160,8 +160,8 @@ void tooltip_update_geometry()
pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
pango_layout_get_pixel_extents(layout, &r1, &r2);
width = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingx + r2.width;
height = 2 * g_tooltip.bg->border.width + 2 * g_tooltip.paddingy + r2.height;
width = left_right_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingx + r2.width;
height = top_bottom_bg_border_width(g_tooltip.bg) + 2 * g_tooltip.paddingy + r2.height;
if (panel_horizontal && panel_position & BOTTOM)
y = panel->posy - height;
@ -275,8 +275,8 @@ void tooltip_update()
// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
// vert.)
cairo_move_to(c,
-r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
-r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
-r1.x / 2 + left_bg_border_width(g_tooltip.bg) + g_tooltip.paddingx,
-r1.y / 2 + 1 + top_bg_border_width(g_tooltip.bg) + g_tooltip.paddingy);
pango_cairo_show_layout(c, layout);
g_object_unref(layout);

View file

@ -45,14 +45,14 @@ void initialize_positions(void *obj, int offset)
for (GList *l = a->children; l; l = l->next) {
Area *child = ((Area *)l->data);
if (panel_horizontal) {
child->posy = offset + a->bg->border.width + a->paddingy;
child->height = a->height - (2 * (a->bg->border.width + a->paddingy));
child->posy = offset + top_border_width(a) + a->paddingy;
child->height = a->height - 2 * a->paddingy - top_bottom_border_width(a);
if (child->_on_change_layout)
child->_on_change_layout(child);
initialize_positions(child, child->posy);
} else {
child->posx = offset + a->bg->border.width + a->paddingy;
child->width = a->width - (2 * (a->bg->border.width + a->paddingy));
child->posx = offset + left_border_width(a) + a->paddingy;
child->width = a->width - 2 * a->paddingy - left_right_border_width(a);
if (child->_on_change_layout)
child->_on_change_layout(child);
initialize_positions(child, child->posx);
@ -108,7 +108,8 @@ void relayout_dynamic(Area *a, int level)
// Layout children
if (a->children) {
if (a->alignment == ALIGN_LEFT) {
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + a->paddingxlr;
int pos =
(panel_horizontal ? a->posx + left_border_width(a) : a->posy + top_border_width(a)) + a->paddingxlr;
for (GList *l = a->children; l; l = l->next) {
Area *child = ((Area *)l->data);
@ -134,8 +135,9 @@ void relayout_dynamic(Area *a, int level)
pos += panel_horizontal ? child->width + a->paddingx : child->height + a->paddingx;
}
} else if (a->alignment == ALIGN_RIGHT) {
int pos =
(panel_horizontal ? a->posx + a->width : a->posy + a->height) - a->bg->border.width - a->paddingxlr;
int pos = (panel_horizontal ? a->posx + a->width - right_border_width(a)
: a->posy + a->height - bottom_border_width(a)) -
a->paddingxlr;
for (GList *l = g_list_last(a->children); l; l = l->prev) {
Area *child = ((Area *)l->data);
@ -175,7 +177,7 @@ void relayout_dynamic(Area *a, int level)
children_size += (l == a->children) ? 0 : a->paddingx;
}
int pos = (panel_horizontal ? a->posx : a->posy) + a->bg->border.width + 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) {
@ -230,15 +232,15 @@ void draw_tree(Area *a)
if (a->pix)
XCopyArea(server.display,
a->pix,
((Panel *)a->panel)->temp_pmap,
server.gc,
0,
0,
a->width,
a->height,
a->posx,
a->posy);
a->pix,
((Panel *)a->panel)->temp_pmap,
server.gc,
0,
0,
a->width,
a->height,
a->posx,
a->posy);
for (GList *l = a->children; l; l = l->next)
draw_tree((Area *)l->data);
@ -251,7 +253,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
if (panel_horizontal) {
// detect free size for LAYOUT_DYNAMIC Areas
int size = a->width - (2 * (a->paddingxlr + a->bg->border.width));
int size = a->width - 2 * a->paddingxlr - left_right_border_width(a);
for (GList *l = a->children; l; l = l->next) {
Area *child = (Area *)l->data;
if (child->on_screen && child->size_mode == LAYOUT_FIXED) {
@ -291,7 +293,7 @@ int relayout_with_constraint(Area *a, int maximum_size)
}
} else {
// detect free size for LAYOUT_DYNAMIC's Area
int size = a->height - (2 * (a->paddingxlr + a->bg->border.width));
int size = a->height - 2 * a->paddingxlr - top_bottom_border_width(a);
for (GList *l = a->children; l; l = l->next) {
Area *child = (Area *)l->data;
if (child->on_screen && child->size_mode == LAYOUT_FIXED) {
@ -408,15 +410,15 @@ void draw(Area *a)
if (server.real_transparency)
clear_pixmap(a->pix, 0, 0, a->width, a->height);
XCopyArea(server.display,
((Panel *)a->panel)->temp_pmap,
a->pix,
server.gc,
a->posx,
a->posy,
a->width,
a->height,
0,
0);
((Panel *)a->panel)->temp_pmap,
a->pix,
server.gc,
a->posx,
a->posy,
a->width,
a->height,
0,
0);
} else {
a->_clear(a);
}
@ -436,36 +438,32 @@ void draw(Area *a)
void draw_background(Area *a, cairo_t *c)
{
if (a->bg->fill_color.alpha > 0.0 ||
(panel_config.mouse_effects && (a->has_mouse_over_effect || a->has_mouse_press_effect))) {
(panel_config.mouse_effects && (a->has_mouse_over_effect || a->has_mouse_press_effect))) {
if (a->mouse_state == MOUSE_OVER)
cairo_set_source_rgba(c,
a->bg->fill_color_hover.rgb[0],
a->bg->fill_color_hover.rgb[1],
a->bg->fill_color_hover.rgb[2],
a->bg->fill_color_hover.alpha);
a->bg->fill_color_hover.rgb[0],
a->bg->fill_color_hover.rgb[1],
a->bg->fill_color_hover.rgb[2],
a->bg->fill_color_hover.alpha);
else if (a->mouse_state == MOUSE_DOWN)
cairo_set_source_rgba(c,
a->bg->fill_color_pressed.rgb[0],
a->bg->fill_color_pressed.rgb[1],
a->bg->fill_color_pressed.rgb[2],
a->bg->fill_color_pressed.alpha);
a->bg->fill_color_pressed.rgb[0],
a->bg->fill_color_pressed.rgb[1],
a->bg->fill_color_pressed.rgb[2],
a->bg->fill_color_pressed.alpha);
else
cairo_set_source_rgba(c,
a->bg->fill_color.rgb[0],
a->bg->fill_color.rgb[1],
a->bg->fill_color.rgb[2],
a->bg->fill_color.alpha);
a->bg->fill_color.rgb[0],
a->bg->fill_color.rgb[1],
a->bg->fill_color.rgb[2],
a->bg->fill_color.alpha);
// Not sure about this
draw_rect(c,
a->bg->border.mask & BORDER_LEFT ? a->bg->border.width : 0,
a->bg->border.mask & BORDER_TOP ? a->bg->border.width : 0,
a->width
- (a->bg->border.mask & BORDER_LEFT ? a->bg->border.width : 0)
- (a->bg->border.mask & BORDER_RIGHT ? a->bg->border.width : 0),
a->height
- (a->bg->border.mask & BORDER_TOP ? a->bg->border.width : 0)
- (a->bg->border.mask & BORDER_BOTTOM ? a->bg->border.width : 0),
a->bg->border.radius - a->bg->border.width / 1.571);
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);
}
@ -476,33 +474,29 @@ void draw_background(Area *a, cairo_t *c)
// draw border inside (x, y, width, height)
if (a->mouse_state == MOUSE_OVER)
cairo_set_source_rgba(c,
a->bg->border_color_hover.rgb[0],
a->bg->border_color_hover.rgb[1],
a->bg->border_color_hover.rgb[2],
a->bg->border_color_hover.alpha);
a->bg->border_color_hover.rgb[0],
a->bg->border_color_hover.rgb[1],
a->bg->border_color_hover.rgb[2],
a->bg->border_color_hover.alpha);
else if (a->mouse_state == MOUSE_DOWN)
cairo_set_source_rgba(c,
a->bg->border_color_pressed.rgb[0],
a->bg->border_color_pressed.rgb[1],
a->bg->border_color_pressed.rgb[2],
a->bg->border_color_pressed.alpha);
a->bg->border_color_pressed.rgb[0],
a->bg->border_color_pressed.rgb[1],
a->bg->border_color_pressed.rgb[2],
a->bg->border_color_pressed.alpha);
else
cairo_set_source_rgba(c,
a->bg->border.color.rgb[0],
a->bg->border.color.rgb[1],
a->bg->border.color.rgb[2],
a->bg->border.color.alpha);
a->bg->border.color.rgb[0],
a->bg->border.color.rgb[1],
a->bg->border.color.rgb[2],
a->bg->border.color.alpha);
draw_rect_on_sides(c,
a->bg->border.mask & BORDER_LEFT ? a->bg->border.width / 2. : 0,
a->bg->border.mask & BORDER_TOP ? a->bg->border.width / 2.0 : 0,
a->width
- (a->bg->border.mask & BORDER_LEFT ? a->bg->border.width / 2. : 0)
- (a->bg->border.mask & BORDER_RIGHT ? a->bg->border.width / 2. : 0),
a->height
- (a->bg->border.mask & BORDER_TOP ? a->bg->border.width / 2. : 0)
- (a->bg->border.mask & BORDER_BOTTOM ? a->bg->border.width / 2. : 0),
a->bg->border.radius,
a->bg->border.mask);
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);
cairo_stroke(c);
}
@ -577,7 +571,7 @@ void mouse_over(Area *area, int pressed)
new_state = area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL;
} else {
new_state =
area->has_mouse_press_effect ? MOUSE_DOWN : area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL;
area->has_mouse_press_effect ? MOUSE_DOWN : area->has_mouse_over_effect ? MOUSE_OVER : MOUSE_NORMAL;
}
}
@ -590,7 +584,7 @@ void mouse_over(Area *area, int pressed)
mouse_over_area->mouse_state = new_state;
mouse_over_area->pix =
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
if (!mouse_over_area->pix)
mouse_over_area->_redraw_needed = TRUE;
panel_refresh = TRUE;
@ -602,7 +596,7 @@ void mouse_out()
return;
mouse_over_area->mouse_state = MOUSE_NORMAL;
mouse_over_area->pix =
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
mouse_over_area->pix_by_state[mouse_over_area->has_mouse_over_effect ? mouse_over_area->mouse_state : 0];
if (!mouse_over_area->pix)
mouse_over_area->_redraw_needed = TRUE;
panel_refresh = TRUE;
@ -713,3 +707,68 @@ Area *find_area_under_mouse(void *root, int x, int y)
} while (new_result != result);
return result;
}
int left_border_width(Area *a)
{
return left_bg_border_width(a->bg);
}
int right_border_width(Area *a)
{
return right_bg_border_width(a->bg);
}
int top_border_width(Area *a)
{
return top_bg_border_width(a->bg);
}
int bottom_border_width(Area *a)
{
return bottom_bg_border_width(a->bg);
}
int left_right_border_width(Area *a)
{
return left_right_bg_border_width(a->bg);
}
int top_bottom_border_width(Area *a)
{
return top_bottom_bg_border_width(a->bg);
}
int bg_border_width(Background *bg, int mask)
{
return bg->border.mask & mask ? bg->border.width : 0;
}
int left_bg_border_width(Background *bg)
{
return bg_border_width(bg, BORDER_LEFT);
}
int top_bg_border_width(Background *bg)
{
return bg_border_width(bg, BORDER_TOP);
}
int right_bg_border_width(Background *bg)
{
return bg_border_width(bg, BORDER_RIGHT);
}
int bottom_bg_border_width(Background *bg)
{
return bg_border_width(bg, BORDER_BOTTOM);
}
int left_right_bg_border_width(Background *bg)
{
return left_bg_border_width(bg) + right_bg_border_width(bg);
}
int top_bottom_bg_border_width(Background *bg)
{
return top_bg_border_width(bg) + bottom_bg_border_width(bg);
}

View file

@ -250,6 +250,20 @@ void relayout(Area *a);
// If maximum_size > 0, it is an upper limit for the child size.
int relayout_with_constraint(Area *a, int maximum_size);
int left_border_width(Area *a);
int right_border_width(Area *a);
int left_right_border_width(Area *a);
int top_border_width(Area *a);
int bottom_border_width(Area *a);
int top_bottom_border_width(Area *a);
int left_bg_border_width(Background *bg);
int right_bg_border_width(Background *bg);
int top_bg_border_width(Background *bg);
int bottom_bg_border_width(Background *bg);
int left_right_bg_border_width(Background *bg);
int top_bottom_bg_border_width(Background *bg);
// Rendering
// Sets the redraw_needed flag on the area and its descendants