Modified to support inputmode changing for popup windows 06/22506/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 28 Feb 2014 12:16:23 +0000 (21:16 +0900)
committershoum.chen@samsung.com <shoum.chen@samsung.com>
Wed, 4 Jun 2014 22:00:44 +0000 (18:00 -0400)
Change-Id: I3ab6d0a4c7e9d754cae71ed3b72e936417559e35

scl/include/sclconfig.h
scl/include/scleventcallback.h
scl/include/sclui.h
scl/include/scluiimpl.h
scl/sclcontroller.cpp
scl/sclui.cpp
scl/scluiimpl.cpp
scl/sclwindows.cpp

index 70cf752..87d35ac 100644 (file)
@@ -333,9 +333,10 @@ typedef enum _SCLHighlightNavigationDirection {
 
 /**@brief  SCL Notification to ISEs */
 typedef enum _SCLUINotiType {
-    SCL_UINOTITYPE_POPUP_OPEN,
-    SCL_UINOTITYPE_POPUP_CLOSE,
-    SCL_UINOTITYPE_POPUP_CLOSE_TIMEOUT, // The layout of popup window will be passed as etc_info data
+    SCL_UINOTITYPE_POPUP_OPENING,
+    SCL_UINOTITYPE_POPUP_OPENED,
+    SCL_UINOTITYPE_POPUP_CLOSING,
+    SCL_UINOTITYPE_POPUP_CLOSED,
     SCL_UINOTITYPE_GESTURE_FLICK,
     SCL_UINOTITYPE_SHIFT_STATE_CHANGE,
     SCL_UINOTITYPE_INPUT_MODE_CHANGE,
index c3bde76..08f2611 100644 (file)
@@ -49,17 +49,26 @@ struct SclNotiDesc {
     SclUIEventDesc *ui_event_desc;
 };
 
-struct SclNotiPopupOpenDesc : SclNotiDesc {
+struct SclNotiPopupOpeningDesc : SclNotiDesc {
     const char *input_mode;
-}; // SCL_UINOTITYPE_POPUP_OPEN
+}; // SCL_UINOTITYPE_POPUP_OPENING
 
-struct SclNotiPopupCloseDesc : SclNotiDesc {
+struct SclNotiPopupOpenedDesc : SclNotiDesc {
+    sclwindow window;
     const char *input_mode;
-}; // SCL_UINOTITYPE_POPUP_CLOSE
+}; // SCL_UINOTITYPE_POPUP_OPENED
 
-struct SclNotiPopupCloseTimeoutDesc : SclNotiDesc {
+struct SclNotiPopupClosingDesc : SclNotiDesc {
+    sclwindow window;
     const char *input_mode;
-}; // SCL_UINOTITYPE_POPUP_CLOSE_TIMEOUT
+    sclboolean timed_out;
+}; // SCL_UINOTITYPE_POPUP_CLOSING
+
+struct SclNotiPopupClosedDesc : SclNotiDesc {
+    sclwindow window;
+    const char *input_mode;
+    sclboolean timed_out;
+}; // SCL_UINOTITYPE_POPUP_CLOSED
 
 struct SclNotiGestureFlickDesc : SclNotiDesc {
     SCLDragType drag_type;
index fe325fe..2126edc 100644 (file)
@@ -111,6 +111,21 @@ public:
     const sclchar* get_input_mode();
 
     /**
+     * @brief This API request SCL library to change the given popup window's input mode
+     * @param[in] window the handle for the popup window that we want to change the input mode
+     * @param[in] input_mode the name of the desired input mode
+     * @return non-zero value is returned when successful
+     */
+    sclboolean set_popup_input_mode(sclwindow window, const sclchar *input_mode);
+
+    /**
+     * @brief This API retrieves the current input mode
+     * @param[in] window the handle for the popup window that we want to retrieve the input mode
+     * @return a string pointer that indicates the name of current input mode
+     */
+    const sclchar* get_popup_input_mode(sclwindow window);
+
+    /**
      * @brief This API request SCL library to suspend screen updates
      * @param[in] pend whether to suspend screen updates
      */
index 74c91a3..52afeab 100644 (file)
@@ -56,6 +56,8 @@ public:
 
     sclboolean set_input_mode(const sclchar *input_mode);
     const sclchar* get_input_mode();
+    sclboolean set_popup_input_mode(sclwindow window, const sclchar *input_mode);
+    const sclchar* get_popup_input_mode(sclwindow window);
 
     void set_update_pending(sclboolean pend);
 
index 3fbad63..e8e9c22 100644 (file)
@@ -534,10 +534,10 @@ CSCLController::process_button_pressed_event(sclwindow window, sclint x, sclint
                 }
                 switch (coordinate->popup_type) {
                 case POPUP_TYPE_BTN_PRESS_POPUP_DRAG: {
-                    SclNotiPopupOpenDesc desc;
+                    SclNotiPopupOpeningDesc desc;
                     desc.ui_event_desc = &key_event_desc;
                     desc.input_mode = coordinate->popup_input_mode[SCL_DRAG_STATE_NONE];
-                    if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPEN, &desc)) {
+                    if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENING, &desc)) {
                         sclint popup_input_mode = sclres_manager->get_inputmode_id(desc.input_mode);
                         SCLDisplayMode display_mode = context->get_display_mode();
                         /* FIXME */
@@ -567,7 +567,8 @@ CSCLController::process_button_pressed_event(sclwindow window, sclint x, sclint
                                 SclWindowOpener opener;
                                 opener.window = window;
                                 opener.key = key_index;
-                                windows->open_popup(opener,
+
+                                sclwindow popup_window = windows->open_popup(opener,
                                     popupRect,
                                     popup_input_mode,
                                     popupLayoutId,
@@ -579,6 +580,12 @@ CSCLController::process_button_pressed_event(sclwindow window, sclint x, sclint
                                     sclres_input_mode_configure[popup_input_mode].timeout
                                     );
 
+                                SclNotiPopupOpenedDesc opened_desc;
+                                opened_desc.ui_event_desc = &key_event_desc;
+                                opened_desc.input_mode = desc.input_mode;
+                                opened_desc.window = popup_window;
+                                handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENED, &opened_desc);
+
                                 windows->hide_window(windows->get_magnifier_window());
                                 /* FIXME : The parent key should be turned back to NORMAL state when RELEASED,
                                     in case of POPUP_TYPE_BTN_PRESS_POPUP_DRAG type. Temporariliy setting NORMAL here. */
@@ -828,10 +835,10 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
                         popupRect.x = coordinate->x + coordinate->popup_relative_x + baseWndRect.x;
                         popupRect.y = coordinate->y + coordinate->popup_relative_y + baseWndRect.y;
 
-                        SclNotiPopupOpenDesc desc;
+                        SclNotiPopupOpeningDesc desc;
                         desc.ui_event_desc = &key_event_desc;
                         desc.input_mode = coordinate->popup_input_mode[SCL_DRAG_STATE_NONE];
-                        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPEN, &desc)) {
+                        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENING, &desc)) {
                             sclint popup_input_mode = sclres_manager->get_inputmode_id(desc.input_mode);
                             SCLDisplayMode display_mode = context->get_display_mode();
                             /* FIXME */
@@ -855,7 +862,8 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
                                     SclWindowOpener opener;
                                     opener.window = window;
                                     opener.key = key_index;
-                                    windows->open_popup(
+
+                                    sclwindow popup_window = windows->open_popup(
                                         opener,
                                         popupRect,
                                         popup_input_mode,
@@ -868,6 +876,12 @@ CSCLController::process_button_long_pressed_event(sclwindow window, sclbyte key_
                                         sclres_input_mode_configure[popup_input_mode].timeout
                                         );
 
+                                    SclNotiPopupOpenedDesc opened_desc;
+                                    opened_desc.ui_event_desc = &key_event_desc;
+                                    opened_desc.input_mode = desc.input_mode;
+                                    opened_desc.window = popup_window;
+                                    handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENED, &opened_desc);
+
                                     windows->hide_window(windows->get_magnifier_window());
                                     _play_tts_for_input_mode_name(popup_input_mode);
                                     ret = TRUE;
@@ -1815,7 +1829,7 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                         SCLDragState dragstate = context->get_cur_drag_state(touch_id);
                         sclint popup_input_mode = NOT_USED;
 
-                        SclNotiPopupOpenDesc desc;
+                        SclNotiPopupOpeningDesc desc;
                         desc.ui_event_desc = &key_event_desc;
 
                         if (scl_check_arrindex(dragstate, SCL_DRAG_STATE_MAX)) {
@@ -1827,7 +1841,7 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                                 desc.input_mode = coordinate->popup_input_mode[SCL_DRAG_STATE_NONE];
                             }
                         }
-                        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPEN, &desc)) {
+                        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENING, &desc)) {
                             popup_input_mode = sclres_manager->get_inputmode_id(desc.input_mode);
                             SCLDisplayMode display_mode = context->get_display_mode();
                             /* FIXME */
@@ -1872,7 +1886,8 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                                     SclWindowOpener opener;
                                     opener.window = window;
                                     opener.key = key_index;
-                                    windows->open_popup(
+
+                                    sclwindow popup_window = windows->open_popup(
                                         opener,
                                         popupRect,
                                         popup_input_mode,
@@ -1885,6 +1900,12 @@ CSCLController::process_button_release_event(sclwindow window, sclint x, sclint
                                         sclres_input_mode_configure[popup_input_mode].timeout
                                         );
 
+                                    SclNotiPopupOpenedDesc opened_desc;
+                                    opened_desc.ui_event_desc = &key_event_desc;
+                                    opened_desc.input_mode = desc.input_mode;
+                                    opened_desc.window = popup_window;
+                                    handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENED, &opened_desc);
+
                                     windows->hide_window(windows->get_magnifier_window());
                                     _play_tts_for_input_mode_name(popup_input_mode);
                                 }
@@ -3310,15 +3331,16 @@ CSCLController::timer_event(const scl32 data)
 
             sclwindow popup_window = SCLWINDOW_INVALID;
 
-            SclNotiPopupOpenDesc desc;
+            SclNotiPopupOpeningDesc desc;
             desc.ui_event_desc = NULL;
             desc.input_mode = SCL_LAYOUT_AUTOPOPUP_NAME;
             if (SCL_EVENT_PASS_ON ==
-                handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPEN, &desc)) {
+                handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENING, &desc)) {
                     /* Currently, window does not support virtual window */
                     SclWindowOpener opener;
                     opener.window = window;
                     opener.key = keyIndex;
+
                     popup_window = windows->open_popup(
                         opener,
                         rect,
@@ -3327,6 +3349,12 @@ CSCLController::timer_event(const scl32 data)
                         FALSE,
                         FALSE
                         );
+
+                    SclNotiPopupOpenedDesc opened_desc;
+                    opened_desc.ui_event_desc = NULL;
+                    opened_desc.input_mode = desc.input_mode;
+                    opened_desc.window = popup_window;
+                    handler->on_event_notification(SCL_UINOTITYPE_POPUP_OPENED, &opened_desc);
             }
 
             windows->hide_window(windows->get_magnifier_window());
