ssd: add optional omnipresent button

This commit is contained in:
Andrew J. Hesford 2024-08-23 12:45:14 -04:00 committed by Consolatis
parent 186a07be9b
commit b7bccc8026
12 changed files with 165 additions and 52 deletions

View file

@ -79,6 +79,21 @@ add_button(struct ssd *ssd, struct ssd_sub_tree *subtree, enum ssd_part_type typ
active ? &theme->button_unshade_active_hover->base
: &theme->button_unshade_inactive_hover->base);
break;
case LAB_SSD_BUTTON_OMNIPRESENT:
/* Omnipresent button has an alternate state when enabled */
btn_root = add_scene_button(&subtree->parts, type, parent,
active ? &theme->button_omnipresent_active_unpressed->base
: &theme->button_omnipresent_inactive_unpressed->base,
active ? &theme->button_omnipresent_active_hover->base
: &theme->button_omnipresent_inactive_hover->base,
x, view);
btn = node_ssd_button_from_node(btn_root->node);
add_toggled_icon(btn, &subtree->parts, LAB_SSD_BUTTON_OMNIPRESENT,
active ? &theme->button_exclusive_active_unpressed->base
: &theme->button_exclusive_inactive_unpressed->base,
active ? &theme->button_exclusive_active_hover->base
: &theme->button_exclusive_inactive_hover->base);
break;
case LAB_SSD_BUTTON_CLOSE:
add_scene_button(&subtree->parts, type, parent,
active ? &theme->button_close_active_unpressed->base
@ -164,6 +179,10 @@ ssd_titlebar_create(struct ssd *ssd)
set_alt_button_icon(ssd, LAB_SSD_BUTTON_SHADE, true);
}
if (view->visible_on_all_workspaces) {
set_alt_button_icon(ssd, LAB_SSD_BUTTON_OMNIPRESENT, true);
}
if (view_is_tiled_and_notify_tiled(view) && !maximized) {
set_squared_corners(ssd, true);
ssd->state.was_tiled_not_maximized = true;
@ -230,24 +249,30 @@ ssd_titlebar_update(struct ssd *ssd)
struct theme *theme = view->server->theme;
bool maximized = view->maximized == VIEW_AXIS_BOTH;
bool tiled_not_maximized = view_is_tiled_and_notify_tiled(ssd->view)
&& !maximized;
bool tiled_not_maximized =
view_is_tiled_and_notify_tiled(ssd->view) && !maximized;
if (ssd->state.was_maximized != maximized
|| ssd->state.was_shaded != view->shaded
|| ssd->state.was_tiled_not_maximized != tiled_not_maximized) {
set_squared_corners(ssd, maximized || tiled_not_maximized);
if (ssd->state.was_maximized != maximized) {
set_alt_button_icon(ssd, LAB_SSD_BUTTON_MAXIMIZE, maximized);
}
if (ssd->state.was_shaded != view->shaded) {
set_alt_button_icon(ssd, LAB_SSD_BUTTON_SHADE, view->shaded);
}
ssd->state.was_maximized = maximized;
ssd->state.was_shaded = view->shaded;
ssd->state.was_tiled_not_maximized = tiled_not_maximized;
}
if (ssd->state.was_shaded != view->shaded) {
set_alt_button_icon(ssd, LAB_SSD_BUTTON_SHADE, view->shaded);
ssd->state.was_shaded = view->shaded;
}
if (ssd->state.was_omnipresent != view->visible_on_all_workspaces) {
set_alt_button_icon(ssd, LAB_SSD_BUTTON_OMNIPRESENT,
view->visible_on_all_workspaces);
ssd->state.was_omnipresent = view->visible_on_all_workspaces;
}
if (width == ssd->state.geometry.width) {
return;
}

View file

@ -221,13 +221,16 @@ ssd_update_geometry(struct ssd *ssd)
return;
}
struct view *view = ssd->view;
assert(view);
struct wlr_box cached = ssd->state.geometry;
struct wlr_box current = ssd->view->current;
struct wlr_box current = view->current;
int min_view_width = rc.theme->window_button_width * (
wl_list_length(&rc.title_buttons_left) + wl_list_length(&rc.title_buttons_right));
int eff_width = current.width;
int eff_height = view_effective_height(ssd->view, /* use_pending */ false);
int eff_height = view_effective_height(view, /* use_pending */ false);
if (eff_width > 0 && eff_width < min_view_width) {
/*
@ -241,39 +244,31 @@ ssd_update_geometry(struct ssd *ssd)
return;
}
if (eff_width == cached.width && eff_height == cached.height) {
if (current.x != cached.x || current.y != cached.y) {
/* Dynamically resize extents based on position and usable_area */
ssd_extents_update(ssd);
ssd->state.geometry = current;
}
bool maximized = ssd->view->maximized == VIEW_AXIS_BOTH;
if (ssd->state.was_maximized != maximized
|| ssd->state.was_shaded != ssd->view->shaded) {
ssd_titlebar_update(ssd);
ssd_border_update(ssd);
ssd_shadow_update(ssd);
/*
* Not strictly necessary as ssd_titlebar_update()
* already sets these values, but set here to be safe.
*/
ssd->state.was_maximized = maximized;
ssd->state.was_shaded = ssd->view->shaded;
}
bool tiled_and_not_maximized = view_is_tiled(ssd->view) && !maximized;
if (ssd->state.was_tiled_not_maximized != tiled_and_not_maximized) {
ssd_titlebar_update(ssd);
ssd_border_update(ssd);
/* see above about being future proof */
ssd->state.was_tiled_not_maximized = tiled_and_not_maximized;
}
return;
bool update_area = eff_width != cached.width || eff_height != cached.height;
bool update_extents = update_area
|| current.x != cached.x || current.y != cached.y;
bool maximized = view->maximized == VIEW_AXIS_BOTH;
bool tiled_not_maximized = view_is_tiled(view) && !maximized;
bool state_changed = ssd->state.was_maximized != maximized
|| ssd->state.was_shaded != view->shaded
|| ssd->state.was_tiled_not_maximized != tiled_not_maximized
|| ssd->state.was_omnipresent != view->visible_on_all_workspaces;
if (update_extents) {
ssd_extents_update(ssd);
}
if (update_area || state_changed) {
ssd_titlebar_update(ssd);
ssd_border_update(ssd);
ssd_shadow_update(ssd);
}
if (update_extents) {
ssd->state.geometry = current;
}
ssd_extents_update(ssd);
ssd_titlebar_update(ssd);
ssd_border_update(ssd);
ssd_shadow_update(ssd);
ssd->state.geometry = current;
}
void