forked from external/yambar
Merge branch 'zero-width-exposables-regressions'
This commit is contained in:
commit
427e0ce418
6 changed files with 78 additions and 27 deletions
29
bar/bar.c
29
bar/bar.c
|
@ -55,9 +55,16 @@ calculate_widths(const struct private *b, int *left, int *center, int *right)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No spacing on the edges (that's what the margins are for) */
|
/* No spacing on the edges (that's what the margins are for) */
|
||||||
*left -= b->left_spacing + b->right_spacing;
|
if (*left > 0)
|
||||||
*center -= b->left_spacing + b->right_spacing;
|
*left -= b->left_spacing + b->right_spacing;
|
||||||
*right -= b->left_spacing + b->right_spacing;
|
if (*center > 0)
|
||||||
|
*center -= b->left_spacing + b->right_spacing;
|
||||||
|
if (*right > 0)
|
||||||
|
*right -= b->left_spacing + b->right_spacing;
|
||||||
|
|
||||||
|
assert(*left >= 0);
|
||||||
|
assert(*center >= 0);
|
||||||
|
assert(*right >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -99,6 +106,7 @@ expose(const struct bar *_bar)
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
bar->left.exps[i] = module_begin_expose(m);
|
bar->left.exps[i] = module_begin_expose(m);
|
||||||
|
assert(bar->left.exps[i]->width >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < bar->center.count; i++) {
|
for (size_t i = 0; i < bar->center.count; i++) {
|
||||||
|
@ -107,6 +115,7 @@ expose(const struct bar *_bar)
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
bar->center.exps[i] = module_begin_expose(m);
|
bar->center.exps[i] = module_begin_expose(m);
|
||||||
|
assert(bar->center.exps[i]->width >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < bar->right.count; i++) {
|
for (size_t i = 0; i < bar->right.count; i++) {
|
||||||
|
@ -115,6 +124,7 @@ expose(const struct bar *_bar)
|
||||||
if (e != NULL)
|
if (e != NULL)
|
||||||
e->destroy(e);
|
e->destroy(e);
|
||||||
bar->right.exps[i] = module_begin_expose(m);
|
bar->right.exps[i] = module_begin_expose(m);
|
||||||
|
assert(bar->right.exps[i]->width >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int left_width, center_width, right_width;
|
int left_width, center_width, right_width;
|
||||||
|
@ -196,7 +206,8 @@ on_mouse(struct bar *_bar, enum mouse_event event, enum mouse_button btn,
|
||||||
for (size_t i = 0; i < bar->left.count; i++) {
|
for (size_t i = 0; i < bar->left.count; i++) {
|
||||||
struct exposable *e = bar->left.exps[i];
|
struct exposable *e = bar->left.exps[i];
|
||||||
|
|
||||||
if (e->width == 0) continue;
|
if (e->width == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
mx += bar->left_spacing;
|
mx += bar->left_spacing;
|
||||||
if (x >= mx && x < mx + e->width) {
|
if (x >= mx && x < mx + e->width) {
|
||||||
|
@ -212,7 +223,8 @@ on_mouse(struct bar *_bar, enum mouse_event event, enum mouse_button btn,
|
||||||
for (size_t i = 0; i < bar->center.count; i++) {
|
for (size_t i = 0; i < bar->center.count; i++) {
|
||||||
struct exposable *e = bar->center.exps[i];
|
struct exposable *e = bar->center.exps[i];
|
||||||
|
|
||||||
if (e->width == 0) continue;
|
if (e->width == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
mx += bar->left_spacing;
|
mx += bar->left_spacing;
|
||||||
if (x >= mx && x < mx + e->width) {
|
if (x >= mx && x < mx + e->width) {
|
||||||
|
@ -224,15 +236,16 @@ on_mouse(struct bar *_bar, enum mouse_event event, enum mouse_button btn,
|
||||||
mx += e->width + bar->right_spacing;
|
mx += e->width + bar->right_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
mx = bar->width - (right_width
|
mx = bar->width - (right_width +
|
||||||
+ bar->left_spacing +
|
bar->left_spacing +
|
||||||
bar->right_margin +
|
bar->right_margin +
|
||||||
bar->border.right_width);
|
bar->border.right_width);
|
||||||
|
|
||||||
for (size_t i = 0; i < bar->right.count; i++) {
|
for (size_t i = 0; i < bar->right.count; i++) {
|
||||||
struct exposable *e = bar->right.exps[i];
|
struct exposable *e = bar->right.exps[i];
|
||||||
|
|
||||||
if (e->width == 0) continue;
|
if (e->width == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
mx += bar->left_spacing;
|
mx += bar->left_spacing;
|
||||||
if (x >= mx && x < mx + e->width) {
|
if (x >= mx && x < mx + e->width) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "dynlist.h"
|
#include "dynlist.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define LOG_MODULE "dynlist"
|
#define LOG_MODULE "dynlist"
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
@ -36,15 +37,24 @@ dynlist_begin_expose(struct exposable *exposable)
|
||||||
const struct private *e = exposable->private;
|
const struct private *e = exposable->private;
|
||||||
|
|
||||||
exposable->width = 0;
|
exposable->width = 0;
|
||||||
|
bool have_at_least_one = false;
|
||||||
|
|
||||||
for (size_t i = 0; i < e->count; i++) {
|
for (size_t i = 0; i < e->count; i++) {
|
||||||
struct exposable *ee = e->exposables[i];
|
struct exposable *ee = e->exposables[i];
|
||||||
e->widths[i] = ee->begin_expose(ee);
|
e->widths[i] = ee->begin_expose(ee);
|
||||||
|
|
||||||
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
assert(e->widths[i] >= 0);
|
||||||
|
|
||||||
|
if (e->widths[i] > 0) {
|
||||||
|
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
||||||
|
have_at_least_one = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exposable->width -= e->left_spacing + e->right_spacing;
|
if (have_at_least_one)
|
||||||
|
exposable->width -= e->left_spacing + e->right_spacing;
|
||||||
|
else
|
||||||
|
assert(exposable->width == 0);
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,18 +39,29 @@ static int
|
||||||
begin_expose(struct exposable *exposable)
|
begin_expose(struct exposable *exposable)
|
||||||
{
|
{
|
||||||
const struct eprivate *e = exposable->private;
|
const struct eprivate *e = exposable->private;
|
||||||
|
bool have_at_least_one = false;
|
||||||
|
|
||||||
exposable->width = exposable->particle->left_margin;
|
exposable->width = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < e->count; i++) {
|
for (size_t i = 0; i < e->count; i++) {
|
||||||
struct exposable *ee = e->exposables[i];
|
struct exposable *ee = e->exposables[i];
|
||||||
e->widths[i] = ee->begin_expose(ee);
|
e->widths[i] = ee->begin_expose(ee);
|
||||||
|
|
||||||
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
assert(e->widths[i] >= 0);
|
||||||
|
|
||||||
|
if (e->widths[i] > 0) {
|
||||||
|
exposable->width += e->left_spacing + e->widths[i] + e->right_spacing;
|
||||||
|
have_at_least_one = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exposable->width -= e->left_spacing + e->right_spacing;
|
if (have_at_least_one) {
|
||||||
exposable->width += exposable->particle->right_margin;
|
exposable->width -= e->left_spacing + e->right_spacing;
|
||||||
|
exposable->width += exposable->particle->left_margin;
|
||||||
|
exposable->width += exposable->particle->right_margin;
|
||||||
|
} else
|
||||||
|
assert(exposable->width == 0);
|
||||||
|
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,13 @@ begin_expose(struct exposable *exposable)
|
||||||
{
|
{
|
||||||
struct eprivate *e = exposable->private;
|
struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
exposable->width = (
|
int width = e->exposable->begin_expose(e->exposable);
|
||||||
exposable->particle->left_margin +
|
assert(width >= 0);
|
||||||
e->exposable->begin_expose(e->exposable) +
|
|
||||||
exposable->particle->right_margin);
|
|
||||||
|
|
||||||
|
if (width > 0)
|
||||||
|
width += exposable->particle->left_margin + exposable->particle->right_margin;
|
||||||
|
|
||||||
|
exposable->width = width;
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,27 @@ static int
|
||||||
begin_expose(struct exposable *exposable)
|
begin_expose(struct exposable *exposable)
|
||||||
{
|
{
|
||||||
struct eprivate *e = exposable->private;
|
struct eprivate *e = exposable->private;
|
||||||
|
bool have_at_least_one = false;
|
||||||
|
|
||||||
/* Margins */
|
exposable->width = 0;
|
||||||
exposable->width = exposable->particle->left_margin +
|
|
||||||
exposable->particle->right_margin;
|
|
||||||
|
|
||||||
/* Sub-exposables */
|
/* Sub-exposables */
|
||||||
for (size_t i = 0; i < e->count; i++)
|
for (size_t i = 0; i < e->count; i++) {
|
||||||
exposable->width += e->exposables[i]->begin_expose(e->exposables[i]);
|
int width = e->exposables[i]->begin_expose(e->exposables[i]);
|
||||||
|
|
||||||
|
assert(width >= 0);
|
||||||
|
if (width >= 0) {
|
||||||
|
exposable->width += width;
|
||||||
|
have_at_least_one = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Margins */
|
||||||
|
if (have_at_least_one) {
|
||||||
|
exposable->width = exposable->particle->left_margin +
|
||||||
|
exposable->particle->right_margin;
|
||||||
|
} else
|
||||||
|
assert(exposable->width == 0);
|
||||||
|
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,13 @@ begin_expose(struct exposable *exposable)
|
||||||
{
|
{
|
||||||
struct eprivate *e = exposable->private;
|
struct eprivate *e = exposable->private;
|
||||||
|
|
||||||
exposable->width = (
|
int width = e->exposable->begin_expose(e->exposable);
|
||||||
exposable->particle->left_margin +
|
assert(width >= 0);
|
||||||
e->exposable->begin_expose(e->exposable) +
|
|
||||||
exposable->particle->right_margin);
|
|
||||||
|
|
||||||
|
if (width > 0)
|
||||||
|
width += exposable->particle->left_margin + exposable->particle->right_margin;
|
||||||
|
|
||||||
|
exposable->width = width;
|
||||||
return exposable->width;
|
return exposable->width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue