Changeset 1085


Ignore:
Timestamp:
Jun 3, 2008, 9:59:00 AM (10 years ago)
Author:
Daniel Kahn Gillmor
Message:

[svn-upgrade] Integrating new upstream version, xdotool (20080603)

Location:
branches/upstream/xdotool/current
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • branches/upstream/xdotool/current/CHANGELIST

    r1077 r1085  
     120080603:
     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
    1820080601:
    29  * Add new commands:
     
    2431    incorrectly typecasting Window to int sometimes.
    2532  * Confirmed that the one (but mostly useless) test passes.
     33
     3420071230:
     35  * Manpage contribution by Daniel Kahn Gillmor
     36  * Add COPYRIGHT from svn to the distributed package.
    2637
    273820070903:
     
    5364  (with menus enabled).
    5465
    55 
    566620070712:
    5767  Added new search options to 'xdotool search'
  • branches/upstream/xdotool/current/Makefile

    r1077 r1085  
    3737        rm -f $(INSTALLMAN)/man1/xdotool.1
    3838
    39 
    4039clean:
    41         rm -f *.o || true
     40        rm -f *.o xdotool xdotool.1 || true
    4241
    4342xdo.o: xdo.c
     
    5857package: test-package-build create-package
    5958
    60 create-package: xdotool.1
     59create-package:
    6160        @NAME=xdotool-`date +%Y%m%d`; \
    6261        echo "Creating package: $$NAME"; \
    6362        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}/; \
    6564        tar -zcf $${NAME}.tar.gz $${NAME}/; \
    6665        rm -rf $${NAME}/
  • branches/upstream/xdotool/current/README

    r1071 r1085  
    44### See the website for more up-to-date documentation
    55# http://www.semicomplete.com/projects/xdotool/
     6#
     7# Also see the manpage, which you can generate by running:
     8# make xdotool.1
    69
    710Compile: make xdotool
     
    3134      See 'xwininfo' output for what each of these are/mean.
    3235
    33 $Id: README 1520 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  
    2222xterm_pid="$!"
    2323
     24sleep 1
     25
    2426try $xdotool search xdotool_test_window
    2527try $xdotool getwindowfocus
     
    4446
    4547try $xdotool windowactivate $wid
     48sleep 0.2
    4649
    47 try $xdotool get_num_desktops $wid
    48 desktops=`$xdotool get_num_desktops $wid`
     50try $xdotool get_num_desktops
     51desktops=`$xdotool get_num_desktops`
    4952try $xdotool set_num_desktops $desktops
    5053
  • branches/upstream/xdotool/current/xdo.c

    r1077 r1085  
    11/* xdo library
    22 *
    3  * $Id: xdo.c 1878 2008-06-01 00:31:53Z jordansissel $
     3 * $Id: xdo.c 1891 2008-06-03 09:00:20Z jordansissel $
    44 *
    55 * - getwindowfocus contributed by Lee Pumphret
     
    106106  ret = XMapWindow(xdo->xdpy, wid);
    107107  XFlush(xdo->xdpy);
    108   return _is_success("XMapWindow", ret);
     108  return _is_success("XMapWindow", ret == 0);
    109109}
    110110
     
    113113  ret = XUnmapWindow(xdo->xdpy, wid);
    114114  XFlush(xdo->xdpy);
    115   return _is_success("XMapWindow", ret);
    116 }
    117 
    118 void xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,
     115  return _is_success("XUnmapWindow", ret == 0);
     116}
     117
     118int xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,
    119119                              Window **windowlist, int *nwindows) {
    120120  regex_t re;
     
    130130  if (ret != 0) {
    131131    fprintf(stderr, "Failed to compile regex: '%s'\n", regex);
    132     return;
     132    return 1;
    133133  }
    134134
     
    166166
    167167  regfree(&re);
     168  return 0;
    168169}
    169170
     
    175176
    176177  ret = XConfigureWindow(xdo->xdpy, wid, CWX | CWY, &wc);
    177   return _is_success("XConfigureWindow", ret);
     178  return _is_success("XConfigureWindow", ret == 0);
    178179}
    179180
     
    212213  ret = XConfigureWindow(xdo->xdpy, wid, cw_flags, &wc);
    213214  XFlush(xdo->xdpy);
    214   return _is_success("XConfigureWindow", ret);
     215  return _is_success("XConfigureWindow", ret == 0);
    215216}
    216217
     
    219220  ret = XSetInputFocus(xdo->xdpy, wid, RevertToParent, CurrentTime);
    220221  XFlush(xdo->xdpy);
    221   return _is_success("XSetInputFocus", ret);
     222  return _is_success("XSetInputFocus", ret == 0);
    222223}
    223224
     
    227228  XEvent xev;
    228229  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  }
    229237
    230238  /* If this window is on another desktop, let's go to that desktop first */
     
    252260  /* XXX: XSendEvent returns 0 on conversion failure, nonzero otherwise.
    253261   * 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);
    255264}
    256265
     
    260269  Window root;
    261270  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  }
    262278
    263279  root = RootWindow(xdo->xdpy, 0);
     
    276292                   &xev);
    277293
    278   return _is_success("XSendEvent[EWMH:_NET_NUMBER_OF_DESKTOPS]", ret);
     294  return _is_success("XSendEvent[EWMH:_NET_NUMBER_OF_DESKTOPS]", ret == 0);
    279295}
    280296
     
    285301  unsigned char *data;
    286302  Window root;
    287 
    288303  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  }
    289311
    290312  request = XInternAtom(xdo->xdpy, "_NET_NUMBER_OF_DESKTOPS", False);
     
    310332
    311333  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  }
    312341
    313342  memset(&xev, 0, sizeof(xev));
     
    325354                   &xev);
    326355
    327   return _is_success("XSendEvent[EWMH:_NET_CURRENT_DESKTOP]", ret);
     356  return _is_success("XSendEvent[EWMH:_NET_CURRENT_DESKTOP]", ret == 0);
    328357}
    329358
     
    337366  Atom request;
    338367
     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
    339375  request = XInternAtom(xdo->xdpy, "_NET_CURRENT_DESKTOP", False);
    340376  root = XDefaultRootWindow(xdo->xdpy);
     
    356392  XWindowAttributes wattr;
    357393  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  }
    358402
    359403  memset(&xev, 0, sizeof(xev));
     
    371415                   &xev);
    372416
    373   return _is_success("XSendEvent[EWMH:_NET_WM_DESKTOP]", ret);
     417  return _is_success("XSendEvent[EWMH:_NET_WM_DESKTOP]", ret == 0);
    374418}
    375419
     
    379423  long nitems;
    380424  unsigned char *data;
    381 
    382425  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  }
    383434
    384435  request = XInternAtom(xdo->xdpy, "_NET_WM_DESKTOP", False);
     
    408459  ret = XTestFakeMotionEvent(xdo->xdpy, -1, x, y, CurrentTime);
    409460  XFlush(xdo->xdpy);
    410   return _is_success("XTestFakeMotionEvent", ret);
     461  return _is_success("XTestFakeMotionEvent", ret == 0);
    411462}
    412463
     
    415466  ret = XTestFakeRelativeMotionEvent(xdo->xdpy, x, y, CurrentTime);
    416467  XFlush(xdo->xdpy);
    417   return _is_success("XTestFakeRelativeMotionEvent", ret);
     468  return _is_success("XTestFakeRelativeMotionEvent", ret == 0);
    418469}
    419470
     
    422473  ret = XTestFakeButtonEvent(xdo->xdpy, button, True, CurrentTime);
    423474  XFlush(xdo->xdpy);
    424   return _is_success("XTestFakeButtonEvent", ret);
     475  return _is_success("XTestFakeButtonEvent(down)", ret == 0);
    425476}
    426477
     
    429480  ret = XTestFakeButtonEvent(xdo->xdpy, button, False, CurrentTime);
    430481  XFlush(xdo->xdpy);
    431   return _is_success("XTestFakeKeyEvent", ret);
     482  return _is_success("XTestFakeButtonEvent(up)", ret == 0);
    432483}
    433484
     
    435486  int ret;
    436487  ret = xdo_mousedown(xdo, button);
    437   if (!ret)
     488  if (ret)
    438489    return ret;
    439490  ret = xdo_mouseup(xdo, button);
    440491  return ret;
    441 
    442   /* no need to flush here */
    443492}
    444493
     
    450499  int shiftcode = 0;
    451500
     501  /* XXX: Add error handling */
    452502  for (i = 0; string[i] != '\0'; i++) {
    453503    key = string[i];
     
    466516  }
    467517
    468   return True;
     518  return 0;
    469519}
    470520
    471521int _xdo_keysequence_do(xdo_t *xdo, char *keyseq, int pressed) {
     522  int ret = 0;
    472523  int *keys = NULL;
    473524  int nkeys;
     
    480531
    481532  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);
    484534  }
    485535
    486536  free(keys);
    487537  XFlush(xdo->xdpy);
    488   return True;
     538  return ret;
    489539}
    490540 
     
    498548
    499549int 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;
    503554}
    504555
     
    509560  int unused_revert_ret;
    510561  ret = XGetInputFocus(xdo->xdpy, window_ret, &unused_revert_ret);
    511   return _is_success("XGetInputFocus", ret);
     562  return _is_success("XGetInputFocus", ret == 0);
    512563}
    513564
     
    731782
    732783int _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)
    743785    fprintf(stderr, "%s failed (code=%d)\n", funcname, code);
    744     return False;
    745   }
    746 
    747   return True;
     786  return code;
    748787}
    749788
  • branches/upstream/xdotool/current/xdo.h

    r1077 r1085  
    33 * - include this if you have code that uses xdo
    44 *
    5  * $Id: xdo.h 1876 2008-05-31 10:54:25Z jordansissel $
     5 * $Id: xdo.h 1891 2008-06-03 09:00:20Z jordansissel $
    66 */
    77
     
    7777
    7878/* Returns: windowlist and nwindows */
    79 void xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,
    80                               Window **windowlist, int *nwindows);
     79int 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  
    33 * command line interface to the xdo library
    44 *
    5  * $Id: xdotool.c 1880 2008-06-01 07:23:14Z jordansissel $
     5 * $Id: xdotool.c 1891 2008-06-03 09:00:20Z jordansissel $
    66 *
    77 * getwindowfocus contributed by Lee Pumphret
     
    2020#include "xdo.h"
    2121
    22 void cmd_click(int argc, char **args);
    23 void cmd_getwindowfocus(int argc, char **args);
    24 void cmd_help(int argc, char **args);
    25 void cmd_key(int argc, char **args);
    26 void cmd_mousedown(int argc, char **args);
    27 void cmd_mousemove(int argc, char **args);
    28 void cmd_mousemove_relative(int argc, char **args);
    29 void cmd_mouseup(int argc, char **args);
    30 void cmd_search(int argc, char **args);
    31 void cmd_type(int argc, char **args);
    32 void cmd_windowactivate(int argc, char **args);
    33 void cmd_windowfocus(int argc, char **args);
    34 void cmd_windowmap(int argc, char **args);
    35 void cmd_windowmove(int argc, char **args);
    36 void cmd_windowraise(int argc, char **args);
    37 void cmd_windowsize(int argc, char **args);
    38 void cmd_windowunmap(int argc, char **args);
     22int cmd_click(int argc, char **args);
     23int cmd_getwindowfocus(int argc, char **args);
     24int cmd_help(int argc, char **args);
     25int cmd_key(int argc, char **args);
     26int cmd_mousedown(int argc, char **args);
     27int cmd_mousemove(int argc, char **args);
     28int cmd_mousemove_relative(int argc, char **args);
     29int cmd_mouseup(int argc, char **args);
     30int cmd_search(int argc, char **args);
     31int cmd_type(int argc, char **args);
     32int cmd_windowactivate(int argc, char **args);
     33int cmd_windowfocus(int argc, char **args);
     34int cmd_windowmap(int argc, char **args);
     35int cmd_windowmove(int argc, char **args);
     36int cmd_windowraise(int argc, char **args);
     37int cmd_windowsize(int argc, char **args);
     38int cmd_windowunmap(int argc, char **args);
    3939
    4040/* pager-like commands */
    41 void cmd_set_num_desktops(int argc, char **args);
    42 void cmd_get_num_desktops(int argc, char **args);
    43 void cmd_set_desktop(int argc, char **args);
    44 void cmd_get_desktop(int argc, char **args);
    45 void cmd_set_desktop_for_window(int argc, char **args);
    46 void cmd_get_desktop_for_window(int argc, char **args);
     41int cmd_set_num_desktops(int argc, char **args);
     42int cmd_get_num_desktops(int argc, char **args);
     43int cmd_set_desktop(int argc, char **args);
     44int cmd_get_desktop(int argc, char **args);
     45int cmd_set_desktop_for_window(int argc, char **args);
     46int cmd_get_desktop_for_window(int argc, char **args);
    4747
    4848xdo_t *xdo;
     
    5151struct dispatch {
    5252  const char *name;
    53   void (*func)(int argc, char **args);
     53  int (*func)(int argc, char **args);
    5454} dispatch[] = {
    5555  /* Query functions */
     
    9090int main(int argc, char **argv) {
    9191  char *cmd;
     92  int ret = 0;
    9293  int i;
    9394
     
    109110  for (i = 0; dispatch[i].name != NULL; i++) {
    110111    if (!strcasecmp(dispatch[i].name, cmd)) {
    111       dispatch[i].func(argc, argv);
     112      ret = dispatch[i].func(argc, argv);
    112113      break;
    113114    }
     
    115116
    116117  xdo_free(xdo);
    117   return 0;
     118  return ret;
    118119}
    119120
     
    123124}
    124125
    125 void cmd_help(int argc, char **args) {
     126int cmd_help(int argc, char **args) {
    126127  int i;
    127128  printf("Available commands:\n");
    128129  for (i = 0; dispatch[i].name != NULL; i++)
    129130    printf("  %s\n", dispatch[i].name);
    130 }
    131 
    132 void cmd_mousemove(int argc, char **args) {
     131
     132  return 0;
     133}
     134
     135int cmd_mousemove(int argc, char **args) {
     136  int ret = 0;
    133137  int x, y;
    134138  char *cmd = *args; argc--; args++;
     
    137141    fprintf(stderr, "usage: %s <xcoord> <ycoord>\n", cmd);
    138142    fprintf(stderr, "You specified the wrong number of args.\n");
    139     return;
     143    return 1;
    140144  }
    141145
     
    143147  y = atoi(args[1]);
    144148
    145   if (!xdo_mousemove(xdo, x, y)) {
     149  ret = xdo_mousemove(xdo, x, y);
     150
     151  if (ret)
    146152    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
     157int cmd_mousemove_relative(int argc, char **args) {
    151158  int x, y;
     159  int ret = 0;
    152160  char *cmd = *args; argc--; args++;
    153161
     
    155163    fprintf(stderr, "usage: %s <xcoord> <ycoord>\n", cmd);
    156164    fprintf(stderr, "You specified the wrong number of args.\n");
    157     return;
     165    return 1;
    158166  }
    159167
     
    161169  y = atoi(args[1]);
    162170
    163   if (!xdo_mousemove_relative(xdo, x, y)) {
     171  ret = xdo_mousemove_relative(xdo, x, y);
     172
     173  if (ret)
    164174    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
     179int cmd_mousedown(int argc, char **args) {
     180  int ret = 0;
    169181  int button;
    170182  char *cmd = *args; argc--; args++;
     
    173185    fprintf(stderr, "usage: %s <button>\n", cmd);
    174186    fprintf(stderr, "You specified the wrong number of args.\n");
    175     return;
     187    return 1;
    176188  }
    177189
    178190  button = atoi(args[0]);
    179191
    180   if (!xdo_mousedown(xdo, button)) {
     192  ret = xdo_mousedown(xdo, button);
     193
     194  if (ret)
    181195    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
     200int cmd_mouseup(int argc, char **args) {
     201  int ret = 0;
    186202  int button;
    187203  char *cmd = *args; argc--; args++;
     
    190206    fprintf(stderr, "usage: %s <button>\n", cmd);
    191207    fprintf(stderr, "You specified the wrong number of args.\n");
    192     return;
     208    return 1;
    193209  }
    194210
    195211  button = atoi(args[0]);
    196212
    197   if (!xdo_mouseup(xdo, button)) {
     213  ret = xdo_mouseup(xdo, button);
     214  if (ret)
    198215    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
     220int 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
     234int cmd_type(int argc, char **args) {
     235  int ret = 0;
    208236  int i;
    209237  char *cmd = *args; argc--; args++;
     
    212240    fprintf(stderr, "usage: %s <things to type>\n", cmd);
    213241    fprintf(stderr, "You specified the wrong number of args.\n");
    214     return;
     242    return 1;
    215243  }
    216244
    217245  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) {
    219249      fprintf(stderr, "xdo_type reported an error\n");
    220250    }
    221   }
    222 }
    223 
    224 void cmd_key(int argc, char **args) {
     251
     252    ret += tmp;
     253  }
     254
     255  return ret > 0;
     256}
     257
     258int cmd_key(int argc, char **args) {
     259  int ret = 0;
    225260  int i;
    226261  char *cmd = *args; argc--; args++;
     
    229264    fprintf(stderr, "usage: %s <keyseq1> [keyseq2 ... keyseqN]\n", cmd);
    230265    fprintf(stderr, "You specified the wrong number of args.\n");
    231     return;
     266    return 1;
    232267  }
    233268
     
    242277  } else {
    243278    fprintf(stderr, "Unknown command '%s'\n", cmd);
    244     return;
     279    return 1;
    245280  }
    246281
    247282  for (i = 0; i < argc; i++) {
    248     if (!func(xdo, args[i]))
     283    int tmp = func(xdo, args[i]);
     284    if (tmp != 0)
    249285      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
     292int cmd_windowmove(int argc, char **args) {
     293  int ret = 0;
    254294  int x, y;
    255295  Window wid;
     
    258298  if (argc != 3) {
    259299    printf("usage: %s wid x y\n", cmd);
    260     return;
     300    return 1;
    261301  }
    262302
     
    265305  y = (int)strtol(args[2], NULL, 0);
    266306
    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
     314int cmd_windowactivate(int argc, char **args) {
     315  int ret = 0;
    273316  Window wid;
    274317  char *cmd = *args; argc--; args++;
     
    276319  if (argc != 1) {
    277320    printf("usage: %s wid\n", cmd);
    278     return;
     321    return 1;
    279322  }
    280323
    281324  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)
    283328    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
     333int cmd_windowfocus(int argc, char **args) {
     334  int ret = 0;
    290335  Window wid;
    291336  char *cmd = *args; argc--; args++;
     
    293338  if (argc != 1) {
    294339    printf("usage: %s wid\n", cmd);
    295     return;
     340    return 1;
    296341  }
    297342
    298343  wid = (Window)strtol(args[0], NULL, 0);
    299   if (!xdo_window_focus(xdo, wid)) {
     344  ret = xdo_window_focus(xdo, wid);
     345  if (ret)
    300346    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
     351int cmd_windowraise(int argc, char **args) {
     352  int ret = 0;
    305353  Window wid;
    306354  char *cmd = *args; argc--; args++;
     
    308356  if (argc != 1) {
    309357    printf("usage: %s wid\n", cmd);
    310     return;
    311   }
     358    return 1;
     359   }
    312360
    313361  wid = (Window)strtol(args[0], NULL, 0);
    314   if (!xdo_window_raise(xdo, wid)) {
     362  ret = xdo_window_raise(xdo, wid);
     363  if (ret)
    315364    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
     369int cmd_windowsize(int argc, char **args) {
     370  int ret = 0;
    320371  int width, height;
    321372  Window wid;
     
    348399  if (argc != 3) {
    349400    printf("usage: %s wid width height\n", cmd);
    350     return;
     401    return 1;
    351402  }
    352403
     
    355406  height = (int)strtol(args[2], NULL, 0);
    356407
    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)
    358410    fprintf(stderr, "xdo_window_setsize reported an error\n");
    359   }
    360 }
    361 
    362 void cmd_search(int argc, char **args) {
     411  return ret;
     412}
     413
     414int cmd_search(int argc, char **args) {
    363415  Window *list;
    364416  int nwindows;
     
    405457  if (argc != 1) {
    406458    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;
    418470  }
    419471
     
    424476  /* Free list as it's malloc'd by xdo_window_list_by_regex */
    425477  free(list);
     478
     479  /* error if number of windows found is zero (behave like grep) */
     480  return !nwindows;
    426481}
    427482
    428483/* Added 2007-07-28 - Lee Pumphret */
    429 void cmd_getwindowfocus(int argc, char **args) {
     484int cmd_getwindowfocus(int argc, char **args) {
     485  int ret = 0;
    430486  Window wid = 0;
    431487  char *cmd = *args; argc--; args++;
     
    433489  if (argc != 0) {
    434490    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) {
    439497    fprintf(stderr, "xdo_window_focus reported an error\n");
    440   } else {
     498  } else { 
    441499    window_print(wid);
    442500  }
    443 }
    444 
    445 void cmd_windowmap(int argc, char **args) {
     501
     502  return ret;
     503}
     504
     505int cmd_windowmap(int argc, char **args) {
     506  int ret = 0;
    446507  Window wid;
    447508  char *cmd = *args; argc--; args++;
     
    449510  if (argc != 1) {
    450511    printf("usage: %s wid\n", cmd);
    451     return;
     512    return 1;
    452513  }
    453514
    454515  wid = (Window)strtol(args[0], NULL, 0);
    455   if (!xdo_window_map(xdo, wid)) {
     516  ret = xdo_window_map(xdo, wid);
     517  if (ret)
    456518    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
     523int cmd_windowunmap(int argc, char **args) {
     524  int ret = 0;
    461525  Window wid;
    462526  char *cmd = *args; argc--; args++;
     
    464528  if (argc != 1) {
    465529    printf("usage: %s wid\n", cmd);
    466     return;
     530    return 1;
    467531  }
    468532
    469533  wid = (Window)strtol(args[0], NULL, 0);
    470   if (!xdo_window_unmap(xdo, wid)) {
     534  ret = xdo_window_unmap(xdo, wid);
     535  if (ret)
    471536    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
     541int cmd_set_num_desktops(int argc, char **args) {
    476542  char *cmd = *args; argc--; args++;
    477543  long ndesktops;
     
    479545  if (argc != 1) {
    480546    printf("usage: %s num_desktops\n", cmd);
    481     return;
     547    return 1;
    482548  }
    483549
    484550  ndesktops = strtol(args[0], NULL, 0);
    485551
    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
     555int cmd_get_num_desktops(int argc, char **args) {
     556  int ret = 0;
    490557  char *cmd = *args; argc--; args++;
    491558  long ndesktops = 0;
     
    493560  if (argc != 0) {
    494561    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);
    499566
    500567  printf("%ld\n", ndesktops);
    501 }
    502 
    503 void cmd_set_desktop(int argc, char **args) {
     568  return ret;
     569}
     570
     571int cmd_set_desktop(int argc, char **args) {
    504572  char *cmd = *args; argc--; args++;
    505573  long desktop;
     
    507575  if (argc != 1) {
    508576    printf("usage: %s desktop\n", cmd);
    509     return;
     577    return 1;
    510578  }
    511579
    512580  desktop = strtol(args[0], NULL, 0);
    513581
    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
     585int cmd_get_desktop(int argc, char **args) {
     586  int ret = 0;
    518587  char *cmd = *args; argc--; args++;
    519588  long desktop = 0;
     
    521590  if (argc != 0) {
    522591    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);
    528596  printf("%ld\n", desktop);
    529 }
    530 
    531 void cmd_set_desktop_for_window(int argc, char **args) {
     597  return ret;
     598}
     599
     600int cmd_set_desktop_for_window(int argc, char **args) {
    532601  char *cmd = *args; argc--; args++;
    533602  long desktop = 0;
     
    536605  if (argc != 2) {
    537606    printf("usage: %s <window> <desktop>\n", cmd);
    538     return;
     607    return 1;
    539608  }
    540609
     
    542611  desktop = strtol(args[1], NULL, 0);
    543612
    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
     616int cmd_get_desktop_for_window(int argc, char **args) {
     617  int ret = 0;
    548618  char *cmd = *args; argc--; args++;
    549619  long desktop = 0;
     
    552622  if (argc != 1) {
    553623    printf("usage: %s <window>\n", cmd);
    554     return;
     624    return 1;
    555625  }
    556626
    557627  window = (Window)strtol(args[0], NULL, 0);
    558628
    559   xdo_get_desktop_for_window(xdo, window, &desktop);
     629  ret = xdo_get_desktop_for_window(xdo, window, &desktop);
    560630  printf("%ld\n", desktop);
    561 }
     631  return ret;
     632}
Note: See TracChangeset for help on using the changeset viewer.