-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevents.cc
66 lines (54 loc) · 970 Bytes
/
events.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#define ICI_CORE
#include "fwd.h"
#ifndef NOEVENTS
#include "cfunc.h"
#include "str.h"
#ifdef _WIN32
#include <windows.h>
#endif
namespace ici
{
#ifdef __APPLE__
static int f_eventloop()
{
return null_ret();
}
#endif
#ifdef _WIN32
/*
* Win32 specific event processing.
*/
static int f_eventloop()
{
MSG msg;
exec *x;
x = leave();
for (;;)
{
switch (GetMessage(&msg, nullptr, 0, 0))
{
case 0:
enter(x);
return null_ret();
case -1:
enter(x);
return ici_get_last_win32_error();
}
enter(x);
TranslateMessage(&msg);
clear_error();
if (DispatchMessage(&msg) == ICI_EVENT_ERROR && error)
{
return 1;
}
x = leave();
}
}
#endif /* _WIN32 */
ICI_DEFINE_CFUNCS(event)
{
ICI_DEFINE_CFUNC(eventloop, f_eventloop),
ICI_CFUNCS_END()
};
} // namespace ici
#endif /* NOEVENTS */