Fix window hide/show() using withdrawn_set() 07/13707/2 accepted/tizen/ivi/20131214.022702 accepted/tizen/mobile/20131216.220210 submit/tizen/20131213.205131
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Thu, 12 Dec 2013 15:36:53 +0000 (16:36 +0100)
committerRafael Antognolli <rafael.antognolli@intel.com>
Fri, 13 Dec 2013 20:08:34 +0000 (18:08 -0200)
Modified to make current version of IVI-Shell work.

Bug-Tizen: https://bugs.tizen.org/jira/browse/TIVI-2048
Bug-Upstream: https://phab.enlightenment.org/T155

Co-Authored-by: Rafael Antognolli <rafael.antognolli@intel.com>
Change-Id: I2dbd03a4b2362df4535f7705f1afffec6928d8db
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
src/lib/ecore_evas/ecore_evas_wayland_egl.c
src/lib/ecore_evas/ecore_evas_wayland_shm.c

index 2b31675..1a2ca6a 100644 (file)
@@ -95,12 +95,14 @@ static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer);
 static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify);
 static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max);
 static void _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full);
+static void _ecore_evas_wl_withdrawn_set(Ecore_Evas *ee, int val);
 static void _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore);
 static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
 static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
 static int _ecore_evas_wl_render(Ecore_Evas *ee);
 static void _ecore_evas_wl_screen_geometry_get(const Ecore_Evas *ee __UNUSED__, int *x, int *y, int *w, int *h);
 static void _ecore_evas_wl_screen_dpi_get(const Ecore_Evas *ee __UNUSED__, int *xdpi, int *ydpi);
+static void _ecore_evas_wl_frame_callback_clean(Ecore_Evas *ee);
 static Eina_Bool _ecore_evas_wl_cb_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *event);
 static Eina_Bool _ecore_evas_wl_cb_mouse_out(void *data __UNUSED__, int type __UNUSED__, void *event);
 static Eina_Bool _ecore_evas_wl_cb_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
@@ -166,7 +168,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    _ecore_evas_wl_maximized_set,
    _ecore_evas_wl_fullscreen_set,
    NULL, // func avoid_damage set
-   NULL, // func withdrawn set
+   _ecore_evas_wl_withdrawn_set,
    NULL, // func sticky set
    _ecore_evas_wl_ignore_events_set,
    _ecore_evas_wl_alpha_set,
@@ -587,6 +589,7 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
         if ((ee->prop.title) && (ee->engine.wl.win->shell_surface))
           wl_shell_surface_set_title(ee->engine.wl.win->shell_surface, 
                                      ee->prop.title);
+
      }
 
    if (ee->engine.wl.frame)
@@ -611,6 +614,9 @@ _ecore_evas_wl_show(Ecore_Evas *ee)
         /*   printf("Failed to get a Surface from Ecore_Wl\n"); */
      }
 
+   /* force an update to push events, especially useful for wayland_egl */
+   evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
    ee->visible = 1;
    if (ee->func.fn_show) ee->func.fn_show(ee);
 }
@@ -636,6 +642,7 @@ _ecore_evas_wl_hide(Ecore_Evas *ee)
 
    ee->visible = 0;
    ee->should_be_visible = 0;
+   _ecore_evas_wl_frame_callback_clean (ee);
 
    if (ee->func.fn_hide) ee->func.fn_hide(ee);
 }
@@ -791,6 +798,17 @@ _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full)
      ee->func.fn_state_change(ee);
 }
 
+static void
+_ecore_evas_wl_withdrawn_set(Ecore_Evas *ee, int val)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (val)
+     ecore_evas_hide(ee);
+   else
+     ecore_evas_show(ee);
+}
+
 static void 
 _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore)
 {
@@ -852,19 +870,33 @@ static const struct wl_callback_listener frame_listener = {
 };
 
 static void
-_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t time __UNUSED__)
+_ecore_evas_wl_frame_callback_clean(Ecore_Evas *ee)
 {
-   Ecore_Evas *ee = data;
    Ecore_Wl_Window *win = ee->engine.wl.win;
 
+   if (!win->frame_pending)
+     return;
+   wl_callback_destroy(win->frame_callback);
    win->frame_callback = NULL;
    win->frame_pending = EINA_FALSE;
-   wl_callback_destroy(callback);
+}
 
