Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event: add dom_event internal_type field #9

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions include/dom/events/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,15 @@ dom_exception _dom_event_set_is_trusted(dom_event *evt, bool trusted);
#define dom_event_set_is_trusted(e,t) _dom_event_set_is_trusted( \
(dom_event *) (e), (bool) (t))

dom_exception _dom_event_get_internal_type(dom_event *evt, unsigned int *result);
#define dom_event_get_internal_type(e,t) _dom_event_get_internal_type( \
(dom_event *) (e), (unsigned int *) (r))

dom_exception _dom_event_set_internal_type(dom_event *evt, unsigned int type);
#define dom_event_set_internal_type(e,t) _dom_event_set_internal_type( \
(dom_event *) (e), (unsigned int) (t))

dom_exception _dom_event_set_target(dom_event *evt, dom_event_target *et);
#define dom_event_set_target(e,t) _dom_event_set_target( \
(dom_event *) (e), (dom_event_target *) (t))
#endif
44 changes: 44 additions & 0 deletions src/events/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ dom_exception _dom_event_initialise(dom_event *evt)
evt->is_initialised = false;
evt->is_trusted = true;

evt->internal_type = 0;

return DOM_NO_ERR;
}

Expand Down Expand Up @@ -396,3 +398,45 @@ dom_exception _dom_event_set_is_trusted(dom_event *evt, bool trusted)

return DOM_NO_ERR;
}

/**
* Get the internal type of this event
*
* \param evt The event object
* \param result The returned value
* \return DOM_NO_ERR.
*/
dom_exception _dom_event_get_internal_type(dom_event *evt, unsigned int *result)
{
*result = evt->internal_type;

return DOM_NO_ERR;
}

/**
* Set the internal type of this event
*
* \param evt The event object
* \param type The internal type
* \return DOM_NO_ERR.
*/
dom_exception _dom_event_set_internal_type(dom_event *evt, unsigned int type)
{
evt->internal_type = type;

return DOM_NO_ERR;
}

/**
* Set the target
*
* \param evt The event object
* \param et The event target
* \return DOM_NO_ERR.
*/
dom_exception _dom_event_set_target(dom_event *evt, dom_event_target *et)
{
evt->target = et;

return DOM_NO_ERR;
}
2 changes: 2 additions & 0 deletions src/events/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct dom_event {
bool in_dispatch; /**< Whether this event is in dispatch */
bool is_initialised; /**< Whether this event is initialised */
bool is_trusted; /**< Whether this event is trusted */

unsigned int internal_type; /**< always 0 for a pure libdom event. */
};

/* Destructor */
Expand Down
Loading