+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
This commit is contained in:
Mike Blumenkrantz 2015-01-10 00:33:55 -05:00
parent 20a933e044
commit 28872897b5
4 changed files with 69 additions and 28 deletions

View File

@ -21,10 +21,11 @@ static const Elm_Win_Trap *trap = NULL;
#define TRAP(sd, name, ...) \ #define TRAP(sd, name, ...) \
do \ do \
{ \ { \
if ((!trap) || (!trap->name) || \ if (sd->type != ELM_WIN_FAKE) \
((trap->name) && \ if ((!trap) || (!trap->name) || \
(trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \ ((trap->name) && \
ecore_evas_##name(sd->ee, ##__VA_ARGS__); \ (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \
ecore_evas_##name(sd->ee, ##__VA_ARGS__); \
} \ } \
while (0) while (0)
@ -1946,6 +1947,7 @@ _elm_win_xwin_update(Elm_Win_Data *sd)
{ {
const char *s; const char *s;
if (sd->type == ELM_WIN_FAKE) return;
_internal_elm_win_xwindow_get(sd); _internal_elm_win_xwindow_get(sd);
if (sd->parent) if (sd->parent)
{ {
@ -2908,10 +2910,16 @@ elm_win_add(Evas_Object *parent,
const char *name, const char *name,
Elm_Win_Type type) 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; 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 static void
_elm_win_cb_hide(void *data EINA_UNUSED, _elm_win_cb_hide(void *data EINA_UNUSED,
Evas *e EINA_UNUSED, Evas *e EINA_UNUSED,
@ -3008,7 +3016,7 @@ _accel_is_gl(void)
} }
EOLIAN static 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 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) switch (type)
{ {
case ELM_WIN_FAKE:
tmp_sd.ee = oee;
break;
case ELM_WIN_INLINED_IMAGE: case ELM_WIN_INLINED_IMAGE:
if (!parent) break; 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); SD_CPY(shot.info);
#undef SD_CPY #undef SD_CPY
if ((trap) && (trap->add)) if ((type != ELM_WIN_FAKE) && (trap) && (trap->add))
sd->trap_data = trap->add(obj); sd->trap_data = trap->add(obj);
/* complementary actions, which depend on final smart data /* 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() */ /* use own version of ecore_evas_object_associate() that does TRAP() */
ecore_evas_data_set(sd->ee, "elm_win", obj); ecore_evas_data_set(sd->ee, "elm_win", obj);
evas_object_event_callback_add if (type != ELM_WIN_FAKE)
(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, {
_elm_win_obj_callback_changed_size_hints, 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 evas_object_intercept_raise_callback_add
(obj, _elm_win_obj_intercept_raise, obj); (obj, _elm_win_obj_intercept_raise, obj);
evas_object_intercept_lower_callback_add evas_object_intercept_lower_callback_add
(obj, _elm_win_obj_intercept_lower, obj); (obj, _elm_win_obj_intercept_lower, obj);
evas_object_intercept_stack_above_callback_add evas_object_intercept_stack_above_callback_add
(obj, _elm_win_obj_intercept_stack_above, obj); (obj, _elm_win_obj_intercept_stack_above, obj);
evas_object_intercept_stack_below_callback_add evas_object_intercept_stack_below_callback_add
(obj, _elm_win_obj_intercept_stack_below, obj); (obj, _elm_win_obj_intercept_stack_below, obj);
evas_object_intercept_layer_set_callback_add evas_object_intercept_layer_set_callback_add
(obj, _elm_win_obj_intercept_layer_set, obj); (obj, _elm_win_obj_intercept_layer_set, obj);
evas_object_intercept_show_callback_add evas_object_intercept_show_callback_add
(obj, _elm_win_obj_intercept_show, obj); (obj, _elm_win_obj_intercept_show, obj);
}
TRAP(sd, name_class_set, name, _elm_appname); TRAP(sd, name_class_set, name, _elm_appname);
ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request); 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); 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_HIDE, _elm_win_cb_hide, NULL);
evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, 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); _elm_win_xwin_update(sd);
#endif #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_list = eina_list_append(_elm_win_list, obj);
_elm_win_count++; _elm_win_count++;

View File

@ -1193,6 +1193,7 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window,
params { params {
@in const(char)* name; @in const(char)* name;
@in Elm_Win_Type type; @in Elm_Win_Type type;
@in Ecore_Evas *oee;
} }
} }
wm_manual_rotation_done_manual { wm_manual_rotation_done_manual {

View File

@ -69,6 +69,10 @@ typedef enum
instead the window and all of its contents will be instead the window and all of its contents will be
rendered to an image buffer and can be shown rendered to an image buffer and can be shown
other process's plug image object*/ 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; } Elm_Win_Type;
/** /**

View File

@ -16,6 +16,25 @@
*/ */
EAPI Evas_Object *elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type); 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 * Adds a window object with standard setup
* *