diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/ecore/src/lib/ecore/ecore_main.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore/ecore_main.c | 185 |
1 files changed, 59 insertions, 126 deletions
diff --git a/libraries/ecore/src/lib/ecore/ecore_main.c b/libraries/ecore/src/lib/ecore/ecore_main.c index 76aced6..587c83b 100644 --- a/libraries/ecore/src/lib/ecore/ecore_main.c +++ b/libraries/ecore/src/lib/ecore/ecore_main.c | |||
@@ -229,10 +229,14 @@ static Eina_Bool win32_handlers_delete_me = EINA_FALSE; | |||
229 | #ifdef _WIN32 | 229 | #ifdef _WIN32 |
230 | Ecore_Select_Function main_loop_select = _ecore_main_win32_select; | 230 | Ecore_Select_Function main_loop_select = _ecore_main_win32_select; |
231 | #else | 231 | #else |
232 | # ifdef HAVE_SYS_SELECT_H | 232 | # if !defined EXOTIC_NO_SELECT |
233 | # include <sys/select.h> | 233 | # ifdef HAVE_SYS_SELECT_H |
234 | # endif | 234 | # include <sys/select.h> |
235 | # endif | ||
235 | Ecore_Select_Function main_loop_select = select; | 236 | Ecore_Select_Function main_loop_select = select; |
237 | # else | ||
238 | Ecore_Select_Function main_loop_select = NULL; | ||
239 | # endif | ||
236 | #endif | 240 | #endif |
237 | 241 | ||
238 | #ifndef USE_G_MAIN_LOOP | 242 | #ifndef USE_G_MAIN_LOOP |
@@ -848,6 +852,21 @@ _ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler) | |||
848 | * DO NOT use this function unless you are the person God comes to ask for | 852 | * DO NOT use this function unless you are the person God comes to ask for |
849 | * advice when He has trouble managing the Universe. | 853 | * advice when He has trouble managing the Universe. |
850 | */ | 854 | */ |
855 | |||
856 | EAPI int | ||
857 | ecore_main_loop_iterate_may_block(int may_block) | ||
858 | { | ||
859 | #ifndef USE_G_MAIN_LOOP | ||
860 | _ecore_lock(); | ||
861 | in_main_loop++; | ||
862 | _ecore_main_loop_iterate_internal(!may_block); | ||
863 | in_main_loop--; | ||
864 | _ecore_unlock(); | ||
865 | return _ecore_event_exist(); | ||
866 | #else | ||
867 | return g_main_context_iteration(NULL, may_block); | ||
868 | #endif | ||
869 | } | ||
851 | EAPI void | 870 | EAPI void |
852 | ecore_main_loop_iterate(void) | 871 | ecore_main_loop_iterate(void) |
853 | { | 872 | { |
@@ -945,39 +964,6 @@ ecore_main_loop_select_func_get(void) | |||
945 | return main_loop_select; | 964 | return main_loop_select; |
946 | } | 965 | } |
947 | 966 | ||
948 | /** | ||
949 | * Adds a callback for activity on the given file descriptor. | ||
950 | * | ||
951 | * @p func will be called during the execution of @ref ecore_main_loop_begin | ||
952 | * when the file descriptor is available for reading, or writing, or both. | ||
953 | * | ||
954 | * Normally when @p func returns ECORE_CALLBACK_CANCEL, it indicates that the | ||
955 | * handler should be marked for deletion (identical to calling @ref ecore_main_fd_handler_del). | ||
956 | * However, if the @p buf_func is supplied, then the return value from the @p func indicates that | ||
957 | * @p func should be called repeatedly until it returns ECORE_CALLBACK_CANCEL. | ||
958 | * | ||
959 | * @p buf_func is called during event loop handling to check if data that has | ||
960 | * been read from the file descriptor is in a buffer and is available to | ||
961 | * read. Some systems (notably xlib) handle their own buffering, and would | ||
962 | * otherwise not work with select(). These systems should use a @p buf_func. | ||
963 | * This is a most annoying hack, only ecore_x uses it, so refer to that for | ||
964 | * an example. NOTE - @p func should probably return ECORE_CALLBACK_RENEW always if | ||
965 | * @p buf_func is used, to avoid confusion with the other return value | ||
966 | * semantics. | ||
967 | * | ||
968 | * @param fd The file descriptor to watch. | ||
969 | * @param flags To watch it for read (@c ECORE_FD_READ) and/or | ||
970 | * (@c ECORE_FD_WRITE) write ability. @c ECORE_FD_ERROR | ||
971 | * | ||
972 | * @param func The callback function. | ||
973 | * @param data The data to pass to the callback. | ||
974 | * @param buf_func The function to call to check if any data has been | ||
975 | * buffered and already read from the fd. Can be @c NULL. | ||
976 | * @param buf_data The data to pass to the @p buf_func function. | ||
977 | * @return A fd handler handle if successful. @c NULL otherwise. | ||
978 | * @note This function CANNOT be used for reading/writing to regular files! | ||
979 | * @ingroup Ecore_FD_Handler_Group | ||
980 | */ | ||
981 | EAPI Ecore_Fd_Handler * | 967 | EAPI Ecore_Fd_Handler * |
982 | ecore_main_fd_handler_add(int fd, | 968 | ecore_main_fd_handler_add(int fd, |
983 | Ecore_Fd_Handler_Flags flags, | 969 | Ecore_Fd_Handler_Flags flags, |
@@ -1059,20 +1045,6 @@ ecore_main_win32_handler_add(void *h __UNUSED__, | |||
1059 | 1045 | ||
1060 | #endif | 1046 | #endif |
1061 | 1047 | ||
1062 | /** | ||
1063 | * Marks an FD handler for deletion. | ||
1064 | * @param fd_handler The FD handler. | ||
1065 | * @return The data pointer set using @ref ecore_main_fd_handler_add, | ||
1066 | * for @p fd_handler on success. @c NULL otherwise. | ||
1067 | * @ingroup Ecore_FD_Handler_Group | ||
1068 | * This function marks an fd handler to be deleted during an iteration of the main loop. | ||
1069 | * It does NOT close the associated fd! | ||
1070 | * | ||
1071 | * @note If the underlying fd is already closed ecore may complain if the main loop | ||
1072 | * is using epoll internally, and also in some rare cases this may cause | ||
1073 | * crashes and instability. Remember to delete your fd handlers before the | ||
1074 | * fds they listen to are closed. | ||
1075 | */ | ||
1076 | EAPI void * | 1048 | EAPI void * |
1077 | ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler) | 1049 | ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler) |
1078 | { | 1050 | { |
@@ -1116,24 +1088,6 @@ ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler __UNUSED__) | |||
1116 | 1088 | ||
1117 | #endif | 1089 | #endif |
1118 | 1090 | ||
1119 | /** | ||
1120 | * @brief Set the prepare callback with data for a given #Ecore_Fd_Handler | ||
1121 | * | ||
1122 | * @param fd_handler The fd handler | ||
1123 | * @param func The prep function | ||
1124 | * @param data The data to pass to the prep function | ||
1125 | * | ||
1126 | * This function will be called prior to any fd handler's callback function | ||
1127 | * (even the other fd handlers), before entering the main loop select function. | ||
1128 | * | ||
1129 | * @note Once a prepare callback is set for a fd handler, it cannot be changed. | ||
1130 | * You need to delete the fd handler and create a new one, to set another | ||
1131 | * callback. | ||
1132 | * @note You probably don't need this function. It is only necessary for very | ||
1133 | * uncommon cases that need special behavior. | ||
1134 | * | ||
1135 | * @ingroup Ecore_FD_Handler_Group | ||
1136 | */ | ||
1137 | EAPI void | 1091 | EAPI void |
1138 | ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, | 1092 | ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, |
1139 | Ecore_Fd_Prep_Cb func, | 1093 | Ecore_Fd_Prep_Cb func, |
@@ -1157,12 +1111,6 @@ unlock: | |||
1157 | _ecore_unlock(); | 1111 | _ecore_unlock(); |
1158 | } | 1112 | } |
1159 | 1113 | ||
1160 | /** | ||
1161 | * Retrieves the file descriptor that the given handler is handling. | ||
1162 | * @param fd_handler The given FD handler. | ||
1163 | * @return The file descriptor the handler is watching. | ||
1164 | * @ingroup Ecore_FD_Handler_Group | ||
1165 | */ | ||
1166 | EAPI int | 1114 | EAPI int |
1167 | ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler) | 1115 | ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler) |
1168 | { | 1116 | { |
@@ -1182,15 +1130,6 @@ unlock: | |||
1182 | return fd; | 1130 | return fd; |
1183 | } | 1131 | } |
1184 | 1132 | ||
1185 | /** | ||
1186 | * Return if read, write or error, or a combination thereof, is active on the | ||
1187 | * file descriptor of the given FD handler. | ||
1188 | * @param fd_handler The given FD handler. | ||
1189 | * @param flags The flags, @c ECORE_FD_READ, @c ECORE_FD_WRITE or | ||
1190 | * @c ECORE_FD_ERROR to query. | ||
1191 | * @return #EINA_TRUE if any of the given flags are active. #EINA_FALSE otherwise. | ||
1192 | * @ingroup Ecore_FD_Handler_Group | ||
1193 | */ | ||
1194 | EAPI Eina_Bool | 1133 | EAPI Eina_Bool |
1195 | ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, | 1134 | ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, |
1196 | Ecore_Fd_Handler_Flags flags) | 1135 | Ecore_Fd_Handler_Flags flags) |
@@ -1213,12 +1152,6 @@ unlock: | |||
1213 | return ret; | 1152 | return ret; |
1214 | } | 1153 | } |
1215 | 1154 | ||
1216 | /** | ||
1217 | * Set what active streams the given FD handler should be monitoring. | ||
1218 | * @param fd_handler The given FD handler. | ||
1219 | * @param flags The flags to be watching. | ||
1220 | * @ingroup Ecore_FD_Handler_Group | ||
1221 | */ | ||
1222 | EAPI void | 1155 | EAPI void |
1223 | ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, | 1156 | ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, |
1224 | Ecore_Fd_Handler_Flags flags) | 1157 | Ecore_Fd_Handler_Flags flags) |
@@ -1742,14 +1675,14 @@ _ecore_main_loop_iterate_internal(int once_only) | |||
1742 | if (_ecore_event_exist()) | 1675 | if (_ecore_event_exist()) |
1743 | { | 1676 | { |
1744 | /* but first conceptually enter an idle state */ | 1677 | /* but first conceptually enter an idle state */ |
1745 | _ecore_idle_enterer_call(); | 1678 | _ecore_idle_enterer_call(); |
1746 | _ecore_throttle(); | 1679 | _ecore_throttle(); |
1747 | /* now quickly poll to see which input fd's are active */ | 1680 | /* now quickly poll to see which input fd's are active */ |
1748 | _ecore_main_select(0.0); | 1681 | _ecore_main_select(0.0); |
1749 | /* allow newly queued timers to expire from now on */ | 1682 | /* allow newly queued timers to expire from now on */ |
1750 | _ecore_timer_enable_new(); | 1683 | _ecore_timer_enable_new(); |
1751 | /* go straight to processing the events we had queued */ | 1684 | /* go straight to processing the events we had queued */ |
1752 | goto process_all; | 1685 | goto process_all; |
1753 | } | 1686 | } |
1754 | 1687 | ||
1755 | if (once_only) | 1688 | if (once_only) |
@@ -1758,17 +1691,17 @@ _ecore_main_loop_iterate_internal(int once_only) | |||
1758 | * if we got any events or signals, allow new timers to process. | 1691 | * if we got any events or signals, allow new timers to process. |
1759 | * use bitwise or to force both conditions to be tested and | 1692 | * use bitwise or to force both conditions to be tested and |
1760 | * merged together */ | 1693 | * merged together */ |
1761 | if (_ecore_main_select(0.0) | _ecore_signal_count_get()) | 1694 | if (_ecore_main_select(0.0) | _ecore_signal_count_get()) |
1762 | { | 1695 | { |
1763 | _ecore_timer_enable_new(); | 1696 | _ecore_timer_enable_new(); |
1764 | goto process_all; | 1697 | goto process_all; |
1765 | } | 1698 | } |
1766 | } | 1699 | } |
1767 | else | 1700 | else |
1768 | { | 1701 | { |
1769 | /* call idle enterers ... */ | 1702 | /* call idle enterers ... */ |
1770 | _ecore_idle_enterer_call(); | 1703 | _ecore_idle_enterer_call(); |
1771 | _ecore_throttle(); | 1704 | _ecore_throttle(); |
1772 | } | 1705 | } |
1773 | 1706 | ||
1774 | /* if these calls caused any buffered events to appear - deal with them */ | 1707 | /* if these calls caused any buffered events to appear - deal with them */ |
@@ -1787,10 +1720,10 @@ _ecore_main_loop_iterate_internal(int once_only) | |||
1787 | if (once_only) | 1720 | if (once_only) |
1788 | { | 1721 | { |
1789 | /* in once_only mode enter idle here instead and then return */ | 1722 | /* in once_only mode enter idle here instead and then return */ |
1790 | _ecore_idle_enterer_call(); | 1723 | _ecore_idle_enterer_call(); |
1791 | _ecore_throttle(); | 1724 | _ecore_throttle(); |
1792 | _ecore_timer_enable_new(); | 1725 | _ecore_timer_enable_new(); |
1793 | goto done; | 1726 | goto done; |
1794 | } | 1727 | } |
1795 | 1728 | ||
1796 | _ecore_fps_marker_1(); | 1729 | _ecore_fps_marker_1(); |
@@ -1808,23 +1741,23 @@ start_loop: /***************************************************************/ | |||
1808 | if (!_ecore_event_exist()) | 1741 | if (!_ecore_event_exist()) |
1809 | { | 1742 | { |
1810 | /* init flags */ | 1743 | /* init flags */ |
1811 | next_time = _ecore_timer_next_get(); | 1744 | next_time = _ecore_timer_next_get(); |
1812 | /* no idlers */ | 1745 | /* no idlers */ |
1813 | if (!_ecore_idler_exist()) | 1746 | if (!_ecore_idler_exist()) |
1814 | { | 1747 | { |
1815 | /* sleep until timeout or forever (-1.0) waiting for on fds */ | 1748 | /* sleep until timeout or forever (-1.0) waiting for on fds */ |
1816 | _ecore_main_select(next_time); | 1749 | _ecore_main_select(next_time); |
1817 | } | 1750 | } |
1818 | else | 1751 | else |
1819 | { | 1752 | { |
1820 | int action = LOOP_CONTINUE; | 1753 | int action = LOOP_CONTINUE; |
1821 | 1754 | ||
1822 | /* no timers - spin */ | 1755 | /* no timers - spin */ |
1823 | if (next_time < 0) action = _ecore_main_loop_spin_no_timers(); | 1756 | if (next_time < 0) action = _ecore_main_loop_spin_no_timers(); |
1824 | /* timers - spin */ | 1757 | /* timers - spin */ |
1825 | else action = _ecore_main_loop_spin_timers(); | 1758 | else action = _ecore_main_loop_spin_timers(); |
1826 | if (action == SPIN_RESTART) goto start_loop; | 1759 | if (action == SPIN_RESTART) goto start_loop; |
1827 | } | 1760 | } |
1828 | } | 1761 | } |
1829 | _ecore_fps_marker_2(); | 1762 | _ecore_fps_marker_2(); |
1830 | 1763 | ||
@@ -1847,8 +1780,8 @@ process_all: /***********************************************************/ | |||
1847 | if (once_only) | 1780 | if (once_only) |
1848 | { | 1781 | { |
1849 | /* if in once_only mode handle idle exiting */ | 1782 | /* if in once_only mode handle idle exiting */ |
1850 | _ecore_idle_enterer_call(); | 1783 | _ecore_idle_enterer_call(); |
1851 | _ecore_throttle(); | 1784 | _ecore_throttle(); |
1852 | } | 1785 | } |
1853 | 1786 | ||
1854 | done: /*******************************************************************/ | 1787 | done: /*******************************************************************/ |