From ab0a1bda94292e4076e08c9a1cb7bde3ba4201fa Mon Sep 17 00:00:00 2001 From: Jean Guyomarc'h Date: Fri, 9 Jan 2015 14:41:04 +0900 Subject: [PATCH] Do not call ecore_x_init() when not using X display. Summary: On some systems (e.g. OS X), both Apple's windows manager and X11 can cohabit, therefore we need to check for the DISPLAY environment variable only when ELM_DISPLAY is not specified. Reviewers: cedric, devilhorns, seoz, raster Reviewed By: raster Differential Revision: https://phab.enlightenment.org/D1721 --- legacy/elementary/src/lib/elm_config.c | 29 ++++++++++++++++++++++++-- legacy/elementary/src/lib/elm_main.c | 29 ++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/legacy/elementary/src/lib/elm_config.c b/legacy/elementary/src/lib/elm_config.c index 5ddea1edb8..9fa9c0df87 100644 --- a/legacy/elementary/src/lib/elm_config.c +++ b/legacy/elementary/src/lib/elm_config.c @@ -3226,9 +3226,34 @@ void _elm_config_sub_init(void) { #ifdef HAVE_ELEMENTARY_X + Eina_Bool init_x; const char *ev = getenv("ELM_DISPLAY"); - if (((ev) && (!strcmp(ev, "x11")) && (getenv("DISPLAY"))) || - (getenv("DISPLAY"))) + Eina_Bool have_display = !!getenv("DISPLAY"); + + if (ev) /* If ELM_DISPLAY is specified */ + { + if (!strcmp(ev, "x11")) /* and it is X11 */ + { + if (!have_display) /* if there is no $DISPLAY */ + { + ERR("$ELM_DISPLAY is set to x11 but $DISPLAY is not set"); + init_x = EINA_FALSE; + } + else /* if there is */ + init_x = EINA_TRUE; + } + else /* not X11 */ + init_x = EINA_FALSE; + } + else /* ELM_DISPLAY not specified */ + { + if (have_display) /* If there is a $DISPLAY */ + init_x = EINA_TRUE; + else /* No $DISPLAY */ + init_x = EINA_FALSE; + } + + if (init_x) { if (ecore_x_init(NULL)) { diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c index 0f2e429437..4bb135e6f5 100644 --- a/legacy/elementary/src/lib/elm_main.c +++ b/legacy/elementary/src/lib/elm_main.c @@ -957,9 +957,34 @@ elm_quicklaunch_fork(int argc, _elm_config_sub_init(); # ifdef HAVE_ELEMENTARY_X { + Eina_Bool init_x; const char *ev = getenv("ELM_DISPLAY"); - if (((ev) && (!strcmp(ev, "x11")) && (getenv("DISPLAY"))) || - (getenv("DISPLAY"))) + Eina_Bool have_display = !!getenv("DISPLAY"); + + if (ev) /* If ELM_DISPLAY is specified */ + { + if (!strcmp(ev, "x11")) /* and it is X11 */ + { + if (!have_display) /* if there is no $DISPLAY */ + { + ERR("$ELM_DISPLAY is set to x11 but $DISPLAY" + " is not set"); + init_x = EINA_FALSE; + } + else /* if there is */ + init_x = EINA_TRUE; + } + else /* not X11 */ + init_x = EINA_FALSE; + } + else /* ELM_DISPLAY not specified */ + { + if (have_display) /* If there is a $DISPLAY */ + init_x = EINA_TRUE; + else /* No $DISPLAY */ + init_x = EINA_FALSE; + } + if (init_x) ecore_x_init(NULL); } # endif