Changeset 1077 for branches


Ignore:
Timestamp:
Jun 1, 2008, 11:23:07 PM (10 years ago)
Author:
Daniel Kahn Gillmor
Message:

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

Location:
branches/upstream/xdotool/current
Files:
3 added
7 edited

Legend:

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

    r1071 r1077  
     120080601:
     2  * Add new commands:
     3    - windowactivate: Activate a window. If the window is on another desktop, we
     4        will switch to that desktop and then activate the window.
     5    - set_num_desktops number: Changes the number of desktops or workspaces.
     6    - get_num_desktops: Output the current number of desktops.
     7    - set_desktop desktop_number: Change the current view to the specified
     8        desktop.
     9    - get_desktop: Output the current desktop in view.
     10    - set_desktop_for_window window_id desktop_number: Move a window to a
     11        different desktop.
     12    - get_desktop_for_window window_id: Output the desktop currently containing
     13        the given window.
     14
     15    windowactivate tested and confirmed working in: ion-3 and Gnome2 (metacity)
     16    The rest of the new commands have only been tested in Gnome2. They do not
     17    work in ion-3 due to lacking support for EWMH in ion.
     18  * Rewrote the man page in perlpod format.
     19
    12020080521:
    221  * Import patches from keynav's xdotool branch (From Lukas Mai) which make
  • branches/upstream/xdotool/current/Makefile

    r1071 r1077  
    1 CFLAGS+= -std=c99 -pedantic -Wall -W -Wno-missing-field-initializers -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -O2 -pipe
     1PREFIX=/usr/local
     2INSTALLBIN=/usr/local/bin
     3INSTALLMAN=/usr/local/man
     4
     5WARNFLAGS+=-pedantic -Wall -W -Wno-missing-field-initializers -Wundef \
     6           -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast \
     7           -Wcast-align -Wwrite-strings -Wstrict-prototypes \
     8           -Wmissing-prototypes -Wnested-externs -Winline \
     9           -Wdisabled-optimization
     10
     11CFLAGS=-pipe -std=c99 $(WARNFLAGS)
    212
    313DEFAULT_LIBS=-L/usr/X11R6/lib -L/usr/local/lib -lX11 -lXtst
     
    1020LDFLAGS+=$(LIBS)
    1121
    12 all: xdotool
     22all: xdotool xdotool.1
     23
     24install: installprog installman
     25
     26installprog: xdotool
     27        install -m 755 xdotool $(INSTALLBIN)/
     28
     29installman: xdotool.1
     30        [ -d $(INSTALLMAN) ] || mkdir $(INSTALLMAN)
     31        [ -d $(INSTALLMAN)/man1 ] || mkdir $(INSTALLMAN)/man1
     32        install -m 644 xdotool.1 $(INSTALLMAN)/man1/
     33
     34deinstall: uninstall
     35uninstall:
     36        rm -f $(INSTALLBIN)/xdotool
     37        rm -f $(INSTALLMAN)/man1/xdotool.1
     38
    1339
    1440clean:
     
    2753        gcc $(CFLAGS) $(LDFLAGS) xdotool.o xdo.o -o $@
    2854
     55xdotool.1: xdotool.pod
     56        pod2man -c "" -r "" xdotool.pod > $@
     57
    2958package: test-package-build create-package
    3059
    31 create-package:
     60create-package: xdotool.1
    3261        @NAME=xdotool-`date +%Y%m%d`; \
    3362        echo "Creating package: $$NAME"; \
    3463        mkdir $${NAME}; \
    35         rsync --exclude .svn -a `ls -d *.c *.h examples t CHANGELIST README Makefile* 2> /dev/null` $${NAME}/; \
     64        rsync --exclude .svn -a `ls -d *.1 *.pod COPYRIGHT *.c *.h examples t CHANGELIST README Makefile* 2> /dev/null` $${NAME}/; \
    3665        tar -zcf $${NAME}.tar.gz $${NAME}/; \
    3766        rm -rf $${NAME}/
  • branches/upstream/xdotool/current/examples/ffsp.sh

    r1062 r1077  
    11#!/bin/sh
    2 # On my workstation, this switches to desktop 2, clears the search bar, pastes
    3 # into the search bar, and presses enter. Hence searching for whatever lies in
    4 # my X clipboard.
     2# Activate firefox and paste the clipboard contents into the url bar.
    53
    6 xdotool key "alt+2"
     4wid=`xdotool search --title "Mozilla Firefox"`
     5xdotool windowactivate $wid
     6sleep 0.2
    77xdotool key "ctrl+j"
    88xdotool key "BackSpace"
    9 xdotool mousemove 600 35
    10 xdotool click 2
     9xdotool key "ctrl+v"
    1110xdotool key "Return"
  • branches/upstream/xdotool/current/t/no_crashes_please.sh

    r1062 r1077  
    4343try $xdotool key "ctrl+w"
    4444
     45try $xdotool windowactivate $wid
     46
     47try $xdotool get_num_desktops $wid
     48desktops=`$xdotool get_num_desktops $wid`
     49try $xdotool set_num_desktops $desktops
     50
     51cur_desktop=`$xdotool get_desktop`
     52try $xdotool set_desktop $cur_desktop
     53
     54desktop=`$xdotool get_desktop_for_window $wid`
     55try $xdotool set_desktop_for_window $wid $desktop
     56
    4557#pkill -f xdotool_test_window
    4658kill $xterm_pid
  • branches/upstream/xdotool/current/xdo.c

    r1071 r1077  
    11/* xdo library
    22 *
    3  * $Id: xdo.c 1854 2008-05-21 07:23:29Z jordansissel $
     3 * $Id: xdo.c 1878 2008-06-01 00:31:53Z jordansissel $
    44 *
    55 * - getwindowfocus contributed by Lee Pumphret
     
    4040static int _xdo_regex_match_window(xdo_t *xdo, Window window, int flags, regex_t *re);
    4141static int _xdo_is_window_visible(xdo_t *xdo, Window wid);
     42static unsigned char * _xdo_getwinprop(xdo_t *xdo, Window window, Atom atom,
     43                                       long *nitems, Atom *type, int *size);
     44static int _xdo_ewmh_is_supported(xdo_t *xdo, const char *feature);
    4245
    4346static int _is_success(const char *funcname, int code);
     
    136139    fprintf(stderr, "No text fields specified for regex search. \nDefaulting to"
    137140            " window title, class, and name searching\n");
    138     flags = SEARCH_TITLE | SEARCH_CLASS | SEARCH_NAME;
     141    flags |= SEARCH_TITLE | SEARCH_CLASS | SEARCH_NAME;
    139142  }
    140143
     
    142145  *windowlist = malloc(matched_window_list_size * sizeof(Window));
    143146
    144   _xdo_get_child_windows(xdo, XDefaultRootWindow(xdo->xdpy),
     147  _xdo_get_child_windows(xdo, RootWindow(xdo->xdpy, 0),
    145148                         &total_window_list, &ntotal_windows,
    146149                         &window_list_size);
     
    149152    if (flags & SEARCH_VISIBLEONLY && !_xdo_is_window_visible(xdo, wid))
    150153      continue;
    151 
    152154    if (!_xdo_regex_match_window(xdo, wid, flags, &re))
    153155      continue;
     
    220222}
    221223
     224int xdo_window_activate(xdo_t *xdo, Window wid) {
     225  int ret;
     226  long desktop = 0;
     227  XEvent xev;
     228  XWindowAttributes wattr;
     229
     230  /* If this window is on another desktop, let's go to that desktop first */
     231
     232  if (_xdo_ewmh_is_supported(xdo, "_NET_WM_DESKTOP") == True
     233      && _xdo_ewmh_is_supported(xdo, "_NET_CURRENT_DESKTOP") == True) {
     234    xdo_get_desktop_for_window(xdo, wid, &desktop);
     235    xdo_set_current_desktop(xdo, desktop);
     236  }
     237
     238  memset(&xev, 0, sizeof(xev));
     239  xev.type = ClientMessage;
     240  xev.xclient.display = xdo->xdpy;
     241  xev.xclient.window = wid;
     242  xev.xclient.message_type = XInternAtom(xdo->xdpy, "_NET_ACTIVE_WINDOW", False);
     243  xev.xclient.format = 32;
     244  xev.xclient.data.l[0] = 2L; /* 2 == Message from a window pager */
     245  xev.xclient.data.l[1] = CurrentTime;
     246
     247  XGetWindowAttributes(xdo->xdpy, wid, &wattr);
     248  ret = XSendEvent(xdo->xdpy, wattr.screen->root, False,
     249                   SubstructureNotifyMask | SubstructureRedirectMask,
     250                   &xev);
     251
     252  /* XXX: XSendEvent returns 0 on conversion failure, nonzero otherwise.
     253   * Manpage says it will only generate BadWindow or BadValue errors */
     254  return _is_success("XSendEvent[EWMH:_NET_ACTIVE_WINDOW]", ret);
     255}
     256
     257int xdo_set_number_of_desktops(xdo_t *xdo, long ndesktops) {
     258  /* XXX: This should support passing a screen number */
     259  XEvent xev;
     260  Window root;
     261  int ret;
     262
     263  root = RootWindow(xdo->xdpy, 0);
     264
     265  memset(&xev, 0, sizeof(xev));
     266  xev.type = ClientMessage;
     267  xev.xclient.display = xdo->xdpy;
     268  xev.xclient.window = root;
     269  xev.xclient.message_type = XInternAtom(xdo->xdpy, "_NET_NUMBER_OF_DESKTOPS",
     270                                         False);
     271  xev.xclient.format = 32;
     272  xev.xclient.data.l[0] = ndesktops;
     273
     274  ret = XSendEvent(xdo->xdpy, root, False,
     275                   SubstructureNotifyMask | SubstructureRedirectMask,
     276                   &xev);
     277
     278  return _is_success("XSendEvent[EWMH:_NET_NUMBER_OF_DESKTOPS]", ret);
     279}
     280
     281int xdo_get_number_of_desktops(xdo_t *xdo, long *ndesktops) {
     282  Atom type;
     283  int size;
     284  long nitems;
     285  unsigned char *data;
     286  Window root;
     287
     288  Atom request;
     289
     290  request = XInternAtom(xdo->xdpy, "_NET_NUMBER_OF_DESKTOPS", False);
     291  root = XDefaultRootWindow(xdo->xdpy);
     292
     293  data = _xdo_getwinprop(xdo, root, request, &nitems, &type, &size);
     294
     295  if (nitems > 0)
     296    *ndesktops = *((long*)data);
     297  else
     298    *ndesktops = 0;
     299
     300  return _is_success("XGetWindowProperty[_NET_NUMBER_OF_DESKTOPS]",
     301                     *ndesktops == 0);
     302
     303}
     304
     305int xdo_set_current_desktop(xdo_t *xdo, long desktop) {
     306  /* XXX: This should support passing a screen number */
     307  XEvent xev;
     308  Window root;
     309  int ret;
     310
     311  root = RootWindow(xdo->xdpy, 0);
     312
     313  memset(&xev, 0, sizeof(xev));
     314  xev.type = ClientMessage;
     315  xev.xclient.display = xdo->xdpy;
     316  xev.xclient.window = root;
     317  xev.xclient.message_type = XInternAtom(xdo->xdpy, "_NET_CURRENT_DESKTOP",
     318                                         False);
     319  xev.xclient.format = 32;
     320  xev.xclient.data.l[0] = desktop;
     321  xev.xclient.data.l[1] = CurrentTime;
     322
     323  ret = XSendEvent(xdo->xdpy, root, False,
     324                   SubstructureNotifyMask | SubstructureRedirectMask,
     325                   &xev);
     326
     327  return _is_success("XSendEvent[EWMH:_NET_CURRENT_DESKTOP]", ret);
     328}
     329
     330int xdo_get_current_desktop(xdo_t *xdo, long *desktop) {
     331  Atom type;
     332  int size;
     333  long nitems;
     334  unsigned char *data;
     335  Window root;
     336
     337  Atom request;
     338
     339  request = XInternAtom(xdo->xdpy, "_NET_CURRENT_DESKTOP", False);
     340  root = XDefaultRootWindow(xdo->xdpy);
     341
     342  data = _xdo_getwinprop(xdo, root, request, &nitems, &type, &size);
     343
     344  if (nitems > 0)
     345    *desktop = *((long*)data);
     346  else
     347    *desktop = -1;
     348
     349  return _is_success("XGetWindowProperty[_NET_CURRENT_DESKTOP]",
     350                     *desktop == -1);
     351}
     352
     353int xdo_set_desktop_for_window(xdo_t *xdo, Window wid, long desktop) {
     354  XEvent xev;
     355  int ret;
     356  XWindowAttributes wattr;
     357  XGetWindowAttributes(xdo->xdpy, wid, &wattr);
     358
     359  memset(&xev, 0, sizeof(xev));
     360  xev.type = ClientMessage;
     361  xev.xclient.display = xdo->xdpy;
     362  xev.xclient.window = wid;
     363  xev.xclient.message_type = XInternAtom(xdo->xdpy, "_NET_WM_DESKTOP",
     364                                         False);
     365  xev.xclient.format = 32;
     366  xev.xclient.data.l[0] = desktop;
     367  xev.xclient.data.l[1] = 2; /* indicate we are messaging from a pager */
     368
     369  ret = XSendEvent(xdo->xdpy, wattr.screen->root, False,
     370                   SubstructureNotifyMask | SubstructureRedirectMask,
     371                   &xev);
     372
     373  return _is_success("XSendEvent[EWMH:_NET_WM_DESKTOP]", ret);
     374}
     375
     376int xdo_get_desktop_for_window(xdo_t *xdo, Window wid, long *desktop) {
     377  Atom type;
     378  int size;
     379  long nitems;
     380  unsigned char *data;
     381
     382  Atom request;
     383
     384  request = XInternAtom(xdo->xdpy, "_NET_WM_DESKTOP", False);
     385
     386  data = _xdo_getwinprop(xdo, wid, request, &nitems, &type, &size);
     387
     388  if (nitems > 0)
     389    *desktop = *((long*)data);
     390  else
     391    *desktop = -1;
     392
     393  return _is_success("XGetWindowProperty[_NET_WM_DESKTOP]",
     394                     *desktop == -1);
     395}
     396
    222397/* XRaiseWindow is ignored in ion3 and Gnome2. Is it even useful? */
    223398int xdo_window_raise(xdo_t *xdo, Window wid) {
     
    328503}
    329504
    330 
    331505/* Add by Lee Pumphret 2007-07-28
    332506 * Modified slightly by Jordan Sissel */
     
    337511  return _is_success("XGetInputFocus", ret);
    338512}
    339 
    340513
    341514/* Helper functions */
     
    567740    fprintf(stderr, "%s failed: got bad window\n", funcname);
    568741    return False;
     742  } else if (code != 1) {
     743    fprintf(stderr, "%s failed (code=%d)\n", funcname, code);
     744    return False;
    569745  }
    570746
     
    582758}
    583759
    584 /* main test */
    585 #ifdef BUILDMAIN
    586 int main(int argc, char **argv) {
    587   char *display_name;
    588   xdo_t *xdo;
    589 
    590   char *yay;
    591 
    592   if ( (display_name = getenv("DISPLAY")) == (void *)NULL) {
    593     fprintf(stderr, "Error: DISPLAY environment variable not set\n");
    594     exit(1);
    595   }
    596 
    597   //yay = strdup("ctrl+l");
    598 
    599   xdo = xdo_new(display_name);
    600   //xdo_mousemove(xdo, 100, 100);
    601   //usleep(100 * 1000);
    602   //xdo_keysequence(xdo, strdup("ctrl+l"));
    603   //xdo_type(xdo, strdup("ls"));
    604   //xdo_keysequence(xdo, strdup("Return"));
    605 
     760/* Arbitrary window property retrieval
     761 * slightly modified version from xprop.c from Xorg */
     762unsigned char * _xdo_getwinprop(xdo_t *xdo, Window window, Atom atom,
     763                                long *nitems, Atom *type, int *size) {
     764  Atom actual_type;
     765  int actual_format;
     766  unsigned long _nitems;
     767  unsigned long nbytes;
     768  unsigned long bytes_after; /* unused */
     769  unsigned char *prop;
     770  int status;
     771
     772  status = XGetWindowProperty(xdo->xdpy, window, atom, 0, (~0L),
     773                              False, AnyPropertyType, &actual_type,
     774                              &actual_format, &_nitems, &bytes_after,
     775                              &prop);
     776  if (status == BadWindow) {
     777    fprintf(stderr, "window id # 0x%lx does not exists!", window);
     778    return NULL;
     779  } if (status != Success) {
     780    fprintf(stderr, "XGetWindowProperty failed!");
     781    return NULL;
     782  }
     783
     784  if (actual_format == 32)
     785    nbytes = sizeof(long);
     786  else if (actual_format == 16)
     787    nbytes = sizeof(short);
     788  else if (actual_format == 8)
     789    nbytes = 1;
     790  else if (actual_format == 0)
     791    nbytes = 0;
     792
     793  *nitems = _nitems;
     794  *type = actual_type;
     795  *size = actual_format;
     796  return prop;
     797}
     798
     799int _xdo_ewmh_is_supported(xdo_t *xdo, const char *feature) {
     800  Atom type = 0;
     801  long nitems = 0L;
     802  int size = 0;
     803  Atom *results = NULL;
     804  long i = 0;
     805
     806  Window root;
     807  Atom request;
     808  Atom feature_atom;
    606809 
    607   Window *list;
    608   int nwindows;
    609   char *query = "xterm";
    610   int i;
    611   if (argc > 1)
    612     query = argv[1];
    613 
    614   xdo_window_list_by_regex(xdo, query, &list, &nwindows);
    615   for (i = 0; i < nwindows; i++) {
    616     printf("%d\n", list[i]);
    617   }
    618   xdo_free(xdo);
    619 
    620   return 0;
    621 }
    622 #endif
    623 
     810  request = XInternAtom(xdo->xdpy, "_NET_SUPPORTED", False);
     811  feature_atom = XInternAtom(xdo->xdpy, feature, False);
     812  root = RootWindow(xdo->xdpy, 0);
     813
     814  results = (Atom *) _xdo_getwinprop(xdo, root, request, &nitems, &type, &size);
     815  for (i = 0L; i < nitems; i++) {
     816    if (results[i] == feature_atom)
     817      return True;
     818  }
     819
     820  return False;
     821}
  • branches/upstream/xdotool/current/xdo.h

    r1071 r1077  
    33 * - include this if you have code that uses xdo
    44 *
    5  * $Id: xdo.h 1854 2008-05-21 07:23:29Z jordansissel $
     5 * $Id: xdo.h 1876 2008-05-31 10:54:25Z jordansissel $
    66 */
    77
     
    1212#define SEARCH_CLASS (1L << 2)
    1313#define SEARCH_NAME (1L << 3)
     14
     15#define SEARCH_IGNORE_TRANSIENTS (1L << 4)
     16#define SEARCH_IGNORE_WINDOW_INPUTONLY (1L << 5)
    1417
    1518#define SIZE_USEHINTS (1L << 0)
     
    3841} xdo_t;
    3942
    40 
    4143xdo_t* xdo_new(char *display);
    4244xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
     
    6163int xdo_window_raise(xdo_t *xdo, Window wid);
    6264int xdo_window_get_focus(xdo_t *xdo, Window *window_ret);
     65int xdo_window_activate(xdo_t *xdo, Window wid);
    6366
    6467int xdo_window_map(xdo_t *xdo, Window wid);
    6568int xdo_window_unmap(xdo_t *xdo, Window wid);
    6669
     70/* pager-like behaviors */
     71int xdo_set_number_of_desktops(xdo_t *xdo, long ndesktops);
     72int xdo_get_number_of_desktops(xdo_t *xdo, long *ndesktops);
     73int xdo_set_current_desktop(xdo_t *xdo, long desktop);
     74int xdo_get_current_desktop(xdo_t *xdo, long *desktop);
     75int xdo_set_desktop_for_window(xdo_t *xdo, Window wid, long desktop);
     76int xdo_get_desktop_for_window(xdo_t *xdo, Window wid, long *desktop);
     77
    6778/* Returns: windowlist and nwindows */
    6879void xdo_window_list_by_regex(xdo_t *xdo, char *regex, int flags,
  • branches/upstream/xdotool/current/xdotool.c

    r1071 r1077  
    33 * command line interface to the xdo library
    44 *
    5  * $Id: xdotool.c 1854 2008-05-21 07:23:29Z jordansissel $
     5 * $Id: xdotool.c 1880 2008-06-01 07:23:14Z jordansissel $
    66 *
    77 * getwindowfocus contributed by Lee Pumphret
     
    2222void cmd_click(int argc, char **args);
    2323void cmd_getwindowfocus(int argc, char **args);
    24 void cmd_help(int unused_argc, char **unused_args);
     24void cmd_help(int argc, char **args);
    2525void cmd_key(int argc, char **args);
    2626void cmd_mousedown(int argc, char **args);
     
    3030void cmd_search(int argc, char **args);
    3131void cmd_type(int argc, char **args);
     32void cmd_windowactivate(int argc, char **args);
    3233void cmd_windowfocus(int argc, char **args);
    33 void cmd_windowmap(int argc, char **args);
    3434void cmd_windowmap(int argc, char **args);
    3535void cmd_windowmove(int argc, char **args);
     
    3737void cmd_windowsize(int argc, char **args);
    3838void cmd_windowunmap(int argc, char **args);
    39 void cmd_windowunmap(int argc, char **args);
     39
     40/* pager-like commands */
     41void cmd_set_num_desktops(int argc, char **args);
     42void cmd_get_num_desktops(int argc, char **args);
     43void cmd_set_desktop(int argc, char **args);
     44void cmd_get_desktop(int argc, char **args);
     45void cmd_set_desktop_for_window(int argc, char **args);
     46void cmd_get_desktop_for_window(int argc, char **args);
    4047
    4148xdo_t *xdo;
     
    5057  { "search", cmd_search, },
    5158
     59  /* Help me! */
    5260  { "help", cmd_help, },
    5361  { "-h", cmd_help, },
     
    6371  { "mouseup", cmd_mouseup, },
    6472  { "type", cmd_type, },
     73  { "windowactivate", cmd_windowactivate, },
    6574  { "windowfocus", cmd_windowfocus, },
    6675  { "windowmap", cmd_windowmap, },
     
    6978  { "windowsize", cmd_windowsize, },
    7079  { "windowunmap", cmd_windowunmap, },
     80
     81  { "set_num_desktops", cmd_set_num_desktops, },
     82  { "get_num_desktops", cmd_get_num_desktops, },
     83  { "set_desktop", cmd_set_desktop, },
     84  { "get_desktop", cmd_get_desktop, },
     85  { "set_desktop_for_window", cmd_set_desktop_for_window, },
     86  { "get_desktop_for_window", cmd_get_desktop_for_window, },
    7187  { NULL, NULL, },
    7288};
     
    103119
    104120void window_print(Window wid) {
    105   switch (sizeof(Window)) {
    106     case sizeof(int):
    107       printf("%d\n", (int)wid);
    108       break;
    109     case sizeof(long):
    110       printf("%ld\n", (long)wid);
    111       break;
    112     default:
    113       printf("Unknown window storage size (%ld)\n", sizeof(Window));
    114   }
    115 }
    116 
    117 void cmd_help(int unused_argc, char **unused_args) {
     121  /* Window is XID is 'unsigned long' or CARD32 */
     122  printf("%ld\n", wid);
     123}
     124
     125void cmd_help(int argc, char **args) {
    118126  int i;
    119127  printf("Available commands:\n");
     
    124132void cmd_mousemove(int argc, char **args) {
    125133  int x, y;
    126   char *cmd = *args;
    127   argc -= 1;
    128   args++;
     134  char *cmd = *args; argc--; args++;
    129135
    130136  if (argc != 2) {
     
    144150void cmd_mousemove_relative(int argc, char **args) {
    145151  int x, y;
    146   char *cmd = *args;
    147   argc -= 1;
    148   args++;
     152  char *cmd = *args; argc--; args++;
    149153
    150154  if (argc != 2) {
     
    164168void cmd_mousedown(int argc, char **args) {
    165169  int button;
    166   char *cmd = *args;
    167   argc -= 1;
    168   args++;
     170  char *cmd = *args; argc--; args++;
    169171
    170172  if (argc != 1) {
     
    183185void cmd_mouseup(int argc, char **args) {
    184186  int button;
    185   char *cmd = *args;
    186   argc -= 1;
    187   args++;
     187  char *cmd = *args; argc--; args++;
    188188
    189189  if (argc != 1) {
     
    207207void cmd_type(int argc, char **args) {
    208208  int i;
    209   char *cmd = *args;
    210   argc -= 1;
    211   args++;
     209  char *cmd = *args; argc--; args++;
    212210
    213211  if (argc == 0) {
     
    226224void cmd_key(int argc, char **args) {
    227225  int i;
    228   char *cmd = *args;
    229   argc -= 1;
    230   args++;
     226  char *cmd = *args; argc--; args++;
    231227
    232228  if (argc == 0) {
     
    258254  int x, y;
    259255  Window wid;
    260   char *cmd = *args;
    261   argc -= 1;
    262   args++;
     256  char *cmd = *args; argc--; args++;
    263257
    264258  if (argc != 3) {
     
    276270}
    277271
     272void cmd_windowactivate(int argc, char **args) {
     273  Window wid;
     274  char *cmd = *args; argc--; args++;
     275
     276  if (argc != 1) {
     277    printf("usage: %s wid\n", cmd);
     278    return;
     279  }
     280
     281  wid = (Window)strtol(args[0], NULL, 0);
     282  if (!xdo_window_activate(xdo, wid)) {
     283    fprintf(stderr, "xdo_window_activate reported an error\n");
     284    return;
     285  }
     286
     287}
     288
    278289void cmd_windowfocus(int argc, char **args) {
    279290  Window wid;
    280   char *cmd = *args;
    281   argc -= 1;
    282   args++;
     291  char *cmd = *args; argc--; args++;
    283292
    284293  if (argc != 1) {
     
    295304void cmd_windowraise(int argc, char **args) {
    296305  Window wid;
    297   char *cmd = *args;
    298   argc -= 1;
    299   args++;
     306  char *cmd = *args; argc--; args++;
    300307
    301308  if (argc != 1) {
     
    412419
    413420  xdo_window_list_by_regex(xdo, *args, search_flags, &list, &nwindows);
    414   /* XXX: We shouldn't assume 'Window' == 'int' here... */
    415421  for (i = 0; i < nwindows; i++)
    416422    window_print(list[i]);
     
    423429void cmd_getwindowfocus(int argc, char **args) {
    424430  Window wid = 0;
    425   char *cmd = *args;
    426   argc -= 1;
    427   args++;
     431  char *cmd = *args; argc--; args++;
    428432
    429433  if (argc != 0) {
     
    441445void cmd_windowmap(int argc, char **args) {
    442446  Window wid;
    443   char *cmd = *args;
    444   argc -= 1;
    445   args++;
     447  char *cmd = *args; argc--; args++;
    446448
    447449  if (argc != 1) {
     
    458460void cmd_windowunmap(int argc, char **args) {
    459461  Window wid;
    460   char *cmd = *args;
    461   argc -= 1;
    462   args++;
     462  char *cmd = *args; argc--; args++;
    463463
    464464  if (argc != 1) {
     
    472472  }
    473473}
     474
     475void cmd_set_num_desktops(int argc, char **args) {
     476  char *cmd = *args; argc--; args++;
     477  long ndesktops;
     478
     479  if (argc != 1) {
     480    printf("usage: %s num_desktops\n", cmd);
     481    return;
     482  }
     483
     484  ndesktops = strtol(args[0], NULL, 0);
     485
     486  xdo_set_number_of_desktops(xdo, ndesktops);
     487}
     488
     489void cmd_get_num_desktops(int argc, char **args) {
     490  char *cmd = *args; argc--; args++;
     491  long ndesktops = 0;
     492
     493  if (argc != 0) {
     494    printf("usage: %s\n", cmd);
     495    return;
     496  }
     497
     498  xdo_get_number_of_desktops(xdo, &ndesktops);
     499
     500  printf("%ld\n", ndesktops);
     501}
     502
     503void cmd_set_desktop(int argc, char **args) {
     504  char *cmd = *args; argc--; args++;
     505  long desktop;
     506
     507  if (argc != 1) {
     508    printf("usage: %s desktop\n", cmd);
     509    return;
     510  }
     511
     512  desktop = strtol(args[0], NULL, 0);
     513
     514  xdo_set_current_desktop(xdo, desktop);
     515}
     516
     517void cmd_get_desktop(int argc, char **args) {
     518  char *cmd = *args; argc--; args++;
     519  long desktop = 0;
     520
     521  if (argc != 0) {
     522    printf("usage: %s\n", cmd);
     523    return;
     524  }
     525
     526  xdo_get_current_desktop(xdo, &desktop);
     527
     528  printf("%ld\n", desktop);
     529}
     530
     531void cmd_set_desktop_for_window(int argc, char **args) {
     532  char *cmd = *args; argc--; args++;
     533  long desktop = 0;
     534  Window window = 0;
     535
     536  if (argc != 2) {
     537    printf("usage: %s <window> <desktop>\n", cmd);
     538    return;
     539  }
     540
     541  window = (Window)strtol(args[0], NULL, 0);
     542  desktop = strtol(args[1], NULL, 0);
     543
     544  xdo_set_desktop_for_window(xdo, window, desktop);
     545}
     546
     547void cmd_get_desktop_for_window(int argc, char **args) {
     548  char *cmd = *args; argc--; args++;
     549  long desktop = 0;
     550  Window window = 0;
     551
     552  if (argc != 1) {
     553    printf("usage: %s <window>\n", cmd);
     554    return;
     555  }
     556
     557  window = (Window)strtol(args[0], NULL, 0);
     558
     559  xdo_get_desktop_for_window(xdo, window, &desktop);
     560  printf("%ld\n", desktop);
     561}
Note: See TracChangeset for help on using the changeset viewer.