From: Artur Świgoń Date: Thu, 20 Oct 2022 09:50:02 +0000 (+0200) Subject: Add e_client_under_position_input_get() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_6.0;p=platform%2Fupstream%2Fenlightenment.git Add e_client_under_position_input_get() Similarly to e_client_under_position_get(), it performs a hit-test, but input regions are also considered. If input regions are present, then the specified position needs to be inside such a region. Change-Id: Ie75c346ffc6e535fdb678e7b5748435f9a003bbb --- diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 7725cd4bba..3929fe0ce7 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -1871,6 +1871,17 @@ _e_client_resize_mouse_down(void *data EINA_UNUSED, int type EINA_UNUSED, void * //////////////////////////////////////////////// +static Eina_Bool +_e_client_under_pointer_helper_ignore_client(E_Desk *desk, E_Client *ec) +{ + /* If a border was specified which should be excluded from the list + * (because it will be closed shortly for example), skip */ + if (e_client_util_ignored_get(ec) || (!e_client_util_desk_visible(ec, desk))) return EINA_TRUE; + if (!evas_object_visible_get(ec->frame)) return EINA_TRUE; + + return EINA_FALSE; +} + static E_Client * _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y) { @@ -1878,10 +1889,7 @@ _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y) E_CLIENT_REVERSE_FOREACH(cec) { - /* If a border was specified which should be excluded from the list - * (because it will be closed shortly for example), skip */ - if (e_client_util_ignored_get(cec) || (!e_client_util_desk_visible(cec, desk))) continue; - if (!evas_object_visible_get(cec->frame)) continue; + if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue; if ((exclude) && (cec == exclude)) continue; if (!E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h)) continue; @@ -1893,6 +1901,43 @@ _e_client_under_pointer_helper(E_Desk *desk, E_Client *exclude, int x, int y) return ec; } +static E_Client * +_e_client_under_pointer_input_helper(E_Desk *desk, int x, int y) +{ + E_Client *ec = NULL, *cec; + + E_CLIENT_REVERSE_FOREACH(cec) + { + if (_e_client_under_pointer_helper_ignore_client(desk, cec)) continue; + + Eina_List *list = NULL; + Eina_Rectangle *rect; + Eina_Bool inside = EINA_FALSE; + e_comp_object_input_rect_get(cec->frame, &list); + if (list) + { + EINA_LIST_FREE(list, rect) + { + if (E_INSIDE(x, y, rect->x, rect->y, rect->w, rect->h)) + inside = EINA_TRUE; + } + } + else + { + if (E_INSIDE(x, y, cec->x, cec->y, cec->w, cec->h)) + inside = EINA_TRUE; + } + + if (!inside) continue; + /* If the layer is higher, the position of the window is higher + * (always on top vs always below) */ + if (!ec || (cec->layer > ec->layer)) + ec = cec; + } + + return ec; +} + //////////////////////////////////////////////// static void @@ -6969,6 +7014,13 @@ E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client return _e_client_under_pointer_helper(desk, exclude, x, y); } +E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y) +{ + if (!desk) return NULL; + + return _e_client_under_pointer_input_helper(desk, x, y); +} + //////////////////////////////////////////// E_API int diff --git a/src/bin/e_client.h b/src/bin/e_client.h index f4dadea3f4..eaf2c8dbd2 100644 --- a/src/bin/e_client.h +++ b/src/bin/e_client.h @@ -1157,6 +1157,7 @@ E_API void e_client_signal_resize_end(E_Client *ec, const char *dir EINA_UNUSED, E_API void e_client_resize_limit(E_Client *ec, int *w, int *h); E_API E_Client *e_client_under_pointer_get(E_Desk *desk, E_Client *exclude); E_API E_Client *e_client_under_position_get(E_Desk *desk, int x, int y, E_Client *exclude); +E_API E_Client *e_client_under_position_input_get(E_Desk *desk, int x, int y); E_API int e_client_pointer_warp_to_center_now(E_Client *ec); E_API int e_client_pointer_warp_to_center(E_Client *ec); E_API void e_client_redirected_set(E_Client *ec, Eina_Bool set);