aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Ashworth <bosrsf04@gmail.com>2019-02-17 20:33:37 -0500
committerDrew DeVault <sir@cmpwn.com>2019-02-18 15:11:48 -0500
commita1b9aa11d12a5b0a2a521d6b9b89d487be2eedd3 (patch)
tree1c48e91df9a0cbc0b8459685a0c592441f2960c4
parent0940a46c114cef62e1d666a3038bf5e18d81ba95 (diff)
downloadsway-1.0-rc3.zip
sway-1.0-rc3.tar.gz
sway-1.0-rc3.tar.bz2
Use container under cursor for mouse bindings1.0-rc3
This matches i3's behavior of executing mouse bindings in regards to the container under the cursor instead of what is focused.
-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 59116d6..172e6b8 100644
--- a/sway/commands/bind.c
+++ b/sway/commands/bind.c
@@ -1,10 +1,11 @@
#define _POSIX_C_SOURCE 200809L
#include <libevdev/libevdev.h>
#include <linux/input-event-codes.h>
-#include <xkbcommon/xkbcommon.h>
-#include <xkbcommon/xkbcommon-names.h>
#include <string.h>
#include <strings.h>
+#include <xkbcommon/xkbcommon.h>
+#include <xkbcommon/xkbcommon-names.h>
+#include <wlr/types/wlr_cursor.h>
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/input/cursor.h"
@@ -330,7 +331,20 @@ struct cmd_results *cmd_bindcode(int argc, char **argv) {
void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) {
sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command);
- list_t *res_list = execute_command(binding->command, seat, NULL);
+ struct sway_container *con = NULL;
+ if (binding->type == BINDING_MOUSESYM
+ || binding->type == BINDING_MOUSECODE) {
+ struct wlr_surface *surface = NULL;
+ double sx, sy;
+ struct sway_node *node = node_at_coords(seat,
+ seat->cursor->cursor->x, seat->cursor->cursor->y,
+ &surface, &sx, &sy);
+ if (node && node->type == N_CONTAINER) {
+ con = node->sway_container;
+ }
+ }
+
+ list_t *res_list = execute_command(binding->command, seat, con);
bool success = true;
for (int i = 0; i < res_list->length; ++i) {
struct cmd_results *results = res_list->items[i];
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index b6955ac..76467d2 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -293,12 +293,13 @@ runtime.
overwrite a binding, swaynag will give you a warning. To silence this, use
the _--no-warn_ flag.
- Mouse buttons can either be specified in the form _button[1-9]_ or by using
- the name of the event code (ex _BTN\_LEFT_ or _BTN\_RIGHT_). For the former
- option, the buttons will be mapped to their values in X11 (1=left, 2=middle,
- 3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back,
- 9=forward). For the latter option, you can find the event names using
- _libinput debug-events_.
+ Mouse bindings operate on the container under the cursor instead of the
+ container that has focus. Mouse buttons can either be specified in the form
+ _button[1-9]_ or by using the name of the event code (ex _BTN\_LEFT_ or
+ _BTN\_RIGHT_). For the former option, the buttons will be mapped to their
+ values in X11 (1=left, 2=middle, 3=right, 4=scroll up, 5=scroll down,
+ 6=scroll left, 7=scroll right, 8=back, 9=forward). For the latter option,
+ you can find the event names using _libinput debug-events_.
_--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options
which affect the region in which the mouse bindings can be triggered. By