mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-14 05:33:59 -04:00
config: add 'startup-mode' option
This option controls the initial window mode: windowed, maximized or fullscreen. The default is windowed.
This commit is contained in:
parent
be8b6e8c75
commit
e197368c0f
6 changed files with 39 additions and 1 deletions
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
* User configurable key- and mouse bindings. See `man 5 foot` and the
|
* User configurable key- and mouse bindings. See `man 5 foot` and the
|
||||||
example `footrc` (https://codeberg.org/dnkl/foot/issues/1)
|
example `footrc` (https://codeberg.org/dnkl/foot/issues/1)
|
||||||
|
* **startup-mode** option to `footrc`, that lets you control the
|
||||||
|
initial window mode: _windowed_, _maximized_ or _fullscreen_.
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
18
config.c
18
config.c
|
|
@ -225,7 +225,7 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
unsigned x, y;
|
unsigned x, y;
|
||||||
if (sscanf(value, "%ux%u", &x, &y) != 2) {
|
if (sscanf(value, "%ux%u", &x, &y) != 2) {
|
||||||
LOG_ERR(
|
LOG_ERR(
|
||||||
"%s: %d: expected PAD_XxPAD_Y, where both are positive integers: %s",
|
"%s:%d: expected PAD_XxPAD_Y, where both are positive integers: %s",
|
||||||
path, lineno, value);
|
path, lineno, value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -234,6 +234,21 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
conf->pad_y = y;
|
conf->pad_y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (strcmp(key, "startup-mode") == 0) {
|
||||||
|
if (strcmp(value, "windowed") == 0)
|
||||||
|
conf->startup_mode = STARTUP_WINDOWED;
|
||||||
|
else if (strcmp(value, "maximized") == 0)
|
||||||
|
conf->startup_mode = STARTUP_MAXIMIZED;
|
||||||
|
else if (strcmp(value, "fullscreen") == 0)
|
||||||
|
conf->startup_mode = STARTUP_FULLSCREEN;
|
||||||
|
else {
|
||||||
|
LOG_ERR(
|
||||||
|
"%s:%d: expected either 'windowed', 'maximized' or 'fullscreen'",
|
||||||
|
path, lineno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "font") == 0) {
|
else if (strcmp(key, "font") == 0) {
|
||||||
char *copy = strdup(value);
|
char *copy = strdup(value);
|
||||||
for (const char *font = strtok(copy, ","); font != NULL; font = strtok(NULL, ",")) {
|
for (const char *font = strtok(copy, ","); font != NULL; font = strtok(NULL, ",")) {
|
||||||
|
|
@ -803,6 +818,7 @@ config_load(struct config *conf, const char *conf_path)
|
||||||
.height = 500,
|
.height = 500,
|
||||||
.pad_x = 2,
|
.pad_x = 2,
|
||||||
.pad_y = 2,
|
.pad_y = 2,
|
||||||
|
.startup_mode = STARTUP_WINDOWED,
|
||||||
.fonts = tll_init(),
|
.fonts = tll_init(),
|
||||||
.scrollback_lines = 1000,
|
.scrollback_lines = 1000,
|
||||||
|
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -15,6 +15,7 @@ struct config {
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned pad_x;
|
unsigned pad_x;
|
||||||
unsigned pad_y;
|
unsigned pad_y;
|
||||||
|
enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode;
|
||||||
|
|
||||||
tll(char *) fonts;
|
tll(char *) fonts;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ in this order:
|
||||||
Padding between border and glyphs, in pixels, on the form
|
Padding between border and glyphs, in pixels, on the form
|
||||||
_XxY_ (-padding). Default: _2x2_.
|
_XxY_ (-padding). Default: _2x2_.
|
||||||
|
|
||||||
|
*startup-mode*
|
||||||
|
Initial window mode: *windowed*, *maximized* or
|
||||||
|
*fullscreen*. Default: _windowed_.
|
||||||
|
|
||||||
*shell*
|
*shell*
|
||||||
Executable to launch. Typically a shell. Default: _$SHELL_ if set,
|
Executable to launch. Typically a shell. Default: _$SHELL_ if set,
|
||||||
otherwise the user's default shell (as specified in
|
otherwise the user's default shell (as specified in
|
||||||
|
|
|
||||||
1
footrc
1
footrc
|
|
@ -4,6 +4,7 @@
|
||||||
# scrollback=1000
|
# scrollback=1000
|
||||||
# geometry=700x500
|
# geometry=700x500
|
||||||
# pad=2x2
|
# pad=2x2
|
||||||
|
# startup-mode=windowed
|
||||||
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
||||||
# term=foot
|
# term=foot
|
||||||
# login-shell=no
|
# login-shell=no
|
||||||
|
|
|
||||||
14
terminal.c
14
terminal.c
|
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
|
#include <xdg-shell.h>
|
||||||
|
|
||||||
#define LOG_MODULE "terminal"
|
#define LOG_MODULE "terminal"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
|
|
@ -800,6 +801,19 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
||||||
/* Let the Wayland backend know we exist */
|
/* Let the Wayland backend know we exist */
|
||||||
tll_push_back(wayl->terms, term);
|
tll_push_back(wayl->terms, term);
|
||||||
|
|
||||||
|
switch (conf->startup_mode) {
|
||||||
|
case STARTUP_WINDOWED:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STARTUP_MAXIMIZED:
|
||||||
|
xdg_toplevel_set_maximized(term->window->xdg_toplevel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STARTUP_FULLSCREEN:
|
||||||
|
xdg_toplevel_set_fullscreen(term->window->xdg_toplevel, NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start the slave/client */
|
/* Start the slave/client */
|
||||||
if ((term->slave = slave_spawn(term->ptmx, argc, term->cwd, argv, term_env, conf->shell, login_shell)) == -1)
|
if ((term->slave = slave_spawn(term->ptmx, argc, term->cwd, argv, term_env, conf->shell, login_shell)) == -1)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue