win: Move autodel to C only

Note: this is C only, not legacy only.
The problem is that bindings will hold a strong reference to the window,
which will then die "under the rug" if autodel is enabled. This then
leads to at least ERR if not crashes.

Note:
elm_policy needs to support autodel and quit on last del only for C
applications. Bindings will require some other mechanism that doesn't
break all assumptions wrt. references.
This commit is contained in:
Jean-Philippe Andre 2017-11-10 16:50:01 +09:00
parent ee89f87673
commit 0c142462a1
6 changed files with 103 additions and 45 deletions

View File

@ -25,8 +25,6 @@ elm_main(int argc, char* argv[])
win_1.type_set(EFL_UI_WIN_BASIC);
});
win_1.autodel_set(true);
#if 0
win_1.eo_cxx::efl::Gfx::size_set({320, 300});

View File

@ -5540,15 +5540,19 @@ _efl_ui_win_icon_object_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
return sd->icon;
}
EOLIAN static void
_efl_ui_win_autodel_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool autodel)
/* Only for C API */
EAPI void
elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
{
ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
sd->autodel = autodel;
}
EOLIAN static Eina_Bool
_efl_ui_win_autodel_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
EAPI Eina_Bool
elm_win_autodel_get(const Eo *obj)
{
Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
if (!sd) return EINA_FALSE;
return sd->autodel;
}

View File

@ -305,51 +305,26 @@ class Efl.Ui.Win (Elm.Widget, Efl.Canvas, Efl.Access.Window,
skip: bool; [[The skip flag state ($true if it is to be skipped).]]
}
}
@property autodel {
set {
[[Set the window's autodel state.
When closing the window in any way outside of the program
control, like pressing the X button in the titlebar or using
a command from the Window Manager, a "delete,request" signal
is emitted to indicate that this event occurred and the
developer can take any action, which may include, or not,
destroying the window object.
When the $autodel parameter is set, the window will be
automatically destroyed when this event occurs, after the
signal is emitted. If $autodel is $false, then the window
will not be destroyed and is up to the program to do so
when it's required.
]]
}
get {
[[Get the window's autodel state.]]
}
values {
autodel: bool; [[If $true, the window will automatically delete
itself when closed.]]
}
}
@property autohide {
[[Window's autohide state.
This property works similarly to @.autodel, automatically handling
"delete,request" signals when set to $trze, with the difference
that it will hide the window, instead of destroying it.
When closing the window in any way outside of the program control,
like pressing the X button in the titlebar or using a command from
the Window Manager, a "delete,request" signal is emitted to indicate
that this event occurred and the developer can take any action, which
may include, or not, destroying the window object.
It is specially designed to work together with $ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN
which allows exiting Elementary's main loop when all the windows
are hidden.
When this property is set to $true, the window will be automatically
hidden when this event occurs, after the signal is emitted. If this
property is $false, nothing will happen, beyond the event emission.
Note: @.autodel and $autohide are not mutually exclusive. The window
C applications can use this option along with the quit policy
$ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting EFL's main
loop when all the windows are hidden.
Note: $autodel and $autohide are not mutually exclusive. The window
will be deleted if both are set to $true.
]]
set {
}
get {
}
values {
autohide: bool; [[If $true, the window will automatically hide
itself when closed.]]

View File

@ -105,7 +105,7 @@
#include <elm_win_common.h>
#ifdef EFL_EO_API_SUPPORT
#include <efl_ui_win.eo.h>
#include <elm_win_eo.h>
#endif
#ifndef EFL_NOLEGACY_API_SUPPORT
#include <elm_win_legacy.h>

View File

@ -6,6 +6,54 @@
#include "efl_ui_win.eo.h"
EAPI void elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel);
EAPI Eina_Bool elm_win_autodel_get(const Evas_Object *obj);
/**
* @brief Set the window's autodel state.
*
* When closing the window in any way outside of the program control, like
* pressing the X button in the titlebar or using a command from the Window
* Manager, a "delete,request" signal is emitted to indicate that this event
* occurred and the developer can take any action, which may include, or not,
* destroying the window object.
*
* When the @c autodel parameter is set, the window will be automatically
* destroyed when this event occurs, after the signal is emitted. If @c autodel
* is @c false, then the window will not be destroyed and is up to the program
* to do so when it's required.
*
* @param[in] obj The object.
* @param[in] autodel If @c true, the window will automatically delete itself
* when closed.
*
* Note: This function is only available in C.
*
* @ingroup Efl_Ui_Win
*/
static inline void
efl_ui_win_autodel_set(Efl_Ui_Win *obj, Eina_Bool autodel)
{
elm_win_autodel_set(obj, autodel);
}
/**
* @brief Get the window's autodel state.
*
* @param[in] obj The object.
*
* @return If @c true, the window will automatically delete itself when closed.
*
* Note: This function is only available in C.
*
* @ingroup Efl_Ui_Win
*/
static inline Eina_Bool
efl_ui_win_autodel_get(const Efl_Ui_Win *obj)
{
return elm_win_autodel_get(obj);
}
/**
* @}
*/

View File

@ -179,6 +179,39 @@ EAPI Evas_Object *elm_win_util_standard_add(const char *name, const cha
*/
EAPI Evas_Object *elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title);
/**
* @brief Set the window's autodel state.
*
* When closing the window in any way outside of the program control, like
* pressing the X button in the titlebar or using a command from the Window
* Manager, a "delete,request" signal is emitted to indicate that this event
* occurred and the developer can take any action, which may include, or not,
* destroying the window object.
*
* When the @c autodel parameter is set, the window will be automatically
* destroyed when this event occurs, after the signal is emitted. If @c autodel
* is @c false, then the window will not be destroyed and is up to the program
* to do so when it's required.
*
* @param[in] obj The object.
* @param[in] autodel If @c true, the window will automatically delete itself
* when closed.
*
* @ingroup Elm_Win
*/
EAPI void elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel);
/**
* @brief Get the window's autodel state.
*
* @param[in] obj The object.
*
* @return If @c true, the window will automatically delete itself when closed.
*
* @ingroup Elm_Win
*/
EAPI Eina_Bool elm_win_autodel_get(const Evas_Object *obj);
/**
* Set the floating mode of a window.
*