@@ -3464,9 +3492,11 @@ CSCLController::timer_event(const scl32 data)
     }
     break;
     case SCL_TIMER_POPUP_TIMEOUT: {
-        SclNotiPopupCloseTimeoutDesc desc;
+        SclNotiPopupClosingDesc desc;
         desc.ui_event_desc = NULL;
         desc.input_mode = NULL;
+        desc.timed_out = TRUE;
+
         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
         CSCLWindows *windows = CSCLWindows::get_instance();
         if (windows && sclres_manager) {
@@ -3481,8 +3511,14 @@ CSCLController::timer_event(const scl32 data)
             }
         }
 
-        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_CLOSE_TIMEOUT, &desc)) {
+        if (SCL_EVENT_PASS_ON == handler->on_event_notification(SCL_UINOTITYPE_POPUP_CLOSING, &desc)) {
             windows->close_all_popups();
+
+            SclNotiPopupClosedDesc closed_desc;
+            closed_desc.ui_event_desc = desc.ui_event_desc;
+            closed_desc.input_mode = desc.input_mode;
+            closed_desc.timed_out = desc.timed_out;
+            handler->on_event_notification(SCL_UINOTITYPE_POPUP_CLOSED, &desc);
         }
         events->destroy_timer(id);
         return FALSE;
index 7cdfe8c..614bdcc 100644 (file)
@@ -103,6 +103,54 @@ CSCLUI::set_input_mode(const sclchar *input_mode)
 }
 
 /**
+ * Returns the current input mode
+ */
+const sclchar*
+CSCLUI::get_input_mode()
+{
+    const sclchar *ret = NULL;
+
+    if (m_impl) {
+        ret = m_impl->get_input_mode();
+    }
+
+    return ret;
+}
+
+/**
+ * Sets the given popup window's input mode to the given mode
+ * @Usage
+ * gCore->set_input_mode("INPUT_MODE_SYMBOL");
+ */
+sclboolean
+CSCLUI::set_popup_input_mode(sclwindow window, const sclchar *input_mode)
+{
+    sclboolean ret = FALSE;
+
+    if (m_impl) {
+        ret = m_impl->set_popup_input_mode(window, input_mode);
+    }
+
+    return ret;
+}
+
+/**
+ * Returns the given popup window's input mode
+ */
+const sclchar*
+CSCLUI::get_popup_input_mode(sclwindow window)
+{
+    const sclchar *ret = NULL;
+
+    if (m_impl) {
+        ret = m_impl->get_popup_input_mode(window);
+    }
+
+    return ret;
+}
+
+
+/**
  * Sets the current rotation
  */
 sclboolean
