From 00477d88297eaa6c87aa144548590c32540e3928 Mon Sep 17 00:00:00 2001 From: Connor Behan Date: Tue, 10 Jun 2014 23:56:12 -0700 Subject: Allow -x and -y switches to undo themselves People who want to dick around might think it is safe to run "xrandr -x" before they know any of the other syntax. When "xrandr -x" again does not get back to a normal screen, they are stuck having to read a manpage with reflected text. Signed-off-by: Connor Behan Reviewed-by: Aaron Plattner Tested-by: Aaron Plattner Signed-off-by: Aaron Plattner --- xrandr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xrandr.c b/xrandr.c index d284f78..db56915 100644 --- a/xrandr.c +++ b/xrandr.c @@ -2571,6 +2571,8 @@ main (int argc, char **argv) Bool provsetoffsink = False; int major, minor; Bool current = False; + Bool toggle_x = False; + Bool toggle_y = False; program_name = argv[0]; for (i = 1; i < argc; i++) { @@ -2639,13 +2641,13 @@ main (int argc, char **argv) } if (!strcmp ("-x", argv[i])) { - reflection |= RR_Reflect_X; + toggle_x = True; setit = True; action_requested = True; continue; } if (!strcmp ("-y", argv[i])) { - reflection |= RR_Reflect_Y; + toggle_y = True; setit = True; action_requested = True; continue; @@ -3824,6 +3826,9 @@ main (int argc, char **argv) { Rotation rotations = XRRConfigRotations(sc, ¤t_rotation); + if (toggle_x && !(current_rotation & RR_Reflect_X)) reflection |= RR_Reflect_X; + if (toggle_y && !(current_rotation & RR_Reflect_Y)) reflection |= RR_Reflect_Y; + if (query) { printf("Current rotation - %s\n", rotation_name (current_rotation)); -- cgit v1.2.3