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 
33 #define SIZE_USEHINTS (1L << 0)
34 
43 #define CURRENTWINDOW (0)
44 
49 typedef struct keysym_charmap {
50  const char *keysym;
51  char key;
53 
59 typedef struct charcodemap {
60  char key;
61  KeyCode code;
62  KeySym symbol;
63  int index;
64  int modmask;
69 
73 typedef struct xdo {
74 
76  Display *xdpy;
77 
79  char *display_name;
80 
82  charcodemap_t *charcodes;
83 
85  int charcodes_len;
86 
88  XModifierKeymap *modmap;
89 
91  KeySym *keymap;
92 
94  int keycode_high; /* highest and lowest keycodes */
95 
97  int keycode_low; /* used by this X server */
98 
100  int keysyms_per_keycode;
101 
104 } xdo_t;
105 
106 
114 typedef struct xdo_active_mods {
115  charcodemap_t *keymods;
116  int nkeymods;
117  unsigned int input_state;
119 
120 
125 #define SEARCH_TITLE (1UL << 0)
126 
131 #define SEARCH_CLASS (1UL << 1)
132 
137 #define SEARCH_NAME (1UL << 2)
138 
143 #define SEARCH_PID (1UL << 3)
144 
149 #define SEARCH_ONLYVISIBLE (1UL << 4)
150 
156 #define SEARCH_SCREEN (1UL << 5)
157 
162 #define SEARCH_CLASSNAME (1UL << 6)
163 
164 
170 typedef struct xdo_search {
171  char *title;
172  char *winclass;
173  char *winclassname;
174  char *winname;
175  int pid;
176  long max_depth;
178  int screen;
183  enum { SEARCH_ANY, SEARCH_ALL } require;
184 
188  unsigned int searchmask;
189 } xdo_search_t;
190 
191 #define XDO_ERROR 1
192 #define XDO_SUCCESS 0
193 
202 xdo_t* xdo_new(char *display);
203 
212 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
213  int close_display_when_freed);
214 
218 const char *xdo_version(void);
219 
225 void xdo_free(xdo_t *xdo);
226 
227 
235 int xdo_mousemove(const xdo_t *xdo, int x, int y, int screen);
236 
244 int xdo_mousemove_relative_to_window(const xdo_t *xdo, Window window, int x, int y);
245 
252 int xdo_mousemove_relative(const xdo_t *xdo, int x, int y);
253 
262 int xdo_mousedown(const xdo_t *xdo, Window window, int button);
263 
272 int xdo_mouseup(const xdo_t *xdo, Window window, int button);
273 
281 int xdo_mouselocation(const xdo_t *xdo, int *x, int *y, int *screen_num);
282 
290 int xdo_mouse_wait_for_move_from(const xdo_t *xdo, int origin_x, int origin_y);
291 
299 int xdo_mouse_wait_for_move_to(const xdo_t *xdo, int dest_x, int dest_y);
300 
308 int xdo_click(const xdo_t *xdo, Window window, int button);
309 
321 int xdo_type(const xdo_t *xdo, Window window, char *string, useconds_t delay);
322 
344 int xdo_keysequence(const xdo_t *xdo, Window window,
345  const char *keysequence, useconds_t delay);
346 
352 int xdo_keysequence_up(const xdo_t *xdo, Window window,
353  const char *keysequence, useconds_t delay);
354 
360 int xdo_keysequence_down(const xdo_t *xdo, Window window,
361  const char *keysequence, useconds_t delay);
362 
374 int xdo_keysequence_list_do(const xdo_t *xdo, Window window,
375  charcodemap_t *keys, int nkeys,
376  int pressed, int *modifier, useconds_t delay);
377 
385 int xdo_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys,
386  int *nkeys);
387 
400 int xdo_window_wait_for_map_state(const xdo_t *xdo, Window wid, int map_state);
401 
402 #define SIZE_TO 0
403 #define SIZE_FROM 1
404 int xdo_window_wait_for_size(const xdo_t *xdo, Window window, unsigned int width,
405  unsigned int height, int flags, int to_or_from);
406 
407 
417 int xdo_window_move(const xdo_t *xdo, Window wid, int x, int y);
418 
431 int xdo_window_translate_with_sizehint(const xdo_t *xdo, Window window,
432  int width, int height, int *width_ret,
433  int *height_ret);
434 
444 int xdo_window_setsize(const xdo_t *xdo, Window wid, int w, int h, int flags);
445 
455 int xdo_window_setprop (const xdo_t *xdo, Window wid, const char *property,
456  const char *value);
457 
464 int xdo_window_setclass(const xdo_t *xdo, Window wid, const char *name,
465  const char *class);
466 
473 int xdo_window_focus(const xdo_t *xdo, Window wid);
474 
481 int xdo_window_raise(const xdo_t *xdo, Window wid);
482 
489 int xdo_window_get_focus(const xdo_t *xdo, Window *window_ret);
490 
497 int xdo_window_wait_for_focus(const xdo_t *xdo, Window window, int want_focus);
498 
506 int xdo_window_get_pid(const xdo_t *xdo, Window window);
507 
517 int xdo_window_sane_get_focus(const xdo_t *xdo, Window *window_ret);
518 
530 int xdo_window_activate(const xdo_t *xdo, Window wid);
531 
541 int xdo_window_wait_for_active(const xdo_t *xdo, Window window, int active);
542 
549 int xdo_window_map(const xdo_t *xdo, Window wid);
550 
556 int xdo_window_unmap(const xdo_t *xdo, Window wid);
557 
569 int xdo_get_window_location(const xdo_t *xdo, Window wid,
570  int *x_ret, int *y_ret, Screen **screen_ret);
571 
579 int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret,
580  unsigned int *height_ret);
581 
582 /* pager-like behaviors */
583 
591 int xdo_window_get_active(const xdo_t *xdo, Window *window_ret);
592 
599 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops);
600 
608 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops);
609 
616 int xdo_set_current_desktop(const xdo_t *xdo, long desktop);
617 
624 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop);
625 
633 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop);
634 
642 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop);
643 
652 int xdo_window_search(const xdo_t *xdo, const xdo_search_t *search,
653  Window **windowlist_ret, int *nwindows_ret);
654 
666 unsigned char *xdo_getwinprop(const xdo_t *xdo, Window window, Atom atom,
667  long *nitems, Atom *type, int *size);
668 
676 unsigned int xdo_get_input_state(const xdo_t *xdo);
677 
682 const keysym_charmap_t *xdo_keysym_charmap(void);
683 
692 const char **xdo_symbol_map(void);
693 
694 /* active modifiers stuff */
695 
699 xdo_active_mods_t *xdo_get_active_modifiers(const xdo_t *xdo);
700 
706 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window,
707  xdo_active_mods_t *active_mods);
708 
714 int xdo_set_active_modifiers(const xdo_t *xdo, Window window,
715  const xdo_active_mods_t *active_mods);
716 
720 void xdo_free_active_modifiers(xdo_active_mods_t *active_mods);
721 
722 #endif /* ifndef _XDO_H_ */