mirror of
https://github.com/swaywm/sway.git
synced 2024-11-28 10:51:28 +00:00
drag_mode_test1
This commit is contained in:
parent
2975514923
commit
635ee1e85d
|
@ -537,6 +537,8 @@ struct sway_config {
|
||||||
bool tiling_drag;
|
bool tiling_drag;
|
||||||
int tiling_drag_threshold;
|
int tiling_drag_threshold;
|
||||||
|
|
||||||
|
bool drag_mode;
|
||||||
|
|
||||||
enum smart_gaps_mode smart_gaps;
|
enum smart_gaps_mode smart_gaps;
|
||||||
int gaps_inner;
|
int gaps_inner;
|
||||||
struct side_gaps gaps_outer;
|
struct side_gaps gaps_outer;
|
||||||
|
|
|
@ -58,6 +58,7 @@ static const struct cmd_handler handlers[] = {
|
||||||
{ "client.urgent", cmd_client_urgent },
|
{ "client.urgent", cmd_client_urgent },
|
||||||
{ "default_border", cmd_default_border },
|
{ "default_border", cmd_default_border },
|
||||||
{ "default_floating_border", cmd_default_floating_border },
|
{ "default_floating_border", cmd_default_floating_border },
|
||||||
|
{ "drag_mode", cmd_drag_mode },
|
||||||
{ "exec", cmd_exec },
|
{ "exec", cmd_exec },
|
||||||
{ "exec_always", cmd_exec_always },
|
{ "exec_always", cmd_exec_always },
|
||||||
{ "floating_maximum_size", cmd_floating_maximum_size },
|
{ "floating_maximum_size", cmd_floating_maximum_size },
|
||||||
|
|
13
sway/commands/drag_mode.c
Normal file
13
sway/commands/drag_mode.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include "sway/commands.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
struct cmd_results *cmd_drag_mode(int argc, char **argv) {
|
||||||
|
struct cmd_results *error = NULL;
|
||||||
|
if ((error = checkarg(argc, "drag_mode", EXPECTED_EQUAL_TO, 1))) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
config->drag_mode = parse_boolean(argv[0], config->drag_mode);
|
||||||
|
|
||||||
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
|
@ -274,6 +274,7 @@ static void config_defaults(struct sway_config *config) {
|
||||||
config->tiling_drag = true;
|
config->tiling_drag = true;
|
||||||
config->tiling_drag_threshold = 9;
|
config->tiling_drag_threshold = 9;
|
||||||
config->primary_selection = true;
|
config->primary_selection = true;
|
||||||
|
config->drag_mode = false;
|
||||||
|
|
||||||
config->smart_gaps = SMART_GAPS_OFF;
|
config->smart_gaps = SMART_GAPS_OFF;
|
||||||
config->gaps_inner = 0;
|
config->gaps_inner = 0;
|
||||||
|
|
|
@ -399,7 +399,8 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
|
|
||||||
// Handle tiling resize via mod
|
// Handle tiling resize via mod
|
||||||
bool mod_pressed = modifiers & config->floating_mod;
|
bool mod_pressed = modifiers & config->floating_mod;
|
||||||
if (cont && !is_floating_or_child && mod_pressed &&
|
bool drag_mode = config->drag_mode;
|
||||||
|
if (cont && !is_floating_or_child && (drag_mode || mod_pressed) &&
|
||||||
state == WLR_BUTTON_PRESSED) {
|
state == WLR_BUTTON_PRESSED) {
|
||||||
uint32_t btn_resize = config->floating_mod_inverse ?
|
uint32_t btn_resize = config->floating_mod_inverse ?
|
||||||
BTN_LEFT : BTN_RIGHT;
|
BTN_LEFT : BTN_RIGHT;
|
||||||
|
@ -451,7 +452,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
if (cont && is_floating_or_child && !is_fullscreen_or_child &&
|
if (cont && is_floating_or_child && !is_fullscreen_or_child &&
|
||||||
state == WLR_BUTTON_PRESSED) {
|
state == WLR_BUTTON_PRESSED) {
|
||||||
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
|
uint32_t btn_move = config->floating_mod_inverse ? BTN_RIGHT : BTN_LEFT;
|
||||||
if (button == btn_move && (mod_pressed || on_titlebar)) {
|
if (button == btn_move && (mod_pressed || on_titlebar || drag_mode)) {
|
||||||
seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
|
seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -470,7 +471,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
// Via mod+click
|
// Via mod+click
|
||||||
uint32_t btn_resize = config->floating_mod_inverse ?
|
uint32_t btn_resize = config->floating_mod_inverse ?
|
||||||
BTN_LEFT : BTN_RIGHT;
|
BTN_LEFT : BTN_RIGHT;
|
||||||
if (mod_pressed && button == btn_resize) {
|
if ((mod_pressed || drag_mode) && button == btn_resize) {
|
||||||
struct sway_container *floater = container_toplevel_ancestor(cont);
|
struct sway_container *floater = container_toplevel_ancestor(cont);
|
||||||
edge = 0;
|
edge = 0;
|
||||||
edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ?
|
edge |= cursor->cursor->x > floater->pending.x + floater->pending.width / 2 ?
|
||||||
|
@ -484,11 +485,11 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle moving a tiling container
|
// Handle moving a tiling container
|
||||||
if (config->tiling_drag && (mod_pressed || on_titlebar) &&
|
if (config->tiling_drag && (mod_pressed || on_titlebar || drag_mode) &&
|
||||||
state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
|
state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
|
||||||
cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
|
cont && cont->pending.fullscreen_mode == FULLSCREEN_NONE) {
|
||||||
// If moving a container by its title bar, use a threshold for the drag
|
// If moving a container by its title bar, use a threshold for the drag
|
||||||
if (!mod_pressed && config->tiling_drag_threshold > 0) {
|
if (!(mod_pressed || drag_mode) && config->tiling_drag_threshold > 0) {
|
||||||
seatop_begin_move_tiling_threshold(seat, cont);
|
seatop_begin_move_tiling_threshold(seat, cont);
|
||||||
} else {
|
} else {
|
||||||
seatop_begin_move_tiling(seat, cont);
|
seatop_begin_move_tiling(seat, cont);
|
||||||
|
|
|
@ -51,6 +51,7 @@ sway_sources = files(
|
||||||
'commands/default_border.c',
|
'commands/default_border.c',
|
||||||
'commands/default_floating_border.c',
|
'commands/default_floating_border.c',
|
||||||
'commands/default_orientation.c',
|
'commands/default_orientation.c',
|
||||||
|
'commands/drag_mode.c',
|
||||||
'commands/exit.c',
|
'commands/exit.c',
|
||||||
'commands/exec.c',
|
'commands/exec.c',
|
||||||
'commands/exec_always.c',
|
'commands/exec_always.c',
|
||||||
|
|
Loading…
Reference in a new issue