implemented shrink option
This commit is contained in:
parent
a25954f8a6
commit
dd047ccd20
15
x.c
15
x.c
@ -203,7 +203,7 @@ static dimension_t calculate_dimensions(GSList *layouts)
|
||||
dim.h += (g_slist_length(layouts) - 1) * settings.separator_height;
|
||||
dim.h += g_slist_length(layouts) * settings.padding * 2;
|
||||
|
||||
int text_width = 0;
|
||||
int text_width = 0, total_width = 0;
|
||||
for (GSList *iter = layouts; iter; iter = iter->next) {
|
||||
colored_layout *cl = iter->data;
|
||||
int w,h;
|
||||
@ -211,14 +211,20 @@ static dimension_t calculate_dimensions(GSList *layouts)
|
||||
dim.h += h;
|
||||
text_width = MAX(w, text_width);
|
||||
|
||||
if (dim.w <= 0) {
|
||||
if (dim.w <= 0 || settings.shrink) {
|
||||
/* dynamic width */
|
||||
if ((text_width + 2 * settings.h_padding) > scr.dim.w) {
|
||||
/* it's bigger than the screen */
|
||||
total_width = MAX(text_width + 2 * settings.h_padding, total_width);
|
||||
|
||||
/* subtract height from the unwrapped text */
|
||||
dim.h -= h;
|
||||
|
||||
if (total_width > scr.dim.w) {
|
||||
/* set width to screen width */
|
||||
dim.w = scr.dim.w - xctx.geometry.y * 2;
|
||||
} else if (total_width < xctx.geometry.w && settings.shrink) {
|
||||
/* set width to text width */
|
||||
dim.w = total_width + 2 * settings.frame_width;
|
||||
}
|
||||
|
||||
/* re-setup the layout */
|
||||
int width = dim.w;
|
||||
@ -232,7 +238,6 @@ static dimension_t calculate_dimensions(GSList *layouts)
|
||||
text_width = MAX(w, text_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dim.w <= 0) {
|
||||
dim.w = text_width + 2 * settings.h_padding;
|
||||
|
Loading…
x
Reference in New Issue
Block a user