Changes that allow to compile SR on Tizen 3.0 Mobile. 73/50273/1
authorTomasz Olszak <t.olszak@samsung.com>
Tue, 27 Oct 2015 10:09:32 +0000 (11:09 +0100)
committerTomasz Olszak <t.olszak@samsung.com>
Tue, 27 Oct 2015 10:09:32 +0000 (11:09 +0100)
There are still many issues related to fact that Wayland differs a lot
comparing to X11 and we used X11 a lot - especially for gesture
recognition, scrolling.

Change-Id: I24ea4d42006fe39359f484c9eddeffc8b7ac6572

CMakeLists.txt
include/elm_access_adapter.h
include/screen_reader_gestures.h
packaging/org.tizen.screen-reader.spec
src/elm_access_adapter.c
src/keyboard_tracker.c
src/navigator.c
src/screen_reader_gestures.c
src/window_tracker.c

index 739a1b8..8044755 100755 (executable)
@@ -40,9 +40,12 @@ ELSE()
 ENDIF()
 
 IF("${X11_ENABLED}" STREQUAL "1")
-    MESSSAGE("X11 is enabled")
+    MESSAGE(STATUS "X11 is enabled")
     SET(CONDITIONAL_PACKAGES ${CONDITIONAL_PACKAGES} "ecore-x")
     ADD_DEFINITIONS("-DX11_ENABLED")
+ELSE()
+    MESSAGE(STATUS "X11 is disabled - using wayland")
+    SET(CONDITIONAL_PACKAGES ${CONDITIONAL_PACKAGES} "ecore-wayland")
 ENDIF()
 
 INCLUDE(FindPkgConfig)
index 027108b..3c6b209 100644 (file)
@@ -1,8 +1,11 @@
 #ifndef ELM_ACCESS_KEYBOARD_ADAPTER_H_
 #define ELM_ACCESS_KEYBOARD_ADAPTER_H_
 
-#include <Ecore.h>
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
+#else
+#include <Ecore_Wayland.h>
+#endif
 
 /**
  * @brief Send ecore x message with elm access read action
  * @param y y coordinate of gesture relative to X root window
  *
  */
+#ifdef X11_ENABLED
 void elm_access_adaptor_emit_read(Ecore_X_Window win, int x, int y);
+#else
+void elm_access_adaptor_emit_read(Ecore_Wl_Window *win, int x, int y);
+#endif
 
 /**
  * @brief Send ecore x message with elm access activate action
@@ -22,6 +29,10 @@ void elm_access_adaptor_emit_read(Ecore_X_Window win, int x, int y);
  * @param y y coordinate of gesture relative to X root window
  *
  */
+#ifdef X11_ENABLED
 void elm_access_adaptor_emit_activate(Ecore_X_Window win, int x, int y);
+#else
+void elm_access_adaptor_emit_activate(Ecore_Wl_Window *win, int x, int y);
+#endif
 
 #endif
index 0e5b1d4..3ac3114 100644 (file)
@@ -2,8 +2,11 @@
 #define SCREEN_READER_GESTURES_H_
 
 #include <Ecore.h>
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
-
+#else
+#include <Ecore_Wayland.h>
+#endif
 /**
  * @brief Accessibility gestures
  */
@@ -70,8 +73,11 @@ Eina_Bool screen_reader_gestures_init(void);
  * @brief Shutdown gesture navigation profile.
  */
 void screen_reader_gestures_shutdown(void);
-
+#ifdef X11_ENABLED
 Eina_Bool screen_reader_gesture_x_grab_touch_devices(Ecore_X_Window win);
+#else
+Eina_Bool screen_reader_gesture_wl_grab_touch_devices(Ecore_Wl_Window win);
+#endif
 
 typedef void (*GestureCB)(void *data, Gesture_Info *info);
 
@@ -103,5 +109,10 @@ void end_scroll(int x, int y);
  *
  * @return Ecore_X_Window Object which represents top window on which gesture occure
  */
