support transient_for in wayland 69/48569/1
authorMinJeong Kim <minjjj.kim@samsung.com>
Wed, 23 Sep 2015 04:59:45 +0000 (13:59 +0900)
committerMinJeong Kim <minjjj.kim@samsung.com>
Wed, 23 Sep 2015 04:59:45 +0000 (13:59 +0900)
Change-Id: Iec376551cfc5df8f3ea0417781fe20e8759fe260

src/0200_transient_for.c
src/e_test_runner.c
src/e_test_runner.h

index cf636364e37eeaee053b1f503a67463e76716699..0a5b205d681ce775b4566003296cd55b43e93834 100644 (file)
@@ -52,6 +52,11 @@ _tc_pre_run(E_TC *tc)
    res = e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_VIS_CHANGED);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
+   res = e_tc_win_transient_for_set(tc->data->tw_child,
+                                    tc->data->tw_parent,
+                                    EINA_TRUE);
+   EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
+
    return EINA_TRUE;
 
 cleanup:
@@ -135,18 +140,19 @@ cleanup:
 Eina_Bool
 tc_0201_transient_for_raise(E_TC *tc)
 {
-   E_TC_Win *tw, *tw2;
+   E_TC_Win *tw_parent, *tw_child, *tw;
    Eina_Bool res = EINA_FALSE;
-   Eina_List *list = NULL;
+   Eina_List *list = NULL, *l;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE);
 
    res = _tc_pre_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
-   tw = tc->data->tw_parent;
+   tw_parent = tc->data->tw_parent;
+   tw_child = tc->data->tw_child;
 
-   e_test_runner_req_win_stack_set(tc->runner, tw, NULL, EINA_TRUE);
+   e_test_runner_req_win_stack_set(tc->runner, tw_parent, NULL, EINA_TRUE);
 
    res = e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_STACK_RAISE);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
@@ -154,9 +160,15 @@ tc_0201_transient_for_raise(E_TC *tc)
    list = e_test_runner_req_win_info_list_get(tc->runner);
    EINA_SAFETY_ON_NULL_GOTO(list, cleanup);
 
-   tw2 = eina_list_nth(list, 0);
-   EINA_SAFETY_ON_NULL_GOTO(tw2, cleanup);
-   EINA_SAFETY_ON_FALSE_GOTO(tw2->native_win == tw->native_win, cleanup);
+   EINA_LIST_FOREACH(list, l, tw)
+     {
+        if (tw->layer > tw_parent->layer) continue;
+
+        break;
+     }
+
+   EINA_SAFETY_ON_NULL_GOTO(tw, cleanup);
+   EINA_SAFETY_ON_FALSE_GOTO(tw->native_win == tw_child->native_win, cleanup);
 
    res = _tc_post_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
@@ -173,18 +185,19 @@ cleanup:
 Eina_Bool
 tc_0202_transient_for_lower(E_TC *tc)
 {
-   E_TC_Win *tw, *tw2;
+   E_TC_Win *tw_parent, *tw_child, *tw;
    Eina_Bool res = EINA_FALSE;
-   Eina_List *list = NULL;
+   Eina_List *list = NULL, *l;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE);
 
    res = _tc_pre_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
-   tw = tc->data->tw_parent;
+   tw_parent = tc->data->tw_parent;
+   tw_child = tc->data->tw_child;
 
-   e_test_runner_req_win_stack_set(tc->runner, tw, NULL, EINA_FALSE);
+   e_test_runner_req_win_stack_set(tc->runner, tw_parent, NULL, EINA_FALSE);
 
    res = e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_STACK_LOWER);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
@@ -192,9 +205,16 @@ tc_0202_transient_for_lower(E_TC *tc)
    list = e_test_runner_req_win_info_list_get(tc->runner);
    EINA_SAFETY_ON_NULL_GOTO(list, cleanup);
 
