Rework quickpanel to account for ability to drag indicators...so now when

indicator moves, quickpanel will adjust it's position accordingly.



SVN revision: 45468
This commit is contained in:
Christopher Michael 2010-01-22 22:51:31 +00:00
parent 056e01de38
commit 19f06ac085
4 changed files with 261 additions and 251 deletions

View File

@ -7,7 +7,7 @@
/* local variabels */
static E_Kbd *kbd = NULL;
static Eina_List *quickpanels = NULL;
Eina_List *quickpanels = NULL;
int _e_illume_log_dom = -1;
EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume2" };

View File

@ -33,4 +33,6 @@ EAPI void *e_modapi_init(E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save(E_Module *m);
extern Eina_List *quickpanels;
#endif

View File

@ -1,22 +1,23 @@
#include "E_Illume.h"
#include "e_mod_main.h"
#include "e_quickpanel.h"
/* local function prototypes */
static void _e_quickpanel_cb_free(E_Quickpanel *qp);
static int _e_quickpanel_cb_client_message(void *data, int type, void *event);
static void _e_quickpanel_cb_border_pre_post_fetch(void *data, void *data2);
static E_Quickpanel *_e_quickpanel_by_border_get(E_Border *bd);
static int _e_quickpanel_border_is_quickpanel(E_Border *bd);
static void _e_quickpanel_slide(E_Quickpanel *qp, int visible, double len);
static int _e_quickpanel_cb_animate(void *data);
static int _e_quickpanel_cb_delay_hide(void *data);
static void _e_quickpanel_hide(E_Quickpanel *qp);
static int _e_quickpanel_cb_sort(const void *b1, const void *b2);
static void _e_quickpanel_slide(E_Quickpanel *qp, int visible, double len);
static void _e_quickpanel_border_show(E_Border *bd);
static void _e_quickpanel_border_hide(E_Border *bd);
static E_Quickpanel *_e_quickpanel_by_border_get(E_Border *bd);
static void _e_quickpanel_cb_free(E_Quickpanel *qp);
static int _e_quickpanel_cb_delay_hide(void *data);
static int _e_quickpanel_cb_animate(void *data);
static int _e_quickpanel_cb_border_add(void *data, int type, void *event);
static int _e_quickpanel_cb_client_message(void *data, int type, void *event);
static int _e_quickpanel_cb_mouse_down(void *data, int type, void *event);
static int _e_quickpanel_cb_mouse_wheel(void *data, int type, void *event);
static void _e_quickpanel_cb_post_fetch(void *data, void *data2);
/* local variables */
static Eina_List *qps = NULL, *handlers = NULL, *hooks = NULL;
static Eina_List *handlers = NULL, *hooks = NULL;
static Ecore_X_Window input_win = 0;
/* public functions */
@ -26,28 +27,28 @@ e_quickpanel_init(void)
handlers =
eina_list_append(handlers,
ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
_e_quickpanel_cb_client_message, NULL));
_e_quickpanel_cb_client_message,
NULL));
handlers =
eina_list_append(handlers,
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
_e_quickpanel_cb_mouse_down, NULL));
ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
_e_quickpanel_cb_mouse_down,
NULL));
handlers =
eina_list_append(handlers,
ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL,
_e_quickpanel_cb_mouse_wheel, NULL));
ecore_event_handler_add(E_EVENT_BORDER_ADD,
_e_quickpanel_cb_border_add,
NULL));
hooks =
eina_list_append(hooks,
e_border_hook_add(E_BORDER_HOOK_EVAL_PRE_POST_FETCH,
_e_quickpanel_cb_border_pre_post_fetch,
NULL));
_e_quickpanel_cb_post_fetch, NULL));
return 1;
}
int
e_quickpanel_shutdown(void)
{
E_Quickpanel *qp;
Ecore_Event_Handler *handler;
E_Border_Hook *hook;
@ -55,8 +56,6 @@ e_quickpanel_shutdown(void)
ecore_event_handler_del(handler);
EINA_LIST_FREE(hooks, hook)
e_border_hook_del(hook);
EINA_LIST_FREE(qps, qp)
e_object_del(E_OBJECT(qp));
return 1;
}
@ -68,7 +67,6 @@ e_quickpanel_new(E_Zone *zone)
qp = E_OBJECT_ALLOC(E_Quickpanel, E_QUICKPANEL_TYPE, _e_quickpanel_cb_free);
if (!qp) return NULL;
qp->zone = zone;
qps = eina_list_append(qps, qp);
return qp;
}
@ -77,16 +75,14 @@ e_quickpanel_show(E_Quickpanel *qp)
{
if (qp->timer) ecore_timer_del(qp->timer);
qp->timer = NULL;
if (qp->visible) return;
if (!qp->borders) return;
qp->borders = eina_list_sort(qp->borders, 0, _e_quickpanel_cb_sort);
if ((qp->visible) || (!qp->borders)) return;
e_illume_border_top_shelf_size_get(qp->zone, NULL, &qp->top_height);
if (!input_win)
{
input_win =
ecore_x_window_input_new(qp->zone->container->win,
qp->zone->x, qp->zone->y,
qp->zone->w, qp->zone->h);
input_win = ecore_x_window_input_new(qp->zone->container->win,
qp->zone->x, qp->zone->y,
qp->zone->w, qp->zone->h);
ecore_x_window_show(input_win);
if (!e_grabinput_get(input_win, 1, input_win))
{
@ -95,20 +91,19 @@ e_quickpanel_show(E_Quickpanel *qp)
return;
}
}
if (il_cfg->sliding.quickpanel.duration <= 0)
{
Eina_List *l;
E_Border *bd;
int ny = 0;
e_illume_border_top_shelf_size_get(qp->zone, NULL, &ny);
EINA_LIST_FOREACH(qp->borders, l, bd)
ny += bd->h;
ny = qp->top_height;
EINA_LIST_FOREACH(qp->borders, l, bd)
{
e_border_lower(bd);
if (!bd->visible) _e_quickpanel_border_show(bd);
e_border_fx_offset(bd, 0, ny);
ny += bd->h;
}
qp->visible = 1;
}
@ -132,7 +127,7 @@ e_quickpanel_by_zone_get(E_Zone *zone)
E_Quickpanel *qp;
if (!zone) return NULL;
EINA_LIST_FOREACH(qps, l, qp)
EINA_LIST_FOREACH(quickpanels, l, qp)
if (qp->zone == zone) return qp;
return NULL;
}
@ -142,20 +137,106 @@ e_quickpanel_position_update(E_Quickpanel *qp)
{
Eina_List *l;
E_Border *bd;
int ty;
int ty = 0;
if (!qp) return;
e_quickpanel_hide(qp);
e_illume_border_top_shelf_pos_get(qp->zone, NULL, &ty);
EINA_LIST_FOREACH(qp->borders, l, bd)
{
bd->x = qp->zone->x;
bd->y = (ty - qp->h);
bd->y = ty;
bd->changes.pos = 1;
bd->changed = 1;
}
}
/* local functions */
static void
_e_quickpanel_hide(E_Quickpanel *qp)
{
if (!qp) return;
if (qp->timer) ecore_timer_del(qp->timer);
qp->timer = NULL;
if (!qp->visible) return;
e_illume_border_top_shelf_size_get(qp->zone, NULL, &qp->top_height);
if (input_win)
{
ecore_x_window_free(input_win);
e_grabinput_release(input_win, input_win);
input_win = 0;
}
if (il_cfg->sliding.quickpanel.duration <= 0)
{
Eina_List *l;
E_Border *bd;
EINA_LIST_REVERSE_FOREACH(qp->borders, l, bd)
{
e_border_fx_offset(bd, 0, 0);
if (bd->visible) _e_quickpanel_border_hide(bd);
}
qp->visible = 0;
}
else
_e_quickpanel_slide(qp, 0,
(double)il_cfg->sliding.quickpanel.duration / 1000.0);
}
static void
_e_quickpanel_slide(E_Quickpanel *qp, int visible, double len)
{
qp->start = ecore_loop_time_get();
qp->len = len;
qp->adjust_start = qp->adjust;
qp->adjust_end = 0;
if (visible) qp->adjust_end = qp->h;
if (!qp->animator)
qp->animator = ecore_animator_add(_e_quickpanel_cb_animate, qp);
}
static void
_e_quickpanel_border_show(E_Border *bd)
{
unsigned int visible = 1;
if (!bd) return;
e_container_border_lower(bd);
e_container_shape_show(bd->shape);
if (!bd->need_reparent) ecore_x_window_show(bd->client.win);
e_hints_window_visible_set(bd);
bd->visible = 1;
bd->changes.visible = 1;
ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &visible, 1);
ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MANAGED, &visible, 1);
}
static void
_e_quickpanel_border_hide(E_Border *bd)
{
unsigned int visible = 0;
e_container_shape_hide(bd->shape);
e_hints_window_hidden_set(bd);
bd->visible = 0;
bd->changes.visible = 1;
ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &visible, 1);
}
static E_Quickpanel *
_e_quickpanel_by_border_get(E_Border *bd)
{
Eina_List *l, *ll;
E_Border *b;
E_Quickpanel *qp;
if (!bd->stolen) return NULL;
EINA_LIST_FOREACH(quickpanels, l, qp)
EINA_LIST_FOREACH(qp->borders, ll, b)
if (b == bd) return qp;
return NULL;
}
static void
_e_quickpanel_cb_free(E_Quickpanel *qp)
{
@ -170,6 +251,94 @@ _e_quickpanel_cb_free(E_Quickpanel *qp)
E_FREE(qp);
}
static int
_e_quickpanel_cb_delay_hide(void *data)
{
E_Quickpanel *qp;
if (!(qp = data)) return 0;
_e_quickpanel_hide(qp);
return 0;
}
static int
_e_quickpanel_cb_animate(void *data)
{
E_Quickpanel *qp;
double t, v = 1.0;
Eina_List *l;
E_Border *bd;
if (!(qp = data)) return 0;
t = ecore_loop_time_get() - qp->start;
if (t > qp->len) t = qp->len;
if (qp->len > 0.0)
{
v = (t / qp->len);
v = (1.0 - v);
v = (v * v * v * v);
v = (1.0 - v);
}
else
t = qp->len;
qp->adjust = (qp->adjust_end * v) + (qp->adjust_start * (1.0 - v));
if (qp->borders)
{
int pbh = 0;
pbh = qp->top_height - qp->h;
EINA_LIST_FOREACH(qp->borders, l, bd)
{
if (e_object_is_del(E_OBJECT(bd))) continue;
if (bd->fx.y != (qp->adjust + pbh))
e_border_fx_offset(bd, 0, (qp->adjust + pbh));
pbh += bd->h;
if (bd->fx.y > 0)
if (!bd->visible) _e_quickpanel_border_show(bd);
if (qp->visible)
{
if (bd->fx.y <= 0)
if (bd->visible) _e_quickpanel_border_hide(bd);
}
}
}
if (t == qp->len)
{
qp->animator = NULL;
if (qp->visible) qp->visible = 0;
else qp->visible = 1;
return 0;
}
return 1;
}
static int
_e_quickpanel_cb_border_add(void *data, int type, void *event)
{
E_Event_Border_Add *ev;
E_Quickpanel *qp;
int ty;
ev = event;
if (!ev->border->client.illume.quickpanel.quickpanel) return 1;
if (!(qp = e_quickpanel_by_zone_get(ev->border->zone))) return 1;
e_illume_border_top_shelf_pos_get(qp->zone, NULL, &ty);
_e_quickpanel_border_hide(ev->border);
if ((ev->border->x != qp->zone->x) || (ev->border->y != ty))
{
ev->border->x = qp->zone->x;
ev->border->y = ty;
ev->border->changes.pos = 1;
ev->border->changed = 1;
}
if (ev->border->zone != qp->zone)
e_border_zone_set(ev->border, qp->zone);
qp->h += ev->border->h;
qp->borders = eina_list_append(qp->borders, ev->border);
return 1;
}
static int
_e_quickpanel_cb_client_message(void *data, int type, void *event)
{
@ -179,52 +348,80 @@ _e_quickpanel_cb_client_message(void *data, int type, void *event)
if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE)
{
E_Zone *zone;
if (zone = e_util_zone_window_find(ev->win))
{
E_Quickpanel *qp;
if (qp = e_quickpanel_by_zone_get(zone))
{
if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
e_quickpanel_hide(qp);
else
e_quickpanel_show(qp);
}
}
}
else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE)
{
E_Border *bd;
E_Quickpanel *qp;
zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
if (!(qp = e_quickpanel_by_zone_get(zone))) return 1;
if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
e_quickpanel_hide(qp);
else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
e_quickpanel_show(qp);
if (!(bd = e_border_find_by_client_window(ev->win))) return 1;
if (!(qp = e_quickpanel_by_zone_get(bd->zone))) return 1;
e_quickpanel_position_update(qp);
}
else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE_REQUEST)
{
E_Border *bd;
E_Zone *zone;
E_Quickpanel *qp;
Ecore_X_Window z, qpw;
Ecore_X_Window z;
qpw = ev->data.l[1];
if (!(bd = e_border_find_by_client_window(qpw))) return 1;
if (!(bd = e_border_find_by_client_window(ev->data.l[1]))) return 1;
z = ecore_x_e_illume_quickpanel_zone_get(bd->client.win);
if (!(zone = e_util_zone_window_find(z))) return 1;
if (bd->zone != zone)
{
if (!(qp = e_quickpanel_by_zone_get(bd->zone))) return 1;
qp->borders = eina_list_remove(qp->borders, bd);
int ty;
e_illume_border_top_shelf_pos_get(zone, NULL, &ty);
if ((bd->x != zone->x) || (bd->y != ty))
{
bd->x = zone->x;
bd->y = ty;
bd->changes.pos = 1;
bd->changed = 1;
}
e_border_zone_set(bd, zone);
}
}
return 1;
}
static int
_e_quickpanel_cb_mouse_down(void *data, int type, void *event)
{
Ecore_Event_Mouse_Button *ev;
Eina_List *l;
E_Quickpanel *qp;
ev = event;
if (ev->event_window != input_win) return 1;
EINA_LIST_FOREACH(quickpanels, l, qp)
if (qp->visible)
ecore_x_e_illume_quickpanel_state_send(qp->zone->black_win,
ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
return 1;
}
static void
_e_quickpanel_cb_border_pre_post_fetch(void *data, void *data2)
_e_quickpanel_cb_post_fetch(void *data, void *data2)
{
E_Border *bd;
E_Quickpanel *qp;
int ty;
if (!(bd = data2)) return;
if (!bd->new_client) return;
if (!_e_quickpanel_border_is_quickpanel(bd)) return;
if ((!bd->new_client) || (!bd->client.illume.quickpanel.quickpanel)) return;
if (_e_quickpanel_by_border_get(bd)) return;
if (!(qp = e_quickpanel_by_zone_get(bd->zone))) return;
qp->borders = eina_list_append(qp->borders, bd);
e_illume_border_top_shelf_pos_get(qp->zone, NULL, &ty);
bd->stolen = 1;
if (bd->remember)
{
@ -238,193 +435,4 @@ _e_quickpanel_cb_border_pre_post_fetch(void *data, void *data2)
}
eina_stringshare_replace(&bd->bordername, "borderless");
bd->client.border.changed = 1;
qp->h += bd->h;
e_border_move(bd, qp->zone->x, (ty - qp->h));
}
static E_Quickpanel *
_e_quickpanel_by_border_get(E_Border *bd)
{
Eina_List *l, *ll;
E_Border *b;
E_Quickpanel *qp;
if (!bd->stolen) return NULL;
EINA_LIST_FOREACH(qps, l, qp)
EINA_LIST_FOREACH(qp->borders, ll, b)
if (b == bd) return qp;
return NULL;
}
static int
_e_quickpanel_border_is_quickpanel(E_Border *bd)
{
return bd->client.illume.quickpanel.quickpanel;
}
static void
_e_quickpanel_slide(E_Quickpanel *qp, int visible, double len)
{
qp->start = ecore_loop_time_get();
qp->len = len;
qp->adjust_start = qp->adjust;
qp->adjust_end = 0;
if (visible)
{
Eina_List *l;
E_Border *bd;
EINA_LIST_FOREACH(qp->borders, l, bd)
qp->adjust_end += bd->h;
}
else
{
int th;
e_illume_border_top_shelf_size_get(qp->zone, NULL, &th);
qp->adjust_end = -th;
}
if (!qp->animator)
qp->animator = ecore_animator_add(_e_quickpanel_cb_animate, qp);
}
static int
_e_quickpanel_cb_animate(void *data)
{
E_Quickpanel *qp;
Eina_List *l;
E_Border *bd;
double t, v;
if (!(qp = data)) return 0;
t = ecore_loop_time_get() - qp->start;
if (t > qp->len) t = qp->len;
if (qp->len > 0.0)
{
v = t / qp->len;
v = 1.0 - v;
v = v * v * v * v;
v = 1.0 - v;
}
else
{
t = qp->len;
v = 1.0;
}
qp->adjust = (qp->adjust_end * v) + (qp->adjust_start * (1.0 - v));
if (qp->borders)
{
EINA_LIST_REVERSE_FOREACH(qp->borders, l, bd)
{
if (e_object_is_del(E_OBJECT(bd))) continue;
e_border_lower(bd);
e_border_fx_offset(bd, 0, (bd->h + qp->adjust));
}
}
if (t == qp->len)
{
qp->animator = NULL;
if (qp->visible)
qp->visible = 0;
else
qp->visible = 1;
return 0;
}
return 1;
}
static int
_e_quickpanel_cb_delay_hide(void *data)
{
E_Quickpanel *qp;
if (!(qp = data)) return 0;
_e_quickpanel_hide(qp);
qp->timer = NULL;
return 0;
}
static void
_e_quickpanel_hide(E_Quickpanel *qp)
{
if (qp->timer) ecore_timer_del(qp->timer);
qp->timer = NULL;
if (!qp->visible) return;
if (input_win)
{
ecore_x_window_free(input_win);
e_grabinput_release(input_win, input_win);
input_win = 0;
}
if (il_cfg->sliding.quickpanel.duration <= 0)
{
Eina_List *l;
E_Border *bd;
EINA_LIST_REVERSE_FOREACH(qp->borders, l, bd)
{
e_border_lower(bd);
e_border_fx_offset(bd, 0, 0);
}
qp->visible = 0;
}
else
_e_quickpanel_slide(qp, 0,
(double)il_cfg->sliding.quickpanel.duration / 1000.0);
}
static int
_e_quickpanel_cb_sort(const void *b1, const void *b2)
{
const E_Border *bd1, *bd2;
int major1, major2, ret;
if (!(bd1 = b1)) return -1;
if (!(bd2 = b2)) return 1;
major1 = bd1->client.illume.quickpanel.priority.major;
major2 = bd2->client.illume.quickpanel.priority.major;
if (major1 < major2) ret = -1;
else if (major1 > major2) ret = 1;
else
{
int minor1, minor2;
minor1 = bd1->client.illume.quickpanel.priority.minor;
minor2 = bd2->client.illume.quickpanel.priority.minor;
if (minor2 < minor1) ret = -1;
else if (minor2 > minor1) ret = 1;
else ret = 0;
}
return ret;
}
static int
_e_quickpanel_cb_mouse_down(void *data, int type, void *event)
{
Ecore_Event_Mouse_Button *ev;
Ecore_X_Window xwin;
ev = event;
if (ev->event_window != input_win) return 1;
xwin = ecore_x_window_root_first_get();
ecore_x_e_illume_quickpanel_state_set(xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
ecore_x_e_illume_quickpanel_state_send(xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
return 1;
}
static int
_e_quickpanel_cb_mouse_wheel(void *data, int type, void *event)
{
Ecore_Event_Mouse_Wheel *ev;
Ecore_X_Window xwin;
ev = event;
if (ev->event_window != input_win) return 1;
if (ev->z > 0) return 1;
xwin = ecore_x_window_root_first_get();
ecore_x_e_illume_quickpanel_state_set(xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
ecore_x_e_illume_quickpanel_state_send(xwin, ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
return 1;
}

View File

@ -13,7 +13,7 @@ struct _E_Quickpanel
Ecore_Timer *timer;
Ecore_Animator *animator;
double start, len;
int h, adjust, adjust_start, adjust_end;
int h, adjust, adjust_start, adjust_end, top_height;
unsigned char visible : 1;
};