From d4a047f967cbcbc02e179723778d8f2016d3aff8 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 19 Jul 2012 04:39:25 +0000 Subject: [PATCH] enlightenment welcomes elementary. Now it's possible to do elm_win_add() from your e_modules and use all elementary features instead of painful e_widgets. We should consider this experimental, but after e17 is out we should start to convert dialogs and such to elementary, eventually deprecating e_widgets and the theme duplication. NOTE: requires r74156 with elementary patch. I'll send an email to the list with a simple patch to skel module to demo this. SVN revision: 74157 --- configure.ac | 20 +++++ src/bin/Makefile.am | 3 +- src/bin/e_main.c | 15 ++++ src/bin/e_win.c | 175 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 89fb058d3..50233a6f9 100644 --- a/configure.ac +++ b/configure.ac @@ -562,6 +562,26 @@ $udisks_mount \ $eeze_mount \ $device_backend" + +want_elementary=auto +have_elementary=no +AC_ARG_ENABLE(elementary, + AC_HELP_STRING([--enable-elementary], [enable Elementary support @<:@default=detect@:>@]), + [want_elementary=$enableval], + [want_elementary=auto] +) +if test "x$want_elementary" != "xno"; then + PKG_CHECK_MODULES(ELM, [elementary >= 1.6.9.0], + [have_elementary=yes], [have_elementary=no]) + if test "x$want_elementary" = "xyes" -a "x$have_elementary" = "xno"; then + AC_MSG_ERROR([Elementary support requested but it was not found]) + fi + if test "x$have_elementary" = "xyes"; then + AC_DEFINE([HAVE_ELEMENTARY], 1, "Have Elementary support") + requirements_e="${requirements_e} elementary > 1.6.9.0" + fi +fi + PKG_CHECK_MODULES(E_OPEN, [ ecore >= 1.2.0 efreet >= 1.2.0 diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index e89efa0e9..2fd1097a2 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -12,6 +12,7 @@ INCLUDES = \ @cf_cflags@ \ @VALGRIND_CFLAGS@ \ @EDJE_DEF@ \ +@ELM_CFLAGS@ \ -DPACKAGE_BIN_DIR=\"@PACKAGE_BIN_DIR@\" \ -DPACKAGE_LIB_DIR=\"@PACKAGE_LIB_DIR@\" \ -DPACKAGE_DATA_DIR=\"@PACKAGE_DATA_DIR@\" \ @@ -356,7 +357,7 @@ e_main.c \ $(enlightenment_src) enlightenment_LDFLAGS = -export-dynamic -enlightenment_LDADD = @e_libs@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm +enlightenment_LDADD = @e_libs@ @ELM_LIBS@ @dlopen_libs@ @cf_libs@ @VALGRIND_LIBS@ -lm enlightenment_imc_SOURCES = \ e.h \ diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 1da33814d..1f766b2ab 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -18,6 +18,10 @@ static double t0, t1, t2; # define TS(x) #endif +#ifdef HAVE_ELEMENTARY +#include +#endif + /* * i need to make more use of these when i'm baffled as to when something is * up. other hooks: @@ -442,6 +446,17 @@ main(int argc, char **argv) TS("Ecore_Evas Init Done"); // _e_main_shutdown_push(ecore_evas_shutdown); +#ifdef HAVE_ELEMENTARY + TS("Elementary Init"); + if (!elm_init(argc, argv)) + { + e_error_message_show(_("Enlightenment cannot initialize Elementary!\n")); + _e_main_shutdown(-1); + } + TS("Elementary Init Done"); + _e_main_shutdown_push(elm_shutdown); +#endif + /* e doesn't sync to compositor - it should be one */ ecore_evas_app_comp_sync_set(0); diff --git a/src/bin/e_win.c b/src/bin/e_win.c index b74633c87..ec69c6260 100644 --- a/src/bin/e_win.c +++ b/src/bin/e_win.c @@ -12,10 +12,185 @@ static void _e_win_cb_delete(Ecore_Evas *ee); /* local subsystem globals */ static Eina_List *wins = NULL; +#ifdef HAVE_ELEMENTARY +/* intercept elm_win operations so we talk directly to e_border */ + +#include + +typedef struct _Elm_Win_Trap_Ctx +{ + E_Border *border; + Ecore_X_Window xwin; + Eina_Bool centered:1; + Eina_Bool placed:1; +} Elm_Win_Trap_Ctx; + +static void * +_elm_win_trap_add(Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = calloc(1, sizeof(Elm_Win_Trap_Ctx)); + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL); + return ctx; +} + +static void +_elm_win_trap_del(void *data, Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN(ctx); + if (ctx->border) + { + e_border_hide(ctx->border, 1); + e_object_del(E_OBJECT(ctx->border)); + } + free(ctx); +} + +static Eina_Bool +_elm_win_trap_hide(void *data, Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + if (!ctx->border) return EINA_TRUE; + e_border_hide(ctx->border, 1); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_show(void *data, Evas_Object *o) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + if (!ctx->border) + { + Ecore_X_Window xwin = elm_win_xwindow_get(o); + E_Container *con = e_util_container_window_find(xwin); + Evas *e = evas_object_evas_get(o); + Ecore_Evas *ee = ecore_evas_ecore_evas_get(e); + + if (!con) + { + E_Manager *man = e_manager_current_get(); + EINA_SAFETY_ON_NULL_RETURN_VAL(man, EINA_TRUE); + con = e_container_current_get(man); + if (!con) con = e_container_number_get(man, 0); + EINA_SAFETY_ON_NULL_RETURN_VAL(con, EINA_TRUE); + } + + ctx->xwin = xwin; + ctx->border = e_border_new(con, xwin, 0, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx->border, EINA_TRUE); + ctx->border->placed = ctx->placed; + ctx->border->internal = 1; + ctx->border->internal_ecore_evas = ee; + } + if (ctx->centered) e_border_center(ctx->border); + e_border_show(ctx->border); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_move(void *data, Evas_Object *o __UNUSED__, int x, int y) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + ctx->centered = EINA_FALSE; + ctx->placed = EINA_TRUE; + if (!ctx->border) return EINA_TRUE; + e_border_move_without_border(ctx->border, x, y); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_resize(void *data, Evas_Object *o __UNUSED__, int w, int h) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + ctx->centered = EINA_FALSE; + if (!ctx->border) return EINA_TRUE; + e_border_resize_without_border(ctx->border, w, h); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_center(void *data, Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + ctx->centered = EINA_TRUE; + if (!ctx->border) return EINA_TRUE; + if (ctx->centered) e_border_center(ctx->border); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_lower(void *data, Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + if (!ctx->border) return EINA_TRUE; + e_border_lower(ctx->border); + return EINA_FALSE; +} + +static Eina_Bool +_elm_win_trap_raise(void *data, Evas_Object *o __UNUSED__) +{ + Elm_Win_Trap_Ctx *ctx = data; + EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, EINA_TRUE); + if (!ctx->border) return EINA_TRUE; + e_border_raise(ctx->border); + return EINA_FALSE; +} + +static const Elm_Win_Trap _elm_win_trap = { + ELM_WIN_TRAP_VERSION, + _elm_win_trap_add, + _elm_win_trap_del, + _elm_win_trap_hide, + _elm_win_trap_show, + _elm_win_trap_move, + _elm_win_trap_resize, + _elm_win_trap_center, + _elm_win_trap_lower, + _elm_win_trap_raise, + /* activate */ NULL, + /* alpha_set */ NULL, + /* aspect_set */ NULL, + /* avoid_damage_set */ NULL, + /* borderless_set */ NULL, + /* demand_attention_set */ NULL, + /* focus_skip_set */ NULL, + /* fullscreen_set */ NULL, + /* iconified_set */ NULL, + /* layer_set */ NULL, + /* manual_render_set */ NULL, + /* maximized_set */ NULL, + /* modal_set */ NULL, + /* name_class_set */ NULL, + /* object_cursor_set */ NULL, + /* override_set */ NULL, + /* rotation_set */ NULL, + /* rotation_with_resize_set */ NULL, + /* shaped_set */ NULL, + /* size_base_set */ NULL, + /* size_step_set */ NULL, + /* size_min_set */ NULL, + /* size_max_set */ NULL, + /* sticky_set */ NULL, + /* title_set */ NULL, + /* urgent_set */ NULL, + /* withdrawn_set */ NULL + }; +#endif + /* externally accessible functions */ EINTERN int e_win_init(void) { +#ifdef HAVE_ELEMENTARY + if (!elm_win_trap_set(&_elm_win_trap)) return 0; +#endif return 1; }