This is the first skeleton code for the focus policy refactoring.
The structure of the class diagram is below.
E_Focus --(has)--> E_Focus_Policy_Iface <|----(Implmentation)-- E_Focus_Policy_Topmost
|
|--(Implmentation)-- E_Focus_Policy_History
All the code for refatoring is diabled with defining the REFACTOR_FOCUS_POLIY feature.
Change-Id: Ia0d18599c53068f1bd68ae5019cf1a489c0bd1e8
src/bin/e_env.h \
src/bin/e_eom.h \
src/bin/e_error.h \
+src/bin/e_focus_policy_iface.h \
src/bin/e_focus.h \
src/bin/e_grabinput.h \
src/bin/e.h \
src/bin/e_env.c \
src/bin/e_eom.c \
src/bin/e_error.c \
+src/bin/e_focus_policy_history.c \
+src/bin/e_focus_policy_topmost.c \
+src/bin/e_focus_policy_iface.c \
src/bin/e_focus.c \
src/bin/e_grabinput.c \
src/bin/e_hints.c \
#define SMARTERRNR() return
#define SMARTERR(x) return x
+//Enable to build E20 for focus policy
+//#define REFACTOR_FOCUS_POLICY // refactoring for focus policy
+
/**
* @}
*/
#include "e.h"
+#ifdef REFACTOR_FOCUS_POLICY
+
+struct _E_Focus {
+ E_Focus_Policy_Ext policy_type; // the focus policy type
+ E_Focus_Policy_Iface *policy_iface; // the focus policy iface
+};
+
+static E_Focus_Policy_Iface *
+_e_focus_policy_iface_get(E_Zone* zone, E_Focus_Policy_Ext type)
+{
+ E_Focus_Policy_Iface *policy;
+
+ if (type == E_FOCUS_EXT_TOP_STACK)
+ {
+ policy = e_focus_policy_iface_topmost_new(zone);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy, NULL);
+ }
+ else if (type == E_FOCUS_EXT_HISTORY)
+ {
+ policy = e_focus_policy_iface_history_new(zone);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy, NULL);
+ }
+ else
+ {
+ ERR("Not Supoorted type : %d", type);
+ return NULL;
+ }
+
+ return policy;
+}
+
+EINTERN E_Focus *
+e_focus_new(E_Zone* zone, E_Focus_Policy_Ext policy_type)
+{
+ E_Focus *focus;
+ E_Focus_Policy_Iface *policy_iface;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(zone, NULL);
+
+ focus = E_NEW(E_Focus, 1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(focus, NULL);
+
+ policy_iface = _e_focus_policy_iface_get(zone, policy_type);
+ if (!policy_iface)
+ {
+ ERR("Fail to get the E_Focus_Policy_Iface type: %d", policy_type);
+ E_FREE(focus);
+ return NULL;
+ }
+
+ focus->policy_type = policy_type;
+ focus->policy_iface = policy_iface;
+
+ ELOGF("FOCUS", "Create E_Focus(%d)", NULL, policy_type);
+
+ return focus;
+}
+
+EINTERN void
+e_focus_del(E_Focus *focus)
+{
+ if (!focus) return;
+
+ if (focus->policy_iface)
+ e_focus_policy_iface_del(focus->policy_iface);
+
+ ELOGF("FOCUS", "Destroy E_Focus(%d)", NULL, focus->policy_type);
+
+ E_FREE(focus);
+}
+
+EINTERN E_Client *
+e_focus_focused_ec_get(E_Focus *focus)
+{
+ E_Focus_Policy_Iface *policy_iface;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(focus, NULL);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(focus->policy_iface, NULL);
+ policy_iface = focus->policy_iface;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy_iface->focused_ec_get, NULL);
+
+ return policy_iface->focused_ec_get(policy_iface->impl);
+}
+
+EINTERN Eina_Bool
+e_focus_update(E_Focus *focus)
+{
+ E_Focus_Policy_Iface *policy_iface;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(focus, EINA_FALSE);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(focus->policy_iface, EINA_FALSE);
+ policy_iface = focus->policy_iface;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy_iface->update, EINA_FALSE);
+
+ return policy_iface->update(policy_iface->impl);
+}
+
+#else
+
/* local subsystem functions */
/* local subsystem globals */
/* local subsystem functions */
+#endif
#ifndef E_FOCUS_H
#define E_FOCUS_H
+typedef struct _E_Focus E_Focus;
+
+EINTERN E_Focus *e_focus_new(E_Zone* zone, E_Focus_Policy_Ext policy_type);
+EINTERN void e_focus_del(E_Focus *focus);
+EINTERN E_Client *e_focus_focused_ec_get(E_Focus *focus); // get the current focused ec
+EINTERN Eina_Bool e_focus_update(E_Focus *focus); // update (find and set) the current focused ec
+
+//#ifdef REFACTOR_FOCUS_POLICY
+//#else
EINTERN void e_focus_event_mouse_in(E_Client* ec);
EINTERN void e_focus_event_mouse_out(E_Client* ec);
EINTERN void e_focus_event_mouse_down(E_Client* ec);
+//#endif
#endif
#endif
--- /dev/null
+#include "e.h"
+
+#ifdef REFACTOR_FOCUS_POLICY
+
+typedef struct _E_Focus_Policy_History_Impl E_Focus_Policy_History;
+
+struct _E_Focus_Policy_History_Impl
+{
+ E_Zone *zone;
+ E_Client *focused_ec;
+};
+
+static void
+_focus_policy_history_del(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_History *history_policy = (E_Focus_Policy_History *)impl;
+
+ if (!history_policy) return;
+
+ ELOGF("FOCUS", "delete history focus policy.", NULL);
+
+ E_FREE(history_policy);
+}
+
+static E_Client *
+_focus_policy_history_focused_ec_get(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_History *history_policy;
+
+ history_policy = (E_Focus_Policy_History *)impl;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(history_policy, NULL);
+
+ return history_policy->focused_ec;
+}
+
+static Eina_Bool
+_focus_policy_history_update(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_History *history_policy;
+
+ history_policy = (E_Focus_Policy_History *)impl;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(history_policy, EINA_FALSE);
+
+ // TODO:
+
+ return EINA_TRUE;
+}
+
+EINTERN E_Focus_Policy_Iface *
+e_focus_policy_iface_history_new(E_Zone* zone)
+{
+ E_Focus_Policy_Iface *policy_iface;
+ E_Focus_Policy_History *history_policy;
+
+ policy_iface = E_NEW(E_Focus_Policy_Iface, 1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy_iface, NULL);
+
+ history_policy = E_NEW(E_Focus_Policy_History, 1);
+ EINA_SAFETY_ON_NULL_GOTO(history_policy, fail);
+
+ history_policy->zone = zone;
+
+ policy_iface->impl = (E_Focus_Policy_Impl *)history_policy;
+ policy_iface->del = _focus_policy_history_del;
+ policy_iface->focused_ec_get = _focus_policy_history_focused_ec_get;
+ policy_iface->update = _focus_policy_history_update;
+
+ return policy_iface;
+
+fail:
+ _focus_policy_history_del(history_policy);
+
+ E_FREE(policy_iface);
+
+ return NULL;
+}
+
+#endif
+
+
--- /dev/null
+#include "e.h"
+
+EINTERN void
+e_focus_policy_iface_del(E_Focus_Policy_Iface *policy_iface)
+{
+ if (!policy_iface) return;
+
+ EINA_SAFETY_ON_NULL_RETURN(policy_iface->del);
+
+ policy_iface->del(policy_iface->impl);
+
+ E_FREE(policy_iface);
+}
--- /dev/null
+#ifdef E_TYPEDEFS
+#else
+#ifndef E_FOCUS_POLICY_IFACE_H
+#define E_FOCUS_POLICY_IFACE_H
+
+typedef struct _E_Focus_Policy_Iface E_Focus_Policy_Iface;
+typedef void E_Focus_Policy_Impl;
+
+struct _E_Focus_Policy_Iface
+{
+ E_Focus_Policy_Impl *impl;
+
+ void (*del)(E_Focus_Policy_Impl *impl); // delete the focus_policy implementation
+
+ E_Client *(*focused_ec_get)(E_Focus_Policy_Impl *impl); // get the current focused ec
+ Eina_Bool (*update)(E_Focus_Policy_Impl *impl); // update the current focus
+};
+
+EINTERN E_Focus_Policy_Iface *e_focus_policy_iface_topmost_new(E_Zone* zone);
+EINTERN E_Focus_Policy_Iface *e_focus_policy_iface_history_new(E_Zone* zone);
+
+EINTERN void e_focus_policy_iface_del(E_Focus_Policy_Iface *policy_iface);
+
+#endif
+#endif
--- /dev/null
+#include "e.h"
+
+#ifdef REFACTOR_FOCUS_POLICY
+
+typedef struct _E_Focus_Policy_Topmost_Impl E_Focus_Policy_Topmost;
+
+struct _E_Focus_Policy_Topmost_Impl
+{
+ E_Zone *zone;
+ E_Client *focused_ec;
+};
+
+static void
+_focus_policy_topmost_del(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_Topmost *topmost_policy = (E_Focus_Policy_Topmost *)impl;
+
+ if (!topmost_policy) return;
+
+ E_FREE(topmost_policy);
+}
+
+static E_Client *
+_focus_policy_topmost_focused_ec_get(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_Topmost *topmost_policy;
+
+ topmost_policy = (E_Focus_Policy_Topmost *)impl;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(topmost_policy, NULL);
+
+ return topmost_policy->focused_ec;
+}
+
+static Eina_Bool
+_focus_policy_topmost_update(E_Focus_Policy_Impl *impl)
+{
+ E_Focus_Policy_Topmost *topmost_policy;
+
+ topmost_policy = (E_Focus_Policy_Topmost *)impl;
+ EINA_SAFETY_ON_NULL_RETURN_VAL(topmost_policy, EINA_FALSE);
+
+ return EINA_TRUE;
+}
+
+EINTERN E_Focus_Policy_Iface *
+e_focus_policy_iface_topmost_new(E_Zone* zone)
+{
+ E_Focus_Policy_Iface *policy_iface;
+ E_Focus_Policy_Topmost *topmost_policy;
+ E_Zone_Hook *zone_hook;
+
+ policy_iface = E_NEW(E_Focus_Policy_Iface, 1);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(policy_iface, NULL);
+
+ topmost_policy = E_NEW(E_Focus_Policy_Topmost, 1);
+ EINA_SAFETY_ON_NULL_GOTO(topmost_policy, fail);
+
+ topmost_policy->zone = zone;
+
+ policy_iface->impl = (E_Focus_Policy_Impl *)topmost_policy;
+ policy_iface->del = _focus_policy_topmost_del;
+ policy_iface->focused_ec_get = _focus_policy_topmost_focused_ec_get;
+ policy_iface->update = _focus_policy_topmost_update;
+
+ return policy_iface;
+
+fail:
+ _focus_policy_topmost_del(topmost_policy);
+
+ E_FREE(policy_iface);
+
+ return NULL;
+}
+
+#endif
+
#include "e_user.h"
#include "e_path.h"
#include "e_error.h"
+#include "e_focus_policy_iface.h"
+#include "e_focus.h"
#include "e_zone.h"
#include "e_desk.h"
#include "e_pixmap.h"
#include "e_config_data.h"
#include "e_icon.h"
#include "e_module.h"
-#include "e_focus.h"
#include "e_place.h"
#include "e_signals.h"
#include "e_layout.h"