From ca411c4d680d806c210d8dac005dd242d7bf75d1 Mon Sep 17 00:00:00 2001 From: devilhorns Date: Thu, 29 Mar 2012 01:26:30 +0000 Subject: [PATCH] Ecore_Wayland: Add an API function which calls wl_display_iterate(readable). Fix ecore_wl_window surface attach of the buffer for shm and egl types. NB: This ensures that both efl/elm clients work under the Wayland Compositor AND the E17 Compositor. NB: The issue here is that clients (when run under the Wayland compositor) need to make sure 'iterate' has been called before creating surfaces so that the wl_compositor is setup. However, the actual E17 Compositor will hang if 'iterate' is called to early. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@69707 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_wayland/Ecore_Wayland.h | 1 + src/lib/ecore_wayland/ecore_wl.c | 14 ++++---- src/lib/ecore_wayland/ecore_wl_window.c | 61 +++++++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/lib/ecore_wayland/Ecore_Wayland.h b/src/lib/ecore_wayland/Ecore_Wayland.h index 47201c5..5f3b612 100644 --- a/src/lib/ecore_wayland/Ecore_Wayland.h +++ b/src/lib/ecore_wayland/Ecore_Wayland.h @@ -276,6 +276,7 @@ EAPI struct wl_display *ecore_wl_display_get(void); EAPI void ecore_wl_screen_size_get(int *w, int *h); EAPI void ecore_wl_pointer_xy_get(int *x, int *y); EAPI int ecore_wl_dpi_get(void); +EAPI void ecore_wl_display_iterate(void); EAPI void ecore_wl_input_grab(Ecore_Wl_Input *input, Ecore_Wl_Window *win, unsigned int button); EAPI void ecore_wl_input_ungrab(Ecore_Wl_Input *input, unsigned int timestamp); diff --git a/src/lib/ecore_wayland/ecore_wl.c b/src/lib/ecore_wayland/ecore_wl.c index 9e43a36..c906ae6 100644 --- a/src/lib/ecore_wayland/ecore_wl.c +++ b/src/lib/ecore_wayland/ecore_wl.c @@ -217,7 +217,6 @@ ecore_wl_flush(void) while (_ecore_wl_disp->mask & WL_DISPLAY_WRITABLE) wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_WRITABLE); -// wl_display_flush(_ecore_wl_disp->wl.display); // old flush code } /** @@ -230,14 +229,9 @@ ecore_wl_flush(void) EAPI void ecore_wl_sync(void) { - LOGFN(__FILE__, __LINE__, __FUNCTION__); +// LOGFN(__FILE__, __LINE__, __FUNCTION__); wl_display_sync(_ecore_wl_disp->wl.display); - - //wl_display_roundtrip(_ecore_wl_disp->wl.display); - - // old sync code -// wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); } /** @@ -326,6 +320,12 @@ ecore_wl_dpi_get(void) return (((w * 254) / mw) + 5) / 10; } +EAPI void +ecore_wl_display_iterate(void) +{ + wl_display_iterate(_ecore_wl_disp->wl.display, WL_DISPLAY_READABLE); +} + /* local functions */ static Eina_Bool _ecore_wl_shutdown(Eina_Bool close) diff --git a/src/lib/ecore_wayland/ecore_wl_window.c b/src/lib/ecore_wayland/ecore_wl_window.c index d4c181c..cefef30 100644 --- a/src/lib/ecore_wayland/ecore_wl_window.c +++ b/src/lib/ecore_wayland/ecore_wl_window.c @@ -227,25 +227,56 @@ ecore_wl_window_buffer_attach(Ecore_Wl_Window *win, struct wl_buffer *buffer, in LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!win) return; - if ((win->surface) && (buffer)) - wl_surface_attach(win->surface, buffer, x, y); - if (win->surface) + + switch (win->buffer_type) { - if (win->region.input) - { - wl_surface_set_input_region(win->surface, win->region.input); - wl_region_destroy(win->region.input); - win->region.input = NULL; - } - if (win->region.opaque) + case ECORE_WL_WINDOW_BUFFER_TYPE_EGL_WINDOW: + /* FIXME: weston has wl_egl_window_get_attached_size */ + break; + case ECORE_WL_WINDOW_BUFFER_TYPE_EGL_IMAGE: + case ECORE_WL_WINDOW_BUFFER_TYPE_SHM: + if (win->surface) { - wl_surface_set_opaque_region(win->surface, win->region.opaque); - wl_region_destroy(win->region.opaque); - win->region.opaque = NULL; + int dx = 0, dy = 0; + + if ((win->server_allocation.w != win->allocation.w) || + (win->server_allocation.h != win->allocation.h)) + { + dx = win->allocation.w - win->server_allocation.w; + dy = win->allocation.h - win->server_allocation.h; + if (buffer) + wl_surface_attach(win->surface, buffer, dx, dy); + } + else + { + if (buffer) + wl_surface_attach(win->surface, buffer, x, y); + } + + win->server_allocation = win->allocation; } - wl_surface_damage(win->surface, 0, 0, - win->allocation.w, win->allocation.h); + break; + default: + return; } + + if (win->region.input) + { + wl_surface_set_input_region(win->surface, win->region.input); + wl_region_destroy(win->region.input); + win->region.input = NULL; + } + + if (win->region.opaque) + { + wl_surface_set_opaque_region(win->surface, win->region.opaque); + wl_region_destroy(win->region.opaque); + win->region.opaque = NULL; + } + + if (win->surface) + wl_surface_damage(win->surface, 0, 0, + win->allocation.w, win->allocation.h); } /** -- 2.7.4