aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-12-23 10:54:50 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-12-23 10:54:50 +0000
commita20e424dc0685275a9ac5c448e7f20c5738fc8b9 (patch)
tree5d5fe7c4fcbc748a0fa7858c979dba8c43f9dbea
parentmeson: generate-version: use CURRENT_SOURCE_DIR instead of SOURCE_ROOT (diff)
parentrender: make sure ‘maximized’ button doesn’t use negative coordinates (diff)
Merge branch 'crash-on-csd-size-1'
Closes #857
-rw-r--r--CHANGELOG.md2
-rw-r--r--config.c6
-rw-r--r--main.c4
-rw-r--r--render.c14
4 files changed, 20 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a972955..e2febfff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -64,6 +64,8 @@
(https://codeberg.org/dnkl/foot/issues/844).
* Crash when setting a key- or mouse binding to the empty string
(https://codeberg.org/dnkl/foot/issues/851).
+* Crash when maximizing the window and `[csd].size=1`
+ (https://codeberg.org/dnkl/foot/issues/857).
### Security
diff --git a/config.c b/config.c
index 2b7ad378..22245fa6 100644
--- a/config.c
+++ b/config.c
@@ -32,6 +32,8 @@
static const uint32_t default_foreground = 0xdcdccc;
static const uint32_t default_background = 0x111111;
+static const size_t min_csd_border_width = 5;
+
#define cube6(r, g) \
r|g|0x00, r|g|0x5f, r|g|0x87, r|g|0xaf, r|g|0xd7, r|g|0xff
@@ -2802,6 +2804,7 @@ config_load(struct config *conf, const char *conf_path,
.font = {0},
.title_height = 26,
.border_width = 5,
+ .border_width_visible = 0,
.button_width = 26,
},
@@ -3009,6 +3012,9 @@ config_override_apply(struct config *conf, config_override_t *overrides,
}
}
+ conf->csd.border_width = max(
+ min_csd_border_width, conf->csd.border_width_visible);
+
return true;
}
diff --git a/main.c b/main.c
index b5a610e2..7370de29 100644
--- a/main.c
+++ b/main.c
@@ -429,7 +429,9 @@ main(int argc, char *const *argv)
}
struct config conf = {NULL};
- bool conf_successful = config_load(&conf, conf_path, &user_notifications, &overrides, check_config);
+ bool conf_successful = config_load(
+ &conf, conf_path, &user_notifications, &overrides, check_config);
+
tll_free(overrides);
if (!conf_successful) {
config_free(conf);
diff --git a/render.c b/render.c
index 34a4da3a..b21b23ce 100644
--- a/render.c
+++ b/render.c
@@ -1528,8 +1528,7 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
/* Only title bar is rendered in maximized mode */
const int border_width = !term->window->is_maximized
- ? max(term->conf->csd.border_width,
- term->conf->csd.border_width_visible) * term->scale : 0;
+ ? term->conf->csd.border_width * term->scale : 0;
const int title_height = term->window->is_fullscreen
? 0
@@ -1756,10 +1755,11 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx,
* The “visible” border.
*/
- int bwidth = max(term->conf->csd.border_width,
- term->conf->csd.border_width_visible); /* Full border size */
+ int bwidth = term->conf->csd.border_width;
int vwidth = term->conf->csd.border_width_visible; /* Visibls size */
+ xassert(bwidth >= vwidth);
+
if (vwidth > 0) {
const struct config *conf = term->conf;
@@ -1887,11 +1887,15 @@ render_csd_button_maximize_maximized(
const int max_width = buf->width / 3;
int width = min(max_height, max_width);
- int thick = 1 * term->scale;
+ int thick = min(width / 2, 1 * term->scale);
const int x_margin = (buf->width - width) / 2;
const int y_margin = (buf->height - width) / 2;
+ xassert(x_margin + width - thick >= 0);
+ xassert(width - 2 * thick >= 0);
+ xassert(y_margin + width - thick >= 0);
+
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, buf->pix[0], &color, 4,
(pixman_rectangle16_t[]){