summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2009-12-28 22:22:50 +0000
committerChristopher Michael <cpmichael1@comcast.net>2009-12-28 22:22:50 +0000
commit5e5c3108ccbcf17f73eb206e93957279b7d75895 (patch)
tree4f6c84446b28135bb7ba9b2a471696e8ddd04e33
parent676817424cc4872c68259da84ad4dd0ae18a195f (diff)
Add missing quickpanel files (not complete yet, but does work)
SVN revision: 44754
-rw-r--r--src/modules/illume2/e_quickpanel.c295
-rw-r--r--src/modules/illume2/e_quickpanel.h28
2 files changed, 323 insertions, 0 deletions
diff --git a/src/modules/illume2/e_quickpanel.c b/src/modules/illume2/e_quickpanel.c
new file mode 100644
index 0000000..7a578dc
--- /dev/null
+++ b/src/modules/illume2/e_quickpanel.c
@@ -0,0 +1,295 @@
1#include "e.h"
2#include "e_quickpanel.h"
3#include "e_mod_config.h"
4#include "e_mod_border.h"
5
6/* local function prototypes */
7static void _e_quickpanel_cb_free(E_Quickpanel *qp);
8static int _e_quickpanel_cb_client_message(void *data, int type, void *event);
9static void _e_quickpanel_cb_border_pre_post_fetch(void *data, void *data2);
10static E_Quickpanel *_e_quickpanel_by_border_get(E_Border *bd);
11static int _e_quickpanel_border_is_quickpanel(E_Border *bd);
12static void _e_quickpanel_slide(E_Quickpanel *qp, int visible, double len);
13static int _e_quickpanel_cb_animate(void *data);
14static int _e_quickpanel_cb_delay_hide(void *data);
15static void _e_quickpanel_hide(E_Quickpanel *qp);
16
17/* local variables */
18static Eina_List *qps = NULL, *handlers = NULL, *hooks = NULL;
19
20/* public functions */
21int
22e_quickpanel_init(void)
23{
24 handlers =
25 eina_list_append(handlers,
26 ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
27 _e_quickpanel_cb_client_message, NULL));
28 hooks =
29 eina_list_append(hooks,
30 e_border_hook_add(E_BORDER_HOOK_EVAL_PRE_POST_FETCH,
31 _e_quickpanel_cb_border_pre_post_fetch,
32 NULL));
33 return 1;
34}
35
36int
37e_quickpanel_shutdown(void)
38{
39 E_Quickpanel *qp;
40 Ecore_Event_Handler *handler;
41 E_Border_Hook *hook;
42
43 EINA_LIST_FREE(handlers, handler)
44 ecore_event_handler_del(handler);
45 EINA_LIST_FREE(hooks, hook)
46 e_border_hook_del(hook);
47 EINA_LIST_FREE(qps, qp)
48 e_object_del(E_OBJECT(qp));
49 return 1;
50}
51
52E_Quickpanel *
53e_quickpanel_new(E_Zone *zone)
54{
55 E_Quickpanel *qp;
56
57 qp = E_OBJECT_ALLOC(E_Quickpanel, E_QUICKPANEL_TYPE, _e_quickpanel_cb_free);
58 if (!qp) return NULL;
59 qp->zone = zone;
60 qp->visible = 0;
61 qps = eina_list_append(qps, qp);
62 return qp;
63}
64
65void
66e_quickpanel_show(E_Quickpanel *qp)
67{
68 if (qp->timer) ecore_timer_del(qp->timer);
69 qp->timer = NULL;
70 if (qp->visible) return;
71 if (il_cfg->sliding.quickpanel.duration <= 0)
72 {
73 Eina_List *l;
74 E_Border *bd;
75 int ny = 0;
76
77 e_mod_border_top_shelf_size_get(qp->zone, NULL, &ny);
78 EINA_LIST_FOREACH(qp->borders, l, bd)
79 ny += bd->h;
80
81 EINA_LIST_FOREACH(qp->borders, l, bd)
82 e_border_fx_offset(bd, 0, ny);
83 qp->visible = 1;
84 }
85 else
86 _e_quickpanel_slide(qp, 1,
87 (double)il_cfg->sliding.quickpanel.duration / 1000.0);
88}
89
90void
91e_quickpanel_hide(E_Quickpanel *qp)
92{
93 if (!qp->visible) return;
94 if (!qp->timer)
95 qp->timer = ecore_timer_add(0.2, _e_quickpanel_cb_delay_hide, qp);
96}
97
98E_Quickpanel *
99e_quickpanel_by_zone_get(E_Zone *zone)
100{
101 Eina_List *l;
102 E_Quickpanel *qp;
103
104 if (!zone) return NULL;
105 EINA_LIST_FOREACH(qps, l, qp)
106 if (qp->zone == zone) return qp;
107 return NULL;
108}
109
110/* local functions */
111static void
112_e_quickpanel_cb_free(E_Quickpanel *qp)
113{
114 E_Border *bd;
115
116 if (qp->animator) ecore_animator_del(qp->animator);
117 qp->animator = NULL;
118 if (qp->timer) ecore_timer_del(qp->timer);
119 qp->timer = NULL;
120 EINA_LIST_FREE(qp->borders, bd)
121 bd->stolen = 0;
122 E_FREE(qp);
123}
124
125static int
126_e_quickpanel_cb_client_message(void *data, int type, void *event)
127{
128 Ecore_X_Event_Client_Message *ev;
129 E_Zone *zone;
130 E_Quickpanel *qp;
131
132 ev = event;
133 if (ev->win != ecore_x_window_root_first_get()) return 1;
134 if (ev->message_type != ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) return 1;
135 zone = e_zone_current_get(e_container_current_get(e_manager_current_get()));
136 if (!(qp = e_quickpanel_by_zone_get(zone))) return 1;
137 if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
138 e_quickpanel_hide(qp);
139 else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
140 e_quickpanel_show(qp);
141 return 1;
142}
143
144static void
145_e_quickpanel_cb_border_pre_post_fetch(void *data, void *data2)
146{
147 E_Border *bd;
148 E_Quickpanel *qp;
149 int ty, th;
150
151 if (!(bd = data2)) return;
152 if (!bd->new_client) return;
153 if (_e_quickpanel_by_border_get(bd)) return;
154 if (!_e_quickpanel_border_is_quickpanel(bd)) return;
155 if (!(qp = e_quickpanel_by_zone_get(bd->zone))) return;
156 e_mod_border_top_shelf_pos_get(qp->zone, NULL, &ty);
157 e_mod_border_top_shelf_size_get(qp->zone, NULL, &th);
158 bd->stolen = 1;
159 if (bd->remember)
160 {
161 if (bd->bordername)
162 {
163 eina_stringshare_del(bd->bordername);
164 bd->bordername = NULL;
165 bd->client.border.changed = 1;
166 }
167 e_remember_unuse(bd->remember);
168 bd->remember = NULL;
169 }
170 eina_stringshare_replace(&bd->bordername, "borderless");
171 bd->client.border.changed = 1;
172 qp->h += bd->h;
173 e_border_move(bd, qp->zone->x, (ty - qp->h));
174 if (qp->visible)
175 e_border_fx_offset(bd, 0, (bd->h - th));
176 qp->borders = eina_list_append(qp->borders, bd);
177}
178
179static E_Quickpanel *
180_e_quickpanel_by_border_get(E_Border *bd)
181{
182 Eina_List *l, *ll;
183 E_Border *b;
184 E_Quickpanel *qp;
185
186 if (!bd->stolen) return NULL;
187 EINA_LIST_FOREACH(qps, l, qp)
188 EINA_LIST_FOREACH(qp->borders, ll, b)
189 if (b == bd) return qp;
190 return NULL;
191}
192
193static int
194_e_quickpanel_border_is_quickpanel(E_Border *bd)
195{
196 return ecore_x_e_illume_quickpanel_get(bd->client.win);
197}
198
199static void
200_e_quickpanel_slide(E_Quickpanel *qp, int visible, double len)
201{
202 qp->start = ecore_loop_time_get();
203 qp->len = len;
204 qp->adjust_start = qp->adjust;
205 qp->adjust_end = 0;
206 if (visible)
207 {
208 Eina_List *l;
209 E_Border *bd;
210
211 EINA_LIST_FOREACH(qp->borders, l, bd)
212 qp->adjust_end += bd->h;
213 }
214 else
215 {
216 int th;
217
218 e_mod_border_top_shelf_size_get(qp->zone, NULL, &th);
219 qp->adjust_end = -th;
220 }
221 if (!qp->animator)
222 qp->animator = ecore_animator_add(_e_quickpanel_cb_animate, qp);
223}
224
225static int
226_e_quickpanel_cb_animate(void *data)
227{
228 E_Quickpanel *qp;
229 Eina_List *l;
230 E_Border *bd;
231 double t, v;
232
233 if (!(qp = data)) return 0;
234 t = ecore_loop_time_get() - qp->start;
235 if (t > qp->len) t = qp->len;
236 if (qp->len > 0.0)
237 {
238 v = t / qp->len;
239 v = 1.0 - v;
240 v = v * v * v * v;
241 v = 1.0 - v;
242 }
243 else
244 {
245 t = qp->len;
246 v = 1.0;
247 }
248 qp->adjust = (qp->adjust_end * v) + (qp->adjust_start * (1.0 - v));
249
250 EINA_LIST_FOREACH(qp->borders, l, bd)
251 e_border_fx_offset(bd, 0, (bd->h + qp->adjust));
252
253 if (t == qp->len)
254 {
255 qp->animator = NULL;
256 if (qp->visible) qp->visible = 0;
257 else qp->visible = 1;
258 return 0;
259 }
260 return 1;
261}
262
263static int
264_e_quickpanel_cb_delay_hide(void *data)
265{
266 E_Quickpanel *qp;
267
268 if (!(qp = data)) return 0;
269 _e_quickpanel_hide(qp);
270 qp->timer = NULL;
271 return 0;
272}
273
274static void
275_e_quickpanel_hide(E_Quickpanel *qp)
276{
277 if (qp->timer) ecore_timer_del(qp->timer);
278 qp->timer = NULL;
279 if (!qp->visible) return;
280 if (il_cfg->sliding.quickpanel.duration <= 0)
281 {
282 Eina_List *l;
283 E_Border *bd;
284 int th;
285
286 e_mod_border_top_shelf_size_get(qp->zone, NULL, &th);
287 EINA_LIST_FOREACH(qp->borders, l, bd)
288 e_border_fx_offset(bd, 0, 0);
289// e_border_fx_offset(bd, 0, -th);
290 qp->visible = 0;
291 }
292 else
293 _e_quickpanel_slide(qp, 0,
294 (double)il_cfg->sliding.quickpanel.duration / 1000.0);
295}
diff --git a/src/modules/illume2/e_quickpanel.h b/src/modules/illume2/e_quickpanel.h
new file mode 100644
index 0000000..737245a
--- /dev/null
+++ b/src/modules/illume2/e_quickpanel.h
@@ -0,0 +1,28 @@
1#ifndef E_QUICKPANEL_H
2#define E_QUICKPANEL_H
3
4#define E_QUICKPANEL_TYPE 0xE1b0990
5
6typedef struct _E_Quickpanel E_Quickpanel;
7struct _E_Quickpanel
8{
9 E_Object e_obj_inherit;
10
11 E_Zone *zone;
12 Eina_List *borders;
13 Ecore_Timer *timer;
14 Ecore_Animator *animator;
15 double start, len;
16 int h, adjust, adjust_start, adjust_end;
17 unsigned char visible : 1;
18};
19
20int e_quickpanel_init(void);
21int e_quickpanel_shutdown(void);
22
23E_Quickpanel *e_quickpanel_new(E_Zone *zone);
24void e_quickpanel_show(E_Quickpanel *qp);
25void e_quickpanel_hide(E_Quickpanel *qp);
26E_Quickpanel *e_quickpanel_by_zone_get(E_Zone *zone);
27
28#endif