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 
131 #define SEARCH_TITLE (1UL << 0)
132 
137 #define SEARCH_CLASS (1UL << 1)
138 
143 #define SEARCH_NAME (1UL << 2)
144 
149 #define SEARCH_PID (1UL << 3)
150 
155 #define SEARCH_ONLYVISIBLE (1UL << 4)
156 
162 #define SEARCH_SCREEN (1UL << 5)
163 
168 #define SEARCH_CLASSNAME (1UL << 6)
169 
175 #define SEARCH_DESKTOP (1UL << 7)
176 
177 
183 typedef struct xdo_search {
184  const char *title;
185  const char *winclass;
186  const char *winclassname;
187  const char *winname;
188  int pid;
189  long max_depth;
191  int screen;
196  enum { SEARCH_ANY, SEARCH_ALL } require;
197 
201  unsigned int searchmask;
202 
204  long desktop;
205 
207  unsigned int limit;
208 } xdo_search_t;
209 
210 #define XDO_ERROR 1
211 #define XDO_SUCCESS 0
212 
221 xdo_t* xdo_new(const char *display);
222 
231 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
232  int close_display_when_freed);
233 
237 const char *xdo_version(void);
238 
244 void xdo_free(xdo_t *xdo);
245 
253 int xdo_move_mouse(const xdo_t *xdo, int x, int y, int screen);
254 
262 int xdo_move_mouse_relative_to_window(const xdo_t *xdo, Window window, int x, int y);
263 
270 int xdo_move_mouse_relative(const xdo_t *xdo, int x, int y);
271 
280 int xdo_mouse_down(const xdo_t *xdo, Window window, int button);
281 
290 int xdo_mouse_up(const xdo_t *xdo, Window window, int button);
291 
299 int xdo_get_mouse_location(const xdo_t *xdo, int *x, int *y, int *screen_num);
300 
306 int xdo_get_window_at_mouse(const xdo_t *xdo, Window *window_ret);
307 
320 int xdo_get_mouse_location2(const xdo_t *xdo, int *x_ret, int *y_ret,
321  int *screen_num_ret, Window *window_ret);
322 
330 int xdo_wait_for_mouse_move_from(const xdo_t *xdo, int origin_x, int origin_y);
331 
339 int xdo_wait_for_mouse_move_to(const xdo_t *xdo, int dest_x, int dest_y);
340 
348 int xdo_click_window(const xdo_t *xdo, Window window, int button);
349 
358 int xdo_click_window_multiple(const xdo_t *xdo, Window window, int button,
359  int repeat, useconds_t delay);
360 
372 int xdo_enter_text_window(const xdo_t *xdo, Window window, const char *string, useconds_t delay);
373 
395 int xdo_send_keysequence_window(const xdo_t *xdo, Window window,
396  const char *keysequence, useconds_t delay);
397 
403 int xdo_send_keysequence_window_up(const xdo_t *xdo, Window window,
404  const char *keysequence, useconds_t delay);
405 
411 int xdo_send_keysequence_window_down(const xdo_t *xdo, Window window,
412  const char *keysequence, useconds_t delay);
413 
425 int xdo_send_keysequence_window_list_do(const xdo_t *xdo, Window window,
426  charcodemap_t *keys, int nkeys,
427  int pressed, int *modifier, useconds_t delay);
428 
437  int *nkeys);
438 
451 int xdo_wait_for_window_map_state(const xdo_t *xdo, Window wid, int map_state);
452 
453 #define SIZE_TO 0
454 #define SIZE_FROM 1
455 int xdo_wait_for_window_size(const xdo_t *xdo, Window window, unsigned int width,
456  unsigned int height, int flags, int to_or_from);
457 
458 
468 int xdo_move_window(const xdo_t *xdo, Window wid, int x, int y);
469 
482 int xdo_translate_window_with_sizehint(const xdo_t *xdo, Window window,
483  unsigned int width, unsigned int height,
484  unsigned int *width_ret, unsigned int *height_ret);
485 
495 int xdo_set_window_size(const xdo_t *xdo, Window wid, int w, int h, int flags);
496 
506 int xdo_set_window_property(const xdo_t *xdo, Window wid, const char *property,
507  const char *value);
508 
515 int xdo_set_window_class(const xdo_t *xdo, Window wid, const char *name,
516  const char *_class);
517 
521 int xdo_set_window_urgency (const xdo_t *xdo, Window wid, int urgency);
522 
532 int xdo_set_window_override_redirect(const xdo_t *xdo, Window wid,
533  int override_redirect);
534 
541 int xdo_focus_window(const xdo_t *xdo, Window wid);
542 
549 int xdo_raise_window(const xdo_t *xdo, Window wid);
550 
557 int xdo_get_focused_window(const xdo_t *xdo, Window *window_ret);
558 
565 int xdo_wait_for_window_focus(const xdo_t *xdo, Window window, int want_focus);
566 
574 int xdo_get_pid_window(const xdo_t *xdo, Window window);
575 
585 int xdo_get_focused_window_sane(const xdo_t *xdo, Window *window_ret);
586 
598 int xdo_activate_window(const xdo_t *xdo, Window wid);
599 
609 int xdo_wait_for_window_active(const xdo_t *xdo, Window window, int active);
610 
617 int xdo_map_window(const xdo_t *xdo, Window wid);
618 
624 int xdo_unmap_window(const xdo_t *xdo, Window wid);
625 
629 int xdo_minimize_window(const xdo_t *xdo, Window wid);
630 
637 int xdo_reparent_window(const xdo_t *xdo, Window wid_source, Window wid_target);
638 
650 int xdo_get_window_location(const xdo_t *xdo, Window wid,
651  int *x_ret, int *y_ret, Screen **screen_ret);
652 
660 int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret,
661  unsigned int *height_ret);
662 
663 /* pager-like behaviors */
664 
672 int xdo_get_active_window(const xdo_t *xdo, Window *window_ret);
673 
680 int xdo_select_window_with_click(const xdo_t *xdo, Window *window_ret);
681 
688 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops);
689 
697 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops);
698 
705 int xdo_set_current_desktop(const xdo_t *xdo, long desktop);
706 
713 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop);
714 
722 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop);
723 
734 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop);
735 
744 int xdo_search_windows(const xdo_t *xdo, const xdo_search_t *search,
745  Window **windowlist_ret, unsigned int *nwindows_ret);
746 
758 unsigned char *xdo_get_window_property_by_atom(const xdo_t *xdo, Window window, Atom atom,
759  long *nitems, Atom *type, int *size);
760 
772 int xdo_get_window_property(const xdo_t *xdo, Window window, const char *property,
773  unsigned char **value, 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_get_keysym_charmap(void);
789 
798 const char **xdo_get_symbol_map(void);
799 
800 /* active modifiers stuff */
801 
809 int xdo_get_active_modifiers(const xdo_t *xdo, charcodemap_t **keys,
810  int *nkeys);
811 
817 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window,
818  charcodemap_t *active_mods,
819  int active_mods_n);
820 
826 int xdo_set_active_modifiers(const xdo_t *xdo, Window window,
827  charcodemap_t *active_mods,
828  int active_mods_n);
829 
836 int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret);
837 
844 int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y);
845 
850 int xdo_kill_window(const xdo_t *xdo, Window window);
851 
855 #define XDO_FIND_PARENTS (0)
856 
860 #define XDO_FIND_CHILDREN (1)
861 
866 int xdo_find_window_client(const xdo_t *xdo, Window window, Window *window_ret,
867  int direction);
868 
874 int xdo_get_window_name(const xdo_t *xdo, Window window,
875  unsigned char **name_ret, int *name_len_ret,
876  int *name_type);
877 
886 void xdo_disable_feature(xdo_t *xdo, int feature);
887 
896 void xdo_enable_feature(xdo_t *xdo, int feature);
897 
906 int xdo_has_feature(xdo_t *xdo, int feature);
907 
915 int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width,
916  unsigned int *height, int screen);
917 #endif /* ifndef _XDO_H_ */