raster pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=466f0af56497c4c70982844cd51c1bbefa45d593

commit 466f0af56497c4c70982844cd51c1bbefa45d593
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Mon Aug 11 08:21:03 2014 +0900

    elm - do not do x11 main/config stuff without DISPLAY set
    
    the engine checks are also broken - but that's a much bigger change,
    so this fixes elm config and main code to not do their x11 work if no
    DISPLAY env var is set. this is right for a wayland world where you
    don't want DISPLAY but WAYLAND_DISPLAY set and used. this fixes
    several ERRs that should never have hapapned in this setup.
---
 src/lib/elm_config.c | 83 +++++++++++++++++++++++++++-------------------------
 src/lib/elm_main.c   |  4 +--
 2 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c
index a74c49c..44fbc2e 100644
--- a/src/lib/elm_config.c
+++ b/src/lib/elm_config.c
@@ -3280,7 +3280,7 @@ _elm_config_sub_shutdown(void)
 #undef ENGINE_COMPARE
      {
 #ifdef HAVE_ELEMENTARY_X
-        ecore_x_shutdown();
+        if (ecore_x_display_get()) ecore_x_shutdown();
 #endif
      }
 }
@@ -3298,57 +3298,60 @@ _elm_config_sub_init(void)
 #undef ENGINE_COMPARE
      {
 #ifdef HAVE_ELEMENTARY_X
-        if (ecore_x_init(NULL))
+        if (getenv("DISPLAY"))
           {
-             Ecore_X_Window win = 0, win2 = 0, root;
-
-             if (!ecore_x_screen_is_composited(0))
-               _elm_config->compositing = 0;
-             ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
-             root = ecore_x_window_root_first_get();
-             if (ecore_x_window_prop_window_get(root,
-                                                _atom[ATOM_E_CONFIG_WIN],
-                                                &win, 1) == 1)
+             if (ecore_x_init(NULL))
                {
-                  if (ecore_x_window_prop_window_get(win,
+                  Ecore_X_Window win = 0, win2 = 0, root;
+
+                  if (!ecore_x_screen_is_composited(0))
+                  _elm_config->compositing = 0;
+                  ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
+                  root = ecore_x_window_root_first_get();
+                  if (ecore_x_window_prop_window_get(root,
                                                      _atom[ATOM_E_CONFIG_WIN],
-                                                     &win2, 1) == 1)
+                                                     &win, 1) == 1)
                     {
-                       if (win2 == win) _config_win = win;
+                       if (ecore_x_window_prop_window_get(win,
+                                                          
_atom[ATOM_E_CONFIG_WIN],
+                                                          &win2, 1) == 1)
+                         {
+                            if (win2 == win) _config_win = win;
+                         }
                     }
-               }
-             if (_config_win == 0)
-               _config_win = ecore_x_window_permanent_new
-                             (root, _atom[ATOM_E_CONFIG_WIN]);
-
-             ecore_x_event_mask_set(_config_win,
-                                    ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
-             _prop_change_handler = ecore_event_handler_add
-               (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
-             if (!getenv("ELM_PROFILE"))
-               {
-                  char *s;
-
-                  s = ecore_x_window_prop_string_get(_config_win,
-                                                     _atom[ATOM_E_PROFILE]);
-                  if (s)
+                  if (_config_win == 0)
+                    _config_win = ecore_x_window_permanent_new
+                      (root, _atom[ATOM_E_CONFIG_WIN]);
+
+                  ecore_x_event_mask_set(_config_win,
+                                         ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
+                  _prop_change_handler = ecore_event_handler_add
+                  (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
+                  if (!getenv("ELM_PROFILE"))
                     {
-                       int changed = 0;
+                       char *s;
 
-                       if (_elm_profile)
+                       s = ecore_x_window_prop_string_get(_config_win,
+                                                          
_atom[ATOM_E_PROFILE]);
+                       if (s)
                          {
-                            if (strcmp(_elm_profile, s)) changed = 1;
-                            free(_elm_profile);
+                            int changed = 0;
+
+                            if (_elm_profile)
+                              {
+                                 if (strcmp(_elm_profile, s)) changed = 1;
+                                 free(_elm_profile);
+                              }
+                            _elm_profile = s;
+                            if (changed) _prop_config_get();
+                            s = strchr(_elm_profile, '/');
+                            if (s) *s = 0;
                          }
-                       _elm_profile = s;
-                       if (changed) _prop_config_get();
-                       s = strchr(_elm_profile, '/');
-                       if (s) *s = 0;
                     }
                }
+             else
+               ERR("Cannot connect to X11 display. check $DISPLAY variable");
           }
-        else
-          ERR("Cannot connect to X11 display. check $DISPLAY variable");
 #endif
      }
    _config_sub_apply();
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index bcd7213..e408985 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -796,7 +796,7 @@ elm_quicklaunch_seed(void)
 #undef ENGINE_COMPARE
           {
 # ifdef HAVE_ELEMENTARY_X
-             ecore_x_sync();
+             if (ecore_x_display_get()) ecore_x_sync();
 # endif
           }
         ecore_main_loop_iterate();
@@ -964,7 +964,7 @@ elm_quicklaunch_fork(int    argc,
 #undef ENGINE_COMPARE
           {
 # ifdef HAVE_ELEMENTARY_X
-             ecore_x_init(NULL);
+             if (getenv("DISPLAY")) ecore_x_init(NULL);
 # endif
           }
         ecore_evas_init(); // FIXME: check errors

-- 


Reply via email to