libxdo
|
00001 00004 #ifndef _XDO_H_ 00005 #define _XDO_H_ 00006 00007 #ifndef __USE_XOPEN 00008 #define __USE_XOPEN 00009 #endif /* __USE_XOPEN */ 00010 00011 #include <sys/types.h> 00012 #include <X11/Xlib.h> 00013 #include <X11/X.h> 00014 #include <unistd.h> 00015 #include <wchar.h> 00016 00037 #define SIZE_USEHINTS (1L << 0) 00038 #define SIZE_USEHINTS_X (1L << 1) 00039 #define SIZE_USEHINTS_Y (1L << 2) 00040 00049 #define CURRENTWINDOW (0) 00050 00055 typedef struct keysym_charmap { 00056 const char *keysym; 00057 wchar_t key; 00058 } keysym_charmap_t; 00059 00065 typedef struct charcodemap { 00066 wchar_t key; 00067 KeyCode code; 00068 KeySym symbol; 00069 int index; 00070 int modmask; 00073 int needs_binding; 00074 } charcodemap_t; 00075 00076 typedef enum { 00077 XDO_FEATURE_XTEST, 00078 } XDO_FEATURES; 00079 00083 typedef struct xdo { 00084 00086 Display *xdpy; 00087 00089 char *display_name; 00090 00092 charcodemap_t *charcodes; 00093 00095 int charcodes_len; 00096 00098 XModifierKeymap *modmap; 00099 00101 KeySym *keymap; 00102 00104 int keycode_high; /* highest and lowest keycodes */ 00105 00107 int keycode_low; /* used by this X server */ 00108 00110 int keysyms_per_keycode; 00111 00113 int close_display_when_freed; 00114 00116 int quiet; 00117 00119 int debug; 00120 00122 int features_mask; 00123 00124 } xdo_t; 00125 00126 00134 typedef struct xdo_active_mods { 00135 charcodemap_t *keymods; 00136 int nkeymods; 00137 unsigned int input_state; 00138 } xdo_active_mods_t; 00139 00140 00145 #define SEARCH_TITLE (1UL << 0) 00146 00151 #define SEARCH_CLASS (1UL << 1) 00152 00157 #define SEARCH_NAME (1UL << 2) 00158 00163 #define SEARCH_PID (1UL << 3) 00164 00169 #define SEARCH_ONLYVISIBLE (1UL << 4) 00170 00176 #define SEARCH_SCREEN (1UL << 5) 00177 00182 #define SEARCH_CLASSNAME (1UL << 6) 00183 00189 #define SEARCH_DESKTOP (1UL << 7) 00190 00191 00197 typedef struct xdo_search { 00198 const char *title; 00199 const char *winclass; 00200 const char *winclassname; 00201 const char *winname; 00202 int pid; 00203 long max_depth; 00204 int only_visible; 00205 int screen; 00210 enum { SEARCH_ANY, SEARCH_ALL } require; 00211 00215 unsigned int searchmask; 00216 00218 long desktop; 00219 00221 unsigned int limit; 00222 } xdo_search_t; 00223 00224 #define XDO_ERROR 1 00225 #define XDO_SUCCESS 0 00226 00235 xdo_t* xdo_new(char *display); 00236 00245 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display, 00246 int close_display_when_freed); 00247 00251 const char *xdo_version(void); 00252 00258 void xdo_free(xdo_t *xdo); 00259 00267 int xdo_mousemove(const xdo_t *xdo, int x, int y, int screen); 00268 00276 int xdo_mousemove_relative_to_window(const xdo_t *xdo, Window window, int x, int y); 00277 00284 int xdo_mousemove_relative(const xdo_t *xdo, int x, int y); 00285 00294 int xdo_mousedown(const xdo_t *xdo, Window window, int button); 00295 00304 int xdo_mouseup(const xdo_t *xdo, Window window, int button); 00305 00313 int xdo_mouselocation(const xdo_t *xdo, int *x, int *y, int *screen_num); 00314 00320 int xdo_mousewindow(const xdo_t *xdo, Window *window_ret); 00321 00334 int xdo_mouselocation2(const xdo_t *xdo, int *x_ret, int *y_ret, 00335 int *screen_num_ret, Window *window_ret); 00336 00344 int xdo_mouse_wait_for_move_from(const xdo_t *xdo, int origin_x, int origin_y); 00345 00353 int xdo_mouse_wait_for_move_to(const xdo_t *xdo, int dest_x, int dest_y); 00354 00362 int xdo_click(const xdo_t *xdo, Window window, int button); 00363 00372 int xdo_click_multiple(const xdo_t *xdo, Window window, int button, 00373 int repeat, useconds_t delay); 00374 00386 int xdo_type(const xdo_t *xdo, Window window, const char *string, useconds_t delay); 00387 00409 int xdo_keysequence(const xdo_t *xdo, Window window, 00410 const char *keysequence, useconds_t delay); 00411 00417 int xdo_keysequence_up(const xdo_t *xdo, Window window, 00418 const char *keysequence, useconds_t delay); 00419 00425 int xdo_keysequence_down(const xdo_t *xdo, Window window, 00426 const char *keysequence, useconds_t delay); 00427 00439 int xdo_keysequence_list_do(const xdo_t *xdo, Window window, 00440 charcodemap_t *keys, int nkeys, 00441 int pressed, int *modifier, useconds_t delay); 00442 00450 int xdo_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys, 00451 int *nkeys); 00452 00465 int xdo_window_wait_for_map_state(const xdo_t *xdo, Window wid, int map_state); 00466 00467 #define SIZE_TO 0 00468 #define SIZE_FROM 1 00469 int xdo_window_wait_for_size(const xdo_t *xdo, Window window, unsigned int width, 00470 unsigned int height, int flags, int to_or_from); 00471 00472 00482 int xdo_window_move(const xdo_t *xdo, Window wid, int x, int y); 00483 00496 int xdo_window_translate_with_sizehint(const xdo_t *xdo, Window window, 00497 int width, int height, int *width_ret, 00498 int *height_ret); 00499 00509 int xdo_window_setsize(const xdo_t *xdo, Window wid, int w, int h, int flags); 00510 00520 int xdo_window_setprop (const xdo_t *xdo, Window wid, const char *property, 00521 const char *value); 00522 00529 int xdo_window_setclass(const xdo_t *xdo, Window wid, const char *name, 00530 const char *class); 00531 00535 int xdo_window_seturgency (const xdo_t *xdo, Window wid, int urgency); 00536 00546 int xdo_window_set_override_redirect(const xdo_t *xdo, Window wid, 00547 int override_redirect); 00548 00555 int xdo_window_focus(const xdo_t *xdo, Window wid); 00556 00563 int xdo_window_raise(const xdo_t *xdo, Window wid); 00564 00571 int xdo_window_get_focus(const xdo_t *xdo, Window *window_ret); 00572 00579 int xdo_window_wait_for_focus(const xdo_t *xdo, Window window, int want_focus); 00580 00588 int xdo_window_get_pid(const xdo_t *xdo, Window window); 00589 00599 int xdo_window_sane_get_focus(const xdo_t *xdo, Window *window_ret); 00600 00612 int xdo_window_activate(const xdo_t *xdo, Window wid); 00613 00623 int xdo_window_wait_for_active(const xdo_t *xdo, Window window, int active); 00624 00631 int xdo_window_map(const xdo_t *xdo, Window wid); 00632 00638 int xdo_window_unmap(const xdo_t *xdo, Window wid); 00639 00643 int xdo_window_minimize(const xdo_t *xdo, Window wid); 00644 00651 int xdo_window_reparent(const xdo_t *xdo, Window wid_source, Window wid_target); 00652 00664 int xdo_get_window_location(const xdo_t *xdo, Window wid, 00665 int *x_ret, int *y_ret, Screen **screen_ret); 00666 00674 int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret, 00675 unsigned int *height_ret); 00676 00677 /* pager-like behaviors */ 00678 00686 int xdo_window_get_active(const xdo_t *xdo, Window *window_ret); 00687 00694 int xdo_window_select_with_click(const xdo_t *xdo, Window *window_ret); 00695 00702 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops); 00703 00711 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops); 00712 00719 int xdo_set_current_desktop(const xdo_t *xdo, long desktop); 00720 00727 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop); 00728 00736 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop); 00737 00748 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop); 00749 00758 int xdo_window_search(const xdo_t *xdo, const xdo_search_t *search, 00759 Window **windowlist_ret, int *nwindows_ret); 00760 00772 unsigned char *xdo_getwinprop(const xdo_t *xdo, Window window, Atom atom, 00773 long *nitems, Atom *type, int *size); 00774 00782 unsigned int xdo_get_input_state(const xdo_t *xdo); 00783 00788 const keysym_charmap_t *xdo_keysym_charmap(void); 00789 00798 const char **xdo_symbol_map(void); 00799 00800 /* active modifiers stuff */ 00801 00805 xdo_active_mods_t *xdo_get_active_modifiers(const xdo_t *xdo); 00806 00812 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window, 00813 xdo_active_mods_t *active_mods); 00814 00820 int xdo_set_active_modifiers(const xdo_t *xdo, Window window, 00821 const xdo_active_mods_t *active_mods); 00822 00826 void xdo_free_active_modifiers(xdo_active_mods_t *active_mods); 00827 00834 int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret); 00835 00842 int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y); 00843 00848 int xdo_window_kill(const xdo_t *xdo, Window window); 00849 00853 #define XDO_FIND_PARENTS (0) 00854 00858 #define XDO_FIND_CHILDREN (1) 00859 00864 int xdo_window_find_client(const xdo_t *xdo, Window window, Window *window_ret, 00865 int direction); 00866 00872 int xdo_get_window_name(const xdo_t *xdo, Window window, 00873 unsigned char **name_ret, int *name_len_ret, 00874 int *name_type); 00875 00884 void xdo_disable_feature(xdo_t *xdo, int feature); 00885 00894 void xdo_enable_feature(xdo_t *xdo, int feature); 00895 00904 int xdo_has_feature(xdo_t *xdo, int feature); 00905 00909 int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width, 00910 unsigned int *height, int screen); 00911 #endif /* ifndef _XDO_H_ */