diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c index 2fa3d39ce..a2adc0d0f 100644 --- a/clutter/clutter/clutter-main.c +++ b/clutter/clutter/clutter-main.c @@ -1954,6 +1954,17 @@ _clutter_process_event_details (ClutterActor *stage, case CLUTTER_CLIENT_MESSAGE: break; + case CLUTTER_DEVICE_ADDED: + case CLUTTER_DEVICE_REMOVED: + if (!_clutter_event_process_filters (event)) + { + ClutterSeat *seat; + + seat = clutter_backend_get_default_seat (context->backend); + clutter_seat_handle_device_event (seat, event); + } + break; + case CLUTTER_EVENT_LAST: break; } diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c index 73672bd36..ba9f2f55a 100644 --- a/clutter/clutter/clutter-seat.c +++ b/clutter/clutter/clutter-seat.c @@ -674,6 +674,46 @@ clutter_seat_compress_motion (ClutterSeat *seat, seat_class->compress_motion (seat, event, to_discard); } +gboolean +clutter_seat_handle_device_event (ClutterSeat *seat, + ClutterEvent *event) +{ + ClutterSeatClass *seat_class; + ClutterInputDevice *device; + + g_return_val_if_fail (CLUTTER_IS_SEAT (seat), FALSE); + g_return_val_if_fail (event, FALSE); + + g_assert (event->type == CLUTTER_DEVICE_ADDED || + event->type == CLUTTER_DEVICE_REMOVED); + + seat_class = CLUTTER_SEAT_GET_CLASS (seat); + + if (seat_class->handle_device_event) + { + if (!seat_class->handle_device_event (seat, event)) + return FALSE; + } + + device = clutter_event_get_source_device (event); + g_assert_true (CLUTTER_IS_INPUT_DEVICE (device)); + + switch (event->type) + { + case CLUTTER_DEVICE_ADDED: + g_signal_emit (seat, signals[DEVICE_ADDED], 0, device); + break; + case CLUTTER_DEVICE_REMOVED: + g_signal_emit (seat, signals[DEVICE_REMOVED], 0, device); + g_object_run_dispose (G_OBJECT (device)); + break; + default: + break; + } + + return TRUE; +} + void clutter_seat_warp_pointer (ClutterSeat *seat, int x, diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h index 7818647af..aa88d7300 100644 --- a/clutter/clutter/clutter-seat.h +++ b/clutter/clutter/clutter-seat.h @@ -106,6 +106,9 @@ struct _ClutterSeatClass ClutterEvent *event, const ClutterEvent *to_discard); + gboolean (* handle_device_event) (ClutterSeat *seat, + ClutterEvent *event); + void (* warp_pointer) (ClutterSeat *seat, int x, int y); @@ -181,6 +184,9 @@ void clutter_seat_compress_motion (ClutterSeat *seat, ClutterEvent *event, const ClutterEvent *to_discard); +gboolean clutter_seat_handle_device_event (ClutterSeat *seat, + ClutterEvent *event); + CLUTTER_EXPORT void clutter_seat_warp_pointer (ClutterSeat *seat, int x,