2022-11-26 16:53:35 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_SSD_INTERNAL_H
|
|
|
|
|
#define LABWC_SSD_INTERNAL_H
|
2022-11-26 16:53:35 -05:00
|
|
|
|
2023-02-08 23:19:14 -05:00
|
|
|
#include <wlr/util/box.h>
|
2025-09-03 05:08:52 -04:00
|
|
|
#include "common/border.h"
|
2025-08-17 16:01:50 -04:00
|
|
|
#include "theme.h"
|
2023-12-06 20:33:26 +00:00
|
|
|
#include "view.h"
|
2022-11-26 16:53:35 -05:00
|
|
|
|
|
|
|
|
struct ssd_state_title_width {
|
|
|
|
|
int width;
|
|
|
|
|
bool truncated;
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
/*
|
|
|
|
|
* The scene-graph of SSD looks like below. The parentheses indicate the type of
|
|
|
|
|
* ssd_part attached to the node.
|
|
|
|
|
*
|
|
|
|
|
* ssd->tree (LAB_SSD_NONE)
|
|
|
|
|
* +--titlebar (LAB_SSD_PART_TITLEBAR)
|
|
|
|
|
* | +--inactive
|
|
|
|
|
* | | +--background bar
|
|
|
|
|
* | | +--left corner
|
|
|
|
|
* | | +--right corner
|
|
|
|
|
* | | +--title (LAB_SSD_PART_TITLE)
|
|
|
|
|
* | | +--iconify button (LAB_SSD_BUTTON_ICONIFY)
|
|
|
|
|
* | | | +--normal close icon image
|
|
|
|
|
* | | | +--hovered close icon image
|
|
|
|
|
* | | | +--...
|
|
|
|
|
* | | +--window icon (LAB_SSD_BUTTON_WINDOW_ICON)
|
|
|
|
|
* | | | +--window icon image
|
|
|
|
|
* | | +--...
|
|
|
|
|
* | +--active
|
|
|
|
|
* | +--...
|
|
|
|
|
* +--border
|
|
|
|
|
* | +--inactive
|
|
|
|
|
* | | +--top
|
|
|
|
|
* | | +--...
|
|
|
|
|
* | +--active
|
|
|
|
|
* | +--top
|
|
|
|
|
* | +--...
|
|
|
|
|
* +--shadow
|
|
|
|
|
* | +--inactive
|
|
|
|
|
* | | +--top
|
|
|
|
|
* | | +--...
|
|
|
|
|
* | +--active
|
|
|
|
|
* | +--top
|
|
|
|
|
* | +--...
|
|
|
|
|
* +--extents
|
|
|
|
|
* +--top
|
|
|
|
|
* +--...
|
|
|
|
|
*/
|
2022-11-26 16:53:35 -05:00
|
|
|
struct ssd {
|
|
|
|
|
struct view *view;
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Cache for current values.
|
|
|
|
|
* Used to detect actual changes so we
|
|
|
|
|
* don't update things we don't have to.
|
|
|
|
|
*/
|
|
|
|
|
struct {
|
2024-08-23 12:45:14 -04:00
|
|
|
/* Button icons need to be swapped on shade or omnipresent toggles */
|
|
|
|
|
bool was_shaded;
|
|
|
|
|
bool was_omnipresent;
|
|
|
|
|
|
|
|
|
|
/*
|
2024-08-25 16:33:41 +09:00
|
|
|
* Corners need to be (un)rounded and borders need be shown/hidden
|
|
|
|
|
* when toggling maximization, and the button needs to be swapped on
|
2024-08-23 12:45:14 -04:00
|
|
|
* maximization toggles.
|
|
|
|
|
*/
|
|
|
|
|
bool was_maximized;
|
2024-08-25 16:33:41 +09:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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;
|
2024-08-23 12:45:14 -04:00
|
|
|
|
2023-02-08 23:19:14 -05:00
|
|
|
struct wlr_box geometry;
|
2022-11-26 16:53:35 -05:00
|
|
|
struct ssd_state_title {
|
|
|
|
|
char *text;
|
2025-08-13 21:00:11 +09:00
|
|
|
/* indexed by enum ssd_active_state */
|
|
|
|
|
struct ssd_state_title_width dstates[2];
|
2022-11-26 16:53:35 -05:00
|
|
|
} title;
|
|
|
|
|
} state;
|
|
|
|
|
|
2023-02-08 23:19:14 -05:00
|
|
|
/* An invisible area around the view which allows resizing */
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_extents_scene {
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
struct wlr_scene_rect *top, *bottom, *left, *right;
|
|
|
|
|
} extents;
|
2022-11-26 16:53:35 -05:00
|
|
|
|
|
|
|
|
/* The top of the view, containing buttons, title, .. */
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_titlebar_scene {
|
2023-04-14 09:01:13 +02:00
|
|
|
int height;
|
|
|
|
|
struct wlr_scene_tree *tree;
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_titlebar_subtree {
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
struct wlr_scene_buffer *corner_left;
|
|
|
|
|
struct wlr_scene_buffer *corner_right;
|
|
|
|
|
struct wlr_scene_buffer *bar;
|
|
|
|
|
struct scaled_font_buffer *title;
|
|
|
|
|
/* List of ssd_parts that represent buttons */
|
|
|
|
|
struct wl_list buttons_left;
|
|
|
|
|
struct wl_list buttons_right;
|
|
|
|
|
} subtrees[2]; /* indexed by enum ssd_active_state */
|
2022-11-26 16:53:35 -05:00
|
|
|
} titlebar;
|
|
|
|
|
|
|
|
|
|
/* Borders allow resizing as well */
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_border_scene {
|
2023-08-23 01:04:40 +02:00
|
|
|
struct wlr_scene_tree *tree;
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_border_subtree {
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
struct wlr_scene_rect *top, *bottom, *left, *right;
|
|
|
|
|
} subtrees[2]; /* indexed by enum ssd_active_state */
|
2022-11-26 16:53:35 -05:00
|
|
|
} border;
|
|
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_shadow_scene {
|
2024-04-22 19:27:53 +01:00
|
|
|
struct wlr_scene_tree *tree;
|
2025-08-13 21:00:11 +09:00
|
|
|
struct ssd_shadow_subtree {
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
struct wlr_scene_buffer *top, *bottom, *left, *right,
|
|
|
|
|
*top_left, *top_right, *bottom_left, *bottom_right;
|
|
|
|
|
} subtrees[2]; /* indexed by enum ssd_active_state */
|
2024-04-22 19:27:53 +01:00
|
|
|
} shadow;
|
|
|
|
|
|
2022-11-26 16:53:35 -05:00
|
|
|
/*
|
|
|
|
|
* Space between the extremities of the view's wlr_surface
|
|
|
|
|
* and the max extents of the server-side decorations.
|
|
|
|
|
* For xdg-shell views with CSD, this margin is zero.
|
|
|
|
|
*/
|
|
|
|
|
struct border margin;
|
|
|
|
|
};
|
|
|
|
|
|
2025-09-03 05:32:44 -04:00
|
|
|
struct ssd_button {
|
2022-11-26 16:53:35 -05:00
|
|
|
struct wlr_scene_node *node;
|
2025-09-03 05:32:44 -04:00
|
|
|
enum lab_node_type type;
|
2022-11-26 16:53:35 -05:00
|
|
|
|
2025-08-13 21:00:11 +09:00
|
|
|
/*
|
|
|
|
|
* Bitmap of lab_button_state that represents a combination of
|
|
|
|
|
* hover/toggled/rounded states.
|
|
|
|
|
*/
|
|
|
|
|
uint8_t state_set;
|
|
|
|
|
/*
|
|
|
|
|
* Image buffers for each combination of hover/toggled/rounded states.
|
|
|
|
|
* img_buffers[state_set] is displayed. Some of these can be NULL
|
|
|
|
|
* (e.g. img_buffers[LAB_BS_ROUNDED] is set only for corner buttons).
|
|
|
|
|
*
|
|
|
|
|
* When the type of ssd_part pointing to ssd_button is
|
|
|
|
|
* LAB_SSD_BUTTON_WINDOW_ICON, these are all NULL and window_icon is
|
|
|
|
|
* used instead.
|
|
|
|
|
*/
|
|
|
|
|
struct scaled_img_buffer *img_buffers[LAB_BS_ALL + 1];
|
|
|
|
|
|
|
|
|
|
struct scaled_icon_buffer *window_icon;
|
|
|
|
|
|
|
|
|
|
struct wl_list link; /* ssd_titlebar_subtree.buttons_{left,right} */
|
2022-11-26 16:53:35 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct wlr_buffer;
|
|
|
|
|
struct wlr_scene_tree;
|
|
|
|
|
|
|
|
|
|
/* SSD internal helpers to create various SSD elements */
|
2025-09-03 05:32:44 -04:00
|
|
|
struct ssd_button *attach_ssd_button(struct wl_list *button_parts,
|
2025-09-03 05:08:52 -04:00
|
|
|
enum lab_node_type type, struct wlr_scene_tree *parent,
|
2025-08-13 21:00:11 +09:00
|
|
|
struct lab_img *imgs[LAB_BS_ALL + 1], int x, int y,
|
2024-10-04 15:27:25 +09:00
|
|
|
struct view *view);
|
2022-11-26 16:53:35 -05:00
|
|
|
|
|
|
|
|
/* SSD internal */
|
|
|
|
|
void ssd_titlebar_create(struct ssd *ssd);
|
|
|
|
|
void ssd_titlebar_update(struct ssd *ssd);
|
|
|
|
|
void ssd_titlebar_destroy(struct ssd *ssd);
|
2024-08-25 16:33:41 +09:00
|
|
|
bool ssd_should_be_squared(struct ssd *ssd);
|
2022-11-26 16:53:35 -05:00
|
|
|
|
|
|
|
|
void ssd_border_create(struct ssd *ssd);
|
|
|
|
|
void ssd_border_update(struct ssd *ssd);
|
|
|
|
|
void ssd_border_destroy(struct ssd *ssd);
|
|
|
|
|
|
|
|
|
|
void ssd_extents_create(struct ssd *ssd);
|
|
|
|
|
void ssd_extents_update(struct ssd *ssd);
|
|
|
|
|
void ssd_extents_destroy(struct ssd *ssd);
|
|
|
|
|
|
2024-04-22 19:27:53 +01:00
|
|
|
void ssd_shadow_create(struct ssd *ssd);
|
|
|
|
|
void ssd_shadow_update(struct ssd *ssd);
|
|
|
|
|
void ssd_shadow_destroy(struct ssd *ssd);
|
|
|
|
|
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_SSD_INTERNAL_H */
|