-   if (win->surface)
+static void
+_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback __UNUSED__, uint32_t time __UNUSED__)
+{
+   Ecore_Evas *ee = data;
+   Ecore_Wl_Window *win = NULL;
+
+   if (!ee) return;
+
+   _ecore_evas_wl_frame_callback_clean(ee);
+
+   if (!(win = ee->engine.wl.win)) return;
+
+   if (ecore_wl_window_surface_get(win))
      {
-        win->frame_callback =
-           wl_surface_frame(win->surface);
+       win->frame_callback =
+           wl_surface_frame(ecore_wl_window_surface_get(win));
         wl_callback_add_listener(win->frame_callback,
                                  &frame_listener, ee);
      }
@@ -877,7 +909,10 @@ _ecore_evas_wl_render(Ecore_Evas *ee)
 
    if (!ee) return 0;
    if (!ee->visible)
-     evas_norender(ee->evas);
+     {
+       evas_norender(ee->evas);
+       return 0;
+     }
    else
      {
         Eina_List *ll = NULL, *updates = NULL;
index 65ef1ca..3dfa4fe 100644 (file)
@@ -101,6 +101,7 @@ static void _ecore_evas_wl_layer_set(Ecore_Evas *ee, int layer);
 static void _ecore_evas_wl_iconified_set(Ecore_Evas *ee, int iconify);
 static void _ecore_evas_wl_maximized_set(Ecore_Evas *ee, int max);
 static void _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full);
+static void _ecore_evas_wl_withdrawn_set(Ecore_Evas *ee, int val);
 static void _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore);
 static void _ecore_evas_wl_alpha_set(Ecore_Evas *ee, int alpha);
 static void _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent);
@@ -111,6 +112,7 @@ static void _ecore_evas_wl_ensure_pool_size(Ecore_Evas *ee, int w, int h);
 static struct wl_shm_pool *_ecore_evas_wl_shm_pool_create(int size, void **data);
 
 static void _ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm EINA_UNUSED);
+static void _ecore_evas_wl_frame_callback_clean(Ecore_Evas *ee);
 
 static void _ecore_evas_wl_buffer_new(Ecore_Evas *ee, struct wl_shm_pool *pool);
 
@@ -184,7 +186,7 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
    _ecore_evas_wl_maximized_set,
    _ecore_evas_wl_fullscreen_set,
    NULL, // func avoid_damage set
-   NULL, // func withdrawn set
+   _ecore_evas_wl_withdrawn_set,
    NULL, // func sticky set
    _ecore_evas_wl_ignore_events_set,
    _ecore_evas_wl_alpha_set,
@@ -699,6 +701,7 @@ _ecore_evas_wl_hide(Ecore_Evas *ee)
 
    munmap(ee->engine.wl.pool_data, ee->engine.wl.pool_size);
 
+
    einfo = (Evas_Engine_Info_Wayland_Shm *)evas_engine_info_get(ee->evas);
    if ((einfo) && (einfo->info.dest))
      {
@@ -706,10 +709,12 @@ _ecore_evas_wl_hide(Ecore_Evas *ee)
         evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
      }
 
-   ecore_wl_window_hide(ee->engine.wl.win);
+   if (ee->engine.wl.win)
+      ecore_wl_window_hide(ee->engine.wl.win);
 
    ee->visible = 0;
    ee->should_be_visible = 0;
+   _ecore_evas_wl_frame_callback_clean (ee);
 
    if (ee->func.fn_hide) ee->func.fn_hide(ee);
 }
@@ -864,6 +869,17 @@ _ecore_evas_wl_fullscreen_set(Ecore_Evas *ee, int full)
      ee->func.fn_state_change(ee);
 }
 
+static void
+_ecore_evas_wl_withdrawn_set(Ecore_Evas *ee, int val)
+{
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (val)
+     ecore_evas_hide(ee);
+   else
+     ecore_evas_show(ee);
+}
+
 static void 
 _ecore_evas_wl_ignore_events_set(Ecore_Evas *ee, int ignore)
 {
@@ -962,7 +978,19 @@ _ecore_evas_wl_transparent_set(Ecore_Evas *ee, int transparent)
 }
 
 static void
-_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t tm EINA_UNUSED)
+_ecore_evas_wl_frame_callback_clean(Ecore_Evas *ee)
+{
+   Ecore_Wl_Window *win = ee->engine.wl.win;
+
+   if (!win->frame_pending)
+     return;
+   wl_callback_destroy(win->frame_callback);
+   win->frame_callback = NULL;
+   win->frame_pending = EINA_FALSE;
+}
+
+static void
+_ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback EINA_UNUSED, uint32_t tm EINA_UNUSED)
 {
    Ecore_Evas *ee = data;
    Ecore_Wl_Window *win = NULL;
@@ -970,9 +998,7 @@ _ecore_evas_wl_frame_complete(void *data, struct wl_callback *callback, uint32_t
    if (!ee) return;
    if (!(win = ee->engine.wl.win)) return;
 
-   win->frame_callback = NULL;
-   win->frame_pending = EINA_FALSE;
-   wl_callback_destroy(callback);
+   _ecore_evas_wl_frame_callback_clean(ee);
 
    if (win->surface)
      {