E: Make E work with the new XCB stuffs. This breaks out e_alert into

it's own utility (as per raster's request/idea). Remove explicit
x_clags in Makefile.am(s) as they are no longer needed.

NB: I added some additional libs to the precache stuffs (even tho it's
not used right now). Also a newer e_main (more optimized).

NB: IF you are brave and want to test this, build evas w/ xcb, build
ecore w/ xcb, then rebuild E. Also, disable building opengl in both
evas & ecore (it's not ready for public consumption when paired w/ xcb).



SVN revision: 61680
This commit is contained in:
Christopher Michael 2011-07-25 09:40:18 +00:00
parent bc5f550546
commit 1a13f8c26f
17 changed files with 2356 additions and 1850 deletions

View File

@ -77,7 +77,7 @@ EFL_CHECK_PATH_MAX
AC_CHECK_FUNCS(setenv)
AC_CHECK_FUNCS(unsetenv)
AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
@ -160,25 +160,25 @@ AC_ARG_ENABLE(simple-x11,
[ want_evas_simple_x11=$enableval ]
)
x_dir=""
x_cflags=""
x_libs=""
AC_PATH_XTRA
AC_CHECK_HEADER(X11/X.h,
[
if test "x$want_evas_simple_x11" = "xyes"; then
x_libs="${x_libs} -lX11 -lXext"
else
x_dir=${x_dir:-/usr/X11R6}
x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}}
x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext"
fi
],[
AC_MSG_ERROR([Cannot find X headers and libraries.])
]
)
AC_SUBST(x_cflags)
AC_SUBST(x_libs)
dnl x_dir=""
dnl x_cflags=""
dnl x_libs=""
dnl AC_PATH_XTRA
dnl AC_CHECK_HEADER(X11/X.h,
dnl [
dnl if test "x$want_evas_simple_x11" = "xyes"; then
dnl x_libs="${x_libs} -lX11 -lXext"
dnl else
dnl x_dir=${x_dir:-/usr/X11R6}
dnl x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}}
dnl x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext"
dnl fi
dnl ],[
dnl AC_MSG_ERROR([Cannot find X headers and libraries.])
dnl ]
dnl )
dnl AC_SUBST(x_cflags)
dnl AC_SUBST(x_libs)
cf_cflags=""
cf_libs=""
@ -372,12 +372,16 @@ eeze_mount=
EEZE_MOUNT_CONFIG=0
if test "x$e_cv_want_mount_eeze" != "xno" ; then
AC_CHECK_LIB([eeze], [eeze_disk_function],
## [
## eeze_mount="eeze >= 1.1.0"
## EEZE_MOUNT_CONFIG=1
## AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting])
## AC_MSG_NOTICE([eeze mounting enabled])
## ],
[
eeze_mount="eeze >= 1.0.99 ecore-con >= 1.0.999"
EEZE_MOUNT_CONFIG=1
AC_DEFINE_UNQUOTED([HAVE_EEZE_MOUNT], [1], [enable eeze mounting])
AC_MSG_NOTICE([eeze mounting enabled])
],
AC_MSG_NOTICE([eeze mounting disabled])
e_cv_want_mount_eeze=no
]
)
else
AC_MSG_NOTICE([eeze mounting disabled])
@ -390,7 +394,7 @@ AM_CONDITIONAL([HAVE_EEZE_MOUNT], [false])
test -n "$hal_mount" && AC_DEFINE_UNQUOTED([HAVE_HAL_MOUNT], [1], [enable HAL mounting])
test -n "$udisks_mount" && AC_DEFINE_UNQUOTED([HAVE_UDISKS_MOUNT], [1], [enable Udisks mounting])
AM_CONDITIONAL([HAVE_UDISKS_MOUNT], [test -n "$udisks_mount"])
AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"])
##AM_CONDITIONAL([HAVE_EEZE_MOUNT], [test -n "$eeze_mount"])
# doxygen program for documentation building
@ -442,6 +446,7 @@ PKG_CHECK_MODULES(E_FM_OP, [
PKG_CHECK_MODULES(E_FM_OPEN, [
ecore >= 1.0.999
ecore-ipc >= 1.0.999
ecore-con >= 1.0.999
eet >= 1.4.0
eina >= 1.0.999
])
@ -460,6 +465,13 @@ PKG_CHECK_MODULES(E_INIT, [
eina >= 1.0.999
])
PKG_CHECK_MODULES(E_ALERT, [
xcb
eina >= 1.0.999
ecore >= 1.0.999
ecore-ipc >= 1.0.999
])
PKG_CHECK_MODULES(E, [
evas >= 1.0.999
ecore >= 1.0.999

View File

@ -9,7 +9,6 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/src/bin \
@e_cflags@ \
@x_cflags@ \
@cf_cflags@ \
@VALGRIND_CFLAGS@ \
@EDJE_DEF@ \
@ -30,7 +29,8 @@ enlightenment_fm_op \
enlightenment_init \
enlightenment_sys \
enlightenment_thumb \
enlightenment_backlight
enlightenment_backlight \
enlightenment_alert
ENLIGHTENMENTHEADERS = \
e_about.h \
@ -184,8 +184,8 @@ e_zone.h
enlightenment_src = \
e_about.c \
e_acpi.c \
e_actions.c \
e_alert.c \
e_actions.c \
e_atoms.c \
e_backlight.c \
e_bg.c \
@ -331,7 +331,7 @@ e_main.c \
$(enlightenment_src)
enlightenment_LDFLAGS = -export-dynamic
enlightenment_LDADD = @e_libs@ @x_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm
enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm
enlightenment_imc_SOURCES = \
e.h \
@ -375,6 +375,12 @@ e_xinerama.c
enlightenment_init_LDADD = @E_INIT_LIBS@
enlightenment_alert_SOURCES = \
e_alert_main.c
enlightenment_alert_LDADD = @E_ALERT_LIBS@
enlightenment_alert_CFLAGS = @E_ALERT_CFLAGS@
# HACK! why install-data-hook? install-exec-hook is run after bin_PROGRAMS
# and before internal_bin_PROGRAMS are installed. install-data-hook is
# run after both

View File

@ -1,169 +1,173 @@
#ifndef E_H
#define E_H
# define E_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define USE_IPC
#if 0
#define OBJECT_PARANOIA_CHECK
#define OBJECT_CHECK
#endif
#ifndef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64
#endif
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
#elif defined __GNUC__
# define alloca __builtin_alloca
#elif defined _AIX
# define alloca __alloca
#elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
#else
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
void *alloca (size_t);
#endif
# define USE_IPC
# if 0
# define OBJECT_PARANOIA_CHECK
# define OBJECT_CHECK
# endif
#ifdef __linux__
#include <features.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/param.h>
#include <utime.h>
#include <dlfcn.h>
#include <math.h>
#include <fnmatch.h>
#include <limits.h>
#include <ctype.h>
#include <time.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <glob.h>
#include <locale.h>
#include <errno.h>
#include <signal.h>
#include <inttypes.h>
#include <sys/time.h>
#include <sys/resource.h>
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
#ifdef HAVE_GETTEXT
# include <libintl.h>
#endif
#ifndef _POSIX_HOST_NAME_MAX
#define _POSIX_HOST_NAME_MAX 255
#endif
#ifdef HAVE_VALGRIND
# include <memcheck.h>
#endif
#ifdef __GLIBC__
#include <execinfo.h>
#include <setjmp.h>
#endif
#include <Eina.h>
#include <Evas.h>
#include <Evas_Engine_Buffer.h>
#include <Ecore.h>
#include <Ecore_X.h>
#include <Ecore_Evas.h>
#include <Ecore_Input.h>
#include <Ecore_Input_Evas.h>
#include <Ecore_Con.h>
#include <Ecore_Ipc.h>
#include <Ecore_File.h>
#include <Eet.h>
#include <Edje.h>
#include <Efreet.h>
#include <Efreet_Mime.h>
#include <E_DBus.h>
#ifdef EAPI
#undef EAPI
#endif
#ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# elif defined __GNUC__
# define alloca __builtin_alloca
# elif defined _AIX
# define alloca __alloca
# elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# define EAPI __declspec(dllimport)
# include <stddef.h>
# ifdef __cplusplus
extern "C"
# endif
void *alloca (size_t);
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# ifdef __linux__
# include <features.h>
# endif
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <string.h>
# include <sys/types.h>
# include <sys/stat.h>
# include <sys/time.h>
# include <sys/param.h>
# include <sys/resource.h>
# include <utime.h>
# include <dlfcn.h>
# include <math.h>
# include <fcntl.h>
# include <fnmatch.h>
# include <limits.h>
# include <ctype.h>
# include <time.h>
# include <dirent.h>
# include <pwd.h>
# include <grp.h>
# include <glob.h>
# include <locale.h>
# include <errno.h>
# include <signal.h>
# include <inttypes.h>
# ifdef HAVE_GETTEXT
# include <libintl.h>
# endif
# ifndef _POSIX_HOST_NAME_MAX
# define _POSIX_HOST_NAME_MAX 255
# endif
# ifdef HAVE_VALGRIND
# include <memcheck.h>
# endif
# ifdef __GLIBC__
# include <execinfo.h>
# include <setjmp.h>
# endif
# include <Eina.h>
# include <Eet.h>
# include <Evas.h>
# include <Evas_Engine_Buffer.h>
# include <Ecore.h>
# include <Ecore_X.h>
# include <Ecore_Evas.h>
# include <Ecore_Input.h>
# include <Ecore_Input_Evas.h>
# include <Ecore_Con.h>
# include <Ecore_Ipc.h>
# include <Ecore_File.h>
# include <Efreet.h>
# include <Efreet_Mime.h>
# include <Edje.h>
# include <E_DBus.h>
# ifdef EAPI
# undef EAPI
# endif
# ifdef WIN32
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
# else
# ifdef __GNUC__
# if __GNUC__ >= 4
/* BROKEN in gcc 4 on amd64 */
#if 0
# pragma GCC visibility push(hidden)
#endif
# define EAPI __attribute__ ((visibility("default")))
# if 0
# pragma GCC visibility push(hidden)
# endif
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
#ifdef EINTERN
#undef EINTERN
#endif
#ifdef __GNUC__
# if __GNUC__ >= 4
# define EINTERN __attribute__ ((visibility("hidden")))
# ifdef EINTERN
# undef EINTERN
# endif
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EINTERN __attribute__ ((visibility("hidden")))
# else
# define EINTERN
# endif
# else
# define EINTERN
# endif
#else
# define EINTERN
#endif
typedef struct _E_Before_Idler E_Before_Idler;
typedef struct _E_Rect E_Rect;
/* convenience macro to compress code and avoid typos */
#define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; }
#define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
#define E_INSIDE(x, y, xx, yy, ww, hh) (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
#define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) (((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh))))
#define E_SPANS_COMMON(x1, w1, x2, w2) (!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
#define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n)
#define E_NEW(s, n) (s *)calloc(n, sizeof(s))
#define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s))
#define E_FREE(p) do { free(p); p = NULL; } while (0)
#define E_FREE_LIST(list, free) \
do \
{ \
if (list) \
{ \
void *data; \
EINA_LIST_FREE(list, data) \
{ \
free(data); \
} \
list = NULL; \
} \
} \
while (0)
# define E_FN_DEL(_fn, _h) if (_h) { _fn(_h); _h = NULL; }
# define E_INTERSECTS(x, y, w, h, xx, yy, ww, hh) \
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && (((x) + (w)) > (xx)) && (((y) + (h)) > (yy)))
# define E_INSIDE(x, y, xx, yy, ww, hh) \
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && ((x) >= (xx)) && ((y) >= (yy)))
# define E_CONTAINS(x, y, w, h, xx, yy, ww, hh) \
(((xx) >= (x)) && (((x) + (w)) >= ((xx) + (ww))) && ((yy) >= (y)) && (((y) + (h)) >= ((yy) + (hh))))
# define E_SPANS_COMMON(x1, w1, x2, w2) \
(!((((x2) + (w2)) <= (x1)) || ((x2) >= ((x1) + (w1)))))
# define E_REALLOC(p, s, n) p = (s *)realloc(p, sizeof(s) * n)
# define E_NEW(s, n) (s *)calloc(n, sizeof(s))
# define E_NEW_RAW(s, n) (s *)malloc(n * sizeof(s))
# define E_FREE(p) do { free(p); p = NULL; } while (0)
# define E_FREE_LIST(list, free) \
do \
{ \
if (list) \
{ \
void *data; \
EINA_LIST_FREE(list, data) \
{ \
free(data); \
} \
list = NULL; \
} \
} \
while (0)
#define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x))
#define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
# define E_CLAMP(x, min, max) (x < min ? min : (x > max ? max : x))
# define E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
{ \
if (E_INTERSECTS(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \
{ \
@ -190,28 +194,27 @@ typedef struct _E_Rect E_Rect;
} \
}
#define E_REMOTE_OPTIONS 1
#define E_REMOTE_OUT 2
#define E_WM_IN 3
#define E_REMOTE_IN 4
#define E_ENUM 5
#define E_LIB_IN 6
# define E_REMOTE_OPTIONS 1
# define E_REMOTE_OUT 2
# define E_WM_IN 3
# define E_REMOTE_IN 4
# define E_ENUM 5
# define E_LIB_IN 6
#define E_TYPEDEFS 1
#include "e_includes.h"
#undef E_TYPEDEFS
#include "e_includes.h"
# define E_TYPEDEFS 1
# include "e_includes.h"
# undef E_TYPEDEFS
# include "e_includes.h"
EAPI E_Before_Idler *e_main_idler_before_add(int (*func) (void *data), void *data, int once);
EAPI void e_main_idler_before_del(E_Before_Idler *eb);
EAPI void e_main_idler_before_del(E_Before_Idler *eb);
struct _E_Before_Idler
{
int (*func) (void *data);
void *data;
unsigned char once : 1;
unsigned char delete_me : 1;
int (*func) (void *data);
void *data;
Eina_Bool once : 1;
Eina_Bool delete_me : 1;
};
struct _E_Rect
@ -227,14 +230,15 @@ extern EAPI E_Path *path_icons;
extern EAPI E_Path *path_modules;
extern EAPI E_Path *path_backgrounds;
extern EAPI E_Path *path_messages;
extern EAPI int restart;
extern EAPI int good;
extern EAPI int evil;
extern EAPI int starting;
extern EAPI int stopping;
extern EAPI Eina_Bool good;
extern EAPI Eina_Bool evil;
extern EAPI Eina_Bool starting;
extern EAPI Eina_Bool stopping;
extern EAPI Eina_Bool restart;
extern EAPI Eina_Bool e_precache_end;
extern EAPI Eina_Bool x_fatal;
extern EAPI unsigned long e_alert_composite_win;
//extern EAPI unsigned long e_alert_composite_win;
#endif

View File

@ -1,229 +1,60 @@
#include "e.h"
#include "e_alert.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <X11/extensions/shape.h>
#include <Ecore.h>
/* local function prototypes */
static Eina_Bool _e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event);
/* local subsystem functions */
/* local variables */
static Ecore_Exe *alert_exe = NULL;
static Ecore_Event_Handler *alert_exe_hdl = NULL;
/* local subsystem globals */
static Display *dd = NULL;
static char *title = NULL, *str1 = NULL, *str2 = NULL;
static Font font = 0;
static XFontStruct *fs = NULL;
static GC gc = 0;
static Window win = 0, b1 = 0, b2 = 0;
static int ww = 320, hh = 240, wx = 20, wy = 20;
EAPI unsigned long e_alert_composite_win = 0;
/* externally accessible functions */
EINTERN int
e_alert_init(const char *disp)
EINTERN int
e_alert_init(void)
{
XGCValues gcv;
int wid, hih, mask;
XSetWindowAttributes att;
dd = XOpenDisplay(disp);
if (!dd) return 0;
font = XLoadFont(dd, "fixed");
fs = XQueryFont(dd, font);
/* dont i18n this - i dont want gettext doing anything as this is called
from a segv */
title = "Enlightenment Error";
str1 = "(F1) Recover";
str2 = "(F2) Exit";
wid = DisplayWidth(dd, DefaultScreen(dd));
hih = DisplayHeight(dd, DefaultScreen(dd));
att.background_pixel = WhitePixel(dd, DefaultScreen(dd));
att.border_pixel = BlackPixel(dd, DefaultScreen(dd));
att.override_redirect = True;
mask = CWBackPixel | CWBorderPixel | CWOverrideRedirect;
wx = (wid - ww) / 2;
wy = (hih - hh) / 2;
win = XCreateWindow(dd, DefaultRootWindow(dd),
wx, wy, ww, hh, 0,
CopyFromParent, InputOutput,
CopyFromParent, mask, &att);
b1 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent,
InputOutput, CopyFromParent, mask, &att);
b2 = XCreateWindow(dd, win, -100, -100, 1, 1, 0, CopyFromParent,
InputOutput, CopyFromParent, mask, &att);
XMapWindow(dd, b1);
XMapWindow(dd, b2);
gc = XCreateGC(dd, win, 0, &gcv);
XSetForeground(dd, gc, att.border_pixel);
XSelectInput(dd, win, KeyPressMask | KeyReleaseMask | ExposureMask);
alert_exe_hdl =
ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_alert_cb_exe_del, NULL);
return 1;
}
EINTERN int
e_alert_shutdown(void)
EINTERN int
e_alert_shutdown(void)
{
if (!x_fatal)
{
XDestroyWindow(dd, win);
XFreeGC(dd, gc);
XFreeFont(dd, fs);
XCloseDisplay(dd);
}
title = NULL;
str1 = NULL;
str2 = NULL;
dd = NULL;
font = 0;
fs = NULL;
gc = 0;
e_alert_hide();
if (alert_exe_hdl) ecore_event_handler_del(alert_exe_hdl);
alert_exe_hdl = NULL;
return 1;
}
EAPI void
e_alert_show(const char *text)
EAPI void
e_alert_show(int sig)
{
int w, i, j, k;
char line[1024];
XEvent ev;
int fw, fh, mh;
KeyCode key;
int button;
char buf[8192];
if (!text) return;
snprintf(buf, sizeof(buf),
"%s/enlightenment/utils/enlightenment_alert %d %d",
e_prefix_lib_get(), sig, getpid());
if ((!dd) || (!fs))
{
fputs(text, stderr);
fflush(stderr);
exit(1);
}
fh = fs->ascent + fs->descent;
mh = ((ww - 20) / 2) - 20;
/* fixed size... */
w = 20;
XMoveResizeWindow(dd, b1, w, hh - 15 - fh, mh + 10, fh + 10);
XSelectInput(dd, b1, ButtonPressMask | ButtonReleaseMask | ExposureMask);
w = ww - 20 - mh;
XMoveResizeWindow(dd, b2, w, hh - 15 - fh, mh + 10, fh + 10);
XSelectInput(dd, b2, ButtonPressMask | ButtonReleaseMask | ExposureMask);
if (e_alert_composite_win)
{
#ifdef ShapeInput
XRectangle rect;
rect.x = wx;
rect.y = wy;
rect.width = ww;
rect.height = hh;
XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput,
0, 0, &rect, 1, ShapeSet, Unsorted);
#endif
XReparentWindow(dd, win, e_alert_composite_win, wx, wy);
}
XMapRaised(dd, win);
XGrabPointer(dd, win, True, ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
XGrabKeyboard(dd, win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
XSetInputFocus(dd, win, RevertToPointerRoot, CurrentTime);
XSync(dd, False);
button = 0;
while (button == 0)
{
XNextEvent(dd, &ev);
switch (ev.type)
{
case KeyPress:
key = XKeysymToKeycode(dd, XStringToKeysym("F1"));
if (key == ev.xkey.keycode)
{
button = 1;
break;
}
key = XKeysymToKeycode(dd, XStringToKeysym("F2"));
if (key == ev.xkey.keycode)
{
button = 2;
break;
}
break;
case ButtonPress:
if (ev.xbutton.window == b1)
button = 1;
else if (ev.xbutton.window == b2)
button = 2;
break;
case Expose:
while (XCheckTypedWindowEvent(dd, ev.xexpose.window, Expose, &ev));
/* outline */
XDrawRectangle(dd, win, gc, 0, 0, ww - 1, hh - 1);
XDrawRectangle(dd, win, gc, 2, 2, ww - 4 - 1, fh + 4 - 1);
fw = XTextWidth(fs, title, strlen(title));
XDrawString(dd, win, gc, 2 + 2 + ((ww - 4 - 4 - fw) / 2) , 2 + 2 + fs->ascent, title, strlen(title));
i = 0;
j = 0;
k = 2 + fh + 4 + 2;
while (text[i])
{
line[j++] = text[i++];
if (line[j - 1] == '\n')
{
line[j - 1] = 0;
j = 0;
XDrawString(dd, win, gc, 4, k + fs->ascent, line, strlen(line));
k += fh + 2;
}
}
fw = XTextWidth(fs, str1, strlen(str1));
XDrawRectangle(dd, b1, gc, 0, 0, mh - 1, fh + 10 - 1);
XDrawString(dd, b1, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str1, strlen(str1));
fw = XTextWidth(fs, str2, strlen(str2));
XDrawRectangle(dd, b2, gc, 0, 0, mh - 1, fh + 10 - 1);
XDrawString(dd, b2, gc, 5 + ((mh - fw) / 2), 5 + fs->ascent, str2, strlen(str2));
XSync(dd, False);
break;
default:
break;
}
}
XDestroyWindow(dd, win);
XSync(dd, False);
switch (button)
{
case 1:
ecore_app_restart();
break;
case 2:
exit(-11);
break;
default:
break;
}
alert_exe = ecore_exe_run(buf, NULL);
pause();
}
/* local subsystem functions */
EAPI void
e_alert_hide(void)
{
if (alert_exe) ecore_exe_terminate(alert_exe);
}
/* local functions */
static Eina_Bool
_e_alert_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Exe_Event_Del *ev;
ev = event;
if (!alert_exe) return ECORE_CALLBACK_RENEW;
if (ev->exe == alert_exe) alert_exe = NULL;
return ECORE_CALLBACK_RENEW;
}

View File

@ -1,13 +1,20 @@
#ifdef E_TYPEDEFS
typedef enum _E_Alert_Op_Type
{
E_ALERT_OP_RESTART = 0,
E_ALERT_OP_EXIT
} E_Alert_Op_Type;
#else
#ifndef E_ALERT_H
#define E_ALERT_H
EINTERN int e_alert_init(const char *disp);
EINTERN int e_alert_init(void);
EINTERN int e_alert_shutdown(void);
void e_alert_show(const char *text);
EAPI void e_alert_show(int sig);
EAPI void e_alert_hide(void);
#endif
#endif

615
src/bin/e_alert_main.c Normal file
View File

@ -0,0 +1,615 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <limits.h>
#include <Eina.h>
#include <Ecore.h>
#include <Ecore_Ipc.h>
#include <xcb/xcb.h>
#define WINDOW_WIDTH 320
#define WINDOW_HEIGHT 240
/* local function prototypes */
static int _e_alert_ipc_init(void);
static Eina_Bool _e_alert_ipc_server_add(void *data, int type, void *event);
static int _e_alert_connect(void);
static void _e_alert_create(void);
static void _e_alert_display(void);
static void _e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h);
static void _e_alert_window_raise(xcb_window_t win);
static void _e_alert_sync(void);
static void _e_alert_shutdown(void);
static void _e_alert_run(void);
static void _e_alert_draw(void);
static int _e_alert_handle_key_press(xcb_generic_event_t *event);
static int _e_alert_handle_button_press(xcb_generic_event_t *event);
static xcb_char2b_t *_e_alert_build_string(const char *str);
static void _e_alert_draw_outline(void);
static void _e_alert_draw_title_outline(void);
static void _e_alert_draw_title(void);
static void _e_alert_draw_text(void);
static void _e_alert_draw_button_outlines(void);
static void _e_alert_draw_button_text(void);
static void _e_alert_restart_e(void);
static void _e_alert_exit_e(void);
/* local variables */
static Ecore_Ipc_Server *_ipc_server = NULL;
static Ecore_Ipc_Server *_server = NULL;
static xcb_connection_t *conn = NULL;
static xcb_screen_t *screen = NULL;
static xcb_window_t win = 0;
static xcb_window_t btn1 = 0;
static xcb_window_t btn2 = 0;
static xcb_font_t font = 0;
static xcb_gcontext_t gc = 0;
static int sw = 0, sh = 0;
static int fa = 0, fh = 0, fw = 0;
static const char *title = NULL, *str1 = NULL, *str2 = NULL;
static int ret = 0, sig = 0;
static pid_t pid;
int
main(int argc, char **argv)
{
int i = 0;
for (i = 1; i < argc; i++)
{
if ((!strcmp(argv[i], "-h")) ||
(!strcmp(argv[i], "-help")) ||
(!strcmp(argv[i], "--help")))
{
printf("This is an internal tool for Enlightenment.\n"
"do not use it.\n");
exit(0);
}
else if ((i == 1))
sig = atoi(argv[i]); // signal
else if ((i == 2))
pid = atoi(argv[i]); // E's pid
}
if (!ecore_init()) return EXIT_FAILURE;
if (!ecore_ipc_init())
{
ecore_shutdown();
return EXIT_FAILURE;
}
if (!_e_alert_connect())
{
printf("FAILED TO INIT ALERT SYSTEM!!!\n");
ecore_ipc_shutdown();
ecore_shutdown();
return EXIT_FAILURE;
}
if (!_e_alert_ipc_init())
{
printf("Failed to Connect to Enlightenment!!!\n");
ecore_ipc_shutdown();
ecore_shutdown();
return EXIT_FAILURE;
}
title = "Enlightenment Error";
str1 = "(F1) Recover";
str2 = "(F2) Exit";
_e_alert_create();
_e_alert_display();
_e_alert_run();
_e_alert_shutdown();
if (ret == 1)
_e_alert_restart_e();
else if (ret == 2)
_e_alert_exit_e();
if (_ipc_server)
ecore_ipc_server_del(_ipc_server);
ecore_ipc_shutdown();
ecore_shutdown();
return EXIT_SUCCESS;
}
/* local functions */
static int
_e_alert_ipc_init(void)
{
char *edir = NULL;
if (!(edir = getenv("E_IPC_SOCKET"))) return 0;
_ipc_server =
ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, edir, 0, NULL);
if (!_ipc_server) return 0;
ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD,
_e_alert_ipc_server_add, NULL);
return 1;
}
static Eina_Bool
_e_alert_ipc_server_add(void *data, int type, void *event)
{
Ecore_Ipc_Event_Server_Add *e;
e = event;
_server = e->server;
return ECORE_CALLBACK_PASS_ON;
}
static int
_e_alert_connect(void)
{
conn = xcb_connect(NULL, NULL);
if ((!conn) || (xcb_connection_has_error(conn)))
{
printf("E_Alert_Main: Error Trying to Connect!!\n");
return 0;
}
/* grab default screen */
screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
sw = screen->width_in_pixels;
sh = screen->height_in_pixels;
return 1;
}
static void
_e_alert_create(void)
{
uint32_t mask, mask_list[4];
int wx = 0, wy = 0;
wx = ((sw - WINDOW_WIDTH) / 2);
wy = ((sh - WINDOW_HEIGHT) / 2);
font = xcb_generate_id(conn);
xcb_open_font(conn, font, strlen("fixed"), "fixed");
/* create main window */
mask = (XCB_CW_BACK_PIXEL | XCB_CW_BORDER_PIXEL |
XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK);
mask_list[0] = screen->white_pixel;
mask_list[1] = screen->black_pixel;
mask_list[2] = 1;
mask_list[3] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_EXPOSURE);
win = xcb_generate_id(conn);
xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, screen->root,
wx, wy, WINDOW_WIDTH, WINDOW_HEIGHT, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
XCB_COPY_FROM_PARENT, mask, mask_list);
/* create button 1 */
mask_list[3] = (XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_EXPOSURE);
btn1 = xcb_generate_id(conn);
xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn1, win,
-100, -100, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
XCB_COPY_FROM_PARENT, mask, mask_list);
xcb_map_window(conn, btn1);
/* create button 2 */
btn2 = xcb_generate_id(conn);
xcb_create_window(conn, XCB_COPY_FROM_PARENT, btn2, win,
-100, -100, 1, 1, 0,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
XCB_COPY_FROM_PARENT, mask, mask_list);
xcb_map_window(conn, btn2);
/* create drawing gc */
mask = (XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT);
mask_list[0] = screen->black_pixel;
mask_list[1] = screen->white_pixel;
mask_list[2] = font;
gc = xcb_generate_id(conn);
xcb_create_gc(conn, gc, win, mask, mask_list);
}
static void
_e_alert_display(void)
{
xcb_char2b_t *str = NULL;
xcb_query_text_extents_cookie_t cookie;
xcb_query_text_extents_reply_t *reply;
int x = 0, w = 0;
str = _e_alert_build_string(title);
cookie =
xcb_query_text_extents_unchecked(conn, font, strlen(title), str);
reply = xcb_query_text_extents_reply(conn, cookie, NULL);
if (reply)
{
fa = reply->font_ascent;
fh = (fa + reply->font_descent);
fw = reply->overall_width;
free(reply);
}
free(str);
/* move buttons */
x = 20;
w = (WINDOW_WIDTH / 2) - 40;
_e_alert_button_move_resize(btn1, x, WINDOW_HEIGHT - 20 - (fh + 20),
w, (fh + 20));
x = ((WINDOW_WIDTH / 2) + 20);
_e_alert_button_move_resize(btn2, x, WINDOW_HEIGHT - 20 - (fh + 20),
w, (fh + 20));
/* FIXME: May need e_alert_composite_win here and checks for shapedinput */
/* if (e_alert_composite_win) */
/* { */
/* #ifdef ShapeInput */
/* XRectangle rect; */
/* rect.x = wx; */
/* rect.y = wy; */
/* rect.width = ww; */
/* rect.height = hh; */
/* XShapeCombineRectangles(dd, e_alert_composite_win, ShapeInput, */
/* 0, 0, &rect, 1, ShapeSet, Unsorted); */
/* #endif */
/* XReparentWindow(dd, win, e_alert_composite_win, wx, wy); */
/* } */
/* map and raise main window */
xcb_map_window(conn, win);
_e_alert_window_raise(win);
/* grab pointer & keyboard */
xcb_grab_pointer_unchecked(conn, 0, win,
(XCB_EVENT_MASK_BUTTON_PRESS |
XCB_EVENT_MASK_BUTTON_RELEASE),
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC,
XCB_NONE, XCB_NONE, XCB_CURRENT_TIME);
xcb_grab_keyboard_unchecked(conn, 0, win, XCB_CURRENT_TIME,
XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT,
win, XCB_CURRENT_TIME);
/* flush screen */
xcb_flush(conn);
/* sync */
_e_alert_sync();
}
static void
_e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h)
{
uint32_t list[4], mask;
if (!btn) return;
mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y |
XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT);
list[0] = x;
list[1] = y;
list[2] = w;
list[3] = h;
xcb_configure_window(conn, btn, mask, (const uint32_t *)&list);
}
static void
_e_alert_window_raise(xcb_window_t win)
{
uint32_t list[] = { XCB_STACK_MODE_ABOVE };
if (!win) return;
xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, list);
}
static void
_e_alert_sync(void)
{
xcb_flush(conn);
free(xcb_get_input_focus_reply(conn,
xcb_get_input_focus(conn), NULL));
}
static void
_e_alert_shutdown(void)
{
xcb_close_font(conn, font);
xcb_destroy_window(conn, btn1);
xcb_destroy_window(conn, btn2);
xcb_destroy_window(conn, win);
xcb_free_gc(conn, gc);
xcb_disconnect(conn);
}
static void
_e_alert_run(void)
{
xcb_generic_event_t *event = NULL;
xcb_flush(conn);
while ((event = xcb_wait_for_event(conn)))
{
switch (event->response_type & ~0x80)
{
case XCB_BUTTON_PRESS:
ret = _e_alert_handle_button_press(event);
break;
case XCB_KEY_PRESS:
ret = _e_alert_handle_key_press(event);
break;
case XCB_EXPOSE:
{
xcb_expose_event_t *ev;
ev = (xcb_expose_event_t *)event;
if (ev->window != win) break;
_e_alert_draw();
_e_alert_sync();
break;
}
default:
break;
}
free(event);
if (ret > 0) break;
}
}
static void
_e_alert_draw(void)
{
_e_alert_draw_outline();
_e_alert_draw_title_outline();
_e_alert_draw_title();
_e_alert_draw_text();
_e_alert_draw_button_outlines();
_e_alert_draw_button_text();
xcb_flush(conn);
}
static int
_e_alert_handle_key_press(xcb_generic_event_t *event)
{
xcb_key_press_event_t *ev;
ev = (xcb_key_press_event_t *)event;
if (ev->detail == 67) // F1
return 1;
else if (ev->detail == 68) // F2
return 2;
else
return 0;
}
static int
_e_alert_handle_button_press(xcb_generic_event_t *event)
{
xcb_button_press_event_t *ev;
ev = (xcb_button_press_event_t *)event;
if (ev->child == btn1)
return 1;
else if (ev->child == btn2)
return 2;
else
return 0;
}
static xcb_char2b_t *
_e_alert_build_string(const char *str)
{
unsigned int i = 0;
xcb_char2b_t *ret = NULL;
if (!(ret = malloc(strlen(str) * sizeof(xcb_char2b_t))))
return NULL;
for (i = 0; i < strlen(str); i++)
{
ret[i].byte1 = 0;
ret[i].byte2 = str[i];
}
return ret;
}
static void
_e_alert_draw_outline(void)
{
xcb_rectangle_t rect;
/* draw outline */
rect.x = 0;
rect.y = 0;
rect.width = (WINDOW_WIDTH - 1);
rect.height = (WINDOW_HEIGHT - 1);
xcb_poly_rectangle(conn, win, gc, 1, &rect);
}
static void
_e_alert_draw_title_outline(void)
{
xcb_rectangle_t rect;
/* draw title box */
rect.x = 2;
rect.y = 2;
rect.width = (WINDOW_WIDTH - 4 - 1);
rect.height = (fh + 4 + 2);
xcb_poly_rectangle(conn, win, gc, 1, &rect);
}
static void
_e_alert_draw_title(void)
{
xcb_void_cookie_t cookie;
int x = 0, y = 0;
/* draw title */
x = (2 + 2 + ((WINDOW_WIDTH - 4 - 4 - fw) / 2));
y = (2 + 2 + fh);
cookie =
xcb_image_text_8(conn, strlen(title), win, gc, x, y, title);
}
static void
_e_alert_draw_text(void)
{
xcb_void_cookie_t cookie;
char warn[1024], msg[PATH_MAX], line[1024];
int i = 0, j = 0, k = 0;
snprintf(msg, sizeof(msg),
"This is not meant to happen and is likely a sign of \n"
"a bug in Enlightenment or the libraries it relies \n"
"on. You can gdb attach to this process (%d) now \n"
"to try debug it or you could exit, or just hit \n"
"restart to try and get your desktop back the way \n"
"it was.\n"
"\n"
"Please compile everything with -g in your CFLAGS.", pid);
switch (sig)
{
case SIGSEGV:
snprintf(warn, sizeof(warn),
"This is very bad. Enlightenment SEGV'd.");
break;
case SIGILL:
snprintf(warn, sizeof(warn),
"This is very bad. Enlightenment SIGILL'd.");
break;
case SIGFPE:
snprintf(warn, sizeof(warn),
"This is very bad. Enlightenment SIGFPE'd.");
break;
case SIGBUS:
snprintf(warn, sizeof(warn),
"This is very bad. Enlightenment SIGBUS'd.");
break;
case SIGABRT:
snprintf(warn, sizeof(warn),
"This is very bad. Enlightenment SIGABRT'd.");
break;
default:
break;
}
/* draw text */
k = (fh + 12);
cookie =
xcb_image_text_8(conn, strlen(warn), win, gc,
4, (k + fa), warn);
k += (2 * (fh + 2));
while (msg[i])
{
line[j++] = msg[i++];
if (line[j - 1] == '\n')
{
line[j - 1] = 0;
j = 0;
cookie =
xcb_image_text_8(conn, strlen(line), win, gc,
4, (k + fa), line);
k += (fh + 2);
}
}
}
static void
_e_alert_draw_button_outlines(void)
{
xcb_rectangle_t rect;
rect.x = 0;
rect.y = 0;
rect.width = (WINDOW_WIDTH / 2) - 40 - 1;
rect.height = (fh + 20) - 1;
/* draw button outlines */
xcb_poly_rectangle(conn, btn1, gc, 1, &rect);
xcb_poly_rectangle(conn, btn2, gc, 1, &rect);
}
static void
_e_alert_draw_button_text(void)
{
xcb_void_cookie_t dcookie;
xcb_char2b_t *str = NULL;
xcb_query_text_extents_cookie_t cookie;
xcb_query_text_extents_reply_t *reply;
int x = 0, w = 0, bw = 0;
bw = (WINDOW_WIDTH / 2) - 40 - 1;
/* draw button1 text */
str = _e_alert_build_string(str1);
cookie =
xcb_query_text_extents_unchecked(conn, font, strlen(str1), str);
reply = xcb_query_text_extents_reply(conn, cookie, NULL);
if (reply)
{
w = reply->overall_width;
free(reply);
}
free(str);
x = (5 + ((bw - w) / 2));
dcookie =
xcb_image_text_8(conn, strlen(str1), btn1, gc, x, (10 + fa), str1);
/* draw button2 text */
str = _e_alert_build_string(str2);
cookie =
xcb_query_text_extents_unchecked(conn, font, strlen(str2), str);
reply = xcb_query_text_extents_reply(conn, cookie, NULL);
if (reply)
{
w = reply->overall_width;
free(reply);
}
free(str);
x = (5 + ((bw - w) / 2));
dcookie =
xcb_image_text_8(conn, strlen(str2), btn2, gc, x, (10 + fa), str2);
}
static void
_e_alert_restart_e(void)
{
kill(getppid(), SIGUSR2);
ecore_ipc_server_send(_server, 8, 0, 0, 0, 0, NULL, 0);
ecore_ipc_server_flush(_server);
}
static void
_e_alert_exit_e(void)
{
kill(getppid(), SIGUSR2);
ecore_ipc_server_send(_server, 8, 1, 0, 0, 0, NULL, 0);
ecore_ipc_server_flush(_server);
}

