mirror of
https://github.com/labwc/labwc.git
synced 2026-03-16 05:33:50 -04:00
src: prefer 'if' over 'goto' where convenient
'goto' should not be used for normal control flow. v2 add comment in lieu of goto label
This commit is contained in:
parent
8b7ae52a91
commit
b48c250177
2 changed files with 23 additions and 25 deletions
|
|
@ -265,23 +265,21 @@ static struct keybind *
|
||||||
match_keybinding(struct server *server, struct keyinfo *keyinfo,
|
match_keybinding(struct server *server, struct keyinfo *keyinfo,
|
||||||
bool is_virtual)
|
bool is_virtual)
|
||||||
{
|
{
|
||||||
if (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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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 */
|
/* Then fall back to keysyms */
|
||||||
for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
|
for (int i = 0; i < keyinfo->translated.nr_syms; i++) {
|
||||||
keybind = match_keybinding_for_sym(server, keyinfo->modifiers,
|
struct keybind *keybind =
|
||||||
keyinfo->translated.syms[i], keyinfo->xkb_keycode);
|
match_keybinding_for_sym(server, keyinfo->modifiers,
|
||||||
|
keyinfo->translated.syms[i], keyinfo->xkb_keycode);
|
||||||
if (keybind) {
|
if (keybind) {
|
||||||
wlr_log(WLR_DEBUG, "translated keysym matched");
|
wlr_log(WLR_DEBUG, "translated keysym matched");
|
||||||
return keybind;
|
return keybind;
|
||||||
|
|
@ -290,8 +288,9 @@ process_syms:
|
||||||
|
|
||||||
/* And finally test for keysyms without modifier */
|
/* And finally test for keysyms without modifier */
|
||||||
for (int i = 0; i < keyinfo->raw.nr_syms; i++) {
|
for (int i = 0; i < keyinfo->raw.nr_syms; i++) {
|
||||||
keybind = match_keybinding_for_sym(server, keyinfo->modifiers,
|
struct keybind *keybind =
|
||||||
keyinfo->raw.syms[i], keyinfo->xkb_keycode);
|
match_keybinding_for_sym(server, keyinfo->modifiers,
|
||||||
|
keyinfo->raw.syms[i], keyinfo->xkb_keycode);
|
||||||
if (keybind) {
|
if (keybind) {
|
||||||
wlr_log(WLR_DEBUG, "raw keysym matched");
|
wlr_log(WLR_DEBUG, "raw keysym matched");
|
||||||
return keybind;
|
return keybind;
|
||||||
|
|
|
||||||
|
|
@ -543,20 +543,19 @@ ssd_update_button_hover(struct wlr_scene_node *node,
|
||||||
struct ssd_hover_state *hover_state)
|
struct ssd_hover_state *hover_state)
|
||||||
{
|
{
|
||||||
struct ssd_button *button = NULL;
|
struct ssd_button *button = NULL;
|
||||||
if (!node || !node->data) {
|
|
||||||
goto disable_old_hover;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct node_descriptor *desc = node->data;
|
if (node && node->data) {
|
||||||
if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
|
struct node_descriptor *desc = node->data;
|
||||||
button = node_ssd_button_from_node(node);
|
if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
|
||||||
if (button == hover_state->button) {
|
button = node_ssd_button_from_node(node);
|
||||||
/* Cursor is still on the same button */
|
if (button == hover_state->button) {
|
||||||
return;
|
/* Cursor is still on the same button */
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_old_hover:
|
/* Disable old hover */
|
||||||
if (hover_state->button) {
|
if (hover_state->button) {
|
||||||
update_button_state(hover_state->button, LAB_BS_HOVERD, false);
|
update_button_state(hover_state->button, LAB_BS_HOVERD, false);
|
||||||
hover_state->view = NULL;
|
hover_state->view = NULL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue