aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,
275 * Functions used by handle_button / 275 * Functions used by handle_button /
276 *--------------------------------*/ 276 *--------------------------------*/
277 277
278static bool trigger_pointer_button_binding(struct sway_seat *seat,
279 struct wlr_input_device *device, uint32_t button,
280 enum wlr_button_state state, uint32_t modifiers,
281 bool on_titlebar, bool on_border, bool on_contents, bool on_workspace) {
282 // We can reach this for non-pointer devices if we're currently emulating
283 // pointer input for one. Emulated input should not trigger bindings.
284 if (device->type != WLR_INPUT_DEVICE_POINTER) {
285 return false;
286 }
287
288 struct seatop_default_event *e = seat->seatop_data;
289
290 char *device_identifier = device ? input_device_get_identifier(device)
291 : strdup("*");
292 struct sway_binding *binding = NULL;
293 if (state == WLR_BUTTON_PRESSED) {
294 state_add_button(e, button);
295 binding = get_active_mouse_binding(e,
296 config->current_mode->mouse_bindings, modifiers, false,
297 on_titlebar, on_border, on_contents, on_workspace,
298 device_identifier);
299 } else {
300 binding = get_active_mouse_binding(e,
301 config->current_mode->mouse_bindings, modifiers, true,
302 on_titlebar, on_border, on_contents, on_workspace,
303 device_identifier);
304 state_erase_button(e, button);
305 }
306
307 free(device_identifier);
308 if (binding) {
309 seat_execute_command(seat, binding);
310 return true;
311 }
312
313 return false;
314}
315
278static void handle_button(struct sway_seat *seat, uint32_t time_msec, 316static void handle_button(struct sway_seat *seat, uint32_t time_msec,
279 struct wlr_input_device *device, uint32_t button, 317 struct wlr_input_device *device, uint32_t button,
280 enum wlr_button_state state) { 318 enum wlr_button_state state) {
281 struct seatop_default_event *e = seat->seatop_data;
282 struct sway_cursor *cursor = seat->cursor; 319 struct sway_cursor *cursor = seat->cursor;
283 320
284 // Determine what's under the cursor 321 // Determine what's under the cursor
@@ -300,29 +337,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
300 bool on_workspace = node && node->type == N_WORKSPACE; 337 bool on_workspace = node && node->type == N_WORKSPACE;
301 bool on_titlebar = cont && !on_border && !surface; 338 bool on_titlebar = cont && !on_border && !surface;
302 339
303 // Handle mouse bindings
304 struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); 340 struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
305 uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0; 341 uint32_t modifiers = keyboard ? wlr_keyboard_get_modifiers(keyboard) : 0;
306 342
307 char *device_identifier = device ? input_device_get_identifier(device) 343 // Handle mouse bindings
308 : strdup("*"); 344 if (trigger_pointer_button_binding(seat, device, button, state, modifiers,
309 struct sway_binding *binding = NULL; 345 on_titlebar, on_border, on_contents, on_workspace)) {
310 if (state == WLR_BUTTON_PRESSED) {
311 state_add_button(e, button);
312 binding = get_active_mouse_binding(e,
313 config->current_mode->mouse_bindings, modifiers, false,
314 on_titlebar, on_border, on_contents, on_workspace,
315 device_identifier);
316 } else {
317 binding = get_active_mouse_binding(e,
318 config->current_mode->mouse_bindings, modifiers, true,
319 on_titlebar, on_border, on_contents, on_workspace,
320 device_identifier);
321 state_erase_button(e, button);
322 }
323 free(device_identifier);
324 if (binding) {
325 seat_execute_command(seat, binding);
326 return; 346 return;
327 } 347 }
328 348
@@ -364,8 +384,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
364 } 384 }
365 385
366 // Handle tiling resize via mod 386 // Handle tiling resize via mod
367 bool mod_pressed = keyboard && 387 bool mod_pressed = modifiers & config->floating_mod;
368 (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
369 if (cont && !is_floating_or_child && mod_pressed && 388 if (cont && !is_floating_or_child && mod_pressed &&
370 state == WLR_BUTTON_PRESSED) { 389 state == WLR_BUTTON_PRESSED) {
371 uint32_t btn_resize = config->floating_mod_inverse ? 390 uint32_t btn_resize = config->floating_mod_inverse ?