From 636114eb7c7925e71a8e29ce0e88f753270fb50f Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Fri, 6 Dec 2013 09:49:31 +0100 Subject: [PATCH] Fix window hide/show() using withdrawn_set() Bug-Tizen: https://bugs.tizen.org/jira/browse/TIVI-2048 Bug-Upstream: https://phab.enlightenment.org/T155 Co-Authored-by: Rafael Antognolli Change-Id: I056aa78214f1e9be20870c8fa04c3160b163ec7a Signed-off-by: Manuel Bachmann --- src/lib/ecore_evas/ecore_evas_wayland_egl.c | 60 +++++++++++++++++++++-------- src/lib/ecore_evas/ecore_evas_wayland_shm.c | 42 ++++++++++++++------ 2 files changed, 74 insertions(+), 28 deletions(-) diff --git a/src/lib/ecore_evas/ecore_evas_wayland_egl.c b/src/lib/ecore_evas/ecore_evas_wayland_egl.c index a438e1c..89abd8e 100644 --- a/src/lib/ecore_evas/ecore_evas_wayland_egl.c +++ b/src/lib/ecore_evas/ecore_evas_wayland_egl.c @@ -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, @@ -579,14 +581,6 @@ _ecore_evas_wl_show(Ecore_Evas *ee) { ecore_wl_window_show(ee->engine.wl.win); ecore_wl_window_update_size(ee->engine.wl.win, ee->w, ee->h); - ecore_wl_window_buffer_attach(ee->engine.wl.win, NULL, 0, 0); - - if ((ee->prop.clas) && (ee->engine.wl.win->shell_surface)) - wl_shell_surface_set_class(ee->engine.wl.win->shell_surface, - ee->prop.clas); - 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 +605,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 +633,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 +789,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 +861,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); + win->frame_pending = EINA_FALSE; +} - 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 +900,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; diff --git a/src/lib/ecore_evas/ecore_evas_wayland_shm.c b/src/lib/ecore_evas/ecore_evas_wayland_shm.c index 987c413..55c411e 100644 --- a/src/lib/ecore_evas/ecore_evas_wayland_shm.c +++ b/src/lib/ecore_evas/ecore_evas_wayland_shm.c @@ -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, @@ -694,11 +696,6 @@ _ecore_evas_wl_hide(Ecore_Evas *ee) if ((!ee) || (!ee->visible)) return; - if (ee->engine.wl.buffer) wl_buffer_destroy(ee->engine.wl.buffer); - ee->engine.wl.buffer = NULL; - - 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 +703,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 +863,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 +972,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 +992,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) { -- 2.7.4