mobile-lua: add additional LABELLED_BY relation
[profile/tv/apps/native/screen-reader.git] / src / elm_access_adapter.c
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "elm_access_adapter.h"
18 #include "logger.h"
19
20 #ifdef X11_ENABLED
21 static void _get_root_coords(Ecore_X_Window win, int *x, int *y)
22 {
23         Ecore_X_Window root = ecore_x_window_root_first_get();
24         Ecore_X_Window parent = ecore_x_window_parent_get(win);
25         int wx, wy;
26
27         if (x)
28                 *x = 0;
29         if (y)
30                 *y = 0;
31
32         while (parent && (root != parent)) {
33                 ecore_x_window_geometry_get(parent, &wx, &wy, NULL, NULL);
34                 if (x)
35                         *x += wx;
36                 if (y)
37                         *y += wy;
38                 parent = ecore_x_window_parent_get(parent);
39         }
40 }
41 static void _send_ecore_x_client_msg(Ecore_X_Window win, int x, int y, Eina_Bool activate)
42 {
43         int x_win, y_win;
44         long type;
45         _get_root_coords(win, &x_win, &y_win);
46         DEBUG("Window screen size:%d %d", x_win, y_win);
47         DEBUG("activate keyboard: %d %d", x, y);
48
49         if (activate)
50                 type = ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE;
51         else
52                 type = ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ;
53
54         ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, win, type, x - x_win, y - y_win, 0);
55 }
56
57 void elm_access_adaptor_emit_activate(Ecore_X_Window win, int x, int y)
58 {
59         _send_ecore_x_client_msg(win, x, y, EINA_TRUE);
60 }
61
62 void elm_access_adaptor_emit_read(Ecore_X_Window win, int x, int y)
63 {
64         _send_ecore_x_client_msg(win, x, y, EINA_FALSE);
65 }
66 #else
67 void elm_access_adaptor_emit_activate(Ecore_Wl_Window *win, int x, int y)
68 {
69
70 }
71
72 void elm_access_adaptor_emit_read(Ecore_Wl_Window *win, int x, int y)
73 {
74
75 }
76 #endif