logind: make use of EVIOCSMASK input ioctl to mask out events we aren't interested in

This way logind will get woken up only when an actual event took place,
and not for every key press on the system.

The ioctl EVIOCSMASK was added by @dvdhrm already in October 2015, for
the use in logind, among others, hence let's actually make use of it
now.

While we are at it, also fix usage of the EVIOCGSW ioctl, where we
assumed a byte array, even though a unsigned long native endian array is
returned.
This commit is contained in:
Lennart Poettering
2017-06-27 19:25:46 +02:00
parent 180f6dbd2c
commit d5dd44b01c
2 changed files with 82 additions and 3 deletions
+12
View File
@@ -23,6 +23,7 @@
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <linux/audit.h>
#include <linux/capability.h>
#include <linux/if_link.h>
@@ -569,6 +570,17 @@ struct btrfs_ioctl_quota_ctl_args {
# define EVIOCREVOKE _IOW('E', 0x91, int)
#endif
#ifndef EVIOCSMASK
struct input_mask {
uint32_t type;
uint32_t codes_size;
uint64_t codes_ptr;
};
#define EVIOCSMASK _IOW('E', 0x93, struct input_mask)
#endif
#ifndef DRM_IOCTL_SET_MASTER
# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
#endif