+#ifdef X11_ENABLED
 Ecore_X_Window top_window_get (int x, int y);
+#else
+Ecore_Wl_Window *top_window_get (int x, int y);
+#endif
+
 #endif
index d0bd43c..9d10be4 100755 (executable)
@@ -1,6 +1,7 @@
 %define AppInstallPath /usr/apps/%{name}
 %define Exec screen-reader
-
+%bcond_with x
+%bcond_with wayland
 
 Name:       org.tizen.screen-reader
 Summary:    Screen Reader Assistive Technology
@@ -17,6 +18,9 @@ BuildRequires:  pkgconfig(ecore)
 %if %{with x}
 BuildRequires:  pkgconfig(ecore-x)
 %endif
+%if %{with wayland}
+BuildRequires:  pkgconfig(ecore-wayland)
+%endif
 BuildRequires:  pkgconfig(eina)
 BuildRequires:  pkgconfig(eldbus)
 BuildRequires:  pkgconfig(elementary)
index fc46227..233e51a 100644 (file)
@@ -17,6 +17,7 @@
 #include "elm_access_adapter.h"
 #include "logger.h"
 
+#ifdef X11_ENABLED
 static void _get_root_coords(Ecore_X_Window win, int *x, int *y)
 {
        Ecore_X_Window root = ecore_x_window_root_first_get();
@@ -37,7 +38,6 @@ static void _get_root_coords(Ecore_X_Window win, int *x, int *y)
                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;
@@ -63,3 +63,14 @@ void elm_access_adaptor_emit_read(Ecore_X_Window win, int x, int y)
 {
        _send_ecore_x_client_msg(win, x, y, EINA_FALSE);
 }
+#else
+void elm_access_adaptor_emit_activate(Ecore_Wl_Window *win, int x, int y)
+{
+
+}
+
+void elm_access_adaptor_emit_read(Ecore_Wl_Window *win, int x, int y)
+{
+
+}
+#endif
\ No newline at end of file
index c0d3c4e..74befc9 100644 (file)
 #include <string.h>
 #include <atspi/atspi.h>
 #include <Ecore.h>
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
+#endif
 #include "keyboard_tracker.h"
 #include "logger.h"
 #include "screen_reader_tts.h"
 static AtspiDeviceListener *listener;
 static Keyboard_Tracker_Cb user_cb;
 static void *user_data;
+#ifdef X11_ENABLED
 static Ecore_Event_Handler *root_xwindow_property_changed_hld = NULL;
 static Ecore_Event_Handler *active_xwindow_property_changed_hld = NULL;
 
@@ -134,7 +137,7 @@ void root_xwindow_property_tracker_unregister()
                root_xwindow_property_changed_hld = NULL;
        }
 }
-
+#endif
 static gboolean device_cb(const AtspiDeviceEvent * stroke, void *data)
 {
        Key k;
@@ -159,8 +162,10 @@ void keyboard_tracker_init(void)
 {
        listener = atspi_device_listener_new(device_cb, NULL, NULL);
        atspi_register_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, ATSPI_KEYLISTENER_SYNCHRONOUS | ATSPI_KEYLISTENER_CANCONSUME, NULL);
+#ifdef X11_ENABLED
        active_xwindow_property_tracker_register();
        root_xwindow_property_tracker_register();
+#endif
        DEBUG("keyboard tracker init");
 }
 
@@ -173,7 +178,9 @@ void keyboard_tracker_register(Keyboard_Tracker_Cb cb, void *data)
 void keyboard_tracker_shutdown(void)
 {
        atspi_deregister_keystroke_listener(listener, NULL, 0, ATSPI_KEY_PRESSED, NULL);
+#ifdef X11_ENABLED
        root_xwindow_property_tracker_unregister();
        active_xwindow_property_tracker_unregister();
+#endif
        DEBUG("keyboard tracker shutdown");
 }
index c965cd8..1dcc68a 100644 (file)
 
 #define _GNU_SOURCE
 #include <stdio.h>
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
+#else
+#include <Ecore_Wayland.h>
+#endif
 #include <Ecore.h>
 #include <math.h>
 #include <atspi/atspi.h>
