1 #include "e_illume_private.h"
2 #include "e_mod_config.h"
5 * @defgroup E_Illume_Main_Group Illume API Information
7 * The following group defines variables, structures, and functions available
12 * Returns the @ref E_Illume_Config_Zone structure for a specific zone.
14 * @param id The id of the E_Zone.
15 * @return The @ref E_Illume_Config_Zone structure for this zone.
17 * @note This function will return a new @ref E_Illume_Config_Zone structure
18 * if none exists. This new @ref E_Illume_Config_Zone will be added to the
19 * existing list of @ref E_Illume_Config_Zone structures automatically.
21 * @ingroup E_Illume_Config_Group
23 EAPI E_Illume_Config_Zone *
24 e_illume_zone_config_get(int id)
27 E_Illume_Config_Zone *cz = NULL;
29 /* loop existing zone configs and look for this id */
30 EINA_LIST_FOREACH(_e_illume_cfg->policy.zones, l, cz)
32 if (cz->id != id) continue;
36 /* we did not find an existing one for this zone, so create a new one */
37 cz = E_NEW(E_Illume_Config_Zone, 1);
42 /* add it to the list */
43 _e_illume_cfg->policy.zones =
44 eina_list_append(_e_illume_cfg->policy.zones, cz);
46 /* save it in config */
47 e_mod_illume_config_save();
49 /* return a fallback */
54 * Determine if a given border is an Indicator window.
56 * @param bd The border to test.
57 * @return EINA_TRUE if it is an Indicator window, EINA_FALSE otherwise.
59 * @note If @p bd is NULL then this function will return EINA_FALSE.
61 * @note It is assumed that Indicator windows are of type
62 * ECORE_X_WINDOW_TYPE_DOCK.
64 * @ingroup E_Illume_Main_Group
67 e_illume_border_is_indicator(E_Border *bd)
69 /* make sure we have a border */
70 if (!bd) return EINA_FALSE;
72 /* indicator windows should be set to dock type, so check for that */
73 if (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) return EINA_FALSE;
75 /* we have a dock window, check against any matches in config */
77 /* check if we are matching on name */
78 if (_e_illume_cfg->policy.indicator.match.name)
80 if ((bd->client.icccm.name) &&
81 (!strcmp(bd->client.icccm.name,
82 _e_illume_cfg->policy.indicator.name)))
86 /* check if we are matching on class */
87 if (_e_illume_cfg->policy.indicator.match.class)
89 if ((bd->client.icccm.class) &&
90 (!strcmp(bd->client.icccm.class,
91 _e_illume_cfg->policy.indicator.class)))
95 /* check if we are matching on title */
96 if (_e_illume_cfg->policy.indicator.match.title)
100 if ((title = e_border_name_get(bd)))
101 if (!strcmp(title, _e_illume_cfg->policy.indicator.title))
105 /* return a fallback */
110 * Determine if a given border is a Softkey window.
112 * @param bd The border to test.
113 * @return EINA_TRUE if it is a Softkey window, EINA_FALSE otherwise.
115 * @note If @p bd is NULL then this function will return EINA_FALSE.
117 * @note It is assumed that Softkey windows are of type
118 * ECORE_X_WINDOW_TYPE_DOCK.
120 * @ingroup E_Illume_Main_Group
123 e_illume_border_is_softkey(E_Border *bd)
125 /* make sure we have a border */
126 if (!bd) return EINA_FALSE;
128 /* legacy code from illume 1 */
129 if (bd->client.qtopia.soft_menu) return EINA_TRUE;
131 /* softkey windows should be set to dock type, so check for that */
132 if (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_DOCK) return EINA_FALSE;
134 /* we have a softkey window, check against any matches in config */
136 /* check if we are matching on name */
137 if (_e_illume_cfg->policy.softkey.match.name)
139 if ((bd->client.icccm.name) &&
140 (!strcmp(bd->client.icccm.name,
141 _e_illume_cfg->policy.softkey.name)))
145 /* check if we are matching on class */
146 if (_e_illume_cfg->policy.softkey.match.class)
148 if ((bd->client.icccm.class) &&
149 (!strcmp(bd->client.icccm.class,
150 _e_illume_cfg->policy.softkey.class)))
154 /* check if we are matching on title */
155 if (_e_illume_cfg->policy.softkey.match.title)
159 if ((title = e_border_name_get(bd)))
160 if (!strcmp(title, _e_illume_cfg->policy.softkey.title))
164 /* return a fallback */
169 * Determine if a given border is a Keyboard window.
171 * @param bd The border to test.
172 * @return EINA_TRUE if it is a Keyboard window, EINA_FALSE otherwise.
174 * @note If @p bd is NULL then this function will return EINA_FALSE.
176 * @ingroup E_Illume_Main_Group
179 e_illume_border_is_keyboard(E_Border *bd)
181 /* make sure we have a border */
182 if (!bd) return EINA_FALSE;
184 /* check for specific flag first */
185 if (bd->client.vkbd.vkbd) return EINA_TRUE;
187 /* legacy code from illume 1 */
188 if ((bd->client.icccm.name) &&
189 ((!strcmp(bd->client.icccm.name, "multitap-pad"))) &&
190 (bd->client.netwm.state.skip_taskbar) &&
191 (bd->client.netwm.state.skip_pager))
194 /* check if we are matching on name */
195 if (_e_illume_cfg->policy.vkbd.match.name)
197 if ((bd->client.icccm.name) &&
198 (!strcmp(bd->client.icccm.name,
199 _e_illume_cfg->policy.vkbd.name)))
203 /* check if we are matching on class */
204 if (_e_illume_cfg->policy.vkbd.match.class)
206 if ((bd->client.icccm.class) &&
207 (!strcmp(bd->client.icccm.class,
208 _e_illume_cfg->policy.vkbd.class)))
212 /* check if we are matching on title */
213 if (_e_illume_cfg->policy.vkbd.match.title)
217 if ((title = e_border_name_get(bd)))
218 if (!strcmp(title, _e_illume_cfg->policy.vkbd.title))
222 /* return a fallback */
227 * Determine if a given border is a Home window.
229 * @param bd The border to test.
230 * @return EINA_TRUE if it is a Home window, EINA_FALSE otherwise.
232 * @note If @p bd is NULL then this function will return EINA_FALSE.
234 * @ingroup E_Illume_Main_Group
237 e_illume_border_is_home(E_Border *bd)
239 /* make sure we have a border */
240 if (!bd) return EINA_FALSE;
242 /* skip windows which are not either 'normal' windows, or 'unknown' windows
243 * NB: Let 'unknown' windows pass through as a safety */
244 if ((bd->client.netwm.type != ECORE_X_WINDOW_TYPE_NORMAL) &&
245 (bd->client.netwm.type != ECORE_X_WINDOW_TYPE_UNKNOWN))
248 /* check if we are matching on name */
249 if (_e_illume_cfg->policy.home.match.name)
251 if ((bd->client.icccm.name) &&
252 (!strcmp(bd->client.icccm.name,
253 _e_illume_cfg->policy.home.name)))
257 /* check if we are matching on class */
258 if (_e_illume_cfg->policy.home.match.class)
260 if ((bd->client.icccm.class) &&
261 (!strcmp(bd->client.icccm.class,
262 _e_illume_cfg->policy.home.class)))
266 /* check if we are matching on title */
267 if (_e_illume_cfg->policy.home.match.title)
271 if ((title = e_border_name_get(bd)))
272 if (!strcmp(title, _e_illume_cfg->policy.home.title))
276 /* return a fallback */
281 * Determine if a given border is a splash screen.
283 * @param bd The border to test.
284 * @return EINA_TRUE if it is a splash screen, EINA_FALSE otherwise.
286 * @note If @p bd is NULL then this function will return EINA_FALSE.
288 * @ingroup E_Illume_Main_Group
291 e_illume_border_is_splash(E_Border *bd)
293 /* make sure we have a border */
294 if (!bd) return EINA_FALSE;
296 /* check actual type */
297 if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_SPLASH) return EINA_TRUE;
299 /* check for transient flag */
300 // if (bd->client.icccm.transient_for != 0) return EINA_TRUE;
302 /* NB: may or may not need to handle these. Needs Testing */
303 if (bd->client.netwm.extra_types)
304 printf("\t\tBorder has extra types: %s\n", bd->client.icccm.class);
306 /* return a fallback */
311 * Determine if a given border is a dialog.
313 * @param bd The border to test.
314 * @return EINA_TRUE if it is a dialog, EINA_FALSE otherwise.
316 * @note If @p bd is NULL then this function will return EINA_FALSE.
318 * @ingroup E_Illume_Main_Group
321 e_illume_border_is_dialog(E_Border *bd)
323 /* make sure we have a border */
324 if (!bd) return EINA_FALSE;
326 /* check actual type */
327 if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_DIALOG) return EINA_TRUE;
329 /* check for transient flag */
330 if (bd->client.icccm.transient_for != 0) return EINA_TRUE;
332 /* check for client leader */
333 /* NB: disabled currently as some GTK windows set this even tho they are
335 // if (bd->client.icccm.client_leader) return EINA_TRUE;
337 /* NB: may or may not need to handle these. Needs Testing */
338 if (bd->client.netwm.extra_types)
339 printf("\t\tBorder has extra types: %s\n", bd->client.icccm.class);
341 /* return a fallback */
346 * Determine if a given border is a QT VCLSalFrame.
348 * @param bd The border to test.
349 * @return EINA_TRUE if it is a VCLSalFrame, EINA_FALSE otherwise.
351 * @note If @p bd is NULL then this function will return EINA_FALSE.
353 * @ingroup E_Illume_Main_Group
356 e_illume_border_is_qt_frame(E_Border *bd)
358 /* make sure we have a border */
359 if (!bd) return EINA_FALSE;
361 /* make sure we have the icccm name and compare it */
362 if ((bd->client.icccm.name) &&
363 (!strncmp(bd->client.icccm.name, "VCLSalFrame", 11)))
366 /* return a fallback */
371 * Determine if a given border is a fullscreen window.
373 * @param bd The border to test.
374 * @return EINA_TRUE if it is fullscreen, EINA_FALSE otherwise.
376 * @note If @p bd is NULL then this function will return EINA_FALSE.
378 * @ingroup E_Illume_Main_Group
381 e_illume_border_is_fullscreen(E_Border *bd)
383 /* make sure we have a border */
384 if (!bd) return EINA_FALSE;
386 /* check for fullscreen */
387 if ((bd->fullscreen) || (bd->need_fullscreen)) return EINA_TRUE;
389 /* return a fallback */
394 * Determine if a given border is an illume conformant window.
396 * @param bd The border to test.
397 * @return EINA_TRUE if it is conformant, EINA_FALSE otherwise.
399 * @note If @p bd is NULL then this function will return EINA_FALSE.
401 * @ingroup E_Illume_Main_Group
404 e_illume_border_is_conformant(E_Border *bd)
406 /* make sure we have a border */
407 if (!bd) return EINA_FALSE;
409 /* return if it is conformant or not */
410 return bd->client.illume.conformant.conformant;
414 * Determine if a given border is a quickpanel window.
416 * @param bd The border to test.
417 * @return EINA_TRUE if it is a quickpanel, EINA_FALSE otherwise.
419 * @note If @p bd is NULL then this function will return EINA_FALSE.
421 * @ingroup E_Illume_Main_Group
424 e_illume_border_is_quickpanel(E_Border *bd)
426 /* make sure we have a border */
427 if (!bd) return EINA_FALSE;
429 /* return if it is a quickpanel or not */
430 return bd->client.illume.quickpanel.quickpanel;
434 * Retrieves the minimum space required to display this border.
436 * @param bd The border to get the minium space for.
437 * @param w Pointer to an integer into which the width is to be stored.
438 * @param h Pointer to an integer into which the height is to be stored.
440 * @note if @p bd is NULL then @p w and @p h will return @c 0.
442 * @ingroup E_Illume_Main_Group
445 e_illume_border_min_get(E_Border *bd, int *w, int *h)
453 if (bd->client.icccm.base_w > bd->client.icccm.min_w)
454 *w = bd->client.icccm.base_w;
456 *w = bd->client.icccm.min_w;
460 if (bd->client.icccm.base_h > bd->client.icccm.min_h)
461 *h = bd->client.icccm.base_h;
463 *h = bd->client.icccm.min_h;
468 * Retrieves a border, given an x and y coordinate, from a zone.
470 * @param zone The zone.
471 * @param x The X coordinate to check for border at.
472 * @param y The Y coordinate to check for border at.
474 * @note if @p zone is NULL then this function will return NULL.
476 * @warning Both X and Y coordinates are required to reliably detect a border.
478 * @ingroup E_Illume_Main_Group
481 e_illume_border_at_xy_get(E_Zone *zone, int x, int y)
486 /* make sure we have a zone */
487 if (!zone) return NULL;
489 /* loop the border client list */
490 /* NB: We use e_border_client_list here, rather than
491 * e_container_border_list, because e_border_client_list is faster.
492 * This is done in reverse order so we get the most recent border first */
493 EINA_LIST_REVERSE_FOREACH(e_border_client_list(), l, bd)
495 /* check zone and skip borders not on this zone */
496 if (bd->zone != zone) continue;
498 /* skip invisibles */
499 if (!bd->visible) continue;
501 /* check position against given coordinates */
502 if ((bd->x != x) || (bd->y != y)) continue;
504 /* filter out borders we don't want */
505 if (e_illume_border_is_indicator(bd)) continue;
506 if (e_illume_border_is_softkey(bd)) continue;
507 if (e_illume_border_is_keyboard(bd)) continue;
508 if (e_illume_border_is_quickpanel(bd)) continue;
509 if (e_illume_border_is_home(bd)) continue;
511 /* found one, return it */
515 /* return a fallback */
520 * Retrieve the parent of a given dialog.
522 * @param bd The border to get the parent of.
523 * @return The border's parent, or NULL if no parent exists.
525 * @note If @p bd is NULL then this function will return NULL.
527 * @ingroup E_Illume_Main_Group
530 e_illume_border_parent_get(E_Border *bd)
532 /* make sure we have a border */
533 if (!bd) return NULL;
535 /* check for border's parent */
536 if (bd->parent) return bd->parent;
538 /* NB: TEST CODE - may need to check bd->leader here */
540 printf("\tDialog Has Leader: %s\n", bd->client.icccm.name);
542 /* check for transient */
543 if (bd->client.icccm.transient_for)
545 /* try to find this borders parent */
546 return e_border_find_by_client_window(bd->client.icccm.transient_for);
548 else if (bd->client.icccm.client_leader)
550 /* NB: using client_leader as parent. THIS NEEDS THOROUGH TESTING !! */
551 return e_border_find_by_client_window(bd->client.icccm.client_leader);
554 /* return a fallback */
559 * Show a given border.
561 * @param bd The border to show.
563 * @note If @p bd is NULL then this function will return.
565 * @ingroup E_Illume_Main_Group
568 e_illume_border_show(E_Border *bd)
570 /* make sure we have a border */
573 e_border_uniconify(bd);
579 unsigned int visible = 1;
581 /* NB: We handle shows this way so we don't get extra layout events from
582 * the e_border calls */
583 e_container_border_lower(bd);
584 e_container_shape_show(bd->shape);
585 if (!bd->need_reparent) ecore_x_window_show(bd->client.win);
586 e_hints_window_visible_set(bd);
588 bd->changes.visible = 1;
589 ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &visible, 1);
590 ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MANAGED, &visible, 1);
595 * Hide a given border.
597 * @param bd The border to hide.
599 * @note If @p bd is NULL then this function will return.
601 * @ingroup E_Illume_Main_Group
604 e_illume_border_hide(E_Border *bd)
606 /* make sure we have a border */
609 e_border_iconify(bd);
613 unsigned int visible = 0;
615 /* NB: We handle hides this way so we don't get extra layout events from
616 * the e_border calls */
617 e_container_shape_hide(bd->shape);
618 if (!bd->iconic) e_hints_window_hidden_set(bd);
620 bd->changes.visible = 1;
621 ecore_x_window_prop_card32_set(bd->client.win, E_ATOM_MAPPED, &visible, 1);
626 * Retrieve the Indicator window on a given zone.
628 * @param zone The zone.
629 * @return The Indicator border, or NULL if no Indicator exists.
631 * @note If @p zone is NULL then this function will return NULL.
633 * @ingroup E_Illume_Main_Group
636 e_illume_border_indicator_get(E_Zone *zone)
641 /* make sure we have a zone */
642 if (!zone) return NULL;
644 /* loop the border client list */
645 /* NB: We use e_border_client_list here, rather than
646 * e_container_border_list, because e_border_client_list is faster */
647 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
649 /* check zone and skip borders not on this zone */
650 if (bd->zone != zone) continue;
652 /* skip borders that are not indicators */
653 if (!e_illume_border_is_indicator(bd)) continue;
655 /* found one, return it */
659 /* return a fallback */
664 * Retrieves the current position of the Indicator window.
666 * @param zone The zone on which to retrieve the Indicator position.
667 * @param x Pointer to an integer into which the left is to be stored.
668 * @param y Pointer to an integer into which the top is to be stored.
670 * @note if @p zone is NULL then @p x, @p y, @p w, and @p h will return @c 0.
672 * @ingroup E_Illume_Main_Group
675 e_illume_border_indicator_pos_get(E_Zone *zone, int *x, int *y)
682 /* make sure we have a zone */
685 /* set default values */
689 /* try and get the Indicator on this zone */
690 if (!(ind = e_illume_border_indicator_get(zone))) return;
692 /* return Indicator position(s) */
698 * Retrieve the Softkey window on a given zone.
700 * @param zone The zone.
701 * @return The Softkey border, or NULL if no Softkey exists.
703 * @note If @p zone is NULL then this function will return NULL.
705 * @ingroup E_Illume_Main_Group
708 e_illume_border_softkey_get(E_Zone *zone)
713 /* make sure we have a zone */
714 if (!zone) return NULL;
716 /* loop the border client list */
717 /* NB: We use e_border_client_list here, rather than
718 * e_container_border_list, because e_border_client_list is faster */
719 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
721 /* check zone and skip borders not on this zone */
722 if (bd->zone != zone) continue;
724 /* skip borders that are not indicators */
725 if (!e_illume_border_is_softkey(bd)) continue;
727 /* found one, return it */
731 /* return a fallback */
736 * Retrieves the current position of the Softkey window.
738 * @param zone The zone on which to retrieve the Softkey position.
739 * @param x Pointer to an integer into which the left is to be stored.
740 * @param y Pointer to an integer into which the top is to be stored.
742 * @note if @p zone is NULL then @p x, @p y, @p w, and @p h will return @c 0.
744 * @ingroup E_Illume_Main_Group
747 e_illume_border_softkey_pos_get(E_Zone *zone, int *x, int *y)
754 /* make sure we have a zone */
757 /* set default values */
761 /* try and get the Softkey on this zone */
762 if (!(sft = e_illume_border_softkey_get(zone))) return;
764 /* return Indicator position(s) */
770 * Retrieve the Keyboard.
772 * @return The @ref E_Illume_Keyboard, or NULL if no keyboard exists.
774 * @ingroup E_Illume_Keyboard_Group
776 EAPI E_Illume_Keyboard *
777 e_illume_keyboard_get(void)
779 /* make sure we have a keyboard */
780 if (!_e_illume_kbd) return NULL;
782 /* return the keyboard */
783 return _e_illume_kbd;
787 * Retrieves the available screen space not occupied by the virtual keyboard.
789 * @param zone The zone on which to retrieve the available space.
790 * @param x Pointer to an integer into which the left is to be stored.
791 * @param y Pointer to an integer into which the top is to be stored.
792 * @param w Pointer to an integer into which the width is to be stored.
793 * @param h Pointer to an integer into which the height is to be stored.
795 * @note if @p zone is NULL then @p x, @p y, @p w, and @p h will return @c 0.
797 * @warning This function does not account for space or position of Indicator
798 * or Softkey windows.
800 * @ingroup E_Illume_Keyboard_Group
803 e_illume_keyboard_safe_app_region_get(E_Zone *zone, int *x, int *y, int *w, int *h)
810 /* make sure we have a zone */
813 /* set default values */
819 /* if the keyboard is disabled, get out */
820 if ((!_e_illume_kbd->visible) || (_e_illume_kbd->disabled)) return;
822 /* if we don't have a border, get out */
823 /* NB: This basically means that we have the vkbd structure, but no
824 * app or module present to act as the vkbd */
825 if (!_e_illume_kbd->border) return;
827 /* if the keyboard border is not on this zone, get out */
828 if (_e_illume_kbd->border->zone != zone) return;
830 if (!_e_illume_kbd->animator)
834 *h -= _e_illume_kbd->border->h;
841 * Retrieve the Home window on a given zone.
843 * @param zone The zone.
844 * @return The Home window, or NULL if no Home window exists.
846 * @note If @p zone is NULL then this function will return NULL.
848 * @ingroup E_Illume_Main_Group
851 e_illume_border_home_get(E_Zone *zone)
856 /* make sure we have a zone */
857 if (!zone) return NULL;
859 /* loop the border client list */
860 /* NB: We use e_border_client_list here, rather than
861 * e_container_border_list, because e_border_client_list is faster */
862 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
864 /* check zone and skip borders not on this zone */
865 if (bd->zone != zone) continue;
867 /* skip borders that are not home windows */
868 if (!e_illume_border_is_home(bd)) continue;
870 /* found one, return it */
874 /* return a fallback */
879 * Retrieve the list of Home windows on a given zone.
881 * @param zone The zone.
882 * @return A list of existing Home windows, or NULL if none exist.
884 * @note If @p zone is NULL then this function will return NULL.
886 * @ingroup E_Illume_Main_Group
889 e_illume_border_home_borders_get(E_Zone *zone)
891 Eina_List *ret = NULL, *l;
894 /* make sure we have a zone */
895 if (!zone) return NULL;
897 /* loop the border client list */
898 /* NB: We use e_border_client_list here, rather than
899 * e_container_border_list, because e_border_client_list is faster */
900 EINA_LIST_FOREACH(e_border_client_list(), l, bd)
902 /* check zone and skip borders not on this zone */
903 if (bd->zone != zone) continue;
905 /* skip borders that are not home windows */
906 if (!e_illume_border_is_home(bd)) continue;
908 /* found one, append it to the list */
909 ret = eina_list_append(ret, bd);
912 /* return the list */
917 * Retrieve the Illume Quickpanel on a given zone.
919 * @param zone The zone on which to retrieve the Quickpanel.
920 * @return The @ref E_Illume_Quickpanel on this zone, or NULL if none exists.
922 * @note If @p zone is NULL then this function will return NULL.
924 * @ingroup E_Illume_Quickpanel_Group
926 EAPI E_Illume_Quickpanel *
927 e_illume_quickpanel_by_zone_get(E_Zone *zone)
929 E_Illume_Quickpanel *qp;
932 /* make sure we have a zone */
933 if (!zone) return NULL;
935 /* loop the list of quickpanels, looking for one on this zone */
936 EINA_LIST_FOREACH(_e_illume_qps, l, qp)
937 if (qp->zone == zone) return qp;
939 /* return a fallback */
944 * Show the Illume Quickpanel on a given zone.
946 * @param zone The zone on which to show the Quickpanel.
948 * @note If @p zone is NULL then this function will return.
950 * @ingroup E_Illume_Quickpanel_Group
953 e_illume_quickpanel_show(E_Zone *zone)
956 ecore_x_e_illume_quickpanel_state_send(zone->black_win,
957 ECORE_X_ILLUME_QUICKPANEL_STATE_ON);
961 * Hide the Illume Quickpanel on a given zone.
963 * @param zone The zone on which to hide the Quickpanel.
965 * @note If @p zone is NULL then this function will return.
967 * @ingroup E_Illume_Quickpanel_Group
970 e_illume_quickpanel_hide(E_Zone *zone)
973 ecore_x_e_illume_quickpanel_state_send(zone->black_win,
974 ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);