mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-25 22:10:06 +01:00
Change libevdev_grab to take an enum
Enum values fo 3 and 4 to avoid callers using true/false values for grabbing and ungrabbing. If the evdev mute ioctl is merged, we can extend this without having to worry about breaking callers. [1] http://lwn.net/Articles/476830/ Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
cfcfa4c159
commit
27528b9668
2 changed files with 14 additions and 2 deletions
|
|
@ -847,9 +847,15 @@ libevdev_grab(struct libevdev *dev, int grab)
|
|||
{
|
||||
int rc = 0;
|
||||
|
||||
if (grab && !dev->grabbed)
|
||||
if (grab != LIBEVDEV_GRAB && grab != LIBEVDEV_UNGRAB)
|
||||
return -EINVAL;
|
||||
|
||||
if (grab == dev->grabbed)
|
||||
return 0;
|
||||
|
||||
if (grab == LIBEVDEV_GRAB)
|
||||
rc = ioctl(dev->fd, EVIOCGRAB, (void *)1);
|
||||
else if (!grab && dev->grabbed)
|
||||
else if (grab == LIBEVDEV_UNGRAB)
|
||||
rc = ioctl(dev->fd, EVIOCGRAB, (void *)0);
|
||||
|
||||
if (rc == 0)
|
||||
|
|
|
|||
|
|
@ -83,6 +83,12 @@ typedef void (*libevdev_log_func_t)(const char *format, va_list args);
|
|||
*/
|
||||
void libevdev_set_log_handler(struct libevdev *dev, libevdev_log_func_t logfunc);
|
||||
|
||||
|
||||
enum EvdevGrabModes {
|
||||
LIBEVDEV_GRAB = 3,
|
||||
LIBEVDEV_UNGRAB = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Grab or ungrab the device through a kernel EVIOCGRAB. This prevents other
|
||||
* clients (including kernel-internal ones such as rfkill) from receiving
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue