Merge pull request #2352 from RedSoxFan/implement-2335

Implement floating_modifier <mod> [inverse|normal]
master
emersion 6 years ago committed by GitHub
commit cdc4ad2b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -320,6 +320,7 @@ struct sway_config {
struct bar_config *current_bar;
char *swaybg_command;
uint32_t floating_mod;
bool floating_mod_inverse;
uint32_t dragging_key;
uint32_t resizing_key;
char *floating_scroll_up_cmd;

@ -1,10 +1,11 @@
#include "strings.h"
#include "sway/commands.h"
#include "sway/config.h"
#include "util.h"
struct cmd_results *cmd_floating_modifier(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "floating_modifier", EXPECTED_EQUAL_TO, 1))) {
if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) {
return error;
}
@ -14,6 +15,15 @@ struct cmd_results *cmd_floating_modifier(int argc, char **argv) {
"Invalid modifier");
}
if (argc == 1 || strcasecmp(argv[1], "normal") == 0) {
config->floating_mod_inverse = false;
} else if (strcasecmp(argv[1], "inverse") == 0) {
config->floating_mod_inverse = true;
} else {
return cmd_results_new(CMD_INVALID, "floating_modifier",
"Usage: floating_modifier <mod> [inverse|normal]");
}
config->floating_mod = mod;
return cmd_results_new(CMD_SUCCESS, NULL, NULL);

@ -180,6 +180,7 @@ static void config_defaults(struct sway_config *config) {
list_add(config->modes, config->current_mode);
config->floating_mod = 0;
config->floating_mod_inverse = false;
config->dragging_key = BTN_LEFT;
config->resizing_key = BTN_RIGHT;

@ -449,15 +449,17 @@ static void dispatch_cursor_button_floating(struct sway_cursor *cursor,
bool over_title = edge == WLR_EDGE_NONE && !surface;
// Check for beginning move
if (button == BTN_LEFT && state == WLR_BUTTON_PRESSED &&
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
if (button == btn_move && state == WLR_BUTTON_PRESSED &&
(mod_pressed || over_title)) {
seat_begin_move(seat, cont, BTN_LEFT);
seat_begin_move(seat, cont, button);
return;
}
// Check for beginning resize
bool resizing_via_border = button == BTN_LEFT && edge != WLR_EDGE_NONE;
bool resizing_via_mod = button == BTN_RIGHT && mod_pressed;
uint32_t btn_resize = config->floating_mod_inverse ? BTN_LEFT : BTN_RIGHT;
bool resizing_via_mod = button == btn_resize && mod_pressed;
if ((resizing_via_border || resizing_via_mod) &&
state == WLR_BUTTON_PRESSED) {
if (edge == WLR_EDGE_NONE) {

Loading…
Cancel
Save