From 92a3f8fc167ea80a0c797e724303dd35eef9a594 Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Wed, 28 Sep 2022 13:31:35 +0900 Subject: [PATCH] ecore_wl2_input: don't be silent on errors, use ina_safety_checks to issue warnings. Change-Id: I682bbe9143afb92cf02f482a0d0ff6cff8c64955 --- src/lib/ecore_wl2/ecore_wl2_input.c | 51 +++++++++++++++---------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/lib/ecore_wl2/ecore_wl2_input.c b/src/lib/ecore_wl2/ecore_wl2_input.c index 057078d..baa04b5 100644 --- a/src/lib/ecore_wl2/ecore_wl2_input.c +++ b/src/lib/ecore_wl2/ecore_wl2_input.c @@ -2725,30 +2725,30 @@ ecore_wl2_window_keygrab_set(Ecore_Wl2_Window *win, const char *key, int mod EIN Eina_Bool ret = EINA_FALSE; struct wl_surface *surface = NULL; + EINA_SAFETY_ON_NULL_GOTO(key, err); + EINA_SAFETY_ON_TRUE_GOTO((grab_mode < ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN), err); + EINA_SAFETY_ON_TRUE_GOTO((grab_mode > ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE), err); + if (win) ewd = win->display; else ewd = ecore_wl2_connected_display_get(NULL); - if (!ewd) goto err; + EINA_SAFETY_ON_NULL_GOTO(ewd, err); while (!ewd->wl.tz_keyrouter) { INF("Wait until keyrouter interface is ready"); wl_display_roundtrip(ewd->wl.display); } - if (!key) goto err; - if ((grab_mode < ECORE_WL2_WINDOW_KEYGRAB_UNKNOWN) || (grab_mode > ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE)) - goto err; INF("win=%p key=%s mod=%d", win, key, grab_mode); keysym = xkb_keysym_from_name(key, XKB_KEYSYM_NO_FLAGS); - if (keysym == XKB_KEY_NoSymbol) { WRN("Keysym of key(\"%s\") doesn't exist", key); - goto err; + EINA_SAFETY_ON_TRUE_GOTO(EINA_TRUE, err); } //We have to find the way to get keycode from keysym before keymap notify @@ -2763,37 +2763,26 @@ ecore_wl2_window_keygrab_set(Ecore_Wl2_Window *win, const char *key, int mod EIN } input = ecore_wl2_input_default_input_get(ewd); + EINA_SAFETY_ON_NULL_GOTO(input, err); - if (input) + while (!input->caps_update) { - while (!input->caps_update) - { - INF("Wait until wl_seat_capabilities_update is ready"); - wl_display_roundtrip(ewd->wl.display); - } - if (input->wl.keyboard) - { - while (!input->xkb.keymap) - { - wl_display_roundtrip(ewd->wl.display); - INF("Wait until keymap event occurs"); - } - INF("Finish keymap event"); - - num_keycodes = ecore_wl2_input_keycode_from_keysym(input->xkb.keymap, keysym, &keycodes); - } - else - { - WRN("This device does not support key"); - goto err; - } + INF("Wait until wl_seat_capabilities_update is ready"); + wl_display_roundtrip(ewd->wl.display); } - if (num_keycodes == 0) + EINA_SAFETY_ON_NULL_GOTO(input->wl.keyboard, err); + + + while (!input->xkb.keymap) { - WRN("Keycode of key(\"%s\") doesn't exist", key); - goto err; + wl_display_roundtrip(ewd->wl.display); + INF("Wait until keymap event occurs"); } + INF("Finish keymap event"); + + num_keycodes = ecore_wl2_input_keycode_from_keysym(input->xkb.keymap, keysym, &keycodes); + EINA_SAFETY_ON_TRUE_GOTO((num_keycodes == 0), err); /* Request to grab a key */ if (win) -- 2.7.4