summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2014-12-03 15:24:33 -0200
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2015-01-05 19:55:09 -0200
commit8b4679b0501fc5ec2a657411239a6d0865fa1933 (patch)
tree6ac5a90c828439059f23392650887e39935835d3
parent209c058122a478938e2594e72e48d7d5ca09ce70 (diff)
downloadenlightenment-8b4679b0501fc5ec2a657411239a6d0865fa1933.tar.gz
elementary: Added autohide and ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN to elm_win
Added the "autohide" property to elm_win.eo. This property, when set to EINA_TRUE, automatically hides the window upon a "delete,request" signal. Created ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN, a new quit policy that automatically exit from the elm_run loop when all windows are hidden. It is an alternative to autodel to conciliates the memory management framework of Eo with any memory management model the program may be using (e.g. RAII principles of C++). Created the auxiliary function "_elm_win_policy_quit_triggered" to check triggering of quit policies. Calling it in "_elm_win_evas_object_smart_del" and "_elm_win_evas_object_smart_hide". The check on "smart_hide" is now necessary, since ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN can be triggered when a window is hidden. Created the auxiliary function "_elm_win_flush_cache_and_exit" to avoid code repetition for exiting the elm_run loop. Small updated on documentation to mention the new autohide property.
-rw-r--r--src/lib/elm_general.h9
-rw-r--r--src/lib/elm_win.c64
-rw-r--r--src/lib/elm_win.eo34
-rw-r--r--src/lib/elm_win.h2
4 files changed, 98 insertions, 11 deletions
diff --git a/src/lib/elm_general.h b/src/lib/elm_general.h
index 86eba3bef9..9c0235ad97 100644
--- a/src/lib/elm_general.h
+++ b/src/lib/elm_general.h
@@ -107,9 +107,12 @@ typedef enum
{
ELM_POLICY_QUIT_NONE = 0, /**< never quit the application
* automatically */
- ELM_POLICY_QUIT_LAST_WINDOW_CLOSED /**< quit when the
- * application's last
- * window is closed */
+ ELM_POLICY_QUIT_LAST_WINDOW_CLOSED, /**< quit when the
+ * application's last
+ * window is closed */
+ ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN /**< quit when the
+ * application's last
+ * window is hidden */
} Elm_Policy_Quit;
/**
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
index f2d8420ea0..1372274d44 100644
--- a/src/lib/elm_win.c
+++ b/src/lib/elm_win.c
@@ -199,6 +199,7 @@ struct _Elm_Win_Data
Eina_Bool modal : 1;
Eina_Bool demand_attention : 1;
Eina_Bool autodel : 1;
+ Eina_Bool autohide : 1;
Eina_Bool constrain : 1;
Eina_Bool resizing : 1;
Eina_Bool iconified : 1;
@@ -481,6 +482,41 @@ _elm_win_state_eval(void *data EINA_UNUSED)
_win_noblank_eval();
}
+static Eina_Bool
+_elm_win_policy_quit_triggered(Eo* triggering_obj)
+{
+ if ((!_elm_win_list) &&
+ (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
+ {
+ return EINA_TRUE;
+ }
+
+ if (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN)
+ {
+ Eina_List *l;
+ Evas_Object *win;
+
+ EINA_LIST_FOREACH(_elm_win_list, l, win)
+ if (win != triggering_obj && evas_object_visible_get(win) == EINA_TRUE)
+ {
+ return EINA_FALSE;
+ }
+ return EINA_TRUE;
+ }
+
+ return EINA_FALSE;
+}
+
+static void
+_elm_win_flush_cache_and_exit(Eo *obj)
+{
+ edje_file_cache_flush();
+ edje_collection_cache_flush();
+ evas_image_cache_flush(evas_object_evas_get(obj));
+ evas_font_cache_flush(evas_object_evas_get(obj));
+ elm_exit();
+}
+
static void
_elm_win_state_eval_queue(void)
{
@@ -1430,6 +1466,9 @@ _elm_win_evas_object_smart_hide(Eo *obj, Elm_Win_Data *sd)
evas_object_hide(sd->pointer.obj);
ecore_evas_hide(sd->pointer.ee);
}
+
+ if (_elm_win_policy_quit_triggered(obj))
+ _elm_win_flush_cache_and_exit(obj);
}
static void
@@ -1751,14 +1790,9 @@ _elm_win_evas_object_smart_del(Eo *obj, Elm_Win_Data *sd)
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
- if ((!_elm_win_list) &&
- (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
+ if (_elm_win_policy_quit_triggered(obj))
{
- edje_file_cache_flush();
- edje_collection_cache_flush();
- evas_image_cache_flush(evas_object_evas_get(obj));
- evas_font_cache_flush(evas_object_evas_get(obj));
- elm_exit();
+ _elm_win_flush_cache_and_exit(obj);
}
}
@@ -1870,6 +1904,8 @@ _elm_win_delete_request(Ecore_Evas *ee)
sd->autodel_clear = &autodel;
evas_object_ref(obj);
evas_object_smart_callback_call(obj, SIG_DELETE_REQUEST, NULL);
+ if (sd->autohide)
+ evas_object_hide(obj);
// FIXME: if above callback deletes - then the below will be invalid
if (autodel) evas_object_del(obj);
else sd->autodel_clear = NULL;
@@ -2695,6 +2731,8 @@ _elm_win_frame_cb_close(void *data,
sd->autodel_clear = &autodel;
evas_object_ref(win);
evas_object_smart_callback_call(win, SIG_DELETE_REQUEST, NULL);
+ if (sd->autohide)
+ evas_object_hide(win);
// FIXME: if above callback deletes - then the below will be invalid
if (autodel) evas_object_del(win);
else sd->autodel_clear = NULL;
@@ -3738,6 +3776,18 @@ _elm_win_autodel_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
}
EOLIAN static void
+_elm_win_autohide_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool autohide)
+{
+ sd->autohide = autohide;
+}
+
+EOLIAN static Eina_Bool
+_elm_win_autohide_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
+{
+ return sd->autohide;
+}
+
+EOLIAN static void
_elm_win_activate(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
{
TRAP(sd, activate);
diff --git a/src/lib/elm_win.eo b/src/lib/elm_win.eo
index 76e317b1b3..106728e088 100644
--- a/src/lib/elm_win.eo
+++ b/src/lib/elm_win.eo
@@ -55,6 +55,40 @@ class Elm_Win (Elm_Widget, Elm_Interface_Atspi_Window,
closed */
}
}
+ autohide {
+ set {
+ /*@
+ Set the window's autohide state.
+
+ This property works similarly to @p autodel, automatically handling
+ "delete,request" signals when set to @c EINA_TRUE, with the difference
+ that it will hide the window, instead of destroying it.
+
+ It is specially designed to work together with @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN
+ which allows exiting Elementary's main loop when all the windows
+ are hidden.
+
+ @see elm_win_autodel_set()
+
+ @note @p autodel and @autohide are not mutually exclusive. The window
+ will be destructed if both autodel and autohide is set to @c EINA_TRUE.
+
+ @ingroup Win */
+ }
+ get {
+ /*@
+ Get the window's autohide state.
+
+ @return If the window will be automatically hidden when closed
+
+ @see elm_win_autohide_set()
+
+ @ingroup Win */
+ }
+ values {
+ bool autohide;
+ }
+ }
override {
set {
/*@
diff --git a/src/lib/elm_win.h b/src/lib/elm_win.h
index 3b43b18111..b94f6f9ad3 100644
--- a/src/lib/elm_win.h
+++ b/src/lib/elm_win.h
@@ -69,7 +69,7 @@
* Signals that you can add callbacks for are:
*
* @li "delete,request": the user requested to close the window. See
- * elm_win_autodel_set().
+ * elm_win_autodel_set() and elm_win_autohide_set().
* @li "focus,in": window got focus (deprecated. use "focused" instead.)
* @li "focus,out": window lost focus (deprecated. use "unfocused" instead.)
* @li "moved": window that holds the canvas was moved