From 28872897b57e948f292aad749f84921be6aa2ac9 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Sat, 10 Jan 2015 00:33:55 -0500 Subject: [PATCH] +elm_win_fake(), ELM_WIN_FAKE type this is a giant hack to provide widget parenting in e. do not use this function, do not use this type, do not even read the related documentation. @feature --- legacy/elementary/src/lib/elm_win.c | 73 +++++++++++++--------- legacy/elementary/src/lib/elm_win.eo | 1 + legacy/elementary/src/lib/elm_win_common.h | 4 ++ legacy/elementary/src/lib/elm_win_legacy.h | 19 ++++++ 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/legacy/elementary/src/lib/elm_win.c b/legacy/elementary/src/lib/elm_win.c index e5de5e8890..3de1efd633 100644 --- a/legacy/elementary/src/lib/elm_win.c +++ b/legacy/elementary/src/lib/elm_win.c @@ -21,10 +21,11 @@ static const Elm_Win_Trap *trap = NULL; #define TRAP(sd, name, ...) \ do \ { \ - if ((!trap) || (!trap->name) || \ - ((trap->name) && \ - (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \ - ecore_evas_##name(sd->ee, ##__VA_ARGS__); \ + if (sd->type != ELM_WIN_FAKE) \ + if ((!trap) || (!trap->name) || \ + ((trap->name) && \ + (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \ + ecore_evas_##name(sd->ee, ##__VA_ARGS__); \ } \ while (0) @@ -1946,6 +1947,7 @@ _elm_win_xwin_update(Elm_Win_Data *sd) { const char *s; + if (sd->type == ELM_WIN_FAKE) return; _internal_elm_win_xwindow_get(sd); if (sd->parent) { @@ -2908,10 +2910,16 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) { - Evas_Object *obj = eo_add(MY_CLASS, parent, elm_obj_win_constructor(name, type)); + Evas_Object *obj = eo_add(MY_CLASS, parent, elm_obj_win_constructor(name, type, NULL)); return obj; } +EAPI Evas_Object * +elm_win_fake(Ecore_Evas *ee) +{ + return eo_add(MY_CLASS, NULL, elm_obj_win_constructor(NULL, ELM_WIN_FAKE, ee)); +} + static void _elm_win_cb_hide(void *data EINA_UNUSED, Evas *e EINA_UNUSED, @@ -3008,7 +3016,7 @@ _accel_is_gl(void) } EOLIAN static void -_elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type) +_elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type, Ecore_Evas *oee) { sd->obj = obj; // in ctor @@ -3027,6 +3035,9 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t switch (type) { + case ELM_WIN_FAKE: + tmp_sd.ee = oee; + break; case ELM_WIN_INLINED_IMAGE: if (!parent) break; { @@ -3366,7 +3377,7 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t SD_CPY(shot.info); #undef SD_CPY - if ((trap) && (trap->add)) + if ((type != ELM_WIN_FAKE) && (trap) && (trap->add)) sd->trap_data = trap->add(obj); /* complementary actions, which depend on final smart data @@ -3438,31 +3449,35 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t /* use own version of ecore_evas_object_associate() that does TRAP() */ ecore_evas_data_set(sd->ee, "elm_win", obj); - evas_object_event_callback_add - (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - _elm_win_obj_callback_changed_size_hints, obj); - - evas_object_intercept_raise_callback_add - (obj, _elm_win_obj_intercept_raise, obj); - evas_object_intercept_lower_callback_add - (obj, _elm_win_obj_intercept_lower, obj); - evas_object_intercept_stack_above_callback_add - (obj, _elm_win_obj_intercept_stack_above, obj); - evas_object_intercept_stack_below_callback_add - (obj, _elm_win_obj_intercept_stack_below, obj); - evas_object_intercept_layer_set_callback_add - (obj, _elm_win_obj_intercept_layer_set, obj); - evas_object_intercept_show_callback_add - (obj, _elm_win_obj_intercept_show, obj); + if (type != ELM_WIN_FAKE) + { + evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + _elm_win_obj_callback_changed_size_hints, obj); + evas_object_intercept_raise_callback_add + (obj, _elm_win_obj_intercept_raise, obj); + evas_object_intercept_lower_callback_add + (obj, _elm_win_obj_intercept_lower, obj); + evas_object_intercept_stack_above_callback_add + (obj, _elm_win_obj_intercept_stack_above, obj); + evas_object_intercept_stack_below_callback_add + (obj, _elm_win_obj_intercept_stack_below, obj); + evas_object_intercept_layer_set_callback_add + (obj, _elm_win_obj_intercept_layer_set, obj); + evas_object_intercept_show_callback_add + (obj, _elm_win_obj_intercept_show, obj); + } TRAP(sd, name_class_set, name, _elm_appname); ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request); - ecore_evas_callback_resize_set(sd->ee, _elm_win_resize); - ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in); - ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in); - ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out); - ecore_evas_callback_move_set(sd->ee, _elm_win_move); ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change); + if (type != ELM_WIN_FAKE) + { + ecore_evas_callback_resize_set(sd->ee, _elm_win_resize); + ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in); + ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in); + ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out); + ecore_evas_callback_move_set(sd->ee, _elm_win_move); + } evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, NULL); evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, NULL); @@ -3483,6 +3498,8 @@ _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type t _elm_win_xwin_update(sd); #endif + /* do not append to list; all windows render as black rects */ + if (type == ELM_WIN_FAKE) return; _elm_win_list = eina_list_append(_elm_win_list, obj); _elm_win_count++; diff --git a/legacy/elementary/src/lib/elm_win.eo b/legacy/elementary/src/lib/elm_win.eo index 76e317b1b3..9cea8eabb6 100644 --- a/legacy/elementary/src/lib/elm_win.eo +++ b/legacy/elementary/src/lib/elm_win.eo @@ -1193,6 +1193,7 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window, params { @in const(char)* name; @in Elm_Win_Type type; + @in Ecore_Evas *oee; } } wm_manual_rotation_done_manual { diff --git a/legacy/elementary/src/lib/elm_win_common.h b/legacy/elementary/src/lib/elm_win_common.h index 5b5b6ff78b..7e45a3aada 100644 --- a/legacy/elementary/src/lib/elm_win_common.h +++ b/legacy/elementary/src/lib/elm_win_common.h @@ -69,6 +69,10 @@ typedef enum instead the window and all of its contents will be rendered to an image buffer and can be shown other process's plug image object*/ + ELM_WIN_FAKE /**< This window was created using a pre-existing canvas. + The window widget can be deleted, but the canvas + must be managed externally. + @since 1.13 */ } Elm_Win_Type; /** diff --git a/legacy/elementary/src/lib/elm_win_legacy.h b/legacy/elementary/src/lib/elm_win_legacy.h index a6f0c2b90c..e32f274962 100644 --- a/legacy/elementary/src/lib/elm_win_legacy.h +++ b/legacy/elementary/src/lib/elm_win_legacy.h @@ -16,6 +16,25 @@ */ EAPI Evas_Object *elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type); +/** + * Creates a fake window object using a pre-existing canvas. + * + * @param ee The Ecore_Evas to use + * + * The returned window widget will not manage or modify the canvas; + * this canvas must continue to be managed externally. + * + * Do not use this function if you are not writing a window manager. + * @warning Exact behaviors of this function are not guaranteed. + * + * @return The created object, or @c NULL on failure + * + * @ingroup Win + * + * @since 1.13 + */ +EAPI Evas_Object *elm_win_fake(Ecore_Evas *ee); + /** * Adds a window object with standard setup *