From fd816230c448bbbcc13626f4f763f6d14c736df6 Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Mon, 14 Mar 2016 13:19:13 -0400 Subject: [PATCH] make e_alert WBOD work in X11 even when built with wayland support If enlightenment is built with support for wayland, then previously the WBOD would not work if we were running the same binary with X11. This was because the alert system would try to connect via drm by default (due to wayland build option). We fix that by checking for the existance of $DISPLAY (as this will not be present under drm), and running the X11 codepath if it is found, running the drm codepath if it is not found. Signed-off-by: Chris Michael --- src/bin/e_alert_main.c | 57 ++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c index bb8629360..0df784cf1 100644 --- a/src/bin/e_alert_main.c +++ b/src/bin/e_alert_main.c @@ -16,14 +16,12 @@ #include #include -#ifdef HAVE_WAYLAND # ifdef HAVE_WL_DRM # include # include # include # include # endif -#endif #define WINDOW_WIDTH 320 #define WINDOW_HEIGHT 240 @@ -33,7 +31,6 @@ #endif /* local function prototypes */ -#ifndef HAVE_WAYLAND static int _e_alert_connect(void); static void _e_alert_create(void); static void _e_alert_display(void); @@ -64,7 +61,6 @@ static xcb_gcontext_t gc = 0; static int fa = 0, fw = 0; static int sw = 0, sh = 0; static int fh = 0; -#endif static const char *title = NULL, *str1 = NULL, *str2 = NULL; static int ret = 0, sig = 0; @@ -85,10 +81,7 @@ struct { SIGABRT, "SIGABRT" } }; -#ifdef HAVE_WAYLAND # ifdef HAVE_WL_DRM -static int fh = 0; -static int sw = 0, sh = 0; static Ecore_Drm_Device *dev = NULL; static Ecore_Drm_Fb *buffer; static Evas *canvas = NULL; @@ -487,7 +480,6 @@ _e_alert_drm_shutdown(void) ecore_drm_shutdown(); evas_shutdown(); } -# endif #endif int @@ -536,31 +528,34 @@ main(int argc, char **argv) str1 = "(F1) Recover"; str2 = "(F12) Logout"; -#ifdef HAVE_WAYLAND -# ifdef HAVE_WL_DRM - if (!_e_alert_drm_connect()) +#ifdef HAVE_WL_DRM + if (!getenv("DISPLAY")) { - printf("FAILED TO INIT ALERT SYSTEM!!!\n"); - ecore_shutdown(); - return EXIT_FAILURE; + if (!_e_alert_drm_connect()) + { + printf("FAILED TO INIT ALERT SYSTEM!!!\n"); + ecore_shutdown(); + return EXIT_FAILURE; + } + _e_alert_drm_create(); + _e_alert_drm_display(); + _e_alert_drm_run(); + _e_alert_drm_shutdown(); } - _e_alert_drm_create(); - _e_alert_drm_display(); - _e_alert_drm_run(); - _e_alert_drm_shutdown(); -# endif -#else - if (!_e_alert_connect()) - { - printf("FAILED TO INIT ALERT SYSTEM!!!\n"); - ecore_shutdown(); - return EXIT_FAILURE; - } - _e_alert_create(); - _e_alert_display(); - _e_alert_run(); - _e_alert_shutdown(); + else #endif + { + if (!_e_alert_connect()) + { + printf("FAILED TO INIT ALERT SYSTEM!!!\n"); + ecore_shutdown(); + return EXIT_FAILURE; + } + _e_alert_create(); + _e_alert_display(); + _e_alert_run(); + _e_alert_shutdown(); + } ecore_shutdown(); @@ -570,7 +565,6 @@ main(int argc, char **argv) } /* local functions */ -#ifndef HAVE_WAYLAND static int _e_alert_connect(void) { @@ -1120,4 +1114,3 @@ _e_alert_draw_button_text(void) xcb_image_text_8(conn, strlen(str2), btn2, gc, x, (10 + fa), str2); } -#endif