- L: window label (aka. title)
- |: empty space (can be used instead of a title)
- W: window menu
+ - S: shade
- I: iconify
- M: maximize
- C: close
- WindowMenu: The button on the left.
- Iconify: The button that looks like an underline.
- Maximize: The button that looks like a box.
+ - Shade: A button that looks like an overline.
- Close: The button that looks like an X.
- Top: The top edge of the window's border.
- Bottom: The bottom edge of the window's border.
</mousebind>
</context>
+ <context name="Shade">
+ <mousebind button="Left" action="Click">
+ <action name="ToggleShade" />
+ </mousebind>
+ </context>
+
<context name="Iconify">
<mousebind button="Left" action="Click">
<action name="Iconify" />
.button = "Left",
.event = "Click",
.action = "ToggleMaximize",
+ }, {
+ .context = "Shade",
+ .button = "Left",
+ .event = "Click",
+ .action = "ToggleShade",
}, {
.context = "Maximize",
.button = "Right",
* don't update things we don't have to.
*/
struct {
+ bool was_shaded; /* To toggle icon on shade */
bool was_maximized; /* To un-round corner buttons and toggle icon on maximize */
bool was_tiled_not_maximized; /* To un-round corner buttons */
struct wlr_box geometry;
LAB_SSD_BUTTON_MAXIMIZE,
LAB_SSD_BUTTON_ICONIFY,
LAB_SSD_BUTTON_WINDOW_MENU,
+ LAB_SSD_BUTTON_SHADE,
LAB_SSD_PART_TITLEBAR,
LAB_SSD_PART_TITLEBAR_CORNER_RIGHT,
LAB_SSD_PART_TITLEBAR_CORNER_LEFT,
enum ssd_part_type ssd_get_part_type(const struct ssd *ssd,
struct wlr_scene_node *node);
uint32_t ssd_resize_edges(enum ssd_part_type type);
-bool ssd_is_button(enum ssd_part_type type);
bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate);
enum ssd_mode ssd_mode_parse(const char *mode);
float window_active_button_iconify_unpressed_image_color[4];
float window_active_button_max_unpressed_image_color[4];
float window_active_button_close_unpressed_image_color[4];
+ float window_active_button_shade_unpressed_image_color[4];
float window_inactive_button_menu_unpressed_image_color[4];
float window_inactive_button_iconify_unpressed_image_color[4];
float window_inactive_button_max_unpressed_image_color[4];
float window_inactive_button_close_unpressed_image_color[4];
+ float window_inactive_button_shade_unpressed_image_color[4];
/* TODO: add pressed and hover colors for buttons */
int menu_item_padding_x;
struct lab_data_buffer *button_restore_active_unpressed;
struct lab_data_buffer *button_iconify_active_unpressed;
struct lab_data_buffer *button_menu_active_unpressed;
+ struct lab_data_buffer *button_shade_active_unpressed;
+ struct lab_data_buffer *button_unshade_active_unpressed;
struct lab_data_buffer *button_close_inactive_unpressed;
struct lab_data_buffer *button_maximize_inactive_unpressed;
struct lab_data_buffer *button_restore_inactive_unpressed;
struct lab_data_buffer *button_iconify_inactive_unpressed;
struct lab_data_buffer *button_menu_inactive_unpressed;
+ struct lab_data_buffer *button_shade_inactive_unpressed;
+ struct lab_data_buffer *button_unshade_inactive_unpressed;
/* hover variants are optional and may be NULL */
struct lab_data_buffer *button_close_active_hover;
struct lab_data_buffer *button_restore_active_hover;
struct lab_data_buffer *button_iconify_active_hover;
struct lab_data_buffer *button_menu_active_hover;
+ struct lab_data_buffer *button_shade_active_hover;
+ struct lab_data_buffer *button_unshade_active_hover;
struct lab_data_buffer *button_close_inactive_hover;
struct lab_data_buffer *button_maximize_inactive_hover;
struct lab_data_buffer *button_restore_inactive_hover;
struct lab_data_buffer *button_iconify_inactive_hover;
struct lab_data_buffer *button_menu_inactive_hover;
+ struct lab_data_buffer *button_shade_inactive_hover;
+ struct lab_data_buffer *button_unshade_inactive_hover;
struct lab_data_buffer *corner_top_left_active_normal;
struct lab_data_buffer *corner_top_right_active_normal;
return LAB_SSD_BUTTON_ICONIFY;
} else if (!strcasecmp(str, "WindowMenu")) {
return LAB_SSD_BUTTON_WINDOW_MENU;
+ } else if (!strcasecmp(str, "Shade")) {
+ return LAB_SSD_BUTTON_SHADE;
} else if (!strcasecmp(str, "Titlebar")) {
return LAB_SSD_PART_TITLEBAR;
} else if (!strcasecmp(str, "Title")) {
case 'C':
type = LAB_SSD_BUTTON_CLOSE;
break;
- /* case 'S': shade */
+ case 'S':
+ type = LAB_SSD_BUTTON_SHADE;
+ break;
/* case 'D': omnipresent */
default:
continue;
&(ssd)->titlebar.inactive)
static void set_squared_corners(struct ssd *ssd, bool enable);
-static void set_maximize_alt_icon(struct ssd *ssd, bool enable);
+static void set_alt_button_icon(struct ssd *ssd, enum ssd_part_type type, bool enable);
static void
add_button(struct ssd *ssd, struct ssd_sub_tree *subtree, enum ssd_part_type type, int x)
struct wlr_scene_tree *parent = subtree->tree;
bool active = subtree == &ssd->titlebar.active;
- struct ssd_part *btn_max_root;
- struct ssd_button *btn_max;
+ struct ssd_part *btn_root;
+ struct ssd_button *btn;
switch (type) {
case LAB_SSD_BUTTON_WINDOW_MENU:
break;
case LAB_SSD_BUTTON_MAXIMIZE:
/* Maximize button has an alternate state when maximized */
- btn_max_root = add_scene_button(&subtree->parts, type, parent,
+ btn_root = add_scene_button(&subtree->parts, type, parent,
active ? &theme->button_maximize_active_unpressed->base
: &theme->button_maximize_inactive_unpressed->base,
active ? &theme->button_maximize_active_hover->base
: &theme->button_maximize_inactive_hover->base,
x, view);
- btn_max = node_ssd_button_from_node(btn_max_root->node);
- add_toggled_icon(btn_max, &subtree->parts, LAB_SSD_BUTTON_MAXIMIZE,
+ btn = node_ssd_button_from_node(btn_root->node);
+ add_toggled_icon(btn, &subtree->parts, LAB_SSD_BUTTON_MAXIMIZE,
active ? &theme->button_restore_active_unpressed->base
: &theme->button_restore_inactive_unpressed->base,
active ? &theme->button_restore_active_hover->base
: &theme->button_restore_inactive_hover->base);
break;
+ case LAB_SSD_BUTTON_SHADE:
+ /* Shade button has an alternate state when shaded */
+ btn_root = add_scene_button(&subtree->parts, type, parent,
+ active ? &theme->button_shade_active_unpressed->base
+ : &theme->button_shade_inactive_unpressed->base,
+ active ? &theme->button_shade_active_hover->base
+ : &theme->button_shade_inactive_hover->base,
+ x, view);
+ btn = node_ssd_button_from_node(btn_root->node);
+ add_toggled_icon(btn, &subtree->parts, LAB_SSD_BUTTON_SHADE,
+ active ? &theme->button_unshade_active_unpressed->base
+ : &theme->button_unshade_inactive_unpressed->base,
+ active ? &theme->button_unshade_active_hover->base
+ : &theme->button_unshade_inactive_hover->base);
+ break;
case LAB_SSD_BUTTON_CLOSE:
add_scene_button(&subtree->parts, type, parent,
active ? &theme->button_close_active_unpressed->base
bool maximized = view->maximized == VIEW_AXIS_BOTH;
if (maximized) {
set_squared_corners(ssd, true);
- set_maximize_alt_icon(ssd, true);
+ set_alt_button_icon(ssd, LAB_SSD_BUTTON_MAXIMIZE, true);
ssd->state.was_maximized = true;
}
+
+ if (view->shaded) {
+ set_alt_button_icon(ssd, LAB_SSD_BUTTON_SHADE, true);
+ }
+
if (view_is_tiled_and_notify_tiled(view) && !maximized) {
set_squared_corners(ssd, true);
ssd->state.was_tiled_not_maximized = true;
}
static void
-set_maximize_alt_icon(struct ssd *ssd, bool enable)
+set_alt_button_icon(struct ssd *ssd, enum ssd_part_type type, bool enable)
{
struct ssd_part *part;
struct ssd_button *button;
struct ssd_sub_tree *subtree;
FOR_EACH_STATE(ssd, subtree) {
- part = ssd_get_part(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE);
+ part = ssd_get_part(&subtree->parts, type);
if (!part) {
return;
}
&& !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_maximize_alt_icon(ssd, 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;
}
};
}
-bool
-ssd_is_button(enum ssd_part_type type)
-{
- return type == LAB_SSD_BUTTON_CLOSE
- || type == LAB_SSD_BUTTON_MAXIMIZE
- || type == LAB_SSD_BUTTON_ICONIFY
- || type == LAB_SSD_BUTTON_WINDOW_MENU;
-}
-
enum ssd_part_type
ssd_get_part_type(const struct ssd *ssd, struct wlr_scene_node *node)
{
ssd->state.geometry = current;
}
bool maximized = ssd->view->maximized == VIEW_AXIS_BOTH;
- if (ssd->state.was_maximized != maximized) {
+ 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 state.was_maximized but to future
- * proof this a bit we also set it here again.
+ * 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) {
if (!ssd) {
return;
}
+ ssd_titlebar_update(ssd);
ssd_border_update(ssd);
wlr_scene_node_set_enabled(&ssd->extents.tree->node, !enable);
ssd_shadow_update(ssd);
}
}
+static bool
+match_button_by_name(struct title_button *b, const char *icon_name)
+{
+ assert(icon_name);
+ return (b->type == LAB_SSD_BUTTON_WINDOW_MENU && !strcmp(icon_name, "menu"))
+ || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max"))
+ || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max_toggled"))
+ || (b->type == LAB_SSD_BUTTON_ICONIFY && !strcmp(icon_name, "iconify"))
+ || (b->type == LAB_SSD_BUTTON_CLOSE && !strcmp(icon_name, "close"))
+ || (b->type == LAB_SSD_BUTTON_SHADE && !strcmp(icon_name, "shade"))
+ || (b->type == LAB_SSD_BUTTON_SHADE && !strcmp(icon_name, "shade_toggled"));
+}
+
static enum corner
corner_from_icon_name(const char *icon_name)
{
struct title_button *b;
wl_list_for_each(b, &rc.title_buttons_left, link) {
- if ((b->type == LAB_SSD_BUTTON_WINDOW_MENU && !strcmp(icon_name, "menu"))
- || (b->type == LAB_SSD_BUTTON_ICONIFY && !strcmp(icon_name, "iconify"))
- || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max"))
- || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max_toggled"))
- || (b->type == LAB_SSD_BUTTON_CLOSE && !strcmp(icon_name, "close"))) {
+ if (match_button_by_name(b, icon_name)) {
return LAB_CORNER_TOP_LEFT;
}
break;
}
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
- if ((b->type == LAB_SSD_BUTTON_WINDOW_MENU && !strcmp(icon_name, "menu"))
- || (b->type == LAB_SSD_BUTTON_ICONIFY && !strcmp(icon_name, "iconify"))
- || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max"))
- || (b->type == LAB_SSD_BUTTON_MAXIMIZE && !strcmp(icon_name, "max_toggled"))
- || (b->type == LAB_SSD_BUTTON_CLOSE && !strcmp(icon_name, "close"))) {
+ if (match_button_by_name(b, icon_name)) {
return LAB_CORNER_TOP_RIGHT;
}
break;
.active.rgba = theme->window_active_button_max_unpressed_image_color,
.inactive.buffer = &theme->button_restore_inactive_unpressed,
.inactive.rgba = theme->window_inactive_button_max_unpressed_image_color,
+ }, {
+ .name = "shade",
+ .fallback_button = (const char[]){ 0x3f, 0x3f, 0x00, 0x0c, 0x1e, 0x3f },
+ .active.buffer = &theme->button_shade_active_unpressed,
+ .active.rgba = theme->window_active_button_shade_unpressed_image_color,
+ .inactive.buffer = &theme->button_shade_inactive_unpressed,
+ .inactive.rgba = theme->window_inactive_button_shade_unpressed_image_color,
+ }, {
+ .name = "shade_toggled",
+ .fallback_button = (const char[]){ 0x3f, 0x3f, 0x00, 0x3f, 0x1e, 0x0c },
+ .active.buffer = &theme->button_unshade_active_unpressed,
+ .active.rgba = theme->window_active_button_shade_unpressed_image_color,
+ .inactive.buffer = &theme->button_unshade_inactive_unpressed,
+ .inactive.rgba = theme->window_inactive_button_shade_unpressed_image_color,
}, {
.name = "close",
.fallback_button = (const char[]){ 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 },
.active.rgba = theme->window_active_button_max_unpressed_image_color,
.inactive.buffer = &theme->button_restore_inactive_hover,
.inactive.rgba = theme->window_inactive_button_max_unpressed_image_color,
+ }, {
+ .name = "shade_hover",
+ /* no fallback (non-hover variant is used instead) */
+ .active.buffer = &theme->button_shade_active_hover,
+ .active.rgba = theme->window_active_button_shade_unpressed_image_color,
+ .inactive.buffer = &theme->button_shade_inactive_hover,
+ .inactive.rgba = theme->window_inactive_button_shade_unpressed_image_color,
+ }, {
+ .name = "shade_toggled_hover",
+ .alt_name = "shade_hover_toggled",
+ /* no fallback (non-hover variant is used instead) */
+ .active.buffer = &theme->button_unshade_active_hover,
+ .active.rgba = theme->window_active_button_shade_unpressed_image_color,
+ .inactive.buffer = &theme->button_unshade_inactive_hover,
+ .inactive.rgba = theme->window_inactive_button_shade_unpressed_image_color,
}, {
.name = "close_hover",
/* no fallback (non-hover variant is used instead) */
theme->window_active_button_iconify_unpressed_image_color);
parse_hexstr("#000000",
theme->window_active_button_max_unpressed_image_color);
+ parse_hexstr("#000000",
+ theme->window_active_button_shade_unpressed_image_color);
parse_hexstr("#000000",
theme->window_active_button_close_unpressed_image_color);
parse_hexstr("#000000",
theme->window_inactive_button_iconify_unpressed_image_color);
parse_hexstr("#000000",
theme->window_inactive_button_max_unpressed_image_color);
+ parse_hexstr("#000000",
+ theme->window_inactive_button_shade_unpressed_image_color);
parse_hexstr("#000000",
theme->window_inactive_button_close_unpressed_image_color);
theme->window_active_button_iconify_unpressed_image_color);
parse_hexstr(value,
theme->window_active_button_max_unpressed_image_color);
+ parse_hexstr(value,
+ theme->window_active_button_shade_unpressed_image_color);
parse_hexstr(value,
theme->window_active_button_close_unpressed_image_color);
}
theme->window_inactive_button_iconify_unpressed_image_color);
parse_hexstr(value,
theme->window_inactive_button_max_unpressed_image_color);
+ parse_hexstr(value,
+ theme->window_inactive_button_shade_unpressed_image_color);
parse_hexstr(value,
theme->window_inactive_button_close_unpressed_image_color);
}
parse_hexstr(value,
theme->window_active_button_max_unpressed_image_color);
}
+ if (match_glob(key, "window.active.button.shade.unpressed.image.color")) {
+ parse_hexstr(value,
+ theme->window_active_button_shade_unpressed_image_color);
+ }
if (match_glob(key, "window.active.button.close.unpressed.image.color")) {
parse_hexstr(value,
theme->window_active_button_close_unpressed_image_color);
parse_hexstr(value,
theme->window_inactive_button_max_unpressed_image_color);
}
+ if (match_glob(key, "window.inactive.button.shade.unpressed.image.color")) {
+ parse_hexstr(value,
+ theme->window_inactive_button_shade_unpressed_image_color);
+ }
if (match_glob(key, "window.inactive.button.close.unpressed.image.color")) {
parse_hexstr(value,
theme->window_inactive_button_close_unpressed_image_color);
zdrop(&theme->button_close_active_unpressed);
zdrop(&theme->button_maximize_active_unpressed);
zdrop(&theme->button_restore_active_unpressed);
+ zdrop(&theme->button_shade_active_unpressed);
+ zdrop(&theme->button_unshade_active_unpressed);
zdrop(&theme->button_iconify_active_unpressed);
zdrop(&theme->button_menu_active_unpressed);
zdrop(&theme->button_close_inactive_unpressed);
zdrop(&theme->button_maximize_inactive_unpressed);
zdrop(&theme->button_restore_inactive_unpressed);
+ zdrop(&theme->button_shade_inactive_unpressed);
+ zdrop(&theme->button_unshade_inactive_unpressed);
zdrop(&theme->button_iconify_inactive_unpressed);
zdrop(&theme->button_menu_inactive_unpressed);
zdrop(&theme->button_close_active_hover);
zdrop(&theme->button_maximize_active_hover);
zdrop(&theme->button_restore_active_hover);
+ zdrop(&theme->button_shade_active_hover);
+ zdrop(&theme->button_unshade_active_hover);
zdrop(&theme->button_iconify_active_hover);
zdrop(&theme->button_menu_active_hover);
zdrop(&theme->button_close_inactive_hover);
zdrop(&theme->button_maximize_inactive_hover);
zdrop(&theme->button_restore_inactive_hover);
+ zdrop(&theme->button_shade_inactive_hover);
+ zdrop(&theme->button_unshade_inactive_hover);
zdrop(&theme->button_iconify_inactive_hover);
zdrop(&theme->button_menu_inactive_hover);