aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTudor Brindus <me@tbrindus.ca>2020-06-14 17:21:38 -0400
committerSimon Ser <contact@emersion.fr>2020-06-16 19:21:55 +0200
commit8fa74add82b4975ea1fb8d1e57308bd591e6d9d0 (patch)
treefb317ea3662c3f13361b641c2f471422417f9ad0
parent20deb8ec1696cba0da50165e3c128895e2f44cdf (diff)
input/pointer: don't trigger pointer bindings for emulated input
Prior to this commit, a tablet device could trigger mouse button down bindings if the pen was pressed on a surface that didn't bind tablet handlers -- but it wouldn't if the surface did bind tablet handlers. We should expose consistent behavior to users so that they don't have to care about emulated vs. non-emulated input, so stop triggering bindings for any non-pointer devices.
-rw-r--r--sway/input/seatop_default.c65
1 files changed, 42 insertions, 23 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index 50d618d8..a1b4aeb2 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -275,10 +275,47 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
* Functions used by handle_button /
*--------------------------------*/
+static bool trigger_pointer_button_binding(struct sway_seat *seat,
+ struct wlr_input_device *device, uint32_t button,
+ enum wlr_button_state state, uint32_t modifiers,
+ bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) {
+ // We can reach this for non-pointer devices if we're currently emulating
+ // pointer input for one. Emulated input should not trigger bindings.
+ if (device->type != WLR_INPUT_DEVICE_POINTER) {
+ return false;
+ }
+
+ struct seatop_default_event *e = seat->seatop_data;
+
+ char *device_identifier = device ? input_device_get_identifier(device)
+ : strdup("*");
+ struct sway_binding *binding = NULL;
+ if (state == WLR_BUTTON_PRESSED) {
+ state_add_button(e, button);
+ binding = get_active_mouse_binding(e,
+ config->current_mode->mouse_bindings, modifiers, false,
+ on_titlebar, on_border, on_contents, on_workspace,
+ device_identifier);
+ } else {
+ binding = get_active_mouse_binding(e,
+ config->current_mode->mouse_bindings, modifiers, true,
+ on_titlebar, on_border, on_contents, on_workspace,
+ device_identifier);
+ state_erase_button(e, button);
+ }
+
+ free(device_identifier);
+ if (binding) {
+ seat_execute_command(seat, binding);
+ return true;
+ }
+
+ return false;
+}
+
static void handle_button(struct sway_seat *seat, uint32_t time_msec,
struct wlr_input_device *device, uint32_t button,
enum wlr_button_state state) {
- struct seatop_default_event *e = seat->seatop_data;
struct sway_cursor *cursor = seat->cursor;
// Determine what's under the cursor
@@ -300,29 +337,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
bool on_workspace = node && node->type == N_WORKSPACE;
bool on_titlebar = cont && !on_border && !surface;
- // Handle mouse bindings
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
- char *device_identifier = device ? input_device_get_identifier(device)
- : strdup("*");
- struct sway_binding *binding = NULL;
- if (state == WLR_BUTTON_PRESSED) {
- state_add_button(e, button);
- binding = get_active_mouse_binding(e,
- config->current_mode->mouse_bindings, modifiers, false,
- on_titlebar, on_border, on_contents, on_workspace,
- device_identifier);
- } else {
- binding = get_active_mouse_binding(e,
- config->current_mode->mouse_bindings, modifiers, true,
- on_titlebar, on_border, on_contents, on_workspace,
- device_identifier);
- state_erase_button(e, button);
- }
- free(device_identifier);
- if (binding) {
- seat_execute_command(seat, binding);
+ // Handle mouse bindings
+ if (trigger_pointer_button_binding(seat, device, button, state, modifiers,
+ on_titlebar, on_border, on_contents, on_workspace)) {
return;
}
@@ -364,8 +384,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
}
// Handle tiling resize via mod
- bool mod_pressed = keyboard &&
- (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
+ bool mod_pressed = modifiers & config->floating_mod;
if (cont && !is_floating_or_child && mod_pressed &&
state == WLR_BUTTON_PRESSED) {
uint32_t btn_resize = config->floating_mod_inverse ?