Stub functions for Wayland usage
authorMikko Ylinen <mikko.ylinen@intel.com>
Sat, 15 Dec 2012 00:03:45 +0000 (02:03 +0200)
committerRusty Lynch <rusty.lynch@intel.com>
Wed, 19 Dec 2012 00:26:10 +0000 (16:26 -0800)
Some functions called by applications make direct calls to X. This will
make apps crashing if Wayland is being used. As a hot fix, stub functions
making calls to X by checking DISPLAY environment variable and
returning to caller if DISPLAY is not set.

configure.ac
ecore-x.pc.in
src/lib/ecore_imf/ecore_imf_context.c
src/lib/ecore_x/xlib/ecore_x.c
src/lib/ecore_x/xlib/ecore_x_events.c
src/lib/ecore_x/xlib/ecore_x_window.c
src/lib/ecore_x/xlib/ecore_x_window_prop.c

index 82d05ac..15a9433 100644 (file)
@@ -561,7 +561,7 @@ requirements_ecore_sdl="ecore >= 1.6.99 eina >= 1.6.99 ${requirements_ecore_sdl}
 requirements_ecore_psl1ght="ecore >= 1.6.99 eina >= 1.6.99 ${requirements_ecore_psl1ght}"
 requirements_ecore_win32="ecore >= 1.6.99 eina >= 1.6.99 ${requirements_ecore_win32}"
 requirements_ecore_wince="ecore >= 1.6.99 eina >= 1.6.99 ${requirements_ecore_wince}"
-requirements_ecore_x="ecore >= 1.6.99 eina >= 1.6.99 ${requirements_ecore_x}"
+requirements_ecore_x="ecore >= 1.6.99 eina >= 1.6.99 ecore-wayland >= 1.6.99 ${requirements_ecore_x}"
 
 
 # glib support (main loop integration)
index 987c396..bcf03e2 100644 (file)
@@ -9,6 +9,6 @@ Name: ecore-x
 Description: E core library, X module
 @pkgconfig_requires_private@: @requirements_ecore_x@
 Version: @VERSION@
-Libs: -L${libdir} -lecore_x
+Libs: -L${libdir} -lecore_x -lecore_wayland
 Libs.private: @x_libs@ @ecore_x_libs_private@
 Cflags: -I${includedir}/ecore-@VMAJ@ @have_ecore_x_xcb_define@