-   tw2 = eina_list_last_data_get(list);
-   EINA_SAFETY_ON_NULL_GOTO(tw2, cleanup);
-   EINA_SAFETY_ON_FALSE_GOTO(tw2->native_win == tw->native_win, cleanup);
+   EINA_LIST_REVERSE_FOREACH(list, l, tw)
+     {
+        if (tw->layer < tw_parent->layer) continue;
+        if (tw->native_win == tw_parent->native_win) continue;
+
+        break;
+     }
+
+   EINA_SAFETY_ON_NULL_GOTO(tw, cleanup);
+   EINA_SAFETY_ON_FALSE_GOTO(tw->native_win == tw_child->native_win, cleanup);
 
    res = _tc_post_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
@@ -237,8 +257,8 @@ tc_0203_transient_for_stack_above(E_TC *tc)
      {
         if (tw2->layer > tw->layer) continue;
         if (tw2->layer < tw->layer) break;
-
-        if (tw2->native_win == tw_parent->native_win)
+        if (tw2->native_win == tw_parent->native_win) continue;
+        if (tw2->native_win == tw->native_win)
           {
              if ((tw_above) &&
                  (tw_above->native_win == tw_child->native_win))
@@ -254,6 +274,8 @@ tc_0203_transient_for_stack_above(E_TC *tc)
    res = _tc_post_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
+   tc->passed = EINA_TRUE;
+
 cleanup:
    _tc_shutdown(tc);
    E_FREE_LIST(list, e_tc_win_del);
@@ -310,12 +332,13 @@ tc_0204_transient_for_stack_below(E_TC *tc)
 
         tw_above = tw2;
      }
-
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
    res = _tc_post_run(tc);
    EINA_SAFETY_ON_FALSE_GOTO(res, cleanup);
 
+   tc->passed = EINA_TRUE;
+
 cleanup:
    _tc_shutdown(tc);
    E_FREE_LIST(list, e_tc_win_del);
index e81e1d8117cd5938da1b6c8b1f0a5f8c3907fcd7..b5a8759a470fc76e982285e4c73147f985d458b3 100644 (file)
@@ -3,6 +3,9 @@
 int _log_dom = -1;
 
 #if HAVE_WAYLAND
+struct tizen_policy *tizen_policy = NULL;
+struct tizen_surface *tizen_surface = NULL;
+
 static void
 _e_test_runner_cb_resource_id(void *data,
                               struct tizen_resource *tizen_resource EINA_UNUSED,
@@ -15,7 +18,7 @@ _e_test_runner_cb_resource_id(void *data,
    elm_exit();
 }
 
-static const struct tizen_resource_listener _ecore_tizen_resource_listener =
+static const struct tizen_resource_listener _tizen_resource_listener =
 {
    _e_test_runner_cb_resource_id,
 };
@@ -33,7 +36,6 @@ _e_test_runner_window_id_get(Evas_Object *elm_win)
    Ecore_Wl_Global *global;
    struct wl_registry *registry;
 
-   struct tizen_surface *tizen_surface = NULL;
    struct tizen_resource *tizen_resource = NULL;
 
    wlwin = elm_win_wl_window_get(elm_win);
@@ -42,33 +44,35 @@ _e_test_runner_window_id_get(Evas_Object *elm_win)
    surf = ecore_wl_window_surface_get(wlwin);
    if (!surf) return 0;
 
-   registry = ecore_wl_registry_get();
-   globals = ecore_wl_globals_get();
+   if (!tizen_surface)
+     {
+        registry = ecore_wl_registry_get();
+        globals = ecore_wl_globals_get();
 
-   if (!registry || !globals) return 0;
+        if (!registry || !globals) return 0;
 
-   EINA_INLIST_FOREACH(globals, global)
-     {
-        if (!strcmp(global->interface, "tizen_surface"))
+        EINA_INLIST_FOREACH(globals, global)
           {
-             tizen_surface =
-                wl_registry_bind(registry, global->id,
-                                 &tizen_surface_interface, 1);
-             break;
+             if (!strcmp(global->interface, "tizen_surface"))
+               {
+                  tizen_surface =
+                     wl_registry_bind(registry, global->id,
+                                      &tizen_surface_interface, 1);
+                  break;
+               }
           }
-     }
 
-   if (!tizen_surface) return 0;
+        if (!tizen_surface) return 0;
+     }
 
    tizen_resource = tizen_surface_get_tizen_resource(tizen_surface, surf);
    if (!tizen_resource) return 0;
    tizen_resource_add_listener(tizen_resource,
-                               &_ecore_tizen_resource_listener, &id);
+                               &_tizen_resource_listener, &id);
 
    elm_run();
 
    if (tizen_resource) tizen_resource_destroy(tizen_resource);
-   if (tizen_surface) tizen_surface_destroy(tizen_surface);
 
    return id;
 #endif
@@ -516,6 +520,51 @@ e_tc_win_hide(E_TC_Win *tw)
    evas_object_hide(tw->elm_win);
 }
 
