1 #include "e_illume_private.h"
2 #include "e_mod_policy.h"
4 /* local function prototypes */
5 static char *_e_mod_policy_find(void);
6 static int _e_mod_policy_load(char *file);
7 static void _e_mod_policy_handlers_add(void);
8 static void _e_mod_policy_hooks_add(void);
9 static void _e_mod_policy_cb_free(E_Illume_Policy *p);
10 static Eina_Bool _e_mod_policy_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void *event);
11 static Eina_Bool _e_mod_policy_cb_border_del(void *data __UNUSED__, int type __UNUSED__, void *event);
12 static Eina_Bool _e_mod_policy_cb_border_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
13 static Eina_Bool _e_mod_policy_cb_border_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event);
14 static Eina_Bool _e_mod_policy_cb_border_show(void *data __UNUSED__, int type __UNUSED__, void *event);
15 static Eina_Bool _e_mod_policy_cb_border_move(void *data __UNUSED__, int type __UNUSED__, void *event);
16 static Eina_Bool _e_mod_policy_cb_border_iconify(void *data __UNUSED__, int type __UNUSED__, void *event);
17 static Eina_Bool _e_mod_policy_cb_border_uniconify(void *data __UNUSED__, int type __UNUSED__, void *event);
18 static Eina_Bool _e_mod_policy_cb_zone_move_resize(void *data __UNUSED__, int type __UNUSED__, void *event);
19 static Eina_Bool _e_mod_policy_cb_client_message(void *data __UNUSED__, int type __UNUSED__, void *event);
20 static Eina_Bool _e_mod_policy_cb_window_property(void *data __UNUSED__, int type __UNUSED__, void *event);
21 static Eina_Bool _e_mod_policy_cb_policy_change(void *data __UNUSED__, int type, void *event __UNUSED__);
22 static Eina_Bool _e_mod_policy_cb_window_configure_request (void *data __UNUSED__, int type __UNUSED__, void *event);
23 static Eina_Bool _e_mod_policy_cb_window_move_resize_request(void *data __UNUSED__, int type __UNUSED__, void *event);
24 static Eina_Bool _e_mod_policy_cb_window_state_request(void *data __UNUSED__, int type __UNUSED__, void *event);
26 static void _e_mod_policy_cb_hook_post_fetch(void *data __UNUSED__, void *data2);
27 static void _e_mod_policy_cb_hook_post_assign(void *data __UNUSED__, void *data2);
28 static void _e_mod_policy_cb_hook_layout(void *data __UNUSED__, void *data2 __UNUSED__);
29 static void _e_mod_policy_cb_hook_post_new_border (void *data __UNUSED__, void *data2);
30 static void _e_mod_policy_cb_hook_pre_fetch(void *data __UNUSED__, void *data2);
31 static void _e_mod_policy_cb_hook_new_border(void *data __UNUSED__, void *data2);
32 #ifdef _F_BORDER_HOOK_PATCH_
33 static void _e_mod_policy_cb_hook_del_border(void *data __UNUSED__, void *data2);
35 static void _e_mod_policy_cb_hook_rotation_list_add(void *data __UNUSED__, void *data2);
37 static Eina_Bool _e_mod_policy_cb_window_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event);
39 static int _e_mod_policy_init_atom (void);
40 static Eina_Bool _e_mod_policy_cb_border_stack(void *data __UNUSED__, int type __UNUSED__, void *event);
41 static Eina_Bool _e_mod_policy_cb_border_zone_set(void *data __UNUSED__, int type __UNUSED__, void *event);
44 static Eina_Bool _e_mod_policy_cb_window_create (void *data __UNUSED__, int type __UNUSED__, void *event);
45 static Eina_Bool _e_mod_policy_cb_window_destroy (void *data __UNUSED__, int type __UNUSED__, void *event);
46 static Eina_Bool _e_mod_policy_cb_window_reparent (void *data __UNUSED__, int type __UNUSED__, void *event);
47 static Eina_Bool _e_mod_policy_cb_window_show (void *data __UNUSED__, int type __UNUSED__, void *event);
48 static Eina_Bool _e_mod_policy_cb_window_hide (void *data __UNUSED__, int type __UNUSED__, void *event);
49 static Eina_Bool _e_mod_policy_cb_window_configure (void *data __UNUSED__, int type __UNUSED__, void *event);
51 static Eina_Bool _e_mod_policy_zonelist_update(void);
52 static Eina_Bool _e_mod_policy_cb_zone_add(void *data __UNUSED__, int type __UNUSED__, void *event);
53 static Eina_Bool _e_mod_policy_cb_zone_del(void *data __UNUSED__, int type __UNUSED__, void *event);
55 static Eina_Bool _e_mod_policy_cb_module_update(void *data __UNUSED__, int type __UNUSED__, void *event);
57 static Eina_Bool _e_mod_policy_cb_idle_enterer(void *data __UNUSED__);
60 static E_Illume_Policy *_policy = NULL;
61 static Eina_List *_policy_hdls = NULL, *_policy_hooks = NULL;
62 Ecore_X_Atom E_ILLUME_BORDER_WIN_RESTACK;
63 static Ecore_X_Atom E_ILLUME_USER_CREATED_WINDOW = 0;
64 static Ecore_X_Atom E_ILLUME_PARENT_BORDER_WINDOW = 0;
65 static Ecore_X_Atom E_ILLUME_ZONE_GEOMETRY = 0;
67 static Ecore_X_Atom E_ILLUME_ATOM_DESK_TOP_WIN_DESK_CHANGE = 0;
68 static Ecore_X_Atom E_ILLUME_ATOM_DESK_NEXT_SHOW = 0;
70 static Ecore_Idle_Enterer *_idle_enterer = NULL;
72 /* external variables */
73 int E_ILLUME_POLICY_EVENT_CHANGE = 0;
76 e_mod_policy_init(void)
82 if (!_e_mod_policy_init_atom())
84 /* creating atom failed, bail out */
85 printf ("Cannot create atom\n");
89 /* try to find the policy specified in config */
90 if (!(file = _e_mod_policy_find()))
92 printf("Cannot find policy\n");
96 /* attempt to load policy */
97 if (!_e_mod_policy_load(file))
99 /* loading policy failed, bail out */
100 printf("Cannot load policy: %s\n", file);
101 if (file) free(file);
105 /* create new event for policy changes */
106 E_ILLUME_POLICY_EVENT_CHANGE = ecore_event_type_new();
108 /* add our event handlers */
109 _e_mod_policy_handlers_add();
111 /* add our border hooks */
112 _e_mod_policy_hooks_add();
114 _idle_enterer = ecore_idle_enterer_add(_e_mod_policy_cb_idle_enterer, NULL);
116 /* loop the root windows */
117 EINA_LIST_FOREACH(e_manager_list(), ml, man)
124 /* loop the containers */
125 EINA_LIST_FOREACH(man->containers, cl, con)
133 EINA_LIST_FOREACH(con->zones, zl, zone)
135 E_Illume_Config_Zone *cz;
136 Ecore_X_Illume_Mode mode = ECORE_X_ILLUME_MODE_SINGLE;
140 /* check for zone config */
141 if (!(cz = e_illume_zone_config_get(zone->id)))
144 /* set mode on this zone */
145 if (cz->mode.dual == 0)
146 mode = ECORE_X_ILLUME_MODE_SINGLE;
149 if ((cz->mode.dual == 1) && (cz->mode.side == 0))
150 mode = ECORE_X_ILLUME_MODE_DUAL_TOP;
151 else if ((cz->mode.dual == 1) && (cz->mode.side == 1))
152 mode = ECORE_X_ILLUME_MODE_DUAL_LEFT;
154 ecore_x_e_illume_mode_set(zone->black_win, mode);
159 if (file) free(file);
164 e_mod_policy_shutdown(void)
166 Ecore_Event_Handler *hdl;
169 /* remove the ecore event handlers */
170 EINA_LIST_FREE(_policy_hdls, hdl)
171 ecore_event_handler_del(hdl);
173 /* remove the border hooks */
174 EINA_LIST_FREE(_policy_hooks, hook)
175 e_border_hook_del(hook);
177 if (_idle_enterer) ecore_idle_enterer_del(_idle_enterer);
178 _idle_enterer = NULL;
180 /* destroy the policy if it exists */
181 if (_policy) e_object_del(E_OBJECT(_policy));
183 /* reset event type */
184 E_ILLUME_POLICY_EVENT_CHANGE = 0;
189 /* local functions */
191 _e_mod_policy_find(void)
194 char buff[PATH_MAX], dir[PATH_MAX], *file;
196 snprintf(buff, sizeof(buff), "%s.so", _e_illume_cfg->policy.name);
197 snprintf(dir, sizeof(dir), "%s/policies", _e_illume_mod_dir);
199 /* try to list all files in this directory */
200 if (!(files = ecore_file_ls(dir))) return NULL;
202 /* loop the returned files */
203 EINA_LIST_FREE(files, file)
205 /* compare file with needed .so */
206 if (!strcmp(file, buff))
208 snprintf(dir, sizeof(dir), "%s/policies/%s",
209 _e_illume_mod_dir, file);
214 if (file) free(file);
217 /* if we did not find the requested policy, use a fallback */
218 snprintf(dir, sizeof(dir), "%s/policies/illume.so", _e_illume_mod_dir);
225 _e_mod_policy_load(char *file)
230 /* delete existing policy first */
231 if (_policy) e_object_del(E_OBJECT(_policy));
233 /* try to create our new policy object */
235 E_OBJECT_ALLOC(E_Illume_Policy, E_ILLUME_POLICY_TYPE,
236 _e_mod_policy_cb_free);
239 printf("Failed to allocate new policy object\n");
243 /* attempt to open the .so */
244 if (!(_policy->handle = dlopen(file, (RTLD_NOW | RTLD_GLOBAL))))
246 /* cannot open the .so file, bail out */
247 printf("Cannot open policy: %s\n", ecore_file_file_get(file));
248 printf("\tError: %s\n", dlerror());
249 e_object_del(E_OBJECT(_policy));
253 /* clear any existing errors in dynamic loader */
256 /* try to link to the needed policy api functions */
257 _policy->api = dlsym(_policy->handle, "e_illume_policy_api");
258 _policy->funcs.init = dlsym(_policy->handle, "e_illume_policy_init");
259 _policy->funcs.shutdown = dlsym(_policy->handle, "e_illume_policy_shutdown");
261 /* check that policy supports needed functions */
262 if ((!_policy->api) || (!_policy->funcs.init) || (!_policy->funcs.shutdown))
264 /* policy doesn't support needed functions, bail out */
265 printf("Policy does not support needed functions: %s\n",
266 ecore_file_file_get(file));
267 printf("\tError: %s\n", dlerror());
268 e_object_del(E_OBJECT(_policy));
272 /* check policy api version */
273 if (_policy->api->version < E_ILLUME_POLICY_API_VERSION)
275 /* policy is too old, bail out */
276 printf("Policy is too old: %s\n", ecore_file_file_get(file));
277 e_object_del(E_OBJECT(_policy));
281 /* try to initialize the policy */
282 if (!_policy->funcs.init(_policy))
284 /* init failed, bail out */
285 printf("Policy failed to initialize: %s\n", ecore_file_file_get(file));
286 e_object_del(E_OBJECT(_policy));
294 _e_mod_policy_handlers_add(void)
297 eina_list_append(_policy_hdls,
298 ecore_event_handler_add(E_EVENT_BORDER_ADD,
299 _e_mod_policy_cb_border_add, NULL));
301 eina_list_append(_policy_hdls,
302 ecore_event_handler_add(E_EVENT_BORDER_REMOVE,
303 _e_mod_policy_cb_border_del, NULL));
305 eina_list_append(_policy_hdls,
306 ecore_event_handler_add(E_EVENT_BORDER_FOCUS_IN,
307 _e_mod_policy_cb_border_focus_in,
310 eina_list_append(_policy_hdls,
311 ecore_event_handler_add(E_EVENT_BORDER_FOCUS_OUT,
312 _e_mod_policy_cb_border_focus_out,
315 eina_list_append(_policy_hdls,
316 ecore_event_handler_add(E_EVENT_BORDER_SHOW,
317 _e_mod_policy_cb_border_show,
320 eina_list_append(_policy_hdls,
321 ecore_event_handler_add(E_EVENT_BORDER_MOVE,
322 _e_mod_policy_cb_border_move,
326 eina_list_append(_policy_hdls,
327 ecore_event_handler_add(E_EVENT_BORDER_STACK,
328 _e_mod_policy_cb_border_stack,
331 eina_list_append(_policy_hdls,
332 ecore_event_handler_add(E_EVENT_BORDER_ZONE_SET,
333 _e_mod_policy_cb_border_zone_set, NULL));
336 eina_list_append(_policy_hdls,
337 ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE,
338 _e_mod_policy_cb_zone_move_resize,
341 eina_list_append(_policy_hdls,
342 ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
343 _e_mod_policy_cb_client_message,
346 eina_list_append(_policy_hdls,
347 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY,
348 _e_mod_policy_cb_window_property,
351 eina_list_append(_policy_hdls,
352 ecore_event_handler_add(E_ILLUME_POLICY_EVENT_CHANGE,
353 _e_mod_policy_cb_policy_change,
357 eina_list_append(_policy_hdls,
358 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_FOCUS_IN,
359 _e_mod_policy_cb_window_focus_in,
364 eina_list_append(_policy_hdls,
365 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CREATE,
366 _e_mod_policy_cb_window_create,
369 eina_list_append(_policy_hdls,
370 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY,
371 _e_mod_policy_cb_window_destroy,
374 eina_list_append(_policy_hdls,
375 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_REPARENT,
376 _e_mod_policy_cb_window_reparent,
379 eina_list_append(_policy_hdls,
380 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW,
381 _e_mod_policy_cb_window_show,
384 eina_list_append(_policy_hdls,
385 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE,
386 _e_mod_policy_cb_window_hide,
389 eina_list_append(_policy_hdls,
390 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE,
391 _e_mod_policy_cb_window_configure,
395 eina_list_append(_policy_hdls,
396 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST,
397 _e_mod_policy_cb_window_configure_request,
400 eina_list_append(_policy_hdls,
401 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST,
402 _e_mod_policy_cb_window_move_resize_request, NULL));
404 eina_list_append(_policy_hdls,
405 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST,
406 _e_mod_policy_cb_window_state_request,
410 eina_list_append(_policy_hdls,
411 ecore_event_handler_add(E_EVENT_ZONE_ADD,
412 _e_mod_policy_cb_zone_add, NULL));
414 eina_list_append(_policy_hdls,
415 ecore_event_handler_add(E_EVENT_ZONE_DEL,
416 _e_mod_policy_cb_zone_del, NULL));
420 eina_list_append(_policy_hdls,
421 ecore_event_handler_add(E_EVENT_BORDER_ICONIFY,
422 _e_mod_policy_cb_border_iconify,
426 eina_list_append(_policy_hdls,
427 ecore_event_handler_add(E_EVENT_BORDER_UNICONIFY,
428 _e_mod_policy_cb_border_uniconify,
433 eina_list_append(_policy_hdls,
434 ecore_event_handler_add(E_EVENT_MODULE_UPDATE,
435 _e_mod_policy_cb_module_update,
440 _e_mod_policy_hooks_add(void)
443 eina_list_append(_policy_hooks,
444 e_border_hook_add(E_BORDER_HOOK_EVAL_POST_FETCH,
445 _e_mod_policy_cb_hook_post_fetch, NULL));
447 eina_list_append(_policy_hooks,
448 e_border_hook_add(E_BORDER_HOOK_EVAL_POST_BORDER_ASSIGN,
449 _e_mod_policy_cb_hook_post_assign, NULL));
451 eina_list_append(_policy_hooks,
452 e_border_hook_add(E_BORDER_HOOK_CONTAINER_LAYOUT,
453 _e_mod_policy_cb_hook_layout, NULL));
455 eina_list_append(_policy_hooks,
456 e_border_hook_add(E_BORDER_HOOK_EVAL_POST_NEW_BORDER,
457 _e_mod_policy_cb_hook_post_new_border, NULL));
459 eina_list_append(_policy_hooks,
460 e_border_hook_add(E_BORDER_HOOK_EVAL_PRE_FETCH,
461 _e_mod_policy_cb_hook_pre_fetch, NULL));
463 eina_list_append(_policy_hooks,
464 e_border_hook_add(E_BORDER_HOOK_NEW_BORDER,
465 _e_mod_policy_cb_hook_new_border, NULL));
466 #ifdef _F_BORDER_HOOK_PATCH_
468 eina_list_append(_policy_hooks,
469 e_border_hook_add(E_BORDER_HOOK_DEL_BORDER,
470 _e_mod_policy_cb_hook_del_border, NULL));
473 eina_list_append(_policy_hooks,
474 e_border_hook_add(E_BORDER_HOOK_ROTATION_LIST_ADD,
475 _e_mod_policy_cb_hook_rotation_list_add, NULL));
479 _e_mod_policy_cb_free(E_Illume_Policy *p)
483 /* tell the policy to shutdown */
484 if (p->funcs.shutdown) p->funcs.shutdown(p);
485 p->funcs.shutdown = NULL;
487 p->funcs.init = NULL;
490 /* close the linked .so */
491 if (p->handle) dlclose(p->handle);
498 _e_mod_policy_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void *event)
500 E_Event_Border_Add *ev;
504 if ((_policy) && (_policy->funcs.border_add))
505 _policy->funcs.border_add(ev->border);
507 return ECORE_CALLBACK_PASS_ON;
511 _e_mod_policy_cb_border_del(void *data __UNUSED__, int type __UNUSED__, void *event)
513 E_Event_Border_Remove *ev;
517 ecore_x_window_prop_property_del(ev->border->client.win, E_ILLUME_PARENT_BORDER_WINDOW);
519 if ((_policy) && (_policy->funcs.border_del))
520 _policy->funcs.border_del(ev->border);
522 return ECORE_CALLBACK_PASS_ON;
526 _e_mod_policy_cb_border_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
528 E_Event_Border_Focus_In *ev;
531 if ((_policy) && (_policy->funcs.border_focus_in))
532 _policy->funcs.border_focus_in(ev->border);
534 return ECORE_CALLBACK_PASS_ON;
538 _e_mod_policy_cb_border_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event)
540 E_Event_Border_Focus_Out *ev;
543 if ((_policy) && (_policy->funcs.border_focus_out))
544 _policy->funcs.border_focus_out(ev->border);
546 return ECORE_CALLBACK_PASS_ON;
550 _e_mod_policy_cb_border_show(void *data __UNUSED__, int type __UNUSED__, void *event)
552 E_Event_Border_Show *ev;
555 if ((_policy) && (_policy->funcs.border_show))
556 _policy->funcs.border_show(ev->border);
558 return ECORE_CALLBACK_PASS_ON;
562 _e_mod_policy_cb_border_move(void *data __UNUSED__, int type __UNUSED__, void *event)
564 E_Event_Border_Move *ev;
567 if ((_policy) && (_policy->funcs.border_move))
568 _policy->funcs.border_move(ev->border);
570 return ECORE_CALLBACK_PASS_ON;
574 _e_mod_policy_cb_border_iconify(void *data __UNUSED__, int type __UNUSED__, void *event)
576 E_Event_Border_Iconify *ev;
579 if ((_policy) && (_policy->funcs.border_iconify_cb))
580 _policy->funcs.border_iconify_cb(ev->border);
582 return ECORE_CALLBACK_PASS_ON;
586 _e_mod_policy_cb_border_uniconify(void *data __UNUSED__, int type __UNUSED__, void *event)
588 E_Event_Border_Uniconify *ev;
591 if ((_policy) && (_policy->funcs.border_uniconify_cb))
592 _policy->funcs.border_uniconify_cb(ev->border);
594 return ECORE_CALLBACK_PASS_ON;
598 _e_mod_policy_cb_zone_move_resize(void *data __UNUSED__, int type __UNUSED__, void *event)
600 E_Event_Zone_Move_Resize *ev;
603 if ((_policy) && (_policy->funcs.zone_move_resize))
604 _policy->funcs.zone_move_resize(ev->zone);
606 return ECORE_CALLBACK_PASS_ON;
610 _e_mod_policy_cb_client_message(void *data __UNUSED__, int type __UNUSED__, void *event)
612 Ecore_X_Event_Client_Message *ev;
615 if (ev->message_type == ECORE_X_ATOM_NET_ACTIVE_WINDOW)
619 if (!(bd = e_border_find_by_client_window(ev->win))) return ECORE_CALLBACK_PASS_ON;
620 if ((_policy) && (_policy->funcs.border_activate))
621 _policy->funcs.border_activate(bd);
623 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_MODE)
627 if (!(zone = e_util_zone_window_find(ev->win))) return ECORE_CALLBACK_PASS_ON;
628 if ((_policy) && (_policy->funcs.zone_mode_change))
629 _policy->funcs.zone_mode_change(zone, ev->data.l[0]);
631 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_CLOSE)
635 if (!(zone = e_util_zone_window_find(ev->win))) return ECORE_CALLBACK_PASS_ON;
636 if ((_policy) && (_policy->funcs.zone_close))
637 _policy->funcs.zone_close(zone);
639 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_FOCUS_BACK)
643 if (!(zone = e_util_zone_window_find(ev->win))) return ECORE_CALLBACK_PASS_ON;
644 if ((_policy) && (_policy->funcs.focus_back))
645 _policy->funcs.focus_back(zone);
647 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD)
651 if (!(zone = e_util_zone_window_find(ev->win))) return ECORE_CALLBACK_PASS_ON;
652 if ((_policy) && (_policy->funcs.focus_forward))
653 _policy->funcs.focus_forward(zone);
655 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_DRAG_START)
659 if (!(bd = e_border_find_by_client_window(ev->win))) return ECORE_CALLBACK_PASS_ON;
660 if ((_policy) && (_policy->funcs.drag_start))
661 _policy->funcs.drag_start(bd);
663 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_DRAG_END)
667 if (!(bd = e_border_find_by_client_window(ev->win))) return ECORE_CALLBACK_PASS_ON;
668 if ((_policy) && (_policy->funcs.drag_end))
669 _policy->funcs.drag_end(bd);
671 else if (ev->message_type == E_ILLUME_BORDER_WIN_RESTACK)
674 E_Border *bd_sibling;
676 if (!(bd = e_border_find_by_client_window(ev->win))) return 1;
677 if (!(bd_sibling = e_border_find_by_client_window((Ecore_X_Window) ev->data.l[0]))) return 1;
679 if ((_policy) && (_policy->funcs.border_restack_request))
680 _policy->funcs.border_restack_request(bd, bd_sibling, ev->data.l[1]);
682 else if (ev->message_type == ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE)
684 if ((_policy) && (_policy->funcs.window_sync_draw_done))
685 _policy->funcs.window_sync_draw_done(ev);
687 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE)
689 if ((_policy) && (_policy->funcs.quickpanel_state_change))
690 _policy->funcs.quickpanel_state_change(ev);
692 else if (ev->message_type == E_ILLUME_ATOM_DESK_TOP_WIN_DESK_CHANGE)
694 if ((_policy) && (_policy->funcs.window_desk_set))
695 _policy->funcs.window_desk_set(ev);
697 else if (ev->message_type == ECORE_X_ATOM_E_ILLUME_WINDOW_STATE)
699 if ((_policy) && (_policy->funcs.illume_win_state_change_request))
700 _policy->funcs.illume_win_state_change_request(ev);
703 return ECORE_CALLBACK_PASS_ON;
707 _e_mod_policy_cb_window_property(void *data __UNUSED__, int type __UNUSED__, void *event)
709 Ecore_X_Event_Window_Property *ev;
712 if ((_policy) && (_policy->funcs.property_change))
713 _policy->funcs.property_change(ev);
715 return ECORE_CALLBACK_PASS_ON;
719 _e_mod_policy_cb_policy_change(void *data __UNUSED__, int type, void *event __UNUSED__)
723 if (type != E_ILLUME_POLICY_EVENT_CHANGE) return ECORE_CALLBACK_PASS_ON;
725 /* find policy specified in config */
726 if (!(file = _e_mod_policy_find())) return ECORE_CALLBACK_PASS_ON;
728 /* try to load the policy */
729 _e_mod_policy_load(file);
731 if (file) free(file);
733 return ECORE_CALLBACK_PASS_ON;
737 _e_mod_policy_cb_hook_post_fetch(void *data __UNUSED__, void *data2)
741 if (!(bd = data2)) return;
742 if ((_policy) && (_policy->funcs.border_post_fetch))
743 _policy->funcs.border_post_fetch(bd);
747 _e_mod_policy_cb_hook_post_assign(void *data __UNUSED__, void *data2)
751 if (!(bd = data2)) return;
752 if ((_policy) && (_policy->funcs.border_post_assign))
753 _policy->funcs.border_post_assign(bd);
757 _e_mod_policy_cb_hook_post_new_border (void *data __UNUSED__, void *data2)
761 if (!(bd = data2)) return;
762 if ((_policy) && (_policy->funcs.border_post_new_border))
763 _policy->funcs.border_post_new_border(bd);
766 static void _e_mod_policy_cb_hook_pre_fetch(void *data __UNUSED__, void *data2)
770 if (!(bd = data2)) return;
771 if ((_policy) && (_policy->funcs.border_pre_fetch))
772 _policy->funcs.border_pre_fetch(bd);
776 _e_mod_policy_cb_hook_new_border(void *data __UNUSED__, void *data2)
780 if (!(bd = data2)) return;
782 ecore_x_window_prop_window_set(bd->win, E_ILLUME_USER_CREATED_WINDOW, &(bd->client.win), 1);
783 ecore_x_window_prop_window_set(bd->client.win, E_ILLUME_PARENT_BORDER_WINDOW, &(bd->win), 1);
785 if ((_policy) && (_policy->funcs.border_new_border))
786 _policy->funcs.border_new_border(bd);
789 #ifdef _F_BORDER_HOOK_PATCH_
791 _e_mod_policy_cb_hook_del_border(void *data __UNUSED__, void *data2)
795 if (!(bd = data2)) return;
796 if ((_policy) && (_policy->funcs.border_del_border))
797 _policy->funcs.border_del_border(bd);
803 _e_mod_policy_cb_window_configure_request (void *data __UNUSED__, int type __UNUSED__, void *event)
805 Ecore_X_Event_Window_Configure_Request* ev = event;
807 if ((_policy) && (_policy->funcs.window_configure_request))
808 _policy->funcs.window_configure_request(ev);
810 return ECORE_CALLBACK_PASS_ON;
814 _e_mod_policy_cb_window_move_resize_request(void *data __UNUSED__, int type __UNUSED__, void *event)
816 Ecore_X_Event_Window_Move_Resize_Request *ev = event;
818 if ((_policy) && (_policy->funcs.window_move_resize_request))
819 _policy->funcs.window_move_resize_request(ev);
821 return ECORE_CALLBACK_PASS_ON;
825 _e_mod_policy_cb_window_state_request(void *data __UNUSED__, int type __UNUSED__, void *event)
827 Ecore_X_Event_Window_State_Request *ev = event;
829 if ((_policy) && (_policy->funcs.window_state_request))
830 _policy->funcs.window_state_request(ev);
832 return ECORE_CALLBACK_PASS_ON;
836 _e_mod_policy_cb_hook_layout(void *data __UNUSED__, void *data2 __UNUSED__)
840 Eina_List *zl = NULL, *l;
842 /* loop through border list and find what changed */
843 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
846 if ((bd->new_client) || (bd->pending_move_resize) ||
847 (bd->changes.pos) || (bd->changes.size) || (bd->changes.visible) ||
848 (bd->need_shape_export) || (bd->need_shape_merge))
850 /* NB: this border changed. add it's zone to list of what needs
851 * updating. This is done so we do not waste cpu cycles
852 * updating zones where nothing changed */
853 if (!eina_list_data_find(zl, bd->zone))
854 zl = eina_list_append(zl, bd->zone);
858 /* loop the zones that need updating and call the policy update function */
859 EINA_LIST_FREE(zl, zone)
861 if ((_policy) && (_policy->funcs.zone_layout))
862 _policy->funcs.zone_layout(zone);
867 _e_mod_policy_cb_window_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event)
869 Ecore_X_Event_Window_Focus_In *ev;
872 if ((_policy) && (_policy->funcs.window_focus_in))
873 _policy->funcs.window_focus_in(ev);
875 return ECORE_CALLBACK_PASS_ON;
879 _e_mod_policy_init_atom (void)
881 E_ILLUME_BORDER_WIN_RESTACK = ecore_x_atom_get ("_E_ILLUME_RESTACK_WINDOW");
882 if (!E_ILLUME_BORDER_WIN_RESTACK)
884 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_ILLUME_RESTACK_WINDOW Atom...\n");
888 E_ILLUME_USER_CREATED_WINDOW = ecore_x_atom_get("_E_USER_CREATED_WINDOW");
889 if (!E_ILLUME_USER_CREATED_WINDOW)
892 "[ILLUME2] cannot create _E_USER_CREATED_WINDOW atom.\n");
896 E_ILLUME_PARENT_BORDER_WINDOW = ecore_x_atom_get("_E_PARENT_BORDER_WINDOW");
897 if (!E_ILLUME_PARENT_BORDER_WINDOW)
900 "[ILLUME2] cannot create _E_PARENT_BORDER_WINDOW atom.\n");
904 E_ILLUME_ZONE_GEOMETRY = ecore_x_atom_get("_E_ILLUME_ZONE_GEOMETRY");
905 if (!E_ILLUME_ZONE_GEOMETRY)
908 "[ILLUME2] cannot create _E_ILLUME_ZONE_GEOMETRY atom.\n");
912 E_ILLUME_ATOM_DESK_TOP_WIN_DESK_CHANGE =
913 ecore_x_atom_get ("_E_ILLUME_ATOM_DESK_TOP_WIN_DESK_CHANGE");
914 if(!E_ILLUME_ATOM_DESK_TOP_WIN_DESK_CHANGE)
916 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_COMP_ENABLE Atom...\n");
920 E_ILLUME_ATOM_DESK_NEXT_SHOW =
921 ecore_x_atom_get ("_E_ILLUME_ATOM_DESK_NEXT_SHOW");
922 if(!E_ILLUME_ATOM_DESK_NEXT_SHOW)
924 fprintf (stderr, "[ILLUME2] Critical Error!!! Cannot create _E_COMP_ENABLE Atom...\n");
932 _e_mod_policy_cb_border_stack(void *data __UNUSED__, int type __UNUSED__, void *event)
934 E_Event_Border_Stack *ev;
937 if ((_policy) && (_policy->funcs.border_stack))
938 _policy->funcs.border_stack(ev);
940 return ECORE_CALLBACK_PASS_ON;
944 _e_mod_policy_cb_border_zone_set(void *data __UNUSED__, int type __UNUSED__, void *event)
946 E_Event_Border_Zone_Set *ev;
949 if ((_policy) && (_policy->funcs.border_zone_set))
950 _policy->funcs.border_zone_set(ev);
952 return ECORE_CALLBACK_PASS_ON;
957 _e_mod_policy_cb_window_create (void *data __UNUSED__, int type __UNUSED__, void *event)
959 Ecore_X_Event_Window_Create* ev = event;
961 if ((_policy) && (_policy->funcs.window_create))
962 _policy->funcs.window_create(ev);
964 return ECORE_CALLBACK_PASS_ON;
968 _e_mod_policy_cb_window_destroy (void *data __UNUSED__, int type __UNUSED__, void *event)
970 Ecore_X_Event_Window_Destroy* ev = event;
972 if ((_policy) && (_policy->funcs.window_destroy))
973 _policy->funcs.window_destroy(ev);
975 return ECORE_CALLBACK_PASS_ON;
979 _e_mod_policy_cb_window_reparent (void *data __UNUSED__, int type __UNUSED__, void *event)
981 Ecore_X_Event_Window_Reparent* ev = event;
983 if ((_policy) && (_policy->funcs.window_reparent))
984 _policy->funcs.window_reparent(ev);
986 return ECORE_CALLBACK_PASS_ON;
990 _e_mod_policy_cb_window_show (void *data __UNUSED__, int type __UNUSED__, void *event)
992 Ecore_X_Event_Window_Show* ev = event;
994 if ((_policy) && (_policy->funcs.window_show))
995 _policy->funcs.window_show(ev);
997 return ECORE_CALLBACK_PASS_ON;
1001 _e_mod_policy_cb_window_hide (void *data __UNUSED__, int type __UNUSED__, void *event)
1003 Ecore_X_Event_Window_Hide* ev = event;
1005 if ((_policy) && (_policy->funcs.window_hide))
1006 _policy->funcs.window_hide(ev);
1008 return ECORE_CALLBACK_PASS_ON;
1012 _e_mod_policy_cb_window_configure (void *data __UNUSED__, int type __UNUSED__, void *event)
1014 Ecore_X_Event_Window_Configure* ev = event;
1016 if ((_policy) && (_policy->funcs.window_configure))
1017 _policy->funcs.window_configure(ev);
1019 return ECORE_CALLBACK_PASS_ON;
1023 _e_mod_policy_zonelist_update(void)
1025 Eina_List *ml, *cl, *zl;
1029 Ecore_X_Window *zones;
1032 /* loop zones and get count */
1033 EINA_LIST_FOREACH(e_manager_list(), ml, man)
1036 EINA_LIST_FOREACH(man->containers, cl, con)
1039 EINA_LIST_FOREACH(con->zones, zl, zone)
1044 /* allocate enough zones */
1045 zones = calloc(zcount, sizeof(Ecore_X_Window));
1046 if (!zones) return EINA_FALSE;
1050 /* loop the zones and set zone list */
1051 EINA_LIST_FOREACH(e_manager_list(), ml, man)
1054 EINA_LIST_FOREACH(man->containers, cl, con)
1057 EINA_LIST_FOREACH(con->zones, zl, zone)
1059 if (!zone) continue;
1061 zones[zcount] = zone->black_win;
1066 ecore_x_e_illume_zone_list_set(man->root, zones, zcount);
1074 _e_mod_policy_cb_zone_add(void *data __UNUSED__, int type __UNUSED__, void *event)
1076 E_Event_Zone_Add *ev;
1078 unsigned int geom[4];
1087 ecore_x_window_prop_card32_set(zone->black_win, E_ILLUME_ZONE_GEOMETRY,
1090 _e_mod_policy_zonelist_update();
1092 return ECORE_CALLBACK_PASS_ON;
1096 _e_mod_policy_cb_zone_del(void *data __UNUSED__, int type __UNUSED__, void *event)
1098 E_Event_Zone_Del *ev;
1104 _e_mod_policy_zonelist_update();
1106 return ECORE_CALLBACK_PASS_ON;
1110 _e_mod_policy_cb_module_update(void *data __UNUSED__, int type __UNUSED__, void *event)
1112 E_Event_Module_Update *ev;
1115 if ((_policy) && (_policy->funcs.module_update))
1116 _policy->funcs.module_update(ev);
1118 return ECORE_CALLBACK_PASS_ON;
1122 _e_mod_policy_cb_idle_enterer(void *data __UNUSED__)
1124 if ((_policy) && (_policy->funcs.idle_enterer))
1125 _policy->funcs.idle_enterer();
1127 return ECORE_CALLBACK_RENEW;
1131 _e_mod_policy_cb_hook_rotation_list_add(void *data __UNUSED__, void *data2)
1135 if (!(bd = data2)) return;
1136 if ((_policy) && (_policy->funcs.rotation_list_add))
1137 _policy->funcs.rotation_list_add(bd);