@@ -1348,6 +1352,7 @@ static void _activate_widget(void)
 static void _quickpanel_change_state(gboolean quickpanel_switch)
 {
        DEBUG("START");
+#ifdef X11_ENABLED
        Ecore_X_Window xwin = 0;
 
        if (quickpanel_switch)
@@ -1366,6 +1371,7 @@ static void _quickpanel_change_state(gboolean quickpanel_switch)
        ecore_x_e_illume_quickpanel_state_send(ecore_x_e_illume_zone_get(xwin), state);
 
        ecore_main_loop_iterate();
+#endif
 }
 
 /**
@@ -2018,7 +2024,9 @@ static void _start_stop_signal_send(void)
 
 static void on_gesture_detected(void *data, Gesture_Info * info)
 {
+#ifdef X11_ENABLED
        Ecore_X_Window keyboard_win;
+#endif
        _on_auto_review_stop();
 
        if (info->type == ONE_FINGER_SINGLE_TAP && info->state == 3) {
@@ -2039,7 +2047,7 @@ static void on_gesture_detected(void *data, Gesture_Info * info)
                        if ((info->event_time - _last_hover_event_time) < ONGOING_HOVER_GESTURE_INTERPRETATION_INTERVAL && info->state == 1)
                                return;
                        _last_hover_event_time = info->state != 1 ? -1 : info->event_time;
-#ifdef ELM_ACCESS_KEYBOARD
+#if defined(ELM_ACCESS_KEYBOARD) && defined(X11_ENABLED)
                        keyboard_win = top_window_get(info->x_end, info->y_end);
                        if (keyboard_win && ecore_x_e_virtual_keyboard_get(keyboard_win)) {
                                elm_access_adaptor_emit_read(keyboard_win, info->x_end, info->y_end);
@@ -2075,7 +2083,7 @@ static void on_gesture_detected(void *data, Gesture_Info * info)
                        _focus_next();
                break;
        case ONE_FINGER_SINGLE_TAP:
-#ifdef ELM_ACCESS_KEYBOARD
+#if defined(ELM_ACCESS_KEYBOARD) && defined(X11_ENABLED)
                keyboard_win = top_window_get(info->x_end, info->y_end);
                if (keyboard_win && ecore_x_e_virtual_keyboard_get(keyboard_win)) {
                        elm_access_adaptor_emit_read(keyboard_win, info->x_end, info->y_end);
@@ -2086,7 +2094,7 @@ static void on_gesture_detected(void *data, Gesture_Info * info)
                        _focus_widget(info);
                break;
        case ONE_FINGER_DOUBLE_TAP:
-#ifdef ELM_ACCESS_KEYBOARD
+#if defined(ELM_ACCESS_KEYBOARD) && defined(X11_ENABLED)
                keyboard_win = top_window_get(info->x_end, info->y_end);
                if (keyboard_win && ecore_x_e_virtual_keyboard_get(keyboard_win)) {
                        elm_access_adaptor_emit_activate(keyboard_win, info->x_end, info->y_end);
index c55d606..1a83297 100644 (file)
 
 #include <Ecore.h>
 #include <Ecore_Input.h>
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
+#else
+#include <Ecore_Wayland.h>
+#endif
 
 static GestureCB _global_cb;
 static void *_global_data;
-static Ecore_Window win;
+
+#ifdef X11_ENABLED
+static Ecore_X_Window win;
+#else
+static Ecore_Wl_Window *win;
+#endif
+
 static Ecore_Event_Handler *property_changed_hld;
 
 struct _Gestures_Config {
@@ -70,7 +80,11 @@ typedef enum {
 } gesture_type_e;
 
 struct _Cover {
+#ifdef X11_ENABLED
        Ecore_X_Window win;      /**< Input window covering given zone */
+#else
+       Ecore_Wl_Window *win;    /**< Input window covering given zone */
+#endif
        unsigned int n_taps;   /**< Number of fingers touching screen */
        unsigned int event_time;
 
