]> git.mdlowis.com Git - proto/labwc.git/commitdiff
src: prefer 'if' over 'goto' where convenient
authorJohn Lindgren <john@jlindgren.net>
Fri, 4 Jul 2025 04:44:22 +0000 (00:44 -0400)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 21 Jul 2025 14:51:10 +0000 (16:51 +0200)
'goto' should not be used for normal control flow.

v2 add comment in lieu of goto label

src/input/keyboard.c
src/ssd/ssd-titlebar.c

index 15b549f1319c7e2c84fa062c66ed4736d496fc4a..17a2139553fa52a2c3dd1668efac477bf5b8c6ff 100644 (file)
@@ -265,23 +265,21 @@ static struct keybind *
 match_keybinding(struct server *server, struct keyinfo *keyinfo,
                bool is_virtual)
 {
-       if (is_virtual) {
-               goto process_syms;
-       }
-
-       /* First try keycodes */
-       struct keybind *keybind = match_keybinding_for_sym(server,
-               keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode);
-       if (keybind) {
-               wlr_log(WLR_DEBUG, "keycode matched");
-               return keybind;
+       if (!is_virtual) {
+               /* First try keycodes */
+               struct keybind *keybind = match_keybinding_for_sym(server,
+                       keyinfo->modifiers, XKB_KEY_NoSymbol, keyinfo->xkb_keycode);
+               if (keybind) {
+                       wlr_log(WLR_DEBUG, "keycode matched");
+                       return keybind;
+               }
        }
 
-process_syms:
        /* Then fall back to keysyms */
        for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
-               keybind = match_keybinding_for_sym(server, keyinfo->modifiers,
-                       keyinfo->translated.syms[i], keyinfo->xkb_keycode);
+               struct keybind *keybind =
+                       match_keybinding_for_sym(server, keyinfo->modifiers,
+                               keyinfo->translated.syms[i], keyinfo->xkb_keycode);
                if (keybind) {
                        wlr_log(WLR_DEBUG, "translated keysym matched");
                        return keybind;
@@ -290,8 +288,9 @@ process_syms:
 
        /* And finally test for keysyms without modifier */
        for (int i = 0; i < keyinfo->raw.nr_syms; i++) {
-               keybind = match_keybinding_for_sym(server, keyinfo->modifiers,
-                       keyinfo->raw.syms[i], keyinfo->xkb_keycode);
+               struct keybind *keybind =
+                       match_keybinding_for_sym(server, keyinfo->modifiers,
+                               keyinfo->raw.syms[i], keyinfo->xkb_keycode);
                if (keybind) {
                        wlr_log(WLR_DEBUG, "raw keysym matched");
                        return keybind;
index d44adf419dcbaac9a0136ff1930138c2d215c5b2..57d49600b35adce2d6a883c7e3c08c95211e076a 100644 (file)
@@ -543,20 +543,19 @@ ssd_update_button_hover(struct wlr_scene_node *node,
                struct ssd_hover_state *hover_state)
 {
        struct ssd_button *button = NULL;
-       if (!node || !node->data) {
-               goto disable_old_hover;
-       }
 
-       struct node_descriptor *desc = node->data;
-       if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
-               button = node_ssd_button_from_node(node);
-               if (button == hover_state->button) {
-                       /* Cursor is still on the same button */
-                       return;
+       if (node && node->data) {
+               struct node_descriptor *desc = node->data;
+               if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
+                       button = node_ssd_button_from_node(node);
+                       if (button == hover_state->button) {
+                               /* Cursor is still on the same button */
+                               return;
+                       }
                }
        }
 
-disable_old_hover:
+       /* Disable old hover */
        if (hover_state->button) {
                update_button_state(hover_state->button, LAB_BS_HOVERD, false);
                hover_state->view = NULL;