View File

@ -903,9 +903,9 @@ e_config_init(void)
E_CONFIG_VAL(D, T, exec.show_exit_dialog, UCHAR);
E_CONFIG_VAL(D, T, null_container_win, UCHAR);
E_CONFIG_LIST(D, T, env_vars, _e_config_env_var_edd);
E_CONFIG_VAL(D, T, backlight.normal, DOUBLE);
E_CONFIG_VAL(D, T, backlight.dim, DOUBLE);
E_CONFIG_VAL(D, T, backlight.transition, DOUBLE);
@ -914,7 +914,7 @@ e_config_init(void)
E_CONFIG_VAL(D, T, deskenv.load_xmodmap, UCHAR);
E_CONFIG_VAL(D, T, deskenv.load_gnome, UCHAR);
E_CONFIG_VAL(D, T, deskenv.load_kde, UCHAR);
e_config_load();
e_config_save_queue();
@ -1021,15 +1021,13 @@ e_config_load(void)
{
printf("EEEK! no config of any sort! abort abort abort!\n");
fprintf(stderr, "EEEK! no config of any sort! abort abort abort!\n");
e_alert_show("Enlightenment was started without any configuration\n"
"files available for the given profile (normally\n"
"default or the last profile used or provided on the\n"
"command-line with -profile etc.)\n"
"\n"
"Cannot contiue without configuration to work with.\n"
"Please ensure you have system or user configuration\n"
"for the profile you are using before proceeeding."
);
e_error_message_show("Enlightenment was started without any configuration\n"
"files available for the given profile (normally\n"
"default or the last profile used or provided on the\n"
"command-line with -profile etc.)\n\n"
"Cannot contiue without configuration to work with.\n"
"Please ensure you have system or user configuration\n"
"for the profile you are using before proceeeding.");
abort();
}
if (e_config->config_version < E_CONFIG_FILE_VERSION)

View File

@ -6,7 +6,6 @@ AM_CFLAGS = \
-I$(top_srcdir) \
-I$(top_srcdir)/src/bin \
@e_cflags@ \
@x_cflags@ \
@cf_cflags@ \
@VALGRIND_CFLAGS@ \
@EDJE_DEF@ \
@ -61,4 +60,3 @@ $(eeze_s) \
../e_sha1.c