Skip to content

Commit

Permalink
rename --aftermodifiers to --afterkeys and make it look at all keys
Browse files Browse the repository at this point in the history
  • Loading branch information
scgtrp committed Oct 16, 2022
1 parent b4db1bf commit 0c569e0
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 96 deletions.
16 changes: 8 additions & 8 deletions cmd_click.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int cmd_click(context_t *context) {
char *cmd = context->argv[0];
int ret = 0;
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;
charcodemap_t *active_mods = NULL;
int active_mods_n;
char *window_arg = NULL;
Expand All @@ -15,12 +15,12 @@ int cmd_click(context_t *context) {

int c;
enum {
opt_unused, opt_help, opt_clearmodifiers, opt_aftermodifiers, opt_window, opt_delay,
opt_unused, opt_help, opt_clearmodifiers, opt_afterkeys, opt_window, opt_delay,
opt_repeat
};
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "aftermodifiers", no_argument, NULL, opt_aftermodifiers },
{ "afterkeys", no_argument, NULL, opt_afterkeys },
{ "help", no_argument, NULL, opt_help },
{ "window", required_argument, NULL, opt_window },
{ "delay", required_argument, NULL, opt_delay },
Expand All @@ -30,7 +30,7 @@ int cmd_click(context_t *context) {
static const char *usage =
"Usage: %s [options] <button>\n"
"--clearmodifiers - reset active modifiers (alt, etc) while moving\n"
"--aftermodifiers - wait for modifiers to be released before typing\n"
"--afterkeys - wait for all keys to be released before typing\n"
"--window WINDOW - specify a window to send click to\n"
"--repeat REPEATS - number of times to click. Default is 1\n"
"--delay MILLISECONDS - delay in milliseconds between clicks.\n"
Expand All @@ -55,8 +55,8 @@ int cmd_click(context_t *context) {
clear_modifiers = 1;
break;
case 'a':
case opt_aftermodifiers:
after_modifiers = 1;
case opt_afterkeys:
after_keys = 1;
break;
case 'w':
case opt_window:
Expand Down Expand Up @@ -93,8 +93,8 @@ int cmd_click(context_t *context) {
button = atoi(context->argv[0]);

window_each(context, window_arg, {
if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
12 changes: 6 additions & 6 deletions cmd_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ int cmd_key(context_t *context) {

/* Options */
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;

static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, 'c' },
{ "aftermodifiers", no_argument, NULL, 'a' },
{ "afterkeys", no_argument, NULL, 'a' },
{ "delay", required_argument, NULL, 'd' },
{ "repeat-delay", required_argument, NULL, 'R' },
{ "help", no_argument, NULL, 'h' },
Expand All @@ -38,7 +38,7 @@ int cmd_key(context_t *context) {
static const char *usage =
"Usage: %s [options] <keysequence> [keysequence ...]\n"
"--clearmodifiers - clear active keyboard modifiers during keystrokes\n"
"--aftermodifiers - wait for modifiers to be released before typing\n"
"--afterkeys - wait for all keys to be released before typing\n"
"--delay DELAY - Use DELAY milliseconds between keystrokes\n"
"--repeat TIMES - How many times to repeat the key sequence\n"
"--repeat-delay DELAY - DELAY milliseconds between repetitions\n"
Expand All @@ -65,7 +65,7 @@ int cmd_key(context_t *context) {
clear_modifiers = 1;
break;
case 'a':
after_modifiers = 1;
after_keys = 1;
break;
case 'h':
printf(usage, cmd);
Expand Down Expand Up @@ -121,8 +121,8 @@ int cmd_key(context_t *context) {

int max_arg = context->argc;
window_each(context, window_arg, {
if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
12 changes: 6 additions & 6 deletions cmd_mousedown.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ int cmd_mousedown(context_t *context) {
charcodemap_t *active_mods = NULL;
int active_mods_n;
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;
char *window_arg = NULL;

int c;
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, 'c' },
{ "aftermodifiers", no_argument, NULL, 'a' },
{ "afterkeys", no_argument, NULL, 'a' },
{ "help", no_argument, NULL, 'h' },
{ "window", required_argument, NULL, 'w' },
{ 0, 0, 0, 0 },
Expand All @@ -23,7 +23,7 @@ int cmd_mousedown(context_t *context) {
"Usage: %s [--clearmodifiers] [--window WINDOW] <button>\n"
"--window <windowid> - specify a window to send keys to\n"
"--clearmodifiers - reset active modifiers (alt, etc) while clicking\n"
"--aftermodifiers - wait for modifiers to be released before clicking\n";
"--afterkeys - wait for all keys to be released before clicking\n";

int option_index;

Expand All @@ -34,7 +34,7 @@ int cmd_mousedown(context_t *context) {
clear_modifiers = 1;
break;
case 'a':
after_modifiers = 1;
after_keys = 1;
break;
case 'h':
printf(usage, cmd);
Expand All @@ -61,8 +61,8 @@ int cmd_mousedown(context_t *context) {
button = atoi(context->argv[0]);

window_each(context, window_arg, {
if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
16 changes: 8 additions & 8 deletions cmd_mousemove.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
struct mousemove {
Window window;
int clear_modifiers;
int after_modifiers;
int after_keys;
int opsync;
int polar_coordinates;
int x;
Expand Down Expand Up @@ -33,12 +33,12 @@ int cmd_mousemove(context_t *context) {

int c;
enum {
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_aftermodifiers, opt_polar,
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_afterkeys, opt_polar,
opt_screen, opt_step, opt_delay, opt_window
};
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "aftermodifiers", no_argument, NULL, opt_aftermodifiers },
{ "afterkeys", no_argument, NULL, opt_afterkeys },
{ "help", no_argument, NULL, opt_help},
{ "polar", no_argument, NULL, opt_polar },
{ "screen", required_argument, NULL, opt_screen },
Expand All @@ -51,7 +51,7 @@ int cmd_mousemove(context_t *context) {
static const char *usage =
"Usage: %s [options] <x> <y>\n"
"-c, --clearmodifiers - reset active modifiers (alt, etc) while moving\n"
"-a, --aftermodifiers - wait for modifiers to be released before moving\n"
"-a, --afterkeys - wait for all keys to be released before moving\n"

//"-d, --delay <MS> - sleeptime in milliseconds between steps.\n"
//"--step <STEP> - pixels to move each time along path to x,y.\n" "-p, --polar - Use polar coordinates. X as an angle, Y as distance\n"
Expand All @@ -68,8 +68,8 @@ int cmd_mousemove(context_t *context) {
mousemove.clear_modifiers = 1;
break;
case 'a':
case opt_aftermodifiers:
mousemove.after_modifiers = 1;
case opt_afterkeys:
mousemove.after_keys = 1;
break;
case 'h':
case opt_help:
Expand Down Expand Up @@ -195,8 +195,8 @@ static int _mousemove(context_t *context, struct mousemove *mousemove) {
int mx, my, mscreen;
xdo_get_mouse_location(context->xdo, &mx, &my, &mscreen);

if (mousemove->after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (mousemove->after_keys) {
xdo_wait_for_key_release(context->xdo);
}

if (mousemove->clear_modifiers) {
Expand Down
14 changes: 7 additions & 7 deletions cmd_mousemove_relative.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ int cmd_mousemove_relative(context_t *context) {
char *cmd = *context->argv;
int polar_coordinates = 0;
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;
int opsync = 0;
int origin_x = -1, origin_y = -1;

charcodemap_t *active_mods = NULL;
int active_mods_n;
int c;
enum {
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_aftermodifiers, opt_polar
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_afterkeys, opt_polar
};
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
{ "polar", no_argument, NULL, opt_polar },
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "aftermodifiers", no_argument, NULL, opt_aftermodifiers },
{ "afterkeys", no_argument, NULL, opt_afterkeys },
{ 0, 0, 0, 0 },
};
static const char *usage =
"Usage: %s [options] <x> <y>\n"
"-c, --clearmodifiers - reset active modifiers (alt, etc) while moving\n"
"-a, --aftermodifiers - wait for modifiers to be released before moving\n"
"-a, --afterkeys - wait for all keys to be released before moving\n"
"-p, --polar - Use polar coordinates. X as an angle, Y as distance\n"
"--sync - only exit once the mouse has moved\n"
"\n"
Expand Down Expand Up @@ -63,7 +63,7 @@ int cmd_mousemove_relative(context_t *context) {
clear_modifiers = 1;
break;
case 'a':
case opt_aftermodifiers:
case opt_afterkeys:
clear_modifiers = 1;
break;
default:
Expand Down Expand Up @@ -102,8 +102,8 @@ int cmd_mousemove_relative(context_t *context) {
y = (-sin(radians) * distance);
}

if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
12 changes: 6 additions & 6 deletions cmd_mouseup.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ int cmd_mouseup(context_t *context) {
charcodemap_t *active_mods = NULL;
int active_mods_n;
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;

int c;
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, 'c' },
{ "aftermodifiers", no_argument, NULL, 'a' },
{ "afterkeys", no_argument, NULL, 'a' },
{ "help", no_argument, NULL, 'h' },
{ "window", required_argument, NULL, 'w' },
{ 0, 0, 0, 0 },
Expand All @@ -23,7 +23,7 @@ int cmd_mouseup(context_t *context) {
"Usage: %s [--clearmodifiers] [--window WINDOW] <button>\n"
"--window <windowid> - specify a window to send keys to\n"
"--clearmodifiers - reset active modifiers (alt, etc) while clicking\n"
"--aftermodifiers - wait for modifiers to be released before clicking\n";
"--afterkeys - wait for all keys to be released before clicking\n";
int option_index;

while ((c = getopt_long_only(context->argc, context->argv, "+caw:h",
Expand All @@ -38,7 +38,7 @@ int cmd_mouseup(context_t *context) {
clear_modifiers = 1;
break;
case 'a':
after_modifiers = 1;
after_keys = 1;
break;
case 'w':
window_arg = strdup(optarg);
Expand All @@ -60,8 +60,8 @@ int cmd_mouseup(context_t *context) {
button = atoi(context->argv[0]);

window_each(context, window_arg, {
if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
16 changes: 8 additions & 8 deletions cmd_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ int cmd_type(context_t *context) {

/* Options */
int clear_modifiers = 0;
int after_modifiers = 0;
int after_keys = 0;
useconds_t delay = 12000; /* 12ms between keystrokes default */

enum {
opt_unused, opt_clearmodifiers, opt_aftermodifiers, opt_delay, opt_help,
opt_unused, opt_clearmodifiers, opt_afterkeys, opt_delay, opt_help,
opt_window, opt_args, opt_terminator, opt_file
};

struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "aftermodifiers", no_argument, NULL, opt_aftermodifiers },
{ "afterkeys", no_argument, NULL, opt_afterkeys },
{ "delay", required_argument, NULL, opt_delay },
{ "help", no_argument, NULL, opt_help },
{ "window", required_argument, NULL, opt_window },
Expand All @@ -52,7 +52,7 @@ int cmd_type(context_t *context) {
"--window <windowid> - specify a window to send keys to\n"
"--delay <milliseconds> - delay between keystrokes\n"
"--clearmodifiers - reset active modifiers (alt, etc) while typing\n"
"--aftermodifiers - wait for modifiers to be released before typing\n"
"--afterkeys - wait for all keys to be released before typing\n"
"--args N - how many arguments to expect in the exec command. This is\n"
" useful for ending an exec and continuing with more xdotool\n"
" commands\n"
Expand All @@ -79,8 +79,8 @@ int cmd_type(context_t *context) {
case opt_clearmodifiers:
clear_modifiers = 1;
break;
case opt_aftermodifiers:
after_modifiers = 1;
case opt_afterkeys:
after_keys = 1;
break;
case opt_help:
printf(usage, cmd);
Expand Down Expand Up @@ -186,8 +186,8 @@ int cmd_type(context_t *context) {
}

window_each(context, window_arg, {
if (after_modifiers) {
xdo_wait_for_modifier_release(context->xdo);
if (after_keys) {
xdo_wait_for_key_release(context->xdo);
}
if (clear_modifiers) {
xdo_get_active_modifiers(context->xdo, &active_mods, &active_mods_n);
Expand Down
Loading

0 comments on commit 0c569e0

Please sign in to comment.