@@ -148,23 +196,6 @@ CSCLUI::get_display_mode()
 }
 
 /**
- * Returns the current input mode
- */
-const sclchar*
-CSCLUI::get_input_mode()
-{
-    const sclchar *ret = NULL;
-
-    if (m_impl) {
-        ret = m_impl->get_input_mode();
-    }
-
-    return ret;
-}
-
-
-
-/**
  * Sets a private key to the current context
  * The other properties except given parameters will keep to the orginal value.
  * @Usage
index 7e242f3..d8142d9 100644 (file)
@@ -219,6 +219,103 @@ CSCLUIImpl::set_input_mode(const sclchar *input_mode)
 }
 
 /**
+ * Returns the current input mode
+ */
+const sclchar*
+CSCLUIImpl::get_input_mode()
+{
+    SCL_DEBUG();
+
+    const sclchar *ret = NULL;
+    if (m_initialized) {
+        CSCLContext *context = CSCLContext::get_instance();
+        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+        if (context && sclres_manager) {
+            scl8 inputmode_id = context->get_input_mode();
+            ret = sclres_manager->get_inputmode_name(inputmode_id);
+        }
+    }
+    return ret;
+}
+
+
+/**
+ * Sets the given popup window's input mode to the given mode
+ * @Usage
+ * gCore->set_input_mode("INPUT_MODE_SYMBOL");
+ */
+sclboolean
+CSCLUIImpl::set_popup_input_mode(sclwindow window, const sclchar *input_mode)
+{
+    SCL_DEBUG();
+    SCL_DEBUG_ELAPASED_TIME_START();
+
+    sclboolean ret = FALSE;
+
+    if (m_initialized) {
+        CSCLWindows *windows = CSCLWindows::get_instance();
+        CSCLResourceCache *cache = CSCLResourceCache::get_instance();
+        CSCLContext *context = CSCLContext::get_instance();
+
+        scl8 mode = NOT_USED;
+        sclshort layout = NOT_USED;
+        SclWindowContext *winctx = NULL;
+
+        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+        if (sclres_manager && windows && context) {
+            SCLDisplayMode display_mode = context->get_display_mode();
+            PSclInputModeConfigure sclres_input_mode_configure = sclres_manager->get_input_mode_configure_table();
+            mode = sclres_manager->get_inputmode_id(input_mode);
+            winctx = windows->get_window_context(window);
+            if (sclres_input_mode_configure &&
+                scl_check_arrindex(mode, MAX_SCL_INPUT_MODE) &&
+                scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
+                    layout = sclres_manager->get_layout_id(sclres_input_mode_configure[mode].layouts[display_mode]);
+            }
+        }
+
+        if (cache && windows && winctx) {
+            if (mode != NOT_USED && mode != winctx->inputmode && layout != NOT_USED) {
+                winctx->inputmode = mode;
+                winctx->layout = layout;
+                cache->recompute_layout(window);
+                windows->update_window(window);
+                ret = TRUE;
+            }
+        }
+    }
+
+    SCL_DEBUG_ELAPASED_TIME_END();
+    return ret;
+}
+
+/**
+ * Returns the given window's input mode
+ */
+const sclchar*
+CSCLUIImpl::get_popup_input_mode(sclwindow window)
+{
+    SCL_DEBUG();
+
+    const sclchar *ret = NULL;
+
+    if (m_initialized) {
+        CSCLWindows *windows = CSCLWindows::get_instance();
+        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+        if (windows && sclres_manager) {
+            SclWindowContext *winctx = windows->get_window_context(window);
+            if (winctx) {
+                if (scl_check_arrindex(winctx->inputmode, MAX_SCL_INPUT_MODE)) {
+                    ret = sclres_manager->get_inputmode_name(winctx->inputmode);
+                }
+            }
+        }
+    }
+
+    return ret;
+}
+
+/**
  * Sets the current rotation
  */
 sclboolean
