mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
Merge branch 'hide-csd-buttons-when-title-bar-gets-too-small' into master
This commit is contained in:
commit
c0156ed1e0
2 changed files with 18 additions and 8 deletions
|
|
@ -115,6 +115,8 @@
|
||||||
* Clipboard (or primary selection) is now cleared when receiving an
|
* Clipboard (or primary selection) is now cleared when receiving an
|
||||||
OSC-52 command with an invalid base64 encoded payload.
|
OSC-52 command with an invalid base64 encoded payload.
|
||||||
* Cursor position being set outside the grid when reflowing text.
|
* Cursor position being set outside the grid when reflowing text.
|
||||||
|
* CSD buttons to be hidden when window size becomes so small that they
|
||||||
|
no longer fit.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
24
render.c
24
render.c
|
|
@ -957,23 +957,33 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
|
||||||
const int border_width = !term->window->is_maximized
|
const int border_width = !term->window->is_maximized
|
||||||
? term->conf->csd.border_width * term->scale : 0;
|
? term->conf->csd.border_width * term->scale : 0;
|
||||||
|
|
||||||
const int title_height = !term->window->is_fullscreen
|
const int title_height = term->window->is_fullscreen
|
||||||
? term->conf->csd.title_height * term->scale : 0;
|
? 0
|
||||||
|
: term->conf->csd.title_height * term->scale;
|
||||||
|
|
||||||
const int button_width = !term->window->is_fullscreen
|
const int button_width = !term->window->is_fullscreen
|
||||||
? term->conf->csd.button_width * term->scale : 0;
|
? term->conf->csd.button_width * term->scale : 0;
|
||||||
|
|
||||||
|
const int button_close_width = term->width >= 1 * button_width
|
||||||
|
? button_width : 0;
|
||||||
|
|
||||||
|
const int button_maximize_width = term->width >= 2 * button_width
|
||||||
|
? button_width : 0;
|
||||||
|
|
||||||
|
const int button_minimize_width = term->width >= 3 * button_width
|
||||||
|
? button_width : 0;
|
||||||
|
|
||||||
switch (surf_idx) {
|
switch (surf_idx) {
|
||||||
case CSD_SURF_TITLE: return (struct csd_data){ 0, -title_height, term->width, title_height};
|
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};
|
case CSD_SURF_LEFT: return (struct csd_data){-border_width, -title_height, border_width, title_height + term->height};
|
||||||
case CSD_SURF_RIGHT: return (struct csd_data){ term->width, -title_height, border_width, title_height + term->height};
|
case CSD_SURF_RIGHT: return (struct csd_data){ term->width, -title_height, border_width, title_height + term->height};
|
||||||
case CSD_SURF_TOP: return (struct csd_data){-border_width, -title_height - border_width, term->width + 2 * border_width, border_width};
|
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};
|
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 */
|
/* 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_MINIMIZE: return (struct csd_data){term->width - 3 * button_width, 0, button_minimize_width, title_height};
|
||||||
case CSD_SURF_MAXIMIZE: return (struct csd_data){term->width - 2 * button_width, 0, button_width, title_height};
|
case CSD_SURF_MAXIMIZE: return (struct csd_data){term->width - 2 * button_width, 0, button_maximize_width, title_height};
|
||||||
case CSD_SURF_CLOSE: return (struct csd_data){term->width - 1 * button_width, 0, button_width, title_height};
|
case CSD_SURF_CLOSE: return (struct csd_data){term->width - 1 * button_width, 0, button_close_width, title_height};
|
||||||
|
|
||||||
case CSD_SURF_COUNT:
|
case CSD_SURF_COUNT:
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
@ -1306,8 +1316,6 @@ render_csd(struct terminal *term)
|
||||||
assert(sub != NULL);
|
assert(sub != NULL);
|
||||||
|
|
||||||
if (width == 0 || height == 0) {
|
if (width == 0 || height == 0) {
|
||||||
/* CSD borders aren't rendered in maximized mode */
|
|
||||||
assert(term->window->is_maximized || term->window->is_fullscreen);
|
|
||||||
wl_subsurface_set_position(sub, 0, 0);
|
wl_subsurface_set_position(sub, 0, 0);
|
||||||
wl_surface_attach(surf, NULL, 0, 0);
|
wl_surface_attach(surf, NULL, 0, 0);
|
||||||
wl_surface_commit(surf);
|
wl_surface_commit(surf);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue