| 
									
										
										
										
											2021-11-13 21:56:53 +00:00
										 |  |  | /* SPDX-License-Identifier: GPL-2.0-only */ | 
					
						
							| 
									
										
										
										
											2023-05-13 16:10:33 +03:00
										 |  |  | #ifndef LABWC_SSD_H
 | 
					
						
							|  |  |  | #define LABWC_SSD_H
 | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-26 16:06:22 -05:00
										 |  |  | #include <wayland-server-core.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-05 21:48:47 +01:00
										 |  |  | #include "common/border.h"
 | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-01 14:51:47 +09:00
										 |  |  | struct wlr_cursor; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-22 19:27:53 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Shadows should start at a point inset from the actual window border, see | 
					
						
							|  |  |  |  * discussion on https://github.com/labwc/labwc/pull/1648.  This constant
 | 
					
						
							|  |  |  |  * specifies inset as a multiple of visible shadow size. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define SSD_SHADOW_INSET 0.3
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-26 20:37:36 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-12-01 22:17:04 +00:00
										 |  |  |  * Sequence these according to the order they should be processed for | 
					
						
							| 
									
										
										
										
											2021-07-26 20:37:36 +01:00
										 |  |  |  * press and hover events. Bear in mind that some of their respective | 
					
						
							|  |  |  |  * interactive areas overlap, so for example buttons need to come before title. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-03-21 21:46:16 +00:00
										 |  |  | enum ssd_part_type { | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 	LAB_SSD_NONE = 0, | 
					
						
							| 
									
										
										
										
											2024-10-04 15:27:25 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	LAB_SSD_BUTTON_CLOSE = 1, | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 	LAB_SSD_BUTTON_MAXIMIZE, | 
					
						
							|  |  |  | 	LAB_SSD_BUTTON_ICONIFY, | 
					
						
							| 
									
										
										
										
											2024-09-06 17:00:40 +09:00
										 |  |  | 	LAB_SSD_BUTTON_WINDOW_ICON, | 
					
						
							| 
									
										
										
										
											2022-01-26 02:54:03 +01:00
										 |  |  | 	LAB_SSD_BUTTON_WINDOW_MENU, | 
					
						
							| 
									
										
										
										
											2024-08-22 16:27:24 -04:00
										 |  |  | 	LAB_SSD_BUTTON_SHADE, | 
					
						
							| 
									
										
										
										
											2024-08-23 12:45:14 -04:00
										 |  |  | 	LAB_SSD_BUTTON_OMNIPRESENT, | 
					
						
							| 
									
										
										
										
											2024-10-04 15:27:25 +09:00
										 |  |  | 	/* only for internal use */ | 
					
						
							|  |  |  | 	LAB_SSD_BUTTON_FIRST = LAB_SSD_BUTTON_CLOSE, | 
					
						
							|  |  |  | 	LAB_SSD_BUTTON_LAST = LAB_SSD_BUTTON_OMNIPRESENT, | 
					
						
							|  |  |  | 	LAB_SSD_BUTTON, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-07 09:35:53 +01:00
										 |  |  | 	LAB_SSD_PART_TITLEBAR, | 
					
						
							| 
									
										
										
										
											2024-08-23 13:05:13 +09:00
										 |  |  | 	LAB_SSD_PART_TITLEBAR_CORNER_RIGHT, | 
					
						
							|  |  |  | 	LAB_SSD_PART_TITLEBAR_CORNER_LEFT, | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 	LAB_SSD_PART_TITLE, | 
					
						
							| 
									
										
										
										
											2024-08-23 13:05:13 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* shared by shadows, borders and extents */ | 
					
						
							| 
									
										
										
										
											2021-07-26 20:37:36 +01:00
										 |  |  | 	LAB_SSD_PART_CORNER_TOP_LEFT, | 
					
						
							|  |  |  | 	LAB_SSD_PART_CORNER_TOP_RIGHT, | 
					
						
							|  |  |  | 	LAB_SSD_PART_CORNER_BOTTOM_RIGHT, | 
					
						
							|  |  |  | 	LAB_SSD_PART_CORNER_BOTTOM_LEFT, | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 	LAB_SSD_PART_TOP, | 
					
						
							|  |  |  | 	LAB_SSD_PART_RIGHT, | 
					
						
							|  |  |  | 	LAB_SSD_PART_BOTTOM, | 
					
						
							|  |  |  | 	LAB_SSD_PART_LEFT, | 
					
						
							| 
									
										
										
										
											2024-08-23 13:05:13 +09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-01 22:17:04 +00:00
										 |  |  | 	LAB_SSD_CLIENT, | 
					
						
							|  |  |  | 	LAB_SSD_FRAME, | 
					
						
							|  |  |  | 	LAB_SSD_ROOT, | 
					
						
							| 
									
										
										
										
											2022-02-18 00:07:37 +01:00
										 |  |  | 	LAB_SSD_MENU, | 
					
						
							|  |  |  | 	LAB_SSD_OSD, | 
					
						
							|  |  |  | 	LAB_SSD_LAYER_SURFACE, | 
					
						
							| 
									
										
										
										
											2023-08-14 23:38:55 +01:00
										 |  |  | 	LAB_SSD_LAYER_SUBSURFACE, | 
					
						
							| 
									
										
										
										
											2022-02-22 07:57:17 +01:00
										 |  |  | 	LAB_SSD_UNMANAGED, | 
					
						
							| 
									
										
										
										
											2024-05-01 07:28:17 +01:00
										 |  |  | 	LAB_SSD_ALL, | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 	LAB_SSD_END_MARKER | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-18 09:46:36 +02:00
										 |  |  | enum ssd_mode { | 
					
						
							| 
									
										
										
										
											2024-10-18 02:07:52 +03:00
										 |  |  | 	LAB_SSD_MODE_INVALID, | 
					
						
							| 
									
										
										
										
											2024-04-18 09:46:36 +02:00
										 |  |  | 	LAB_SSD_MODE_NONE, | 
					
						
							|  |  |  | 	LAB_SSD_MODE_BORDER, | 
					
						
							| 
									
										
										
										
											2024-10-18 02:07:52 +03:00
										 |  |  | 	LAB_SSD_MODE_FULL, | 
					
						
							| 
									
										
										
										
											2024-04-18 09:46:36 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | /* Forward declare arguments */ | 
					
						
							| 
									
										
										
										
											2022-11-26 16:53:35 -05:00
										 |  |  | struct ssd; | 
					
						
							|  |  |  | struct ssd_button; | 
					
						
							|  |  |  | struct ssd_hover_state; | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | struct view; | 
					
						
							| 
									
										
										
										
											2022-11-26 16:06:22 -05:00
										 |  |  | struct wlr_scene; | 
					
						
							|  |  |  | struct wlr_scene_node; | 
					
						
							| 
									
										
										
										
											2022-01-29 17:52:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-26 16:46:28 -05:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Public SSD API | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * For convenience in dealing with non-SSD views, this API allows NULL | 
					
						
							|  |  |  |  * ssd/button/node arguments and attempts to do something sensible in | 
					
						
							|  |  |  |  * that case (e.g. no-op/return default values). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * NULL scene/view arguments are not allowed. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | struct ssd *ssd_create(struct view *view, bool active); | 
					
						
							|  |  |  | struct border ssd_get_margin(const struct ssd *ssd); | 
					
						
							| 
									
										
										
										
											2024-09-09 17:43:38 +02:00
										 |  |  | int ssd_get_corner_width(void); | 
					
						
							| 
									
										
										
										
											2023-08-25 13:22:23 +02:00
										 |  |  | void ssd_update_margin(struct ssd *ssd); | 
					
						
							| 
									
										
										
										
											2022-11-26 16:46:28 -05:00
										 |  |  | void ssd_set_active(struct ssd *ssd, bool active); | 
					
						
							|  |  |  | void ssd_update_title(struct ssd *ssd); | 
					
						
							|  |  |  | void ssd_update_geometry(struct ssd *ssd); | 
					
						
							|  |  |  | void ssd_destroy(struct ssd *ssd); | 
					
						
							| 
									
										
										
										
											2024-04-18 09:46:36 +02:00
										 |  |  | void ssd_set_titlebar(struct ssd *ssd, bool enabled); | 
					
						
							| 
									
										
										
										
											2022-11-26 16:46:28 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-05 10:35:56 +01:00
										 |  |  | void ssd_enable_keybind_inhibit_indicator(struct ssd *ssd, bool enable); | 
					
						
							| 
									
										
										
										
											2023-08-08 03:39:35 +02:00
										 |  |  | void ssd_enable_shade(struct ssd *ssd, bool enable); | 
					
						
							| 
									
										
										
										
											2023-03-05 10:35:56 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-26 16:46:28 -05:00
										 |  |  | struct ssd_hover_state *ssd_hover_state_new(void); | 
					
						
							| 
									
										
										
										
											2022-06-08 19:51:02 +02:00
										 |  |  | void ssd_update_button_hover(struct wlr_scene_node *node, | 
					
						
							|  |  |  | 	struct ssd_hover_state *hover_state); | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-26 16:53:35 -05:00
										 |  |  | enum ssd_part_type ssd_button_get_type(const struct ssd_button *button); | 
					
						
							|  |  |  | struct view *ssd_button_get_view(const struct ssd_button *button); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | /* Public SSD helpers */ | 
					
						
							| 
									
										
										
										
											2022-11-26 16:06:22 -05:00
										 |  |  | enum ssd_part_type ssd_get_part_type(const struct ssd *ssd, | 
					
						
							| 
									
										
										
										
											2025-02-01 14:51:47 +09:00
										 |  |  | 	struct wlr_scene_node *node, struct wlr_cursor *cursor); | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | uint32_t ssd_resize_edges(enum ssd_part_type type); | 
					
						
							|  |  |  | bool ssd_part_contains(enum ssd_part_type whole, enum ssd_part_type candidate); | 
					
						
							| 
									
										
										
										
											2024-04-20 06:29:51 +02:00
										 |  |  | enum ssd_mode ssd_mode_parse(const char *mode); | 
					
						
							| 
									
										
										
										
											2022-02-21 03:18:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* TODO: clean up / update */ | 
					
						
							|  |  |  | struct border ssd_thickness(struct view *view); | 
					
						
							|  |  |  | struct wlr_box ssd_max_extents(struct view *view); | 
					
						
							| 
									
										
										
										
											2021-03-21 20:54:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-26 16:13:09 -05:00
										 |  |  | /* SSD debug helpers */ | 
					
						
							|  |  |  | bool ssd_debug_is_root_node(const struct ssd *ssd, struct wlr_scene_node *node); | 
					
						
							|  |  |  | const char *ssd_debug_get_node_name(const struct ssd *ssd, | 
					
						
							|  |  |  | 	struct wlr_scene_node *node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-13 16:10:33 +03:00
										 |  |  | #endif /* LABWC_SSD_H */
 |