diff options
author | Calvin Lee <cyrus296@gmail.com> | 2017-04-04 21:20:27 -0600 |
---|---|---|
committer | Calvin Lee <cyrus296@gmail.com> | 2017-04-05 22:07:23 -0600 |
commit | 069d37f987c4e323cdb9396f0d80ac83d00566ff (patch) | |
tree | b883a5553107ab24d5346db42062518f9e7bdca9 /sway/commands/resize.c | |
parent | Merge pull request #1145 from 4e554c4c/marks (diff) | |
download | sway-069d37f987c4e323cdb9396f0d80ac83d00566ff.tar.gz sway-069d37f987c4e323cdb9396f0d80ac83d00566ff.tar.zst sway-069d37f987c4e323cdb9396f0d80ac83d00566ff.zip |
Improve criteria handling
This commit changes how commands decide what container to act on.
Commands get the current container though `current_container`, a global
defined in sway/commands.c. If a criteria is given before a command,
then the following command will be run once for every container the
criteria matches with a reference to the matching container in
'current_container'. Commands should use this instead of
`get_focused_container()` from now on.
This commit also fixes a few (minor) mistakes made in implementing marks
such as non-escaped arrows in sway(5) and calling the "mark" command
"floating" by accident. It also cleans up `criteria.c` in a few places.
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r-- | sway/commands/resize.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 61af080c..ef52bb07 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c | |||
@@ -19,7 +19,7 @@ enum resize_dim_types { | |||
19 | }; | 19 | }; |
20 | 20 | ||
21 | static bool set_size_floating(int new_dimension, bool use_width) { | 21 | static bool set_size_floating(int new_dimension, bool use_width) { |
22 | swayc_t *view = get_focused_float(swayc_active_workspace()); | 22 | swayc_t *view = current_container; |
23 | if (view) { | 23 | if (view) { |
24 | if (use_width) { | 24 | if (use_width) { |
25 | int current_width = view->width; | 25 | int current_width = view->width; |
@@ -50,7 +50,7 @@ static bool set_size_floating(int new_dimension, bool use_width) { | |||
50 | } | 50 | } |
51 | 51 | ||
52 | static bool resize_floating(int amount, bool use_width) { | 52 | static bool resize_floating(int amount, bool use_width) { |
53 | swayc_t *view = get_focused_float(swayc_active_workspace()); | 53 | swayc_t *view = current_container; |
54 | 54 | ||
55 | if (view) { | 55 | if (view) { |
56 | if (use_width) { | 56 | if (use_width) { |
@@ -64,7 +64,7 @@ static bool resize_floating(int amount, bool use_width) { | |||
64 | } | 64 | } |
65 | 65 | ||
66 | static bool resize_tiled(int amount, bool use_width) { | 66 | static bool resize_tiled(int amount, bool use_width) { |
67 | swayc_t *container = get_focused_view(swayc_active_workspace()); | 67 | swayc_t *container = current_container; |
68 | swayc_t *parent = container->parent; | 68 | swayc_t *parent = container->parent; |
69 | int idx_focused = 0; | 69 | int idx_focused = 0; |
70 | bool use_major = false; | 70 | bool use_major = false; |
@@ -199,7 +199,7 @@ static bool resize_tiled(int amount, bool use_width) { | |||
199 | 199 | ||
200 | static bool set_size_tiled(int amount, bool use_width) { | 200 | static bool set_size_tiled(int amount, bool use_width) { |
201 | int desired; | 201 | int desired; |
202 | swayc_t *focused = get_focused_view(swayc_active_workspace()); | 202 | swayc_t *focused = current_container; |
203 | 203 | ||
204 | if (use_width) { | 204 | if (use_width) { |
205 | desired = amount - focused->width; | 205 | desired = amount - focused->width; |
@@ -211,7 +211,7 @@ static bool set_size_tiled(int amount, bool use_width) { | |||
211 | } | 211 | } |
212 | 212 | ||
213 | static bool set_size(int dimension, bool use_width) { | 213 | static bool set_size(int dimension, bool use_width) { |
214 | swayc_t *focused = get_focused_view_include_floating(swayc_active_workspace()); | 214 | swayc_t *focused = current_container; |
215 | 215 | ||
216 | if (focused) { | 216 | if (focused) { |
217 | if (focused->is_floating) { | 217 | if (focused->is_floating) { |
@@ -225,7 +225,7 @@ static bool set_size(int dimension, bool use_width) { | |||
225 | } | 225 | } |
226 | 226 | ||
227 | static bool resize(int dimension, bool use_width, enum resize_dim_types dim_type) { | 227 | static bool resize(int dimension, bool use_width, enum resize_dim_types dim_type) { |
228 | swayc_t *focused = get_focused_view_include_floating(swayc_active_workspace()); | 228 | swayc_t *focused = current_container; |
229 | 229 | ||
230 | // translate "10 ppt" (10%) to appropriate # of pixels in case we need it | 230 | // translate "10 ppt" (10%) to appropriate # of pixels in case we need it |
231 | float ppt_dim = (float)dimension / 100; | 231 | float ppt_dim = (float)dimension / 100; |