1 module xdo; 2 3 import core.sys.posix.unistd : useconds_t; 4 import x11.X; 5 import x11.Xlib; 6 7 /** 8 * @mainpage 9 * 10 * libxdo helps you send fake mouse and keyboard input, search for windows, 11 * perform various window management tasks such as desktop changes, window 12 * movement, etc. 13 * 14 * For examples on libxdo usage, the xdotool source code is a good reference. 15 * 16 * @see xdo.h 17 * @see xdo_new 18 */ 19 20 /** 21 * When issuing a window size change, giving this flag will make the size 22 * change be relative to the size hints of the window. For terminals, this 23 * generally means that the window size will be relative to the font size, 24 * allowing you to change window sizes based on character rows and columns 25 * instead of pixels. 26 */ 27 enum SIZE_USEHINTS = (1L << 0); 28 /// ditto 29 enum SIZE_USEHINTS_X = (1L << 1); 30 /// ditto 31 enum SIZE_USEHINTS_Y = (1L << 2); 32 33 /** 34 * CURRENTWINDOW is a special identify for xdo input faking (mouse and 35 * keyboard) functions like xdo_send_keysequence_window that indicate we should target the 36 * current window, not a specific window. 37 * 38 * Generally, this means we will use XTEST instead of XSendEvent when sending 39 * events. 40 */ 41 enum CURRENTWINDOW = 0; 42 43 /** 44 * @internal 45 * Map character to whatever information we need to be able to send 46 * this key (keycode, modifiers, group, etc) 47 */ 48 struct charcodemap { 49 wchar key; /** the letter for this key, like 'a' */ 50 KeyCode code; /** the keycode that this key is on */ 51 KeySym symbol; /** the symbol representing this key */ 52 int group; /** the keyboard group that has this key in it */ 53 int modmask; /** the modifiers to apply when sending this key */ 54 /** if this key need to be bound at runtime because it does not 55 * exist in the current keymap, this will be set to 1. */ 56 int needs_binding; 57 } 58 59 alias charcodemap_t = charcodemap; 60 61 enum XDO_FEATURES { 62 XDO_FEATURE_XTEST, /** Is XTest available? */ 63 } 64 65 /** 66 * The main context. 67 */ 68 struct xdo { 69 70 /** The Display for Xlib */ 71 Display *xdpy; 72 73 /** The display name, if any. NULL if not specified. */ 74 char *display_name; 75 76 /** @internal Array of known keys/characters */ 77 charcodemap_t *charcodes; 78 79 /** @internal Length of charcodes array */ 80 int charcodes_len; 81 82 /** @internal UNUSED -- result from XGetModifierMapping */ 83 XModifierKeymap *modmap; 84 85 /** @internal UNUSED -- current keyboard mapping (via XGetKeyboardMapping) */ 86 KeySym *keymap; 87 88 /** @internal highest keycode value */ 89 int keycode_high; /* highest and lowest keycodes */ 90 91 /** @internal lowest keycode value */ 92 int keycode_low; /* used by this X server */ 93 94 /** @internal number of keysyms per keycode */ 95 int keysyms_per_keycode; 96 97 /** Should we close the display when calling xdo_free? */ 98 int close_display_when_freed; 99 100 /** Be extra quiet? (omits some error/message output) */ 101 int quiet; 102 103 /** Enable debug output? */ 104 int debug_; 105 106 /** Feature flags, such as XDO_FEATURE_XTEST, etc... */ 107 int features_mask; 108 109 } 110 111 alias xdo_t = xdo; 112 113 114 /** 115 * Search only window title. DEPRECATED - Use SEARCH_NAME 116 * @see xdo_search_windows 117 */ 118 enum SEARCH_TITLE = (1UL << 0); 119 120 /** 121 * Search only window class. 122 * @see xdo_search_windows 123 */ 124 enum SEARCH_CLASS = (1UL << 1); 125 126 /** 127 * Search only window name. 128 * @see xdo_search_windows 129 */ 130 enum SEARCH_NAME = (1UL << 2); 131 132 /** 133 * Search only window pid. 134 * @see xdo_search_windows 135 */ 136 enum SEARCH_PID = (1UL << 3); 137 138 /** 139 * Search only visible windows. 140 * @see xdo_search_windows 141 */ 142 enum SEARCH_ONLYVISIBLE = (1UL << 4); 143 144 /** 145 * Search only a specific screen. 146 * @see xdo_search.screen 147 * @see xdo_search_windows 148 */ 149 enum SEARCH_SCREEN = (1UL << 5); 150 151 /** 152 * Search only window class name. 153 * @see xdo_search 154 */ 155 enum SEARCH_CLASSNAME = (1UL << 6); 156 157 /** 158 * Search a specific desktop 159 * @see xdo_search.screen 160 * @see xdo_search_windows 161 */ 162 enum SEARCH_DESKTOP = (1UL << 7); 163 164 165 /** 166 * The window search query structure. 167 * 168 * @see xdo_search_windows 169 */ 170 struct xdo_search { 171 const char *title; /** pattern to test against a window title */ 172 const char *winclass; /** pattern to test against a window class */ 173 const char *winclassname; /** pattern to test against a window class */ 174 const char *winname; /** pattern to test against a window name */ 175 int pid; /** window pid (From window atom _NET_WM_PID) */ 176 long max_depth; /** depth of search. 1 means only toplevel windows */ 177 int only_visible; /** boolean; set true to search only visible windows */ 178 int screen; /** what screen to search, if any. If none given, search 179 all screens */ 180 181 /** Should the tests be 'and' or 'or' ? If 'and', any failure will skip the 182 * window. If 'or', any success will keep the window in search results. */ 183 enum { SEARCH_ANY, SEARCH_ALL } 184 int require; 185 186 /** bitmask of things you are searching for, such as SEARCH_NAME, etc. 187 * @see SEARCH_NAME, SEARCH_CLASS, SEARCH_PID, SEARCH_CLASSNAME, etc 188 */ 189 uint searchmask; 190 191 /** What desktop to search, if any. If none given, search all screens. */ 192 long desktop; 193 194 /** How many results to return? If 0, return all. */ 195 uint limit; 196 } 197 198 alias xdo_search_t = xdo_search; 199 200 enum XDO_ERROR = 1; 201 enum XDO_SUCCESS = 0; 202 203 extern (C) nothrow @nogc: 204 205 /** 206 * Create a new xdo_t instance. 207 * 208 * @param display the string display name, such as ":0". If null, uses the 209 * environment variable DISPLAY just like XOpenDisplay(NULL). 210 * 211 * @return Pointer to a new xdo_t or NULL on failure 212 */ 213 xdo_t* xdo_new(const char *display); 214 215 /** 216 * Create a new xdo_t instance with an existing X11 Display instance. 217 * 218 * @param xdpy the Display pointer given by a previous XOpenDisplay() 219 * @param display the string display name 220 * @param close_display_when_freed If true, we will close the display when 221 * xdo_free is called. Otherwise, we leave it open. 222 */ 223 xdo_t* xdo_new_with_opened_display(Display *xdpy, const char *display, 224 int close_display_when_freed); 225 226 /** 227 * Return a string representing the version of this library 228 */ 229 /*const*/ char* xdo_version(); 230 231 /** 232 * Free and destroy an xdo_t instance. 233 * 234 * If close_display_when_freed is set, then we will also close the Display. 235 */ 236 void xdo_free(xdo_t *xdo); 237 238 /** 239 * Move the mouse to a specific location. 240 * 241 * @param x the target X coordinate on the screen in pixels. 242 * @param y the target Y coordinate on the screen in pixels. 243 * @param screen the screen (number) you want to move on. 244 */ 245 int xdo_move_mouse(const xdo_t *xdo, int x, int y, int screen); 246 247 /** 248 * Move the mouse to a specific location relative to the top-left corner 249 * of a window. 250 * 251 * @param x the target X coordinate on the screen in pixels. 252 * @param y the target Y coordinate on the screen in pixels. 253 */ 254 int xdo_move_mouse_relative_to_window(const xdo_t *xdo, Window window, int x, int y); 255 256 /** 257 * Move the mouse relative to it's current position. 258 * 259 * @param x the distance in pixels to move on the X axis. 260 * @param y the distance in pixels to move on the Y axis. 261 */ 262 int xdo_move_mouse_relative(const xdo_t *xdo, int x, int y); 263 264 /** 265 * Send a mouse press (aka mouse down) for a given button at the current mouse 266 * location. 267 * 268 * @param window The window you want to send the event to or CURRENTWINDOW 269 * @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is 270 * right, 4 is wheel up, 5 is wheel down. 271 */ 272 int xdo_mouse_down(const xdo_t *xdo, Window window, int button); 273 274 /** 275 * Send a mouse release (aka mouse up) for a given button at the current mouse 276 * location. 277 * 278 * @param window The window you want to send the event to or CURRENTWINDOW 279 * @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is 280 * right, 4 is wheel up, 5 is wheel down. 281 */ 282 int xdo_mouse_up(const xdo_t *xdo, Window window, int button); 283 284 /** 285 * Get the current mouse location (coordinates and screen number). 286 * 287 * @param x integer pointer where the X coordinate will be stored 288 * @param y integer pointer where the Y coordinate will be stored 289 * @param screen_num integer pointer where the screen number will be stored 290 */ 291 int xdo_get_mouse_location(const xdo_t *xdo, int *x, int *y, int *screen_num); 292 293 /** 294 * Get the window the mouse is currently over 295 * 296 * @param window_ret Winter pointer where the window will be stored. 297 */ 298 int xdo_get_window_at_mouse(const xdo_t *xdo, Window *window_ret); 299 300 /** 301 * Get all mouse location-related data. 302 * 303 * If null is passed for any parameter, we simply do not store it. 304 * Useful if you only want the 'y' coordinate, for example. 305 * 306 * @param x integer pointer where the X coordinate will be stored 307 * @param y integer pointer where the Y coordinate will be stored 308 * @param screen_num integer pointer where the screen number will be stored 309 * @param window Window pointer where the window/client the mouse is over 310 * will be stored. 311 */ 312 int xdo_get_mouse_location2(const xdo_t *xdo, int *x_ret, int *y_ret, 313 int *screen_num_ret, Window *window_ret); 314 315 /** 316 * Wait for the mouse to move from a location. This function will block 317 * until the condition has been satisfied. 318 * 319 * @param origin_x the X position you expect the mouse to move from 320 * @param origin_y the Y position you expect the mouse to move from 321 */ 322 int xdo_wait_for_mouse_move_from(const xdo_t *xdo, int origin_x, int origin_y); 323 324 /** 325 * Wait for the mouse to move to a location. This function will block 326 * until the condition has been satisfied. 327 * 328 * @param dest_x the X position you expect the mouse to move to 329 * @param dest_y the Y position you expect the mouse to move to 330 */ 331 int xdo_wait_for_mouse_move_to(const xdo_t *xdo, int dest_x, int dest_y); 332 333 /** 334 * Send a click for a specific mouse button at the current mouse location. 335 * 336 * @param window The window you want to send the event to or CURRENTWINDOW 337 * @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is 338 * right, 4 is wheel up, 5 is wheel down. 339 */ 340 int xdo_click_window(const xdo_t *xdo, Window window, int button); 341 342 /** 343 * Send a one or more clicks for a specific mouse button at the current mouse 344 * location. 345 * 346 * @param window The window you want to send the event to or CURRENTWINDOW 347 * @param button The mouse button. Generally, 1 is left, 2 is middle, 3 is 348 * right, 4 is wheel up, 5 is wheel down. 349 */ 350 int xdo_click_window_multiple(const xdo_t *xdo, Window window, int button, 351 int repeat, useconds_t delay); 352 353 /** 354 * Type a string to the specified window. 355 * 356 * If you want to send a specific key or key sequence, such as "alt+l", you 357 * want instead xdo_send_keysequence_window(...). 358 * 359 * @param window The window you want to send keystrokes to or CURRENTWINDOW 360 * @param string The string to type, like "Hello world!" 361 * @param delay The delay between keystrokes in microseconds. 12000 is a decent 362 * choice if you don't have other plans. 363 */ 364 int xdo_enter_text_window(const xdo_t *xdo, Window window, const char *string, useconds_t delay); 365 366 /** 367 * Send a keysequence to the specified window. 368 * 369 * This allows you to send keysequences by symbol name. Any combination 370 * of X11 KeySym names separated by '+' are valid. Single KeySym names 371 * are valid, too. 372 * 373 * Examples: 374 * "l" 375 * "semicolon" 376 * "alt+Return" 377 * "Alt_L+Tab" 378 * 379 * If you want to type a string, such as "Hello world." you want to instead 380 * use xdo_enter_text_window. 381 * 382 * @param window The window you want to send the keysequence to or 383 * CURRENTWINDOW 384 * @param keysequence The string keysequence to send. 385 * @param delay The delay between keystrokes in microseconds. 386 */ 387 int xdo_send_keysequence_window(const xdo_t *xdo, Window window, 388 const char *keysequence, useconds_t delay); 389 390 /** 391 * Send key release (up) events for the given key sequence. 392 * 393 * @see xdo_send_keysequence_window 394 */ 395 int xdo_send_keysequence_window_up(const xdo_t *xdo, Window window, 396 const char *keysequence, useconds_t delay); 397 398 /** 399 * Send key press (down) events for the given key sequence. 400 * 401 * @see xdo_send_keysequence_window 402 */ 403 int xdo_send_keysequence_window_down(const xdo_t *xdo, Window window, 404 const char *keysequence, useconds_t delay); 405 406 /** 407 * Send a series of keystrokes. 408 * 409 * @param window The window to send events to or CURRENTWINDOW 410 * @param keys The array of charcodemap_t entities to send. 411 * @param nkeys The length of the keys parameter 412 * @param pressed 1 for key press, 0 for key release. 413 * @param modifier Pointer to integer to record the modifiers activated by 414 * the keys being pressed. If NULL, we don't save the modifiers. 415 * @param delay The delay between keystrokes in microseconds. 416 */ 417 int xdo_send_keysequence_window_list_do(const xdo_t *xdo, Window window, 418 charcodemap_t *keys, int nkeys, 419 int pressed, int *modifier, useconds_t delay); 420 421 /** 422 * Get a list of active keys. Uses XQueryKeymap. 423 * 424 * @param keys Pointer to the array of charcodemap_t that will be allocated 425 * by this function. 426 * @param nkeys Pointer to integer where the number of keys will be stored. 427 */ 428 int xdo_get_active_keys_to_keycode_list(const xdo_t *xdo, charcodemap_t **keys, 429 int *nkeys); 430 431 /** 432 * Wait for a window to have a specific map state. 433 * 434 * State possibilities: 435 * IsUnmapped - window is not displayed. 436 * IsViewable - window is mapped and shown (though may be clipped by windows 437 * on top of it) 438 * IsUnviewable - window is mapped but a parent window is unmapped. 439 * 440 * @param wid the window you want to wait for. 441 * @param map_state the state to wait for. 442 */ 443 int xdo_wait_for_window_map_state(const xdo_t *xdo, Window wid, int map_state); 444 445 enum SIZE_TO = 0; 446 enum SIZE_FROM = 1; 447 int xdo_wait_for_window_size(const xdo_t *xdo, Window window, uint width, 448 uint height, int flags, int to_or_from); 449 450 451 /** 452 * Move a window to a specific location. 453 * 454 * The top left corner of the window will be moved to the x,y coordinate. 455 * 456 * @param wid the window to move 457 * @param x the X coordinate to move to. 458 * @param y the Y coordinate to move to. 459 */ 460 int xdo_move_window(const xdo_t *xdo, Window wid, int x, int y); 461 462 /** 463 * Apply a window's sizing hints (if any) to a given width and height. 464 * 465 * This function wraps XGetWMNormalHints() and applies any 466 * resize increment and base size to your given width and height values. 467 * 468 * @param window the window to use 469 * @param width the unit width you want to translate 470 * @param height the unit height you want to translate 471 * @param width_ret the return location of the translated width 472 * @param height_ret the return location of the translated height 473 */ 474 int xdo_translate_window_with_sizehint(const xdo_t *xdo, Window window, 475 uint width, uint height, 476 uint *width_ret, uint *height_ret); 477 478 /** 479 * Change the window size. 480 * 481 * @param wid the window to resize 482 * @param w the new desired width 483 * @param h the new desired height 484 * @param flags if 0, use pixels for units. If SIZE_USEHINTS, then 485 * the units will be relative to the window size hints. 486 */ 487 int xdo_set_window_size(const xdo_t *xdo, Window wid, int w, int h, int flags); 488 489 /** 490 * Change a window property. 491 * 492 * Example properties you can change are WM_NAME, WM_ICON_NAME, etc. 493 * 494 * @param wid The window to change a property of. 495 * @param property the string name of the property. 496 * @param value the string value of the property. 497 */ 498 int xdo_set_window_property(const xdo_t *xdo, Window wid, const char *property, 499 const char *value); 500 501 /** 502 * Change the window's classname and or class. 503 * 504 * @param name The new class name. If NULL, no change. 505 * @param _class The new class. If NULL, no change. 506 */ 507 int xdo_set_window_class(const xdo_t *xdo, Window wid, const char *name, 508 const char *_class); 509 510 /** 511 * Sets the urgency hint for a window. 512 */ 513 int xdo_set_window_urgency (const xdo_t *xdo, Window wid, int urgency); 514 515 /** 516 * Set the override_redirect value for a window. This generally means 517 * whether or not a window manager will manage this window. 518 * 519 * If you set it to 1, the window manager will usually not draw borders on the 520 * window, etc. If you set it to 0, the window manager will see it like a 521 * normal application window. 522 * 523 */ 524 int xdo_set_window_override_redirect(const xdo_t *xdo, Window wid, 525 int override_redirect); 526 527 /** 528 * Focus a window. 529 * 530 * @see xdo_activate_window 531 * @param wid the window to focus. 532 */ 533 int xdo_focus_window(const xdo_t *xdo, Window wid); 534 535 /** 536 * Raise a window to the top of the window stack. This is also sometimes 537 * termed as bringing the window forward. 538 * 539 * @param wid The window to raise. 540 */ 541 int xdo_raise_window(const xdo_t *xdo, Window wid); 542 543 /** 544 * Get the window currently having focus. 545 * 546 * @param window_ret Pointer to a window where the currently-focused window 547 * will be stored. 548 */ 549 int xdo_get_focused_window(const xdo_t *xdo, Window *window_ret); 550 551 /** 552 * Wait for a window to have or lose focus. 553 * 554 * @param window The window to wait on 555 * @param want_focus If 1, wait for focus. If 0, wait for loss of focus. 556 */ 557 int xdo_wait_for_window_focus(const xdo_t *xdo, Window window, int want_focus); 558 559 /** 560 * Get the PID owning a window. Not all applications support this. 561 * It looks at the _NET_WM_PID property of the window. 562 * 563 * @param window the window to query. 564 * @return the process id or 0 if no pid found. 565 */ 566 int xdo_get_pid_window(const xdo_t *xdo, Window window); 567 568 /** 569 * Like xdo_get_focused_window, but return the first ancestor-or-self window * 570 * having a property of WM_CLASS. This allows you to get the "real" or 571 * top-level-ish window having focus rather than something you may not expect 572 * to be the window having focused. 573 * 574 * @param window_ret Pointer to a window where the currently-focused window 575 * will be stored. 576 */ 577 int xdo_get_focused_window_sane(const xdo_t *xdo, Window *window_ret); 578 579 /** 580 * Activate a window. This is generally a better choice than xdo_focus_window 581 * for a variety of reasons, but it requires window manager support: 582 * - If the window is on another desktop, that desktop is switched to. 583 * - It moves the window forward rather than simply focusing it 584 * 585 * Requires your window manager to support this. 586 * Uses _NET_ACTIVE_WINDOW from the EWMH spec. 587 * 588 * @param wid the window to activate 589 */ 590 int xdo_activate_window(const xdo_t *xdo, Window wid); 591 592 /** 593 * Wait for a window to be active or not active. 594 * 595 * Requires your window manager to support this. 596 * Uses _NET_ACTIVE_WINDOW from the EWMH spec. 597 * 598 * @param window the window to wait on 599 * @param active If 1, wait for active. If 0, wait for inactive. 600 */ 601 int xdo_wait_for_window_active(const xdo_t *xdo, Window window, int active); 602 603 /** 604 * Map a window. This mostly means to make the window visible if it is 605 * not currently mapped. 606 * 607 * @param wid the window to map. 608 */ 609 int xdo_map_window(const xdo_t *xdo, Window wid); 610 611 /** 612 * Unmap a window 613 * 614 * @param wid the window to unmap 615 */ 616 int xdo_unmap_window(const xdo_t *xdo, Window wid); 617 618 /** 619 * Minimize a window. 620 */ 621 int xdo_minimize_window(const xdo_t *xdo, Window wid); 622 623 /** 624 * Reparents a window 625 * 626 * @param wid_source the window to reparent 627 * @param wid_target the new parent window 628 */ 629 int xdo_reparent_window(const xdo_t *xdo, Window wid_source, Window wid_target); 630 631 /** 632 * Get a window's location. 633 * 634 * @param wid the window to query 635 * @param x_ret pointer to int where the X location is stored. If NULL, X is 636 * ignored. 637 * @param y_ret pointer to int where the Y location is stored. If NULL, X is 638 * ignored. 639 * @param screen_ret Pointer to Screen* where the Screen* the window on is 640 * stored. If NULL, this parameter is ignored. 641 */ 642 int xdo_get_window_location(const xdo_t *xdo, Window wid, 643 int *x_ret, int *y_ret, Screen **screen_ret); 644 645 /** 646 * Get a window's size. 647 * 648 * @param wid the window to query 649 * @param width_ret pointer to uint where the width is stored. 650 * @param height_ret pointer to uint where the height is stored. 651 */ 652 int xdo_get_window_size(const xdo_t *xdo, Window wid, uint *width_ret, 653 uint *height_ret); 654 655 /* pager-like behaviors */ 656 657 /** 658 * Get the currently-active window. 659 * Requires your window manager to support this. 660 * Uses _NET_ACTIVE_WINDOW from the EWMH spec. 661 * 662 * @param window_ret Pointer to Window where the active window is stored. 663 */ 664 int xdo_get_active_window(const xdo_t *xdo, Window *window_ret); 665 666 /** 667 * Get a window ID by clicking on it. This function blocks until a selection 668 * is made. 669 * 670 * @param window_ret Pointer to Window where the selected window is stored. 671 */ 672 int xdo_select_window_with_click(const xdo_t *xdo, Window *window_ret); 673 674 /** 675 * Set the number of desktops. 676 * Uses _NET_NUMBER_OF_DESKTOPS of the EWMH spec. 677 * 678 * @param ndesktops the new number of desktops to set. 679 */ 680 int xdo_set_number_of_desktops(const xdo_t *xdo, long ndesktops); 681 682 /** 683 * Get the current number of desktops. 684 * Uses _NET_NUMBER_OF_DESKTOPS of the EWMH spec. 685 * 686 * @param ndesktops pointer to long where the current number of desktops is 687 * stored 688 */ 689 int xdo_get_number_of_desktops(const xdo_t *xdo, long *ndesktops); 690 691 /** 692 * Switch to another desktop. 693 * Uses _NET_CURRENT_DESKTOP of the EWMH spec. 694 * 695 * @param desktop The desktop number to switch to. 696 */ 697 int xdo_set_current_desktop(const xdo_t *xdo, long desktop); 698 699 /** 700 * Get the current desktop. 701 * Uses _NET_CURRENT_DESKTOP of the EWMH spec. 702 * 703 * @param desktop pointer to long where the current desktop number is stored. 704 */ 705 int xdo_get_current_desktop(const xdo_t *xdo, long *desktop); 706 707 /** 708 * Move a window to another desktop 709 * Uses _NET_WM_DESKTOP of the EWMH spec. 710 * 711 * @param wid the window to move 712 * @param desktop the desktop destination for the window 713 */ 714 int xdo_set_desktop_for_window(const xdo_t *xdo, Window wid, long desktop); 715 716 /** 717 * Get the desktop a window is on. 718 * Uses _NET_WM_DESKTOP of the EWMH spec. 719 * 720 * If your desktop does not support _NET_WM_DESKTOP, then '*desktop' remains 721 * unmodified. 722 * 723 * @param wid the window to query 724 * @param deskto pointer to long where the desktop of the window is stored 725 */ 726 int xdo_get_desktop_for_window(const xdo_t *xdo, Window wid, long *desktop); 727 728 /** 729 * Search for windows. 730 * 731 * @param search the search query. 732 * @param windowlist_ret the list of matching windows to return 733 * @param nwindows_ret the number of windows (length of windowlist_ret) 734 * @see xdo_search_t 735 */ 736 int xdo_search_windows(const xdo_t *xdo, const xdo_search_t *search, 737 Window **windowlist_ret, uint *nwindows_ret); 738 739 /** 740 * Generic property fetch. 741 * 742 * @param window the window to query 743 * @param atom the Atom to request 744 * @param nitems the number of items 745 * @param type the type of the return 746 * @param size the size of the type 747 * @return data consisting of 'nitems' items of size 'size' and type 'type' 748 * will need to be cast to the type before using. 749 */ 750 ubyte *xdo_get_window_property_by_atom(const xdo_t *xdo, Window window, Atom atom, 751 long *nitems, Atom *type, int *size); 752 753 /** 754 * Get property of window by name of atom. 755 * 756 * @param window the window to query 757 * @param property the name of the atom 758 * @param nitems the number of items 759 * @param type the type of the return 760 * @param size the size of the type 761 * @return data consisting of 'nitems' items of size 'size' and type 'type' 762 * will need to be cast to the type before using. 763 */ 764 int xdo_get_window_property(const xdo_t *xdo, Window window, const char *property, 765 ubyte **value, long *nitems, Atom *type, int *size); 766 767 /** 768 * Get the current input state. This is a mask value containing any of the 769 * following: ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, 770 * Mod4Mask, or Mod5Mask. 771 * 772 * @return the input mask 773 */ 774 uint xdo_get_input_state(const xdo_t *xdo); 775 776 /** 777 * If you need the symbol map, use this method. 778 * 779 * The symbol map is an array of string pairs mapping common tokens to X Keysym 780 * strings, such as "alt" to "Alt_L" 781 * 782 * @returns array of strings. 783 */ 784 /*const*/ char** xdo_get_symbol_map(); 785 786 /* active modifiers stuff */ 787 788 /** 789 * Get a list of active keys. Uses XQueryKeymap. 790 * 791 * @param keys Pointer to the array of charcodemap_t that will be allocated 792 * by this function. 793 * @param nkeys Pointer to integer where the number of keys will be stored. 794 */ 795 int xdo_get_active_modifiers(const xdo_t *xdo, charcodemap_t **keys, 796 int *nkeys); 797 798 /** 799 * Send any events necessary to clear the active modifiers. 800 * For example, if you are holding 'alt' when xdo_get_active_modifiers is 801 * called, then this method will send a key-up for 'alt' 802 */ 803 int xdo_clear_active_modifiers(const xdo_t *xdo, Window window, 804 charcodemap_t *active_mods, 805 int active_mods_n); 806 807 /** 808 * Send any events necessary to make these modifiers active. 809 * This is useful if you just cleared the active modifiers and then wish 810 * to restore them after. 811 */ 812 int xdo_set_active_modifiers(const xdo_t *xdo, Window window, 813 charcodemap_t *active_mods, 814 int active_mods_n); 815 816 /** 817 * Get the position of the current viewport. 818 * 819 * This is only relevant if your window manager supports 820 * _NET_DESKTOP_VIEWPORT 821 */ 822 int xdo_get_desktop_viewport(const xdo_t *xdo, int *x_ret, int *y_ret); 823 824 /** 825 * Set the position of the current viewport. 826 * 827 * This is only relevant if your window manager supports 828 * _NET_DESKTOP_VIEWPORT 829 */ 830 int xdo_set_desktop_viewport(const xdo_t *xdo, int x, int y); 831 832 /** 833 * Kill a window and the client owning it. 834 * 835 */ 836 int xdo_kill_window(const xdo_t *xdo, Window window); 837 838 /** 839 * Close a window without trying to kill the client. 840 * 841 */ 842 int xdo_close_window(const xdo_t *xdo, Window window); 843 844 /** 845 * Find a client window that is a parent of the window given 846 */ 847 enum XDO_FIND_PARENTS = (0); 848 849 /** 850 * Find a client window that is a child of the window given 851 */ 852 enum XDO_FIND_CHILDREN = (1); 853 854 /** 855 * Find a client window (child) in a given window. Useful if you get the 856 * window manager's decorator window rather than the client window. 857 */ 858 int xdo_find_window_client(const xdo_t *xdo, Window window, Window *window_ret, 859 int direction); 860 861 /** 862 * Get a window's name, if any. 863 * 864 * TODO(sissel): Document 865 */ 866 int xdo_get_window_name(const xdo_t *xdo, Window window, 867 ubyte **name_ret, int *name_len_ret, 868 int *name_type); 869 870 /** 871 * Disable an xdo feature. 872 * 873 * This function is mainly used by libxdo itself, however, you may find it useful 874 * in your own applications. 875 * 876 * @see XDO_FEATURES 877 */ 878 void xdo_disable_feature(xdo_t *xdo, int feature); 879 880 /** 881 * Enable an xdo feature. 882 * 883 * This function is mainly used by libxdo itself, however, you may find it useful 884 * in your own applications. 885 * 886 * @see XDO_FEATURES 887 */ 888 void xdo_enable_feature(xdo_t *xdo, int feature); 889 890 /** 891 * Check if a feature is enabled. 892 * 893 * This function is mainly used by libxdo itself, however, you may find it useful 894 * in your own applications. 895 * 896 * @see XDO_FEATURES 897 */ 898 int xdo_has_feature(xdo_t *xdo, int feature); 899 900 /** 901 * Query the viewport (your display) dimensions 902 * 903 * If Xinerama is active and supported, that api internally is used. 904 * If Xineram is disabled, we will report the root window's dimensions 905 * for the given screen. 906 */ 907 int xdo_get_viewport_dimensions(xdo_t *xdo, uint *width, 908 uint *height, int screen);