Fix output transform anticlockwise

This wouldn't have any effect if the transform was flipped.
This commit is contained in:
Simon Ser 2020-02-10 18:25:24 +01:00 committed by Drew DeVault
parent 8b593677d2
commit a5a4d32816

View file

@ -4,6 +4,22 @@
#include "log.h" #include "log.h"
#include "sway/output.h" #include "sway/output.h"
static enum wl_output_transform invert_rotation_direction(
enum wl_output_transform t) {
switch (t) {
case WL_OUTPUT_TRANSFORM_90:
return WL_OUTPUT_TRANSFORM_270;
case WL_OUTPUT_TRANSFORM_270:
return WL_OUTPUT_TRANSFORM_90;
case WL_OUTPUT_TRANSFORM_FLIPPED_90:
return WL_OUTPUT_TRANSFORM_FLIPPED_270;
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
return WL_OUTPUT_TRANSFORM_FLIPPED_90;
default:
return t;
}
}
struct cmd_results *output_cmd_transform(int argc, char **argv) { struct cmd_results *output_cmd_transform(int argc, char **argv) {
if (!config->handler_context.output_config) { if (!config->handler_context.output_config) {
return cmd_results_new(CMD_FAILURE, "Missing output config"); return cmd_results_new(CMD_FAILURE, "Missing output config");
@ -11,6 +27,7 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
if (!argc) { if (!argc) {
return cmd_results_new(CMD_INVALID, "Missing transform argument."); return cmd_results_new(CMD_INVALID, "Missing transform argument.");
} }
enum wl_output_transform transform; enum wl_output_transform transform;
if (strcmp(*argv, "normal") == 0 || if (strcmp(*argv, "normal") == 0 ||
strcmp(*argv, "0") == 0) { strcmp(*argv, "0") == 0) {
@ -32,6 +49,7 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
} else { } else {
return cmd_results_new(CMD_INVALID, "Invalid output transform."); return cmd_results_new(CMD_INVALID, "Invalid output transform.");
} }
struct output_config *output = config->handler_context.output_config; struct output_config *output = config->handler_context.output_config;
config->handler_context.leftovers.argc = argc - 1; config->handler_context.leftovers.argc = argc - 1;
config->handler_context.leftovers.argv = argv + 1; config->handler_context.leftovers.argv = argv + 1;
@ -50,13 +68,14 @@ struct cmd_results *output_cmd_transform(int argc, char **argv) {
"Cannot apply relative transform to unknown output %s", output->name); "Cannot apply relative transform to unknown output %s", output->name);
} }
if (strcmp(argv[1], "anticlockwise") == 0) { if (strcmp(argv[1], "anticlockwise") == 0) {
transform = wlr_output_transform_invert(transform); transform = invert_rotation_direction(transform);
} }
struct wlr_output *w_output = s_output->wlr_output; struct wlr_output *w_output = s_output->wlr_output;
transform = wlr_output_transform_compose(w_output->transform, transform); transform = wlr_output_transform_compose(w_output->transform, transform);
config->handler_context.leftovers.argv += 1; config->handler_context.leftovers.argv += 1;
config->handler_context.leftovers.argc -= 1; config->handler_context.leftovers.argc -= 1;
} }
output->transform = transform; output->transform = transform;
return NULL; return NULL;
} }