config: add csd.double-click-to-maximize=no|yes option

When enabled, double-clicking the CSD titlebar will (un)maximize the
window.

Defaults to ‘yes’ (since this is the old hard-coded behavior).

Closes #1293
This commit is contained in:
Daniel Eklöf 2023-07-14 12:03:35 +02:00
parent 3cd0e2adb0
commit 3f7be59062
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 19 additions and 1 deletions

View file

@ -56,9 +56,12 @@
* Support for the new `cursor-shape-v1` Wayland protocol, i.e. server * Support for the new `cursor-shape-v1` Wayland protocol, i.e. server
side cursor shapes ([#1379][1379]). side cursor shapes ([#1379][1379]).
* Support for touchscreen input ([#517][517]). * Support for touchscreen input ([#517][517]).
* `csd.double-click-to-maximize` option to `foot.ini`. Defaults to
`yes` ([#1293][1293]).
[1379]: https://codeberg.org/dnkl/foot/issues/1379 [1379]: https://codeberg.org/dnkl/foot/issues/1379
[517]: https://codeberg.org/dnkl/foot/issues/517 [517]: https://codeberg.org/dnkl/foot/issues/517
[1293]: https://codeberg.org/dnkl/foot/issues/1293
### Changed ### Changed

View file

@ -1475,6 +1475,9 @@ parse_section_csd(struct context *ctx)
else if (strcmp(key, "hide-when-maximized") == 0) else if (strcmp(key, "hide-when-maximized") == 0)
return value_to_bool(ctx, &conf->csd.hide_when_maximized); return value_to_bool(ctx, &conf->csd.hide_when_maximized);
else if (strcmp(key, "double-click-to-maximize") == 0)
return value_to_bool(ctx, &conf->csd.double_click_to_maximize);
else { else {
LOG_CONTEXTUAL_ERR("not a valid action: %s", key); LOG_CONTEXTUAL_ERR("not a valid action: %s", key);
return false; return false;
@ -3009,6 +3012,7 @@ config_load(struct config *conf, const char *conf_path,
.preferred = CONF_CSD_PREFER_SERVER, .preferred = CONF_CSD_PREFER_SERVER,
.font = {0}, .font = {0},
.hide_when_maximized = false, .hide_when_maximized = false,
.double_click_to_maximize = true,
.title_height = 26, .title_height = 26,
.border_width = 5, .border_width = 5,
.border_width_visible = 0, .border_width_visible = 0,

View file

@ -285,6 +285,7 @@ struct config {
uint16_t button_width; uint16_t button_width;
bool hide_when_maximized; bool hide_when_maximized;
bool double_click_to_maximize;
struct { struct {
bool title_set:1; bool title_set:1;

View file

@ -692,6 +692,10 @@ Examples:
is maximized. The completely disable the titlebar, set *size* to 0 is maximized. The completely disable the titlebar, set *size* to 0
instead. Default: _no_. instead. Default: _no_.
*double-click-to-maximize*
Boolean. When enabled, double-clicking the CSD titlebar will
(un)maximize the window. Default: _yes_.
*border-width* *border-width*
Width of the border, in pixels (subject to output scaling). Note Width of the border, in pixels (subject to output scaling). Note
that the border encompasses the entire window, including the title that the border encompasses the entire window, including the title

View file

@ -123,6 +123,7 @@
# font=<primary font> # font=<primary font>
# color=<foreground color> # color=<foreground color>
# hide-when-maximized=no # hide-when-maximized=no
# double-click-to-maximize=yes
# border-width=0 # border-width=0
# border-color=<csd.color> # border-color=<csd.color>
# button-width=26 # button-width=26

View file

@ -2287,7 +2287,10 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
struct wl_window *win = term->window; struct wl_window *win = term->window;
/* Toggle maximized state on double-click */ /* Toggle maximized state on double-click */
if (button == BTN_LEFT && seat->mouse.count == 2) { if (term->conf->csd.double_click_to_maximize &&
button == BTN_LEFT &&
seat->mouse.count == 2)
{
if (win->is_maximized) if (win->is_maximized)
xdg_toplevel_unset_maximized(win->xdg_toplevel); xdg_toplevel_unset_maximized(win->xdg_toplevel);
else else

View file

@ -777,6 +777,8 @@ test_section_csd(void)
&conf.csd.color.quit); &conf.csd.color.quit);
test_boolean(&ctx, &parse_section_csd, "hide-when-maximized", test_boolean(&ctx, &parse_section_csd, "hide-when-maximized",
&conf.csd.hide_when_maximized); &conf.csd.hide_when_maximized);
test_boolean(&ctx, &parse_section_csd, "double-click-to-maximize",
&conf.csd.double_click_to_maximize);
/* TODO: verify the set bit is actually set for colors */ /* TODO: verify the set bit is actually set for colors */
/* TODO: font */ /* TODO: font */