diff options
Diffstat (limited to 'src/periodic.c')
-rw-r--r-- | src/periodic.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/periodic.c b/src/periodic.c index 29c26de9..9e9dfdba 100644 --- a/src/periodic.c +++ b/src/periodic.c | |||
@@ -21,10 +21,12 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |||
21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | 21 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ |
22 | 22 | ||
23 | #include "periodic.h" | 23 | #include "periodic.h" |
24 | #include "ui/widget.h" | ||
24 | #include "app.h" | 25 | #include "app.h" |
25 | 26 | ||
26 | #include <the_Foundation/string.h> | 27 | #include <the_Foundation/string.h> |
27 | #include <the_Foundation/thread.h> | 28 | #include <the_Foundation/thread.h> |
29 | #include <SDL_events.h> | ||
28 | #include <SDL_timer.h> | 30 | #include <SDL_timer.h> |
29 | 31 | ||
30 | iDeclareType(PeriodicCommand) | 32 | iDeclareType(PeriodicCommand) |
@@ -54,7 +56,7 @@ iDefineTypeConstructionArgs(PeriodicCommand, (iAny *ctx, const char *cmd), ctx, | |||
54 | 56 | ||
55 | static const uint32_t postingInterval_Periodic_ = 500; | 57 | static const uint32_t postingInterval_Periodic_ = 500; |
56 | 58 | ||
57 | iBool postCommands_Periodic(iPeriodic *d) { | 59 | iBool dispatchCommands_Periodic(iPeriodic *d) { |
58 | const uint32_t now = SDL_GetTicks(); | 60 | const uint32_t now = SDL_GetTicks(); |
59 | if (now - d->lastPostTime < postingInterval_Periodic_) { | 61 | if (now - d->lastPostTime < postingInterval_Periodic_) { |
60 | return iFalse; | 62 | return iFalse; |
@@ -63,7 +65,14 @@ iBool postCommands_Periodic(iPeriodic *d) { | |||
63 | iBool wasPosted = iFalse; | 65 | iBool wasPosted = iFalse; |
64 | lock_Mutex(d->mutex); | 66 | lock_Mutex(d->mutex); |
65 | iConstForEach(Array, i, &d->commands.values) { | 67 | iConstForEach(Array, i, &d->commands.values) { |
66 | postCommandString_App(&((const iPeriodicCommand *) i.value)->command); | 68 | const iPeriodicCommand *pc = i.value; |
69 | const SDL_UserEvent ev = { | ||
70 | .type = SDL_USEREVENT, | ||
71 | .code = command_UserEventCode, | ||
72 | .data1 = (void *) cstr_String(&pc->command) | ||
73 | }; | ||
74 | iAssert(isInstance_Object(pc->context, &Class_Widget)); | ||
75 | dispatchEvent_Widget(pc->context, (const SDL_Event *) &ev); | ||
67 | wasPosted = iTrue; | 76 | wasPosted = iTrue; |
68 | } | 77 | } |
69 | unlock_Mutex(d->mutex); | 78 | unlock_Mutex(d->mutex); |