mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2025-12-30 14:10:08 +01:00
ei: error out if we're in the wrong device state for emulating
This commit is contained in:
parent
d698ed2f75
commit
83b4902d9f
1 changed files with 14 additions and 4 deletions
|
|
@ -277,6 +277,8 @@ handle_msg_paused(struct ei_device *device)
|
|||
static struct brei_result *
|
||||
handle_msg_start_emulating(struct ei_device *device, uint32_t sequence)
|
||||
{
|
||||
struct brei_result *result = NULL;
|
||||
|
||||
DISCONNECT_IF_SENDER_CONTEXT(device);
|
||||
|
||||
switch (device->state) {
|
||||
|
|
@ -284,22 +286,27 @@ handle_msg_start_emulating(struct ei_device *device, uint32_t sequence)
|
|||
case EI_DEVICE_STATE_NEW:
|
||||
case EI_DEVICE_STATE_PAUSED:
|
||||
case EI_DEVICE_STATE_EMULATING:
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_SERVER:
|
||||
result = brei_result_new(EI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid device state %ud for a start_emulating event", device->state);
|
||||
break;
|
||||
case EI_DEVICE_STATE_RESUMED:
|
||||
ei_queue_device_start_emulating_event(device, sequence);
|
||||
device->state = EI_DEVICE_STATE_EMULATING;
|
||||
break;
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_CLIENT:
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_SERVER:
|
||||
/* race condition, that's fine */
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct brei_result *
|
||||
handle_msg_stop_emulating(struct ei_device *device)
|
||||
{
|
||||
struct brei_result *result = NULL;
|
||||
|
||||
DISCONNECT_IF_SENDER_CONTEXT(device);
|
||||
|
||||
switch (device->state) {
|
||||
|
|
@ -307,17 +314,20 @@ handle_msg_stop_emulating(struct ei_device *device)
|
|||
case EI_DEVICE_STATE_NEW:
|
||||
case EI_DEVICE_STATE_PAUSED:
|
||||
case EI_DEVICE_STATE_RESUMED:
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_SERVER:
|
||||
result = brei_result_new(EI_CONNECTION_DISCONNECT_REASON_PROTOCOL,
|
||||
"Invalid device state %ud for a stop_emulating event", device->state);
|
||||
break;
|
||||
case EI_DEVICE_STATE_EMULATING:
|
||||
ei_queue_device_stop_emulating_event(device);
|
||||
device->state = EI_DEVICE_STATE_RESUMED;
|
||||
break;
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_CLIENT:
|
||||
case EI_DEVICE_STATE_REMOVED_FROM_SERVER:
|
||||
/* race condition, that's fine */
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
static struct brei_result *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue