Fixed the problem that virtual dim / popup does not work properly 50/64250/3
authorJi-hoon Lee <dalton.lee@samsung.com>
Wed, 30 Mar 2016 13:30:12 +0000 (22:30 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Thu, 31 Mar 2016 07:03:02 +0000 (16:03 +0900)
Change-Id: I4c9f3fdc35d456012e055adaaf8f0f9cd768a7cd

scl/gwes/efl/sclevents-efl.cpp
scl/gwes/efl/sclgraphics-efl.cpp
scl/gwes/efl/sclwindows-efl.cpp

index 9d0a236..85728c7 100755 (executable)
@@ -58,6 +58,83 @@ Eina_Bool client_message_cb(void *data, int type, void *event);
 Eina_Bool key_pressed(void *data, int type, void *event_info);
 #endif
 
+static sclboolean get_window_rect(const sclwindow window, SclRectangle *rect)
+{
+    SCL_DEBUG();
+    sclboolean ret = FALSE;
+    CSCLUtils *utils = CSCLUtils::get_instance();
+    CSCLWindows *windows = CSCLWindows::get_instance();
+    CSCLContext *context = CSCLContext::get_instance();
+    if (windows && context && utils && rect) {
+        SclWindowContext *window_context = windows->get_window_context(window);
+        sclint scr_w, scr_h;
+        /* get window size */
+        if (window_context && utils->get_screen_resolution(&scr_w, &scr_h)) {
+            switch (context->get_rotation()) {
+                case ROTATION_90_CW:
+                    {
+                        rect->height = window_context->geometry.width;
+                        rect->width = window_context->geometry.height;
+                        rect->y = scr_w - rect->height - window_context->geometry.x;
+                        rect->x = window_context->geometry.y;
+                    }
+                    break;
+                case ROTATION_180:
+                    {
+                        rect->width = window_context->geometry.width;
+                        rect->height = window_context->geometry.height;
+                        rect->x = scr_w - window_context->geometry.x - rect->width;
+                        rect->y = scr_h - window_context->geometry.y - rect->height;
+                    }
+                    break;
+                case ROTATION_90_CCW:
+                    {
+                        rect->height = window_context->geometry.width;
+                        rect->width = window_context->geometry.height;
+                        rect->y = window_context->geometry.x;
+                        rect->x = scr_h - window_context->geometry.y - rect->width;
+                    }
+                    break;
+                default:
+                    {
+                        rect->x = window_context->geometry.x;
+                        rect->y = window_context->geometry.y;
+                        rect->width = window_context->geometry.width;
+                        rect->height = window_context->geometry.height;
+                    }
+                    break;
+            }
+            ret = TRUE;
+        } else {
+            rect->x = rect->y = rect->width = rect->height = 0;
+        }
+    }
+    return ret;
+}
+
+#ifdef WAYLAND
+/* In wayland, root.x / root.y is not available, so need to apply virtual offset
+   when event occurred on a virtual window */
+static void apply_virtual_offset(SclRectangle rect, int *adjustx, int *adjusty)
+{
+    int virtual_offset_x = 0;
+    int virtual_offset_y = 0;
+    SclRectangle base_rect = {0, 0, 0, 0};
+
+    CSCLWindows *windows = CSCLWindows::get_instance();
+    if (windows) {
+        if (get_window_rect(windows->get_base_window(), &base_rect)) {
+            virtual_offset_x = rect.x - base_rect.x;
+            virtual_offset_y = rect.y - base_rect.y;
+        }
+        if (adjustx && adjusty) {
+            *adjustx -= virtual_offset_x;
+            *adjusty -= virtual_offset_y;
+        }
+    }
+}
+#endif
+
 /**
  * Constructor
  */
@@ -114,61 +191,6 @@ void CSCLEventsImplEfl::fini()
     m_key_pressed_handler = NULL;
 }
 