@@ -292,28 +389,6 @@ CSCLUIImpl::get_display_mode()
 }
 
 /**
- * Returns the current input mode
- */
-const sclchar*
-CSCLUIImpl::get_input_mode()
-{
-    SCL_DEBUG();
-
-    const sclchar *ret = NULL;
-    if (m_initialized) {
-        CSCLContext *context = CSCLContext::get_instance();
-        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-        if (context && sclres_manager) {
-            scl8 inputmode_id = context->get_input_mode();
-            ret = sclres_manager->get_inputmode_name(inputmode_id);
-        }
-    }
-    return ret;
-}
-
-
-
-/**
  * Sets a private key to the current context
  * The other properties except given parameters will keep to the orginal value.
  * @Usage
index 5b14a94..b5d3aaf 100644 (file)
@@ -152,7 +152,7 @@ sclwindow CSCLWindows::open_popup(const SclWindowOpener opener, const SclRectang
             }
         }
 
-        sclwindow window = create_window(opener, geometry, inputmode, layout, popup_type, is_virtual, img_offset_x, img_offset_y, timeout);
+        window = create_window(opener, geometry, inputmode, layout, popup_type, is_virtual, img_offset_x, img_offset_y, timeout);
         events->destroy_timer(SCL_TIMER_POPUP_TIMEOUT);
         if (timeout > 0) {
             events->create_timer(SCL_TIMER_POPUP_TIMEOUT, timeout, layout);