@@ -115,8 +129,10 @@ struct _Cover {
 typedef struct _Cover Cover;
 
 Gestures_Config *_e_mod_config;
+#ifdef X11_ENABLED
 static Ecore_X_Window scrolled_win;
 static int rx, ry;
+#endif
 static Eina_List *handlers;
 static Cover *cov;
 static int win_angle;
@@ -126,24 +142,25 @@ static unsigned int _win_angle_get(void);
 
 void __transform_coordinates(int *ax, int *ay)
 {
-       Ecore_X_Window root;
        int w;
        int h;
        int tmp;
+#ifdef X11_ENABLED
+       ecore_x_window_geometry_get(ecore_x_window_root_first_get(), NULL, NULL, &w, &h);
+#else
+       ecore_wl_screen_size_get(&w, &h);
+#endif
 
        win_angle = _win_angle_get();
 
        switch (win_angle) {
        case 90:
-               root = ecore_x_window_root_first_get();
-               ecore_x_window_geometry_get(root, NULL, NULL, &w, &h);
                tmp = *ax;
                *ax = h - *ay;
                *ay = tmp;
                break;
        case 270:
-               root = ecore_x_window_root_first_get();
-               ecore_x_window_geometry_get(root, NULL, NULL, &w, &h);
+
                tmp = *ax;
                *ax = *ay;
                *ay = w - tmp;
@@ -615,7 +632,7 @@ static void _hover_gesture_mouse_up(Ecore_Event_Mouse_Button * ev, Cover * cov)
        if (cov->n_taps == 0)
                cov->hover_gesture.state = GESTURE_NOT_STARTED;
 }
-
+#ifdef X11_ENABLED
 static void _get_root_coords(Ecore_X_Window win, int *x, int *y)
 {
        Ecore_X_Window root = ecore_x_window_root_first_get();
@@ -648,9 +665,17 @@ Ecore_X_Window top_window_get(int x, int y)
        }
        return 0;
 }
+#else
+Ecore_Wl_Window *top_window_get(int x, int y)
+{
+       return 0;
+}
+#endif
+
 
 void start_scroll(int x, int y)
 {
+#ifdef X11_ENABLED
        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]));
        _get_root_coords(under, &rx, &ry);
@@ -658,25 +683,31 @@ void start_scroll(int x, int y)
        ecore_x_window_focus(under);
        ecore_x_mouse_down_send(under, x - rx, y - ry, 1);
        scrolled_win = under;
+#endif
 }
 
 void continue_scroll(int x, int y)
 {
+#ifdef X11_ENABLED
        ecore_x_mouse_move_send(scrolled_win, x - rx, y - ry);
+#endif
 }
 
 void end_scroll(int x, int y)
 {
-       ecore_x_mouse_up_send(scrolled_win, x - rx, y - ry, 1);
+#ifdef X11_ENABLED
+       ecore_x_mouse_up_send(scrolled_win, x - rx, y - ry, 1); 
        ecore_x_mouse_out_send(scrolled_win, x - rx, y - ry);
+#endif
 }
 
 static unsigned int _win_angle_get(void)
 {
+       int angle = 0;
+#ifdef X11_ENABLED
        Ecore_X_Window root, first_root;
        int ret;
        int count;
-       int angle = 0;
        unsigned char *prop_data = NULL;
 
        first_root = ecore_x_window_root_first_get();
@@ -688,7 +719,9 @@ static unsigned int _win_angle_get(void)
 
        if (prop_data)
                free(prop_data);
+#else
 
+#endif
        return angle;
 }
 
@@ -1025,25 +1058,34 @@ static Eina_Bool _gesture_input_win_create(void)
        int w, h;
 
        if (!win) {
+#ifdef X11_ENABLED
                Ecore_Window root = ecore_x_window_root_first_get();
                if (!root)
                        return EINA_FALSE;
                ecore_x_window_geometry_get(root, NULL, NULL, &w, &h);
                win = ecore_x_window_input_new(root, 0, 0, w, h);
+#else
+               ecore_wl_screen_size_get(&w, &h);
+               win = ecore_wl_window_new(NULL, 0, 0, w, h, ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW);
+#endif
        }
        if (!win)
                return EINA_FALSE;
 
