backend: Bridge platform-dependent event data creation to device managers

Device managers can now implement the ClutterEventExtender interface
that allows them to set their own data to events, make the backend call
those implementations if the device manager implements the interface.

https://bugzilla.gnome.org/show_bug.cgi?id=758238
This commit is contained in:
Carlos Garnacho 2015-11-17 17:37:45 +01:00
parent 5ea70bd102
commit 4115f215ac

View File

@ -53,6 +53,7 @@
#include "clutter-stage-private.h" #include "clutter-stage-private.h"
#include "clutter-stage-window.h" #include "clutter-stage-window.h"
#include "clutter-version.h" #include "clutter-version.h"
#include "clutter-device-manager-private.h"
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS #define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include "deprecated/clutter-backend.h" #include "deprecated/clutter-backend.h"
@ -998,10 +999,17 @@ _clutter_backend_copy_event_data (ClutterBackend *backend,
const ClutterEvent *src, const ClutterEvent *src,
ClutterEvent *dest) ClutterEvent *dest)
{ {
ClutterEventExtenderInterface *iface;
ClutterBackendClass *klass; ClutterBackendClass *klass;
klass = CLUTTER_BACKEND_GET_CLASS (backend); klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (klass->copy_event_data != NULL) if (CLUTTER_IS_EVENT_EXTENDER (backend->device_manager))
{
iface = CLUTTER_EVENT_EXTENDER_GET_IFACE (backend->device_manager);
iface->copy_event_data (CLUTTER_EVENT_EXTENDER (backend->device_manager),
src, dest);
}
else if (klass->copy_event_data != NULL)
klass->copy_event_data (backend, src, dest); klass->copy_event_data (backend, src, dest);
} }
@ -1009,10 +1017,18 @@ void
_clutter_backend_free_event_data (ClutterBackend *backend, _clutter_backend_free_event_data (ClutterBackend *backend,
ClutterEvent *event) ClutterEvent *event)
{ {
ClutterEventExtenderInterface *iface;
ClutterBackendClass *klass; ClutterBackendClass *klass;
klass = CLUTTER_BACKEND_GET_CLASS (backend); klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (klass->free_event_data != NULL)
if (CLUTTER_IS_EVENT_EXTENDER (backend->device_manager))
{
iface = CLUTTER_EVENT_EXTENDER_GET_IFACE (backend->device_manager);
iface->free_event_data (CLUTTER_EVENT_EXTENDER (backend->device_manager),
event);
}
else if (klass->free_event_data != NULL)
klass->free_event_data (backend, event); klass->free_event_data (backend, event);
} }