3 #include <winpr/thread.h>
4 #include <winpr/collections.h>
6 DEFINE_EVENT_BEGIN(MouseMotion)
9 DEFINE_EVENT_END(MouseMotion)
11 DEFINE_EVENT_BEGIN(MouseButton)
16 DEFINE_EVENT_END(MouseButton)
18 static void MouseMotionEventHandler(
void* context,
const MouseMotionEventArgs* e)
20 printf(
"MouseMotionEvent: x: %d y: %d\n", e->x, e->y);
23 static void MouseButtonEventHandler(
void* context,
const MouseButtonEventArgs* e)
25 printf(
"MouseButtonEvent: x: %d y: %d flags: %d button: %d\n", e->x, e->y, e->flags, e->button);
28 static wEventType Node_Events[] = { DEFINE_EVENT_ENTRY(MouseMotion),
29 DEFINE_EVENT_ENTRY(MouseButton) };
31 #define NODE_EVENT_COUNT (sizeof(Node_Events) / sizeof(wEventType))
33 int TestPubSub(
int argc,
char* argv[])
40 node = PubSub_New(TRUE);
44 PubSub_AddEventTypes(node, Node_Events, NODE_EVENT_COUNT);
46 PubSub_SubscribeMouseMotion(node, MouseMotionEventHandler);
47 PubSub_SubscribeMouseButton(node, MouseButtonEventHandler);
51 MouseMotionEventArgs e;
56 PubSub_OnMouseMotion(node, NULL, &e);
60 MouseButtonEventArgs e;
67 PubSub_OnMouseButton(node, NULL, &e);