summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-17 20:33:37 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2019-02-17 20:33:37 -0500
commit041594d2ab4fb6f8de2055d3704da5f54146c44e (patch)
tree98ad97cbeac9c87f49385fb33338a81b49d84441 /sway
parentworkspace_next_name: fallback to next available number (diff)
downloadsway-041594d2ab4fb6f8de2055d3704da5f54146c44e.tar.gz
sway-041594d2ab4fb6f8de2055d3704da5f54146c44e.tar.zst
sway-041594d2ab4fb6f8de2055d3704da5f54146c44e.zip
Use container under cursor for mouse bindings
This matches i3's behavior of executing mouse bindings in regards to the container under the cursor instead of what is focused.
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bind.c20
-rw-r--r--sway/sway.5.scd13
2 files changed, 24 insertions, 9 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c
index 59116d67..172e6b8a 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -1,10 +1,11 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2#include <libevdev/libevdev.h> 2#include <libevdev/libevdev.h>
3#include <linux/input-event-codes.h> 3#include <linux/input-event-codes.h>
4#include <xkbcommon/xkbcommon.h>
5#include <xkbcommon/xkbcommon-names.h>
6#include <string.h> 4#include <string.h>
7#include <strings.h> 5#include <strings.h>
6#include <xkbcommon/xkbcommon.h>
7#include <xkbcommon/xkbcommon-names.h>
8#include <wlr/types/wlr_cursor.h>
8#include "sway/commands.h" 9#include "sway/commands.h"
9#include "sway/config.h" 10#include "sway/config.h"
10#include "sway/input/cursor.h" 11#include "sway/input/cursor.h"
@@ -330,7 +331,20 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
330void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) { 331void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) {
331 sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command); 332 sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command);
332 333
333 list_t *res_list = execute_command(binding->command, seat, NULL); 334 struct sway_container *con = NULL;
335 if (binding->type == BINDING_MOUSESYM
336 || binding->type == BINDING_MOUSECODE) {
337 struct wlr_surface *surface = NULL;
338 double sx, sy;
339 struct sway_node *node = node_at_coords(seat,
340 seat->cursor->cursor->x, seat->cursor->cursor->y,
341 &surface, &sx, &sy);
342 if (node && node->type == N_CONTAINER) {
343 con = node->sway_container;
344 }
345 }
346
347 list_t *res_list = execute_command(binding->command, seat, con);
334 bool success = true; 348 bool success = true;
335 for (int i = 0; i < res_list->length; ++i) { 349 for (int i = 0; i < res_list->length; ++i) {
336 struct cmd_results *results = res_list->items[i]; 350 struct cmd_results *results = res_list->items[i];
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index b6955acd..76467d23 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -293,12 +293,13 @@ runtime.
293 overwrite a binding, swaynag will give you a warning. To silence this, use 293 overwrite a binding, swaynag will give you a warning. To silence this, use
294 the _--no-warn_ flag. 294 the _--no-warn_ flag.
295 295
296 Mouse buttons can either be specified in the form _button[1-9]_ or by using 296 Mouse bindings operate on the container under the cursor instead of the
297 the name of the event code (ex _BTN\_LEFT_ or _BTN\_RIGHT_). For the former 297 container that has focus. Mouse buttons can either be specified in the form
298 option, the buttons will be mapped to their values in X11 (1=left, 2=middle, 298 _button[1-9]_ or by using the name of the event code (ex _BTN\_LEFT_ or
299 3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back, 299 _BTN\_RIGHT_). For the former option, the buttons will be mapped to their
300 9=forward). For the latter option, you can find the event names using 300 values in X11 (1=left, 2=middle, 3=right, 4=scroll up, 5=scroll down,
301 _libinput debug-events_. 301 6=scroll left, 7=scroll right, 8=back, 9=forward). For the latter option,
302 you can find the event names using _libinput debug-events_.
302 303
303 _--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options 304 _--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options
304 which affect the region in which the mouse bindings can be triggered. By 305 which affect the region in which the mouse bindings can be triggered. By