- l = read(b->fd, &ev, sizeof(ev));
- if (l < 0)
- return errno != EAGAIN ? -errno : 0;
- if ((size_t) l < sizeof(ev))
- return -EIO;
-
- /* If there's a graphical session on the seat this device
- * belongs to we ignore events, it is job of the graphical
- * session to handle the event. */
- if (has_graphical_session(b->manager, b->seat))
- return 0;
-
- if (ev.type == EV_KEY && ev.value > 0) {
-
- switch (ev.code) {
-
- case KEY_POWER:
- case KEY_POWER2:
- log_info("Power key pressed.");
- return button_power_off(b, b->manager->handle_power_key);
-
- case KEY_SLEEP:
- case KEY_SUSPEND:
- log_info("Sleep key pressed.");
- return button_suspend(b, b->manager->handle_sleep_key);