Changeset 1103 for branches


Ignore:
Timestamp:
Jul 18, 2008, 6:06:47 PM (10 years ago)
Author:
Daniel Kahn Gillmor
Message:

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

Location:
branches/upstream/xdotool/current
Files:
5 edited

Legend:

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

    r1090 r1103  
     120080716:
     2  * Fix return codes in xdo_keysequence() and other functions
     3
    1420080606:
    25  * Correctly report an error if xdotool is invoked with an invalid command.
  • branches/upstream/xdotool/current/Makefile

    r1085 r1103  
    1 PREFIX=/usr/local
    2 INSTALLBIN=/usr/local/bin
    3 INSTALLMAN=/usr/local/man
     1PREFIX?=/usr/local
     2INSTALLBIN=$(PREFIX)/bin
     3INSTALLMAN=$(PREFIX)/man
    44
    5 WARNFLAGS+=-pedantic -Wall -W -Wno-missing-field-initializers -Wundef \
     5WARNFLAGS+=-pedantic -Wall -W -Wundef \
    66           -Wendif-labels -Wshadow -Wpointer-arith -Wbad-function-cast \
    77           -Wcast-align -Wwrite-strings -Wstrict-prototypes \
    88           -Wmissing-prototypes -Wnested-externs -Winline \
    9            -Wdisabled-optimization
     9           -Wdisabled-optimization -Wno-missing-field-initializers
    1010
    1111CFLAGS=-pipe -std=c99 $(WARNFLAGS)
     
    4141
    4242xdo.o: xdo.c
    43         gcc $(CFLAGS) -c xdo.c
     43        $(CC) $(CFLAGS) -c xdo.c
    4444
    4545xdotool.o: xdotool.c
    46         gcc $(CFLAGS) -c xdotool.c
     46        $(CC) $(CFLAGS) -c xdotool.c
    4747
    4848xdo.c: xdo.h
     
    5050
    5151xdotool: xdotool.o xdo.o
    52         gcc $(CFLAGS) $(LDFLAGS) xdotool.o xdo.o -o $@
     52        $(CC) $(CFLAGS) $(LDFLAGS) xdotool.o xdo.o -o $@
    5353
    5454xdotool.1: xdotool.pod
  • branches/upstream/xdotool/current/xdo.c

    r1090 r1103  
    11/* xdo library
    22 *
    3  * $Id: xdo.c 1917 2008-06-06 06:59:27Z jordansissel $
     3 * $Id: xdo.c 1954 2008-07-16 23:21:28Z jordansissel $
    44 *
    55 * - getwindowfocus contributed by Lee Pumphret
     
    103103
    104104int xdo_window_map(xdo_t *xdo, Window wid) {
    105   int ret;
     105  int ret = 0;
    106106  ret = XMapWindow(xdo->xdpy, wid);
    107107  XFlush(xdo->xdpy);
     
    110110
    111111int xdo_window_unmap(xdo_t *xdo, Window wid) {
    112   int ret;
     112  int ret = 0;
    113113  ret = XUnmapWindow(xdo->xdpy, wid);
    114114  XFlush(xdo->xdpy);
     
    124124  int matched_window_list_size = 100;
    125125
    126   int ret;
    127   int i;
     126  int ret = 0;
     127  int i = 0;
    128128
    129129  ret = regcomp(&re, regex, REG_EXTENDED | REG_ICASE);
     
    171171int xdo_window_move(xdo_t *xdo, Window wid, int x, int y) {
    172172  XWindowChanges wc;
    173   int ret;
     173  int ret = 0;
    174174  wc.x = x;
    175175  wc.y = y;
     
    181181int xdo_window_setsize(xdo_t *xdo, Window wid, int width, int height, int flags) {
    182182  XWindowChanges wc;
    183   int ret;
     183  int ret = 0;
    184184  int cw_flags = 0;
    185185
     
    217217
    218218int xdo_window_focus(xdo_t *xdo, Window wid) {
    219   int ret;
     219  int ret = 0;
    220220  ret = XSetInputFocus(xdo->xdpy, wid, RevertToParent, CurrentTime);
    221221  XFlush(xdo->xdpy);
     
    224224
    225225int xdo_window_activate(xdo_t *xdo, Window wid) {
    226   int ret;
     226  int ret = 0;
    227227  long desktop = 0;
    228228  XEvent xev;
     
    267267  XEvent xev;
    268268  Window root;
    269   int ret;
     269  int ret = 0;
    270270
    271271  if (_xdo_ewmh_is_supported(xdo, "_NET_NUMBER_OF_DESKTOPS") == False) {
     
    328328  XEvent xev;
    329329  Window root;
    330   int ret;
     330  int ret = 0;
    331331
    332332  root = RootWindow(xdo->xdpy, 0);
     
    388388int xdo_set_desktop_for_window(xdo_t *xdo, Window wid, long desktop) {
    389389  XEvent xev;
    390   int ret;
     390  int ret = 0;
    391391  XWindowAttributes wattr;
    392392  XGetWindowAttributes(xdo->xdpy, wid, &wattr);
     
    445445}
    446446
     447int xdo_window_get_active(xdo_t *xdo, Window *window_ret) {
     448  Atom type;
     449  int size;
     450  long nitems;
     451  unsigned char *data;
     452  Atom request;
     453  Window root;
     454
     455  if (_xdo_ewmh_is_supported(xdo, "_NET_ACTIVE_WINDOW") == False) {
     456    fprintf(stderr,
     457            "Your windowmanager claims not to support _NET_ACTIVE_WINDOW, "
     458            "so the attempt to query the active window aborted.\n");
     459    return 1;
     460  }
     461
     462  request = XInternAtom(xdo->xdpy, "_NET_ACTIVE_WINDOW", False);
     463  root = XDefaultRootWindow(xdo->xdpy);
     464  data = _xdo_getwinprop(xdo, root, request, &nitems, &type, &size);
     465
     466  if (nitems > 0)
     467    *window_ret = *((Window*)data);
     468  else
     469    *window_ret = 0;
     470
     471  return _is_success("XGetWindowProperty[_NET_ACTIVE_WINDOW]",
     472                     *window_ret == 0);
     473}
     474
    447475/* XRaiseWindow is ignored in ion3 and Gnome2. Is it even useful? */
    448476int xdo_window_raise(xdo_t *xdo, Window wid) {
    449   int ret;
     477  int ret = 0;
    450478  ret = XRaiseWindow(xdo->xdpy, wid);
    451479  XFlush(xdo->xdpy);
     
    455483/* XXX: Include 'screen number' support? */
    456484int xdo_mousemove(xdo_t *xdo, int x, int y)  {
    457   int ret;
     485  int ret = 0;
    458486  ret = XTestFakeMotionEvent(xdo->xdpy, -1, x, y, CurrentTime);
    459487  XFlush(xdo->xdpy);
     
    462490
    463491int xdo_mousemove_relative(xdo_t *xdo, int x, int y)  {
    464   int ret;
     492  int ret = 0;
    465493  ret = XTestFakeRelativeMotionEvent(xdo->xdpy, x, y, CurrentTime);
    466494  XFlush(xdo->xdpy);
     
    469497
    470498int xdo_mousedown(xdo_t *xdo, int button) {
    471   int ret;
     499  int ret = 0;
    472500  ret = XTestFakeButtonEvent(xdo->xdpy, button, True, CurrentTime);
    473501  XFlush(xdo->xdpy);
     
    476504
    477505int xdo_mouseup(xdo_t *xdo, int button) {
    478   int ret;
     506  int ret = 0;
    479507  ret = XTestFakeButtonEvent(xdo->xdpy, button, False, CurrentTime);
    480508  XFlush(xdo->xdpy);
     
    482510}
    483511
     512int xdo_mouselocation(xdo_t *xdo, int *x_ret, int *y_ret, int *screen_num_ret) {
     513  int ret = False;
     514  int x = 0, y = 0, screen_num = 0;
     515  int i = 0;
     516  Window dummy_win = 0;
     517  int dummy_int = 0;
     518  unsigned int dummy_uint = 0;
     519  int screencount = ScreenCount(xdo->xdpy);
     520
     521  for (i = 0; i < screencount; i++) {
     522    Screen *screen = ScreenOfDisplay(xdo->xdpy, i);
     523    ret = XQueryPointer(xdo->xdpy, RootWindowOfScreen(screen),
     524                        &dummy_win, &dummy_win,
     525                        &x, &y, &dummy_int, &dummy_int, &dummy_uint);
     526    if (ret == True) {
     527      screen_num = i;
     528      break;
     529    }
     530  }
     531
     532  if (ret == True) {
     533    if (x_ret != NULL) *x_ret = x;
     534    if (y_ret != NULL) *y_ret = y;
     535    if (screen_num_ret != NULL) *screen_num_ret = screen_num;
     536  }
     537
     538  return _is_success("XQueryPointer", ret == False);
     539
     540}
     541
    484542int xdo_click(xdo_t *xdo, int button) {
    485   int ret;
     543  int ret = 0;
    486544  ret = xdo_mousedown(xdo, button);
    487545  if (ret)
     
    547605
    548606int xdo_keysequence(xdo_t *xdo, char *keyseq) {
    549   int ret;
     607  int ret = 0;
    550608  ret += _xdo_keysequence_do(xdo, keyseq, True);
    551609  ret += _xdo_keysequence_do(xdo, keyseq, False);
     
    556614 * Modified slightly by Jordan Sissel */
    557615int xdo_window_get_focus(xdo_t *xdo, Window *window_ret) {
    558   int ret;
     616  int ret = 0;
    559617  int unused_revert_ret;
    560618  ret = XGetInputFocus(xdo->xdpy, window_ret, &unused_revert_ret);
  • branches/upstream/xdotool/current/xdo.h

    r1085 r1103  
    33 * - include this if you have code that uses xdo
    44 *
    5  * $Id: xdo.h 1891 2008-06-03 09:00:20Z jordansissel $
     5 * $Id: xdo.h 1947 2008-06-16 03:41:25Z jordansissel $
    66 */
    77
     
    5050int xdo_mousedown(xdo_t *xdo, int button);
    5151int xdo_mouseup(xdo_t *xdo, int button);
     52int xdo_mouselocation(xdo_t *xdo, int *x, int *y, int *screen_num);
    5253
    5354int xdo_click(xdo_t *xdo, int button);
     
    6970
    7071/* pager-like behaviors */
     72int xdo_window_get_active(xdo_t *xdo, Window *window_ret);
    7173int xdo_set_number_of_desktops(xdo_t *xdo, long ndesktops);
    7274int xdo_get_number_of_desktops(xdo_t *xdo, long *ndesktops);
  • branches/upstream/xdotool/current/xdotool.c

    r1090 r1103  
    33 * command line interface to the xdo library
    44 *
    5  * $Id: xdotool.c 1894 2008-06-03 16:42:45Z jordansissel $
     5 * $Id: xdotool.c 1947 2008-06-16 03:41:25Z jordansissel $
    66 *
    77 * getwindowfocus contributed by Lee Pumphret
     
    2222int cmd_click(int argc, char **args);
    2323int cmd_getwindowfocus(int argc, char **args);
     24int cmd_getactivewindow(int argc, char **args);
    2425int cmd_help(int argc, char **args);
    2526int cmd_key(int argc, char **args);
     
    2829int cmd_mousemove_relative(int argc, char **args);
    2930int cmd_mouseup(int argc, char **args);
     31int cmd_mouselocation(int argc, char **args);
    3032int cmd_search(int argc, char **args);
    3133int cmd_type(int argc, char **args);
     
    5557  /* Query functions */
    5658  { "getwindowfocus", cmd_getwindowfocus, },
     59  { "getactivewindow", cmd_getactivewindow, },
    5760  { "search", cmd_search, },
    5861
     
    7073  { "mousemove_relative", cmd_mousemove_relative, },
    7174  { "mouseup", cmd_mouseup, },
     75  { "mouselocation", cmd_mouselocation, },
    7276  { "type", cmd_type, },
    7377  { "windowactivate", cmd_windowactivate, },
     
    223227  if (ret)
    224228    fprintf(stderr, "xdo_mouseup reported an error\n");
    225  
     229
     230  return ret;
     231}
     232
     233int cmd_mouselocation(int argc, char **args) {
     234  int x, y, screen_num;
     235  int ret;
     236  char *cmd = *args; argc--; args++;
     237
     238  if (argc != 0) {
     239    fprintf(stderr, "usage: %s\n", cmd);
     240    return 1;
     241  }
     242
     243  ret = xdo_mouselocation(xdo, &x, &y, &screen_num);
     244  printf("x:%d y:%d screen:%d\n", x, y, screen_num);
    226245  return ret;
    227246}
     
    512531}
    513532
     533int cmd_getactivewindow(int argc, char **args) {
     534  Window wid = 0;
     535  int ret;
     536  char *cmd = *args; argc--; args++;
     537
     538  if (argc != 0) {
     539    printf("usage: %s\n", cmd);
     540    return 1;
     541  }
     542
     543  ret = xdo_window_get_active(xdo, &wid);
     544
     545  if (ret) {
     546    fprintf(stderr, "xdo_get_active_window reported an error\n");
     547  } else {
     548    window_print(wid);
     549  }
     550}
     551
    514552int cmd_windowmap(int argc, char **args) {
    515553  int ret = 0;
Note: See TracChangeset for help on using the changeset viewer.