aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-11-06 14:17:33 +0100
committerLibravatar GitHub <noreply@github.com>2018-11-06 14:17:33 +0100
commit001ec1f3fdd700c23fb6dc91018697130af225ff (patch)
tree6144d7050fa2ac7383ffbe614cd76697f36929c8
parentMerge pull request #3068 from emersion/effective-damage (diff)
parentAdd relative output transform (diff)
downloadsway-001ec1f3fdd700c23fb6dc91018697130af225ff.tar.gz
sway-001ec1f3fdd700c23fb6dc91018697130af225ff.tar.zst
sway-001ec1f3fdd700c23fb6dc91018697130af225ff.zip
Merge pull request #3046 from tokyovigilante/relative-transform
Add relative output transform
-rw-r--r--sway/commands/output/transform.c46
-rw-r--r--sway/sway-output.5.scd7
2 files changed, 40 insertions, 13 deletions
diff --git a/sway/commands/output/transform.c b/sway/commands/output/transform.c
index f9a94d64..c1555323 100644
--- a/sway/commands/output/transform.c
+++ b/sway/commands/output/transform.c
@@ -1,6 +1,8 @@
1#include <string.h> 1#include <string.h>
2#include "sway/commands.h" 2#include "sway/commands.h"
3#include "sway/config.h" 3#include "sway/config.h"
4#include "log.h"
5#include "sway/output.h"
4 6
5struct cmd_results *output_cmd_transform(int argc, char **argv) { 7struct cmd_results *output_cmd_transform(int argc, char **argv) {
6 if (!config->handler_context.output_config) { 8 if (!config->handler_context.output_config) {
@@ -10,30 +12,52 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
10 return cmd_results_new(CMD_INVALID, "output", 12 return cmd_results_new(CMD_INVALID, "output",
11 "Missing transform argument."); 13 "Missing transform argument.");
12 } 14 }
13 15 enum wl_output_transform transform;
14 struct output_config *output = config->handler_context.output_config;
15 if (strcmp(*argv, "normal") == 0) { 16 if (strcmp(*argv, "normal") == 0) {
16 output->transform = WL_OUTPUT_TRANSFORM_NORMAL; 17 transform = WL_OUTPUT_TRANSFORM_NORMAL;
17 } else if (strcmp(*argv, "90") == 0) { 18 } else if (strcmp(*argv, "90") == 0) {
18 output->transform = WL_OUTPUT_TRANSFORM_90; 19 transform = WL_OUTPUT_TRANSFORM_90;
19 } else if (strcmp(*argv, "180") == 0) { 20 } else if (strcmp(*argv, "180") == 0) {
20 output->transform = WL_OUTPUT_TRANSFORM_180; 21 transform = WL_OUTPUT_TRANSFORM_180;
21 } else if (strcmp(*argv, "270") == 0) { 22 } else if (strcmp(*argv, "270") == 0) {
22 output->transform = WL_OUTPUT_TRANSFORM_270; 23 transform = WL_OUTPUT_TRANSFORM_270;
23 } else if (strcmp(*argv, "flipped") == 0) { 24 } else if (strcmp(*argv, "flipped") == 0) {
24 output->transform = WL_OUTPUT_TRANSFORM_FLIPPED; 25 transform = WL_OUTPUT_TRANSFORM_FLIPPED;
25 } else if (strcmp(*argv, "flipped-90") == 0) { 26 } else if (strcmp(*argv, "flipped-90") == 0) {
26 output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_90; 27 transform = WL_OUTPUT_TRANSFORM_FLIPPED_90;
27 } else if (strcmp(*argv, "flipped-180") == 0) { 28 } else if (strcmp(*argv, "flipped-180") == 0) {
28 output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_180; 29 transform = WL_OUTPUT_TRANSFORM_FLIPPED_180;
29 } else if (strcmp(*argv, "flipped-270") == 0) { 30 } else if (strcmp(*argv, "flipped-270") == 0) {
30 output->transform = WL_OUTPUT_TRANSFORM_FLIPPED_270; 31 transform = WL_OUTPUT_TRANSFORM_FLIPPED_270;
31 } else { 32 } else {
32 return cmd_results_new(CMD_INVALID, "output", 33 return cmd_results_new(CMD_INVALID, "output",
33 "Invalid output transform."); 34 "Invalid output transform.");
34 } 35 }
35 36 struct output_config *output = config->handler_context.output_config;
36 config->handler_context.leftovers.argc = argc - 1; 37 config->handler_context.leftovers.argc = argc - 1;
37 config->handler_context.leftovers.argv = argv + 1; 38 config->handler_context.leftovers.argv = argv + 1;
39 if (argc > 1 &&
40 (strcmp(argv[1], "clockwise") == 0 || strcmp(argv[1], "anticlockwise") == 0)) {
41 if (!sway_assert(output->name != NULL, "Output config name not set")) {
42 return NULL;
43 }
44 if (strcmp(output->name, "*") == 0) {
45 return cmd_results_new(CMD_INVALID, "output",
46 "Cannot apply relative transform to all outputs.");
47 }
48 struct sway_output *s_output = output_by_name(output->name);
49 if (s_output == NULL) {
50 return cmd_results_new(CMD_INVALID, "output",
51 "Cannot apply relative transform to unknown output %s", output->name);
52 }
53 if (strcmp(argv[1], "anticlockwise") == 0) {
54 transform = wlr_output_transform_invert(transform);
55 }
56 struct wlr_output *w_output = s_output->wlr_output;
57 transform = wlr_output_transform_compose(w_output->transform, transform);
58 config->handler_context.leftovers.argv += 1;
59 config->handler_context.leftovers.argc -= 1;
60 }
61 output->transform = transform;
38 return NULL; 62 return NULL;
39} 63}
diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd
index 1b456008..37b7108b 100644
--- a/sway/sway-output.5.scd
+++ b/sway/sway-output.5.scd
@@ -59,10 +59,13 @@ must be separated by one space. For example:
59 Sets the background of the given output to the specified color. _color_ 59 Sets the background of the given output to the specified color. _color_
60 should be specified as _#RRGGBB_. Alpha is not supported. 60 should be specified as _#RRGGBB_. Alpha is not supported.
61 61
62*output* <name> transform <transform> 62*output* <name> transform <transform> [clockwise|anticlockwise]
63 Sets the background transform to the given value. Can be one of "90", "180", 63 Sets the background transform to the given value. Can be one of "90", "180",
64 "270" for rotation; or "flipped", "flipped-90", "flipped-180", "flipped-270" 64 "270" for rotation; or "flipped", "flipped-90", "flipped-180", "flipped-270"
65 to apply a rotation and flip, or "normal" to apply no transform. 65 to apply a rotation and flip, or "normal" to apply no transform. If a single
66 output is chosen and a rotation direction is specified
67 (_clockwise_ or _anticlockwise_) then the transform is added or
68 subtracted from the current tranform.
66 69
67*output* <name> disable|enable 70*output* <name> disable|enable
68 Enables or disables the specified output (all outputs are enabled by 71 Enables or disables the specified output (all outputs are enabled by