evdev: fixes evdev build issues + don't ref default stage
This updates the evdev input backend code to compile and also updates the code to not refer to the default stage and instead check for a stage to be associated with the input device. If no stage is currently associated with a device generating events then the events are dropped on the floor. Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
parent
86f2aed570
commit
602a89afa8
@ -46,6 +46,7 @@
|
|||||||
#include "clutter-private.h"
|
#include "clutter-private.h"
|
||||||
#include "clutter-stage-manager.h"
|
#include "clutter-stage-manager.h"
|
||||||
#include "clutter-xkb-utils.h"
|
#include "clutter-xkb-utils.h"
|
||||||
|
#include "clutter-backend-private.h"
|
||||||
|
|
||||||
#include "clutter-device-manager-evdev.h"
|
#include "clutter-device-manager-evdev.h"
|
||||||
|
|
||||||
@ -152,16 +153,21 @@ notify_key (ClutterEventSource *source,
|
|||||||
guint32 key,
|
guint32 key,
|
||||||
guint32 state)
|
guint32 state)
|
||||||
{
|
{
|
||||||
|
ClutterInputDevice *input_device = (ClutterInputDevice *) source->device;
|
||||||
|
ClutterStage *stage;
|
||||||
ClutterEvent *event = NULL;
|
ClutterEvent *event = NULL;
|
||||||
ClutterActor *stage;
|
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
/* We can drop the event on the floor if no stage has been
|
||||||
|
* associated with the device yet. */
|
||||||
|
stage = _clutter_input_device_get_stage (input_device);
|
||||||
|
if (!stage)
|
||||||
|
return;
|
||||||
|
|
||||||
/* if we have a mapping for that device, use it to generate the event */
|
/* if we have a mapping for that device, use it to generate the event */
|
||||||
if (source->xkb)
|
if (source->xkb)
|
||||||
event =
|
event =
|
||||||
_clutter_key_event_new_from_evdev ((ClutterInputDevice *) source->device,
|
_clutter_key_event_new_from_evdev (input_device,
|
||||||
CLUTTER_STAGE (stage),
|
stage,
|
||||||
source->xkb,
|
source->xkb,
|
||||||
time_, key, state,
|
time_, key, state,
|
||||||
&source->modifier_state);
|
&source->modifier_state);
|
||||||
@ -176,13 +182,19 @@ notify_motion (ClutterEventSource *source,
|
|||||||
gint x,
|
gint x,
|
||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
|
ClutterInputDevice *input_device = (ClutterInputDevice *) source->device;
|
||||||
gfloat stage_width, stage_height, new_x, new_y;
|
gfloat stage_width, stage_height, new_x, new_y;
|
||||||
ClutterEvent *event;
|
ClutterEvent *event;
|
||||||
ClutterActor *stage;
|
ClutterStage *stage;
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
/* We can drop the event on the floor if no stage has been
|
||||||
stage_width = clutter_actor_get_width (stage);
|
* associated with the device yet. */
|
||||||
stage_height = clutter_actor_get_height (stage);
|
stage = _clutter_input_device_get_stage (input_device);
|
||||||
|
if (!stage)
|
||||||
|
return;
|
||||||
|
|
||||||
|
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||||
|
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||||
|
|
||||||
event = clutter_event_new (CLUTTER_MOTION);
|
event = clutter_event_new (CLUTTER_MOTION);
|
||||||
|
|
||||||
@ -204,8 +216,8 @@ notify_motion (ClutterEventSource *source,
|
|||||||
source->y = new_y;
|
source->y = new_y;
|
||||||
|
|
||||||
event->motion.time = time_;
|
event->motion.time = time_;
|
||||||
event->motion.stage = CLUTTER_STAGE (stage);
|
event->motion.stage = stage;
|
||||||
event->motion.device = (ClutterInputDevice *) source->device;
|
event->motion.device = input_device;
|
||||||
event->motion.modifier_state = source->modifier_state;
|
event->motion.modifier_state = source->modifier_state;
|
||||||
event->motion.x = new_x;
|
event->motion.x = new_x;
|
||||||
event->motion.y = new_y;
|
event->motion.y = new_y;
|
||||||
@ -219,8 +231,9 @@ notify_button (ClutterEventSource *source,
|
|||||||
guint32 button,
|
guint32 button,
|
||||||
guint32 state)
|
guint32 state)
|
||||||
{
|
{
|
||||||
|
ClutterInputDevice *input_device = (ClutterInputDevice *) source->device;
|
||||||
ClutterEvent *event;
|
ClutterEvent *event;
|
||||||
ClutterActor *stage;
|
ClutterStage *stage;
|
||||||
gint button_nr;
|
gint button_nr;
|
||||||
static gint maskmap[8] =
|
static gint maskmap[8] =
|
||||||
{
|
{
|
||||||
@ -228,7 +241,11 @@ notify_button (ClutterEventSource *source,
|
|||||||
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK, 0, 0, 0
|
CLUTTER_BUTTON4_MASK, CLUTTER_BUTTON5_MASK, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
/* We can drop the event on the floor if no stage has been
|
||||||
|
* associated with the device yet. */
|
||||||
|
stage = _clutter_input_device_get_stage (input_device);
|
||||||
|
if (!stage)
|
||||||
|
return;
|
||||||
|
|
||||||
button_nr = button - BTN_LEFT + 1;
|
button_nr = button - BTN_LEFT + 1;
|
||||||
if (G_UNLIKELY (button_nr < 1 || button_nr > 8))
|
if (G_UNLIKELY (button_nr < 1 || button_nr > 8))
|
||||||
@ -265,17 +282,16 @@ clutter_event_dispatch (GSource *g_source,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
ClutterEventSource *source = (ClutterEventSource *) g_source;
|
ClutterEventSource *source = (ClutterEventSource *) g_source;
|
||||||
|
ClutterInputDevice *input_device = (ClutterInputDevice *) source->device;
|
||||||
struct input_event ev[8];
|
struct input_event ev[8];
|
||||||
ClutterEvent *event;
|
ClutterEvent *event;
|
||||||
gint len, i, dx = 0, dy = 0;
|
gint len, i, dx = 0, dy = 0;
|
||||||
uint32_t _time;
|
uint32_t _time;
|
||||||
ClutterStageManager *stage_manager;
|
ClutterStage *stage;
|
||||||
ClutterStage *default_stage;
|
|
||||||
|
|
||||||
clutter_threads_enter ();
|
clutter_threads_enter ();
|
||||||
|
|
||||||
stage_manager = clutter_stage_manager_get_default ();
|
stage = _clutter_input_device_get_stage (input_device);
|
||||||
default_stage = clutter_stage_manager_get_default_stage (stage_manager);
|
|
||||||
|
|
||||||
/* Don't queue more events if we haven't finished handling the previous batch
|
/* Don't queue more events if we haven't finished handling the previous batch
|
||||||
*/
|
*/
|
||||||
@ -310,7 +326,7 @@ clutter_event_dispatch (GSource *g_source,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Drop events if we don't have any stage to forward them to */
|
/* Drop events if we don't have any stage to forward them to */
|
||||||
if (!default_stage)
|
if (!stage)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < len / sizeof (ev[0]); i++)
|
for (i = 0; i < len / sizeof (ev[0]); i++)
|
||||||
@ -462,17 +478,8 @@ clutter_event_source_new (ClutterInputDeviceEvdev *input_device)
|
|||||||
}
|
}
|
||||||
else if (type == CLUTTER_POINTER_DEVICE)
|
else if (type == CLUTTER_POINTER_DEVICE)
|
||||||
{
|
{
|
||||||
/* initialize the pointer position to the center of the default stage */
|
event_source->x = 0;
|
||||||
ClutterActor *stage;
|
event_source->y = 0;
|
||||||
gfloat stage_width, stage_height;
|
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
|
||||||
|
|
||||||
stage_width = clutter_actor_get_width (stage);
|
|
||||||
stage_height = clutter_actor_get_height (stage);
|
|
||||||
|
|
||||||
event_source->x = (gint) stage_width / 2;
|
|
||||||
event_source->y = (gint) stage_height / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and finally configure and attach the GSource */
|
/* and finally configure and attach the GSource */
|
||||||
|
@ -466,6 +466,7 @@ AS_IF([test "x$enable_evdev" = "xyes"],
|
|||||||
AS_IF([test "x$have_evdev" = "xyes"],
|
AS_IF([test "x$have_evdev" = "xyes"],
|
||||||
[
|
[
|
||||||
CLUTTER_INPUT_BACKENDS="$CLUTTER_INPUT_BACKENDS evdev"
|
CLUTTER_INPUT_BACKENDS="$CLUTTER_INPUT_BACKENDS evdev"
|
||||||
|
BACKEND_PC_FILES="$BACKEND_PC_FILES gudev-1.0 xkbcommon"
|
||||||
experimental_input_backend="yes"
|
experimental_input_backend="yes"
|
||||||
AC_DEFINE([HAVE_EVDEV], [1], [Have evdev support for input handling])
|
AC_DEFINE([HAVE_EVDEV], [1], [Have evdev support for input handling])
|
||||||
SUPPORT_EVDEV=1
|
SUPPORT_EVDEV=1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user