+#ifdef X11_ENABLED
        ecore_x_input_multi_select(win);
        ecore_x_window_show(win);
        ecore_x_window_raise(win);
-
+#else
+       ecore_wl_window_show(win);
+       ecore_wl_window_raise(win);
+#endif
        // restet gestures
        memset(cov, 0x0, sizeof(Cover));
 
        return EINA_TRUE;
 }
-
+#ifdef X11_ENABLED
 static Eina_Bool _win_property_changed(void *data, int type, void *event)
 {
        Ecore_X_Event_Window_Property *wp = event;
@@ -1055,9 +1097,11 @@ static Eina_Bool _win_property_changed(void *data, int type, void *event)
 
        return EINA_TRUE;
 }
+#endif
 
 static Eina_Bool _gestures_input_window_init(void)
 {
+#ifdef X11_ENABLED
        Ecore_Window root = ecore_x_window_root_first_get();
        if (!root) {
                ERROR("No root window found. Is Window manager running?");
@@ -1065,7 +1109,7 @@ static Eina_Bool _gestures_input_window_init(void)
        }
        ecore_x_event_mask_set(root, ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
        property_changed_hld = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _win_property_changed, NULL);
-
+#endif
        return _gesture_input_win_create();
 }
 
@@ -1073,15 +1117,22 @@ static void _gestures_input_widnow_shutdown(void)
 {
        ecore_event_handler_del(property_changed_hld);
        if (win)
+#ifdef X11_ENABLED
                ecore_x_window_free(win);
+#else
+               ecore_wl_window_free(win);
+#endif
        win = 0;
 }
 
 Eina_Bool screen_reader_gestures_init(void)
 {
        ecore_init();
+#ifdef X11_ENABLED
        ecore_x_init(NULL);
-
+#else
+       ecore_wl_init(NULL);
+#endif
        cov = calloc(sizeof(Cover), 1);
 
        if (!_gestures_input_window_init()) {
@@ -1112,8 +1163,11 @@ void screen_reader_gestures_shutdown(void)
                ecore_event_handler_del(hdlr);
        }
        _gestures_input_widnow_shutdown();
-
+#ifdef X11_ENABLED
        ecore_x_shutdown();
+#else
+       ecore_wl_shutdown();
+#endif
        ecore_shutdown();
        free(_e_mod_config);
        free(cov);
index ebdb9be..4dbfc8b 100644 (file)
 #include <string.h>
 #include "window_tracker.h"
 #include "logger.h"
+
+#ifdef X11_ENABLED
 #include <Ecore_X.h>
 #include <Ecore_X_Atoms.h>
+#endif
 
 static Window_Tracker_Cb user_cb;
 static void *user_data;
@@ -49,8 +52,10 @@ static AtspiAccessible *_get_active_win(void)
                return NULL;
        }
 
-       Ecore_X_Window focus_window = ecore_x_window_focus_get();
        unsigned int active_window_pid = 0;
+#ifdef X11_ENABLED
+       Ecore_X_Window focus_window = ecore_x_window_focus_get();
+
        if (focus_window) {
                //invoking atspi_accessible_get_child_count for non active apps results in very long screen-reader startup
                //not active apps have low priority and dbus calls take a lot of time (a few hundred ms per call)
@@ -60,6 +65,7 @@ static AtspiAccessible *_get_active_win(void)
                if (active_window_pid)
                        DEBUG("First we will try filter apps by PID: %i", active_window_pid);
        }
+#endif
        desktop_children_count = atspi_accessible_get_child_count(desktop, NULL);
        for (i = 0; i < desktop_children_count; i++) {
                AtspiAccessible *app = atspi_accessible_get_child_at_index(desktop, i, NULL);