static void evdev_middlebutton_handle_timeout(uint64_t now, void *data) { struct evdev_device *device = (struct evdev_device*)data; evdev_middlebutton_handle_event(device, now, MIDDLEBUTTON_EVENT_TIMEOUT); }
static void evdev_middlebutton_handle_timeout(uint64_t now, void *data) { struct evdev_device *device = (struct evdev_device*)data; evdev_middlebutton_handle_event(device, libinput_now(device->base.seat->libinput), MIDDLEBUTTON_EVENT_TIMEOUT); }
bool evdev_middlebutton_filter_button(struct evdev_device *device, uint64_t time, int button, enum libinput_button_state state) { enum evdev_middlebutton_event event; bool is_press = state == LIBINPUT_BUTTON_STATE_PRESSED; int rc; unsigned int bit = (button - BTN_LEFT); uint32_t old_mask = 0; if (!device->middlebutton.enabled) return false; switch (button) { case BTN_LEFT: if (is_press) event = MIDDLEBUTTON_EVENT_L_DOWN; else event = MIDDLEBUTTON_EVENT_L_UP; break; case BTN_RIGHT: if (is_press) event = MIDDLEBUTTON_EVENT_R_DOWN; else event = MIDDLEBUTTON_EVENT_R_UP; break; /* BTN_MIDDLE counts as "other" and resets middle button * emulation */ case BTN_MIDDLE: default: event = MIDDLEBUTTON_EVENT_OTHER; break; } if (button < BTN_LEFT || bit >= sizeof(device->middlebutton.button_mask) * 8) { log_bug_libinput(device->base.seat->libinput, "Button mask too small for %d\n", libevdev_event_code_get_name(EV_KEY, button)); return true; } rc = evdev_middlebutton_handle_event(device, time, event); old_mask = device->middlebutton.button_mask; if (is_press) device->middlebutton.button_mask |= 1 << bit; else device->middlebutton.button_mask &= ~(1 << bit); if (old_mask != device->middlebutton.button_mask && device->middlebutton.button_mask == 0) { evdev_middlebutton_handle_event(device, time, MIDDLEBUTTON_EVENT_ALL_UP); evdev_middlebutton_apply_config(device); } return rc; }