-sclboolean get_window_rect(const sclwindow window, SclRectangle *rect)
-{
-    SCL_DEBUG();
-    sclboolean ret = FALSE;
-    CSCLUtils *utils = CSCLUtils::get_instance();
-    CSCLWindows *windows = CSCLWindows::get_instance();
-    CSCLContext *context = CSCLContext::get_instance();
-    if (windows && context && utils && rect) {
-        SclWindowContext *window_context = windows->get_window_context(window);
-        sclint scr_w, scr_h;
-        /* get window size */
-        utils->get_screen_resolution(&scr_w, &scr_h);
-        if (window_context) {
-            switch (context->get_rotation()) {
-                case ROTATION_90_CW:
-                    {
-                        rect->height = window_context->geometry.width;
-                        rect->width = window_context->geometry.height;
-                        rect->y = scr_w - rect->height - window_context->geometry.x;
-                        rect->x = window_context->geometry.y;
-                    }
-                    break;
-                case ROTATION_180:
-                    {
-                        rect->width = window_context->geometry.width;
-                        rect->height = window_context->geometry.height;
-                        rect->x = scr_w - window_context->geometry.x - rect->width;
-                        rect->y = scr_h - window_context->geometry.y - rect->height;
-                    }
-                    break;
-                case ROTATION_90_CCW:
-                    {
-                        rect->height = window_context->geometry.width;
-                        rect->width = window_context->geometry.height;
-                        rect->y = window_context->geometry.x;
-                        rect->x = scr_h - window_context->geometry.y - rect->width;
-                    }
-                    break;
-                default:
-                    {
-                        rect->x = window_context->geometry.x;
-                        rect->y = window_context->geometry.y;
-                        rect->width = window_context->geometry.width;
-                        rect->height = window_context->geometry.height;
-                    }
-                    break;
-            }
-            ret = TRUE;
-        } else {
-            rect->x = rect->y = rect->width = rect->height = 0;
-        }
-    }
-    return ret;
-}
-
 /**  Here x and y contains "actual" x and y position relative to portrait root window,
      and window_context->width,height contains the window's orientation dependant width and height */
 SclPoint get_rotated_local_coords(sclint x, sclint y, SCLRotation rotation, SclRectangle *rect) {
@@ -301,48 +323,50 @@ Eina_Bool mouse_press(void *data, int type, void *event_info)
                     windows->get_window_rect(window, &(window_context->geometry));
                     if (get_window_rect(window, &rect)) {
 #ifdef WAYLAND
-                        int adjustx = ev->x + rect.x;
-                        int adjusty = ev->y + rect.y;
+                        int root_x = ev->x + rect.x;
+                        int root_y = ev->y + rect.y;
+                        if (window_context->is_virtual) {
+                            apply_virtual_offset(rect, &root_x, &root_y);
+                        }
 #else
-                        int adjustx = ev->root.x;
-                        int adjusty = ev->root.y;
+                        int root_x = ev->root.x;
+                        int root_y = ev->root.y;
 #endif
+                        int adjust_x = root_x;
+                        int adjust_y = root_y;
 
                         SclResParserManager *sclres_manager = SclResParserManager::get_instance();
                         PSclDefaultConfigure default_configure = NULL;
                         if (sclres_manager) {
                             default_configure = sclres_manager->get_default_configure();
                         }
+
                         if (default_configure) {
                             SCLDisplayMode display_mode = context->get_display_mode();
                             if (scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                                adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                                adjustment->apply_touch_offset(
+                                        default_configure->touch_offset_level[display_mode],
+                                        &adjust_x, &adjust_y);
                             }
                         }
 
-                        sclint winwidth = rect.width;
-                        sclint winheight = rect.height;
+                        sclint win_width = rect.width;
+                        sclint win_height = rect.height;
                         if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                            rect.height = winwidth;
-                            rect.width = winheight;
+                            rect.height = win_width;
+                            rect.width = win_height;
                         }
 
+                        /* Check whether will-be-adjusted coordinate is within the window area */
                         sclboolean process_event = FALSE;
-                        if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                            (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
+                        if ((adjust_x >= rect.x && adjust_x <= (rect.x + win_width)) &&
+                            (adjust_y >= rect.y && adjust_y <= (rect.y + win_height))) {
                                 process_event = TRUE;
                         }
-                        if (process_event)
-                        {
-                            // Now convert the global coordinate to appropriate local coordinate
-#ifdef WAYLAND
-                            int root_x = ev->x + rect.x;
-                            int root_y = ev->y + rect.y;
-#else
-                            int root_x = ev->root.x;
-                            int root_y = ev->root.y;
-#endif
-                            SclPoint coords = get_rotated_local_coords(root_x, root_y, context->get_rotation(), &rect);
+                        if (process_event) {
+                            /* Now convert the global coordinate to appropriate local coordinate */
+                            SclPoint coords = get_rotated_local_coords(
+                                    root_x, root_y, context->get_rotation(), &rect);
                             controller->mouse_press(window, coords.x, coords.y, ev->multi.device);
                             mouse_pressed = TRUE;
                             processed = TRUE;
@@ -356,7 +380,8 @@ Eina_Bool mouse_press(void *data, int type, void *event_info)
 
         if (!processed) {
             window = pressed_window;
-            if (get_window_rect(window, &rect)) {
+            SclWindowContext *window_context = windows->get_window_context(window);
+            if (window_context && get_window_rect(window, &rect)) {
                 if (context->get_rotation() == ROTATION_90_CW || context->get_rotation() == ROTATION_90_CCW) {
                     sclint temp = rect.width;
                     rect.width = rect.height;
@@ -367,6 +392,9 @@ Eina_Bool mouse_press(void *data, int type, void *event_info)
 #ifdef WAYLAND
                 int root_x = ev->x + rect.x;
                 int root_y = ev->y + rect.y;
+                if (window_context->is_virtual) {
+                    apply_virtual_offset(rect, &root_x, &root_y);
+                }
 #else
                 int root_x = ev->root.x;
                 int root_y = ev->root.y;
@@ -430,50 +458,51 @@ Eina_Bool mouse_release(void *data, int type, void *event_info)
                         windows->get_window_rect(window, &(window_context->geometry));
                         if (get_window_rect(window, &rect)) {
 #ifdef WAYLAND
-                            int adjustx = ev->x + rect.x;
-                            int adjusty = ev->y + rect.y;
+                            int root_x = ev->x + rect.x;
+                            int root_y = ev->y + rect.y;
+                            if (window_context->is_virtual) {
+                                apply_virtual_offset(rect, &root_x, &root_y);
+                            }
 #else
-                            int adjustx = ev->root.x;
-                            int adjusty = ev->root.y;
+                            int root_x = ev->root.x;
+                            int root_y = ev->root.y;
 #endif
+                            int adjust_x = root_x;
+                            int adjust_y = root_y;
 
                             SclResParserManager *sclres_manager = SclResParserManager::get_instance();
                             PSclDefaultConfigure default_configure = NULL;
                             if (sclres_manager) {
                                 default_configure = sclres_manager->get_default_configure();
                             }
+
                             if (default_configure) {
                                 SCLDisplayMode display_mode = context->get_display_mode();
                                 CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
                                 if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                                    adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                                    adjustment->apply_touch_offset(
+                                            default_configure->touch_offset_level[display_mode],
+                                            &adjust_x, &adjust_y);
                                 }
                             }
 
-                            sclint winwidth = rect.width;
-                            sclint winheight = rect.height;
+                            sclint win_width = rect.width;
+                            sclint win_height = rect.height;
                             if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                                rect.height = winwidth;
-                                rect.width = winheight;
+                                rect.height = win_width;
+                                rect.width = win_height;
                             }
 
+                            /* Check whether will-be-adjusted coordinate is within the window area */
                             sclboolean process_event = FALSE;
-                            if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                                (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
+                            if ((adjust_x >= rect.x && adjust_x <= (rect.x + win_width)) &&
+                                (adjust_y >= rect.y && adjust_y <= (rect.y + win_height))) {
                                     process_event = TRUE;
                             }
-                            if (process_event)
-                            {
+                            if (process_event) {
                                 /* Now convert the global coordinate to appropriate local coordinate */
-#ifdef WAYLAND
-                                int root_x = ev->x + rect.x;
-                                int root_y = ev->y + rect.y;
-#else
-                                int root_x = ev->root.x;
-                                int root_y = ev->root.y;
-#endif
-
-                                SclPoint coords = get_rotated_local_coords(root_x, root_y, context->get_rotation(), &rect);
+                                SclPoint coords = get_rotated_local_coords(
+                                        root_x, root_y, context->get_rotation(), &rect);
                                 controller->mouse_release(window, coords.x, coords.y, ev->multi.device);
                                 processed = TRUE;
                             }
@@ -486,7 +515,8 @@ Eina_Bool mouse_release(void *data, int type, void *event_info)
 
         if (!processed) {
             window = pressed_window;
-            if (get_window_rect(window, &rect)) {
+            SclWindowContext *window_context = windows->get_window_context(window);
+            if (window_context && get_window_rect(window, &rect)) {
                 if (context->get_rotation() == ROTATION_90_CW || context->get_rotation() == ROTATION_90_CCW) {
                     sclint temp = rect.width;
                     rect.width = rect.height;
@@ -497,6 +527,9 @@ Eina_Bool mouse_release(void *data, int type, void *event_info)
 #ifdef WAYLAND
                 int root_x = ev->x + rect.x;
                 int root_y = ev->y + rect.y;
+                if (window_context->is_virtual) {
+                    apply_virtual_offset(rect, &root_x, &root_y);
+                }
 #else
                 int root_x = ev->root.x;
                 int root_y = ev->root.y;
@@ -668,12 +701,18 @@ Eina_Bool mouse_move(void *data, int type, void *event_info)
                         windows->get_window_rect(window, &(window_context->geometry));
                         if (get_window_rect(window, &rect)) {
 #ifdef WAYLAND
-                            int adjustx = ev->x + rect.x;
-                            int adjusty = ev->y + rect.y;
+                            int root_x = ev->x + rect.x;
+                            int root_y = ev->y + rect.y;
+                            if (window_context->is_virtual) {
+                                apply_virtual_offset(rect, &root_x, &root_y);
+                            }
 #else
-                            int adjustx = ev->root.x;
-                            int adjusty = ev->root.y;
+                            int root_x = ev->root.x;
+                            int root_y = ev->root.y;
 #endif
+                            int adjust_x = root_x;
+                            int adjust_y = root_y;
+
                             SclResParserManager *sclres_manager = SclResParserManager::get_instance();
                             PSclDefaultConfigure default_configure = NULL;
                             if (sclres_manager) {
@@ -683,20 +722,22 @@ Eina_Bool mouse_move(void *data, int type, void *event_info)
                                 SCLDisplayMode display_mode = context->get_display_mode();
                                 CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
                                 if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                                    adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                                    adjustment->apply_touch_offset(
+                                            default_configure->touch_offset_level[display_mode],
+                                            &adjust_x, &adjust_y);
                                 }
                             }
 
-                            sclint winwidth = rect.width;
-                            sclint winheight = rect.height;
+                            sclint win_width = rect.width;
+                            sclint win_height = rect.height;
                             if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                                rect.height = winwidth;
-                                rect.width = winheight;
+                                rect.height = win_width;
+                                rect.width = win_height;
                             }
 
                             sclboolean process_event = FALSE;
-                            if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                                (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
+                            if ((adjust_x >= rect.x && adjust_x <= (rect.x + win_width)) &&
+                                (adjust_y >= rect.y && adjust_y <= (rect.y + win_height))) {
                                     process_event = TRUE;
                             }
                             /* Process this event regardless of the coordinate if the top window has the POPUP_GRAB layout style */
@@ -708,18 +749,10 @@ Eina_Bool mouse_move(void *data, int type, void *event_info)
                                     }
                                 }
                             }
-                            if (process_event)
-                            {
+                            if (process_event) {
                                 /* Now convert the global coordinate to appropriate local coordinate */
-#ifdef WAYLAND
-                                int root_x = ev->x + rect.x;
-                                int root_y = ev->y + rect.y;
-#else
-                                int root_x = ev->root.x;
-                                int root_y = ev->root.y;
-#endif
-
-                                SclPoint coords = get_rotated_local_coords(root_x, root_y, context->get_rotation(), &rect);
+                                SclPoint coords = get_rotated_local_coords(
+                                        root_x, root_y, context->get_rotation(), &rect);
                                 controller->mouse_move(window, coords.x, coords.y, ev->multi.device);
                                 processed = TRUE;
                             }
@@ -732,11 +765,15 @@ Eina_Bool mouse_move(void *data, int type, void *event_info)
 
         if (!processed) {
             window = pressed_window;
-            if (get_window_rect(window, &rect)) {
+            SclWindowContext *window_context = windows->get_window_context(window);
+            if (window_context && get_window_rect(window, &rect)) {
                 /* Now convert the global coordinate to appropriate local coordinate */
 #ifdef WAYLAND
                 int root_x = ev->x + rect.x;
                 int root_y = ev->y + rect.y;
+                if (window_context->is_virtual) {
+                    apply_virtual_offset(rect, &root_x, &root_y);
+                }
 #else
                 int root_x = ev->root.x;
                 int root_y = ev->root.y;
index 4df0eb8..f22b4c2 100644 (file)
@@ -795,20 +795,15 @@ CSCLGraphicsImplEfl::draw_rectangle(sclwindow window, const scldrawctx draw_ctx,
             Evas_Object *window_object = (Evas_Object*)window;
             if (window_context->is_virtual) {
                 window_object = static_cast<Evas_Object*>(windows->get_base_window());
-            //    //window_context = windows->get_window_context(windows->get_base_window());
             }
 
             Evas *evas = evas_object_evas_get(window_object);
             Evas_Object *rectobj = evas_object_rectangle_add(evas);
 
-            evas_object_size_hint_weight_set(rectobj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-            elm_win_resize_object_add(window_object, rectobj);
             evas_object_color_set(rectobj, fill_color.r, fill_color.g, fill_color.b, fill_color.a);
 
             evas_object_move(rectobj, pos_x, pos_y);
             evas_object_resize(rectobj, width, height);
-
-//            evas_object_raise(rectobj);
             evas_object_show(rectobj);
 
             object->extracted = FALSE;
index 60c1ed8..8bfd128 100644 (file)
@@ -40,8 +40,6 @@
 
 using namespace scl;
 
-#define USING_DIM_BG
-
 #ifndef WAYLAND
 static Ecore_X_Atom ATOM_WM_CLASS = 0;
 static Ecore_X_Window app_window = 0;
@@ -501,33 +499,6 @@ CSCLWindowsImplEfl::show_window(const sclwindow window, sclboolean queue)
     CSCLContext *context = CSCLContext::get_instance();
     CSCLUtils *utils = CSCLUtils::get_instance();
     if (windows && context && window) {
-#ifdef USING_DIM_BG
-        if (window == windows->get_dim_window()) {
-            Evas_Object *base_window = static_cast<Evas_Object*>(windows->get_base_window());
-            static Evas_Object *dim_bg = NULL;
-            if (dim_bg == NULL) {
-                dim_bg = elm_bg_add(static_cast<Evas_Object*>(windows->get_base_window()));
-                SclColor color;
-                color.r = color.g = color.b = 0;
-                color.a = 102;
-                SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-                if (sclres_manager) {
-                    PSclDefaultConfigure default_configure = sclres_manager->get_default_configure();
-                    if (default_configure)
-                        color = default_configure->dim_color;
-                }
-                evas_object_color_set(dim_bg, color.r, color.g, color.b, color.a);
-                evas_object_data_set(base_window, "dim_bg", (void *)dim_bg);
-            }
-            SclRectangle rect;
-            get_window_rect(windows->get_base_window(), &rect);
-            evas_object_resize(dim_bg, rect.width, rect.height);
-            evas_object_move(dim_bg, 0, 0);
-            evas_object_show(dim_bg);
-            evas_object_layer_set(dim_bg, SHRT_MAX);
-            return;
-        }
-#endif
         SclWindowContext *window_context = windows->get_window_context(window);
         if (!(context->get_hidden_state())) {
             if (window_context) {
@@ -609,14 +580,6 @@ CSCLWindowsImplEfl::hide_window(const sclwindow window,  sclboolean fForce)
     SclWindowContext *window_context = NULL;
 
     if (windows && window) {
-#ifdef USING_DIM_BG
-        if (window == windows->get_dim_window()) {
-            Evas_Object *base_window = static_cast<Evas_Object*>(windows->get_base_window());
-            Evas_Object *dim_bg = (Evas_Object *)evas_object_data_get(base_window, "dim_bg");
-            evas_object_hide(dim_bg);
-            return;
-        }
-#endif
 #ifdef USING_KEY_GRAB
     if (window == windows->get_base_window()) {
         CSCLKeyFocusHandler* focus_handler = CSCLKeyFocusHandler::get_instance();