#include "e_mod_private_data.h"
#include "e_mod_main.h"
#include "e_mod_quickpanel.h"
-#include "e_mod_indicator.h"
#include "e_mod_gesture.h"
+#include "e_mod_region.h"
#include "e_mod_transit.h"
#include "e_mod_rotation.h"
#define SMART_NAME "quickpanel_object"
#define INTERNAL_ENTRY \
Mover_Data *md; \
- md = evas_object_smart_data_get(obj);
+ md = evas_object_smart_data_get(obj)
#define QP_SHOW(EC) \
do \
typedef struct _Pol_Quickpanel Pol_Quickpanel;
typedef struct _Mover_Data Mover_Data;
-typedef struct _Handler_Data Handler_Data;
typedef struct _Mover_Effect_Data Mover_Effect_Data;
struct _Pol_Quickpanel
{
E_Client *ec;
Evas_Object *mover;
+ Evas_Object *indi_obj;
+ Evas_Object *handler_obj;
- struct
- {
- Evas_Object *obj;
- Eina_Rectangle rect;
- } handler;
+ Eina_List *hooks;
+ Eina_List *events;
+
+ Rot_Idx rotation;
Eina_Bool show_block;
};
struct _Mover_Data
{
Pol_Quickpanel *qp;
+ E_Client *ec;
Evas_Object *smart_obj; //smart object
Evas_Object *qp_layout_obj; // quickpanel's e_layout_object
Evas_Object *base_clip; // clipper for quickapnel base object
Evas_Object *handler_clip; // clipper for quickpanel handler object
- struct
- {
- Handler_Data *data;
- Eina_Rectangle rect;
- } handler;
+ Eina_Rectangle handler_rect;
+ Rot_Idx rotation;
struct
{
Pol_Transit *transit;
Mover_Effect_Data *data;
- int y;
+ int x, y;
unsigned int timestamp;
float accel;
Eina_Bool visible;
} effect_info;
};
-struct _Handler_Data
-{
- Pol_Quickpanel *qp;
- Pol_Gesture *gesture;
- Evas_Object *handler;
- Evas_Object *mover;
-};
-
struct _Mover_Effect_Data
{
Pol_Transit *transit;
Evas_Object *mover;
- int from_dy;
- int to_dy;
+ int from;
+ int to;
Eina_Bool visible : 1;
};
static Pol_Quickpanel *_pol_quickpanel = NULL;
-static Eina_List *_quickpanel_events = NULL;
-static Eina_List *_quickpanel_hooks = NULL;
static Evas_Smart *_mover_smart = NULL;
static Pol_Quickpanel *
-_quickpanel_find(E_Client *ec)
+_quickpanel_get()
{
- if (!_pol_quickpanel)
- return NULL;
-
- if (_pol_quickpanel->ec == ec)
- return _pol_quickpanel;
-
- return NULL;
+ return _pol_quickpanel;
}
static void
_mover_intercept_show(void *data, Evas_Object *obj)
{
- Mover_Data *md = data;
- E_Client *ec = md->qp->ec;
+ Mover_Data *md;
+ E_Client *ec;
Evas *e;
+ md = data;
md->qp->show_block = EINA_FALSE;
- e = evas_object_evas_get(obj);
-
+ ec = md->ec;
QP_SHOW(ec);
/* force update */
e_comp_object_dirty(ec->frame);
e_comp_object_render(ec->frame);
- // create base_clip
+ // create base_clip
+ e = evas_object_evas_get(obj);
md->base_clip = evas_object_rectangle_add(e);
e_layout_pack(md->qp_layout_obj, md->base_clip);
e_layout_child_move(md->base_clip, 0, 0);
// create handler_mirror_obj
md->handler_mirror_obj = e_comp_object_util_mirror_add(ec->frame);
e_layout_pack(md->qp_layout_obj, md->handler_mirror_obj);
- e_layout_child_move(md->handler_mirror_obj, md->handler.rect.x, md->handler.rect.y);
+ e_layout_child_move(md->handler_mirror_obj, ec->x, ec->y);
e_layout_child_resize(md->handler_mirror_obj, ec->w, ec->h);
evas_object_show(md->handler_mirror_obj);
// create handler_clip
md->handler_clip = evas_object_rectangle_add(e);
e_layout_pack(md->qp_layout_obj, md->handler_clip);
- e_layout_child_move(md->handler_clip, md->handler.rect.x, md->handler.rect.y);
- e_layout_child_resize(md->handler_clip, md->handler.rect.w, md->handler.rect.h);
+ e_layout_child_move(md->handler_clip, md->handler_rect.x, md->handler_rect.y);
+ e_layout_child_resize(md->handler_clip, md->handler_rect.w, md->handler_rect.h);
evas_object_color_set(md->handler_clip, 255, 255, 255, 255);
evas_object_show(md->handler_clip);
evas_object_clip_set(md->handler_mirror_obj, md->handler_clip);
static Eina_Bool
_mover_obj_handler_move(Mover_Data *md, int x, int y)
{
- // angle 0 case
- // do not move handler out of screen.
- if ((y + md->handler.rect.h) > md->qp->ec->zone->h) return EINA_FALSE;
-
- // angle 0 case
- md->handler.rect.y = y;
-
- e_layout_child_resize(md->base_clip, md->qp->ec->w, md->handler.rect.y); // base clip resize
+ E_Zone *zone;
+ E_Client *ec;
- e_layout_child_move(md->handler_mirror_obj, md->handler.rect.x, md->handler.rect.y - md->qp->ec->h + md->handler.rect.h); // handler mirror object move
- e_layout_child_move(md->handler_clip, md->handler.rect.x, md->handler.rect.y); // handler mirror object move
+ ec = md->ec;
+ zone = ec->zone;
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ if ((x + md->handler_rect.w) > zone->w) return EINA_FALSE;
+
+ md->handler_rect.x = x;
+ e_layout_child_resize(md->base_clip, md->handler_rect.x, ec->h);
+ e_layout_child_move(md->handler_mirror_obj, md->handler_rect.x - ec->w + md->handler_rect.w, md->handler_rect.y);
+ e_layout_child_move(md->handler_clip, md->handler_rect.x, md->handler_rect.y);
+ break;
+ case ROT_IDX_180:
+ if ((y - md->handler_rect.h) < 0) return EINA_FALSE;
+
+ md->handler_rect.y = y;
+ e_layout_child_move(md->base_clip, md->handler_rect.x, md->handler_rect.y);
+ e_layout_child_resize(md->base_clip, ec->w, ec->h - md->handler_rect.y);
+ e_layout_child_move(md->handler_mirror_obj, md->handler_rect.x, md->handler_rect.y - md->handler_rect.h);
+ e_layout_child_move(md->handler_clip, md->handler_rect.x, md->handler_rect.y - md->handler_rect.h);
+ break;
+ case ROT_IDX_270:
+ if ((x - md->handler_rect.w) < 0) return EINA_FALSE;
+
+ md->handler_rect.x = x;
+ e_layout_child_move(md->base_clip, md->handler_rect.x, md->handler_rect.y);
+ e_layout_child_resize(md->base_clip, ec->w - md->handler_rect.x, ec->h);
+ e_layout_child_move(md->handler_mirror_obj, md->handler_rect.x - md->handler_rect.w, md->handler_rect.y);
+ e_layout_child_move(md->handler_clip, md->handler_rect.x - md->handler_rect.w, md->handler_rect.y);
+ break;
+ default:
+ if ((y + md->handler_rect.h) > zone->h) return EINA_FALSE;
+
+ md->handler_rect.y = y;
+ e_layout_child_resize(md->base_clip, ec->w, md->handler_rect.y);
+ e_layout_child_move(md->handler_mirror_obj, md->handler_rect.x, md->handler_rect.y - ec->h + md->handler_rect.h);
+ e_layout_child_move(md->handler_clip, md->handler_rect.x, md->handler_rect.y);
+ }
return EINA_TRUE;
}
{
Evas_Object *mover;
Mover_Data *md;
+ int x, y, w, h;
- if (!qp->ec) return NULL;
- if (!qp->ec->frame) return NULL;
-
- if (qp->mover)
- return qp->mover;
+ /* Pause WM Rotation during mover object is working. */
+ e_zone_rotation_block_set(qp->ec->zone, "quickpanel-mover", EINA_TRUE);
_mover_smart_init();
mover = evas_object_smart_add(evas_object_evas_get(qp->ec->frame), _mover_smart);
+ /* Should setup 'md' before call evas_object_show() */
md = evas_object_smart_data_get(mover);
md->qp = qp;
- md->handler.rect.w = qp->handler.rect.w;
- md->handler.rect.h = qp->handler.rect.h;
+ md->ec = qp->ec;
+ md->rotation = qp->rotation;
+
+ e_mod_region_rectangle_get(qp->handler_obj, qp->rotation, &x, &y, &w, &h);
+ EINA_RECTANGLE_SET(&md->handler_rect, x, y, w, h);
- evas_object_move(mover, 0, 0); // 0 angle case
+ evas_object_move(mover, 0, 0);
evas_object_resize(mover, qp->ec->w, qp->ec->h);
evas_object_show(mover);
- qp->mover = mover;
-
- e_zone_rotation_block_set(qp->ec->zone, "quickpanel-mover", EINA_TRUE);
+ qp->show_block = EINA_FALSE;
return mover;
}
return NULL;
md = evas_object_smart_data_get(mover);
-
+ md->effect_info.x = x;
md->effect_info.y = y;
md->effect_info.timestamp = timestamp;
return mover;
}
+static void
+_mover_obj_visible_set(Evas_Object *mover, Eina_Bool visible)
+{
+ Mover_Data *md;
+ E_Client *ec;
+ int x = 0, y = 0;
+
+ md = evas_object_smart_data_get(mover);
+ ec = md->ec;
+
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ x = visible ? ec->zone->w : 0;
+ break;
+ case ROT_IDX_180:
+ y = visible ? 0 : ec->zone->h;
+ break;
+ case ROT_IDX_270:
+ x = visible ? 0 : ec->zone->w;
+ break;
+ default:
+ y = visible ? ec->zone->h : 0;
+ break;
+ }
+
+ _mover_obj_handler_move(md, x, y);
+}
+
static Eina_Bool
_mover_obj_move(Evas_Object *mover, int x, int y, unsigned int timestamp)
{
Mover_Data *md;
- int dy;
+ int dp;
unsigned int dt;
if (!mover) return EINA_FALSE;
/* Calculate the acceleration of movement,
* determine the visibility of quickpanel based on the result. */
- dy = y - md->effect_info.y;
dt = timestamp - md->effect_info.timestamp;
- if (dt) md->effect_info.accel = (float)dy / (float)dt;
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ dp = x - md->effect_info.x;
+ break;
+ case ROT_IDX_180:
+ dp = md->effect_info.y - y;
+ break;
+ case ROT_IDX_270:
+ dp = md->effect_info.x - x;
+ break;
+ default:
+ dp = y - md->effect_info.y;
+ break;
+ }
+ if (dt) md->effect_info.accel = (float)dp / (float)dt;
/* Store current information to next calculation */
+ md->effect_info.x = x;
md->effect_info.y = y;
md->effect_info.timestamp = timestamp;
}
static Pol_Transit_Effect *
-_mover_obj_effect_data_new(Pol_Transit *transit, Evas_Object *mover, int from_y, int to_y, Eina_Bool visible)
+_mover_obj_effect_data_new(Pol_Transit *transit, Evas_Object *mover, int from, int to, Eina_Bool visible)
{
Mover_Effect_Data *ed;
ed->transit = transit;
ed->mover = mover;
ed->visible = visible;
- ed->from_dy = from_y;
- ed->to_dy = to_y;
+ ed->from = from;
+ ed->to = to;
return ed;
}
{
Mover_Effect_Data *ed = effect;
Mover_Data *md;
- int new_y;
+ int new_x = 0, new_y = 0;
md = evas_object_smart_data_get(ed->mover);
- new_y = ed->from_dy + (ed->to_dy * progress);
- _mover_obj_handler_move(md, 0, new_y);
+
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ case ROT_IDX_270:
+ new_x = ed->from + (ed->to * progress);
+ break;
+ default:
+ case ROT_IDX_180:
+ new_y = ed->from + (ed->to * progress);
+ break;
+ }
+
+ _mover_obj_handler_move(md, new_x, new_y);
}
static void
}
static void
-_mover_obj_effect_start(Evas_Object *mover, int from_y, Eina_Bool visible)
+_mover_obj_effect_start(Evas_Object *mover, Eina_Bool visible)
{
Mover_Data *md;
E_Client *ec;
Pol_Transit *transit;
Pol_Transit_Effect *effect;
- int to_y;
+ int from;
+ int to;
double duration;
const double ref = 0.1;
md = evas_object_smart_data_get(mover);
ec = md->qp->ec;
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ from = md->handler_rect.x;
+ to = (visible) ? (ec->zone->w - from) : (-from);
+ duration = ((double)abs(to) / (ec->zone->w / 2)) * ref;
+ break;
+ case ROT_IDX_180:
+ from = md->handler_rect.y;
+ to = (visible) ? (-from) : (ec->zone->h - from);
+ duration = ((double)abs(to) / (ec->zone->h / 2)) * ref;
+ break;
+ case ROT_IDX_270:
+ from = md->handler_rect.x;
+ to = (visible) ? (-from) : (ec->zone->w - from);
+ duration = ((double)abs(to) / (ec->zone->w / 2)) * ref;
+ break;
+ default:
+ from = md->handler_rect.y;
+ to = (visible) ? (ec->zone->h - from) : (-from);
+ duration = ((double)abs(to) / (ec->zone->h / 2)) * ref;
+ break;
+ }
+
transit = pol_transit_add();
pol_transit_object_add(transit, mover);
pol_transit_tween_mode_set(transit, POL_TRANSIT_TWEEN_MODE_DECELERATE);
- /* determine the position as a destination */
- to_y = (visible) ? (ec->zone->h - from_y) : (-from_y);
-
- /* determine the transit's duration */
- duration = ((double)abs(to_y) / (ec->zone->h / 2)) * ref;
pol_transit_duration_set(transit, duration);
/* create and add effect to transit */
- effect = _mover_obj_effect_data_new(transit, mover, from_y, to_y, visible);
+ effect = _mover_obj_effect_data_new(transit, mover, from, to, visible);
pol_transit_effect_add(transit, _mover_obj_effect_op, effect, _mover_obj_effect_data_free);
/* start transit */
}
static Eina_Bool
-_mover_obj_visibility_eval(Evas_Object *mover, int x, int y, unsigned int timestamp)
+_mover_obj_visibility_eval(Evas_Object *mover)
{
E_Client *ec;
Mover_Data *md;
+ Eina_Bool threshold;
const float sensitivity = 1.5; /* hard coded. (arbitrary) */
md = evas_object_smart_data_get(mover);
- ec = md->qp->ec;
+ ec = md->ec;
+
+ switch (md->rotation)
+ {
+ case ROT_IDX_90:
+ threshold = (md->handler_rect.x > (ec->zone->w / 2));
+ break;
+ case ROT_IDX_180:
+ threshold = (md->handler_rect.y < (ec->zone->h / 2));
+ break;
+ case ROT_IDX_270:
+ threshold = (md->handler_rect.x < (ec->zone->w / 2));
+ break;
+ default:
+ threshold = (md->handler_rect.y > (ec->zone->h / 2));
+ break;
+ }
if ((md->effect_info.accel > sensitivity) ||
- ((md->effect_info.accel > -sensitivity) && (y > ec->zone->h / 2)))
+ ((md->effect_info.accel > -sensitivity) && threshold))
return EINA_TRUE;
return EINA_FALSE;
}
static void
-_handler_obj_cb_mover_obj_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
+_region_obj_cb_gesture_start(void *data, Evas_Object *handler, int x, int y, unsigned int timestamp)
{
- Handler_Data *hd;
+ Pol_Quickpanel *qp;
- hd = data;
- hd->mover = NULL;
-}
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ return;
-static void
-_handler_obj_cb_gesture_start(void *data, Evas_Object *handler, int x, int y, unsigned int timestamp)
-{
- Handler_Data *hd;
+ if (EINA_UNLIKELY(!qp->ec))
+ return;
- hd = data;
- if (hd->mover)
+ if (e_object_is_del(E_OBJECT(qp->ec)))
+ return;
+
+ if (qp->mover)
{
- if (_mover_obj_is_animating(hd->mover))
+ if (_mover_obj_is_animating(qp->mover))
return;
DBG("Mover object already existed");
- evas_object_del(hd->mover);
+ evas_object_del(qp->mover);
}
e_comp_wl_touch_cancel();
- hd->mover = _mover_obj_new_with_move(hd->qp, 0, y, timestamp);
- evas_object_event_callback_add(hd->mover, EVAS_CALLBACK_DEL, _handler_obj_cb_mover_obj_del, hd);
+ qp->mover = _mover_obj_new_with_move(qp, x, y, timestamp);
}
static void
-_handler_obj_cb_gesture_move(void *data, Evas_Object *handler, int x, int y, unsigned int timestamp)
+_region_obj_cb_gesture_move(void *data, Evas_Object *handler, int x, int y, unsigned int timestamp)
{
- Handler_Data *hd;
+ Pol_Quickpanel *qp;
- hd = data;
- if (!hd->mover)
+ qp = data;
+ if (!qp->mover)
return;
- if (_mover_obj_is_animating(hd->mover))
+ if (_mover_obj_is_animating(qp->mover))
return;
- _mover_obj_move(hd->mover, 0, y, timestamp);
+ _mover_obj_move(qp->mover, x, y, timestamp);
}
static void
-_handler_obj_cb_gesture_end(void *data EINA_UNUSED, Evas_Object *handler, int x, int y, unsigned int timestamp)
+_region_obj_cb_gesture_end(void *data EINA_UNUSED, Evas_Object *handler, int x, int y, unsigned int timestamp)
{
- Handler_Data *hd;
+ Pol_Quickpanel *qp;
Eina_Bool v;
- hd = data;
- if (!hd->mover)
+ qp = data;
+ if (!qp->mover)
{
DBG("Could not find quickpanel mover object");
return;
}
- if (_mover_obj_is_animating(hd->mover))
+ if (_mover_obj_is_animating(qp->mover))
return;
- v = _mover_obj_visibility_eval(hd->mover, 0, y, timestamp);
- _mover_obj_effect_start(hd->mover, y, v);
+ v = _mover_obj_visibility_eval(qp->mover);
+ _mover_obj_effect_start(qp->mover, v);
}
static void
-_handler_obj_cb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+_quickpanel_free(Pol_Quickpanel *qp)
{
- Handler_Data *hd;
-
- hd = data;
-
- E_FREE_FUNC(hd->mover, evas_object_del);
- E_FREE_FUNC(hd->gesture, e_mod_gesture_del);
-
- free(hd);
-}
-
-static void
-_quickpanel_free(Pol_Quickpanel *pol_qp)
-{
- if (pol_qp->mover)
- evas_object_del(pol_qp->mover);
-
- E_FREE_FUNC(pol_qp->handler.obj, evas_object_del);
- E_FREE_LIST(_quickpanel_hooks, e_client_hook_del);
+ E_FREE_FUNC(qp->mover, evas_object_del);
+ E_FREE_FUNC(qp->indi_obj, evas_object_del);
+ E_FREE_FUNC(qp->handler_obj, evas_object_del);
+ E_FREE_LIST(qp->events, ecore_event_handler_del);
+ E_FREE_LIST(qp->hooks, e_client_hook_del);
E_FREE(_pol_quickpanel);
}
static void
-_quickpanel_hook_client_del(void *d EINA_UNUSED, E_Client *ec)
+_quickpanel_hook_client_del(void *d, E_Client *ec)
{
- Pol_Quickpanel *pol_qp;
+ Pol_Quickpanel *qp;
+
+ qp = d;
+ if (EINA_UNLIKELY(!qp))
+ return;
if (!ec) return;
- pol_qp = _quickpanel_find(ec);
- if (!pol_qp)
+ if (qp->ec != ec)
return;
- _quickpanel_free(pol_qp);
+ _quickpanel_free(qp);
}
static void
-_quickpanel_client_evas_cb_show(void *data, Evas *evas, Evas_Object *qp_obj, void *event)
+_quickpanel_client_evas_cb_show(void *data, Evas *evas, Evas_Object *obj, void *event)
{
- Evas_Object *handler = data;
+ Pol_Quickpanel *qp;
+
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ return;
- evas_object_show(handler);
- evas_object_raise(handler);
+ if (qp->show_block)
+ {
+ QP_HIDE(qp->ec);
+ evas_object_show(qp->indi_obj);
+ return;
+ }
+
+ evas_object_show(qp->handler_obj);
+ evas_object_raise(qp->handler_obj);
+
+ evas_object_hide(qp->indi_obj);
}
static void
-_quickpanel_client_evas_cb_hide(void *data, Evas *evas, Evas_Object *qp_obj, void *event)
+_quickpanel_client_evas_cb_hide(void *data, Evas *evas, Evas_Object *obj, void *event)
{
- evas_object_hide((Evas_Object *)data);
+ Pol_Quickpanel *qp;
+
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ return;
+
+ evas_object_hide(qp->handler_obj);
+ evas_object_show(qp->indi_obj);
}
static void
-_quickpanel_client_evas_cb_move(void *data, Evas *evas, Evas_Object *qp_obj, void *event)
+_quickpanel_client_evas_cb_move(void *data, Evas *evas, Evas_Object *obj, void *event)
{
- Evas_Object *handler = data;
+ Pol_Quickpanel *qp;
int x, y, hx, hy;
- hx = _pol_quickpanel->handler.rect.x;
- hy = _pol_quickpanel->handler.rect.y;
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ return;
- evas_object_geometry_get(qp_obj, &x, &y, NULL, NULL);
- evas_object_move(handler, x + hx, y + hy);
+ e_mod_region_rectangle_get(qp->handler_obj, qp->rotation, &hx, &hy, NULL, NULL);
+ evas_object_geometry_get(obj, &x, &y, NULL, NULL);
+ evas_object_move(qp->handler_obj, x + hx, y + hy);
}
static void
-_quickpanel_handler_rect_add(Pol_Quickpanel *qp, int angle, int x, int y, int w, int h)
+_quickpanel_handler_rect_add(Pol_Quickpanel *qp, Rot_Idx ridx, int x, int y, int w, int h)
{
E_Client *ec;
- Evas_Object *handler;
+ Evas_Object *obj;
ec = qp->ec;
ELOGF("QUICKPANEL", "Handler Geo Set | x %d, y %d, w %d, h %d",
NULL, NULL, x, y, w, h);
- handler =
- e_mod_quickpanel_handler_object_add(ec,
- ec->client.x + x,
- ec->client.y + y,
- w, h);
+ if (qp->handler_obj)
+ goto end;
+
+ obj = e_mod_region_object_new();
+ if (!obj)
+ return;
+
+ e_mod_region_cb_set(obj,
+ _region_obj_cb_gesture_start,
+ _region_obj_cb_gesture_move,
+ _region_obj_cb_gesture_end, qp);
/* Add handler object to smart member to follow the client's stack */
- evas_object_smart_member_add(handler, ec->frame);
- evas_object_propagate_events_set(handler, 0);
-
+ evas_object_smart_member_add(obj, ec->frame);
+ evas_object_propagate_events_set(obj, 0);
if (evas_object_visible_get(ec->frame))
- evas_object_show(handler);
+ evas_object_show(obj);
- evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,
- _quickpanel_client_evas_cb_show, handler);
- evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE,
- _quickpanel_client_evas_cb_hide, handler);
- evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE,
- _quickpanel_client_evas_cb_move, handler);
+ qp->handler_obj = obj;
- EINA_RECTANGLE_SET(&qp->handler.rect, x, y, w, h);
- qp->handler.obj = handler;
+end:
+ e_mod_region_rectangle_set(qp->handler_obj, ridx, x, y, w, h);
}
static void
-_quickpanel_handler_region_set(Pol_Quickpanel *qp, int angle, Eina_Tiler *tiler)
+_quickpanel_handler_region_set(Pol_Quickpanel *qp, Rot_Idx ridx, Eina_Tiler *tiler)
{
Eina_Iterator *it;
Eina_Rectangle *r;
+ int x = 0, y = 0;
- /* NOTE: supported single rectangle, not tiler */
+ /* FIXME supported single rectangle, not tiler */
it = eina_tiler_iterator_new(tiler);
EINA_ITERATOR_FOREACH(it, r)
{
- _quickpanel_handler_rect_add(qp, angle, r->x, r->y, r->w, r->h);
- e_mod_indicator_create(r->w, r->h);
+ _quickpanel_handler_rect_add(qp, ridx, r->x, r->y, r->w, r->h);
+
+ /* FIXME: this should be set by another way like indicator */
+ if (ridx == ROT_IDX_180)
+ {
+ x = 0;
+ y = qp->ec->zone->h - r->h;
+ }
+ else if (ridx == ROT_IDX_270)
+ {
+ x = qp->ec->zone->w - r->w;
+ y = 0;
+ }
+ e_mod_region_rectangle_set(qp->indi_obj, ridx, x, y, r->w, r->h);
+
break;
}
eina_iterator_free(it);
{
E_Client *ec;
Evas_Object *mover;
- Mover_Data *md;
Eina_Bool cur_vis = EINA_FALSE;
- int from_y;
int x, y, w, h;
ec = qp->ec;
_mover_obj_effect_stop(mover);
}
-
- md = evas_object_smart_data_get(mover);
- from_y = md->handler.rect.y;
}
else
{
- from_y = vis ? 0 : ec->zone->h;
- mover = _mover_obj_new_with_move(qp, 0, from_y, 0);
+ mover = _mover_obj_new(qp);
+ _mover_obj_visible_set(mover, !vis);
}
- _mover_obj_effect_start(mover, from_y, vis);
+ _mover_obj_effect_start(mover, vis);
}
else
{
}
}
-static void
-_quickpanel_client_evas_cb_show_block(void *data, Evas *evas, Evas_Object *qp_obj, void *event)
-{
- Pol_Quickpanel *pol_qp = data;
- E_Client *ec = pol_qp->ec;
-
- if (pol_qp->show_block)
- QP_HIDE(ec);
- else
- {
- evas_object_event_callback_del_full(ec->frame,
- EVAS_CALLBACK_SHOW,
- _quickpanel_client_evas_cb_show_block,
- pol_qp);
- }
-}
-
static Eina_Bool
_quickpanel_cb_buffer_change(void *data, int type, void *event)
{
}
static Eina_Bool
+_quickpanel_cb_rotation_begin(void *data, int type, void *event)
+{
+ Pol_Quickpanel *qp;
+ E_Event_Client *ev = event;
+ E_Client *ec;
+
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ goto end;
+
+ ec = ev->ec;
+ if (EINA_UNLIKELY(!ec))
+ goto end;
+
+ if (qp->ec != ec)
+ goto end;
+
+ E_FREE_FUNC(qp->mover, evas_object_del);
+
+ evas_object_hide(qp->indi_obj);
+ evas_object_hide(qp->handler_obj);
+
+end:
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_quickpanel_cb_rotation_cancel(void *data, int type, void *event)
+{
+ Pol_Quickpanel *qp;
+ E_Event_Client *ev = event;
+ E_Client *ec;
+
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ goto end;
+
+ ec = ev->ec;
+ if (EINA_UNLIKELY(!ec))
+ goto end;
+
+ if (qp->ec != ec)
+ goto end;
+
+ if (evas_object_visible_get(ec->frame))
+ evas_object_show(qp->handler_obj);
+ else
+ evas_object_show(qp->indi_obj);
+
+end:
+ return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
_quickpanel_cb_rotation_done(void *data, int type, void *event)
{
+ Pol_Quickpanel *qp;
E_Event_Client *ev = event;
E_Client *ec;
+ qp = data;
+ if (EINA_UNLIKELY(!qp))
+ goto end;
+
ec = ev->ec;
- if (ec != e_mod_quickpanel_client_get())
+ if (EINA_UNLIKELY(!ec))
goto end;
- if (!ec->visible)
+ if (qp->ec != ec)
goto end;
- /* force update */
- e_comp_object_damage(ec->frame, 0, 0, ec->w, ec->h);
- e_comp_object_dirty(ec->frame);
+ qp->rotation = e_mod_rotation_angle_to_idx(ec->e.state.rot.ang.curr);
+
+ if (evas_object_visible_get(ec->frame))
+ evas_object_show(qp->handler_obj);
+ else
+ evas_object_show(qp->indi_obj);
end:
return ECORE_CALLBACK_PASS_ON;
}
+static Evas_Object *
+_quickpanel_indicator_object_new(Pol_Quickpanel *qp)
+{
+ Evas_Object *indi_obj;
+
+ indi_obj = e_mod_region_object_new();
+ if (!indi_obj)
+ return NULL;
+
+ evas_object_repeat_events_set(indi_obj, EINA_TRUE);
+ /* FIXME: make me move to explicit layer something like POL_LAYER */
+ evas_object_layer_set(indi_obj, EVAS_LAYER_MAX - 1);
+
+ e_mod_region_cb_set(indi_obj,
+ _region_obj_cb_gesture_start,
+ _region_obj_cb_gesture_move,
+ _region_obj_cb_gesture_end, qp);
+
+ return indi_obj;
+}
+
#undef E_CLIENT_HOOK_APPEND
#define E_CLIENT_HOOK_APPEND(l, t, cb, d) \
do \
EINTERN void
e_mod_quickpanel_client_set(E_Client *ec)
{
- Pol_Quickpanel *pol_qp = NULL;
+ Pol_Quickpanel *qp;
if (EINA_UNLIKELY(!ec))
{
- pol_qp = _quickpanel_find(e_mod_quickpanel_client_get());
- _quickpanel_free(pol_qp);
+ qp = _quickpanel_get();
+ if (qp)
+ _quickpanel_free(qp);
return;
}
/* if we have not setup evas callbacks for this client, do it */
if (_pol_quickpanel) return;
- pol_qp = E_NEW(Pol_Quickpanel, 1);
- if (!pol_qp) return;
+ ELOGF("QUICKPANEL", "Set Client | ec %p", NULL, NULL, ec);
- pol_qp->ec = ec;
- pol_qp->show_block = EINA_TRUE;
+ qp = calloc(1, sizeof(*qp));
+ if (!qp)
+ return;
- ELOGF("QUICKPANEL", "Set Client | ec %p", NULL, NULL, ec);
+ _pol_quickpanel = qp;
+
+ qp->ec = ec;
+ qp->show_block = EINA_TRUE;
+ qp->indi_obj = _quickpanel_indicator_object_new(qp);
+ if (!qp->indi_obj)
+ {
+ free(qp);
+ return;
+ }
eina_stringshare_replace(&ec->icccm.window_role, "quickpanel");
// set skip iconify
ec->exp_iconify.skip_iconify = 1;
-
ec->e.state.rot.type = E_CLIENT_ROTATION_TYPE_DEPENDENT;
+
+ /* force update rotation for quickpanel */
e_mod_pol_rotation_force_update_add(ec);
QP_HIDE(ec);
- // to avoid that quickpanel is shawn, when it's first launched. */
- evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW,
- _quickpanel_client_evas_cb_show_block, pol_qp);
-
- E_CLIENT_HOOK_APPEND(_quickpanel_hooks, E_CLIENT_HOOK_DEL,
- _quickpanel_hook_client_del, NULL);
-
- E_LIST_HANDLER_APPEND(_quickpanel_events, E_EVENT_CLIENT_BUFFER_CHANGE, _quickpanel_cb_buffer_change, NULL);
- E_LIST_HANDLER_APPEND(_quickpanel_events, E_EVENT_CLIENT_ROTATION_CHANGE_END, _quickpanel_cb_rotation_done, NULL);
+ evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_SHOW, _quickpanel_client_evas_cb_show, qp);
+ evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_HIDE, _quickpanel_client_evas_cb_hide, qp);
+ evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_MOVE, _quickpanel_client_evas_cb_move, qp);
- _pol_quickpanel = pol_qp;
+ E_CLIENT_HOOK_APPEND(qp->hooks, E_CLIENT_HOOK_DEL, _quickpanel_hook_client_del, qp);
+ E_LIST_HANDLER_APPEND(qp->events, E_EVENT_CLIENT_BUFFER_CHANGE, _quickpanel_cb_buffer_change, qp);
+ E_LIST_HANDLER_APPEND(qp->events, E_EVENT_CLIENT_ROTATION_CHANGE_BEGIN, _quickpanel_cb_rotation_begin, qp);
+ E_LIST_HANDLER_APPEND(qp->events, E_EVENT_CLIENT_ROTATION_CHANGE_CANCEL, _quickpanel_cb_rotation_cancel, qp);
+ E_LIST_HANDLER_APPEND(qp->events, E_EVENT_CLIENT_ROTATION_CHANGE_END, _quickpanel_cb_rotation_done, qp);
}
EINTERN E_Client *
e_mod_quickpanel_region_set(int type, int angle, Eina_Tiler *tiler)
{
Pol_Quickpanel *qp;
- E_Client *ec;
+ Rot_Idx ridx;
- ec = e_mod_quickpanel_client_get();
- if (EINA_UNLIKELY(!ec))
+ qp = _quickpanel_get();
+ if (EINA_UNLIKELY(!qp))
return EINA_FALSE;
- qp = _quickpanel_find(ec);
- if (EINA_UNLIKELY(!qp))
+ if (EINA_UNLIKELY(!qp->ec))
return EINA_FALSE;
- // FIXME should consider rotation.
- if (angle != 0)
+ if (e_object_is_del(E_OBJECT(qp->ec)))
return EINA_FALSE;
// FIXME: region type
if (type != 0)
return EINA_FALSE;
- _quickpanel_handler_region_set(qp, angle, tiler);
+ ridx = e_mod_rotation_angle_to_idx(angle);
+ _quickpanel_handler_region_set(qp, ridx, tiler);
return EINA_TRUE;
}
-EINTERN Evas_Object *
-e_mod_quickpanel_handler_object_add(E_Client *ec, int x, int y, int w, int h)
-{
- Pol_Quickpanel *qp;
- Pol_Gesture *gesture;
- Evas_Object *handler;
- Handler_Data *hd;
-
- qp = _quickpanel_find(ec);
- if (!qp)
- return NULL;
-
- hd = E_NEW(Handler_Data, 1);
- if (EINA_UNLIKELY(!hd))
- return NULL;
-
- handler = evas_object_rectangle_add(evas_object_evas_get(ec->frame));
-
- /* make it transparent */
- evas_object_color_set(handler, 0, 0, 0, 0);
-
- evas_object_repeat_events_set(handler, EINA_TRUE);
-
- evas_object_move(handler, x, y);
- evas_object_resize(handler, w, h);
-
- evas_object_event_callback_add(handler, EVAS_CALLBACK_DEL, _handler_obj_cb_del, hd);
-
- gesture = e_mod_gesture_add(handler, POL_GESTURE_TYPE_LINE);
- e_mod_gesture_cb_set(gesture,
- _handler_obj_cb_gesture_start,
- _handler_obj_cb_gesture_move,
- _handler_obj_cb_gesture_end,
- hd);
-
- hd->qp = qp;
- hd->gesture = gesture;
- hd->handler = handler;
- hd->mover = NULL;
-
- return handler;
-}
-
EINTERN void
e_mod_quickpanel_show(void)
{
Pol_Quickpanel *qp;
- E_Client *ec;
- ec = e_mod_quickpanel_client_get();
- if (!ec)
+ qp = _quickpanel_get();
+ if (EINA_UNLIKELY(!qp))
return;
- qp = _quickpanel_find(ec);
- if (!qp)
+ if (EINA_UNLIKELY(!qp->ec))
+ return;
+
+ if (e_object_is_del(E_OBJECT(qp->ec)))
return;
_quickpanel_visibility_change(qp, EINA_TRUE, EINA_TRUE);
e_mod_quickpanel_hide(void)
{
Pol_Quickpanel *qp;
- E_Client *ec;
- ec = e_mod_quickpanel_client_get();
- if (!ec)
+ qp = _quickpanel_get();
+ if (EINA_UNLIKELY(!qp))
return;
- qp = _quickpanel_find(ec);
- if (!qp)
+ if (EINA_UNLIKELY(!qp->ec))
+ return;
+
+ if (e_object_is_del(E_OBJECT(qp->ec)))
return;
_quickpanel_visibility_change(qp, EINA_FALSE, EINA_TRUE);