Merge pull request #3713 from RedSoxFan/fix-mouse-bindings

Use container under cursor for mouse bindings
master
Drew DeVault 6 years ago committed by GitHub
commit e625c0b18c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,11 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <libevdev/libevdev.h> #include <libevdev/libevdev.h>
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-names.h>
#include <string.h> #include <string.h>
#include <strings.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/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/input/cursor.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) { void seat_execute_command(struct sway_seat *seat, struct sway_binding *binding) {
sway_log(SWAY_DEBUG, "running command for binding: %s", binding->command); 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; bool success = true;
for (int i = 0; i < res_list->length; ++i) { for (int i = 0; i < res_list->length; ++i) {
struct cmd_results *results = res_list->items[i]; struct cmd_results *results = res_list->items[i];

@ -293,12 +293,13 @@ runtime.
overwrite a binding, swaynag will give you a warning. To silence this, use overwrite a binding, swaynag will give you a warning. To silence this, use
the _--no-warn_ flag. the _--no-warn_ flag.
Mouse buttons can either be specified in the form _button[1-9]_ or by using Mouse bindings operate on the container under the cursor instead of the
the name of the event code (ex _BTN\_LEFT_ or _BTN\_RIGHT_). For the former container that has focus. Mouse buttons can either be specified in the form
option, the buttons will be mapped to their values in X11 (1=left, 2=middle, _button[1-9]_ or by using the name of the event code (ex _BTN\_LEFT_ or
3=right, 4=scroll up, 5=scroll down, 6=scroll left, 7=scroll right, 8=back, _BTN\_RIGHT_). For the former option, the buttons will be mapped to their
9=forward). For the latter option, you can find the event names using values in X11 (1=left, 2=middle, 3=right, 4=scroll up, 5=scroll down,
_libinput debug-events_. 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 _--whole-window_, _--border_, and _--exclude-titlebar_ are mouse-only options
which affect the region in which the mouse bindings can be triggered. By which affect the region in which the mouse bindings can be triggered. By

Loading…
Cancel
Save