diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-18 16:13:28 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-07-22 23:10:19 +1000 |
commit | 9fbe13b9be18c732b58033a57a22a299af91a170 (patch) | |
tree | a24901c1bb4eff87877c0d9fb96767b662a9d533 /sway/commands/floating_modifier.c | |
parent | Merge pull request #2320 from RedSoxFan/reset-outputs-on-reload (diff) | |
download | sway-9fbe13b9be18c732b58033a57a22a299af91a170.tar.gz sway-9fbe13b9be18c732b58033a57a22a299af91a170.tar.zst sway-9fbe13b9be18c732b58033a57a22a299af91a170.zip |
Implement floating_modifier and mouse operations for floating views
This implements the following:
* `floating_modifier` configuration directive
* Drag a floating window by its title bar
* Hold mod + drag a floating window from anywhere
* Resize a floating view by dragging the border
* Resize a floating view by holding mod and right clicking anywhere on
the view
* Resize a floating view and keep aspect ratio by holding shift while
resizing using either method
* Mouse cursor turns into resize when hovering floating border or corner
Diffstat (limited to 'sway/commands/floating_modifier.c')
-rw-r--r-- | sway/commands/floating_modifier.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sway/commands/floating_modifier.c b/sway/commands/floating_modifier.c new file mode 100644 index 00000000..1ced50af --- /dev/null +++ b/sway/commands/floating_modifier.c | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifdef __linux__ | ||
2 | #include <linux/input-event-codes.h> | ||
3 | #elif __FreeBSD__ | ||
4 | #include <dev/evdev/input-event-codes.h> | ||
5 | #endif | ||
6 | #include <xkbcommon/xkbcommon.h> | ||
7 | #include <xkbcommon/xkbcommon-names.h> | ||
8 | #include <strings.h> | ||
9 | #include "sway/commands.h" | ||
10 | #include "sway/config.h" | ||
11 | #include "list.h" | ||
12 | #include "log.h" | ||
13 | #include "util.h" | ||
14 | |||
15 | struct cmd_results *cmd_floating_modifier(int argc, char **argv) { | ||
16 | struct cmd_results *error = NULL; | ||
17 | if ((error = checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1))) { | ||
18 | return error; | ||
19 | } | ||
20 | |||
21 | uint32_t mod = get_modifier_mask_by_name(argv[0]); | ||
22 | if (!mod) { | ||
23 | return cmd_results_new(CMD_INVALID, "floating_modifier", | ||
24 | "Invalid modifier"); | ||
25 | } | ||
26 | |||
27 | config->floating_mod = mod; | ||
28 | |||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
30 | } | ||