00001
00004 #ifndef _XDO_H_
00005 #define _XDO_H_
00006
00007 #ifndef __USE_XOPEN
00008 #define __USE_XOPEN
00009 #endif
00010
00011 #include <sys/types.h>
00012 #include <X11/Xlib.h>
00013 #include <X11/X.h>
00014 #include <unistd.h>
00015
00033 #define SIZE_USEHINTS (1L << 0)
00034
00043 #define CURRENTWINDOW (0)
00044
00049 typedef struct keysym_charmap {
00050 const char *keysym;
00051 char key;
00052 } keysym_charmap_t;
00053
00059 typedef struct charcodemap {
00060 char key;
00061 KeyCode code;
00062 KeySym symbol;
00063 int index;
00064 int modmask;
00067 int needs_binding;
00068 } charcodemap_t;
00069
00073 typedef struct xdo {
00074
00076 Display *xdpy;
00077
00079 char *display_name;
00080
00082 charcodemap_t *charcodes;
00083
00085 int charcodes_len;
00086
00088 XModifierKeymap *modmap;
00089
00091 KeySym *keymap;
00092
00094 int keycode_high;
00095
00097 int keycode_low;
00098
00100 int keysyms_per_keycode;
00101
00103 int close_display_when_freed;
00104 } xdo_t;
00105
00106
00114 typedef struct xdo_active_mods {
00115 charcodemap_t *keymods;
00116 int nkeymods;
00117 unsigned int input_state;
00118 } xdo_active_mods_t;
00119
00120
00125 #define SEARCH_TITLE (1UL << 0)
00126
00131 #define SEARCH_CLASS (1UL << 1)
00132
00137 #define SEARCH_NAME (1UL << 2)
00138
00143 #define SEARCH_PID (1UL << 3)
00144
00149 #define SEARCH_ONLYVISIBLE (1UL << 4)
00150
00156 #define SEARCH_SCREEN (1UL << 5)
00157
00162 #define SEARCH_CLASSNAME (1UL << 6)
00163
00164
00170 typedef struct xdo_search {
00171 char *title;
00172 char *winclass;
00173 char *winclassname;
00174 char *winname;
00175 int pid;
00176 long max_depth;
00177 int only_visible;
00178 int screen;
00183 enum { SEARCH_ANY, SEARCH_ALL } require;
00184
00188 unsigned int searchmask;
00189 } xdo_search_t;
00190
00191 #define XDO_ERROR 1
00192 #define XDO_SUCCESS 0
00193
00202 xdo_t* xdo_new(char *display);
00203
00212 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
00213 int close_display_when_freed);
00214
00218 const char *xdo_version(void);
00219
00225 void xdo_free(xdo_t *xdo);
00226
00227
00235 int xdo_mousemove(const xdo_t *xdo, int x, int y, int screen);
00236
00244 int xdo_mousemove_relative_to_window(const xdo_t *xdo, Window window, int x, int y);
00245
00252 int xdo_mousemove_relative(const xdo_t *xdo, int x, int y);
00253
00262 int xdo_mousedown(const xdo_t *xdo, Window window, int button);
00263
00272 int xdo_mouseup(const xdo_t *xdo, Window window, int button);
00273
00281 int xdo_mouselocation(const xdo_t *xdo, int *x, int *y, int *screen_num);
00282
00290 int xdo_mouse_wait_for_move_from(const xdo_t *xdo, int origin_x, int origin_y);
00291
00299 int xdo_mouse_wait_for_move_to(const xdo_t *xdo, int dest_x, int dest_y);
00300
00308 int xdo_click(const xdo_t *xdo, Window window, int button);
00309
00321 int xdo_type(const xdo_t *xdo, Window window, char *string, useconds_t delay);
00322
00344 int xdo_keysequence(const xdo_t *xdo, Window window,
00345 const char *keysequence, useconds_t delay);
00346
00352 int xdo_keysequence_up(const xdo_t *xdo, Window window,
00353 const char *keysequence, useconds_t delay);
00354
00360 int xdo_keysequence_down(const xdo_t *xdo, Window window,
00361 const char *keysequence, useconds_t delay);
00362
00374 int xdo_keysequence_list_do(const xdo_t *xdo, Window window,
00375 charcodemap_t *keys, int nkeys,
00376 int pressed, int *modifier, useconds_t delay);
00377
00385 int xdo_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys,
00386 int *nkeys);
00387
00400 int xdo_window_wait_for_map_state(const xdo_t *xdo, Window wid, int map_state);
00401
00402 #define SIZE_TO 0
00403 #define SIZE_FROM 1
00404 int xdo_window_wait_for_size(const xdo_t *xdo, Window window, unsigned int width,
00405 unsigned int height, int flags, int to_or_from);
00406
00407
00417 int xdo_window_move(const xdo_t *xdo, Window wid, int x, int y);
00418
00431 int xdo_window_translate_with_sizehint(const xdo_t *xdo, Window window,
00432 int width, int height, int *width_ret,
00433 int *height_ret);
00434
00444 int xdo_window_setsize(const xdo_t *xdo, Window wid, int w, int h, int flags);
00445
00455 int xdo_window_setprop (const xdo_t *xdo, Window wid, const char *property,
00456 const char *value);
00457
00464 int xdo_window_setclass(const xdo_t *xdo, Window wid, const char *name,
00465 const char *class);
00466
00473 int xdo_window_focus(const xdo_t *xdo, Window wid);
00474
00481 int xdo_window_raise(const xdo_t *xdo, Window wid);
00482
00489 int xdo_window_get_focus(const xdo_t *xdo, Window *window_ret);
00490
00497 int xdo_window_wait_for_focus(const xdo_t *xdo, Window window, int want_focus);
00498
00506 int xdo_window_get_pid(const xdo_t *xdo, Window window);
00507
00517 int xdo_window_sane_get_focus(const xdo_t *xdo, Window *window_ret);
00518
00530 int xdo_window_activate(const xdo_t *xdo, Window wid);
00531
00541 int xdo_window_wait_for_active(const xdo_t *xdo, Window window, int active);
00542
00549 int xdo_window_map(const xdo_t *xdo, Window wid);
00550
00556 int xdo_window_unmap(const xdo_t *xdo, Window wid);
00557
00569 int xdo_get_window_location(const xdo_t *xdo, Window wid,
00570 int *x_ret, int *y_ret, Screen **screen_ret);
00571
00579 int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret,
00580 unsigned int *height_ret);
00581
00582
00583
00591 int xdo_window_get_active(const xdo_t *xdo, Window *window_ret);
00592
00599 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops);
00600
00608 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops);
00609
00616 int xdo_set_current_desktop(const xdo_t *xdo, long desktop);
00617
00624 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop);
00625
00633 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop);
00634
00642 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop);
00643
00652 int xdo_window_search(const xdo_t *xdo, const xdo_search_t *search,
00653 Window **windowlist_ret, int *nwindows_ret);
00654
00666 unsigned char *xdo_getwinprop(const xdo_t *xdo, Window window, Atom atom,
00667 long *nitems, Atom *type, int *size);
00668
00676 unsigned int xdo_get_input_state(const xdo_t *xdo);
00677
00682 const keysym_charmap_t *xdo_keysym_charmap(void);
00683
00692 const char **xdo_symbol_map(void);
00693
00694
00695
00699 xdo_active_mods_t *xdo_get_active_modifiers(const xdo_t *xdo);
00700
00706 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window,
00707 xdo_active_mods_t *active_mods);
00708
00714 int xdo_set_active_modifiers(const xdo_t *xdo, Window window,
00715 const xdo_active_mods_t *active_mods);
00716
00720 void xdo_free_active_modifiers(xdo_active_mods_t *active_mods);
00721
00722 #endif