Support for keyboard
authorPatryk Kaczmarek <patryk.k@samsung.com>
Mon, 10 Aug 2015 04:14:11 +0000 (06:14 +0200)
committerPatryk Kaczmarek <patryk.k@samsung.com>
Mon, 10 Aug 2015 11:56:50 +0000 (13:56 +0200)
  * Ecore Msg sent to window manager to support accessibility features in virtual keyboard

Change-Id: Ifd98a2d903f5beb36ffa9df7307ded3d69ed98f9
Signed-off-by: Patryk Kaczmarek <patryk.k@samsung.com>
include/elm_access_adapter.h [new file with mode: 0644]
include/screen_reader_gestures.h
packaging/org.tizen.screen-reader.spec
src/elm_access_adapter.c [new file with mode: 0644]
src/navigator.c
src/screen_reader_gestures.c

diff --git a/include/elm_access_adapter.h b/include/elm_access_adapter.h
new file mode 100644 (file)
index 0000000..027108b
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef ELM_ACCESS_KEYBOARD_ADAPTER_H_
+#define ELM_ACCESS_KEYBOARD_ADAPTER_H_
+
+#include <Ecore.h>
+#include <Ecore_X.h>
+
+/**
+ * @brief Send ecore x message with elm access read action
+ *
+ * @param win keyboard window
+ * @param x x coordinate of gesture relative to X root window
+ * @param y y coordinate of gesture relative to X root window
+ *
+ */
+void elm_access_adaptor_emit_read(Ecore_X_Window win, int x, int y);
+
+/**
+ * @brief Send ecore x message with elm access activate action
+ *
+ * @param win keyboard window
+ * @param x x coordinate of gesture relative to X root window
+ * @param y y coordinate of gesture relative to X root window
+ *
+ */
+void elm_access_adaptor_emit_activate(Ecore_X_Window win, int x, int y);
+
+#endif
index 12c4445..0e5b1d4 100644 (file)
@@ -95,4 +95,13 @@ void continue_scroll(int x, int y);
  */
 void end_scroll(int x, int y);
 
+/**
+ * @brief Get top window object on which gesture occure
+ *
+ * @param x Gesture X coordinate
+ * @param y Gesture Y coordinate
+ *
+ * @return Ecore_X_Window Object which represents top window on which gesture occure
+ */
+Ecore_X_Window top_window_get (int x, int y);
 #endif
index 9fe46ba..8790dbd 100755 (executable)
@@ -40,6 +40,7 @@ An utility library for developers of the menu screen.
 %if "%{?tizen_profile_name}" == "tv"
     export CFLAGS+=" -DSCREEN_READER_TV"
 %endif
+export CFLAGS+=" -DELM_ACCESS_KEYBOARD"
 
 rm -rf CMakeFiles CMakeCache.txt && cmake . -DCMAKE_INSTALL_PREFIX="%{AppInstallPath}" -DCMAKE_TARGET="%{Exec}" -DCMAKE_PACKAGE="%{name}"
 make %{?jobs:-j%jobs} \
diff --git a/src/elm_access_adapter.c b/src/elm_access_adapter.c
new file mode 100644 (file)
index 0000000..87c1720
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "elm_access_adapter.h"
+#include "logger.h"
+
+static void
+_get_root_coords(Ecore_X_Window win, int *x, int *y)
+{
+   Ecore_X_Window root = ecore_x_window_root_first_get();
+   Ecore_X_Window parent = ecore_x_window_parent_get(win);
+   int wx, wy;
+
+   if (x) *x = 0;
+   if (y) *y = 0;
+
+   while (parent && (root != parent))
+      {
+         ecore_x_window_geometry_get(parent, &wx, &wy, NULL, NULL);
+         if (x) *x += wx;
+         if (y) *y += wy;
+         parent = ecore_x_window_parent_get(parent);
+      }
+}
+
+static void
+_send_ecore_x_client_msg (Ecore_X_Window win, int x, int y, Eina_Bool activate)
+{
+   int x_win, y_win;
+   long type;
+   _get_root_coords(win, &x_win, &y_win);
+   DEBUG("Window screen size:%d %d", x_win, y_win);
+   DEBUG("activate keyboard: %d %d", x, y);
+
+   if (activate)
+      type = ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE;
+   else
+      type = ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ;
+
+   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);
+}
+void
+elm_access_adaptor_emit_activate (Ecore_X_Window win, int x, int y)
+{
+   _send_ecore_x_client_msg(win, x, y, EINA_TRUE);
+}
+
+void
+elm_access_adaptor_emit_read (Ecore_X_Window win, int x, int y)
+{
+   _send_ecore_x_client_msg(win, x, y, EINA_FALSE);
+}
index 75b0a79..f512b68 100644 (file)
@@ -31,6 +31,7 @@
 #include "screen_reader_tts.h"
 #include "screen_reader_gestures.h"
 #include "dbus_gesture_adapter.h"
