treewide: remove empty statements in switch cases

For longer cases, factor out the logic to new functions.
For very short cases, just move the declaration before the switch.

v2: in one case, replace the switch with if/else.
This commit is contained in:
John Lindgren 2025-05-22 10:53:58 -04:00 committed by Johan Malm
parent fbb92e2e30
commit a3d6226728
5 changed files with 59 additions and 50 deletions

View file

@ -168,24 +168,19 @@ resize_indicator_update(struct view *view)
view_box.height = view_effective_height(view, /* use_pending */ false);
}
switch (view->server->input_mode) {
case LAB_INPUT_STATE_RESIZE:
; /* works around "a label can only be part of a statement" */
if (view->server->input_mode == LAB_INPUT_STATE_RESIZE) {
struct view_size_hints hints = view_get_size_hints(view);
snprintf(text, sizeof(text), "%d x %d",
MAX(0, view_box.width - hints.base_width)
/ MAX(1, hints.width_inc),
MAX(0, view_box.height - hints.base_height)
/ MAX(1, hints.height_inc));
break;
case LAB_INPUT_STATE_MOVE:
; /* works around "a label can only be part of a statement" */
} else if (view->server->input_mode == LAB_INPUT_STATE_MOVE) {
struct border margin = ssd_get_margin(view->ssd);
snprintf(text, sizeof(text), "%d , %d",
view_box.x - margin.left,
view_box.y - margin.top);
break;
default:
} else {
wlr_log(WLR_ERROR, "Invalid input mode for indicator update %u",
view->server->input_mode);
return;