mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
evdev: Allow to retrieve the input.h event code from ClutterEvents
This is now stored as platform data in the ClutterEvent, so can be retrieved with the clutter_evdev_event_get_event_code() call that's been added to the evdev backend. https://bugzilla.gnome.org/show_bug.cgi?id=758238
This commit is contained in:
parent
dfc749e576
commit
f1ad702309
@ -598,6 +598,7 @@ endif # SUPPORT_TSLIB
|
||||
evdev_c_priv = \
|
||||
evdev/clutter-device-manager-evdev.c \
|
||||
evdev/clutter-input-device-evdev.c \
|
||||
evdev/clutter-event-evdev.c \
|
||||
$(NULL)
|
||||
evdev_h_priv = \
|
||||
evdev/clutter-device-manager-evdev.h \
|
||||
|
@ -188,12 +188,22 @@ clutter_device_manager_evdev_copy_event_data (ClutterEventExtender *event_extend
|
||||
const ClutterEvent *src,
|
||||
ClutterEvent *dest)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev;
|
||||
|
||||
event_evdev = _clutter_event_get_platform_data (src);
|
||||
if (event_evdev != NULL)
|
||||
_clutter_event_set_platform_data (dest, _clutter_event_evdev_copy (event_evdev));
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_device_manager_evdev_free_event_data (ClutterEventExtender *event_extender,
|
||||
ClutterEvent *event)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev;
|
||||
|
||||
event_evdev = _clutter_event_get_platform_data (event);
|
||||
if (event_evdev != NULL)
|
||||
_clutter_event_evdev_free (event_evdev);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -131,6 +131,9 @@ void clutter_evdev_warp_pointer (ClutterInputDevice *pointer_device,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_26
|
||||
guint32 clutter_evdev_event_get_event_code (const ClutterEvent *event);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_EVDEV_H__ */
|
||||
|
101
clutter/evdev/clutter-event-evdev.c
Normal file
101
clutter/evdev/clutter-event-evdev.c
Normal file
@ -0,0 +1,101 @@
|
||||
/* Clutter.
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2015 Red Hat
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authored by:
|
||||
* Carlos Garnacho <carlosg@gnome.org>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "clutter/clutter-device-manager-private.h"
|
||||
#include "clutter/clutter-event-private.h"
|
||||
#include "clutter-input-device-evdev.h"
|
||||
#include "clutter-evdev.h"
|
||||
|
||||
typedef struct _ClutterEventEvdev ClutterEventEvdev;
|
||||
|
||||
struct _ClutterEventEvdev
|
||||
{
|
||||
guint32 evcode;
|
||||
};
|
||||
|
||||
static ClutterEventEvdev *
|
||||
_clutter_event_evdev_new (void)
|
||||
{
|
||||
return g_slice_new0 (ClutterEventEvdev);
|
||||
}
|
||||
|
||||
ClutterEventEvdev *
|
||||
_clutter_event_evdev_copy (ClutterEventEvdev *event_evdev)
|
||||
{
|
||||
if (event_evdev != NULL)
|
||||
return g_slice_dup (ClutterEventEvdev, event_evdev);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_event_evdev_free (ClutterEventEvdev *event_evdev)
|
||||
{
|
||||
if (event_evdev != NULL)
|
||||
g_slice_free (ClutterEventEvdev, event_evdev);
|
||||
}
|
||||
|
||||
static ClutterEventEvdev *
|
||||
clutter_evdev_event_ensure_platform_data (ClutterEvent *event)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
|
||||
|
||||
if (!event_evdev)
|
||||
{
|
||||
event_evdev = _clutter_event_evdev_new ();
|
||||
_clutter_event_set_platform_data (event, event_evdev);
|
||||
}
|
||||
|
||||
return event_evdev;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_evdev_event_set_event_code (ClutterEvent *event,
|
||||
guint32 evcode)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev;
|
||||
|
||||
event_evdev = clutter_evdev_event_ensure_platform_data (event);
|
||||
event_evdev->evcode = evcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_evdev_event_get_event_code:
|
||||
* @event: a #ClutterEvent
|
||||
*
|
||||
* Returns the event code of the original event. See linux/input.h for more
|
||||
* information.
|
||||
*
|
||||
* Returns: The event code.
|
||||
**/
|
||||
guint32
|
||||
clutter_evdev_event_get_event_code (const ClutterEvent *event)
|
||||
{
|
||||
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
|
||||
|
||||
if (event_evdev)
|
||||
return event_evdev->evcode;
|
||||
|
||||
return 0;
|
||||
}
|
@ -57,6 +57,7 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ClutterInputDeviceEvdev ClutterInputDeviceEvdev;
|
||||
typedef struct _ClutterSeatEvdev ClutterSeatEvdev;
|
||||
typedef struct _ClutterEventEvdev ClutterEventEvdev;
|
||||
|
||||
struct _ClutterInputDeviceEvdev
|
||||
{
|
||||
@ -83,6 +84,13 @@ void _clutter_input_device_evdev_update_leds (ClutterIn
|
||||
|
||||
ClutterInputDeviceType _clutter_input_device_evdev_determine_type (struct libinput_device *libinput_device);
|
||||
|
||||
|
||||
ClutterEventEvdev * _clutter_event_evdev_copy (ClutterEventEvdev *event_evdev);
|
||||
void _clutter_event_evdev_free (ClutterEventEvdev *event_evdev);
|
||||
|
||||
void _clutter_evdev_event_set_event_code (ClutterEvent *event,
|
||||
guint32 evcode);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_INPUT_DEVICE_EVDEV_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user