From ac32bcda07015dbf00f3b804f5e4595cd7994245 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 25 Feb 2020 19:05:48 +0100 Subject: main: geometry defaults to 800x600 pixels --- doc/foot.1.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/foot.1.scd b/doc/foot.1.scd index 8b5268b7..97815066 100644 --- a/doc/foot.1.scd +++ b/doc/foot.1.scd @@ -31,7 +31,7 @@ execute (instead of the shell). Default: _monospace_. *-g*,*--geometry*=_WIDTHxHEIGHT_ - Set initial window width and height. + Set initial window width and height. Default: *800x600*. *-t*,*--term*=_TERM_ Value to set the environment variable *TERM* to. Default: *foot*. -- cgit v1.3 From 5717a0dfb07d4d302186277a5b6d20ef7d12898c Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 29 Feb 2020 11:01:23 +0100 Subject: config: change default geometry from 800x600 -> 700x500 If the display resolution *is* 800x600, using this size is bad since there will typically be panels and other things on the screen too. Not that 800x600 is something we expect to see in real life, but may happen on virtual displays. --- completions/zsh/_foot | 2 +- config.c | 4 ++-- doc/foot.1.scd | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/completions/zsh/_foot b/completions/zsh/_foot index 0132604a..c573d4cf 100644 --- a/completions/zsh/_foot +++ b/completions/zsh/_foot @@ -6,7 +6,7 @@ _arguments \ '(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \ '(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \ '--login-shell[start shell as a login shell]' \ - '(-g --geometry)'{-g,--geometry}'[window WIDTHxHEIGHT, in pixels (800x600)]:geometry:()' \ + '(-g --geometry)'{-g,--geometry}'[window WIDTHxHEIGHT, in pixels (700x50)]:geometry:()' \ '(-s --server)'{-s,--server}'[run as server; open terminals by running footclient]:server:_files' \ '--hold[remain open after child process exits]' \ '(-p --print-pid)'{-p,--print-pid}'[print PID to this file or FD when up and running (server mode only)]:pidfile:_files' \ diff --git a/config.c b/config.c index 63db806e..37795bb9 100644 --- a/config.c +++ b/config.c @@ -491,8 +491,8 @@ config_load(struct config *conf, const char *conf_path) *conf = (struct config) { .term = strdup("foot"), .shell = get_shell(), - .width = 800, - .height = 600, + .width = 700, + .height = 500, .pad_x = 2, .pad_y = 2, .fonts = tll_init(), diff --git a/doc/foot.1.scd b/doc/foot.1.scd index 97815066..5b3c07cc 100644 --- a/doc/foot.1.scd +++ b/doc/foot.1.scd @@ -31,7 +31,7 @@ execute (instead of the shell). Default: _monospace_. *-g*,*--geometry*=_WIDTHxHEIGHT_ - Set initial window width and height. Default: *800x600*. + Set initial window width and height. Default: *700x500*. *-t*,*--term*=_TERM_ Value to set the environment variable *TERM* to. Default: *foot*. -- cgit v1.3 From 22ce09eb44db887d32a5b3a88740939b7285c763 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 18:42:49 +0100 Subject: config: make CSD user configurable The user can now configure the following: * Whether to prefer CSDs or SSDs. But note that this is only a hint to the compositor - it may deny our request. Furthermore, not all compositors implement the decoration manager protocol, meaning CSDs will be used regardless of the user configuration (GNOME/mutter being the most prominent one). * Title bar size and color, including transparency * Border size and color, including transparency Also drop support for rendering the CSDs inside the main surface. --- config.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++--- config.h | 14 ++++++++ doc/foot.5.scd | 31 ++++++++++++++++++ footrc | 7 ++++ input.c | 31 +++++++++--------- render.c | 100 ++++++++++++++++++++++----------------------------------- wayland.c | 35 +++++++++++--------- wayland.h | 9 ------ 8 files changed, 210 insertions(+), 107 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index 37795bb9..246e0d18 100644 --- a/config.c +++ b/config.c @@ -133,7 +133,7 @@ str_to_double(const char *s, double *res) } static bool -str_to_color(const char *s, uint32_t *color, const char *path, int lineno) +str_to_color(const char *s, uint32_t *color, bool allow_alpha, const char *path, int lineno) { unsigned long value; if (!str_to_ulong(s, 16, &value)) { @@ -141,7 +141,12 @@ str_to_color(const char *s, uint32_t *color, const char *path, int lineno) return false; } - *color = value & 0xffffff; + if (!allow_alpha && (value & 0xff000000) != 0) { + LOG_ERR("%s:%d: color value must not have an alpha component", path, lineno); + return false; + } + + *color = value; return true; } @@ -273,7 +278,7 @@ parse_section_colors(const char *key, const char *value, struct config *conf, } uint32_t color_value; - if (!str_to_color(value, &color_value, path, lineno)) + if (!str_to_color(value, &color_value, false, path, lineno)) return false; *color = color_value; @@ -305,8 +310,8 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, uint32_t text_color, cursor_color; if (text == NULL || cursor == NULL || - !str_to_color(text, &text_color, path, lineno) || - !str_to_color(cursor, &cursor_color, path, lineno)) + !str_to_color(text, &text_color, false, path, lineno) || + !str_to_color(cursor, &cursor_color, false, path, lineno)) { LOG_ERR("%s:%d: invalid cursor colors: %s", path, lineno, value); free(value_copy); @@ -326,6 +331,66 @@ parse_section_cursor(const char *key, const char *value, struct config *conf, return true; } +static bool +parse_section_csd(const char *key, const char *value, struct config *conf, + const char *path, unsigned lineno) +{ + if (strcmp(key, "preferred") == 0) { + if (strcmp(value, "server") == 0) + conf->csd.preferred = CONF_CSD_PREFER_SERVER; + else if (strcmp(value, "client") == 0) + conf->csd.preferred = CONF_CSD_PREFER_CLIENT; + else { + LOG_ERR("%s:%d: expected either 'server' or 'client'", path, lineno); + return false; + } + } + + else if (strcmp(key, "titlebar-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, path, lineno)) { + LOG_ERR("%s:%d: invalid titlebar-color: %s", path, lineno, value); + return false; + } + + conf->csd.color.title_set = true; + conf->csd.color.title = color; + } + + else if (strcmp(key, "border-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, path, lineno)) { + LOG_ERR("%s:%d: invalid border-color: %s", path, lineno, value); + return false; + } + + conf->csd.color.border_set = true; + conf->csd.color.border = color; + } + + else if (strcmp(key, "titlebar") == 0) { + unsigned long pixels; + if (!str_to_ulong(value, 10, &pixels)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + + conf->csd.title_height = pixels; + } + + else if (strcmp(key, "border") == 0) { + unsigned long pixels; + if (!str_to_ulong(value, 10, &pixels)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + + conf->csd.border_width = pixels; + } + + return true; +} + static bool parse_config_file(FILE *f, struct config *conf, const char *path) { @@ -333,6 +398,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) SECTION_MAIN, SECTION_COLORS, SECTION_CURSOR, + SECTION_CSD, } section = SECTION_MAIN; /* Function pointer, called for each key/value line */ @@ -345,6 +411,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) [SECTION_MAIN] = &parse_section_main, [SECTION_COLORS] = &parse_section_colors, [SECTION_CURSOR] = &parse_section_cursor, + [SECTION_CSD] = &parse_section_csd, }; #if defined(_DEBUG) && defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG @@ -352,6 +419,7 @@ parse_config_file(FILE *f, struct config *conf, const char *path) [SECTION_MAIN] = "main", [SECTION_COLORS] = "colors", [SECTION_CURSOR] = "cursor", + [SECTION_CSD] = "csd", }; #endif @@ -408,6 +476,8 @@ parse_config_file(FILE *f, struct config *conf, const char *path) section = SECTION_COLORS; else if (strcmp(&line[1], "cursor") == 0) section = SECTION_CURSOR; + else if (strcmp(&line[1], "csd") == 0) + section = SECTION_CSD; else { LOG_ERR("%s:%d: invalid section name: %s", path, lineno, &line[1]); goto err; @@ -532,6 +602,16 @@ config_load(struct config *conf, const char *conf_path) }, }, + .csd = { + .preferred = CONF_CSD_PREFER_SERVER, + .title_height = 26, + .border_width = 5, + .color = { + .title_set = false, + .border_set = false, + }, + }, + .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), .server_socket_path = get_server_socket_path(), .presentation_timings = false, diff --git a/config.h b/config.h index 3677129f..fa765476 100644 --- a/config.h +++ b/config.h @@ -36,6 +36,20 @@ struct config { } color; } cursor; + struct { + enum { CONF_CSD_PREFER_SERVER, CONF_CSD_PREFER_CLIENT } preferred; + + int title_height; + int border_width; + + struct { + bool title_set; + bool border_set; + uint32_t title; + uint32_t border; + } color; + } csd; + size_t render_worker_count; char *server_socket_path; bool presentation_timings; diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 41785366..30fd735c 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -98,6 +98,37 @@ in this order: Background translucency. A value in the range 0.0-1.0, where 0.0 means completely transparent, and 1.0 is opaque. Default: _1.0_. +# SECTION: csd + +This section controls the look of the _CSDs_ (Client Side +Decorations). Note that the default is to *not* use CSDs, but instead +to use _SSDs_ (Server Side Decorations) when the compositor supports +it. + +*preferred* + Which type of window decorations to prefer: *client* (CSD) or + *server* (SSD). Note that this is only a hint to the + compositor. Depending on the compositor's configuration and + capabilities, it may not have any effect. Default: _server_. + +*titlebar* + Height, in pixels (but subject to output scaling), of the + titlebar, not including the window border. Default: _26_. + +*border* + Width, in pixels (but subject to output scaling), of the + borders. Default: _5_. + +*titlebar-color* + Titlebar AARRGGBB color. Note that unlike the other color values, + the *titlebar-color* value also has an _alpha_ component. Default: + use the default _foreground_ color. + +*border-color* + Border AARRGGBB color. Note that unlike the other color values, + the *border-color* value also has an _alpha_ component. Default: + _transparent_. + # FONT FORMAT The font is specified in FontConfig syntax. That is, a colon-separated diff --git a/footrc b/footrc index e6010eb2..7eea3ada 100644 --- a/footrc +++ b/footrc @@ -33,3 +33,10 @@ # bright6=b3ffff # bright7=ffffff # alpha=1.0 + +[csd] +# preferred=server +# titlebar=26 +# border=5 +# titlebar-color= +# border-color=00000000 diff --git a/input.c b/input.c index 2fde9ca4..dbb8ec33 100644 --- a/input.c +++ b/input.c @@ -21,6 +21,7 @@ #define LOG_MODULE "input" #define LOG_ENABLE_DBG 0 #include "log.h" +#include "config.h" #include "commands.h" #include "keymap.h" #include "render.h" @@ -616,6 +617,7 @@ input_repeat(struct wayland *wayl, uint32_t key) static bool is_top_left(const struct terminal *term, int x, int y) { + int csd_border_size = term->conf->csd.border_width; return ( (term->active_surface == TERM_SURF_BORDER_LEFT && y < 10 * term->scale) || (term->active_surface == TERM_SURF_BORDER_TOP && x < (10 + csd_border_size) * term->scale)); @@ -624,6 +626,7 @@ is_top_left(const struct terminal *term, int x, int y) static bool is_top_right(const struct terminal *term, int x, int y) { + int csd_border_size = term->conf->csd.border_width; return ( (term->active_surface == TERM_SURF_BORDER_RIGHT && y < 10 * term->scale) || (term->active_surface == TERM_SURF_BORDER_TOP && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale)); @@ -632,6 +635,8 @@ is_top_right(const struct terminal *term, int x, int y) static bool is_bottom_left(const struct terminal *term, int x, int y) { + int csd_title_size = term->conf->csd.title_height; + int csd_border_size = term->conf->csd.border_width; return ( (term->active_surface == TERM_SURF_BORDER_LEFT && y > csd_title_size * term->scale + term->height) || (term->active_surface == TERM_SURF_BORDER_BOTTOM && x < (10 + csd_border_size) * term->scale)); @@ -640,6 +645,8 @@ is_bottom_left(const struct terminal *term, int x, int y) static bool is_bottom_right(const struct terminal *term, int x, int y) { + int csd_title_size = term->conf->csd.title_height; + int csd_border_size = term->conf->csd.border_width; return ( (term->active_surface == TERM_SURF_BORDER_RIGHT && y > csd_title_size * term->scale + term->height) || (term->active_surface == TERM_SURF_BORDER_BOTTOM && x > term->width + 1 * csd_border_size * term->scale - 10 * term->scale)); @@ -648,22 +655,14 @@ is_bottom_right(const struct terminal *term, int x, int y) static const char * xcursor_for_csd_border(struct terminal *term, int x, int y) { - if (is_top_left(term, x, y)) - return "top_left_corner"; - else if (is_top_right(term, x, y)) - return "top_right_corner"; - else if (is_bottom_left(term, x, y)) - return "bottom_left_corner"; - else if (is_bottom_right(term, x, y)) - return "bottom_right_corner"; - else if (term->active_surface == TERM_SURF_BORDER_LEFT) - return "left_side"; - else if (term->active_surface == TERM_SURF_BORDER_RIGHT) - return "right_side"; - else if (term->active_surface == TERM_SURF_BORDER_TOP) - return "top_side"; - else if (term->active_surface == TERM_SURF_BORDER_BOTTOM) - return"bottom_side"; + if (is_top_left(term, x, y)) return "top_left_corner"; + else if (is_top_right(term, x, y)) return "top_right_corner"; + else if (is_bottom_left(term, x, y)) return "bottom_left_corner"; + else if (is_bottom_right(term, x, y)) return "bottom_right_corner"; + else if (term->active_surface == TERM_SURF_BORDER_LEFT) return "left_side"; + else if (term->active_surface == TERM_SURF_BORDER_RIGHT) return "right_side"; + else if (term->active_surface == TERM_SURF_BORDER_TOP) return "top_side"; + else if (term->active_surface == TERM_SURF_BORDER_BOTTOM) return"bottom_side"; else { assert(false); return NULL; diff --git a/render.c b/render.c index 740d3e55..f08c4cf4 100644 --- a/render.c +++ b/render.c @@ -25,9 +25,6 @@ #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) -const int csd_border_size = 5; -const int csd_title_size = 26; - struct renderer { struct fdm *fdm; struct wayland *wayl; @@ -680,12 +677,11 @@ 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 - ? csd_border_size * term->scale : 0; + ? term->conf->csd.border_width * term->scale : 0; const int title_height = !term->window->is_fullscreen - ? csd_title_size * term->scale : 0; + ? term->conf->csd.title_height * term->scale : 0; -#if FOOT_CSD_OUTSIDE switch (surf_idx) { case CSD_SURF_TITLE: return (struct csd_data){ 0, -title_height, term->width, title_height}; case CSD_SURF_LEFT: return (struct csd_data){-border_width, -title_height, border_width, title_height + term->height}; @@ -697,18 +693,6 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) assert(false); return (struct csd_data){0}; } -#else - switch (surf_idx) { - case CSD_SURF_TITLE: return (struct csd_data){ border_width, border_width, term->width - 2 * border_width, title_height}; - case CSD_SURF_LEFT: return (struct csd_data){ 0, border_width, border_width, term->height - 2 * border_width}; - case CSD_SURF_RIGHT: return (struct csd_data){term->width - border_width, border_width, border_width, term->height - 2 * border_width}; - case CSD_SURF_TOP: return (struct csd_data){ 0, 0, term->width, border_width}; - - case CSD_SURF_COUNT: - assert(false); - return (struct csd_data){0}; - } -#endif assert(false); return (struct csd_data){0}; @@ -749,18 +733,18 @@ render_csd_title(struct terminal *term) struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie); - pixman_color_t color = color_hex_to_pixman(term->colors.fg); + uint32_t _color = term->colors.fg; + uint16_t alpha = 0xffff; + + if (term->conf->csd.color.title_set) { + _color = term->conf->csd.color.title; + alpha = _color >> 24 | (_color >> 24 << 8); + } + pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); if (!term->visual_focus) pixman_color_dim(&color); - struct wl_region *region = wl_compositor_create_region(term->wl->compositor); - if (region != NULL) { - wl_region_add(region, 0, 0, INT32_MAX, INT32_MAX); - wl_surface_set_opaque_region(surf, region); - wl_region_destroy(region); - } - render_csd_part(term, surf, buf, info.width, info.height, &color); } @@ -782,8 +766,15 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx) struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie); - pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); + uint32_t _color = 0; + uint16_t alpha = 0; + + if (term->conf->csd.color.border_set) { + _color = term->conf->csd.color.border; + alpha = _color >> 24 | (_color >> 24 << 8); + } + pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); if (!term->visual_focus) pixman_color_dim(&color); render_csd_part(term, surf, buf, info.width, info.height, &color); @@ -1145,12 +1136,7 @@ render_search_box(struct terminal *term) assert(term->scale >= 1); const int scale = term->scale; -#if FOOT_CSD_OUTSIDE - const int csd = 0; -#else - const int csd = term->window->use_csd == CSD_YES ? csd_border_size * scale : 0; -#endif - const size_t margin = csd + 3 * scale; + const size_t margin = 3 * scale; const size_t width = term->width - 2 * margin; const size_t visible_width = min( @@ -1264,15 +1250,6 @@ maybe_resize(struct terminal *term, int width, int height, bool force) width *= scale; height *= scale; - /* Scaled CSD border + title bar sizes */ -#if FOOT_CSD_OUTSIDE - const int csd_border = 0; - const int csd_title = 0; -#else - const int csd_border = term->window->use_csd == CSD_YES ? csd_border_size * scale : 0; - const int csd_title = term->window->use_csd == CSD_YES ? csd_title_size * scale : 0; -#endif - if (width == 0 && height == 0) { /* * The compositor is letting us choose the size @@ -1293,10 +1270,10 @@ maybe_resize(struct terminal *term, int width, int height, bool force) /* Account for CSDs, to make actual window size match * the configured size */ if (!term->window->is_maximized) { - width -= 2 * csd_border_size; - height -= 2 * csd_border_size + csd_title_size; + width -= 2 * term->conf->csd.border_width; + height -= 2 * term->conf->csd.border_width + term->conf->csd.title_height; } else { - height -= csd_title_size; + height -= term->conf->csd.title_height; } } @@ -1305,24 +1282,23 @@ maybe_resize(struct terminal *term, int width, int height, bool force) } } - const int csd_x = 2 * csd_border; - const int csd_y = 2 * csd_border + csd_title; - - /* Padding */ - const int pad_x = scale * term->conf->pad_x; - const int pad_y = scale * term->conf->pad_y; - /* Don't shrink grid too much */ const int min_cols = 20; const int min_rows = 4; /* Minimum window size */ - const int min_width = csd_x + 2 * pad_x + min_cols * term->cell_width; - const int min_height = csd_y + 2 * pad_y + min_rows * term->cell_height; + const int min_width = min_cols * term->cell_width; + const int min_height = min_rows * term->cell_height; width = max(width, min_width); height = max(height, min_height); + /* Padding */ + const int max_pad_x = (width - min_width) / 2; + const int max_pad_y = (height - min_height) / 2; + const int pad_x = min(max_pad_x, scale * term->conf->pad_x); + const int pad_y = min(max_pad_y, scale * term->conf->pad_y); + if (!force && width == term->width && height == term->height && scale == term->scale) return false; @@ -1342,8 +1318,8 @@ maybe_resize(struct terminal *term, int width, int height, bool force) const int old_rows = term->rows; /* Screen rows/cols after resize */ - const int new_cols = (term->width - 2 * pad_x - csd_x) / term->cell_width; - const int new_rows = (term->height - 2 * pad_y - csd_y) / term->cell_height; + const int new_cols = (term->width - 2 * pad_x) / term->cell_width; + const int new_rows = (term->height - 2 * pad_y) / term->cell_height; /* Grid rows/cols after resize */ const int new_normal_grid_rows = 1 << (32 - __builtin_clz(new_rows + scrollback_lines - 1)); @@ -1353,15 +1329,15 @@ maybe_resize(struct terminal *term, int width, int height, bool force) assert(new_rows >= 1); /* Margins */ - term->margins.left = csd_border + pad_x; - term->margins.top = csd_border + csd_title + pad_y; + term->margins.left = pad_x; + term->margins.top = pad_y; term->margins.right = term->width - new_cols * term->cell_width - term->margins.left; term->margins.bottom = term->height - new_rows * term->cell_height - term->margins.top; - assert(term->margins.left >= csd_border + pad_x); - assert(term->margins.right >= csd_border + pad_x); - assert(term->margins.top >= csd_border + csd_title + pad_y); - assert(term->margins.bottom >= csd_border + pad_y); + assert(term->margins.left >= pad_x); + assert(term->margins.right >= pad_x); + assert(term->margins.top >= pad_y); + assert(term->margins.bottom >= pad_y); if (new_cols == old_cols && new_rows == old_rows) { LOG_DBG("grid layout unaffected; skipping reflow"); diff --git a/wayland.c b/wayland.c index 957f736e..c5272994 100644 --- a/wayland.c +++ b/wayland.c @@ -536,18 +536,14 @@ xdg_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel, * sub-surfaces. Thus, since our resize code assumes the size * to resize to is the main window only, adjust the size here, * to account for the CSDs. - * - * Of course this does *not* apply when we position the CSDs - * *inside* the main surface. */ -#if FOOT_CSD_OUTSIDE + const struct config *conf = win->term->conf; if (!is_maximized) { - width -= 2 * csd_border_size; - height -= 2 * csd_border_size + csd_title_size; + width -= 2 * conf->csd.border_width; + height -= 2 * conf->csd.border_width + conf->csd.title_height; } else { - height -= csd_title_size; + height -= conf->csd.title_height; } -#endif } win->configure.is_activated = is_activated; @@ -670,18 +666,18 @@ xdg_toplevel_decoration_configure(void *data, if (win->is_configured && win->use_csd == CSD_YES) { struct terminal *term = win->term; - int scale = term->scale; + const struct config *conf = term->conf; + int scale = term->scale; int width = term->width / scale; int height = term->height / scale; -#if FOOT_CSD_OUTSIDE if (!term->window->is_maximized) { - width -= 2 * csd_border_size; - height -= 2 * csd_border_size + csd_title_size; + width -= 2 * conf->csd.border_width; + height -= 2 * conf->csd.border_width + conf->csd.title_height; } else - height -= csd_title_size; -#endif + height -= conf->csd.title_height; + render_resize_force(term, width, height); } } @@ -1013,6 +1009,7 @@ struct wl_window * wayl_win_init(struct terminal *term) { struct wayland *wayl = term->wl; + const struct config *conf = wayl->conf; struct wl_window *win = calloc(1, sizeof(*win)); win->term = term; @@ -1050,8 +1047,16 @@ wayl_win_init(struct terminal *term) if (wayl->xdg_decoration_manager != NULL) { win->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration( wayl->xdg_decoration_manager, win->xdg_toplevel); + + LOG_INFO("preferring %s decorations", + conf->csd.preferred == CONF_CSD_PREFER_SERVER ? "SSD" : "CSD"); + zxdg_toplevel_decoration_v1_set_mode( - win->xdg_toplevel_decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + win->xdg_toplevel_decoration, + (conf->csd.preferred == CONF_CSD_PREFER_SERVER + ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE + : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE)); + zxdg_toplevel_decoration_v1_add_listener( win->xdg_toplevel_decoration, &xdg_toplevel_decoration_listener, win); } else { diff --git a/wayland.h b/wayland.h index b879c319..f94ad0e5 100644 --- a/wayland.h +++ b/wayland.h @@ -82,15 +82,6 @@ struct wl_primary { uint32_t serial; }; -/* I'd prefer to position the CSD sub-surfaces outside the main - * surface. Unfortunately, a lot of compositors doesn't handle this - * correctly. When this define is 0, we instead position the CSD - * sub-surfaces inside the main surface, and offset the grid content - * accordingly. */ -#define FOOT_CSD_OUTSIDE 1 -extern const int csd_border_size; -extern const int csd_title_size; - enum csd_surface { CSD_SURF_TITLE, CSD_SURF_LEFT, -- cgit v1.3 From 74175b5bd12d5d28bcb298f3dfdad63b7e5bba56 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 18:45:38 +0100 Subject: config: prefer $SHELL over /etc/passwd If the user hasn't configured a shell in footrc, use $SHELL. Only if that variable isn't set do we use the shell from /etc/passwd. --- config.c | 16 ++++++++++------ doc/foot.5.scd | 7 ++++--- footrc | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index 246e0d18..4303c4ab 100644 --- a/config.c +++ b/config.c @@ -44,15 +44,19 @@ static const uint32_t default_bright[] = { static char * get_shell(void) { - struct passwd *passwd = getpwuid(getuid()); - if (passwd == NULL) { - LOG_ERRNO("failed to lookup user"); - return NULL; + const char *shell = getenv("SHELL"); + + if (shell == NULL) { + struct passwd *passwd = getpwuid(getuid()); + if (passwd == NULL) { + LOG_ERRNO("failed to lookup user"); + return NULL; + } + + shell = passwd->pw_shell; } - const char *shell = passwd->pw_shell; LOG_DBG("user's shell: %s", shell); - return strdup(shell); } diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 30fd735c..2eebcf11 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -41,9 +41,10 @@ in this order: _XxY_ (-padding). *shell* - Executable to launch. Typically a shell. Default: the user's - default shell (as specified in _/etc/passwd_). You can also pass - arguments. For example "/bin/bash --norc". + Executable to launch. Typically a shell. Default: _$SHELL_ if set, + otherwise the user's default shell (as specified in + _/etc/passwd_). You can also pass arguments. For example + "/bin/bash --norc". *login-shell* Start a login shell, by prepending a '-' to argv[0]. Default: _no_. diff --git a/footrc b/footrc index 7eea3ada..e63403f8 100644 --- a/footrc +++ b/footrc @@ -4,7 +4,7 @@ # scrollback=1000 # geometry=800x600 # pad=2x2 -# shell= (you may need to override if you need a login shell) +# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd) # term=foot # login-shell=no # workers= -- cgit v1.3 From 1f33b4a292fbfa097dd591692cb8c1ba7a5f7de9 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 18:47:48 +0100 Subject: doc: foot.5: describe what each section in the configuration file does --- doc/foot.5.scd | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'doc') diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 2eebcf11..99240b21 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -64,6 +64,9 @@ in this order: # SECTION: cursor +This section controls the cursor style and color. Note that +applications can change these runtime. + *style* Configures the default cursor style, and is one of: _block_, _bar_ or _underline_. Default: _block_. @@ -77,6 +80,9 @@ in this order: # SECTION: colors +This section controls the 16 ANSI colors and the default foreground +and background colors. Note that applications can change these runtime. + *foreground* Default RRGGBB foreground color. This is the color used when no ANSI color is being used. Default: _dcdccc_. -- cgit v1.3 From 9699c9b8bfcbd7f9ebef5ee4ffe370cb03b1c8a2 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 20:29:28 +0100 Subject: csd: initial implementation of minimize/maximize/close buttons --- config.c | 47 ++++++++++++++++++++++++++++++++-- config.h | 7 +++++ doc/foot.5.scd | 34 ++++++++++++++++++------ footrc | 8 ++++-- input.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ render.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- render.h | 1 + terminal.c | 16 ++++++++---- terminal.h | 3 +++ wayland.c | 6 ++++- wayland.h | 7 +++-- 11 files changed, 268 insertions(+), 21 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index 983cda99..ef7f9a25 100644 --- a/config.c +++ b/config.c @@ -372,7 +372,7 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.color.border = color; } - else if (strcmp(key, "titlebar") == 0) { + else if (strcmp(key, "titlebar-size") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); @@ -382,7 +382,7 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.title_height = pixels; } - else if (strcmp(key, "border") == 0) { + else if (strcmp(key, "border-width") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); @@ -392,6 +392,48 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.border_width = pixels; } + else if (strcmp(key, "button-width") == 0) { + unsigned long pixels; + if (!str_to_ulong(value, 10, &pixels)) { + LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); + return false; + } + + conf->csd.button_width = pixels; + } + + else if (strcmp(key, "button-minimize-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, path, lineno)) { + LOG_ERR("%s:%d: invalid button-minimize-color: %s", path, lineno, value); + return false; + } + + conf->csd.color.minimize_set = true; + conf->csd.color.minimize = color; + } + + else if (strcmp(key, "button-maximize-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, path, lineno)) { + LOG_ERR("%s:%d: invalid button-maximize-color: %s", path, lineno, value); + return false; + } + + conf->csd.color.maximize_set = true; + conf->csd.color.maximize = color; + } + + else if (strcmp(key, "button-close-color") == 0) { + uint32_t color; + if (!str_to_color(value, &color, true, path, lineno)) { + LOG_ERR("%s:%d: invalid button-close-color: %s", path, lineno, value); + return false; + } + + conf->csd.color.close_set = true; + conf->csd.color.close = color; + } return true; } @@ -602,6 +644,7 @@ config_load(struct config *conf, const char *conf_path) .preferred = CONF_CSD_PREFER_SERVER, .title_height = 26, .border_width = 5, + .button_width = 22, .color = { .title_set = false, .border_set = false, diff --git a/config.h b/config.h index fa765476..dd34c589 100644 --- a/config.h +++ b/config.h @@ -41,12 +41,19 @@ struct config { int title_height; int border_width; + int button_width; struct { bool title_set; bool border_set; + bool minimize_set; + bool maximize_set; + bool close_set; uint32_t title; uint32_t border; + uint32_t minimize; + uint32_t maximize; + uint32_t close; } color; } csd; diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 99240b21..778809a4 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -83,6 +83,10 @@ applications can change these runtime. This section controls the 16 ANSI colors and the default foreground and background colors. Note that applications can change these runtime. +The colors are in RRGGBB format. That is, they do *not* have an alpha +component. You can configure the background transparency with the +_alpha_ option. + *foreground* Default RRGGBB foreground color. This is the color used when no ANSI color is being used. Default: _dcdccc_. @@ -112,29 +116,43 @@ Decorations). Note that the default is to *not* use CSDs, but instead to use _SSDs_ (Server Side Decorations) when the compositor supports it. +Note that unlike the colors defined in the _colors_ section, the color +values here are in AARRGGBB format. I.e. they contain an alpha +component. + *preferred* Which type of window decorations to prefer: *client* (CSD) or *server* (SSD). Note that this is only a hint to the compositor. Depending on the compositor's configuration and capabilities, it may not have any effect. Default: _server_. -*titlebar* +*titlebar-size* Height, in pixels (but subject to output scaling), of the titlebar, not including the window border. Default: _26_. -*border* +*border-width* Width, in pixels (but subject to output scaling), of the borders. Default: _5_. *titlebar-color* - Titlebar AARRGGBB color. Note that unlike the other color values, - the *titlebar-color* value also has an _alpha_ component. Default: - use the default _foreground_ color. + Titlebar AARRGGBB color. Default: use the default _foreground_ + color. *border-color* - Border AARRGGBB color. Note that unlike the other color values, - the *border-color* value also has an _alpha_ component. Default: - _transparent_. + Border AARRGGBB color. Default: _transparent_. + +*button-width* + Width, in pixels (but subject to output scaling), of the + minimize/maximize/close buttons. Default: _22_. + +*button-minimize-color* + Minimize button's AARRGGBB color. Default: _ff0000ff_. + +*button-maximize-color* + Maximize button's AARRGGBB color. Default: _ff00ff00_. + +*button-close-color* + Close button's AARRGGBB color. Default: _ffff0000_. # FONT FORMAT diff --git a/footrc b/footrc index 7078ff43..a9bce529 100644 --- a/footrc +++ b/footrc @@ -36,7 +36,11 @@ [csd] # preferred=server -# titlebar=26 -# border=5 +# titlebar-size=26 +# border-width=5 # titlebar-color= # border-color=00000000 +# button-width=22 +# button-minimize-color=ff0000ff +# button-maximize-color=ff00ff00 +# button-close-color=ffff0000 diff --git a/input.c b/input.c index 2526807a..5ca13785 100644 --- a/input.c +++ b/input.c @@ -24,6 +24,7 @@ #include "config.h" #include "commands.h" #include "keymap.h" +#include "quirks.h" #include "render.h" #include "search.h" #include "selection.h" @@ -708,6 +709,28 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, render_xcursor_set(term); break; + case TERM_SURF_BUTTON_MINIMIZE: + case TERM_SURF_BUTTON_MAXIMIZE: + case TERM_SURF_BUTTON_CLOSE: { + enum csd_surface idx = + term->active_surface == TERM_SURF_BUTTON_MINIMIZE ? CSD_SURF_MINIMIZE : + term->active_surface == TERM_SURF_BUTTON_MAXIMIZE ? CSD_SURF_MAXIMIZE : + CSD_SURF_CLOSE; + + quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[CSD_SURF_TITLE]); + quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[idx]); + + render_csd_button(term, idx); + + quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[idx]); + quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[CSD_SURF_TITLE]); + wl_surface_commit(win->surface); + + term->xcursor = "left_ptr"; + render_xcursor_set(term); + break; + } + case TERM_SURF_NONE: assert(false); break; @@ -746,8 +769,43 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, = wl_surface_get_user_data(surface); assert(old_moused == win->term); } + + enum term_surface active_surface = old_moused->active_surface; + old_moused->active_surface = TERM_SURF_NONE; term_xcursor_update(old_moused); + + switch (active_surface) { + case TERM_SURF_BUTTON_MINIMIZE: + case TERM_SURF_BUTTON_MAXIMIZE: + case TERM_SURF_BUTTON_CLOSE: { + enum csd_surface idx = + active_surface == TERM_SURF_BUTTON_MINIMIZE ? CSD_SURF_MINIMIZE : + active_surface == TERM_SURF_BUTTON_MAXIMIZE ? CSD_SURF_MAXIMIZE : + CSD_SURF_CLOSE; + + quirk_weston_subsurface_desync_on(old_moused->window->csd.sub_surface[CSD_SURF_TITLE]); + quirk_weston_subsurface_desync_on(old_moused->window->csd.sub_surface[idx]); + + render_csd_button(old_moused, idx); + + quirk_weston_subsurface_desync_off(old_moused->window->csd.sub_surface[idx]); + quirk_weston_subsurface_desync_off(old_moused->window->csd.sub_surface[CSD_SURF_TITLE]); + wl_surface_commit(old_moused->window->surface); + break; + } + + case TERM_SURF_NONE: + case TERM_SURF_GRID: + case TERM_SURF_SEARCH: + case TERM_SURF_TITLE: + case TERM_SURF_BORDER_LEFT: + case TERM_SURF_BORDER_RIGHT: + case TERM_SURF_BORDER_TOP: + case TERM_SURF_BORDER_BOTTOM: + break; + } + } } @@ -787,6 +845,9 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, switch (term->active_surface) { case TERM_SURF_NONE: case TERM_SURF_SEARCH: + case TERM_SURF_BUTTON_MINIMIZE: + case TERM_SURF_BUTTON_MAXIMIZE: + case TERM_SURF_BUTTON_CLOSE: break; case TERM_SURF_TITLE: @@ -976,6 +1037,26 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, return; } + case TERM_SURF_BUTTON_MINIMIZE: + if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) + xdg_toplevel_set_minimized(term->window->xdg_toplevel); + break; + + case TERM_SURF_BUTTON_MAXIMIZE: + if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) { + if (term->window->is_maximized) + xdg_toplevel_unset_maximized(term->window->xdg_toplevel); + else + xdg_toplevel_set_maximized(term->window->xdg_toplevel); + } + break; + + case TERM_SURF_BUTTON_CLOSE: + if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) + term_shutdown(term); + //LOG_ERR("unimplemented: terminate"); + break; + case TERM_SURF_SEARCH: break; diff --git a/render.c b/render.c index f08c4cf4..c24c41cc 100644 --- a/render.c +++ b/render.c @@ -682,6 +682,9 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) const int title_height = !term->window->is_fullscreen ? term->conf->csd.title_height * term->scale : 0; + const int button_width = !term->window->is_fullscreen + ? term->conf->csd.button_width * term->scale : 0; + switch (surf_idx) { case CSD_SURF_TITLE: return (struct csd_data){ 0, -title_height, term->width, title_height}; case CSD_SURF_LEFT: return (struct csd_data){-border_width, -title_height, border_width, title_height + term->height}; @@ -689,6 +692,11 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx) case CSD_SURF_TOP: return (struct csd_data){-border_width, -title_height - border_width, term->width + 2 * border_width, border_width}; case CSD_SURF_BOTTOM: return (struct csd_data){-border_width, term->height, term->width + 2 * border_width, border_width}; + /* Positioned relative to CSD_SURF_TITLE */ + case CSD_SURF_MINIMIZE: return (struct csd_data){term->width - 3 * button_width, 0, button_width, title_height}; + case CSD_SURF_MAXIMIZE: return (struct csd_data){term->width - 2 * button_width, 0, button_width, title_height}; + case CSD_SURF_CLOSE: return (struct csd_data){term->width - 1 * button_width, 0, button_width, title_height}; + case CSD_SURF_COUNT: assert(false); return (struct csd_data){0}; @@ -780,6 +788,73 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx) render_csd_part(term, surf, buf, info.width, info.height, &color); } +void +render_csd_button(struct terminal *term, enum csd_surface surf_idx) +{ + assert(surf_idx >= CSD_SURF_MINIMIZE); + + if (term->window->use_csd != CSD_YES) + return; + + struct csd_data info = get_csd_data(term, surf_idx); + struct wl_surface *surf = term->window->csd.surface[surf_idx]; + + if (info.width == 0 || info.height == 0) + return; + + unsigned long cookie = shm_cookie_csd(term, surf_idx); + struct buffer *buf = shm_get_buffer( + term->wl->shm, info.width, info.height, cookie); + + uint32_t _color; + uint16_t alpha = 0xffff; + bool is_active = false; + const bool *is_set = NULL; + const uint32_t *conf_color = NULL; + + switch (surf_idx) { + case CSD_SURF_MINIMIZE: + _color = 0xff0000ff; + is_set = &term->conf->csd.color.minimize_set; + conf_color = &term->conf->csd.color.minimize; + is_active = term->active_surface == TERM_SURF_BUTTON_MINIMIZE; + break; + + case CSD_SURF_MAXIMIZE: + _color = 0xff00ff00; + is_set = &term->conf->csd.color.maximize_set; + conf_color = &term->conf->csd.color.maximize; + is_active = term->active_surface == TERM_SURF_BUTTON_MAXIMIZE; + break; + + case CSD_SURF_CLOSE: + _color = 0xffff0000; + is_set = &term->conf->csd.color.close_set; + conf_color = &term->conf->csd.color.close; + is_active = term->active_surface == TERM_SURF_BUTTON_CLOSE; + break; + + default: + assert(false); + break; + } + + if (is_active) { + if (*is_set) { + _color = *conf_color; + alpha = _color >> 24 | (_color >> 24 << 8); + } + } else { + _color = 0; + alpha = 0; + } + + pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); + if (!term->visual_focus) + pixman_color_dim(&color); + render_csd_part(term, surf, buf, info.width, info.height, &color); +} + void render_csd(struct terminal *term) { @@ -798,7 +873,7 @@ render_csd(struct terminal *term) if (width == 0 || height == 0) { /* CSD borders aren't rendered in maximized mode */ - assert(term->window->is_maximized); + assert(term->window->is_maximized || term->window->is_fullscreen); wl_subsurface_set_position(sub, 0, 0); wl_surface_attach(surf, NULL, 0, 0); wl_surface_commit(surf); @@ -811,6 +886,8 @@ render_csd(struct terminal *term) render_csd_title(term); for (size_t i = CSD_SURF_LEFT; i <= CSD_SURF_BOTTOM; i++) render_csd_border(term, i); + for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) + render_csd_button(term, i); } static void frame_callback( diff --git a/render.h b/render.h index 2177e8bd..cccf2001 100644 --- a/render.h +++ b/render.h @@ -19,6 +19,7 @@ bool render_xcursor_set(struct terminal *term); void render_search_box(struct terminal *term); void render_csd(struct terminal *term); void render_csd_title(struct terminal *term); +void render_csd_button(struct terminal *term, enum csd_surface surf_idx); struct render_worker_context { int my_id; diff --git a/terminal.c b/terminal.c index 290a1425..c57b3c1c 100644 --- a/terminal.c +++ b/terminal.c @@ -2149,16 +2149,22 @@ term_surface_kind(const struct terminal *term, const struct wl_surface *surface) return TERM_SURF_GRID; else if (surface == term->window->search_surface) return TERM_SURF_SEARCH; - else if (surface == term->window->csd.surface[0]) + else if (surface == term->window->csd.surface[CSD_SURF_TITLE]) return TERM_SURF_TITLE; - else if (surface == term->window->csd.surface[1]) + else if (surface == term->window->csd.surface[CSD_SURF_LEFT]) return TERM_SURF_BORDER_LEFT; - else if (surface == term->window->csd.surface[2]) + else if (surface == term->window->csd.surface[CSD_SURF_RIGHT]) return TERM_SURF_BORDER_RIGHT; - else if (surface == term->window->csd.surface[3]) + else if (surface == term->window->csd.surface[CSD_SURF_TOP]) return TERM_SURF_BORDER_TOP; - else if (surface == term->window->csd.surface[4]) + else if (surface == term->window->csd.surface[CSD_SURF_BOTTOM]) return TERM_SURF_BORDER_BOTTOM; + else if (surface == term->window->csd.surface[CSD_SURF_MINIMIZE]) + return TERM_SURF_BUTTON_MINIMIZE; + else if (surface == term->window->csd.surface[CSD_SURF_MAXIMIZE]) + return TERM_SURF_BUTTON_MAXIMIZE; + else if (surface == term->window->csd.surface[CSD_SURF_CLOSE]) + return TERM_SURF_BUTTON_CLOSE; else return TERM_SURF_NONE; } diff --git a/terminal.h b/terminal.h index df3fb06a..3731ee0d 100644 --- a/terminal.h +++ b/terminal.h @@ -194,6 +194,9 @@ enum term_surface { TERM_SURF_BORDER_RIGHT, TERM_SURF_BORDER_TOP, TERM_SURF_BORDER_BOTTOM, + TERM_SURF_BUTTON_MINIMIZE, + TERM_SURF_BUTTON_MAXIMIZE, + TERM_SURF_BUTTON_CLOSE, }; struct terminal { diff --git a/wayland.c b/wayland.c index 95d2880e..26982815 100644 --- a/wayland.c +++ b/wayland.c @@ -47,8 +47,12 @@ csd_instantiate(struct wl_window *win) assert(win->csd.sub_surface[i] == NULL); win->csd.surface[i] = wl_compositor_create_surface(wayl->compositor); + + struct wl_surface *parent = i < CSD_SURF_MINIMIZE + ? win->surface : win->csd.surface[CSD_SURF_TITLE]; + win->csd.sub_surface[i] = wl_subcompositor_get_subsurface( - wayl->sub_compositor, win->csd.surface[i], win->surface); + wayl->sub_compositor, win->csd.surface[i], parent); wl_subsurface_set_sync(win->csd.sub_surface[i]); wl_surface_set_user_data(win->csd.surface[i], win); diff --git a/wayland.h b/wayland.h index f94ad0e5..ed53591d 100644 --- a/wayland.h +++ b/wayland.h @@ -88,6 +88,9 @@ enum csd_surface { CSD_SURF_RIGHT, CSD_SURF_TOP, CSD_SURF_BOTTOM, + CSD_SURF_MINIMIZE, + CSD_SURF_MAXIMIZE, + CSD_SURF_CLOSE, CSD_SURF_COUNT, }; @@ -103,8 +106,8 @@ struct wl_window { enum {CSD_UNKNOWN, CSD_NO, CSD_YES } use_csd; struct { - struct wl_surface *surface[5]; - struct wl_subsurface *sub_surface[5]; + struct wl_surface *surface[CSD_SURF_COUNT]; + struct wl_subsurface *sub_surface[CSD_SURF_COUNT]; int move_timeout_fd; uint32_t serial; } csd; -- cgit v1.3 From b14c217fb62bbdf4350c2877b889f42fe2ba69b8 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 21:09:21 +0100 Subject: render: csd: minimize: change default color to a lighter blue --- doc/foot.5.scd | 2 +- render.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 778809a4..f4a263d8 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -146,7 +146,7 @@ component. minimize/maximize/close buttons. Default: _22_. *button-minimize-color* - Minimize button's AARRGGBB color. Default: _ff0000ff_. + Minimize button's AARRGGBB color. Default: _ff1e90ff_. *button-maximize-color* Maximize button's AARRGGBB color. Default: _ff00ff00_. diff --git a/render.c b/render.c index c9aa8f78..c3ea0744 100644 --- a/render.c +++ b/render.c @@ -871,7 +871,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) switch (surf_idx) { case CSD_SURF_MINIMIZE: - _color = 0xff0000ff; + _color = 0xff1e90ff; is_set = &term->conf->csd.color.minimize_set; conf_color = &term->conf->csd.color.minimize; is_active = term->active_surface == TERM_SURF_BUTTON_MINIMIZE; -- cgit v1.3 From 63a3d6ce03f0de8bf5f1d7d8ccc789970c8c11c8 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 21:10:25 +0100 Subject: render: csd: close: change default color to a lighter blue --- doc/foot.5.scd | 2 +- render.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/foot.5.scd b/doc/foot.5.scd index f4a263d8..8d5f9bab 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -152,7 +152,7 @@ component. Maximize button's AARRGGBB color. Default: _ff00ff00_. *button-close-color* - Close button's AARRGGBB color. Default: _ffff0000_. + Close button's AARRGGBB color. Default: _ffff3030_. # FONT FORMAT diff --git a/render.c b/render.c index c3ea0744..468b2d31 100644 --- a/render.c +++ b/render.c @@ -885,7 +885,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) break; case CSD_SURF_CLOSE: - _color = 0xffff0000; + _color = 0xffff3030; is_set = &term->conf->csd.color.close_set; conf_color = &term->conf->csd.color.close; is_active = term->active_surface == TERM_SURF_BUTTON_CLOSE; -- cgit v1.3 From cb6616ef8ac9f778a4e86b713033d0355dc27279 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 2 Mar 2020 21:11:17 +0100 Subject: render: csd: maximize: change default color to a lighter green --- doc/foot.5.scd | 2 +- render.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 8d5f9bab..3d775cb5 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -149,7 +149,7 @@ component. Minimize button's AARRGGBB color. Default: _ff1e90ff_. *button-maximize-color* - Maximize button's AARRGGBB color. Default: _ff00ff00_. + Maximize button's AARRGGBB color. Default: _ff30ff30_. *button-close-color* Close button's AARRGGBB color. Default: _ffff3030_. diff --git a/render.c b/render.c index 468b2d31..52c80e08 100644 --- a/render.c +++ b/render.c @@ -878,7 +878,7 @@ render_csd_button(struct terminal *term, enum csd_surface surf_idx) break; case CSD_SURF_MAXIMIZE: - _color = 0xff00ff00; + _color = 0xff30ff30; is_set = &term->conf->csd.color.maximize_set; conf_color = &term->conf->csd.color.maximize; is_active = term->active_surface == TERM_SURF_BUTTON_MAXIMIZE; -- cgit v1.3 From c90d70b2bfc93fa7bf58f9e8805a55b191828886 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 3 Mar 2020 18:18:59 +0100 Subject: config: CSD borders are always invisible That is, remove all configuration options and always draw them fully transparent. --- config.c | 29 ++--------------------------- config.h | 2 -- doc/foot.5.scd | 17 +++++------------ footrc | 6 ++---- render.c | 12 +----------- 5 files changed, 10 insertions(+), 56 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index ef7f9a25..158eabec 100644 --- a/config.c +++ b/config.c @@ -350,7 +350,7 @@ parse_section_csd(const char *key, const char *value, struct config *conf, } } - else if (strcmp(key, "titlebar-color") == 0) { + else if (strcmp(key, "color") == 0) { uint32_t color; if (!str_to_color(value, &color, true, path, lineno)) { LOG_ERR("%s:%d: invalid titlebar-color: %s", path, lineno, value); @@ -361,18 +361,7 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.color.title = color; } - else if (strcmp(key, "border-color") == 0) { - uint32_t color; - if (!str_to_color(value, &color, true, path, lineno)) { - LOG_ERR("%s:%d: invalid border-color: %s", path, lineno, value); - return false; - } - - conf->csd.color.border_set = true; - conf->csd.color.border = color; - } - - else if (strcmp(key, "titlebar-size") == 0) { + else if (strcmp(key, "size") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); @@ -382,16 +371,6 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.title_height = pixels; } - else if (strcmp(key, "border-width") == 0) { - unsigned long pixels; - if (!str_to_ulong(value, 10, &pixels)) { - LOG_ERR("%s:%d: expected an integer: %s", path, lineno, value); - return false; - } - - conf->csd.border_width = pixels; - } - else if (strcmp(key, "button-width") == 0) { unsigned long pixels; if (!str_to_ulong(value, 10, &pixels)) { @@ -645,10 +624,6 @@ config_load(struct config *conf, const char *conf_path) .title_height = 26, .border_width = 5, .button_width = 22, - .color = { - .title_set = false, - .border_set = false, - }, }, .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), diff --git a/config.h b/config.h index dd34c589..a89637e1 100644 --- a/config.h +++ b/config.h @@ -45,12 +45,10 @@ struct config { struct { bool title_set; - bool border_set; bool minimize_set; bool maximize_set; bool close_set; uint32_t title; - uint32_t border; uint32_t minimize; uint32_t maximize; uint32_t close; diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 3d775cb5..69c6f385 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -126,23 +126,16 @@ component. compositor. Depending on the compositor's configuration and capabilities, it may not have any effect. Default: _server_. -*titlebar-size* - Height, in pixels (but subject to output scaling), of the - titlebar, not including the window border. Default: _26_. +*size* + Height, in pixels (subject to output scaling), of the + titlebar. Default: _26_. -*border-width* - Width, in pixels (but subject to output scaling), of the - borders. Default: _5_. - -*titlebar-color* +*color* Titlebar AARRGGBB color. Default: use the default _foreground_ color. -*border-color* - Border AARRGGBB color. Default: _transparent_. - *button-width* - Width, in pixels (but subject to output scaling), of the + Width, in pixels (subject to output scaling), of the minimize/maximize/close buttons. Default: _22_. *button-minimize-color* diff --git a/footrc b/footrc index a9bce529..e2799fdd 100644 --- a/footrc +++ b/footrc @@ -36,10 +36,8 @@ [csd] # preferred=server -# titlebar-size=26 -# border-width=5 -# titlebar-color= -# border-color=00000000 +# size=26 +# color= # button-width=22 # button-minimize-color=ff0000ff # button-maximize-color=ff00ff00 diff --git a/render.c b/render.c index 52c80e08..b422ef93 100644 --- a/render.c +++ b/render.c @@ -779,17 +779,7 @@ render_csd_border(struct terminal *term, enum csd_surface surf_idx) struct buffer *buf = shm_get_buffer( term->wl->shm, info.width, info.height, cookie); - uint32_t _color = 0; - uint16_t alpha = 0; - - if (term->conf->csd.color.border_set) { - _color = term->conf->csd.color.border; - alpha = _color >> 24 | (_color >> 24 << 8); - } - - pixman_color_t color = color_hex_to_pixman_with_alpha(_color, alpha); - if (!term->visual_focus) - pixman_color_dim(&color); + pixman_color_t color = color_hex_to_pixman_with_alpha(0, 0); render_csd_part(term, surf, buf, info.width, info.height, &color); csd_commit(term, surf, buf); } -- cgit v1.3 From 27ef5b472a88706decf6c993eec6e0e0d6775312 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 6 Mar 2020 19:11:31 +0100 Subject: config: change default CSD button width from 22 -> 26 --- config.c | 2 +- doc/foot.5.scd | 2 +- footrc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/config.c b/config.c index 158eabec..46056567 100644 --- a/config.c +++ b/config.c @@ -623,7 +623,7 @@ config_load(struct config *conf, const char *conf_path) .preferred = CONF_CSD_PREFER_SERVER, .title_height = 26, .border_width = 5, - .button_width = 22, + .button_width = 26, }, .render_worker_count = sysconf(_SC_NPROCESSORS_ONLN), diff --git a/doc/foot.5.scd b/doc/foot.5.scd index 69c6f385..edfecc27 100644 --- a/doc/foot.5.scd +++ b/doc/foot.5.scd @@ -136,7 +136,7 @@ component. *button-width* Width, in pixels (subject to output scaling), of the - minimize/maximize/close buttons. Default: _22_. + minimize/maximize/close buttons. Default: _26_. *button-minimize-color* Minimize button's AARRGGBB color. Default: _ff1e90ff_. diff --git a/footrc b/footrc index e2799fdd..7cac547d 100644 --- a/footrc +++ b/footrc @@ -38,7 +38,7 @@ # preferred=server # size=26 # color= -# button-width=22 +# button-width=26 # button-minimize-color=ff0000ff # button-maximize-color=ff00ff00 # button-close-color=ffff0000 -- cgit v1.3