Changeset 1085
- Timestamp:
- Jun 3, 2008 9:59:00 AM (5 years ago)
- Location:
- branches/upstream/xdotool/current
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/upstream/xdotool/current/CHANGELIST
r1077 r1085 1 20080603: 2 * Daniel Kahn Gillmor reported a problem with return codes from xdotool. All 3 commands return proper exit status now (0 == success, nonzero == error) 4 * I tested on 3 window managers: Gnome2 2.20.0, OpenBox 3.4, ion-3rc-20070608 5 - Gnome and OpenBox pass all tests. 6 - ion-3 fails on any desktop-related methods (ion-3 lacks the support). 7 1 8 20080601: 2 9 * Add new commands: … … 24 31 incorrectly typecasting Window to int sometimes. 25 32 * Confirmed that the one (but mostly useless) test passes. 33 34 20071230: 35 * Manpage contribution by Daniel Kahn Gillmor 36 * Add COPYRIGHT from svn to the distributed package. 26 37 27 38 20070903: … … 53 64 (with menus enabled). 54 65 55 56 66 20070712: 57 67 Added new search options to 'xdotool search' -
branches/upstream/xdotool/current/Makefile
r1077 r1085 37 37 rm -f $(INSTALLMAN)/man1/xdotool.1 38 38 39 40 39 clean: 41 rm -f *.o || true40 rm -f *.o xdotool xdotool.1 || true 42 41 43 42 xdo.o: xdo.c … … 58 57 package: test-package-build create-package 59 58 60 create-package: xdotool.159 create-package: 61 60 @NAME=xdotool-`date +%Y%m%d`; \ 62 61 echo "Creating package: $$NAME"; \ 63 62 mkdir $${NAME}; \ 64 rsync --exclude .svn -a `ls -d *. 1 *.pod COPYRIGHT *.c *.h examples t CHANGELIST README Makefile* 2> /dev/null` $${NAME}/; \63 rsync --exclude .svn -a `ls -d *.pod COPYRIGHT *.c *.h examples t CHANGELIST README Makefile* 2> /dev/null` $${NAME}/; \ 65 64 tar -zcf $${NAME}.tar.gz $${NAME}/; \ 66 65 rm -rf $${NAME}/ -
branches/upstream/xdotool/current/README
r1071 r1085 4 4 ### See the website for more up-to-date documentation 5 5 # http://www.semicomplete.com/projects/xdotool/ 6 # 7 # Also see the manpage, which you can generate by running: 8 # make xdotool.1 6 9 7 10 Compile: make xdotool … … 31 34 See 'xwininfo' output for what each of these are/mean. 32 35 33 $Id: README 1 520 2007-08-12 23:51:17Z psionic$36 $Id: README 1892 2008-06-03 09:04:59Z jordansissel $ -
branches/upstream/xdotool/current/t/no_crashes_please.sh
r1077 r1085 22 22 xterm_pid="$!" 23 23 24 sleep 1 25 24 26 try $xdotool search xdotool_test_window 25 27 try $xdotool getwindowfocus … … 44 46 45 47 try $xdotool windowactivate $wid 48 sleep 0.2 46 49 47 try $xdotool get_num_desktops $wid48 desktops=`$xdotool get_num_desktops $wid`50 try $xdotool get_num_desktops 51 desktops=`$xdotool get_num_desktops` 49 52 try $xdotool set_num_desktops $desktops 50 53 -
branches/upstream/xdotool/current/xdo.c
r1077 r1085 1 1 /* xdo library 2 2 * 3 * $Id: xdo.c 18 78 2008-06-01 00:31:53Z jordansissel $3 * $Id: xdo.c 1891 2008-06-03 09:00:20Z jordansissel $ 4 4 * 5 5 * - getwindowfocus contributed by Lee Pumphret … … 106 106 ret = XMapWindow(xdo->xdpy, wid); 107 107 XFlush(xdo->xdpy); 108 return _is_success("XMapWindow", ret );108 return _is_success("XMapWindow", ret == 0); 109 109 } 110 110 … … 113 113 ret = XUnmapWindow(xdo->xdpy, wid); 114 114 XFlush(xdo->xdpy); 115 return _is_success("X MapWindow", ret);116 } 117 118 voidxdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,115 return _is_success("XUnmapWindow", ret == 0); 116 } 117 118 int xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags, 119 119 Window **windowlist, int *nwindows) { 120 120 regex_t re; … … 130 130 if (ret != 0) { 131 131 fprintf(stderr, "Failed to compile regex: '%s'\n", regex); 132 return ;132 return 1; 133 133 } 134 134 … … 166 166 167 167 regfree(&re); 168 return 0; 168 169 } 169 170 … … 175 176 176 177 ret = XConfigureWindow(xdo->xdpy, wid, CWX | CWY, &wc); 177 return _is_success("XConfigureWindow", ret );178 return _is_success("XConfigureWindow", ret == 0); 178 179 } 179 180 … … 212 213 ret = XConfigureWindow(xdo->xdpy, wid, cw_flags, &wc); 213 214 XFlush(xdo->xdpy); 214 return _is_success("XConfigureWindow", ret );215 return _is_success("XConfigureWindow", ret == 0); 215 216 } 216 217 … … 219 220 ret = XSetInputFocus(xdo->xdpy, wid, RevertToParent, CurrentTime); 220 221 XFlush(xdo->xdpy); 221 return _is_success("XSetInputFocus", ret );222 return _is_success("XSetInputFocus", ret == 0); 222 223 } 223 224 … … 227 228 XEvent xev; 228 229 XWindowAttributes wattr; 230 231 if (_xdo_ewmh_is_supported(xdo, "_NET_ACTIVE_WINDOW") == False) { 232 fprintf(stderr, 233 "Your windowmanager claims not to support _NET_ACTIVE_WINDOW, " 234 "so the attempt to activate the window was aborted.\n"); 235 return 1; 236 } 229 237 230 238 /* If this window is on another desktop, let's go to that desktop first */ … … 252 260 /* XXX: XSendEvent returns 0 on conversion failure, nonzero otherwise. 253 261 * Manpage says it will only generate BadWindow or BadValue errors */ 254 return _is_success("XSendEvent[EWMH:_NET_ACTIVE_WINDOW]", ret); 262 printf("netact:%d\n", ret); 263 return _is_success("XSendEvent[EWMH:_NET_ACTIVE_WINDOW]", ret == 0); 255 264 } 256 265 … … 260 269 Window root; 261 270 int ret; 271 272 if (_xdo_ewmh_is_supported(xdo, "_NET_NUMBER_OF_DESKTOPS") == False) { 273 fprintf(stderr, 274 "Your windowmanager claims not to support _NET_NUMBER_OF_DESKTOPS, " 275 "so the attempt to change the number of desktops was aborted.\n"); 276 return 1; 277 } 262 278 263 279 root = RootWindow(xdo->xdpy, 0); … … 276 292 &xev); 277 293 278 return _is_success("XSendEvent[EWMH:_NET_NUMBER_OF_DESKTOPS]", ret );294 return _is_success("XSendEvent[EWMH:_NET_NUMBER_OF_DESKTOPS]", ret == 0); 279 295 } 280 296 … … 285 301 unsigned char *data; 286 302 Window root; 287 288 303 Atom request; 304 305 if (_xdo_ewmh_is_supported(xdo, "_NET_NUMBER_OF_DESKTOPS") == False) { 306 fprintf(stderr, 307 "Your windowmanager claims not to support _NET_NUMBER_OF_DESKTOPS, " 308 "so the attempt to query the number of desktops was aborted.\n"); 309 return 1; 310 } 289 311 290 312 request = XInternAtom(xdo->xdpy, "_NET_NUMBER_OF_DESKTOPS", False); … … 310 332 311 333 root = RootWindow(xdo->xdpy, 0); 334 335 if (_xdo_ewmh_is_supported(xdo, "_NET_CURRENT_DESKTOP") == False) { 336 fprintf(stderr, 337 "Your windowmanager claims not to support _NET_CURRENT_DESKTOP, " 338 "so the attempt to change desktops was aborted.\n"); 339 return 1; 340 } 312 341 313 342 memset(&xev, 0, sizeof(xev)); … … 325 354 &xev); 326 355 327 return _is_success("XSendEvent[EWMH:_NET_CURRENT_DESKTOP]", ret );356 return _is_success("XSendEvent[EWMH:_NET_CURRENT_DESKTOP]", ret == 0); 328 357 } 329 358 … … 337 366 Atom request; 338 367 368 if (_xdo_ewmh_is_supported(xdo, "_NET_CURRENT_DESKTOP") == False) { 369 fprintf(stderr, 370 "Your windowmanager claims not to support _NET_CURRENT_DESKTOP, " 371 "so the query for the current desktop was aborted.\n"); 372 return 1; 373 } 374 339 375 request = XInternAtom(xdo->xdpy, "_NET_CURRENT_DESKTOP", False); 340 376 root = XDefaultRootWindow(xdo->xdpy); … … 356 392 XWindowAttributes wattr; 357 393 XGetWindowAttributes(xdo->xdpy, wid, &wattr); 394 395 if (_xdo_ewmh_is_supported(xdo, "_NET_WM_DESKTOP") == False) { 396 fprintf(stderr, 397 "Your windowmanager claims not to support _NET_WM_DESKTOP, " 398 "so the attempt to change a window's desktop location was " 399 "aborted.\n"); 400 return 1; 401 } 358 402 359 403 memset(&xev, 0, sizeof(xev)); … … 371 415 &xev); 372 416 373 return _is_success("XSendEvent[EWMH:_NET_WM_DESKTOP]", ret );417 return _is_success("XSendEvent[EWMH:_NET_WM_DESKTOP]", ret == 0); 374 418 } 375 419 … … 379 423 long nitems; 380 424 unsigned char *data; 381 382 425 Atom request; 426 427 if (_xdo_ewmh_is_supported(xdo, "_NET_WM_DESKTOP") == False) { 428 fprintf(stderr, 429 "Your windowmanager claims not to support _NET_WM_DESKTOP, " 430 "so the attempt to query a window's desktop location was " 431 "aborted.\n"); 432 return 1; 433 } 383 434 384 435 request = XInternAtom(xdo->xdpy, "_NET_WM_DESKTOP", False); … … 408 459 ret = XTestFakeMotionEvent(xdo->xdpy, -1, x, y, CurrentTime); 409 460 XFlush(xdo->xdpy); 410 return _is_success("XTestFakeMotionEvent", ret );461 return _is_success("XTestFakeMotionEvent", ret == 0); 411 462 } 412 463 … … 415 466 ret = XTestFakeRelativeMotionEvent(xdo->xdpy, x, y, CurrentTime); 416 467 XFlush(xdo->xdpy); 417 return _is_success("XTestFakeRelativeMotionEvent", ret );468 return _is_success("XTestFakeRelativeMotionEvent", ret == 0); 418 469 } 419 470 … … 422 473 ret = XTestFakeButtonEvent(xdo->xdpy, button, True, CurrentTime); 423 474 XFlush(xdo->xdpy); 424 return _is_success("XTestFakeButtonEvent ", ret);475 return _is_success("XTestFakeButtonEvent(down)", ret == 0); 425 476 } 426 477 … … 429 480 ret = XTestFakeButtonEvent(xdo->xdpy, button, False, CurrentTime); 430 481 XFlush(xdo->xdpy); 431 return _is_success("XTestFake KeyEvent", ret);482 return _is_success("XTestFakeButtonEvent(up)", ret == 0); 432 483 } 433 484 … … 435 486 int ret; 436 487 ret = xdo_mousedown(xdo, button); 437 if ( !ret)488 if (ret) 438 489 return ret; 439 490 ret = xdo_mouseup(xdo, button); 440 491 return ret; 441 442 /* no need to flush here */443 492 } 444 493 … … 450 499 int shiftcode = 0; 451 500 501 /* XXX: Add error handling */ 452 502 for (i = 0; string[i] != '\0'; i++) { 453 503 key = string[i]; … … 466 516 } 467 517 468 return True;518 return 0; 469 519 } 470 520 471 521 int _xdo_keysequence_do(xdo_t *xdo, char *keyseq, int pressed) { 522 int ret = 0; 472 523 int *keys = NULL; 473 524 int nkeys; … … 480 531 481 532 for (i = 0; i < nkeys; i++) { 482 //fprintf(stderr, "Typing %d (%d)\n", keys[i], pressed); 483 XTestFakeKeyEvent(xdo->xdpy, keys[i], pressed, CurrentTime); 533 ret += !XTestFakeKeyEvent(xdo->xdpy, keys[i], pressed, CurrentTime); 484 534 } 485 535 486 536 free(keys); 487 537 XFlush(xdo->xdpy); 488 return True;538 return ret; 489 539 } 490 540 … … 498 548 499 549 int xdo_keysequence(xdo_t *xdo, char *keyseq) { 500 _xdo_keysequence_do(xdo, keyseq, True); 501 _xdo_keysequence_do(xdo, keyseq, False); 502 return True; 550 int ret; 551 ret += _xdo_keysequence_do(xdo, keyseq, True); 552 ret += _xdo_keysequence_do(xdo, keyseq, False); 553 return ret; 503 554 } 504 555 … … 509 560 int unused_revert_ret; 510 561 ret = XGetInputFocus(xdo->xdpy, window_ret, &unused_revert_ret); 511 return _is_success("XGetInputFocus", ret );562 return _is_success("XGetInputFocus", ret == 0); 512 563 } 513 564 … … 731 782 732 783 int _is_success(const char *funcname, int code) { 733 if (code == BadMatch) { 734 fprintf(stderr, "%s failed: got bad match\n", funcname); 735 return False; 736 } else if (code == BadValue) { 737 fprintf(stderr, "%s failed: got bad value\n", funcname); 738 return False; 739 } else if (code == BadWindow) { 740 fprintf(stderr, "%s failed: got bad window\n", funcname); 741 return False; 742 } else if (code != 1) { 784 if (code != 0) 743 785 fprintf(stderr, "%s failed (code=%d)\n", funcname, code); 744 return False; 745 } 746 747 return True; 786 return code; 748 787 } 749 788 -
branches/upstream/xdotool/current/xdo.h
r1077 r1085 3 3 * - include this if you have code that uses xdo 4 4 * 5 * $Id: xdo.h 18 76 2008-05-31 10:54:25Z jordansissel $5 * $Id: xdo.h 1891 2008-06-03 09:00:20Z jordansissel $ 6 6 */ 7 7 … … 77 77 78 78 /* Returns: windowlist and nwindows */ 79 voidxdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,80 Window **windowlist, int *nwindows);79 int xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags, 80 Window **windowlist, int *nwindows); -
branches/upstream/xdotool/current/xdotool.c
r1077 r1085 3 3 * command line interface to the xdo library 4 4 * 5 * $Id: xdotool.c 18 80 2008-06-01 07:23:14Z jordansissel $5 * $Id: xdotool.c 1891 2008-06-03 09:00:20Z jordansissel $ 6 6 * 7 7 * getwindowfocus contributed by Lee Pumphret … … 20 20 #include "xdo.h" 21 21 22 voidcmd_click(int argc, char **args);23 voidcmd_getwindowfocus(int argc, char **args);24 voidcmd_help(int argc, char **args);25 voidcmd_key(int argc, char **args);26 voidcmd_mousedown(int argc, char **args);27 voidcmd_mousemove(int argc, char **args);28 voidcmd_mousemove_relative(int argc, char **args);29 voidcmd_mouseup(int argc, char **args);30 voidcmd_search(int argc, char **args);31 voidcmd_type(int argc, char **args);32 voidcmd_windowactivate(int argc, char **args);33 voidcmd_windowfocus(int argc, char **args);34 voidcmd_windowmap(int argc, char **args);35 voidcmd_windowmove(int argc, char **args);36 voidcmd_windowraise(int argc, char **args);37 voidcmd_windowsize(int argc, char **args);38 voidcmd_windowunmap(int argc, char **args);22 int cmd_click(int argc, char **args); 23 int cmd_getwindowfocus(int argc, char **args); 24 int cmd_help(int argc, char **args); 25 int cmd_key(int argc, char **args); 26 int cmd_mousedown(int argc, char **args); 27 int cmd_mousemove(int argc, char **args); 28 int cmd_mousemove_relative(int argc, char **args); 29 int cmd_mouseup(int argc, char **args); 30 int cmd_search(int argc, char **args); 31 int cmd_type(int argc, char **args); 32 int cmd_windowactivate(int argc, char **args); 33 int cmd_windowfocus(int argc, char **args); 34 int cmd_windowmap(int argc, char **args); 35 int cmd_windowmove(int argc, char **args); 36 int cmd_windowraise(int argc, char **args); 37 int cmd_windowsize(int argc, char **args); 38 int cmd_windowunmap(int argc, char **args); 39 39 40 40 /* pager-like commands */ 41 voidcmd_set_num_desktops(int argc, char **args);42 voidcmd_get_num_desktops(int argc, char **args);43 voidcmd_set_desktop(int argc, char **args);44 voidcmd_get_desktop(int argc, char **args);45 voidcmd_set_desktop_for_window(int argc, char **args);46 voidcmd_get_desktop_for_window(int argc, char **args);41 int cmd_set_num_desktops(int argc, char **args); 42 int cmd_get_num_desktops(int argc, char **args); 43 int cmd_set_desktop(int argc, char **args); 44 int cmd_get_desktop(int argc, char **args); 45 int cmd_set_desktop_for_window(int argc, char **args); 46 int cmd_get_desktop_for_window(int argc, char **args); 47 47 48 48 xdo_t *xdo; … … 51 51 struct dispatch { 52 52 const char *name; 53 void(*func)(int argc, char **args);53 int (*func)(int argc, char **args); 54 54 } dispatch[] = { 55 55 /* Query functions */ … … 90 90 int main(int argc, char **argv) { 91 91 char *cmd; 92 int ret = 0; 92 93 int i; 93 94 … … 109 110 for (i = 0; dispatch[i].name != NULL; i++) { 110 111 if (!strcasecmp(dispatch[i].name, cmd)) { 111 dispatch[i].func(argc, argv);112 ret = dispatch[i].func(argc, argv); 112 113 break; 113 114 } … … 115 116 116 117 xdo_free(xdo); 117 return 0;118 return ret; 118 119 } 119 120 … … 123 124 } 124 125 125 voidcmd_help(int argc, char **args) {126 int cmd_help(int argc, char **args) { 126 127 int i; 127 128 printf("Available commands:\n"); 128 129 for (i = 0; dispatch[i].name != NULL; i++) 129 130 printf(" %s\n", dispatch[i].name); 130 } 131 132 void cmd_mousemove(int argc, char **args) { 131 132 return 0; 133 } 134 135 int cmd_mousemove(int argc, char **args) { 136 int ret = 0; 133 137 int x, y; 134 138 char *cmd = *args; argc--; args++; … … 137 141 fprintf(stderr, "usage: %s <xcoord> <ycoord>\n", cmd); 138 142 fprintf(stderr, "You specified the wrong number of args.\n"); 139 return ;143 return 1; 140 144 } 141 145 … … 143 147 y = atoi(args[1]); 144 148 145 if (!xdo_mousemove(xdo, x, y)) { 149 ret = xdo_mousemove(xdo, x, y); 150 151 if (ret) 146 152 fprintf(stderr, "xdo_mousemove reported an error\n"); 147 } 148 } 149 150 void cmd_mousemove_relative(int argc, char **args) { 153 154 return ret; 155 } 156 157 int cmd_mousemove_relative(int argc, char **args) { 151 158 int x, y; 159 int ret = 0; 152 160 char *cmd = *args; argc--; args++; 153 161 … … 155 163 fprintf(stderr, "usage: %s <xcoord> <ycoord>\n", cmd); 156 164 fprintf(stderr, "You specified the wrong number of args.\n"); 157 return ;165 return 1; 158 166 } 159 167 … … 161 169 y = atoi(args[1]); 162 170 163 if (!xdo_mousemove_relative(xdo, x, y)) { 171 ret = xdo_mousemove_relative(xdo, x, y); 172 173 if (ret) 164 174 fprintf(stderr, "xdo_mousemove_relative reported an error\n"); 165 } 166 } 167 168 void cmd_mousedown(int argc, char **args) { 175 176 return ret; 177 } 178 179 int cmd_mousedown(int argc, char **args) { 180 int ret = 0; 169 181 int button; 170 182 char *cmd = *args; argc--; args++; … … 173 185 fprintf(stderr, "usage: %s <button>\n", cmd); 174 186 fprintf(stderr, "You specified the wrong number of args.\n"); 175 return ;187 return 1; 176 188 } 177 189 178 190 button = atoi(args[0]); 179 191 180 if (!xdo_mousedown(xdo, button)) { 192 ret = xdo_mousedown(xdo, button); 193 194 if (ret) 181 195 fprintf(stderr, "xdo_mousedown reported an error\n"); 182 } 183 } 184 185 void cmd_mouseup(int argc, char **args) { 196 197 return ret; 198 } 199 200 int cmd_mouseup(int argc, char **args) { 201 int ret = 0; 186 202 int button; 187 203 char *cmd = *args; argc--; args++; … … 190 206 fprintf(stderr, "usage: %s <button>\n", cmd); 191 207 fprintf(stderr, "You specified the wrong number of args.\n"); 192 return ;208 return 1; 193 209 } 194 210 195 211 button = atoi(args[0]); 196 212 197 if (!xdo_mouseup(xdo, button)) { 213 ret = xdo_mouseup(xdo, button); 214 if (ret) 198 215 fprintf(stderr, "xdo_mouseup reported an error\n"); 199 } 200 } 201 202 void cmd_click(int argc, char **args) { 203 cmd_mousedown(argc, args); 204 cmd_mouseup(argc, args); 205 } 206 207 void cmd_type(int argc, char **args) { 216 217 return ret; 218 } 219 220 int cmd_click(int argc, char **args) { 221 int button; 222 char *cmd = *args; argc--; args++; 223 224 if (argc != 1) { 225 fprintf(stderr, "usage: %s <button>\n", cmd); 226 fprintf(stderr, "You specified the wrong number of args.\n"); 227 return 1; 228 } 229 230 button = atoi(args[0]); 231 return xdo_click(xdo, button); 232 } 233 234 int cmd_type(int argc, char **args) { 235 int ret = 0; 208 236 int i; 209 237 char *cmd = *args; argc--; args++; … … 212 240 fprintf(stderr, "usage: %s <things to type>\n", cmd); 213 241 fprintf(stderr, "You specified the wrong number of args.\n"); 214 return ;242 return 1; 215 243 } 216 244 217 245 for (i = 0; i < argc; i++) { 218 if (!xdo_type(xdo, args[i])) { 246 int tmp = xdo_type(xdo, args[i]); 247 248 if (tmp) { 219 249 fprintf(stderr, "xdo_type reported an error\n"); 220 250 } 221 } 222 } 223 224 void cmd_key(int argc, char **args) { 251 252 ret += tmp; 253 } 254 255 return ret > 0; 256 } 257 258 int cmd_key(int argc, char **args) { 259 int ret = 0; 225 260 int i; 226 261 char *cmd = *args; argc--; args++; … … 229 264 fprintf(stderr, "usage: %s <keyseq1> [keyseq2 ... keyseqN]\n", cmd); 230 265 fprintf(stderr, "You specified the wrong number of args.\n"); 231 return ;266 return 1; 232 267 } 233 268 … … 242 277 } else { 243 278 fprintf(stderr, "Unknown command '%s'\n", cmd); 244 return ;279 return 1; 245 280 } 246 281 247 282 for (i = 0; i < argc; i++) { 248 if (!func(xdo, args[i])) 283 int tmp = func(xdo, args[i]); 284 if (tmp != 0) 249 285 fprintf(stderr, "xdo_keysequence reported an error for string '%s'\n", args[i]); 250 } 251 } 252 253 void cmd_windowmove(int argc, char **args) { 286 ret += tmp; 287 } 288 289 return ret; 290 } 291 292 int cmd_windowmove(int argc, char **args) { 293 int ret = 0; 254 294 int x, y; 255 295 Window wid; … … 258 298 if (argc != 3) { 259 299 printf("usage: %s wid x y\n", cmd); 260 return ;300 return 1; 261 301 } 262 302 … … 265 305 y = (int)strtol(args[2], NULL, 0); 266 306 267 if (!xdo_window_move(xdo, wid, x, y)) { 268 fprintf(stderr, "xdo_window_mvoe reported an error\n"); 269 } 270 } 271 272 void cmd_windowactivate(int argc, char **args) { 307 ret = xdo_window_move(xdo, wid, x, y); 308 if (ret) 309 fprintf(stderr, "xdo_window_move reported an error\n"); 310 311 return ret; 312 } 313 314 int cmd_windowactivate(int argc, char **args) { 315 int ret = 0; 273 316 Window wid; 274 317 char *cmd = *args; argc--; args++; … … 276 319 if (argc != 1) { 277 320 printf("usage: %s wid\n", cmd); 278 return ;321 return 1; 279 322 } 280 323 281 324 wid = (Window)strtol(args[0], NULL, 0); 282 if (!xdo_window_activate(xdo, wid)) { 325 ret = xdo_window_activate(xdo, wid); 326 327 if (ret) 283 328 fprintf(stderr, "xdo_window_activate reported an error\n"); 284 return; 285 }286 287 } 288 289 void cmd_windowfocus(int argc, char **args) { 329 330 return ret; 331 } 332 333 int cmd_windowfocus(int argc, char **args) { 334 int ret = 0; 290 335 Window wid; 291 336 char *cmd = *args; argc--; args++; … … 293 338 if (argc != 1) { 294 339 printf("usage: %s wid\n", cmd); 295 return ;340 return 1; 296 341 } 297 342 298 343 wid = (Window)strtol(args[0], NULL, 0); 299 if (!xdo_window_focus(xdo, wid)) { 344 ret = xdo_window_focus(xdo, wid); 345 if (ret) 300 346 fprintf(stderr, "xdo_window_focus reported an error\n"); 301 } 302 } 303 304 void cmd_windowraise(int argc, char **args) { 347 348 return ret; 349 } 350 351 int cmd_windowraise(int argc, char **args) { 352 int ret = 0; 305 353 Window wid; 306 354 char *cmd = *args; argc--; args++; … … 308 356 if (argc != 1) { 309 357 printf("usage: %s wid\n", cmd); 310 return ;311 }358 return 1; 359 } 312 360 313 361 wid = (Window)strtol(args[0], NULL, 0); 314 if (!xdo_window_raise(xdo, wid)) { 362 ret = xdo_window_raise(xdo, wid); 363 if (ret) 315 364 fprintf(stderr, "xdo_window_raise reported an error\n"); 316 } 317 } 318 319 void cmd_windowsize(int argc, char **args) { 365 366 return ret; 367 } 368 369 int cmd_windowsize(int argc, char **args) { 370 int ret = 0; 320 371 int width, height; 321 372 Window wid; … … 348 399 if (argc != 3) { 349 400 printf("usage: %s wid width height\n", cmd); 350 return ;401 return 1; 351 402 } 352 403 … … 355 406 height = (int)strtol(args[2], NULL, 0); 356 407 357 if (!xdo_window_setsize(xdo, wid, width, height, size_flags)) { 408 ret = xdo_window_setsize(xdo, wid, width, height, size_flags); 409 if (ret) 358 410 fprintf(stderr, "xdo_window_setsize reported an error\n"); 359 }360 } 361 362 voidcmd_search(int argc, char **args) {411 return ret; 412 } 413 414 int cmd_search(int argc, char **args) { 363 415 Window *list; 364 416 int nwindows; … … 405 457 if (argc != 1) { 406 458 printf( 407 "Usage: xdotool %s "408 "[--onlyvisible] [--title --class --name] regexp_pattern\n"409 " --onlyvisible matches only windows currently visible\n"410 " --title check regexp_pattern agains the window title\n"411 " --class check regexp_pattern agains the window class\n"412 " --name check regexp_pattern agains the window name\n"413 "\n"414 "* If none of --title, --class, and --name are specified,\n"415 "the defaults are to match any of them.\n",416 cmd);417 return ;459 "Usage: xdotool %s " 460 "[--onlyvisible] [--title --class --name] regexp_pattern\n" 461 " --onlyvisible matches only windows currently visible\n" 462 " --title check regexp_pattern agains the window title\n" 463 " --class check regexp_pattern agains the window class\n" 464 " --name check regexp_pattern agains the window name\n" 465 "\n" 466 "* If none of --title, --class, and --name are specified,\n" 467 "the defaults are to match any of them.\n", 468 cmd); 469 return 1; 418 470 } 419 471 … … 424 476 /* Free list as it's malloc'd by xdo_window_list_by_regex */ 425 477 free(list); 478 479 /* error if number of windows found is zero (behave like grep) */ 480 return !nwindows; 426 481 } 427 482 428 483 /* Added 2007-07-28 - Lee Pumphret */ 429 void cmd_getwindowfocus(int argc, char **args) { 484 int cmd_getwindowfocus(int argc, char **args) { 485 int ret = 0; 430 486 Window wid = 0; 431 487 char *cmd = *args; argc--; args++; … … 433 489 if (argc != 0) { 434 490 printf("usage: %s\n", cmd); 435 return; 436 } 437 438 if (!xdo_window_get_focus(xdo, &wid)) { 491 return 1; 492 } 493 494 ret = xdo_window_get_focus(xdo, &wid); 495 496 if (ret) { 439 497 fprintf(stderr, "xdo_window_focus reported an error\n"); 440 } else { 498 } else { 441 499 window_print(wid); 442 500 } 443 } 444 445 void cmd_windowmap(int argc, char **args) { 501 502 return ret; 503 } 504 505 int cmd_windowmap(int argc, char **args) { 506 int ret = 0; 446 507 Window wid; 447 508 char *cmd = *args; argc--; args++; … … 449 510 if (argc != 1) { 450 511 printf("usage: %s wid\n", cmd); 451 return ;512 return 1; 452 513 } 453 514 454 515 wid = (Window)strtol(args[0], NULL, 0); 455 if (!xdo_window_map(xdo, wid)) { 516 ret = xdo_window_map(xdo, wid); 517 if (ret) 456 518 fprintf(stderr, "xdo_window_map reported an error\n"); 457 } 458 } 459 460 void cmd_windowunmap(int argc, char **args) { 519 520 return ret; 521 } 522 523 int cmd_windowunmap(int argc, char **args) { 524 int ret = 0; 461 525 Window wid; 462 526 char *cmd = *args; argc--; args++; … … 464 528 if (argc != 1) { 465 529 printf("usage: %s wid\n", cmd); 466 return ;530 return 1; 467 531 } 468 532 469 533 wid = (Window)strtol(args[0], NULL, 0); 470 if (!xdo_window_unmap(xdo, wid)) { 534 ret = xdo_window_unmap(xdo, wid); 535 if (ret) 471 536 fprintf(stderr, "xdo_window_unmap reported an error\n"); 472 } 473 } 474 475 void cmd_set_num_desktops(int argc, char **args) { 537 538 return ret; 539 } 540 541 int cmd_set_num_desktops(int argc, char **args) { 476 542 char *cmd = *args; argc--; args++; 477 543 long ndesktops; … … 479 545 if (argc != 1) { 480 546 printf("usage: %s num_desktops\n", cmd); 481 return ;547 return 1; 482 548 } 483 549 484 550 ndesktops = strtol(args[0], NULL, 0); 485 551 486 xdo_set_number_of_desktops(xdo, ndesktops); 487 } 488 489 void cmd_get_num_desktops(int argc, char **args) { 552 return xdo_set_number_of_desktops(xdo, ndesktops); 553 } 554 555 int cmd_get_num_desktops(int argc, char **args) { 556 int ret = 0; 490 557 char *cmd = *args; argc--; args++; 491 558 long ndesktops = 0; … … 493 560 if (argc != 0) { 494 561 printf("usage: %s\n", cmd); 495 return ;496 } 497 498 xdo_get_number_of_desktops(xdo, &ndesktops);562 return 1; 563 } 564 565 ret = xdo_get_number_of_desktops(xdo, &ndesktops); 499 566 500 567 printf("%ld\n", ndesktops); 501 } 502 503 void cmd_set_desktop(int argc, char **args) { 568 return ret; 569 } 570 571 int cmd_set_desktop(int argc, char **args) { 504 572 char *cmd = *args; argc--; args++; 505 573 long desktop; … … 507 575 if (argc != 1) { 508 576 printf("usage: %s desktop\n", cmd); 509 return ;577 return 1; 510 578 } 511 579 512 580 desktop = strtol(args[0], NULL, 0); 513 581 514 xdo_set_current_desktop(xdo, desktop); 515 } 516 517 void cmd_get_desktop(int argc, char **args) { 582 return xdo_set_current_desktop(xdo, desktop); 583 } 584 585 int cmd_get_desktop(int argc, char **args) { 586 int ret = 0; 518 587 char *cmd = *args; argc--; args++; 519 588 long desktop = 0; … … 521 590 if (argc != 0) { 522 591 printf("usage: %s\n", cmd); 523 return; 524 } 525 526 xdo_get_current_desktop(xdo, &desktop); 527 592 return 1; 593 } 594 595 ret = xdo_get_current_desktop(xdo, &desktop); 528 596 printf("%ld\n", desktop); 529 } 530 531 void cmd_set_desktop_for_window(int argc, char **args) { 597 return ret; 598 } 599 600 int cmd_set_desktop_for_window(int argc, char **args) { 532 601 char *cmd = *args; argc--; args++; 533 602 long desktop = 0; … … 536 605 if (argc != 2) { 537 606 printf("usage: %s <window> <desktop>\n", cmd); 538 return ;607 return 1; 539 608 } 540 609 … … 542 611 desktop = strtol(args[1], NULL, 0); 543 612 544 xdo_set_desktop_for_window(xdo, window, desktop); 545 } 546 547 void cmd_get_desktop_for_window(int argc, char **args) { 613 return xdo_set_desktop_for_window(xdo, window, desktop); 614 } 615 616 int cmd_get_desktop_for_window(int argc, char **args) { 617 int ret = 0; 548 618 char *cmd = *args; argc--; args++; 549 619 long desktop = 0; … … 552 622 if (argc != 1) { 553 623 printf("usage: %s <window>\n", cmd); 554 return ;624 return 1; 555 625 } 556 626 557 627 window = (Window)strtol(args[0], NULL, 0); 558 628 559 xdo_get_desktop_for_window(xdo, window, &desktop);629 ret = xdo_get_desktop_for_window(xdo, window, &desktop); 560 630 printf("%ld\n", desktop); 561 } 631 return ret; 632 }
Note: See TracChangeset
for help on using the changeset viewer.

