libxdo
 All Data Structures Files Functions Variables Typedefs
xdo.h
Go to the documentation of this file.
1 
4 #ifndef _XDO_H_
5 #define _XDO_H_
6 
7 #ifndef __USE_XOPEN
8 #define __USE_XOPEN
9 #endif /* __USE_XOPEN */
10 
11 #include <sys/types.h>
12 #include <X11/Xlib.h>
13 #include <X11/X.h>
14 #include <unistd.h>
15 #include <wchar.h>
16 
37 #define SIZE_USEHINTS (1L << 0)
38 #define SIZE_USEHINTS_X (1L << 1)
39 #define SIZE_USEHINTS_Y (1L << 2)
40 
49 #define CURRENTWINDOW (0)
50 
55 typedef struct keysym_charmap {
56  const char *keysym;
57  wchar_t key;
59 
65 typedef struct charcodemap {
66  wchar_t key;
67  KeyCode code;
68  KeySym symbol;
69  int index;
70  int modmask;
75 
76 typedef enum {
77  XDO_FEATURE_XTEST,
78 } XDO_FEATURES;
79 
83 typedef struct xdo {
84 
86  Display *xdpy;
87 
89  char *display_name;
90 
92  charcodemap_t *charcodes;
93 
95  int charcodes_len;
96 
98  XModifierKeymap *modmap;
99 
101  KeySym *keymap;
102 
104  int keycode_high; /* highest and lowest keycodes */
105 
107  int keycode_low; /* used by this X server */
108 
110  int keysyms_per_keycode;
111 
114 
116  int quiet;
117 
119  int debug;
120 
123 
124 } xdo_t;
125 
126 
134 typedef struct xdo_active_mods {
135  charcodemap_t *keymods;
136  int nkeymods;
137  unsigned int input_state;
139 
140 
145 #define SEARCH_TITLE (1UL << 0)
146 
151 #define SEARCH_CLASS (1UL << 1)
152 
157 #define SEARCH_NAME (1UL << 2)
158 
163 #define SEARCH_PID (1UL << 3)
164 
169 #define SEARCH_ONLYVISIBLE (1UL << 4)
170 
176 #define SEARCH_SCREEN (1UL << 5)
177 
182 #define SEARCH_CLASSNAME (1UL << 6)
183 
189 #define SEARCH_DESKTOP (1UL << 7)
190 
191 
197 typedef struct xdo_search {
198  const char *title;
199  const char *winclass;
200  const char *winclassname;
201  const char *winname;
202  int pid;
203  long max_depth;
205  int screen;
210  enum { SEARCH_ANY, SEARCH_ALL } require;
211 
215  unsigned int searchmask;
216 
218  long desktop;
219 
221  unsigned int limit;
222 } xdo_search_t;
223 
224 #define XDO_ERROR 1
225 #define XDO_SUCCESS 0
226 
235 xdo_t* xdo_new(char *display);
236 
245 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
246  int close_display_when_freed);
247 
251 const char *xdo_version(void);
252 
258 void xdo_free(xdo_t *xdo);
259 
267 int xdo_mousemove(const xdo_t *xdo, int x, int y, int screen);
268 
276 int xdo_mousemove_relative_to_window(const xdo_t *xdo, Window window, int x, int y);
277 
284 int xdo_mousemove_relative(const xdo_t *xdo, int x, int y);
285 
294 int xdo_mousedown(const xdo_t *xdo, Window window, int button);
295 
304 int xdo_mouseup(const xdo_t *xdo, Window window, int button);
305 
313 int xdo_mouselocation(const xdo_t *xdo, int *x, int *y, int *screen_num);
314 
320 int xdo_mousewindow(const xdo_t *xdo, Window *window_ret);
321 
334 int xdo_mouselocation2(const xdo_t *xdo, int *x_ret, int *y_ret,
335  int *screen_num_ret, Window *window_ret);
336 
344 int xdo_mouse_wait_for_move_from(const xdo_t *xdo, int origin_x, int origin_y);
345 
353 int xdo_mouse_wait_for_move_to(const xdo_t *xdo, int dest_x, int dest_y);
354 
362 int xdo_click(const xdo_t *xdo, Window window, int button);
363 
372 int xdo_click_multiple(const xdo_t *xdo, Window window, int button,
373  int repeat, useconds_t delay);
374 
386 int xdo_type(const xdo_t *xdo, Window window, const char *string, useconds_t delay);
387 
409 int xdo_keysequence(const xdo_t *xdo, Window window,
410  const char *keysequence, useconds_t delay);
411 
417 int xdo_keysequence_up(const xdo_t *xdo, Window window,
418  const char *keysequence, useconds_t delay);
419 
425 int xdo_keysequence_down(const xdo_t *xdo, Window window,
426  const char *keysequence, useconds_t delay);
427 
439 int xdo_keysequence_list_do(const xdo_t *xdo, Window window,
440  charcodemap_t *keys, int nkeys,
441  int pressed, int *modifier, useconds_t delay);
442 
450 int xdo_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys,
451  int *nkeys);
452 
465 int xdo_window_wait_for_map_state(const xdo_t *xdo, Window wid, int map_state);
466 
467 #define SIZE_TO 0
468 #define SIZE_FROM 1
469 int xdo_window_wait_for_size(const xdo_t *xdo, Window window, unsigned int width,
470  unsigned int height, int flags, int to_or_from);
471 
472 
482 int xdo_window_move(const xdo_t *xdo, Window wid, int x, int y);
483 
496 int xdo_window_translate_with_sizehint(const xdo_t *xdo, Window window,
497  int width, int height, int *width_ret,
498  int *height_ret);
499 
509 int xdo_window_setsize(const xdo_t *xdo, Window wid, int w, int h, int flags);
510 
520 int xdo_window_setprop (const xdo_t *xdo, Window wid, const char *property,
521  const char *value);
522 
529 int xdo_window_setclass(const xdo_t *xdo, Window wid, const char *name,
530  const char *_class);
531 
535 int xdo_window_seturgency (const xdo_t *xdo, Window wid, int urgency);
536 
546 int xdo_window_set_override_redirect(const xdo_t *xdo, Window wid,
547  int override_redirect);
548 
555 int xdo_window_focus(const xdo_t *xdo, Window wid);
556 
563 int xdo_window_raise(const xdo_t *xdo, Window wid);
564 
571 int xdo_window_get_focus(const xdo_t *xdo, Window *window_ret);
572 
579 int xdo_window_wait_for_focus(const xdo_t *xdo, Window window, int want_focus);
580 
588 int xdo_window_get_pid(const xdo_t *xdo, Window window);
589 
599 int xdo_window_sane_get_focus(const xdo_t *xdo, Window *window_ret);
600 
612 int xdo_window_activate(const xdo_t *xdo, Window wid);
613 
623 int xdo_window_wait_for_active(const xdo_t *xdo, Window window, int active);
624 
631 int xdo_window_map(const xdo_t *xdo, Window wid);
632 
638 int xdo_window_unmap(const xdo_t *xdo, Window wid);
639 
643 int xdo_window_minimize(const xdo_t *xdo, Window wid);
644 
651 int xdo_window_reparent(const xdo_t *xdo, Window wid_source, Window wid_target);
652 
664 int xdo_get_window_location(const xdo_t *xdo, Window wid,
665  int *x_ret, int *y_ret, Screen **screen_ret);
666 
674 int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret,
675  unsigned int *height_ret);
676 
677 /* pager-like behaviors */
678 
686 int xdo_window_get_active(const xdo_t *xdo, Window *window_ret);
687 
694 int xdo_window_select_with_click(const xdo_t *xdo, Window *window_ret);
695 
702 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops);
703 
711 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops);
712 
719 int xdo_set_current_desktop(const xdo_t *xdo, long desktop);
720 
727 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop);
728 
736 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop);
737 
748 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop);
749 
758 int xdo_window_search(const xdo_t *xdo, const xdo_search_t *search,
759  Window **windowlist_ret, int *nwindows_ret);
760 
772 unsigned char *xdo_getwinprop(const xdo_t *xdo, Window window, Atom atom,
773  long *nitems, Atom *type, int *size);
774 
782 unsigned int xdo_get_input_state(const xdo_t *xdo);
783 
788 const keysym_charmap_t *xdo_keysym_charmap(void);
789 
798 const char **xdo_symbol_map(void);
799 
800 /* active modifiers stuff */
801 
805 xdo_active_mods_t *xdo_get_active_modifiers(const xdo_t *xdo);
806 
812 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window,
813  xdo_active_mods_t *active_mods);
814 
820 int xdo_set_active_modifiers(const xdo_t *xdo, Window window,
821  const xdo_active_mods_t *active_mods);
822 
826 void xdo_free_active_modifiers(xdo_active_mods_t *active_mods);
827 
834 int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret);
835 
842 int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y);
843 
848 int xdo_window_kill(const xdo_t *xdo, Window window);
849 
853 #define XDO_FIND_PARENTS (0)
854 
858 #define XDO_FIND_CHILDREN (1)
859 
864 int xdo_window_find_client(const xdo_t *xdo, Window window, Window *window_ret,
865  int direction);
866 
872 int xdo_get_window_name(const xdo_t *xdo, Window window,
873  unsigned char **name_ret, int *name_len_ret,
874  int *name_type);
875 
884 void xdo_disable_feature(xdo_t *xdo, int feature);
885 
894 void xdo_enable_feature(xdo_t *xdo, int feature);
895 
904 int xdo_has_feature(xdo_t *xdo, int feature);
905 
909 int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width,
910  unsigned int *height, int screen);
911 #endif /* ifndef _XDO_H_ */