index 5e4ede8..88b11a2 100644 (file)
@@ -569,6 +569,13 @@ ecore_imf_context_preedit_string_with_attributes_get(Ecore_IMF_Context *ctx, cha
 EAPI void
 ecore_imf_context_focus_in(Ecore_IMF_Context *ctx)
 {
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
      {
         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@@ -1776,6 +1783,13 @@ ecore_imf_context_input_panel_caps_lock_mode_get(Ecore_IMF_Context *ctx)
 EAPI void
 ecore_imf_context_input_panel_geometry_get(Ecore_IMF_Context *ctx, int *x, int *y, int *w, int *h)
 {
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
      {
         ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
index f8244e7..bf54458 100644 (file)
@@ -45,6 +45,8 @@ void *alloca (size_t);
 #include "Ecore_X_Atoms.h"
 #include "Ecore_Input.h"
 
+#define ROOT_WIN_ID 1
+
 static Eina_Bool _ecore_x_fd_handler(void *data,
                                      Ecore_Fd_Handler *fd_handler);
 static Eina_Bool _ecore_x_fd_handler_buf(void *data,
@@ -791,6 +793,13 @@ ecore_x_disconnect(void)
 EAPI Ecore_X_Display *
 ecore_x_display_get(void)
 {
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return NULL;
+   /*XXX End Hooks for Wayland */
+
    return (Ecore_X_Display *)_ecore_x_disp;
 }
 
@@ -815,6 +824,14 @@ EAPI Ecore_X_Screen *
 ecore_x_default_screen_get(void)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return NULL;
+   /*XXX End Hooks for Wayland */
+
    return (Ecore_X_Screen *)DefaultScreenOfDisplay(_ecore_x_disp);
 }
 
@@ -835,6 +852,16 @@ ecore_x_screen_size_get(const Ecore_X_Screen *screen,
 {
    Screen *s = (Screen *)screen;
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY"))) {
+     ecore_x_window_size_get(ROOT_WIN_ID, w, h);
+     return;
+   }
+   /*XXX End Hooks for Wayland */
+
    if (w) *w = 0;
    if (h) *h = 0;
    if (!s) return;
@@ -936,6 +963,14 @@ EAPI void
 ecore_x_flush(void)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    XFlush(_ecore_x_disp);
 }
 
@@ -948,6 +983,14 @@ EAPI void
 ecore_x_sync(void)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    XSync(_ecore_x_disp, False);
 }
 
@@ -1024,6 +1067,13 @@ ecore_x_dpi_get(void)
 {
    Screen *s;
 
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return 75;
+   /*XXX End Hooks for Wayland */
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    s = DefaultScreenOfDisplay(_ecore_x_disp);
    if (s->mwidth <= 0)
@@ -1264,6 +1314,13 @@ ecore_x_window_root_list(int *num_ret)
 EAPI Ecore_X_Window
 ecore_x_window_root_first_get(void)
 {
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return ROOT_WIN_ID;
+   /*XXX End Hooks for Wayland */
+
    return RootWindow(_ecore_x_disp, 0);
 /*
    int num;
index 2e780aa..498f4fd 100644 (file)
@@ -109,6 +109,13 @@ ecore_x_event_mask_set(Ecore_X_Window w,
    XWindowAttributes attr;
    XSetWindowAttributes s_attr;
 
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    if (!w)
      w = DefaultRootWindow(_ecore_x_disp);
index f16f5b1..4ec9fd3 100644 (file)
@@ -11,6 +11,8 @@
 #include "Ecore_X.h"
 #include "Ecore_X_Atoms.h"
 
+#define ROOT_WIN_ID 1
+
 static int ignore_num = 0;
 static Ecore_X_Window *ignore_list = NULL;
 
@@ -607,6 +609,13 @@ ecore_x_window_focus_get(void)
    Window win;
    int revert_mode;
 
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return ROOT_WIN_ID;
+   /*XXX End Hooks for Wayland */
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    win = 0;
    XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
@@ -684,6 +693,20 @@ ecore_x_window_size_get(Ecore_X_Window win,
 {
    int dummy_x, dummy_y;
 
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY"))) {
+     if (win == ROOT_WIN_ID) {
+       if (ecore_wl_init(NULL) > 1) {
+        ecore_wl_shutdown(0);
+       }
+         ecore_wl_screen_size_get(w, h);
+     }
+     return;
+   }
+   /*XXX End Hooks for Wayland */
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    if (win == 0)
      win = DefaultRootWindow(_ecore_x_disp);
@@ -1255,6 +1278,13 @@ ecore_x_window_shadow_tree_flush(void)
 EAPI Ecore_X_Window
 ecore_x_window_root_get(Ecore_X_Window win)
 {
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return ROOT_WIN_ID;
+   /*XXX End Hooks for Wayland */
+
    XWindowAttributes att;
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
index 98b41c4..215a4ef 100644 (file)
@@ -90,6 +90,13 @@ ecore_x_window_prop_card32_get(Ecore_X_Window win,
    unsigned int i;
    int num;
 
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return -1;
+   /*XXX End Hooks for Wayland */
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    prop_ret = NULL;
    if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
@@ -484,6 +491,14 @@ ecore_x_window_prop_property_set(Ecore_X_Window win,
                                  int number)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   /*XXX Start Hooks for Wayland */
+   char *d;
+
+   if (!(d = getenv("DISPLAY")))
+     return;
+   /*XXX End Hooks for Wayland */
+
    if (win == 0)
      win = DefaultRootWindow(_ecore_x_disp);