aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/tiling_drag_threshold.c22
-rw-r--r--sway/config.c1
-rw-r--r--sway/input/cursor.c40
-rw-r--r--sway/input/seat.c11
-rw-r--r--sway/meson.build1
-rw-r--r--sway/sway-output.5.scd12
-rw-r--r--sway/sway.5.scd21
8 files changed, 97 insertions, 12 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 927434bc..0883b57b 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -87,6 +87,7 @@ static struct cmd_handler handlers[] = {
87 { "smart_borders", cmd_smart_borders }, 87 { "smart_borders", cmd_smart_borders },
88 { "smart_gaps", cmd_smart_gaps }, 88 { "smart_gaps", cmd_smart_gaps },
89 { "tiling_drag", cmd_tiling_drag }, 89 { "tiling_drag", cmd_tiling_drag },
90 { "tiling_drag_threshold", cmd_tiling_drag_threshold },
90 { "title_align", cmd_title_align }, 91 { "title_align", cmd_title_align },
91 { "titlebar_border_thickness", cmd_titlebar_border_thickness }, 92 { "titlebar_border_thickness", cmd_titlebar_border_thickness },
92 { "titlebar_padding", cmd_titlebar_padding }, 93 { "titlebar_padding", cmd_titlebar_padding },
diff --git a/sway/commands/tiling_drag_threshold.c b/sway/commands/tiling_drag_threshold.c
new file mode 100644
index 00000000..6b0531c3
--- /dev/null
+++ b/sway/commands/tiling_drag_threshold.c
@@ -0,0 +1,22 @@
1#include <string.h>
2#include "sway/commands.h"
3#include "sway/config.h"
4#include "log.h"
5
6struct cmd_results *cmd_tiling_drag_threshold(int argc, char **argv) {
7 struct cmd_results *error = NULL;
8 if ((error = checkarg(argc, "tiling_drag_threshold", EXPECTED_EQUAL_TO, 1))) {
9 return error;
10 }
11
12 char *inv;
13 int value = strtol(argv[0], &inv, 10);
14 if (*inv != '\0' || value < 0) {
15 return cmd_results_new(CMD_INVALID, "tiling_drag_threshold",
16 "Invalid threshold specified");
17 }
18
19 config->tiling_drag_threshold = value;
20
21 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
22}
diff --git a/sway/config.c b/sway/config.c
index bb7f796d..5d631b7e 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -233,6 +233,7 @@ static void config_defaults(struct sway_config *config) {
233 config->show_marks = true; 233 config->show_marks = true;
234 config->title_align = ALIGN_LEFT; 234 config->title_align = ALIGN_LEFT;
235 config->tiling_drag = true; 235 config->tiling_drag = true;
236 config->tiling_drag_threshold = 9;
236 237
237 config->smart_gaps = false; 238 config->smart_gaps = false;
238 config->gaps_inner = 0; 239 config->gaps_inner = 0;
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index f8302ddf..66a9e435 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -384,6 +384,30 @@ static void handle_move_tiling_motion(struct sway_seat *seat,
384 desktop_damage_box(&seat->op_drop_box); 384 desktop_damage_box(&seat->op_drop_box);
385} 385}
386 386
387static void handle_move_tiling_threshold_motion(struct sway_seat *seat,
388 struct sway_cursor *cursor) {
389 double cx = seat->cursor->cursor->x;
390 double cy = seat->cursor->cursor->y;
391 double sx = seat->op_ref_lx;
392 double sy = seat->op_ref_ly;
393
394 // Get the scaled threshold for the output. Even if the operation goes
395 // across multiple outputs of varying scales, just use the scale for the
396 // output that the cursor is currently on for simplicity.
397 struct wlr_output *wlr_output = wlr_output_layout_output_at(
398 root->output_layout, cx, cy);
399 double output_scale = wlr_output ? wlr_output->scale : 1;
400 double threshold = config->tiling_drag_threshold * output_scale;
401 threshold *= threshold;
402
403 // If the threshold has been exceeded, start the actual drag
404 if ((cx - sx) * (cx - sx) + (cy - sy) * (cy - sy) > threshold) {
405 seat->operation = OP_MOVE_TILING;
406 cursor_set_image(cursor, "grab", NULL);
407 handle_move_tiling_motion(seat, cursor);
408 }
409}
410
387static void calculate_floating_constraints(struct sway_container *con, 411static void calculate_floating_constraints(struct sway_container *con,
388 int *min_width, int *max_width, int *min_height, int *max_height) { 412 int *min_width, int *max_width, int *min_height, int *max_height) {
389 if (config->floating_minimum_width == -1) { // no minimum 413 if (config->floating_minimum_width == -1) { // no minimum
@@ -640,6 +664,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor,
640 case OP_MOVE_FLOATING: 664 case OP_MOVE_FLOATING:
641 handle_move_floating_motion(seat, cursor); 665 handle_move_floating_motion(seat, cursor);
642 break; 666 break;
667 case OP_MOVE_TILING_THRESHOLD:
668 handle_move_tiling_threshold_motion(seat, cursor);
669 break;
643 case OP_MOVE_TILING: 670 case OP_MOVE_TILING:
644 handle_move_tiling_motion(seat, cursor); 671 handle_move_tiling_motion(seat, cursor);
645 break; 672 break;
@@ -984,12 +1011,21 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
984 if (config->tiling_drag && (mod_pressed || on_titlebar) && 1011 if (config->tiling_drag && (mod_pressed || on_titlebar) &&
985 state == WLR_BUTTON_PRESSED && !is_floating_or_child && 1012 state == WLR_BUTTON_PRESSED && !is_floating_or_child &&
986 cont && !cont->is_fullscreen) { 1013 cont && !cont->is_fullscreen) {
987 if (on_titlebar) { 1014 struct sway_container *focus = seat_get_focused_container(seat);
1015 bool focused = focus == cont || container_has_ancestor(focus, cont);
1016 if (on_titlebar && !focused) {
988 node = seat_get_focus_inactive(seat, &cont->node); 1017 node = seat_get_focus_inactive(seat, &cont->node);
989 seat_set_focus(seat, node); 1018 seat_set_focus(seat, node);
990 } 1019 }
1020
991 seat_pointer_notify_button(seat, time_msec, button, state); 1021 seat_pointer_notify_button(seat, time_msec, button, state);
992 seat_begin_move_tiling(seat, cont, button); 1022
1023 // If moving a container by it's title bar, use a threshold for the drag
1024 if (!mod_pressed && config->tiling_drag_threshold > 0) {
1025 seat_begin_move_tiling_threshold(seat, cont, button);
1026 } else {
1027 seat_begin_move_tiling(seat, cont, button);
1028 }
993 return; 1029 return;
994 } 1030 }
995 1031
diff --git a/sway/input/seat.c b/sway/input/seat.c
index fa82c9ce..9422713d 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -1052,6 +1052,17 @@ void seat_begin_move_floating(struct sway_seat *seat,
1052 cursor_set_image(seat->cursor, "grab", NULL); 1052 cursor_set_image(seat->cursor, "grab", NULL);
1053} 1053}
1054 1054
1055void seat_begin_move_tiling_threshold(struct sway_seat *seat,
1056 struct sway_container *con, uint32_t button) {
1057 seat->operation = OP_MOVE_TILING_THRESHOLD;
1058 seat->op_container = con;
1059 seat->op_button = button;
1060 seat->op_target_node = NULL;
1061 seat->op_target_edge = 0;
1062 seat->op_ref_lx = seat->cursor->cursor->x;
1063 seat->op_ref_ly = seat->cursor->cursor->y;
1064}
1065
1055void seat_begin_move_tiling(struct sway_seat *seat, 1066void seat_begin_move_tiling(struct sway_seat *seat,
1056 struct sway_container *con, uint32_t button) { 1067 struct sway_container *con, uint32_t button) {
1057 seat->operation = OP_MOVE_TILING; 1068 seat->operation = OP_MOVE_TILING;
diff --git a/sway/meson.build b/sway/meson.build
index 7f739287..98676ce0 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -89,6 +89,7 @@ sway_sources = files(
89 'commands/swaynag_command.c', 89 'commands/swaynag_command.c',
90 'commands/swap.c', 90 'commands/swap.c',
91 'commands/tiling_drag.c', 91 'commands/tiling_drag.c',
92 'commands/tiling_drag_threshold.c',
92 'commands/title_align.c', 93 'commands/title_align.c',
93 'commands/title_format.c', 94 'commands/title_format.c',
94 'commands/titlebar_border_thickness.c', 95 'commands/titlebar_border_thickness.c',
diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd
index 9940d8e8..28524478 100644
--- a/sway/sway-output.5.scd
+++ b/sway/sway-output.5.scd
@@ -38,17 +38,20 @@ must be separated by one space. For example:
38 Places the specified output at the specific position in the global 38 Places the specified output at the specific position in the global
39 coordinate space. If scaling is active, it has to be considered when 39 coordinate space. If scaling is active, it has to be considered when
40 positioning. For example, if the scaling factor for the left output is 2, 40 positioning. For example, if the scaling factor for the left output is 2,
41 the relative position for the right output has to be divided by 2. 41 the relative position for the right output has to be divided by 2. The
42 reference point is the top left corner so if you want the bottoms aligned
43 this has to be considered as well.
42 44
43 Example: 45 Example:
44 46
45 output HDMI1 scale 2 47 output HDMI1 scale 2
46 48
47 output HDMI1 pos 0 0 res 3200x1800 49 output HDMI1 pos 0 1020 res 3200x1800
48 50
49 output eDP1 pos 1600 0 res 1920x1080 51 output eDP1 pos 1600 0 res 1920x1080
50 52
51 Note that the x-pos of eDP1 is 1600 = 3200/2. 53 Note that the left x-pos of eDP1 is 1600 = 3200/2 and the bottom y-pos is
54 1020 + (1800 / 2) = 1920 = 0 + 1920
52 55
53*output* <name> scale <factor> 56*output* <name> scale <factor>
54 Scales the specified output by the specified scale _factor_. An integer is 57 Scales the specified output by the specified scale _factor_. An integer is
@@ -57,7 +60,8 @@ must be separated by one space. For example:
57 represent the contents of your windows - they will be rendered at the next 60 represent the contents of your windows - they will be rendered at the next
58 highest integral scale factor and downscaled. You may be better served by 61 highest integral scale factor and downscaled. You may be better served by
59 setting an integral scale factor and adjusting the font size of your 62 setting an integral scale factor and adjusting the font size of your
60 applications to taste. 63 applications to taste. HiDPI isn't supported with Xwayland clients (windows
64 will blur).
61 65
62*output* <name> background|bg <file> <mode> [<fallback\_color>] 66*output* <name> background|bg <file> <mode> [<fallback\_color>]
63 Sets the wallpaper for the given output to the specified file, using the 67 Sets the wallpaper for the given output to the specified file, using the
diff --git a/sway/sway.5.scd b/sway/sway.5.scd
index e6abef56..3757a097 100644
--- a/sway/sway.5.scd
+++ b/sway/sway.5.scd
@@ -327,7 +327,8 @@ runtime.
327 A view that does not have focus. 327 A view that does not have focus.
328 328
329 *client.urgent* 329 *client.urgent*
330 A view with an urgency hint. *Note*: This is not currently implemented. 330 A view with an urgency hint. *Note*: Native Wayland windows do not
331 support urgency. Urgency only works for Xwayland windows.
331 332
332 The meaning of each color is: 333 The meaning of each color is:
333 334
@@ -431,7 +432,7 @@ The default colors are:
431 432
432*focus\_follows\_mouse* yes|no|always 433*focus\_follows\_mouse* yes|no|always
433 If set to _yes_, moving your mouse over a window will focus that window. If 434 If set to _yes_, moving your mouse over a window will focus that window. If
434 set to _always_, the window under the cursor will always be focused, even 435 set to _always_, the window under the cursor will always be focused, even
435 after switching between workspaces. 436 after switching between workspaces.
436 437
437*focus\_wrapping* yes|no|force 438*focus\_wrapping* yes|no|force
@@ -450,11 +451,11 @@ The default colors are:
450 Thickness of the titlebar border in pixels 451 Thickness of the titlebar border in pixels
451 452
452*titlebar\_padding* <horizontal> [<vertical>] 453*titlebar\_padding* <horizontal> [<vertical>]
453 Padding of the text in the titlebar. _horizontal_ value affects horizontal 454 Padding of the text in the titlebar. _horizontal_ value affects horizontal
454 padding of the text while _vertical_ value affects vertical padding (space 455 padding of the text while _vertical_ value affects vertical padding (space
455 above and below text). Padding includes titlebar borders so their value 456 above and below text). Padding includes titlebar borders so their value
456 should be greater than titlebar\_border\_thickness. If _vertical_ value is 457 should be greater than titlebar\_border\_thickness. If _vertical_ value is
457 not specified it is set to the _horizontal_ value. 458 not specified it is set to the _horizontal_ value.
458 459
459*for\_window* <criteria> <command> 460*for\_window* <criteria> <command>
460 Whenever a window that matches _criteria_ appears, run list of commands. 461 Whenever a window that matches _criteria_ appears, run list of commands.
@@ -572,6 +573,14 @@ The default colors are:
572 the _floating\_mod_ will also allow the container to be dragged. _toggle_ 573 the _floating\_mod_ will also allow the container to be dragged. _toggle_
573 should not be used in the config file. 574 should not be used in the config file.
574 575
576*tiling\_drag\_threshold* <threshold>
577 Sets the threshold that must be exceeded for a container to be dragged by
578 its titlebar. This has no effect if _floating\_mod_ is used or if
579 _tiling\_drag_ is set to _disable_. Once the threshold has been exceeded
580 once, the drag starts and the cursor can come back inside the threshold
581 without stopping the drag. _threshold_ is multiplied by the scale of the
582 output that the cursor on. The default is 9.
583
575*title\_align* left|center|right 584*title\_align* left|center|right
576 Sets the title alignment. If _right_ is selected and _show\_marks_ is set 585 Sets the title alignment. If _right_ is selected and _show\_marks_ is set
577 to _yes_, the marks will be shown on the _left_ side instead of the 586 to _yes_, the marks will be shown on the _left_ side instead of the