22static std::array<std::string_view, 2>
string_partition(std::string_view s,
const char delimiter)
24 std::array<std::string_view, 2> result;
25 size_t pos = s.find(delimiter);
26 if (pos == std::string_view::npos) {
32 result[0] = s.substr(0, pos);
33 result[1] = s.substr(pos + 1);
39 uint32_t *button_mask_p,
41 const int output_capacity)
43 const char delimiter =
',';
45 while (!buttons.empty() && (i < output_capacity)) {
46 const size_t p = buttons.find(delimiter);
47 const std::string_view button_id = buttons.substr(0, p);
50 if (button_id ==
"close") {
53 else if (button_id ==
"maximize") {
56 else if (button_id ==
"minimize") {
59 else if (button_id ==
"icon") {
65 const uint32_t value_mask = (1 << uint32_t(value));
66 if ((*button_mask_p & value_mask) == 0) {
67 *button_mask_p |= value_mask;
72 if (p == std::string_view::npos) {
75 buttons.remove_prefix(p + 1);
89 std::array<std::string_view, 2> buttons_pair =
string_partition(buttons,
':');
91 uint32_t button_mask = 0;
92 for (
int side = 0; side < 2; side++) {
96 if (buttons_capacity > 0) {
102 buttons_pair[side], &button_mask, &layout.
buttons[i], buttons_capacity);
105 return button_mask != 0;
@ GHOST_kCSDTypeButtonClose
@ GHOST_kCSDTypeButtonMinimize
@ GHOST_kCSDTypeButtonMaximize
@ GHOST_kCSDTypeButtonMenu
bool GHOST_WindowCSD_LayoutFromString(GHOST_CSD_Layout &layout, const std::string_view buttons)
bool GHOST_WindowCSD_Check(GWL_CurrentDesktopType desktop_type)
static int string_parse_buttons(std::string_view buttons, uint32_t *button_mask_p, GHOST_TCSD_Type *output, const int output_capacity)
static std::array< std::string_view, 2 > string_partition(std::string_view s, const char delimiter)
void GHOST_WindowCSD_LayoutDefault(GHOST_CSD_Layout &layout)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
GHOST_TCSD_Type buttons[5]