clutter-event: Add device added/removed events

Add clutter device added and removed events to allow processing of them as
it happens in the backends, queuing them and performing actions in order.

This allows not to loose any event that is performed just before removing or
disabling a device, and still process the events in order in the event
queue.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1371
This commit is contained in:
Marco Trevisan (Treviño) 2020-07-17 16:31:10 +02:00 committed by Carlos Garnacho
parent fe1d297680
commit cd00e69ce3
4 changed files with 43 additions and 0 deletions

View File

@ -12715,6 +12715,9 @@ clutter_actor_event (ClutterActor *actor,
signal_num = -1;
detail = quark_stage;
break;
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
break;
case CLUTTER_EVENT_LAST: /* Just keep compiler warnings quiet */
break;
}

View File

@ -906,6 +906,8 @@ typedef enum /*< prefix=CLUTTER >*/
CLUTTER_PAD_BUTTON_RELEASE,
CLUTTER_PAD_STRIP,
CLUTTER_PAD_RING,
CLUTTER_DEVICE_ADDED,
CLUTTER_DEVICE_REMOVED,
CLUTTER_EVENT_LAST /* helper */
} ClutterEventType;

View File

@ -414,6 +414,8 @@ clutter_event_get_position (const ClutterEvent *event,
case CLUTTER_PAD_BUTTON_RELEASE:
case CLUTTER_PAD_STRIP:
case CLUTTER_PAD_RING:
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
graphene_point_init (position, 0.f, 0.f);
break;
@ -487,6 +489,8 @@ clutter_event_set_coords (ClutterEvent *event,
case CLUTTER_PAD_BUTTON_RELEASE:
case CLUTTER_PAD_STRIP:
case CLUTTER_PAD_RING:
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
break;
case CLUTTER_ENTER:
@ -1158,6 +1162,11 @@ clutter_event_set_device (ClutterEvent *event,
case CLUTTER_PAD_RING:
event->pad_ring.device = device;
break;
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
g_set_object (&event->device.device, device);
break;
}
}
@ -1254,6 +1263,11 @@ clutter_event_get_device (const ClutterEvent *event)
case CLUTTER_PAD_RING:
device = event->pad_ring.device;
break;
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
device = event->device.device;
break;
}
return device;
@ -1407,6 +1421,11 @@ clutter_event_copy (const ClutterEvent *event)
sizeof (gdouble) * n_axes);
break;
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
g_set_object (&new_event->device.device, event->device.device);
break;
default:
break;
}
@ -1461,6 +1480,10 @@ clutter_event_free (ClutterEvent *event)
case CLUTTER_TOUCH_CANCEL:
g_free (event->touch.axes);
break;
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
g_clear_object (&event->device.device);
break;
default:
break;
@ -1728,6 +1751,8 @@ clutter_event_get_axes (const ClutterEvent *event,
case CLUTTER_EVENT_LAST:
case CLUTTER_PROXIMITY_IN:
case CLUTTER_PROXIMITY_OUT:
case CLUTTER_DEVICE_ADDED:
case CLUTTER_DEVICE_REMOVED:
break;
case CLUTTER_SCROLL:

View File

@ -121,6 +121,7 @@ typedef struct _ClutterProximityEvent ClutterProximityEvent;
typedef struct _ClutterPadButtonEvent ClutterPadButtonEvent;
typedef struct _ClutterPadStripEvent ClutterPadStripEvent;
typedef struct _ClutterPadRingEvent ClutterPadRingEvent;
typedef struct _ClutterDeviceEvent ClutterDeviceEvent;
/**
* ClutterAnyEvent:
@ -544,6 +545,17 @@ struct _ClutterPadRingEvent
guint32 mode;
};
struct _ClutterDeviceEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;
ClutterInputDevice *device;
};
/**
* ClutterEvent:
*
@ -570,6 +582,7 @@ union _ClutterEvent
ClutterPadButtonEvent pad_button;
ClutterPadStripEvent pad_strip;
ClutterPadRingEvent pad_ring;
ClutterDeviceEvent device;
};
/**