+#include "elm_access_adapter.h"
 
 #define QUICKPANEL_DOWN TRUE
 #define QUICKPANEL_UP FALSE
@@ -1850,6 +1851,25 @@ static void _start_stop_signal_send(void)
 
 static void on_gesture_detected(void *data, Gesture_Info *info)
 {
+
+#ifdef ELM_ACCESS_KEYBOARD
+   Ecore_X_Window keyboard_win = top_window_get(info->x_end, info->y_end);
+   if (keyboard_win && ecore_x_e_virtual_keyboard_get(keyboard_win))
+      {
+         DEBUG("Gesture is on virtural keyboard screen");
+         if (info->type == ONE_FINGER_SINGLE_TAP || info->type == ONE_FINGER_HOVER)
+            {
+               elm_access_adaptor_emit_read (keyboard_win, info->x_end, info->y_end);
+               return;
+            }
+         else if (info->type == ONE_FINGER_DOUBLE_TAP)
+            {
+               elm_access_adaptor_emit_activate (keyboard_win, info->x_end, info->y_end);
+               return;
+            }
+      }
+#endif
+
    dbus_gesture_adapter_emit(info);
    _on_auto_review_stop();
 
index bf6b386..940e637 100644 (file)
@@ -691,6 +691,19 @@ static void _get_root_coords(Ecore_X_Window win, int *x, int *y)
       }
 }
 
+Ecore_X_Window top_window_get (int x, int y)
+{
+   Ecore_X_Window wins[1] = { win };
+   Ecore_X_Window under = ecore_x_window_at_xy_with_skip_get(x, y, wins, sizeof(wins)/sizeof(wins[0]));
+   if (under)
+      {
+         _get_root_coords(under, &rx, &ry);
+         DEBUG("Recieved window with coords:%d %d", rx, ry);
+         return under;
+      }
+   return 0;
+}
+
 void
 start_scroll(int x, int y)
 {
@@ -1162,14 +1175,6 @@ _cb_mouse_down(void    *data EINA_UNUSED,
                void    *event)
 {
    Ecore_Event_Mouse_Button *ev = event;
-   int x, y;
-
-   if (ecore_x_e_virtual_keyboard_get(ev->window))
-     {
-        _get_root_coords(ev->window, &x, &y);
-        ecore_x_mouse_in_send(ev->window, ev->x - x, ev->y - y);
-        ecore_x_mouse_down_send(ev->window, ev->x - x, ev->y -y, 1);
-     }
 
    cov->n_taps++;
    cov->event_time = ev->timestamp;
@@ -1191,14 +1196,6 @@ _cb_mouse_up(void    *data EINA_UNUSED,
              void    *event)
 {
    Ecore_Event_Mouse_Button *ev = event;
-   int x, y;
-
-   if (ecore_x_e_virtual_keyboard_get(ev->window))
-     {
-        _get_root_coords(ev->window, &x, &y);
-        ecore_x_mouse_out_send(ev->window, ev->x - x, ev->y - y);
-        ecore_x_mouse_up_send(ev->window, ev->x - x, ev->y -y, 1);
-     }
 
    cov->n_taps--;
    cov->event_time = ev->timestamp;
@@ -1218,14 +1215,6 @@ _cb_mouse_move(void    *data EINA_UNUSED,
                void    *event)
 {
    Ecore_Event_Mouse_Move *ev = event;
-   int x, y;
-
-   if (ecore_x_e_virtual_keyboard_get(ev->window))
-     {
-        _get_root_coords(ev->window, &x, &y);
-        ecore_x_window_geometry_get(ev->window, &x, &y, NULL, NULL);
-        ecore_x_mouse_move_send(ev->window, ev->x - x, ev->y - y);
-     }
 
    cov->event_time = ev->timestamp;