style: 禁掉 clang-format 的 AlignConsecutiveAssignments 规则并重新格式化整个项目
This commit is contained in:
@@ -6,12 +6,6 @@ IndentWidth: 2
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignCompound: true
|
||||
PadOperators: true
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ typedef enum zdwm_button_t {
|
||||
ZDWM_BUTTON_MIDDLE,
|
||||
} zdwm_button_t;
|
||||
|
||||
/* clang-format off */
|
||||
typedef enum zdwm_modifier_bit_t {
|
||||
ZDWM_MOD_NONE = 0u,
|
||||
ZDWM_MOD_SHIFT = 1u << 0,
|
||||
@@ -35,6 +36,8 @@ typedef enum zdwm_modifier_bit_t {
|
||||
ZDWM_MOD_4 = 1u << 5,
|
||||
ZDWM_MOD_5 = 1u << 6,
|
||||
} zdwm_modifier_bit_t;
|
||||
/* clang-format on */
|
||||
|
||||
typedef uint32_t zdwm_modifier_mask_t;
|
||||
|
||||
typedef struct zdwm_rect_t {
|
||||
|
||||
@@ -734,8 +734,9 @@ backend_scan_result_t *backend_scan_windows(backend_t *backend) {
|
||||
auto transient_for = window_get_transient_for(backend, window);
|
||||
auto r = transient_for == XCB_WINDOW_NONE ? result : sub_result;
|
||||
auto slot = array_push(r->windows, r->count, r->capacity);
|
||||
if (!populate_window_event(backend, list[i], slot) ||
|
||||
slot->override_redirect) {
|
||||
if (
|
||||
!populate_window_event(backend, list[i], slot) || slot->override_redirect
|
||||
) {
|
||||
window_layer_props_cleanup(&slot->props);
|
||||
window_metadata_cleanup(&slot->metadata);
|
||||
r->count--;
|
||||
|
||||
@@ -58,8 +58,10 @@ static bool maximized_from_states(
|
||||
uint32_t state_count
|
||||
) {
|
||||
for (uint32_t i = 0; i < state_count; i++) {
|
||||
if (state_atoms[i] == atoms->_NET_WM_STATE_MAXIMIZED_VERT ||
|
||||
state_atoms[i] == atoms->_NET_WM_STATE_MAXIMIZED_HORZ)
|
||||
if (
|
||||
state_atoms[i] == atoms->_NET_WM_STATE_MAXIMIZED_VERT ||
|
||||
state_atoms[i] == atoms->_NET_WM_STATE_MAXIMIZED_HORZ
|
||||
)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -341,8 +343,10 @@ static bool handle_property_notify(
|
||||
const xcb_property_notify_event_t *xcb_event
|
||||
) {
|
||||
auto window_id = xcb_event->window;
|
||||
if (xcb_event->atom == backend->atoms.WM_NAME ||
|
||||
xcb_event->atom == backend->atoms._NET_WM_NAME) {
|
||||
if (
|
||||
xcb_event->atom == backend->atoms.WM_NAME ||
|
||||
xcb_event->atom == backend->atoms._NET_WM_NAME
|
||||
) {
|
||||
event->type = ZDWM_EVENT_WINDOW_METADATA_CHANGED;
|
||||
|
||||
auto data = &event->as.window_metadata_change;
|
||||
|
||||
@@ -38,10 +38,12 @@ static char *window_get_text_property(
|
||||
char *value = (char *)xcb_get_property_value(reply);
|
||||
|
||||
char *text = nullptr;
|
||||
if (length && reply->format == 8 &&
|
||||
if (
|
||||
length && reply->format == 8 &&
|
||||
(reply->type == XCB_ATOM_STRING ||
|
||||
reply->type == backend->atoms.UTF8_STRING ||
|
||||
reply->type == backend->atoms.COMPOUND_TEXT)) {
|
||||
reply->type == backend->atoms.COMPOUND_TEXT)
|
||||
) {
|
||||
text = p_strndup(value, (size_t)length);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,13 +84,17 @@ bar_cell_set_icon(zdwm_bar_item_t *item, size_t index, zdwm_icon_t icon) {
|
||||
if (icon_ptr->type == icon.type) {
|
||||
switch (icon.type) {
|
||||
case ZDWM_ICON_TEXT:
|
||||
if (icon_ptr->as.text == icon.as.text ||
|
||||
strcmp(icon_ptr->as.text, icon.as.text) == 0) {
|
||||
if (
|
||||
icon_ptr->as.text == icon.as.text ||
|
||||
strcmp(icon_ptr->as.text, icon.as.text) == 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
case ZDWM_ICON_IMAGE:
|
||||
if (icon_ptr->as.image_path == icon.as.image_path ||
|
||||
strcmp(icon_ptr->as.image_path, icon.as.image_path) == 0) {
|
||||
if (
|
||||
icon_ptr->as.image_path == icon.as.image_path ||
|
||||
strcmp(icon_ptr->as.image_path, icon.as.image_path) == 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +119,7 @@ bar_cell_set_indicator(zdwm_bar_item_t *item, size_t index, bool show) {
|
||||
item->dirty = true;
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
zdwm_bar_cell_api_t bar_cell_api = {
|
||||
.get_cell_count = bar_cell_get_count,
|
||||
.set_cell_count = bar_cell_set_count,
|
||||
@@ -124,6 +129,7 @@ zdwm_bar_cell_api_t bar_cell_api = {
|
||||
.cell_set_icon = bar_cell_set_icon,
|
||||
.cell_set_indicator = bar_cell_set_indicator,
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
void bar_cell_set_region(
|
||||
zdwm_bar_item_t *item,
|
||||
|
||||
@@ -98,11 +98,11 @@ array_erase_impl(void *items, size_t item_size, size_t *count, size_t index) {
|
||||
#define array_reserve(items, capacity, need) \
|
||||
array_reserve_impl((void **)&(items), sizeof(*(items)), &(capacity), (need))
|
||||
|
||||
/* clang-format off */
|
||||
/** @brief 为具体类型数组追加一个槽位。 */
|
||||
#define array_push(items, count, capacity)\
|
||||
( \
|
||||
typeof(items) \
|
||||
)array_push_impl((void **)&(items), sizeof(*(items)), &(count), &(capacity))
|
||||
(typeof(items))array_push_impl((void **)&(items), sizeof(*(items)), &(count), &(capacity))
|
||||
/* clang-format on */
|
||||
|
||||
/** @brief 删除具体类型数组中指定下标的元素。 */
|
||||
#define array_erase(items, count, index) \
|
||||
|
||||
@@ -56,7 +56,7 @@ bool hex_color_to_rgba(const char *hex, uint32_t *rgba) {
|
||||
|
||||
size_t len = strlen(hex);
|
||||
char extended[9] = {0};
|
||||
uint32_t color = 0x00000000;
|
||||
uint32_t color = 0x00'00'00'00;
|
||||
|
||||
if (len == 3 || len == 4) {
|
||||
extended[0] = extended[1] = hex[0];
|
||||
@@ -76,7 +76,7 @@ bool hex_color_to_rgba(const char *hex, uint32_t *rgba) {
|
||||
return false;
|
||||
}
|
||||
|
||||
color = strtoul(extended, nullptr, 16) & 0xffffffff;
|
||||
color = strtoul(extended, nullptr, 16) & 0xff'ff'ff'ff;
|
||||
*rgba = color;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
#include "base/array.h"
|
||||
#include "base/memory.h"
|
||||
|
||||
void window_list_push(
|
||||
window_list_t *window_list,
|
||||
zdwm_window_id_t window_id
|
||||
) {
|
||||
void window_list_push(window_list_t *window_list, zdwm_window_id_t window_id) {
|
||||
zdwm_window_id_t *window =
|
||||
array_push(window_list->windows, window_list->count, window_list->capacity);
|
||||
*window = window_id;
|
||||
|
||||
@@ -52,10 +52,12 @@ bool config_defaults_build(
|
||||
);
|
||||
zdwm_layout_id_t floating_id =
|
||||
api->register_layout(builder, "floating", "><>", "floating", nullptr);
|
||||
if (fair_id == ZDWM_LAYOUT_ID_INVALID ||
|
||||
if (
|
||||
fair_id == ZDWM_LAYOUT_ID_INVALID ||
|
||||
maximize_id == ZDWM_LAYOUT_ID_INVALID ||
|
||||
fullscreen_id == ZDWM_LAYOUT_ID_INVALID ||
|
||||
floating_id == ZDWM_LAYOUT_ID_INVALID) {
|
||||
floating_id == ZDWM_LAYOUT_ID_INVALID
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,10 @@ struct zdwm_config_builder_t {
|
||||
void runtime_config_cleanup(runtime_init_desc_t *desc) {
|
||||
if (!desc) return;
|
||||
|
||||
if (desc->layouts.slots || desc->layouts.slot_count ||
|
||||
desc->layouts.slot_capacity) {
|
||||
if (
|
||||
desc->layouts.slots || desc->layouts.slot_count ||
|
||||
desc->layouts.slot_capacity
|
||||
) {
|
||||
layout_registry_cleanup(&desc->layouts);
|
||||
}
|
||||
binding_table_destroy(desc->binding_table);
|
||||
@@ -53,8 +55,10 @@ void runtime_config_cleanup(runtime_init_desc_t *desc) {
|
||||
static void config_builder_cleanup(zdwm_config_builder_t *builder) {
|
||||
if (!builder) return;
|
||||
|
||||
if (builder->layouts.slots || builder->layouts.slot_count ||
|
||||
builder->layouts.slot_capacity) {
|
||||
if (
|
||||
builder->layouts.slots || builder->layouts.slot_count ||
|
||||
builder->layouts.slot_capacity
|
||||
) {
|
||||
layout_registry_cleanup(&builder->layouts);
|
||||
}
|
||||
workspace_desc_list_cleanup(&builder->workspaces, &builder->workspace_count);
|
||||
@@ -336,10 +340,10 @@ static bool runtime_config_build(
|
||||
builder.output_count = output_count;
|
||||
builder.binding_table = binding_table_create();
|
||||
|
||||
/* clang-format off */
|
||||
zdwm_api_t api = {
|
||||
.abi_version = ZDWM_CONFIG_ABI_VERSION,
|
||||
.builtin_layouts =
|
||||
{
|
||||
.builtin_layouts = {
|
||||
.fair = fair,
|
||||
.fullscreen = fullscreen,
|
||||
.maximize = maximize,
|
||||
@@ -356,19 +360,18 @@ static bool runtime_config_build(
|
||||
.set_interaction_fps = runtime_config_set_interaction_fps,
|
||||
|
||||
.subscribe_current_output = runtime_config_subscribe_current_output,
|
||||
.subscribe_initial_workspace_list =
|
||||
runtime_config_subscribe_initial_workspace_list,
|
||||
.subscribe_initial_workspace_list = runtime_config_subscribe_initial_workspace_list,
|
||||
.subscribe_workspace_active = runtime_config_subscribe_workspace_active,
|
||||
.subscribe_layout = runtime_config_subscribe_layout,
|
||||
.subscribe_binding_mode = runtime_config_subscribe_binding_mode,
|
||||
.subscribe_initial_window_list =
|
||||
runtime_config_subscribe_initial_window_list,
|
||||
.subscribe_initial_window_list = runtime_config_subscribe_initial_window_list,
|
||||
.subscribe_window_added = runtime_config_subscribe_window_added,
|
||||
.subscribe_window_updated = runtime_config_subscribe_window_updated,
|
||||
.subscribe_window_removed = runtime_config_subscribe_window_removed,
|
||||
|
||||
.set_bar_config = runtime_config_set_bar_config,
|
||||
};
|
||||
/* clang-format on */
|
||||
bool ok = setup(&api, &builder, outputs, output_count) &&
|
||||
config_builder_finish(&builder, out);
|
||||
config_builder_cleanup(&builder);
|
||||
|
||||
@@ -82,8 +82,10 @@ static const mod_entry_t mod_table[] = {
|
||||
|
||||
static modifier_mask_t lookup_modifier(const char *name, size_t len) {
|
||||
for (size_t i = 0; i < countof(mod_table); ++i) {
|
||||
if (strlen(mod_table[i].name) == len &&
|
||||
strncmp(name, mod_table[i].name, len) == 0) {
|
||||
if (
|
||||
strlen(mod_table[i].name) == len &&
|
||||
strncmp(name, mod_table[i].name, len) == 0
|
||||
) {
|
||||
return mod_table[i].mask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,11 +75,13 @@ typedef struct window_metadata_change_event_t {
|
||||
window_metadata_t metadata;
|
||||
} window_metadata_change_event_t;
|
||||
|
||||
/* clang-format off */
|
||||
typedef enum window_activation_source_t {
|
||||
ZDWM_WINDOW_ACTIVATION_SOURCE_LEGACY = 0,
|
||||
ZDWM_WINDOW_ACTIVATION_SOURCE_APPLICATION = 1,
|
||||
ZDWM_WINDOW_ACTIVATION_SOURCE_PAGER = 2,
|
||||
} window_activation_source_t;
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct window_activate_request_event_t {
|
||||
window_id_t window;
|
||||
|
||||
@@ -609,6 +609,7 @@ static void route_map_request(
|
||||
if (window) layer_type = MAX(window->layer, layer_type);
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
command_t manage_window_cmd = {
|
||||
.type = ZDWM_COMMAND_MANAGE_WINDOW,
|
||||
.as.manage_window = {
|
||||
@@ -635,6 +636,7 @@ static void route_map_request(
|
||||
},
|
||||
},
|
||||
};
|
||||
/* clang-format on */
|
||||
|
||||
rule_action_t action = {.workspace = ZDWM_WORKSPACE_ID_INVALID};
|
||||
bool have_rule_match = rules_resolve(rules, &e->metadata, &action);
|
||||
@@ -1431,16 +1433,20 @@ static void send_window_to_workspace(
|
||||
|
||||
if (src_visible) {
|
||||
if (src_ws && src_ws->focused_window_id != src_old_focused) {
|
||||
if (!window_id_invalid(src_old_focused) &&
|
||||
state_window_get(state, src_old_focused)) {
|
||||
if (
|
||||
!window_id_invalid(src_old_focused) &&
|
||||
state_window_get(state, src_old_focused)
|
||||
) {
|
||||
plan_push_change_border_color_effect(
|
||||
plan,
|
||||
src_old_focused,
|
||||
&ctx->border->normal_color
|
||||
);
|
||||
}
|
||||
if (!window_id_invalid(src_ws->focused_window_id) &&
|
||||
state_window_get(state, src_ws->focused_window_id)) {
|
||||
if (
|
||||
!window_id_invalid(src_ws->focused_window_id) &&
|
||||
state_window_get(state, src_ws->focused_window_id)
|
||||
) {
|
||||
plan_push_focus_effect(plan, src_ws->focused_window_id);
|
||||
plan_push_change_border_color_effect(
|
||||
plan,
|
||||
@@ -1469,8 +1475,10 @@ static void send_window_to_workspace(
|
||||
|
||||
auto listeners = ctx->listeners;
|
||||
listeners_notify_window_updated(listeners, state, command->window);
|
||||
if (src_ws && src_ws->focused_window_id != src_old_focused &&
|
||||
!window_id_invalid(src_ws->focused_window_id)) {
|
||||
if (
|
||||
src_ws && src_ws->focused_window_id != src_old_focused &&
|
||||
!window_id_invalid(src_ws->focused_window_id)
|
||||
) {
|
||||
listeners_notify_window_updated(
|
||||
listeners,
|
||||
state,
|
||||
@@ -1555,12 +1563,14 @@ static void switch_workspace(
|
||||
auto output_id = workspace->output_id;
|
||||
workspace_id_t old_workspace = ZDWM_WORKSPACE_ID_INVALID;
|
||||
|
||||
if (state_output_set_current_workspace(
|
||||
if (
|
||||
state_output_set_current_workspace(
|
||||
state,
|
||||
output_id,
|
||||
workspace_id,
|
||||
&old_workspace
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
plan->need_relayout = true;
|
||||
add_switch_workspace_effects(state, old_workspace, workspace_id, plan);
|
||||
listeners_notify_workspace_active(listeners, output_id, workspace_id);
|
||||
|
||||
@@ -65,6 +65,7 @@ typedef enum window_state_request_action_t {
|
||||
ZDWM_WINDOW_STATE_ACTION_TOGGLE,
|
||||
} window_state_request_action_t;
|
||||
|
||||
/* clang-format off */
|
||||
typedef enum configure_field_t {
|
||||
ZDWM_CONFIGURE_FIELD_X = 1u << 0,
|
||||
ZDWM_CONFIGURE_FIELD_Y = 1u << 1,
|
||||
@@ -74,6 +75,7 @@ typedef enum configure_field_t {
|
||||
ZDWM_CONFIGURE_FIELD_SIBLING = 1u << 5,
|
||||
ZDWM_CONFIGURE_FIELD_STACK_MODE = 1u << 6,
|
||||
} configure_field_t;
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct configure_data_t {
|
||||
window_id_t window;
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef enum window_layer_type_t {
|
||||
ZDWM_WINDOW_LAYER_COUNT,
|
||||
} window_layer_type_t;
|
||||
|
||||
/* clang-format off */
|
||||
typedef enum window_metadata_change_flags_t {
|
||||
ZDWM_WINDOW_METADATA_CHANGE_TITLE = 1u << 0,
|
||||
ZDWM_WINDOW_METADATA_CHANGE_APP_ID = 1u << 1,
|
||||
@@ -47,6 +48,7 @@ typedef enum window_metadata_change_flags_t {
|
||||
ZDWM_WINDOW_METADATA_CHANGE_CLASS = 1u << 3,
|
||||
ZDWM_WINDOW_METADATA_CHANGE_INSTANCE = 1u << 4,
|
||||
} window_metadata_change_flags_t;
|
||||
/* clang-format on */
|
||||
|
||||
typedef struct window_layer_props_t {
|
||||
window_type_t *types;
|
||||
|
||||
@@ -178,8 +178,10 @@ static void runtime_init_desc_cleanup(runtime_init_desc_t *desc) {
|
||||
desc->backend = nullptr;
|
||||
}
|
||||
|
||||
if (desc->layouts.slots || desc->layouts.slot_count ||
|
||||
desc->layouts.slot_capacity) {
|
||||
if (
|
||||
desc->layouts.slots || desc->layouts.slot_count ||
|
||||
desc->layouts.slot_capacity
|
||||
) {
|
||||
layout_registry_cleanup(&desc->layouts);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user