Loading...
Searching...
No Matches
xdo.h
Go to the documentation of this file.
#ifndef _XDO_H_
#define _XDO_H_
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif /* __USE_XOPEN */
#include <sys/types.h>
#include <X11/Xlib.h>
#include <X11/X.h>
#include <unistd.h>
#include <wchar.h>
#define SIZE_USEHINTS (1L << 0)
#define SIZE_USEHINTS_X (1L << 1)
#define SIZE_USEHINTS_Y (1L << 2)
#define CURRENTWINDOW (0)
typedef struct charcodemap {
wchar_t key;
KeyCode code;
KeySym symbol;
int group;
int modmask;
int needs_binding;
} charcodemap_t;
typedef enum {
XDO_FEATURE_XTEST,
} XDO_FEATURES;
typedef struct xdo {
Display *xdpy;
char *display_name;
charcodemap_t *charcodes;
int charcodes_len;
XModifierKeymap *modmap;
KeySym *keymap;
int keycode_high; /* highest and lowest keycodes */
int keycode_low; /* used by this X server */
int keysyms_per_keycode;
int close_display_when_freed;
int quiet;
int debug;
int features_mask;
} xdo_t;
#define SEARCH_TITLE (1UL << 0)
#define SEARCH_CLASS (1UL << 1)
#define SEARCH_NAME (1UL << 2)
#define SEARCH_PID (1UL << 3)
#define SEARCH_ONLYVISIBLE (1UL << 4)
#define SEARCH_SCREEN (1UL << 5)
#define SEARCH_CLASSNAME (1UL << 6)
#define SEARCH_DESKTOP (1UL << 7)
typedef struct xdo_search {
const char *title;
const char *winclass;
const char *winclassname;
const char *winname;
int pid;
long max_depth;
int only_visible;
int screen;
enum { SEARCH_ANY, SEARCH_ALL } require;
unsigned int searchmask;
long desktop;
unsigned int limit;
} xdo_search_t;
#define XDO_ERROR 1
#define XDO_SUCCESS 0
xdo_t* xdo_new(const char *display);
xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display,
int close_display_when_freed);
const char *xdo_version(void);
void xdo_free(xdo_t *xdo);
int xdo_move_mouse(const xdo_t *xdo, int x, int y, int screen);
int xdo_move_mouse_relative_to_window(const xdo_t *xdo, Window window, int x, int y);
int xdo_move_mouse_relative(const xdo_t *xdo, int x, int y);
int xdo_mouse_down(const xdo_t *xdo, Window window, int button);
int xdo_mouse_up(const xdo_t *xdo, Window window, int button);
int xdo_get_mouse_location(const xdo_t *xdo, int *x, int *y, int *screen_num);
int xdo_get_window_at_mouse(const xdo_t *xdo, Window *window_ret);
int xdo_get_mouse_location2(const xdo_t *xdo, int *x_ret, int *y_ret,
int *screen_num_ret, Window *window_ret);
int xdo_wait_for_mouse_move_from(const xdo_t *xdo, int origin_x, int origin_y);
int xdo_wait_for_mouse_move_to(const xdo_t *xdo, int dest_x, int dest_y);
int xdo_click_window(const xdo_t *xdo, Window window, int button);
int xdo_click_window_multiple(const xdo_t *xdo, Window window, int button,
int repeat, useconds_t delay);
int xdo_enter_text_window(const xdo_t *xdo, Window window, const char *string, useconds_t delay);
int xdo_send_keysequence_window(const xdo_t *xdo, Window window,
const char *keysequence, useconds_t delay);
int xdo_send_keysequence_window_up(const xdo_t *xdo, Window window,
const char *keysequence, useconds_t delay);
int xdo_send_keysequence_window_down(const xdo_t *xdo, Window window,
const char *keysequence, useconds_t delay);
int xdo_send_keysequence_window_list_do(const xdo_t *xdo, Window window,
charcodemap_t *keys, int nkeys,
int pressed, int *modifier, useconds_t delay);
int xdo_get_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys,
int *nkeys);
int xdo_wait_for_window_map_state(const xdo_t *xdo, Window wid, int map_state);
#define SIZE_TO 0
#define SIZE_FROM 1
int xdo_wait_for_window_size(const xdo_t *xdo, Window window, unsigned int width,
unsigned int height, int flags, int to_or_from);
int xdo_move_window(const xdo_t *xdo, Window wid, int x, int y);
int xdo_translate_window_with_sizehint(const xdo_t *xdo, Window window,
unsigned int width, unsigned int height,
unsigned int *width_ret, unsigned int *height_ret);
int xdo_set_window_size(const xdo_t *xdo, Window wid, int w, int h, int flags);
int xdo_set_window_property(const xdo_t *xdo, Window wid, const char *property,
const char *value);
int xdo_set_window_class(const xdo_t *xdo, Window wid, const char *name,
const char *_class);
int xdo_set_window_urgency (const xdo_t *xdo, Window wid, int urgency);
int xdo_set_window_override_redirect(const xdo_t *xdo, Window wid,
int override_redirect);
int xdo_focus_window(const xdo_t *xdo, Window wid);
int xdo_raise_window(const xdo_t *xdo, Window wid);
int xdo_get_focused_window(const xdo_t *xdo, Window *window_ret);
int xdo_wait_for_window_focus(const xdo_t *xdo, Window window, int want_focus);
int xdo_get_pid_window(const xdo_t *xdo, Window window);
int xdo_get_focused_window_sane(const xdo_t *xdo, Window *window_ret);
int xdo_activate_window(const xdo_t *xdo, Window wid);
int xdo_wait_for_window_active(const xdo_t *xdo, Window window, int active);
int xdo_map_window(const xdo_t *xdo, Window wid);
int xdo_unmap_window(const xdo_t *xdo, Window wid);
int xdo_minimize_window(const xdo_t *xdo, Window wid);
int xdo_reparent_window(const xdo_t *xdo, Window wid_source, Window wid_target);
int xdo_get_window_location(const xdo_t *xdo, Window wid,
int *x_ret, int *y_ret, Screen **screen_ret);
int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret,
unsigned int *height_ret);
/* pager-like behaviors */
int xdo_get_active_window(const xdo_t *xdo, Window *window_ret);
int xdo_select_window_with_click(const xdo_t *xdo, Window *window_ret);
int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops);
int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops);
int xdo_set_current_desktop(const xdo_t *xdo, long desktop);
int xdo_get_current_desktop(const xdo_t *xdo, long *desktop);
int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop);
int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop);
int xdo_search_windows(const xdo_t *xdo, const xdo_search_t *search,
Window **windowlist_ret, unsigned int *nwindows_ret);
unsigned char *xdo_get_window_property_by_atom(const xdo_t *xdo, Window window, Atom atom,
long *nitems, Atom *type, int *size);
int xdo_get_window_property(const xdo_t *xdo, Window window, const char *property,
unsigned char **value, long *nitems, Atom *type, int *size);
unsigned int xdo_get_input_state(const xdo_t *xdo);
const char **xdo_get_symbol_map(void);
/* active modifiers stuff */
int xdo_get_active_modifiers(const xdo_t *xdo, charcodemap_t **keys,
int *nkeys);
int xdo_clear_active_modifiers(const xdo_t *xdo, Window window,
charcodemap_t *active_mods,
int active_mods_n);
int xdo_set_active_modifiers(const xdo_t *xdo, Window window,
charcodemap_t *active_mods,
int active_mods_n);
int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret);
int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y);
int xdo_kill_window(const xdo_t *xdo, Window window);
int xdo_close_window(const xdo_t *xdo, Window window);
#define XDO_FIND_PARENTS (0)
#define XDO_FIND_CHILDREN (1)
int xdo_find_window_client(const xdo_t *xdo, Window window, Window *window_ret,
int direction);
int xdo_get_window_name(const xdo_t *xdo, Window window,
unsigned char **name_ret, int *name_len_ret,
int *name_type);
void xdo_disable_feature(xdo_t *xdo, int feature);
void xdo_enable_feature(xdo_t *xdo, int feature);
int xdo_has_feature(xdo_t *xdo, int feature);
int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width,
unsigned int *height, int screen);
#endif /* ifndef _XDO_H_ */
charcodemap
Definition xdo.h:56
charcodemap::modmask
int modmask
the keyboard group that has this key in it
Definition xdo.h:61
charcodemap::group
int group
the symbol representing this key
Definition xdo.h:60
charcodemap::symbol
KeySym symbol
the keycode that this key is on
Definition xdo.h:59
charcodemap::code
KeyCode code
the letter for this key, like 'a'
Definition xdo.h:58
charcodemap::needs_binding
int needs_binding
the modifiers to apply when sending this key
Definition xdo.h:64
xdo_search
The window search query structure.
Definition xdo.h:174
xdo_search::desktop
long desktop
What desktop to search, if any.
Definition xdo.h:195
xdo_search::limit
unsigned int limit
How many results to return? If 0, return all.
Definition xdo.h:198
xdo_search::winclassname
const char * winclassname
pattern to test against a window class
Definition xdo.h:177
xdo_search::screen
int screen
boolean; set true to search only visible windows
Definition xdo.h:182
xdo_search::require
enum xdo_search::@0 require
what screen to search, if any.
xdo_search::searchmask
unsigned int searchmask
bitmask of things you are searching for, such as SEARCH_NAME, etc.
Definition xdo.h:192
xdo_search::only_visible
int only_visible
depth of search.
Definition xdo.h:181
xdo_search::pid
int pid
pattern to test against a window name
Definition xdo.h:179
xdo_search::winclass
const char * winclass
pattern to test against a window title
Definition xdo.h:176
xdo_search::max_depth
long max_depth
window pid (From window atom _NET_WM_PID)
Definition xdo.h:180
xdo_search::winname
const char * winname
pattern to test against a window class
Definition xdo.h:178
xdo
The main context.
Definition xdo.h:74
xdo::debug
int debug
Enable debug output?
Definition xdo.h:110
xdo::features_mask
int features_mask
Feature flags, such as XDO_FEATURE_XTEST, etc...
Definition xdo.h:113
xdo::quiet
int quiet
Be extra quiet? (omits some error/message output)
Definition xdo.h:107
xdo::close_display_when_freed
int close_display_when_freed
Should we close the display when calling xdo_free?
Definition xdo.h:104
xdo::xdpy
Display * xdpy
The Display for Xlib.
Definition xdo.h:77
xdo::display_name
char * display_name
The display name, if any.
Definition xdo.h:80
xdo_set_desktop_for_window
int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop)
Move a window to another desktop Uses _NET_WM_DESKTOP of the EWMH spec.
Definition xdo.c:625
xdo_kill_window
int xdo_kill_window(const xdo_t *xdo, Window window)
Kill a window and the client owning it.
Definition xdo.c:1832
xdo_disable_feature
void xdo_disable_feature(xdo_t *xdo, int feature)
Disable an xdo feature.
Definition xdo.c:1923
xdo_set_window_override_redirect
int xdo_set_window_override_redirect(const xdo_t *xdo, Window wid, int override_redirect)
Set the override_redirect value for a window.
Definition xdo.c:326
xdo_get_desktop_viewport
int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret)
Get the position of the current viewport.
Definition xdo.c:1772
xdo_t
struct xdo xdo_t
The main context.
xdo_get_window_size
int xdo_get_window_size(const xdo_t *xdo, Window wid, unsigned int *width_ret, unsigned int *height_ret)
Get a window's size.
Definition xdo.c:233
xdo_click_window
int xdo_click_window(const xdo_t *xdo, Window window, int button)
Send a click for a specific mouse button at the current mouse location.
Definition xdo.c:927
xdo_clear_active_modifiers
int xdo_clear_active_modifiers(const xdo_t *xdo, Window window, charcodemap_t *active_mods, int active_mods_n)
Send any events necessary to clear the active modifiers.
Definition xdo.c:1664
xdo_get_mouse_location
int xdo_get_mouse_location(const xdo_t *xdo, int *x, int *y, int *screen_num)
Get the current mouse location (coordinates and screen number).
Definition xdo.c:863
xdo_set_window_size
int xdo_set_window_size(const xdo_t *xdo, Window wid, int w, int h, int flags)
Change the window size.
Definition xdo.c:291
xdo_get_symbol_map
const char ** xdo_get_symbol_map(void)
If you need the symbol map, use this method.
Definition xdo.c:1660
xdo_get_focused_window_sane
int xdo_get_focused_window_sane(const xdo_t *xdo, Window *window_ret)
Like xdo_get_focused_window, but return the first ancestor-or-self window * having a property of WM_C...
Definition xdo.c:1173
xdo_get_number_of_desktops
int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops)
Get the current number of desktops.
Definition xdo.c:530
xdo_map_window
int xdo_map_window(const xdo_t *xdo, Window wid)
Map a window.
Definition xdo.c:168
xdo_get_input_state
unsigned int xdo_get_input_state(const xdo_t *xdo)
Get the current input state.
Definition xdo.c:1648
xdo_move_mouse_relative
int xdo_move_mouse_relative(const xdo_t *xdo, int x, int y)
Move the mouse relative to it's current position.
Definition xdo.c:795
xdo_new_with_opened_display
xdo_t * xdo_new_with_opened_display(Display *xdpy, const char *display, int close_display_when_freed)
Create a new xdo_t instance with an existing X11 Display instance.
Definition xdo.c:99
xdo_click_window_multiple
int xdo_click_window_multiple(const xdo_t *xdo, Window window, int button, int repeat, useconds_t delay)
Send a one or more clicks for a specific mouse button at the current mouse location.
Definition xdo.c:939
xdo_get_current_desktop
int xdo_get_current_desktop(const xdo_t *xdo, long *desktop)
Get the current desktop.
Definition xdo.c:593
xdo_reparent_window
int xdo_reparent_window(const xdo_t *xdo, Window wid_source, Window wid_target)
Reparents a window.
Definition xdo.c:182
xdo_set_active_modifiers
int xdo_set_active_modifiers(const xdo_t *xdo, Window window, charcodemap_t *active_mods, int active_mods_n)
Send any events necessary to make these modifiers active.
Definition xdo.c:1692
xdo_unmap_window
int xdo_unmap_window(const xdo_t *xdo, Window wid)
Unmap a window.
Definition xdo.c:175
xdo_free
void xdo_free(xdo_t *xdo)
Free and destroy an xdo_t instance.
Definition xdo.c:138
xdo_get_active_window
int xdo_get_active_window(const xdo_t *xdo, Window *window_ret)
Get the currently-active window.
Definition xdo.c:686
xdo_send_keysequence_window_up
int xdo_send_keysequence_window_up(const xdo_t *xdo, Window window, const char *keysequence, useconds_t delay)
Send key release (up) events for the given key sequence.
Definition xdo.c:1115
xdo_get_window_name
int xdo_get_window_name(const xdo_t *xdo, Window window, unsigned char **name_ret, int *name_len_ret, int *name_type)
Get a window's name, if any.
Definition xdo.c:1844
xdo_has_feature
int xdo_has_feature(xdo_t *xdo, int feature)
Check if a feature is enabled.
Definition xdo.c:1927
xdo_activate_window
int xdo_activate_window(const xdo_t *xdo, Window wid)
Activate a window.
Definition xdo.c:459
xdo_mouse_down
int xdo_mouse_down(const xdo_t *xdo, Window window, int button)
Send a mouse press (aka mouse down) for a given button at the current mouse location.
Definition xdo.c:859
xdo_new
xdo_t * xdo_new(const char *display)
Create a new xdo_t instance.
Definition xdo.c:83
xdo_send_keysequence_window_down
int xdo_send_keysequence_window_down(const xdo_t *xdo, Window window, const char *keysequence, useconds_t delay)
Send key press (down) events for the given key sequence.
Definition xdo.c:1110
xdo_get_desktop_for_window
int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop)
Get the desktop a window is on.
Definition xdo.c:656
xdo_wait_for_window_active
int xdo_wait_for_window_active(const xdo_t *xdo, Window window, int active)
Wait for a window to be active or not active.
Definition xdo.c:439
xdo_send_keysequence_window
int xdo_send_keysequence_window(const xdo_t *xdo, Window window, const char *keysequence, useconds_t delay)
Send a keysequence to the specified window.
Definition xdo.c:1120
xdo_translate_window_with_sizehint
int xdo_translate_window_with_sizehint(const xdo_t *xdo, Window window, unsigned int width, unsigned int height, unsigned int *width_ret, unsigned int *height_ret)
Apply a window's sizing hints (if any) to a given width and height.
Definition xdo.c:260
xdo_wait_for_mouse_move_from
int xdo_wait_for_mouse_move_from(const xdo_t *xdo, int origin_x, int origin_y)
Wait for the mouse to move from a location.
Definition xdo.c:1741
xdo_set_current_desktop
int xdo_set_current_desktop(const xdo_t *xdo, long desktop)
Switch to another desktop.
Definition xdo.c:561
xdo_search_t
struct xdo_search xdo_search_t
The window search query structure.
xdo_get_pid_window
int xdo_get_pid_window(const xdo_t *xdo, Window window)
Get the PID owning a window.
Definition xdo.c:1719
xdo_select_window_with_click
int xdo_select_window_with_click(const xdo_t *xdo, Window *window_ret)
Get a window ID by clicking on it.
Definition xdo.c:716
xdo_get_focused_window
int xdo_get_focused_window(const xdo_t *xdo, Window *window_ret)
Get the window currently having focus.
Definition xdo.c:1131
xdo_focus_window
int xdo_focus_window(const xdo_t *xdo, Window wid)
Focus a window.
Definition xdo.c:392
xdo_send_keysequence_window_list_do
int xdo_send_keysequence_window_list_do(const xdo_t *xdo, Window window, charcodemap_t *keys, int nkeys, int pressed, int *modifier, useconds_t delay)
Send a series of keystrokes.
Definition xdo.c:1027
xdo_move_window
int xdo_move_window(const xdo_t *xdo, Window wid, int x, int y)
Move a window to a specific location.
Definition xdo.c:250
xdo_close_window
int xdo_close_window(const xdo_t *xdo, Window window)
Close a window without trying to kill the client.
Definition xdo.c:1838
xdo_set_window_class
int xdo_set_window_class(const xdo_t *xdo, Window wid, const char *name, const char *_class)
Change the window's classname and or class.
Definition xdo.c:337
xdo_enable_feature
void xdo_enable_feature(xdo_t *xdo, int feature)
Enable an xdo feature.
Definition xdo.c:1919
xdo_get_mouse_location2
int xdo_get_mouse_location2(const xdo_t *xdo, int *x_ret, int *y_ret, int *screen_num_ret, Window *window_ret)
Get all mouse location-related data.
Definition xdo.c:872
xdo_minimize_window
int xdo_minimize_window(const xdo_t *xdo, Window wid)
Minimize a window.
Definition xdo.c:1882
xdo_get_window_at_mouse
int xdo_get_window_at_mouse(const xdo_t *xdo, Window *window_ret)
Get the window the mouse is currently over.
Definition xdo.c:868
xdo_search_windows
int xdo_search_windows(const xdo_t *xdo, const xdo_search_t *search, Window **windowlist_ret, unsigned int *nwindows_ret)
Search for windows.
Definition xdo_search.c:31
xdo_get_viewport_dimensions
int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width, unsigned int *height, int screen)
Query the viewport (your display) dimensions.
Definition xdo.c:1931
xdo_move_mouse_relative_to_window
int xdo_move_mouse_relative_to_window(const xdo_t *xdo, Window window, int x, int y)
Move the mouse to a specific location relative to the top-left corner of a window.
Definition xdo.c:784
xdo_enter_text_window
int xdo_enter_text_window(const xdo_t *xdo, Window window, const char *string, useconds_t delay)
Type a string to the specified window.
Definition xdo.c:958
xdo_wait_for_window_map_state
int xdo_wait_for_window_map_state(const xdo_t *xdo, Window wid, int map_state)
Wait for a window to have a specific map state.
Definition xdo.c:156
xdo_move_mouse
int xdo_move_mouse(const xdo_t *xdo, int x, int y, int screen)
Move the mouse to a specific location.
Definition xdo.c:770
xdo_set_number_of_desktops
int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops)
Set the number of desktops.
Definition xdo.c:499
xdo_get_window_property_by_atom
unsigned char * xdo_get_window_property_by_atom(const xdo_t *xdo, Window window, Atom atom, long *nitems, Atom *type, int *size)
Generic property fetch.
Definition xdo.c:1430
xdo_set_window_property
int xdo_set_window_property(const xdo_t *xdo, Window wid, const char *property, const char *value)
Change a window property.
Definition xdo.c:369
xdo_raise_window
int xdo_raise_window(const xdo_t *xdo, Window wid)
Raise a window to the top of the window stack.
Definition xdo.c:763
xdo_wait_for_mouse_move_to
int xdo_wait_for_mouse_move_to(const xdo_t *xdo, int dest_x, int dest_y)
Wait for the mouse to move to a location.
Definition xdo.c:1757
xdo_mouse_up
int xdo_mouse_up(const xdo_t *xdo, Window window, int button)
Send a mouse release (aka mouse up) for a given button at the current mouse location.
Definition xdo.c:855
xdo_get_window_location
int xdo_get_window_location(const xdo_t *xdo, Window wid, int *x_ret, int *y_ret, Screen **screen_ret)
Get a window's location.
Definition xdo.c:189
xdo_get_active_modifiers
int xdo_get_active_modifiers(const xdo_t *xdo, charcodemap_t **keys, int *nkeys)
Get a list of active keys.
Definition xdo.c:1604
xdo_version
const char * xdo_version(void)
Return a string representing the version of this library.
Definition xdo.c:152
xdo_get_window_property
int xdo_get_window_property(const xdo_t *xdo, Window window, const char *property, unsigned char **value, long *nitems, Atom *type, int *size)
Get property of window by name of atom.
Definition xdo.c:1419
xdo_set_window_urgency
int xdo_set_window_urgency(const xdo_t *xdo, Window wid, int urgency)
Sets the urgency hint for a window.
Definition xdo.c:353
xdo_wait_for_window_focus
int xdo_wait_for_window_focus(const xdo_t *xdo, Window window, int want_focus)
Wait for a window to have or lose focus.
Definition xdo.c:1148
xdo_get_active_keys_to_keycode_list
int xdo_get_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys, int *nkeys)
Get a list of active keys.
xdo_find_window_client
int xdo_find_window_client(const xdo_t *xdo, Window window, Window *window_ret, int direction)
Find a client window (child) in a given window.
Definition xdo.c:1179
xdo_set_desktop_viewport
int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y)
Set the position of the current viewport.
Definition xdo.c:1809