+Eina_Bool
+e_tc_win_transient_for_set(E_TC_Win *tw_child, E_TC_Win *tw_parent, Eina_Bool set)
+{
+#if HAVE_WAYLAND
+   Eina_Inlist *globals;
+   Ecore_Wl_Global *global;
+   struct wl_registry *registry;
+
+   if (!tizen_policy)
+     {
+        registry = ecore_wl_registry_get();
+        globals = ecore_wl_globals_get();
+
+        if (!registry || !globals) return EINA_FALSE;
+
+        EINA_INLIST_FOREACH(globals, global)
+          {
+             if (!strcmp(global->interface, "tizen_policy"))
+               {
+                  tizen_policy =
+                     wl_registry_bind(registry, global->id,
+                                      &tizen_policy_interface, 1);
+               }
+          }
+
+        if (!tizen_policy) return EINA_FALSE;
+     }
+
+   if (set)
+     tizen_policy_set_transient_for(tizen_policy,
+                                    tw_child->native_win,
+                                    tw_parent->native_win);
+   else
+     tizen_policy_unset_transient_for(tizen_policy,
+                                    tw_child->native_win);
+#else
+   if (set)
+     ecore_x_icccm_transient_for_set(tw_child->native_win,
+                                     tw_parent->native_win);
+   else
+     ecore_x_icccm_transient_for_unset(tw_child->native_win);
+#endif
+   return EINA_TRUE;
+}
+
 static E_TC *
 _e_tc_add(unsigned int num,
           const char *name,
@@ -584,6 +633,14 @@ _e_test_runner_shutdown(E_Test_Runner *runner)
      {
         E_FREE(tc);
      }
+
+#if HAVE_WAYLAND
+   if (tizen_surface) tizen_surface_destroy(tizen_surface);
+   if (tizen_policy) tizen_policy_destroy(tizen_policy);
+
+   tizen_surface = NULL;
+   tizen_policy = NULL;
+#endif
 }
 
 static void
index 3460f1503c6a9d7168de1590034afa07c1eb2514..e897c6a75c62dd0ee21f248575f6d40cc6987a09 100644 (file)
@@ -6,9 +6,11 @@
 #include <Elementary.h>
 
 #if HAVE_WAYLAND
-#include <Ecore_Wayland.h>
-#include <wayland-client.h>
-#include <tizen-extension-client-protocol.h>
+ #include <Ecore_Wayland.h>
+ #include <wayland-client.h>
+ #include <tizen-extension-client-protocol.h>
+#else
+ #include <Ecore_X.h>
 #endif
 
 extern int _log_dom;
@@ -134,6 +136,7 @@ void       e_tc_win_del(E_TC_Win *tw);
 void       e_tc_win_geom_update(E_TC_Win *tw);
 void       e_tc_win_show(E_TC_Win *tw);
 void       e_tc_win_hide(E_TC_Win *tw);
+Eina_Bool  e_tc_win_transient_for_set(E_TC_Win *tw_parent, E_TC_Win *tw_child, Eina_Bool set);
 
 /* test cases */
 Eina_Bool  tc_0000_base_pass(E_TC *tc);