ssd: allow ssd to be smaller than minimal size by hiding buttons

This fixes the ugly look of SSD for tiny windows (e.g. "xterm -geometry
1x1") due to the early return in `ssd_update_geometry()`. Now SSDs are
rendered correctly for those windows by hiding some buttons when the
window width is smaller than the total width of buttons. Additionally for
windows smaller than (button width)*2, the corners are un-rounded so a
small titlebar can be rendered with a scene-rect.
This commit is contained in:
tokyo4j 2024-08-25 16:33:41 +09:00 committed by Andrew J. Hesford
parent b34f2c9d85
commit 1be69dc28b
6 changed files with 184 additions and 120 deletions

View file

@ -53,12 +53,19 @@ struct ssd {
bool was_omnipresent;
/*
* Corners need to be (un)rounded when toggling tiling or
* maximization, and the button needs to be swapped on
* Corners need to be (un)rounded and borders need be shown/hidden
* when toggling maximization, and the button needs to be swapped on
* maximization toggles.
*/
bool was_maximized;
bool was_tiled_not_maximized;
/*
* Corners need to be (un)rounded but borders should be kept shown when
* the window is (un)tiled and notified about it or when the window may
* become so small that only a squared scene-rect can be used to render
* such a small titlebar.
*/
bool was_squared;
struct wlr_box geometry;
struct ssd_state_title {
@ -109,9 +116,6 @@ struct ssd_part {
/* This part represented in scene graph */
struct wlr_scene_node *node;
/* Targeted geometry. May be NULL */
struct wlr_box *geometry;
struct wl_list link;
};
@ -151,6 +155,7 @@ void ssd_destroy_parts(struct wl_list *list);
void ssd_titlebar_create(struct ssd *ssd);
void ssd_titlebar_update(struct ssd *ssd);
void ssd_titlebar_destroy(struct ssd *ssd);
bool ssd_should_be_squared(struct ssd *ssd);
void ssd_border_create(struct ssd *ssd);
void ssd_border_update(struct ssd *ssd);