X11 equivalent Wayland calls and notes

From Tizen Wiki
Jump to: navigation, search

The purpose of this page is to note what Evas or Wayland calls can be used in place of X11 ones. Please add any you know of and feel free to fix any that are incorrect. This is a work in progress.

Packaging

To support X11 and X11 packaging:

BuildRequires:  pkgconfig(ecore-x)

To support Wayland and Wayland packaging:

BuildRequires:  pkgconfig(ecore-wayland)

X11 + Wayland packaging:

At the beginning of the spec file add:

%bcond_with wayland
%bcond_with x

Then

%if %{with x}
BuildRequires:  pkgconfig(ecore-x)
%endif
%if %{with wayland}
BuildRequires:  pkgconfig(ecore-wayland)
%endif

Packaging cmake build

X11 packaging:

%cmake . 

X11 + Wayland packaging:

%cmake .  \
%if %{with wayland}
        -DWAYLAND_SUPPORT=On \
%else
        -DWAYLAND_SUPPORT=Off \
%endif
%if %{with x}
        -DX11_SUPPORT=On 
%else
        -DX11_SUPPORT=Off 
%endif

Then into the CMakeLists.txt

X11 cmake:

pkg_check_modules(pkgs REQUIRED
ecore-x
elementary
evas
vconf)

X11 + Wayland cmake:

IF(X11_SUPPORT)
       SET(WIN_PKG "ecore-x")
ENDIF(X11_SUPPORT)
IF(WAYLAND_SUPPORT)
       SET(WIN_PKG "${WIN_PKG} ecore-wayland")
ENDIF(WAYLAND_SUPPORT)
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
                        elementary
                        evas
                        vconf
                        ${WIN_PKG})

For build flag:

IF(WAYLAND_SUPPORT)
 ADD_DEFINITIONS("-DHAVE_WAYLAND")
ENDIF(WAYLAND_SUPPORT)
IF(X11_SUPPORT)
 ADD_DEFINITIONS("-DHAVE_X11")
ENDIF(X11_SUPPORT)
#ifdef HAVE_X
# include <Ecore_X.h>
#endif

#ifdef HAVE_WAYLAND
# include <Ecore_wayland.h>
#endif

Then you'll have be wise to manage both cases , X11 may be prefered for supporting xwayland and xserver if not xserver prefer wl case 1st

Window

These two are NOT interchangeable:

Ecore_X_Window != Ecore_Wl_Window

Ecore_X_Window == Window == unsigned int

Ecore_Wl_Window == struct _Ecore_Wl_Window

Equivalent Calls

ecore_x_dpi_get ecore_evas_screen_dpi_get
ecore_x_flush ecore_evas_manual_render (?)
ecore_x_screen_size_get ecore_evas_screen_geometry_get
ecore_x_window_cursor_set ecore_evas_cursor_set
ecore_x_window_focus ecore_evas_activate
ecore_x_window_free ecore_evas_free (?)
ecore_x_window_geometry_get ecore_evas_geometry_get (?)
ecore_x_window_hide ecore_evas_hide
ecore_x_window_move ecore_evas_move
ecore_x_window_move_resiz ecore_evas_move_resize
ecore_x_window_new ecore_evas_new
ecore_x_window_raise ecore_evas_raise
ecore_x_window_resize ecore_evas_resize
ecore_x_window_show ecore_evas_show
ecore_x_window_size_get ecore_evas_geometry_get
ecore_x_window_root_first_get not needed ???
ecore_x_netwm_pid_get

Not tested yet:

capi-ui-efl-util provides abstract X/Wayland ecore calls.

check "[platform/core/api/efl-util.git]/include/efl_util.h" file.

Equivalent Data

Ecore_X_Event_Client_Message  ???

Equivalent Implementations OpenGL

OpenGL is not implemented in Wayland

X11 code:

#include <GL/gl.h>

Wayland code:

#ifdef HAVE_GL_GL_H
# include <GL/gl.h>
#else
# include <GLES/gl.h>
#endif

Equivalent Implementations GLX

Wayland doesn't have GLX, but EGL.

X11 GLX Context :

XVisualInfo *visinfo = glXChooseVisual(dpy, DefaultScreen(dpy), attrs);
GLXcontext context = glXCreateContext(dpy, visinfo, NULL, True );
glXMakeCurrent(dpy, window, context);
  /* draw GL here */
glXSwapBuffers(dpy, window);

Wayland EGL Context :

EGLDisplay edpy = eglGetDisplay ((EGLNativeDisplayType) wl_display);
EGLBoolean result = eglChooseConfig (edpy, attrs, &ecfg, 1, &numconfigs);
EGLContext ectx = eglCreateContext (edpy, ecfg, EGL_NO_CONTEXT, attrs);
 /* ... */
struct wl_egl_window *ewindow = wl_egl_window_create (surface, WIDTH, HEIGHT);
EGLSurface esrf = eglCreateWindowSurface (edpy, ecfg, ewindow, NULL);
eglMakeCurrent (edpy, esrf, esrf, ectx);
/* draw GLES here */
eglSwapBuffers (edpy, esrf);

or use the EGLX wrapper library :

https://github.com/Tarnyko/EGLX

Equivalent Implementations get window size

X11 code:

ecore_x_window_size_get(ecore_x_window_root_first_get(),&w, &h);

X11 + Wayland code:

#ifdef HAVE_X11
Ecore_X_Window xwin;
xwin = elm_win_xwindow_get(eo);
if (xwin != 0)
  ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
else {
#endif
#ifdef HAVE_WAYLAND
Ecore_Wl_Window *wlwin;
wlwin = elm_win_wl_window_get(eo);
if (wlwin != NULL)
ecore_wl_screen_size_get(&w, &h);
#endif
#ifdef HAVE_X11
}
#endif

Equivalent Implementations hide/show window

EFL-specific

 /* hide */
elm_win_withdrawn_set (window, EINA_TRUE);
 /* show */
elm_win_withdrawn_set (window, EINA_FALSE);

Toolkit-independant (NOT MERGED UPSTREAM YET)

 /* X11 Hide */
XUnmapWindow (display, window);
 /* X11 Show */
XMapWindow (display, window);
 /* Wayland Hide */
#include "xdg-shell-client-protocol.h"

struct xdg_surface *xdg_surface;
xdg_surface = xdg_shell_get_xdg_surface(xdg_shell, surface);
xdg_surface_set_minimized(xdg_surface);

Equivalent Implementations raise window

/* EFL hack : hide and show consecutively to put window in foreground */
elm_win_withdrawn_set (window, EINA_TRUE);
elm_win_withdrawn_set (window, EINA_FALSE);

Equivalent Implementations rotation

Functionality X specific X agnostic equivalent  Notes
Get screen rotation ecore_x_window_prop_property_get() + ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE ecore_evas_rotation_get() Wayland functionality not tested.


Missing Wayland Equivalents

Events

  • Rotation
  • Keygrab
  • Visibility (ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE)

Commands

  • Rotate